From c9eb289e14d65334905b362a3c45520d1a9b0e7f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:54:53 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- xarray/datatree_/datatree/__init__.py | 12 +++++------ xarray/datatree_/datatree/datatree.py | 20 +++++++++++-------- xarray/datatree_/datatree/extensions.py | 2 +- xarray/datatree_/datatree/formatting.py | 6 +++--- xarray/datatree_/datatree/io.py | 2 +- xarray/datatree_/datatree/iterators.py | 2 +- xarray/datatree_/datatree/mapping.py | 8 ++++---- xarray/datatree_/datatree/ops.py | 2 +- xarray/datatree_/datatree/render.py | 2 +- xarray/datatree_/datatree/testing.py | 4 ++-- .../datatree_/datatree/tests/test_datatree.py | 4 +++- xarray/datatree_/datatree/treenode.py | 2 +- 12 files changed, 36 insertions(+), 30 deletions(-) diff --git a/xarray/datatree_/datatree/__init__.py b/xarray/datatree_/datatree/__init__.py index 3b97ea9d4db..03342d34ff5 100644 --- a/xarray/datatree_/datatree/__init__.py +++ b/xarray/datatree_/datatree/__init__.py @@ -1,14 +1,14 @@ # import public API -from .datatree import DataTree -from .extensions import register_datatree_accessor -from .io import open_datatree -from .mapping import TreeIsomorphismError, map_over_subtree -from .treenode import InvalidTreeError, NotFoundInTreeError +from xarray.datatree_.datatree.datatree import DataTree +from xarray.datatree_.datatree.extensions import register_datatree_accessor +from xarray.datatree_.datatree.io import open_datatree +from xarray.datatree_.datatree.mapping import TreeIsomorphismError, map_over_subtree +from xarray.datatree_.datatree.treenode import InvalidTreeError, NotFoundInTreeError try: # NOTE: the `_version.py` file must not be present in the git repository # as it is generated by setuptools at install time - from ._version import __version__ + from xarray.datatree_.datatree._version import __version__ except ImportError: # pragma: no cover # Local copy or not installed with setuptools __version__ = "999" diff --git a/xarray/datatree_/datatree/datatree.py b/xarray/datatree_/datatree/datatree.py index c86c2e2e3e8..61636012ba2 100644 --- a/xarray/datatree_/datatree/datatree.py +++ b/xarray/datatree_/datatree/datatree.py @@ -40,16 +40,20 @@ ) from xarray.core.variable import Variable -from . import formatting, formatting_html -from .common import TreeAttrAccessMixin -from .mapping import TreeIsomorphismError, check_isomorphic, map_over_subtree -from .ops import ( +from xarray.datatree_.datatree import formatting, formatting_html +from xarray.datatree_.datatree.common import TreeAttrAccessMixin +from xarray.datatree_.datatree.mapping import ( + TreeIsomorphismError, + check_isomorphic, + map_over_subtree, +) +from xarray.datatree_.datatree.ops import ( DataTreeArithmeticMixin, MappedDatasetMethodsMixin, MappedDataWithCoords, ) -from .render import RenderTree -from .treenode import NamedNode, NodePath, Tree +from xarray.datatree_.datatree.render import RenderTree +from xarray.datatree_.datatree.treenode import NamedNode, NodePath, Tree try: from xarray.core.variable import calculate_dimensions @@ -1484,7 +1488,7 @@ def to_netcdf( kwargs : Addional keyword arguments to be passed to ``xarray.Dataset.to_netcdf`` """ - from .io import _datatree_to_netcdf + from xarray.datatree_.datatree.io import _datatree_to_netcdf _datatree_to_netcdf( self, @@ -1526,7 +1530,7 @@ def to_zarr( kwargs : Additional keyword arguments to be passed to ``xarray.Dataset.to_zarr`` """ - from .io import _datatree_to_zarr + from xarray.datatree_.datatree.io import _datatree_to_zarr _datatree_to_zarr( self, diff --git a/xarray/datatree_/datatree/extensions.py b/xarray/datatree_/datatree/extensions.py index f6f4e985a79..51a8ee577ab 100644 --- a/xarray/datatree_/datatree/extensions.py +++ b/xarray/datatree_/datatree/extensions.py @@ -1,6 +1,6 @@ from xarray.core.extensions import _register_accessor -from .datatree import DataTree +from xarray.datatree_.datatree.datatree import DataTree def register_datatree_accessor(name): diff --git a/xarray/datatree_/datatree/formatting.py b/xarray/datatree_/datatree/formatting.py index deba57eb09d..070dd09ca5b 100644 --- a/xarray/datatree_/datatree/formatting.py +++ b/xarray/datatree_/datatree/formatting.py @@ -2,11 +2,11 @@ from xarray.core.formatting import _compat_to_str, diff_dataset_repr -from .mapping import diff_treestructure -from .render import RenderTree +from xarray.datatree_.datatree.mapping import diff_treestructure +from xarray.datatree_.datatree.render import RenderTree if TYPE_CHECKING: - from .datatree import DataTree + from xarray.datatree_.datatree.datatree import DataTree def diff_nodewise_summary(a, b, compat): diff --git a/xarray/datatree_/datatree/io.py b/xarray/datatree_/datatree/io.py index 8bb7682f085..cd6d5d0ec17 100644 --- a/xarray/datatree_/datatree/io.py +++ b/xarray/datatree_/datatree/io.py @@ -1,6 +1,6 @@ from xarray import Dataset, open_dataset -from .datatree import DataTree, NodePath +from xarray.datatree_.datatree.datatree import DataTree, NodePath def _iter_zarr_groups(root, parent="/"): diff --git a/xarray/datatree_/datatree/iterators.py b/xarray/datatree_/datatree/iterators.py index 52ed8d22422..a3c092b004c 100644 --- a/xarray/datatree_/datatree/iterators.py +++ b/xarray/datatree_/datatree/iterators.py @@ -2,7 +2,7 @@ from collections import abc from typing import Callable, Iterator, List, Optional -from .treenode import Tree +from xarray.datatree_.datatree.treenode import Tree """These iterators are copied from anytree.iterators, with minor modifications.""" diff --git a/xarray/datatree_/datatree/mapping.py b/xarray/datatree_/datatree/mapping.py index 34e227d349d..9b008c2e840 100644 --- a/xarray/datatree_/datatree/mapping.py +++ b/xarray/datatree_/datatree/mapping.py @@ -8,11 +8,11 @@ from xarray import DataArray, Dataset -from .iterators import LevelOrderIter -from .treenode import NodePath, TreeNode +from xarray.datatree_.datatree.iterators import LevelOrderIter +from xarray.datatree_.datatree.treenode import NodePath, TreeNode if TYPE_CHECKING: - from .datatree import DataTree + from xarray.datatree_.datatree.datatree import DataTree class TreeIsomorphismError(ValueError): @@ -156,7 +156,7 @@ def map_over_subtree(func: Callable) -> Callable: @functools.wraps(func) def _map_over_subtree(*args, **kwargs) -> DataTree | Tuple[DataTree, ...]: """Internal function which maps func over every node in tree, returning a tree of the results.""" - from .datatree import DataTree + from xarray.datatree_.datatree.datatree import DataTree all_tree_inputs = [a for a in args if isinstance(a, DataTree)] + [ a for a in kwargs.values() if isinstance(a, DataTree) diff --git a/xarray/datatree_/datatree/ops.py b/xarray/datatree_/datatree/ops.py index d6ac4f83e7c..b4687447be4 100644 --- a/xarray/datatree_/datatree/ops.py +++ b/xarray/datatree_/datatree/ops.py @@ -2,7 +2,7 @@ from xarray import Dataset -from .mapping import map_over_subtree +from xarray.datatree_.datatree.mapping import map_over_subtree """ Module which specifies the subset of xarray.Dataset's API which we wish to copy onto DataTree. diff --git a/xarray/datatree_/datatree/render.py b/xarray/datatree_/datatree/render.py index aef327c5c47..7f407606722 100644 --- a/xarray/datatree_/datatree/render.py +++ b/xarray/datatree_/datatree/render.py @@ -6,7 +6,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: - from .datatree import DataTree + from xarray.datatree_.datatree.datatree import DataTree Row = collections.namedtuple("Row", ("pre", "fill", "node")) diff --git a/xarray/datatree_/datatree/testing.py b/xarray/datatree_/datatree/testing.py index 1cbcdf2d4e3..658056cf795 100644 --- a/xarray/datatree_/datatree/testing.py +++ b/xarray/datatree_/datatree/testing.py @@ -1,7 +1,7 @@ from xarray.testing.assertions import ensure_warnings -from .datatree import DataTree -from .formatting import diff_tree_repr +from xarray.datatree_.datatree.datatree import DataTree +from xarray.datatree_.datatree.formatting import diff_tree_repr @ensure_warnings diff --git a/xarray/datatree_/datatree/tests/test_datatree.py b/xarray/datatree_/datatree/tests/test_datatree.py index fde83b2e226..3815f99bcb2 100644 --- a/xarray/datatree_/datatree/tests/test_datatree.py +++ b/xarray/datatree_/datatree/tests/test_datatree.py @@ -212,7 +212,9 @@ def test_getitem_multiple_data_variables(self): results = DataTree(name="results", data=data) xrt.assert_identical(results[["temp", "p"]], data[["temp", "p"]]) - @pytest.mark.xfail(reason="Indexing needs to return whole tree (GH https://github.com/xarray-contrib/datatree/issues/77)") + @pytest.mark.xfail( + reason="Indexing needs to return whole tree (GH https://github.com/xarray-contrib/datatree/issues/77)" + ) def test_getitem_dict_like_selection_access_to_dataset(self): data = xr.Dataset({"temp": [0, 50]}) results = DataTree(name="results", data=data) diff --git a/xarray/datatree_/datatree/treenode.py b/xarray/datatree_/datatree/treenode.py index 1689d261c34..01529e82bdf 100644 --- a/xarray/datatree_/datatree/treenode.py +++ b/xarray/datatree_/datatree/treenode.py @@ -341,7 +341,7 @@ def subtree(self: Tree) -> Iterator[Tree]: -------- DataTree.descendants """ - from . import iterators + from xarray.datatree_.datatree import iterators return iterators.PreOrderIter(self)