Skip to content

Align long time interval check with cftime #274

@trexfeathers

Description

@trexfeathers

We currently blanket disallow month or year intervals when passing operations down to cftime:

cf-units/cf_units/__init__.py

Lines 1932 to 1939 in 37c8400

# `cftime` cannot parse long time intervals ("months" or "years").
if self.is_long_time_interval():
interval = self.origin.split(" ")[0]
emsg = (
'Time units with interval of "months", "years" '
'(or singular of these) cannot be processed, got "{!s}".'
)
raise ValueError(emsg.format(interval))

cftime disallows these intervals, presumably because it requires consistent-length time increments. But cftime is more intelligent about this than cf-units is, e.g. month intervals are allowed for 360_day calendars (Unidata/cftime#75).

We should make sure our own checks don't cover over details like the 360_day exception. The Pythonic choice would be to do no extra checks at all in cf-units, simply relying on cftime to raise the appropriate error; is there a good reason why we don't do this?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions