On Fri, Aug 29, 2008 at 3:08 PM, Christopher Barker <[EMAIL PROTECTED]> wrote: > Alan G Isaac wrote: >> Does this do what you want? >> idx = np.abs(a)<min_value >> a[idx] = min_value > > yup, that's it. I had forgotten about that kind of indexing, even though > I used it for: a[a==0] = min_value > > Keith Goodman wrote: >> If you only have integers then >> >>>> x >> array([ 1, 2, -5, -1, 0]) >>>> np.sign(x+1e-16) * np.maximum(np.abs(x), 2) >> array([ 2., 2., -5., -2., 2.]) > > that would work, though I like Alan's better.
I thought -1 should go to -2. If not, then my attempt doesn't work. _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
