How to xor all elements of a boolean numpy array using vectorized methods: i.e. a_1 xor a_2 xor ... xor a_n ?
a_1 xor a_2 xor ... xor a_n
I would rather use xor ufunc, I think that bitwise_xor (or logical_xor ):
bitwise_xor
logical_xor
np.bitwise_xor.reduce(a)
or
np.logical_xor.reduce(a)
One benefit is that you don't get bogus things to float.
Probably most efficient to use sum :
sum
np.sum(arr) % 2