Closed
Description
Describe the issue:
np.unique seems to ignore MaskedArray mask when axis is not None, and returns a regular np.ndarray instead of a MaskedArray. In the code example below, the output is
<class 'numpy.ma.core.MaskedArray'> [1 2 3 --]
<class 'numpy.ndarray'> [1 2 3 4]
but one should instead expect
<class 'numpy.ma.core.MaskedArray'> [1 2 3 --]
<class 'numpy.ma.core.MaskedArray'> [1 2 3 --]
Reproduce the code example:
import numpy as np
import numpy.ma as ma
a = ma.array([1,2,3,4,2,3,1,4], mask=[0,0,1,1,0,0,0,1])
out = np.unique(a)
print(type(out), out)
out = np.unique(a, axis=0)
print(type(out), out)
Error message:
No response
Runtime information:
1.24.2
3.9.13 (main, Oct 13 2022, 16:12:19)
[Clang 12.0.0 ]
WARNING: threadpoolctl
not found in system! Install it by pip install threadpoolctl
. Once installed, try np.show_runtime
again for more detailed build information
[{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP', 'ASIMDDP'],
'not_found': ['ASIMDFHM']}}]
None
Context for the issue:
I need to find unique rows in a 2D MaskedArray.