Say I have a numpy array as follows:
arr = np.array([[[1, 7], [5, 1]], [[5, 7], [6, 7]]])
where each of the innermost sub-arrays is an element. So for example; [1, 7] and [5, 1] are both considered elements.
... and I would like to find all the elements which satisfy: [<=5, >=7]. So, a truthy result array for the above example would look as follows:
arr_truthy = [[True, False], [True, False]]
... as for one of the bottom elements in arr the first value is <=5 and the second is >=7.
I can solve this easily by iterating over each of the axes in arr:
for x in range(arr.shape[0]):
for y in range(arr.shape[1]):
# test values, report if true.
.. but this method is slow and I'm hoping there's a more numpy way to do it. I've tried np.where but I can't work out how to do the multi sub-element conditional.
I'm effectively trying to test an independent conditional on each number in the elements.
Can anyone point me in the right direction?