cf.Data.all¶
-
Data.
all
(axis=None, keepdims=True, split_every=None)[source]¶ Test whether all data array elements evaluate to True.
- Parameters
- axis: (sequence of)
int
, optional Axis or axes along which a logical AND reduction is performed. The default (
None
) is to perform a logical AND over all the dimensions of the input array. axis may be negative, in which case it counts from the last to the first axis.- keepdims:
bool
, optional By default, the axes which are collapsed are left in the result as dimensions with size one, so that the result will broadcast correctly against the input array. If set to False then collapsed axes are removed from the data.
- 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.
- axis: (sequence of)
- Returns
Data
Whether or not all data array elements evaluate to True.
Examples
>>> d = cf.Data([[1, 2], [3, 4]]) >>> d.all() <CF Data(1, 1): [[True]]> >>> d.all(keepdims=False) <CF Data(1, 1): True> >>> d.all(axis=0) <CF Data(1, 2): [[True, True]]> >>> d.all(axis=1) <CF Data(2, 1): [[True, True]]> >>> d.all(axis=()) <CF Data(2, 2): [[True, ..., True]]>
>>> d[0] = cf.masked >>> d[1, 0] = 0 >>> print(d.array) [[-- --] [0 4]] >>> d.all(axis=0) <CF Data(1, 2): [[False, True]]> >>> d.all(axis=1) <CF Data(2, 1): [[--, False]]>
>>> d[...] = cf.masked >>> d.all() <CF Data(1, 1): [[--]]> >>> bool(d.all()) True >>> bool(d.all(keepdims=False)) False