NCAS-CMS / cf-python

A CF-compliant Earth Science data analysis library
http://ncas-cms.github.io/cf-python
MIT License
120 stars 19 forks source link

`cf.Field.match_by_construct` always returns `True` for 1-d constructs whose axis is not in the data #691

Closed davidhassell closed 12 months ago

davidhassell commented 1 year ago

At v3.15.3, cf.Field.match_by_construct always returns True when matching against a size 1 construct that whose domain axis is not spanned by the field's data array, regardless of the condition:

>>> import cf
>>> f = cf.example_field(0)
>>> print(f)
Field: specific_humidity (ncvar%q)
----------------------------------
Data            : specific_humidity(latitude(5), longitude(8)) 1
Cell methods    : area: mean
Dimension coords: latitude(5) = [-75.0, ..., 75.0] degrees_north
                : longitude(8) = [22.5, ..., 337.5] degrees_east
                : time(1) = [2019-01-01 00:00:00]

>>> f.match_by_construct(time=cf.dt('2019-01-01'))
True
>>> f.match_by_construct(time=cf.dt('1959-12-16'))
True