Reputation: 3745
This answer is what I'm looking for, but since boolean subtraction has been depreciated it no longer works. Is there a better way?
A = np.array([[-2, -1, 1],
[-1, 0, 1],
[-1, 1, 2]], dtype=float)
zcs = np.diff(np.signbit(A), axis=1) # find zero crossings in each row - now fails
generates:
Traceback (most recent call last):
File "/Users/david/Documents/wow.py", line 4, in <module>
zcs = np.diff(np.signbit(A), axis=1) # now fails
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/function_base.py", line 1926, in diff
return a[slice1]-a[slice2]
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead.
Upvotes: 0
Views: 355
Reputation: 14399
This is apparently fixed in 1.14.0, but as a quick fix explicit type casting:
zcs = np.diff(np.signbit(A).astype(int), axis=1)
should work.
Upvotes: 1