cfdm.Constructs.filter_by_connectivity¶
-
Constructs.
filter_by_connectivity
(*connectivities, todict=False, cached=None)[source]¶ Select cell connectivity constructs by connectivity type.
New in version (cfdm): 1.11.0.0
See also
filter
,filters_applied
,inverse_filter
,clear_filters_applied
,unfilter
- Parameters
- connectivities: optional
Select cell connectivity constructs that have a connectivity type, defined by their
get_connectivity
methods, that matches any of the given values.If no connectivities are provided then all cell connectivity constructs are selected.
A value may be any object that can match via the
==
operator, or are.Pattern
object that matches via itssearch
method.- 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.- cached: optional
If any value other than
None
then return cached without selecting any constructs.
- Returns
Constructs
ordict
or cachedThe selected cell connectivity constructs, or a cached value.
Examples
>>> print(t.constructs.filter_by_type('cell_connectivity') Constructs: {'cellconnectivity0': <CellConnectivity: connectivity:edge(13824) >, 'cellconnectivity1': <CellConnectivity: connectivity:node(13824) >}
Select cell connectivity constructs that have a connectivity type of “edge”:
>>> print(c.filter_by_connectivity('edge') Constructs: {'cellconnectivity0': <CellConnectivity: connectivity:edge(13824) >,
Select cell connectivity constructs that have a connectivity type of ‘edge’ or ‘node’:
>>> print(c.filter_by_connectivity('edge', 'node') Constructs: {'cellconnectivity0': <CellConnectivity: connectivity:edge(13824) >, 'cellconnectivity1': <CellConnectivity: connectivity:node(13824) >}
Select cell connectivity constructs that have a connectivity type that starts with “n”:
>>> print(c.filter_by_connectivity(re.compile('^n'))) Constructs: {'cellconnectivity1': <CellConnectivity: connectivity:node(13824) >}
Select cell connectivity constructs that have a connectivity type of any value:
>>> print(c.filter_by_connectivity()) Constructs: {'cellconnectivity0': <CellConnectivity: connectivity:edge(13824) >, 'cellconnectivity1': <CellConnectivity: connectivity:node(13824) >}