[Numpy-discussion] How do I do this?

Alan G Isaac aisaac@american....
Sat Aug 30 08:05:52 CDT 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))


More information about the Numpy-discussion mailing list