J'e
J'e

Reputation: 3706

numpy: bitwise and on array

I'm trying to do an "&" operation across all the values in a simple bool array. The array I have is as follows:

array([False False True], dtype=bool) 

The only thing I've come up with is to slice out the values in the array and use "&" to give a "False" result. I feel like there must be a better way but I don't know enough about numpy to use it properly.

Upvotes: 3

Views: 1936

Answers (1)

shx2
shx2

Reputation: 64298

Use arr.all(), which is the same as np.all(arr):

import numpy as np
arr = np.array([False, False, True], dtype=bool) 
arr.all()
=> False
np.all(arr)
=> False

Upvotes: 2

Related Questions