Skip to content

preliminary pr to examine the DataTree injected docs. #8977

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

Closed
wants to merge 9 commits into from
317 changes: 317 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,323 @@ Reshaping and reorganizing
DataArray.sortby
DataArray.broadcast_like



DataTree
========

Creating a DataTree
-------------------

Methods of creating a datatree.

.. autosummary::
:toctree: generated/

DataTree
DataTree.from_dict

Tree Attributes
---------------

Attributes relating to the recursive tree-like structure of a ``DataTree``.

.. autosummary::
:toctree: generated/

DataTree.parent
DataTree.children
DataTree.name
DataTree.path
DataTree.root
DataTree.is_root
DataTree.is_leaf
DataTree.leaves
DataTree.level
DataTree.depth
DataTree.width
DataTree.subtree
DataTree.descendants
DataTree.siblings
DataTree.lineage
DataTree.parents
DataTree.ancestors
DataTree.groups

Data Contents
-------------

Interface to the data objects (optionally) stored inside a single ``DataTree`` node.
This interface echoes that of ``xarray.Dataset``.

.. autosummary::
:toctree: generated/

DataTree.dims
DataTree.sizes
DataTree.data_vars
DataTree.coords
DataTree.attrs
DataTree.encoding
DataTree.indexes
DataTree.nbytes
DataTree.ds
DataTree.to_dataset
DataTree.has_data
DataTree.has_attrs
DataTree.is_empty
DataTree.is_hollow

Dictionary Interface
--------------------

``DataTree`` objects also have a dict-like interface mapping keys to either ``xarray.DataArray``s or to child ``DataTree`` nodes.

.. autosummary::
:toctree: generated/

DataTree.__getitem__
DataTree.__setitem__
DataTree.__delitem__
DataTree.update
DataTree.get
DataTree.items
DataTree.keys
DataTree.values

Tree Manipulation
-----------------

For manipulating, traversing, navigating, or mapping over the tree structure.

.. autosummary::
:toctree: generated/

DataTree.orphan
DataTree.same_tree
DataTree.relative_to
DataTree.iter_lineage
DataTree.find_common_ancestor
DataTree.map_over_subtree
map_over_subtree
DataTree.pipe
DataTree.match
DataTree.filter

Pathlib-like Interface
----------------------

``DataTree`` objects deliberately echo some of the API of `pathlib.PurePath`.

.. autosummary::
:toctree: generated/

DataTree.name
DataTree.parent
DataTree.parents
DataTree.relative_to

Missing:

..

``DataTree.glob``
``DataTree.joinpath``
``DataTree.with_name``
``DataTree.walk``
``DataTree.rename``
``DataTree.replace``

DataTree Contents
-----------------

Manipulate the contents of all nodes in a tree simultaneously.

.. autosummary::
:toctree: generated/

DataTree.copy
DataTree.assign_coords
DataTree.merge
DataTree.rename
DataTree.rename_vars
DataTree.rename_dims
DataTree.swap_dims
DataTree.expand_dims
DataTree.drop_vars
DataTree.drop_dims
DataTree.set_coords
DataTree.reset_coords

DataTree Node Contents
----------------------

Manipulate the contents of a single DataTree node.

.. autosummary::
:toctree: generated/

DataTree.assign
DataTree.drop_nodes


Comparisons
-----------

Compare one ``DataTree`` object to another.

.. autosummary::
:toctree: generated/

DataTree.isomorphic
DataTree.equals
DataTree.identical

Indexing
--------

Index into all nodes in the subtree simultaneously.

.. autosummary::
:toctree: generated/

DataTree.isel
DataTree.sel
DataTree.drop_sel
DataTree.drop_isel
DataTree.head
DataTree.tail
DataTree.thin
DataTree.squeeze
DataTree.interp
DataTree.interp_like
DataTree.reindex
DataTree.reindex_like
DataTree.set_index
DataTree.reset_index
DataTree.reorder_levels
DataTree.query

..

Missing:
``DataTree.loc``


Missing Value Handling
----------------------

.. autosummary::
:toctree: generated/

DataTree.isnull
DataTree.notnull
DataTree.combine_first
DataTree.dropna
DataTree.fillna
DataTree.ffill
DataTree.bfill
DataTree.interpolate_na
DataTree.where
DataTree.isin

Computation
-----------

Apply a computation to the data in all nodes in the subtree simultaneously.

.. autosummary::
:toctree: generated/

DataTree.map
DataTree.reduce
DataTree.diff
DataTree.quantile
DataTree.differentiate
DataTree.integrate
DataTree.map_blocks
DataTree.polyfit
DataTree.curvefit

Aggregation
-----------

Aggregate data in all nodes in the subtree simultaneously.

.. 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

ndarray methods
---------------

Methods copied from :py:class:`numpy.ndarray` objects, here applying to the data in all nodes in the subtree.

.. autosummary::
:toctree: generated/

DataTree.argsort
DataTree.astype
DataTree.clip
DataTree.conj
DataTree.conjugate
DataTree.round
DataTree.rank

Reshaping and reorganising
--------------------------

Reshape or reorganise the data in all nodes in the subtree.

.. autosummary::
:toctree: generated/

DataTree.transpose
DataTree.stack
DataTree.unstack
DataTree.shift
DataTree.roll
DataTree.pad
DataTree.sortby
DataTree.broadcast_like

Plotting
--------

I/O
---

Open a datatree from an on-disk store or serialize the tree.

.. autosummary::
:toctree: generated/

open_datatree
DataTree.to_dict
DataTree.to_netcdf
DataTree.to_zarr

..

Missing:
``open_mfdatatree``

IO / Conversion
===============

Expand Down
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Internal Changes
``xarray/testing/assertions`` for ``DataTree``. (:pull:`8967`)
By `Owen Littlejohns <https://github.com/owenlittlejohns>`_ and
`Tom Nicholas <https://github.com/TomNicholas>`_.
- Migrates ``ops.py`` functionality into ``xarray/core/datatree_ops.py`` (:pull:`8976`)
By `Matt Savoie <https://github.com/flamingbear>`_ and `Tom Nicholas <https://github.com/TomNicholas>`_.


.. _whats-new.2024.03.0:
Expand Down
5 changes: 5 additions & 0 deletions xarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
load_dataset,
open_dataarray,
open_dataset,
open_datatree,
open_mfdataset,
save_mfdataset,
)
Expand All @@ -31,6 +32,7 @@
from xarray.core.coordinates import Coordinates
from xarray.core.dataarray import DataArray
from xarray.core.dataset import Dataset
from xarray.core.datatree import DataTree, map_over_subtree
from xarray.core.extensions import (
register_dataarray_accessor,
register_dataset_accessor,
Expand Down Expand Up @@ -79,10 +81,12 @@
"load_dataarray",
"load_dataset",
"map_blocks",
"map_over_subtree",
"merge",
"ones_like",
"open_dataarray",
"open_dataset",
"open_datatree",
"open_mfdataset",
"open_zarr",
"polyval",
Expand All @@ -99,6 +103,7 @@
"Context",
"Coordinates",
"DataArray",
"DataTree",
"Dataset",
"Index",
"IndexSelResult",
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -5260,7 +5260,7 @@ def differentiate(
edge_order: Literal[1, 2] = 1,
datetime_unit: DatetimeUnitOptions = None,
) -> Self:
""" Differentiate the array with the second order accurate central
"""Differentiate the array with the second order accurate central
differences.

.. note::
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8313,7 +8313,7 @@ def differentiate(
edge_order: Literal[1, 2] = 1,
datetime_unit: DatetimeUnitOptions | None = None,
) -> Self:
""" Differentiate with the second order accurate central
"""Differentiate with the second order accurate central
differences.

.. note::
Expand Down
Loading
Loading