Skip to content

Conversation

@spencerkclark
Copy link

This PR adds a hypothesis strategy for drawing cftime objects of any calendar type between the dates of -99999-01-01 and 99999-12-DDT23:59:59.999999 (the maximum day depends on the calendar type).

cc: @dcherian

This is my first time writing a hypothesis strategy, so let me know if you have any tips / suggestions. The core of it is a bit simpler than the strategy for generating standard library datetime.datetime objects. I broke things up into a basic strategy—one that generates datetimes within a certain range—and one specific to the ISO-8601 round-trip test, since I can imagine use-cases where we might want to change the minimum and maximum values and / or have tighter control over the calendar.

@kmuehlbauer
Copy link
Owner

Thanks @spencerkclark for tackling this. Would it make sense to merge this, to see if/how this works in xarray CI?

@spencerkclark
Copy link
Author

Sure, we can give that a try and iterate further from there if needed—at least locally the test passed.

@kmuehlbauer kmuehlbauer merged commit 81d44ef into kmuehlbauer:iso-parser Dec 29, 2024
@spencerkclark spencerkclark deleted the cftime-strategy branch December 30, 2024 16:55
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.

2 participants