mcmodels.utils.nonzero_unique

mcmodels.utils.nonzero_unique(ar, **unique_kwargs)[source]

np.unique returning only nonzero unique elements.

Parameters:
ar : array_like

Input array. Unless axis is specified, this will be flattened if it is not already 1-D.

return_index : bool, optional

If True, also return the indices of ar (along the specified axis, if provided, or in the flattened array) that result in the unique array.

return_counts : bool, optional

If True, also return the number of times each unique item appears in ar.

axis : int or None, optional

The axis to operate on. If None, ar will be flattened beforehand. Otherwise, duplicate items will be removed along the provided axis, with all the other axes belonging to the each of the unique elements. Object arrays or structured arrays that contain objects are not supported if the axis kwarg is used.

Returns:
unique : array

Unique values sorted in the order in which they occur

unique_indices : array, optional

Indices of the first occurance of the unique values. Only returned if return_indices kwarg is specified as True.

unique_counts : array

Counts of the unique values. Only returned if return_counts kwarg is specified as True.