Wed Sep 2 11:11:08 CDT 2009
I know I am splitting the hair, but should not
np.bitwise_and.identity be -1 instead of 1?
I mean, something with all the bits set?
I am checking whether all elements of a vector 'v'
have a certain bit 'b' set:
if np.bitwise_and.reduce(v) & (1 << b):
# do something
If v is empty, the expression is true for b==0 and
In fact np.bitwise_and.identity is 1.
I like being able to use np.bitwise_and.reduce
because it many times faster than (v & (1 << b)).all()
(it does not create the temporary vector).
Of course there are workarounds but I was wondering
if there is a reason for this behaviour.
More information about the NumPy-Discussion