Skip to content

Commit d87b209

Browse files
committed
Merge branch 'main' of https://github.com/pydata/xarray
2 parents 6a23bfb + 7a654ad commit d87b209

File tree

14 files changed

+74
-60
lines changed

14 files changed

+74
-60
lines changed

doc/whats-new.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Bug fixes
3232
By `Deepak Cherian <https://github.com/dcherian>`_.
3333
- Check and fix character array string dimension names, issue warnings as needed (:issue:`6352`, :pull:`10395`).
3434
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
35-
35+
- Fix the error message of :py:func:`testing.assert_equal` when two different :py:class:`DataTree` objects
36+
are passed (:pull:`10440`). By `Mathias Hauser <https://github.com/mathause>`_.
3637

3738

3839
Documentation
@@ -1009,7 +1010,7 @@ New Features
10091010
for example, will retain the object. However, one cannot do operations that are not possible on the ``ExtensionArray``
10101011
then, such as broadcasting. (:issue:`5287`, :issue:`8463`, :pull:`8723`)
10111012
By `Ilan Gold <https://github.com/ilan-gold>`_.
1012-
- :py:func:`testing.assert_allclose`/:py:func:`testing.assert_equal` now accept a new argument ``check_dims="transpose"``, controlling whether a transposed array is considered equal. (:issue:`5733`, :pull:`8991`)
1013+
- :py:func:`testing.assert_allclose` / :py:func:`testing.assert_equal` now accept a new argument ``check_dims="transpose"``, controlling whether a transposed array is considered equal. (:issue:`5733`, :pull:`8991`)
10131014
By `Ignacio Martinez Vazquez <https://github.com/ignamv>`_.
10141015
- Added the option to avoid automatically creating 1D pandas indexes in :py:meth:`Dataset.expand_dims()`, by passing the new kwarg
10151016
``create_index_for_new_dim=False``. (:pull:`8960`)

xarray/coding/cftime_offsets.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,18 @@ def _shift_month(date, months, day_option: DayOption = "start"):
289289
_ = attempt_import("cftime")
290290

291291
has_year_zero = date.has_year_zero
292-
delta_year = (date.month + months) // 12
292+
year = date.year + (date.month + months) // 12
293293
month = (date.month + months) % 12
294294

295295
if month == 0:
296296
month = 12
297-
delta_year = delta_year - 1
297+
year -= 1
298298

299299
if not has_year_zero:
300-
if date.year < 0 and date.year + delta_year >= 0:
301-
delta_year = delta_year + 1
302-
elif date.year > 0 and date.year + delta_year <= 0:
303-
delta_year = delta_year - 1
304-
305-
year = date.year + delta_year
300+
if date.year < 0 <= year:
301+
year += 1
302+
elif year <= 0 < date.year:
303+
year -= 1
306304

307305
# Silence warnings associated with generating dates with years < 1.
308306
with warnings.catch_warnings():

xarray/core/coordinates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ def _update_coords(
788788
# check for inconsistent state *before* modifying anything in-place
789789
dims = calculate_dimensions(variables)
790790
new_coord_names = set(coords)
791-
for dim in dims.keys():
791+
for dim in dims:
792792
if dim in variables:
793793
new_coord_names.add(dim)
794794

xarray/core/formatting.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,15 +1039,13 @@ def diff_dataset_repr(a, b, compat):
10391039
def diff_nodewise_summary(a: DataTree, b: DataTree, compat):
10401040
"""Iterates over all corresponding nodes, recording differences between data at each location."""
10411041

1042-
compat_str = _compat_to_str(compat)
1043-
10441042
summary = []
10451043
for path, (node_a, node_b) in group_subtrees(a, b):
10461044
a_ds, b_ds = node_a.dataset, node_b.dataset
10471045

10481046
if not a_ds._all_compat(b_ds, compat):
10491047
path_str = "root node" if path == "." else f"node {path!r}"
1050-
dataset_diff = diff_dataset_repr(a_ds, b_ds, compat_str)
1048+
dataset_diff = diff_dataset_repr(a_ds, b_ds, compat)
10511049
data_diff = indent(
10521050
"\n".join(dataset_diff.split("\n", 1)[1:]), prefix=" "
10531051
)

xarray/core/indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,7 @@ def __setitem__(self, indexer: ExplicitIndexer, value: Any) -> None:
21512151
)
21522152

21532153
def transpose(self, order: Iterable[int]) -> Self:
2154-
new_dims = tuple([self._dims[i] for i in order])
2154+
new_dims = tuple(self._dims[i] for i in order)
21552155
return type(self)(self._transform, self._coord_name, new_dims)
21562156

21572157
def __repr__(self: Any) -> str:

xarray/core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ def attempt_import(module: str) -> ModuleType:
12921292
reason = package_purpose.get(package_name, "")
12931293
try:
12941294
return importlib.import_module(module)
1295-
except (ImportError, ModuleNotFoundError) as e:
1295+
except ImportError as e:
12961296
raise ImportError(
12971297
f"The {install_name} package is required {reason}"
12981298
" but could not be imported."

xarray/plot/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ def _determine_cmap_params(
248248
isinstance(levels, Iterable) and levels[0] * levels[-1] < 0
249249
)
250250
# kwargs not specific about divergent or not: infer defaults from data
251-
divergent = (
252-
((vmin < 0) and (vmax > 0)) or not center_is_none or levels_are_divergent
253-
)
251+
divergent = (vmin < 0 < vmax) or not center_is_none or levels_are_divergent
254252
else:
255253
divergent = False
256254

xarray/structure/merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ def merge_core(
718718
coord_names.intersection_update(variables)
719719
if explicit_coords is not None:
720720
coord_names.update(explicit_coords)
721-
for dim in dims.keys():
721+
for dim in dims:
722722
if dim in variables:
723723
coord_names.add(dim)
724724
ambiguous_coords = coord_names.intersection(noncoord_names)

xarray/tests/arrays.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
This module contains various lazy array classes which can be wrapped and manipulated by xarray objects but will raise on data access.
3+
"""
4+
15
from collections.abc import Callable, Iterable
26
from typing import Any
37

@@ -6,10 +10,6 @@
610
from xarray.core import utils
711
from xarray.core.indexing import ExplicitlyIndexed
812

9-
"""
10-
This module contains various lazy array classes which can be wrapped and manipulated by xarray objects but will raise on data access.
11-
"""
12-
1313

1414
class UnexpectedDataAccess(Exception):
1515
pass

xarray/tests/test_backends.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3803,13 +3803,11 @@ def assert_expected_files(expected: list[str], store: str) -> None:
38033803
]
38043804
)
38053805

3806-
assert set(expected) == set(
3807-
[
3808-
file.lstrip("c/")
3809-
for file in ls
3810-
if (file not in (".zattrs", ".zarray", "zarr.json"))
3811-
]
3812-
)
3806+
assert set(expected) == {
3807+
file.lstrip("c/")
3808+
for file in ls
3809+
if (file not in (".zattrs", ".zarray", "zarr.json"))
3810+
}
38133811

38143812
# The zarr format is set by the `default_zarr_format`
38153813
# pytest fixture that acts on a superclass

0 commit comments

Comments
 (0)