[Numpy-discussion] How do I do this?

Alan G Isaac aisaac at american.edu
Sat Aug 30 09:05:52 EDT 2008


Christopher Barker wrote:
> 0 should go to 2 --it's not, because sign(0) == 0, so the 2 gets turned 
> to zero, my original problem. 

Odd asymmetry. Then you can use Keith's version. Or

a[idx] = min_value*(np.sign(a[idx]) + (a[idx]==0))

Alan





More information about the NumPy-Discussion mailing list