I have a big ndimensional array. I want to iterate on it to check whether a condition is locally satisfied. Next snippet explains my problem.
a = np.random.randint(2, size=(60,80,3,3))
test = np.array([[1,0,0],[0,1,0],[0,0,0]])
for i in xrange(a.shape[0]):
for j in xrange(b.shape[1]):
if (a[i,j] == test).all():
# Do something with indices i and j
The code is obviously very slow. I tried using numpy.where but it's not working as it looks for equality at each of the four indices.
EDIT: I do also need to store the indices (i,j) which satisfy the condition