Uh oh!
There was an error while loading. Please reload this page.
Support vectorized interpolation with more scipy interpolators - #9526
Conversation
max-sixty
commented
Sep 23, 2024
Something has gone kinda wrong with git here! Maybe try squashing to a single commit? |
519d2c6 to
09a9e73Comparehollymandel
commented
Sep 23, 2024
yes, done, thanks! |
max-sixty
commented
Sep 23, 2024
Nice, thanks! (I don't know this code well so will defer to others on the review, hope that's OK...) |
hollymandel
commented
Sep 23, 2024
Sounds good! I actually wanted it to be a "draft PR" as I'm still double-checking it, though perhaps submitting it this way is confusing on the maintainers' end and I should rescind until it's ready. |
we're actually happy to have PRs developed like this, it allows us to guide people more easily in case there's any issues. This includes advising in case the direction is seriously wrong (which I don't think it is in this case, but I also don't know this area too well) Just tell us when you think this is ready or if you need any help. |
9ec3e07 to
9c33edfCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| if not indexes_coords: | ||
| return var.copy() | ||
| # default behavior |
Uh oh!
There was an error while loading. Please reload this page.
| if not has_scipy: | ||
| pytest.skip("scipy is not installed.") |
There was a problem hiding this comment.
| ifnothas_scipy: | |
| pytest.skip("scipy is not installed.") |
driveby cleanup. The requires_scipydecorator will skip the test if scipy isn't available. Import it from xarray.tests if it's not present.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| # x, new_x are tuples of size 1. | ||
| x, new_x = x[0], new_x[0] | ||
| rslt = func(x, var, assume_sorted=True, **kwargs)(np.ravel(new_x)) | ||
| x, new_x = x[0].data, new_x[0].data |
There was a problem hiding this comment.
- The addition of
.datais significant. Where did the types change? We seem to have moved fromnp.ndarraytoVariable? - Is there a reason you got rid of
assume_sorted=True?
There was a problem hiding this comment.
This doesn't seem to have been necessary, changing back
The interpolators I have added (
Scipy.Interpolate.Akima1DInterpolator, etc...) require sorted axes but don't takeassume_sortedas an argument. OnlyScipy.Interpolate.Interp1dtakes this argument. Since we are always calling it withTrue, I'm just letting the default for ScipyInterpolator init impose this.
There is maybe a philosophical conflict here and in previous comments about kwarg handling for the different interpolators. The preexisting script (missing.py) has special classes (NumpyInterpolator, ScipyInterpolator...) which basically just do this handling. I didn't add any new classes for the new interpolators and rather tried to do everything with kwargs determined by _get_interpolator.
There was a problem hiding this comment.
Re (1): If you're comfortable with typing, some type hints would go a long way towards improving this module.
Re (2): sounds good
There was a problem hiding this comment.
(1) Yeah can do! Prefer a separate commit though (?)
There was a problem hiding this comment.
we squash merge so it doesn't matter :) unless you meant separate PR, in which case that would be fine too.
Nice progress! I pushed a commit that should handle the min scipy version failure with Please add a note to
Yes, we error on unexpected warnings. To add this, catch the warning using withpytest.warns(DeprecationWarning):
...
It also let us handle the annoying pieces like min scipy versions ;). We have established patterns to handle such things, but its hard for a new contributor to find them at first glance |
425874c to
76defd1Compare76defd1 to
623be9fComparedcherian
commented
Sep 24, 2024
(fyi we squash on merge, so you needn't squash every change) |
dcherian
left a comment
There was a problem hiding this comment.
Very nice work! Thanks for taking this on, we've needed someone to do this for a while now :)
One last request, please add a note to whats-new.rst
max-sixty
commented
Sep 25, 2024
Thanks @hollymandel ! |
Uh oh!
There was an error while loading. Please reload this page.