Skip to content

Commit

Permalink
Reimplement DataTree aggregations (#9589)
Browse files Browse the repository at this point in the history
* Reimplement DataTree aggregations

They now allow for dimensions that are missing on particular nodes, and
use Xarray's standard generate_aggregations machinery, like aggregations
for DataArray and Dataset.

Fixes #8949, #8963

* add API docs on DataTree aggregations

* remove incorrectly added sel methods

* fix docstring reprs

* mypy fix

* fix self import

* remove unimplemented agg methods

* replace dim_arg_to_dims_set with parse_dims

* add parse_dims_as_set

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix mypy errors

* change tests to match slightly different error now thrown

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: TomNicholas <tom@cworthy.org>
  • Loading branch information
3 people authored Oct 13, 2024
1 parent 70a2a55 commit 707231e
Show file tree
Hide file tree
Showing 11 changed files with 1,507 additions and 113 deletions.
38 changes: 17 additions & 21 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -828,30 +828,26 @@ Index into all nodes in the subtree simultaneously.
.. DataTree.polyfit
.. DataTree.curvefit
.. Aggregation
.. -----------
Aggregation
-----------

.. Aggregate data in all nodes in the subtree simultaneously.
Aggregate data in all nodes in the subtree simultaneously.

.. .. autosummary::
.. :toctree: generated/
.. autosummary::
:toctree: generated/

.. DataTree.all
.. DataTree.any
.. DataTree.argmax
.. DataTree.argmin
.. DataTree.idxmax
.. DataTree.idxmin
.. DataTree.max
.. DataTree.min
.. DataTree.mean
.. DataTree.median
.. DataTree.prod
.. DataTree.sum
.. DataTree.std
.. DataTree.var
.. DataTree.cumsum
.. DataTree.cumprod
DataTree.all
DataTree.any
DataTree.max
DataTree.min
DataTree.mean
DataTree.median
DataTree.prod
DataTree.sum
DataTree.std
DataTree.var
DataTree.cumsum
DataTree.cumprod

.. ndarray methods
.. ---------------
Expand Down
Loading

0 comments on commit 707231e

Please sign in to comment.