Skip to content

New ignore_properties keyword to cf.unique_constructs #597

@davidhassell

Description

@davidhassell

It would be useful to allow cf.unique_constructs to ignore selected properties when assessing equality of input constructs. For example, two Field constructs may differ only by a timestamp within their "history" properties, and this may be of no concern. This would look like:

>>> import cf
>>> f = cf.example_field(0)
>>> f2 = f.copy()
>>> f.set_property('foo', 'bar')
>>> f2.set_property('foo', 'bar2')
>>> cf.unique_constructs([f, f2]) 
[<Field: specific_humidity(latitude(5), longitude(8)) 1>,
 <Field: specific_humidity(latitude(5), longitude(8)) 1>]
>>> cf.unique_constructs([f, f2], ignore_properties='foo')
[<Field: specific_humidity(latitude(5), longitude(8)) 1>]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions