Skip to content

Commit 076bd8e

Browse files
patrick-naylorpre-commit-ci[bot]Illviljandcherian
authored
Generate cumulative aggregations (#7152)
* Added file to generate docs for cumulatives. generate_cumulatives.py creates _cumulatives.py * Fixed mypy issues * Updated cumulatives to fix mypy issues * Added keep_attrs to groupby funcs * Combined cumulatives and reductions and aggregations and modified dataset cumulative functions. * Merged cumulatives and reductions into aggregations * Removed test print from dataset.py * Removed generate_cumulatives and generate_reductions * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated _aggregations with docstring changes * Updated generate_aggregations.py with suggestions from @dcherian. Removed potential solution to #6528. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Removed unecessary function from dataset.py * Removed unecessary function from dataset.py * Updated api.rst, whats-new.rst and added a cumprod test to test_groupby.py * Fixed accidental edit to test_dataset.py * Apply suggestions from code review * Merge and rename reductions and cumulatives to aggregations * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * minor tweaks * Update computation.py * Update generate_aggregations.py * Update .pre-commit-config.yaml * fix mypy * use _group_dim in resample? * Update resample.py * Manually fix docstring * Apply suggestions from code review Co-authored-by: Deepak Cherian <[email protected]> * Use TEMPLATE_SEE_ALSO * use default example * add resample test * remove cumulative function in ops * Revert "remove cumulative function in ops" This reverts commit 66e7390. * Add numeric_only=True Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Illviljan <[email protected]> Co-authored-by: Deepak Cherian <[email protected]>
1 parent 0a75d13 commit 076bd8e

11 files changed

+1386
-214
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repos:
3434
rev: v0.3.7
3535
hooks:
3636
- id: blackdoc
37-
exclude: "generate_reductions.py"
37+
exclude: "generate_aggregations.py"
3838
additional_dependencies: ["black==22.10.0"]
3939
- id: blackdoc-autoupdate-black
4040
- repo: https://github.com/PyCQA/flake8

doc/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ Dataset
754754
DatasetGroupBy.any
755755
DatasetGroupBy.count
756756
DatasetGroupBy.cumsum
757+
DatasetGroupBy.cumprod
757758
DatasetGroupBy.max
758759
DatasetGroupBy.mean
759760
DatasetGroupBy.median
@@ -784,6 +785,7 @@ DataArray
784785
DataArrayGroupBy.any
785786
DataArrayGroupBy.count
786787
DataArrayGroupBy.cumsum
788+
DataArrayGroupBy.cumprod
787789
DataArrayGroupBy.max
788790
DataArrayGroupBy.mean
789791
DataArrayGroupBy.median

doc/whats-new.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ New Features
2828
- Display the indexes in a new section of the text and HTML reprs
2929
(:pull:`6795`, :pull:`7183`, :pull:`7185`)
3030
By `Justus Magin <https://github.com/keewis>`_ and `Benoît Bovy <https://github.com/benbovy>`_.
31+
- Added methods :py:meth:`DataArrayGroupBy.cumprod` and :py:meth:`DatasetGroupBy.cumprod`.
32+
(:pull:`5816`)
33+
By `Patrick Naylor <https://github.com/patrick-naylor>`_
3134

3235
Breaking changes
3336
~~~~~~~~~~~~~~~~
@@ -62,6 +65,8 @@ Documentation
6265
Add :py:meth:`__str__` to surface the new :py:class:`BackendEntrypoint` ``description``
6366
and ``url`` attributes. (:issue:`6577`, :pull:`7000`)
6467
By `Jessica Scheick <https://github.com/jessicas11>`_.
68+
- Created docstring examples for :py:meth:`DataArray.cumsum`, :py:meth:`DataArray.cumprod`, :py:meth:`Dataset.cumsum`, :py:meth:`Dataset.cumprod`, :py:meth:`DatasetGroupBy.cumsum`, :py:meth:`DataArrayGroupBy.cumsum`. (:issue:`5816`, :pull:`7152`)
69+
By `Patrick Naylor <https://github.com/patrick-naylor>`_
6570
- Add example of using :py:meth:`DataArray.coarsen.construct` to User Guide. (:pull:`7192`)
6671
By `Tom Nicholas <https://github.com/TomNicholas>`_.
6772
- Rename ``axes`` to ``axs`` in plotting to align with ``matplotlib.pyplot.subplots``. (:pull:`7194`)

0 commit comments

Comments
 (0)