Skip to content

Commit 93d2abc

Browse files
committed
Merge branch 'main' into concat_default_kwargs
2 parents aa3180e + 4c2540d commit 93d2abc

33 files changed

+788
-420
lines changed

.github/workflows/ci-additional.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report
124124
125125
- name: Upload mypy coverage to Codecov
126-
uses: codecov/codecov-action@v5.3.1
126+
uses: codecov/codecov-action@v5.4.0
127127
with:
128128
file: mypy_report/cobertura.xml
129129
flags: mypy
@@ -174,7 +174,7 @@ jobs:
174174
python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report
175175
176176
- name: Upload mypy coverage to Codecov
177-
uses: codecov/codecov-action@v5.3.1
177+
uses: codecov/codecov-action@v5.4.0
178178
with:
179179
file: mypy_report/cobertura.xml
180180
flags: mypy-min
@@ -230,7 +230,7 @@ jobs:
230230
python -m pyright xarray/
231231
232232
- name: Upload pyright coverage to Codecov
233-
uses: codecov/codecov-action@v5.3.1
233+
uses: codecov/codecov-action@v5.4.0
234234
with:
235235
file: pyright_report/cobertura.xml
236236
flags: pyright
@@ -286,7 +286,7 @@ jobs:
286286
python -m pyright xarray/
287287
288288
- name: Upload pyright coverage to Codecov
289-
uses: codecov/codecov-action@v5.3.1
289+
uses: codecov/codecov-action@v5.4.0
290290
with:
291291
file: pyright_report/cobertura.xml
292292
flags: pyright39

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172
path: pytest.xml
173173

174174
- name: Upload code coverage to Codecov
175-
uses: codecov/codecov-action@v5.3.1
175+
uses: codecov/codecov-action@v5.4.0
176176
env:
177177
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
178178
with:

.github/workflows/upstream-dev-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs:
140140
run: |
141141
python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report
142142
- name: Upload mypy coverage to Codecov
143-
uses: codecov/codecov-action@v5.3.1
143+
uses: codecov/codecov-action@v5.4.0
144144
with:
145145
file: mypy_report/cobertura.xml
146146
flags: mypy

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,8 @@ doc/team-panel.txt
8181
doc/external-examples-gallery.txt
8282
doc/notebooks-examples-gallery.txt
8383
doc/videos-gallery.txt
84+
85+
# Until we support this properly, excluding from gitignore. (adding it to
86+
# gitignore to make it _easier_ to work with `uv`, not as an indication that I
87+
# think we shouldn't...)
88+
uv.lock

.pre-commit-config.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
- id: text-unicode-replacement-char
2626
- repo: https://github.com/astral-sh/ruff-pre-commit
2727
# Ruff version.
28-
rev: v0.9.4
28+
rev: v0.9.9
2929
hooks:
3030
- id: ruff-format
3131
- id: ruff
@@ -37,12 +37,12 @@ repos:
3737
exclude: "generate_aggregations.py"
3838
additional_dependencies: ["black==24.8.0"]
3939
- repo: https://github.com/rbubley/mirrors-prettier
40-
rev: v3.4.2
40+
rev: v3.5.3
4141
hooks:
4242
- id: prettier
4343
args: [--cache-location=.prettier_cache/cache]
4444
- repo: https://github.com/pre-commit/mirrors-mypy
45-
rev: v1.14.1
45+
rev: v1.15.0
4646
hooks:
4747
- id: mypy
4848
# Copied from setup.cfg
@@ -73,3 +73,9 @@ repos:
7373
hooks:
7474
- id: validate-pyproject
7575
additional_dependencies: ["validate-pyproject-schema-store[all]"]
76+
- repo: https://github.com/crate-ci/typos
77+
rev: dictgen-v0.3.1
78+
hooks:
79+
- id: typos
80+
# https://github.com/crate-ci/typos/issues/347
81+
pass_filenames: false

doc/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ For manipulating, traversing, navigating, or mapping over the tree structure.
697697
DataTree.pipe
698698
DataTree.match
699699
DataTree.filter
700+
DataTree.filter_like
700701

701702
Pathlib-like Interface
702703
----------------------

doc/whats-new.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ v2025.02.0 (unreleased)
2121

2222
New Features
2323
~~~~~~~~~~~~
24+
- Added :py:meth:`DataTree.filter_like` to conveniently restructure a DataTree like another DataTree (:issue:`10096`, :pull:`10097`).
25+
By `Kobe Vandelanotte <https://github.com/kobebryant432>`_.
2426
- Added :py:meth:`Coordinates.from_xindex` as convenience for creating a new :py:class:`Coordinates` object
2527
directly from an existing Xarray index object if the latter supports it (:pull:`10000`)
2628
By `Benoit Bovy <https://github.com/benbovy>`_.
@@ -60,9 +62,18 @@ Bug fixes
6062
- Fix DataArray().drop_attrs(deep=False) and add support for attrs to
6163
DataArray()._replace(). (:issue:`10027`, :pull:`10030`). By `Jan
6264
Haacker <https://github.com/j-haacker>`_.
65+
- Prevent false resolution change warnings from being emitted when decoding
66+
timedeltas encoded with floating point values, and make it clearer how to
67+
silence this warning message in the case that it is rightfully emitted
68+
(:issue:`10071`, :pull:`10072`). By `Spencer Clark
69+
<https://github.com/spencerkclark>`_.
6370
- Fix ``isel`` for multi-coordinate Xarray indexes (:issue:`10063`, :pull:`10066`).
6471
By `Benoit Bovy <https://github.com/benbovy>`_.
65-
72+
- Fix dask tokenization when opening each node in :py:func:`xarray.open_datatree`
73+
(:issue:`10098`, :pull:`10100`). By `Sam Levang <https://github.com/slevang>`_.
74+
- Improve handling of dtype and NaT when encoding/decoding masked and packaged
75+
datetimes and timedeltas (:issue:`8957`, :pull:`10050`).
76+
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
6677

6778
Documentation
6879
~~~~~~~~~~~~~
@@ -103,7 +114,7 @@ class can be passed through the ``decode_times`` keyword argument (see also
103114
coder = xr.coders.CFDatetimeCoder(time_unit="s")
104115
ds = xr.open_dataset(filename, decode_times=coder)
105116
106-
Similar control of the resoution of decoded timedeltas can be achieved through
117+
Similar control of the resolution of decoded timedeltas can be achieved through
107118
passing a :py:class:`coders.CFTimedeltaCoder` instance to the
108119
``decode_timedelta`` keyword argument:
109120

pyproject.toml

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
[project]
2-
authors = [
3-
{ name = "xarray Developers", email = "[email protected]" },
4-
]
2+
authors = [{ name = "xarray Developers", email = "[email protected]" }]
53
classifiers = [
64
"Development Status :: 5 - Production/Stable",
75
"License :: OSI Approved :: Apache Software License",
@@ -22,11 +20,7 @@ name = "xarray"
2220
readme = "README.md"
2321
requires-python = ">=3.10"
2422

25-
dependencies = [
26-
"numpy>=1.24",
27-
"packaging>=23.2",
28-
"pandas>=2.1",
29-
]
23+
dependencies = ["numpy>=1.24", "packaging>=23.2", "pandas>=2.1"]
3024

3125
# We don't encode minimum requirements here (though if we can write a script to
3226
# generate the text from `min_deps_check.py`, that's welcome...). We do add
@@ -70,6 +64,7 @@ types = [
7064
"types-PyYAML",
7165
"types-Pygments",
7266
"types-colorama",
67+
"types-decorator",
7368
"types-defusedxml",
7469
"types-docutils",
7570
"types-networkx",
@@ -93,10 +88,7 @@ dask = "xarray.namedarray.daskmanager:DaskManager"
9388

9489
[build-system]
9590
build-backend = "setuptools.build_meta"
96-
requires = [
97-
"setuptools>=42",
98-
"setuptools-scm>=7",
99-
]
91+
requires = ["setuptools>=42", "setuptools-scm>=7"]
10092

10193
[tool.setuptools]
10294
packages = ["xarray"]
@@ -120,10 +112,7 @@ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING"]
120112

121113
[tool.mypy]
122114
enable_error_code = ["ignore-without-code", "redundant-self", "redundant-expr"]
123-
exclude = [
124-
'build',
125-
'xarray/util/generate_.*\.py',
126-
]
115+
exclude = ['build', 'xarray/util/generate_.*\.py']
127116
files = "xarray"
128117
show_error_context = true
129118
warn_redundant_casts = true
@@ -254,10 +243,7 @@ module = ["xarray.namedarray.*", "xarray.tests.test_namedarray"]
254243
# reportMissingTypeStubs = false
255244

256245
[tool.ruff]
257-
extend-exclude = [
258-
"doc",
259-
"_typed_ops.pyi",
260-
]
246+
extend-exclude = ["doc", "_typed_ops.pyi"]
261247

262248
[tool.ruff.lint]
263249
extend-select = [
@@ -383,3 +369,64 @@ test = "pytest"
383369
ignore = [
384370
"PP308", # This option creates a large amount of log lines.
385371
]
372+
373+
[tool.typos]
374+
375+
[tool.typos.default]
376+
extend-ignore-identifiers-re = [
377+
# Variable names
378+
"nd_.*",
379+
".*_nd",
380+
"ba_.*",
381+
".*_ba",
382+
"ser_.*",
383+
".*_ser",
384+
# Function/class names
385+
"NDArray.*",
386+
".*NDArray.*",
387+
]
388+
389+
[tool.typos.default.extend-words]
390+
# NumPy function names
391+
arange = "arange"
392+
393+
# Technical terms
394+
nd = "nd"
395+
nin = "nin"
396+
397+
# Variable names
398+
ba = "ba"
399+
ser = "ser"
400+
fo = "fo"
401+
iy = "iy"
402+
vart = "vart"
403+
ede = "ede"
404+
405+
# Organization/Institution names
406+
Stichting = "Stichting"
407+
Mathematisch = "Mathematisch"
408+
409+
# People's names
410+
Soler = "Soler"
411+
Bruning = "Bruning"
412+
Tung = "Tung"
413+
Claus = "Claus"
414+
Celles = "Celles"
415+
slowy = "slowy"
416+
Commun = "Commun"
417+
418+
# Tests
419+
Ome = "Ome"
420+
SUR = "SUR"
421+
Tio = "Tio"
422+
Ono = "Ono"
423+
abl = "abl"
424+
425+
# Technical terms
426+
splitted = "splitted"
427+
childs = "childs"
428+
cutted = "cutted"
429+
LOCA = "LOCA"
430+
431+
[tool.typos.type.jupyter]
432+
extend-ignore-re = ["\"id\": \".*\""]

xarray/backends/api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@
3535
from xarray.backends.locks import _get_scheduler
3636
from xarray.coders import CFDatetimeCoder, CFTimedeltaCoder
3737
from xarray.core import dtypes, indexing
38+
from xarray.core.chunk import _get_chunk, _maybe_chunk
3839
from xarray.core.combine import (
3940
_infer_concat_order_from_positions,
4041
_nested_combine,
4142
combine_by_coords,
4243
)
4344
from xarray.core.dataarray import DataArray
44-
from xarray.core.dataset import Dataset, _get_chunk, _maybe_chunk
45+
from xarray.core.dataset import Dataset
4546
from xarray.core.datatree import DataTree
4647
from xarray.core.indexes import Index
4748
from xarray.core.treenode import group_subtrees
@@ -461,6 +462,7 @@ def _datatree_from_backend_datatree(
461462
inline_array,
462463
chunked_array_type,
463464
from_array_kwargs,
465+
node=path,
464466
**extra_tokens,
465467
)
466468
for path, [node] in group_subtrees(backend_tree)

xarray/backends/zarr.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ def _get_zarr_dims_and_attrs(zarr_obj, dimension_key, try_nczarr):
375375
pass
376376
else:
377377
attributes = dict(zarr_obj.attrs)
378+
if len(zarr_obj.shape) != len(dimensions):
379+
raise KeyError(
380+
"Zarr object is missing the `dimension_names` metadata which is "
381+
"required for xarray to determine variable dimensions."
382+
)
378383
return dimensions, attributes
379384

380385
# Zarr arrays do not have dimensions. To get around this problem, we add
@@ -393,7 +398,13 @@ def _get_zarr_dims_and_attrs(zarr_obj, dimension_key, try_nczarr):
393398

394399
# NCZarr defines dimensions through metadata in .zarray
395400
zarray_path = os.path.join(zarr_obj.path, ".zarray")
396-
zarray = json.loads(zarr_obj.store[zarray_path])
401+
if _zarr_v3():
402+
import asyncio
403+
404+
zarray_str = asyncio.run(zarr_obj.store.get(zarray_path)).to_bytes()
405+
else:
406+
zarray_str = zarr_obj.store.get(zarray_path)
407+
zarray = json.loads(zarray_str)
397408
try:
398409
# NCZarr uses Fully Qualified Names
399410
dimensions = [

0 commit comments

Comments
 (0)