2008/8/29 Christopher Barker <[EMAIL PROTECTED]>: > How can I do this without another line of code special casing the 0, > which isn't that big I deal, but it seems kind of ugly... > > >>> a[a==0] = min_value > >>> np.sign(a) * np.maximum(np.abs(a), min_value) > array([ 2, 2, 2, 3, 4, -5])
Maybe (np.sign(a) | 1) * np.maximum(np.abs(a), min_value) is a little bit easier on the eye. Cheers Stéfan _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
