cf.Data.unique¶
-
Data.
unique
(split_every=None)[source]¶ The unique elements of the data.
Returns the sorted unique elements of the array.
- Parameters
- split_every:
int
ordict
, optional Determines the depth of the recursive aggregation. If set to or more than the number of input chunks, the aggregation will be performed in two steps, one partial collapse per input chunk and a single aggregation at the end. If set to less than that, an intermediate aggregation step will be used, so that any of the intermediate or final aggregation steps operates on no more than
split_every
inputs. The depth of the aggregation graph will be \(log_{split_every}(input chunks along reduced axes)\). Setting to a low value can reduce cache size and network transfers, at the cost of more CPU and a larger dask graph.By default,
dask
heuristically decides on a good value. A default can also be set globally with thesplit_every
key indask.config
. Seedask.array.reduction
for details.
- split_every:
- Returns
Data
The unique values in a 1-d array.
Examples
>>> d = cf.Data([[4, 2, 1], [1, 2, 3]], 'metre') >>> print(d.array) [[4 2 1] [1 2 3]] >>> e = d.unique() >>> e <CF Data(4): [1, ..., 4] metre> >>> print(e.array) [1 2 3 4] >>> d[0, 0] = cf.masked >>> print(d.array) [[-- 2 1] [1 2 3]] >>> e = d.unique() >>> print(e.array) [1 2 3 --]