cfdm.Constructs.filter_by_size

Constructs.filter_by_size(*sizes, todict=False, cached=None)[source]

Select domain axis constructs by size.

New in version (cfdm): 1.7.3

Parameters
sizes: optional

Select domain axis constructs that have sizes, defined by their get_size methods, that match any of the given values.

If no sizes are provided then all domain axis constructs are selected.

A value may be any object that can match an integer via ==.

todict: bool, optional

If True then return a dictionary of constructs keyed by their construct identifiers, instead of a Constructs object. This is a faster option.

New in version (cfdm): 1.8.9.0

cached: optional

If any value other than None then return cached without selecting any constructs.

New in version (cfdm): 1.8.9.0

Returns
Constructs or dict or cached

The selected constructs, or a cached valued.

Examples

Select domain axis constructs that have a size of 1:

>>> d = c.filter_by_size(1)

Select domain axis constructs that have a size of 1 or 96:

>>> d = c.filter_by_size(1, 96)