bundles / numpy 2.4.3 / numpy / ma / extras / unique
function
numpy.ma.extras:unique
source: /numpy/ma/extras.py:1267
Signature
def unique(ar1, return_index = False, return_inverse = False)Summary
Finds the unique elements of an array.
Extended Summary
Masked values are considered the same element (masked). The output array is always a masked array. See numpy.unique for more details.
Examples
import numpy as np a = [1, 2, 1000, 2, 3] mask = [0, 0, 1, 0, 0] masked_a = np.ma.masked_array(a, mask)✓
masked_a np.ma.unique(masked_a) np.ma.unique(masked_a, return_index=True) np.ma.unique(masked_a, return_inverse=True) np.ma.unique(masked_a, return_index=True, return_inverse=True)✗
(masked_array(data=[1, 2, 3, --],
mask=[False, False, False, True],
fill_value=999999), array([0, 1, 4, 2]), array([0, 1, 3, 1, 2]))
See also
- numpy.unique
Equivalent function for ndarrays.
Aliases
numpy.ma.unique