They're the bitwise operators, not the logical ones. So they correspond to bitwise_or() and bitwise_and().
On Sun, 27 Sept 2026 at 14:09, zhong.ann--- via NumPy-Discussion < [email protected]> wrote: > Hi, I would like to report weird behaviours of the logical operands "|" > and "&" when interacting with Numpy.Arrays of integer and boolean elements. > I have observed that if we put "|" or "&" between a Numpy.Array of > integers and a Numpy.Array of booleans, "|" would increase the non-zero > even integers by 1 in the returned output, while "&" would treat the > non-zero even integers as 0 and return 0 for them. > For example: numpy.array([-2, -1, 0, 1, 2, 3, 4]) | numpy.array([True]) > would generate result as array([-1, -1, 1, 1, 3, 3, 5]). > numpy.array([-2, -1, 0, 1, 2, 3, 4]) & numpy.array([True]) would generate > result as array([0, 1, 0, 1, 0, 1, 0]) . > According to the numpy user guide, the operands "|" and "&" are equivalent > to logical_or() and logical_and() respectively, but in fact logical_or() > and logical_and() return an array of boolean values when given both an > array of integer and an array of boolean as input. > Note that the logical operands "|" and "&" are not supported by python > built-in array.array to work between an array of integer and an array of > boolean. > Could you please advise if these logical operands should be supported to > operate on an array of integer and an array of boolean? If they should, > what would be the expected behaviours? Thank you. > _______________________________________________ > NumPy-Discussion mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3//lists/numpy-discussion.python.org > Member address: [email protected] >
_______________________________________________ NumPy-Discussion mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/numpy-discussion.python.org Member address: [email protected]
