-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Do not transpose 1d arrays during interpolation #5542
base: main
Are you sure you want to change the base?
Do not transpose 1d arrays during interpolation #5542
Conversation
It's just a simple copy/paste job at the moment. I welcome suggestions for a more elegant solution. |
Unit Test Results 6 files 6 suites 52m 1s ⏱️ Results for commit fb68d59. ♻️ This comment has been updated with latest results. |
Sorry this didn't get @Illviljan . It looks good, without me having that much context. Do you have any info on whether this has any performance impact? I imagine this isn't as easy as it sounds, but do you have a view on whether we could apply this concept more broadly, and make transposing 1D arrays a no-op in the transpose method, rather than writing that logic for each method that calls |
Yes this improves the interp performance a bit. The .copy in the transpose is rather slow so it seems better to just not do it. An alternative is removing the .copy in the transpose or make it an option? |
Edit: actually is this already implemented? https://github.com/pydata/xarray/blob/main/xarray/core/variable.py#L1441-L1444. Does interpolate not hit this code path? Is it worth adding an ASV? I've found them fairly quick to set up a new one, though takes some lift to set up the environment etc. I think in general we should try and have them for performance work, so we can track if it regresses. |
Yes, that's the copy that's slow and there's no real need to create a new copy in the 1D case. My (bad) idea was to just return the original array there instead, but as you noted that might not be fully intuitive. A ASV for 1D- and ND-interpolation and having it running in the CI would be nice. |
It's curious that's slow — it's not a deep copy and so should be fast (in python terms!), since it's just copying the class instance. Totally understand re ASV — and more generally you should choose the most meaningful work for you. I hope you continue to become more involved with the project, and there'll be plenty of time to expand into other areas. (though down a level, we should have some way of justifying the merge — let me know if you have any profiles to hand, no rush) Thanks as ever @Illviljan ! |
Seems a waste of time to transpose 1d arrays.
pre-commit run --all-files
whats-new.rst
api.rst