-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
polyval: Use Horner's algorithm + support chunked inputs #6548
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
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
e309682
new polyval algo
headtr1ck 88e476a
polyval improved typing with datasets
headtr1ck 261aadc
more polyval unit tests
headtr1ck 2a6a633
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a2701b8
support for Dataset coord in polyval
headtr1ck 553de10
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4fbca23
fix bug in polyval broadcasting
headtr1ck b335679
Merge branch 'main' into main
max-sixty b54a4a3
Merge branch 'main' into main
max-sixty 7001e4e
Merge branch 'main' into main
max-sixty 212505f
support for datetime values in polyval
headtr1ck 595c83c
Merge branch 'main' of github.com:headtr1ck/xarray into main
headtr1ck 945cbfb
polyval update in whats-new
headtr1ck 5945537
fix dask polyval unit tests
headtr1ck a0964ed
fix bug in polyval unit tests
headtr1ck 82db394
add polyval benchmark
headtr1ck ca5a7f7
add breaking change of polyval tp whats-new
headtr1ck 7a70831
move _ensure_numeric to its own function
headtr1ck 401e126
fix import error in _ensure_numeric
headtr1ck 3c21a64
add raise_if_dask_computes to polyval unit tests
headtr1ck ff37fe2
chunk coord arg as well for polyval unit tests
headtr1ck 63ed137
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8343b29
simplify polyval algo with sortby
headtr1ck 7ad9168
Merge branch 'main' of github.com:headtr1ck/xarray into main
headtr1ck 0ef3462
comment some code until PR#6556
headtr1ck e6f4675
Revert "comment some code until PR#6556"
headtr1ck 3b88386
fix dask issues with polyval unit tests
headtr1ck ce392a7
remove unused import
headtr1ck 4e8b72e
make polyval benchmark backwards compatible
headtr1ck 70c4419
another bugfix for polyval benchmark
headtr1ck c4ced87
Update asv_bench/benchmarks/polyfit.py
dcherian 7a73a42
Actually compute dask arrays in benchmark.
dcherian a824ad2
Minor cleanup
dcherian 047cd04
simplify polyval algo using reindex
headtr1ck 0d0bb8e
don't copy coeffs if not necessary
headtr1ck ef49710
Merge branch 'pydata:main' into main
headtr1ck 05e0266
Make sure degree_dim is an indexed coordinate of int dtype
dcherian bd3dd81
Fix benchmark
dcherian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import numpy as np | ||
|
||
import xarray as xr | ||
|
||
from . import parameterized, randn, requires_dask | ||
|
||
NDEGS = (2, 5, 20) | ||
NX = (10**2, 10**6) | ||
|
||
|
||
class Polyval: | ||
def setup(self, *args, **kwargs): | ||
self.xs = {nx: xr.DataArray(randn((nx,)), dims="x", name="x") for nx in NX} | ||
self.coeffs = { | ||
ndeg: xr.DataArray( | ||
randn((ndeg,)), dims="degree", coords={"degree": np.arange(ndeg)} | ||
) | ||
for ndeg in NDEGS | ||
} | ||
|
||
@parameterized(["nx", "ndeg"], [NX, NDEGS]) | ||
def time_polyval(self, nx, ndeg): | ||
x = self.xs[nx] | ||
c = self.coeffs[ndeg] | ||
xr.polyval(x, c).compute() | ||
|
||
@parameterized(["nx", "ndeg"], [NX, NDEGS]) | ||
def peakmem_polyval(self, nx, ndeg): | ||
x = self.xs[nx] | ||
c = self.coeffs[ndeg] | ||
xr.polyval(x, c).compute() | ||
|
||
|
||
class PolyvalDask(Polyval): | ||
def setup(self, *args, **kwargs): | ||
requires_dask() | ||
super().setup(*args, **kwargs) | ||
self.xs = {k: v.chunk({"x": 10000}) for k, v in self.xs.items()} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.