-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add engine="numbagg" * Fix. * fix CI * Add nanlen * fix env * Add numbagg * Bettter numbagg benchmarks? * Update ci/environment.yml * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * cleanup * Error on dtype specified * Don't shadow sum, mean, sum_of_squares * more skip * Fix backup npg aggregations * xfail nanmean bool * ignore numbagg for mypy * Add to upstream-dev CI * Add to optional dependencies * Fix bool reductions * fix mypy ignore * reintroduce engines * Update docstring * Update docs. * Support more aggregations * More aggregations * back to nancount * Add any, all * promote in nanstd too * Add ddof in anticipation of numbagg/numbagg#138 * Add more benchmarks * reorder benchmark table * Fix numba compilation setup? * More benchmarks * Rework benchmarks * small docstring update * ignore asv typing * fix type ignoring * Guard against numbagg failures * Use released numbagg --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maximilian Roos <[email protected]>
- Loading branch information
1 parent
68b122e
commit 9f82e19
Showing
14 changed files
with
271 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -23,3 +23,5 @@ dependencies: | |
- toolz | ||
- numba | ||
- scipy | ||
- pip: | ||
- numbagg>=0.3 |
This file contains 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 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 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,100 @@ | ||
from functools import partial | ||
|
||
import numbagg | ||
import numbagg.grouped | ||
import numpy as np | ||
|
||
|
||
def _numbagg_wrapper( | ||
group_idx, | ||
array, | ||
*, | ||
axis=-1, | ||
func="sum", | ||
size=None, | ||
fill_value=None, | ||
dtype=None, | ||
numbagg_func=None, | ||
): | ||
return numbagg_func( | ||
array, | ||
group_idx, | ||
axis=axis, | ||
num_labels=size, | ||
# The following are unsupported | ||
# fill_value=fill_value, | ||
# dtype=dtype, | ||
) | ||
|
||
|
||
def nansum(group_idx, array, *, axis=-1, size=None, fill_value=None, dtype=None): | ||
if np.issubdtype(array.dtype, np.bool_): | ||
array = array.astype(np.in64) | ||
return numbagg.grouped.group_nansum( | ||
array, | ||
group_idx, | ||
axis=axis, | ||
num_labels=size, | ||
# fill_value=fill_value, | ||
# dtype=dtype, | ||
) | ||
|
||
|
||
def nanmean(group_idx, array, *, axis=-1, size=None, fill_value=None, dtype=None): | ||
if np.issubdtype(array.dtype, np.int_): | ||
array = array.astype(np.float64) | ||
return numbagg.grouped.group_nanmean( | ||
array, | ||
group_idx, | ||
axis=axis, | ||
num_labels=size, | ||
# fill_value=fill_value, | ||
# dtype=dtype, | ||
) | ||
|
||
|
||
def nanvar(group_idx, array, *, axis=-1, size=None, fill_value=None, dtype=None, ddof=0): | ||
assert ddof != 0 | ||
if np.issubdtype(array.dtype, np.int_): | ||
array = array.astype(np.float64) | ||
return numbagg.grouped.group_nanvar( | ||
array, | ||
group_idx, | ||
axis=axis, | ||
num_labels=size, | ||
# ddof=0, | ||
# fill_value=fill_value, | ||
# dtype=dtype, | ||
) | ||
|
||
|
||
def nanstd(group_idx, array, *, axis=-1, size=None, fill_value=None, dtype=None, ddof=0): | ||
assert ddof != 0 | ||
if np.issubdtype(array.dtype, np.int_): | ||
array = array.astype(np.float64) | ||
return numbagg.grouped.group_nanstd( | ||
array, | ||
group_idx, | ||
axis=axis, | ||
num_labels=size, | ||
# ddof=0, | ||
# fill_value=fill_value, | ||
# dtype=dtype, | ||
) | ||
|
||
|
||
nansum_of_squares = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nansum_of_squares) | ||
nanlen = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nancount) | ||
nanprod = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nanprod) | ||
nanfirst = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nanfirst) | ||
nanlast = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nanlast) | ||
# nanargmax = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nanargmax) | ||
# nanargmin = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nanargmin) | ||
nanmax = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nanmax) | ||
nanmin = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nanmin) | ||
any = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nanany) | ||
all = partial(_numbagg_wrapper, numbagg_func=numbagg.grouped.group_nanall) | ||
|
||
# sum = nansum | ||
# mean = nanmean | ||
# sum_of_squares = nansum_of_squares |
This file contains 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
Oops, something went wrong.