-
Notifications
You must be signed in to change notification settings - Fork 8
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
Refactor reduce module; improve performance for mode, median #270
Conversation
* Simplify methods by just giving a contiguous values array instead of source and indices * Provide a pre-allocated workspace to avoid dynamic allocation in reduce functions * Add a generalized percentile function
Small miscellaneous fixes.
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 for the fixes. I have some small suggestions but no major things. Approving in advance.
return values, weights, work | ||
|
||
|
||
def reverse_args(): |
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.
To remove some duplicate code and show the precise difference between forward and reverse args, you can simplify this function to:
def reverse_args(): | |
def reverse_args(): | |
values, weights, work = forward_args() | |
return np.flip(values), weights, work |
(FYI: I wasn't allowed by Github to put a multi-line suggestion here, as some lines are deleted. Therefore put the suggestion just on the function definition line).
xugrid/regrid/nanpercentile.py
Outdated
@@ -0,0 +1,97 @@ | |||
""" | |||
Numba percentile methods allocate continuosly on the heap. |
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.
Numba percentile methods allocate continuosly on the heap. | |
Numba percentile methods allocate continuously on the heap. |
xugrid/regrid/regridder.py
Outdated
Examples | ||
-------- | ||
Setup a custom percentile method and apply it: | ||
|
||
>>> p33_3 = OverlapRegridder.create_percentile_method(33.3) | ||
>>> regridder = OverlapRegridder(source, target, method=p33_3) |
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.
Good that you are adding an example of the percentiles. I think most users are just looking for the simple use case, so for them it is better to start with the simplest example. And perhaps also guide them to what is the most important method to call (regrid
)?
Examples | |
-------- | |
Setup a custom percentile method and apply it: | |
>>> p33_3 = OverlapRegridder.create_percentile_method(33.3) | |
>>> regridder = OverlapRegridder(source, target, method=p33_3) | |
Examples | |
-------- | |
Create an OverlapRegridder to regrid with means: | |
>>> regridder = OverlapRegridder(source_grid, target_grid, method="mean") | |
>>> regridder.regrid(source_data) | |
Setup a custom percentile method and apply it: | |
>>> p33_3 = OverlapRegridder.create_percentile_method(33.3) | |
>>> regridder = OverlapRegridder(source_grid, target_grid, method=p33_3) |
Fixes #240