Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 29, 2024
1 parent 4af5329 commit c9eb289
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 30 deletions.
12 changes: 6 additions & 6 deletions xarray/datatree_/datatree/__init__.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
20 changes: 12 additions & 8 deletions xarray/datatree_/datatree/datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion xarray/datatree_/datatree/extensions.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
6 changes: 3 additions & 3 deletions xarray/datatree_/datatree/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion xarray/datatree_/datatree/io.py
Original file line number Diff line number Diff line change
@@ -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="/"):
Expand Down
2 changes: 1 addition & 1 deletion xarray/datatree_/datatree/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
8 changes: 4 additions & 4 deletions xarray/datatree_/datatree/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion xarray/datatree_/datatree/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion xarray/datatree_/datatree/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down
4 changes: 2 additions & 2 deletions xarray/datatree_/datatree/testing.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion xarray/datatree_/datatree/tests/test_datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion xarray/datatree_/datatree/treenode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c9eb289

Please sign in to comment.