# pulse2percept.utils.array¶

is_strictly_increasing, sample, unique, radial_mask

Functions

 is_strictly_increasing(arr[, tol]) radial_mask(shape[, mask, sd]) sample(sequence[, k]) Randomly selects k elements from a sequence unique(a[, tol, return_index]) Find the unique elements of a sorted 1D array
pulse2percept.utils.array.sample(sequence, k=1)[source]

Randomly selects k elements from a sequence

New in version 0.8.

Parameters: sequence (list, tuple, np.ndarray) – A sequence like a list, a tuple, an array, etc. k (int or float, optional) – If an integer, the number of elements to pick If a float between 0 and 1, the fraction of elements to pick sample (list) – List of randomly chosen elements from the sequence
pulse2percept.utils.array.unique(a, tol=1e-06, return_index=False)[source]

Find the unique elements of a sorted 1D array

Special case of numpy.unique (array is flat, sortened) with a tolerance level tol.

New in version 0.7.

Parameters: a (array_like) – Input array: must be sorted, and will be flattened if it is not already 1-D. tol (float, optional) – If the difference between two elements in the array is smaller than tol, the two elements are considered equal. return_index (bool, optional) – If True, also return the indices of a that result in the unique array. unique (ndarray) – The sorted unique values unique_indices (ndarray, optional) – The indices of the first occurrences of the unique values in the original array. Only provided if return_index is True.