Skip to content
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

Migrate datatree.py module into xarray.core. #8789

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ed47ffd
Migrate datatree.py module into xarray.core.
owenlittlejohns Feb 16, 2024
0784196
Add correct PR reference to whats-new.rst.
owenlittlejohns Feb 27, 2024
647582d
Revert to using Union in datatree.py.
owenlittlejohns Feb 28, 2024
26f3e61
Catch remaining unfixed import path.
owenlittlejohns Feb 28, 2024
5e575d7
Fix easier mypy annotations in datatree.py and test_datatree.py.
owenlittlejohns Feb 28, 2024
6b7a15f
Straggling mypy change in datatree.py.
owenlittlejohns Feb 28, 2024
738bf28
datatree.py comment clean-up.
owenlittlejohns Feb 28, 2024
6eaa021
More mypy corrections in datatree.py and test_datatree.py.
owenlittlejohns Feb 29, 2024
0397e67
Removes unnecessary dict wrapper.
flamingbear Mar 4, 2024
c45c56a
DAS-2062: renames as_array -> to_dataarray
flamingbear Mar 4, 2024
b333b1d
DAS-2062: Updates doc string for Datatree.to_zarr
flamingbear Mar 4, 2024
34e00bd
DAS-2062: reverts what-new.rst
flamingbear Mar 4, 2024
c171470
Merge branch 'main' into DAS-2062-migrate-datatree-module-pr
flamingbear Mar 5, 2024
a0d3702
DAS-2062: clarify wording in comment.
flamingbear Mar 5, 2024
869103b
Change Datatree.to_dataarray to call correctly
flamingbear Mar 5, 2024
379bc5c
Merge branch 'main' into DAS-2062-migrate-datatree-module-pr
flamingbear Mar 11, 2024
12590fb
Clarify DataTree's names are still strings now.
flamingbear Mar 14, 2024
8c3ba13
Merge branch 'main' into DAS-2062-migrate-datatree-module-pr
dcherian Mar 15, 2024
5cc7c41
Merge branch 'main' into DAS-2062-migrate-datatree-module-pr
flamingbear Mar 15, 2024
4a53979
DAS-2062: Cast k explicitly to str for typing.
flamingbear Mar 18, 2024
ffa5f71
Ignore mypy errors for DataTree.ds assignment.
owenlittlejohns Mar 19, 2024
881af78
Fix DataTree.update type hint.
owenlittlejohns Mar 19, 2024
3fc4796
Final mypy issue - ignore DataTree.get override.
owenlittlejohns Mar 20, 2024
14b5c02
Update contributors in whats-new.rst
owenlittlejohns Mar 21, 2024
3aaf837
Merge branch 'main' into DAS-2062-migrate-datatree-module-pr
owenlittlejohns Mar 21, 2024
ce68416
Fix GitHub handle.
owenlittlejohns Mar 21, 2024
0ae54cb
Merge branch 'main' into DAS-2062-migrate-datatree-module-pr
flamingbear Mar 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ Internal Changes
- Migrates ``treenode`` functionality into ``xarray/core`` (:pull:`8757`)
By `Matt Savoie <https://github.com/flamingbear>`_ and `Tom Nicholas
<https://github.com/TomNicholas>`_.
- Migrates ``datatree`` functionality into ``xarray/core``. (:pull: `8789`)
By `Owen Littlejohns <https://github.com/owenlittlejohns>`_, `Matt Savoie
<https://github.com/flamingbear>`_ and `Tom Nicholas <https://github.com/TomNicholas>`_.


.. _whats-new.2024.02.0:
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
T_NetcdfTypes = Literal[
"NETCDF4", "NETCDF4_CLASSIC", "NETCDF3_64BIT", "NETCDF3_CLASSIC"
]
from xarray.datatree_.datatree import DataTree
from xarray.core.datatree import DataTree

DATAARRAY_NAME = "__xarray_dataarray_name__"
DATAARRAY_VARIABLE = "__xarray_dataarray_variable__"
Expand Down
4 changes: 2 additions & 2 deletions xarray/backends/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from netCDF4 import Dataset as ncDataset

from xarray.core.dataset import Dataset
from xarray.core.datatree import DataTree
from xarray.core.types import NestedSequence
from xarray.datatree_.datatree import DataTree

# Create a logger object, but don't add any handlers. Leave that to user code.
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -137,8 +137,8 @@ def _open_datatree_netcdf(
**kwargs,
) -> DataTree:
from xarray.backends.api import open_dataset
from xarray.core.datatree import DataTree
from xarray.core.treenode import NodePath
from xarray.datatree_.datatree import DataTree

ds = open_dataset(filename_or_obj, **kwargs)
tree_root = DataTree.from_dict({"/": ds})
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/h5netcdf_.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

from xarray.backends.common import AbstractDataStore
from xarray.core.dataset import Dataset
from xarray.datatree_.datatree import DataTree
from xarray.core.datatree import DataTree


class H5NetCDFArrayWrapper(BaseNetCDF4Array):
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/netCDF4_.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

from xarray.backends.common import AbstractDataStore
from xarray.core.dataset import Dataset
from xarray.datatree_.datatree import DataTree
from xarray.core.datatree import DataTree

# This lookup table maps from dtype.byteorder to a readable endian
# string used by netCDF4.
Expand Down
4 changes: 2 additions & 2 deletions xarray/backends/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

from xarray.backends.common import AbstractDataStore
from xarray.core.dataset import Dataset
from xarray.datatree_.datatree import DataTree
from xarray.core.datatree import DataTree


# need some special secret attributes to tell us the dimensions
Expand Down Expand Up @@ -1048,8 +1048,8 @@ def open_datatree(
import zarr

from xarray.backends.api import open_dataset
from xarray.core.datatree import DataTree
from xarray.core.treenode import NodePath
from xarray.datatree_.datatree import DataTree

zds = zarr.open_group(filename_or_obj, mode="r")
ds = open_dataset(filename_or_obj, engine="zarr", **kwargs)
Expand Down
Loading
Loading