unique#
- class brainunit.math.unique(a, return_index=False, return_inverse=False, return_counts=False, axis=None, *, equal_nan=False, size=None, fill_value=None, **kwargs)#
Find the unique elements of a quantity or an array.
- Parameters:
a (array_like, Quantity) – Input array.
return_index (bool, optional) – If True, also return the indices of a (along the specified axis, if provided) that result in the unique array.
return_inverse (bool, optional) – If True, also return the indices of the unique array (for the specified axis, if provided) that can be used to reconstruct a.
return_counts (bool, optional) – If True, also return the number of times each unique item appears in a.
axis (int, optional) – The axis along which to operate. If None, the array is flattened before use. Default is None.
equal_nan (bool, optional) – Whether to compare NaN’s as equal. If True, NaN’s in a will be considered equal to each other in the unique array.
size (int, optional) – The length of the output array. If size is not None, the output array will have the length of size.
fill_value (scalar, optional) – The value to use for missing values. If fill_value is not None, the output array will have the length of size.
- Returns:
res – The sorted unique values.
- Return type:
ndarray, Quantity
Examples
>>> import saiunit as u >>> a = [0, 1, 2, 1, 0] * u.second >>> u.math.unique(a)