On Sat, Aug 30, 2008 at 7:29 AM, Keith Goodman <[EMAIL PROTECTED]> wrote: > On Sat, Aug 30, 2008 at 6:24 AM, Alan G Isaac <[EMAIL PROTECTED]> wrote: >> Stéfan van der Walt wrote: >>> (np.sign(a) | 1) ... >> >> Ah, that's nice. How about >> idx = np.abs(a)<min_value >> a[idx] = min_value*(np.sign(a[idx]) | 1) > > Or, since he asked to do it in one line, > >>> min_value = 2 >>> x > array([ 1, 2, -5, -1, 0]) >>> np.sign(x | 1) * np.maximum(np.abs(x), min_value) > array([ 2, 2, -5, -2, 2])
Why did I send that? Sorry. I saw Stéfan's (np.sign(a) | 1), plugged it in and sent it. But Stéfan already did that. An automated 5 minute delay on sending numpy email would cut the email you get from me in half. _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
