-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement cftime vectorization as discussed in PR #8322 #8324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement cftime vectorization as discussed in PR #8322 #8324
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antscloud Nice catch! I have two suggestion to get the test suite running.
@antscloud are you willing to continue this? It would be a good addition. |
cff06d4
to
f28fc7d
Compare
Hi, sorry i completely forgot about this issue, i've implemented the suggestions and all the tests appear to pass, I hope it works in the CI 🤞 |
I didn't check in detail if we have a test that might cover this already and if yes, what the changes are. |
I don't think we currently do, but I think this new benchmark should cover it: #9262. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @antscloud! I think this looks good to me now. Could you add a what's new entry under a new Performance
heading?
3 times faster, not bad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
xarray/coding/times.py
Outdated
dates = np.atleast_1d(dates) | ||
|
||
# Find all the None position | ||
none_position = np.equal(dates, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy complains here.
Not sure if this is an issue of wrong typing of numpy, or if this is not a recommended way of calling equals. (I think the None is the problem).
Co-authored-by: Michael Niklas <[email protected]>
The mypy error is still there, not sure how to effectively fix it, maybe use kwargs instead or simply type ignore it. Otherwise this looks good and should get an entry in whats-new! |
Thanks @antscloud! Still a valuable addition, which should be mentioned in |
Great, either I messed up the merge or this fails now, because of other concurring changes in the past time. @spencerkclark Do you spot anything suspicious here? |
Thanks @kmuehlbauer for reviving this—I think the test failures are a manifestation of the cftime issue you found earlier (Unidata/cftime#354). The difference here from what was implemented in #9618 is that While the issue was fixed in Unidata/cftime#355, a new version of cftime has not yet been released. We could lobby for that, or raise an error in these circumstances. Independent of the cftime issue, there may be a reasonable case for raising (#10352). |
@spencerkclark Looks like this works after merging #10352. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @antscloud! Sorry this took so long to push through. I went ahead and added a what's new entry on your behalf. Feel free to edit as you see fit, but otherwise I will merge on Thursday.
@kmuehlbauer I'm guessing you approve now, but giving you the chance to take another look and remove your requested change (which I think is resolved). |
The benchmark workflow failure is unrelated, so I am going to go ahead and merge. Thanks again @antscloud! |
* main: Fix performance regression in interp from pydata#9881 (pydata#10370) html repr: improve style for dropdown sections (pydata#10354) Grouper tweaks. (pydata#10362) Docs: Add links to getting help mermaid diagram (pydata#10324) Enforce ruff/flynt rules (FLY) (pydata#10375) Add missing AbstractWritableDataStore base methods and arguments (pydata#10343) Improve html repr in dark mode (Jupyterlab + Xarray docs) (pydata#10353) Pin Mypy to 1.15 (pydata#10378) use numpy dtype exposed by zarr array instead of metadata.data_type (pydata#10348) Fix doc typo for caption "Interoperability" (pydata#10374) Implement cftime vectorization as discussed in PR pydata#8322 (pydata#8324) Enforce ruff/flake8-pyi rules (PYI) (pydata#10359) Apply assorted ruff/Pylint rules (PL) / Enforce PLE rules (pydata#10366) (fix): pandas extension array repr for int64[pyarrow] (pydata#10317) Enforce ruff/flake8-implicit-str-concat rules (ISC) (pydata#10368) Enforce ruff/refurb rules (FURB) (pydata#10367) Ignore ruff/Pyflakes rule F401 more precisely (pydata#10369) Apply assorted ruff/flake8-simplify rules (SIM) (pydata#10364) Apply assorted ruff/flake8-pytest-style rules (PT) (pydata#10363) Fix "a array" misspelling (pydata#10365)
As discussed in #8322, here is the test for implementing the vectorization
Only this test seems to fail in
test_coding_times.py
:xarray/xarray/tests/test_coding_times.py
Lines 1061 to 1071 in f895dc1
I don't really understand why though if you have an idea