Python - Checking for common cooardinate between 3D ndarray and 2D ndarray without using loops! (Numpy)
Im trying to solve a problem in which I am given 2 ndarray of booleans . one of shape (n,m,z), denote as A, and the other (n,m), denote as B. If I am thinking of the 3D array as an array of 'z' 2D arrays, I would like to check if for every i between 0 and z, there is at least one coordinate [x,y] that: A[x,y,i] == B[x,y] == 1.
for example: let A be
np.array([[[1,0,0],
[0,1,0],
[0,0,1]]
,
[[0,1,0],
[0,1,0],
[0,1,0]],
[[1,0,0],
[0,1,0],
[0,0,1]]])
and B be:
> [[1,0,0],
[0,1,0],
[0,0,1]])
The function should return True!
I need to solve it without any loops (just numpy tools)!
Thank you in advance.
source https://stackoverflow.com/questions/72071507/python-checking-for-common-cooardinate-between-3d-ndarray-and-2d-ndarray-witho
Comments
Post a Comment