I had a Masked array and a Numpy boolean array containing 3 dimensional values. However when I used indexing of numpy array inside masked array it led to loss of dimensions. I couldn't figure out the reason:
Masked_array = [[[--, 1, --],
[--, 1, --],
[--, 1, --]]]
Running this line gave me
masked_array = masked_array.mask
mm = ~np.logical_and.accumulate(masked_array)
list(masked_array[mm])
the output as [1, 1, 1]
instead of [[1] [1] [1]]
I couldnt understand the error and tried various methods.
Could you please help me in clarifying the doubt. Thanks
accumulatemask to the array. Boolean indexing of a numpy array flattens the result. You get to do your ownreshapeif you think the results make sense as 2d.numpydoes not make any such assumptions for you.