Skip to content

Enhance and move ISO-8601 parser to coding.times - #9899

Merged
dcherian merged 21 commits into
pydata:mainfrom
kmuehlbauer:iso-parser
Dec 31, 2024
Merged

Enhance and move ISO-8601 parser to coding.times#9899
dcherian merged 21 commits into
pydata:mainfrom
kmuehlbauer:iso-parser

Conversation

@kmuehlbauer

@kmuehlbauerkmuehlbauer commented Dec 17, 2024

Copy link
Copy Markdown
Contributor

This enhances the ISO-8601 parser to check for signed years (eg, -0300 or +0010) as well as 5 digit years (eg. -10000, +20000, 10000). The relevant parsing code is moved to coding.times (to prevent circular import) as these functionality will be used in #9618 within coding.times.

  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst

@kmuehlbauer
kmuehlbauer marked this pull request as ready for review December 17, 2024 11:01
Comment threadxarray/tests/test_cftimeindex.py Outdated
Comment threadxarray/tests/test_cftimeindex.py Outdated
Comment threadproperties/test_encode_decode.py
Comment threadxarray/tests/test_cftimeindex.py Outdated
kmuehlbauerand others added 3 commits December 17, 2024 17:06
Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
@kmuehlbauer

Copy link
Copy Markdown
ContributorAuthor

@dcherian Thanks for the review, I've addressed according your comments and suggestions.

@spencerkclarkspencerkclark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kmuehlbauer—this looks nice. I guess so long as we accept a flexible number of digits in the year it will be hard to extend beyond five-digit years, which is totally fine for now.

Per @dcherian's TODO, I tried my hand at adding a hypothesis strategy for generating cftime objects in kmuehlbauer#2.

Comment threadxarray/tests/test_cftimeindex.py Outdated
Comment threaddoc/whats-new.rst Outdated
kmuehlbauerand others added 2 commits December 29, 2024 13:55
Co-authored-by: Spencer Clark <spencerkclark@gmail.com>
Comment threaddoc/whats-new.rst Outdated
@spencerkclarkspencerkclark added the run-slow-hypothesis Run slow hypothesis tests label Dec 29, 2024

@headtr1ckheadtr1ck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take the opportunity and add some typing.

But looks good, thanks.

Comment threadxarray/coding/times.py Outdated
Comment threadxarray/coding/times.py Outdated
Comment threadxarray/tests/test_cftimeindex.py Outdated
Comment threadxarray/coding/times.py Outdated
Comment threadxarray/coding/times.py Outdated
Comment threadxarray/coding/times.py Outdated
Comment threadxarray/coding/times.py Outdated
Comment threadxarray/coding/cftimeindex.py
@kmuehlbauer

Copy link
Copy Markdown
ContributorAuthor

Let's take the opportunity and add some typing.

Thanks @headtr1ck for the review and typing addendum.

@kmuehlbauer

Copy link
Copy Markdown
ContributorAuthor

Per @dcherian's TODO, I tried my hand at adding a hypothesis strategy for generating cftime objects in kmuehlbauer#2.

Thanks @spencerkclark for reviewing and the additions!

@spencerkclarkspencerkclark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kmuehlbauer! Though it passes CI, I'm happy to iterate further on the hypothesis portion in this or a follow-up PR if needed. It's fairly low-stakes / orthogonal to the main contribution.

return self.min_value + datetime.timedelta(microseconds=result)


class CFTimeStrategyISO8601(st.SearchStrategy):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spencerkclark very nice!

I think the idiomatic way is to use composite but we can do that later.

@dcherian
dcherian merged commit b14080e into pydata:mainDec 31, 2024
@kmuehlbauer
kmuehlbauer deleted the iso-parser branch January 2, 2025 16:17
dcherian added a commit to dcherian/xarray that referenced this pull request Mar 19, 2025
* main: (63 commits)
Fix zarr upstream tests (pydata#9927)
Update pre-commit hooks (pydata#9925)
split out CFDatetimeCoder, deprecate use_cftime as kwarg (pydata#9901)
dev whats-new (pydata#9923)
Whats-new 2025.01.0 (pydata#9919)
Silence upstream Zarr warnings (pydata#9920)
time coding refactor (pydata#9906)
fix warning from scipy backend guess_can_open on directory (pydata#9911)
Enhance and move ISO-8601 parser to coding.times (pydata#9899)
Edit serialization error message (pydata#9916)
friendlier error messages for missing chunk managers (pydata#9676)
Bump codecov/codecov-action from 5.1.1 to 5.1.2 in the actions group (pydata#9915)
Rewrite interp to use `apply_ufunc` (pydata#9881)
Skip dask rolling (pydata#9909)
Explicitly configure ReadTheDocs build to use conf.py (pydata#9908)
Cache pre-existing Zarr arrays in Zarr backend (pydata#9861)
Optimize idxmin, idxmax with dask (pydata#9800)
remove unused "type: ignore" comments in test_plot.py (fixed in matplotlib 3.10.0) (pydata#9904)
move scalar-handling logic into `possibly_convert_objects` (pydata#9900)
Add missing DataTree attributes to docs (pydata#9876)
...
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-slow-hypothesisRun slow hypothesis tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@kmuehlbauer@dcherian@spencerkclark@headtr1ck