Skip to content

Ignore infinite offsets in the standard-calendar cftime range check - #11994

Open
mahdi-taghi wants to merge 1 commit into
pydata:mainfrom
mahdi-taghi:fix/cftime-infinite-range-11988
Open

mahdi-taghi wants to merge 1 commit into
pydata:mainfrom
mahdi-taghi:fix/cftime-infinite-range-11988

Conversation

@mahdi-taghi

@mahdi-taghi mahdi-taghi commented Dec 5, 2026 •

Copy link
Copy Markdown

Description

With msecs since 2000-01-01, a -inf offset next to a valid date in year 1600 can make decode_cf raise an overflow. The range check picks -inf as the minimum and uses the reference date under its mask, so it tries to fit the year-1600 date into datetime64[ns].

Use the finite offsets for the range check. When a chunked array needs cftime, decode each chunk into that representation so Dask can combine the chunks without changing the dates. If sampling misses an out-of-range date, report the mismatch before combining the chunks.

The tests cover dates on both sides of the NumPy range, chunking before and after decoding, opening a NetCDF file with chunks, and preserving existing missing values in mixed chunks.

Checklist

AI Disclosure

  • This PR contains AI-assisted code and tests.
  • The changes were tested locally.
  • I have completed a personal review of the diff and take responsibility for these changes.

AI assistance was used to reproduce the range error, implement the fix, and test the NumPy and Dask paths.

@mahdi-taghi
mahdi-taghi marked this pull request as ready for review December 5, 2026 11:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant