Skip to content

Commit f87f0b2

Browse files
Illviljanpre-commit-ci[bot]dcherian
authored
Use cumsum from flox
* use cumsum from flox * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update groupby.py * Update groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update groupby.py * Update groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * use apply_ufunc for dataset and dataarray handling * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * sync protocols with each other * typing * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add dataset and version requirement * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _aggregations.py * Update xarray/core/groupby.py Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com> * Update groupby.py * Update groupby.py * Update groupby.py * Update generate_aggregations.py * Renove workaround in test * Update _aggregations.py * Update _aggregations.py * Update test_groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * clean ups * Add expected groups, add options * Update groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * expeced_groups not supported in groupby_scan * Update _aggregations.py * Update _aggregations.py * Update generate_aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update generate_aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update _aggregations.py * Update test_groupby.py * Update test_groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_groupby.py * Update generate_aggregations.py * Update test_groupby.py * Update test_groupby.py * Update test_groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update generate_aggregations.py * Update _aggregations.py * Update _aggregations.py * Update test_groupby.py * Update generate_aggregations.py * Update _aggregations.py * Update _aggregations.py * Datatree should use Dataset.func rather than Dataset.reduce(func) * docstsrings for datatree can now be fixed * Update _aggregations.py * Update test_dataset.py * Update test_dataset.py * Update generate_aggregations.py * Update _aggregations.py * Update generate_aggregations.py * Update generate_aggregations.py * Update _aggregations.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * mapping in collections * add coords * test ds.cumsum with expected outcomes * Update test_dataset.py * Update test_dataset.py * Update test_dataset.py * Add use_lazy_group_idx to parametrize * Update test_groupby.py * cumusum in flox requires 0.10.5 * Update test_groupby.py * Update whats-new.rst * Update whats-new.rst * Update whats-new.rst * Add ASV test * Motivate use Dataset.func further * test refactor * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" This reverts commit eff5561. * Update test_groupby.py * Update test_groupby.py * Update test_groupby.py * Update test_groupby.py * Update test_groupby.py * nd-array tests and different dims * Update test_groupby.py * Update test_groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_groupby.py * Update test_groupby.py * Update test_groupby.py * more tests * Update test_groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_groupby.py * Update test_groupby.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_groupby.py * Update test_groupby.py * Update test_groupby.py * Update test_groupby.py * ns to us * Update whats-new.rst --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
1 parent 00eb4ac commit f87f0b2

8 files changed

Lines changed: 805 additions & 273 deletions

File tree

asv_bench/benchmarks/groupby.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@ def time_init(self, ndim):
2828
getattr(self, f"ds{ndim}d").groupby("b")
2929

3030
@parameterized(
31-
["method", "ndim", "use_flox"], [("sum", "mean"), (1, 2), (True, False)]
31+
["method", "ndim", "use_flox"],
32+
[("sum", "mean", "cumsum"), (1, 2), (True, False)],
3233
)
3334
def time_agg_small_num_groups(self, method, ndim, use_flox):
3435
ds = getattr(self, f"ds{ndim}d")
3536
with xr.set_options(use_flox=use_flox):
3637
getattr(ds.groupby("a"), method)().compute()
3738

3839
@parameterized(
39-
["method", "ndim", "use_flox"], [("sum", "mean"), (1, 2), (True, False)]
40+
["method", "ndim", "use_flox"],
41+
[("sum", "mean", "cumsum"), (1, 2), (True, False)],
4042
)
4143
def time_agg_large_num_groups(self, method, ndim, use_flox):
4244
ds = getattr(self, f"ds{ndim}d")

doc/whats-new.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ Documentation
125125
- Fix code blocks on "how to create custom index" doc page (:pull:`11255`).
126126
By `Nick Hodgskin <https://github.com/VeckoTheGecko>`_.
127127

128+
Performance
129+
~~~~~~~~~~~
130+
131+
- Groupby cumsum can now be accelerated with flox. Coordinates are now retained
132+
as well. (:issue:`6528`, :pull:`10987`)
133+
By `Jimmy Westling <https://github.com/illviljan>`_.
134+
128135
Internal Changes
129136
~~~~~~~~~~~~~~~~
130137

@@ -345,6 +352,9 @@ Performance
345352

346353
- Add a fastpath to the backend plugin system for standard engines (:issue:`10178`, :pull:`10937`).
347354
By `Sam Levang <https://github.com/slevang>`_.
355+
- Groupby cumsum can now be accelerated with flox. Coordinates are now retained
356+
as well. (:issue:`6528`, :pull:`10987`)
357+
By `Jimmy Westling <https://github.com/illviljan>`_.
348358
- Optimize :py:class:`~xarray.coding.variables.CFMaskCoder` decoder (:pull:`11105`).
349359
By `Deepak Cherian <https://github.com/dcherian>`_.
350360

0 commit comments

Comments
 (0)