Implementation of rust based cftime #8322
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in #8302, here is a first attempt to implement
cftime_rs
.There are a lot of tests and I struggle to understand all the processing in
coding/times.py
.However, with this first attempt I've been able to make the
test_cf_datetime
work (ignoring one test)xarray/xarray/tests/test_coding_times.py
Lines 127 to 131 in 8423f2c
Also there are some key differences betwwen
cftime
andcftime-rs
:cftime-rs
will not overflow as soon asnumpy
,python
orcftime
. It can go from -291,672,107,014 BC to 291,672,107,014 AD approximately and this depends on calendar.only_use_python_datetimes
argument. Instead there are 4 distinct functions :PyCFDatetime
Finally, and regardless of this PR, I guess there could be a speed improvement by vectorizing operations by replacing this :
xarray/xarray/coding/times.py
Lines 622 to 649 in df0ddaf
by something like this :
xarray/xarray/coding/times.py
Lines 631 to 670 in 8423f2c
We can use numpy instead of list comprehensions. It takes a bit more of memory though.