3D numpy array subset

Oscar Benjamin oscar.j.benjamin at gmail.com
Wed Dec 9 15:20:20 EST 2015


On 9 Dec 2015 14:26, "Heli" <hemla21 at gmail.com> wrote:
>
> Dear all,
>
> I am reading a dataset from a HDF5 file using h5py. my datasets are 3D.
>
> Then I will need to check if another 3d numpy array is a subset of this
3D array i am reading from the file.
>
> In general, is there any way to check if two 3d numpy arrays have
intersections and if so, get the indices of the intersection area.
>
> By intersection, I exactly mean the intersection definition used in set
theory.

Does this help:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.intersect1d.html

I'm not sure how the 3d part is relevant but that function finds the common
elements of two arrays. Use .flat or something to make the 3d arrays be
treated as 1d. Otherwise it's not clear what you mean by intersection.

--
Oscar



More information about the Python-list mailing list