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]) _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
