Skip to content

Change constructs access API for consistency #204

@davidhassell

Description

@davidhassell

This enhancements imports changes from cfdm v1.8.9.0: NCAS-CMS/cfdm#132 by making the *identity, **filter_kwargs API available to construct selection methods:

>>> import cf
>>> f = cf.example_field(1)
>>> f.domain_axes(filter_by_size=(cf.gt(1),))
<CF Constructs: domain_axis(2)>
>>> f.dimension_coordinates('X', 'Y')
<CF Constructs: dimension_coordinate(2)>
>>> f.coordinates('X', 'Y')
<CF Constructs: auxiliary_coordinate(2), dimension_coordinate(2)>
>>> f.coordinates('X', 'Y', filter_by_naxes=(1,))
<CF Constructs: dimension_coordinate(2)>

Consequences

The only possibly bad effect that this could have is for the default argument to be consumed by the *identity arguments if it is given as a positional parameter. For example, to Specify a default of None:

>>> f.construct('altitude', None)  # ok at v3.8.0
>>> f.construct('altitude', None)  # NOT ok with proposed change
>>> f.construct('altitude', default=None)  # ok with proposed change and at v3.8.0

Regardless of this potential for code breaking, I think this change will be beneficial.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestperformanceRelating to speed and memory performance

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions