Skip to content

Commit a1af177

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0b2d4a2 commit a1af177

File tree

7 files changed

+33
-18
lines changed

7 files changed

+33
-18
lines changed

xarray/core/coordinates.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@
2121
assert_no_index_corrupted,
2222
create_default_index_implicit,
2323
)
24-
from xarray.core.types import CompatOptions, DataVars, ErrorOptions, Self, T_DataArray, T_Xarray
24+
from xarray.core.types import (
25+
CompatOptions,
26+
DataVars,
27+
ErrorOptions,
28+
Self,
29+
T_DataArray,
30+
T_Xarray,
31+
)
2532
from xarray.core.utils import (
2633
Frozen,
2734
ReprObject,
@@ -507,7 +514,9 @@ def _merge_raw(self, other, reflexive, compat: CompatOptions | CombineKwargDefau
507514
indexes = dict(self.xindexes)
508515
else:
509516
coord_list = [self, other] if not reflexive else [other, self]
510-
variables, indexes = merge_coordinates_without_align(coord_list, compat=compat)
517+
variables, indexes = merge_coordinates_without_align(
518+
coord_list, compat=compat
519+
)
511520
return variables, indexes
512521

513522
@contextmanager
@@ -533,7 +542,7 @@ def merge(
533542
self,
534543
other: Mapping[Any, Any] | None,
535544
compat: CompatOptions | CombineKwargDefault = "minimal",
536-
) -> Dataset:
545+
) -> Dataset:
537546
"""Merge two sets of coordinates to create a new Dataset
538547
539548
The method implements the logic used for joining coordinates in the

xarray/core/dataarray.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4900,7 +4900,8 @@ def _binary_op(
49004900
else f(other_variable_or_arraylike, self.variable)
49014901
)
49024902
coords, indexes = self.coords._merge_raw(
4903-
other_coords, reflexive, compat=OPTIONS["arithmetic_compat"])
4903+
other_coords, reflexive, compat=OPTIONS["arithmetic_compat"]
4904+
)
49044905
name = result_name([self, other])
49054906

49064907
return self._replace(variable, coords, name, indexes=indexes)
@@ -4920,7 +4921,9 @@ def _inplace_binary_op(self, other: DaCompatible, f: Callable) -> Self:
49204921
other_coords = getattr(other, "coords", None)
49214922
other_variable = getattr(other, "variable", other)
49224923
try:
4923-
with self.coords._merge_inplace(other_coords, compat=OPTIONS["arithmetic_compat"]):
4924+
with self.coords._merge_inplace(
4925+
other_coords, compat=OPTIONS["arithmetic_compat"]
4926+
):
49244927
f(self.variable, other_variable)
49254928
except MergeError as exc:
49264929
raise MergeError(

xarray/core/options.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
from collections.abc import Sequence
55
from typing import TYPE_CHECKING, Any, Literal, TypedDict, get_args
66

7-
from xarray.core.utils import FrozenDict
87
from xarray.core.types import CompatOptions
9-
from xarray.util.deprecation_helpers import CombineKwargDefault, _ARITHMETIC_COMPAT_DEFAULT
8+
from xarray.core.utils import FrozenDict
9+
from xarray.util.deprecation_helpers import (
10+
_ARITHMETIC_COMPAT_DEFAULT,
11+
CombineKwargDefault,
12+
)
1013

1114
if TYPE_CHECKING:
1215
from matplotlib.colors import Colormap

xarray/tests/test_dataarray.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,7 +2478,7 @@ def test_math_with_coords(self) -> None:
24782478
actual = 1 + orig
24792479
assert_identical(expected, actual)
24802480

2481-
with xr.set_options(arithmetic_compat='minimal'):
2481+
with xr.set_options(arithmetic_compat="minimal"):
24822482
actual = orig + orig[0, 0]
24832483
exp_coords = {k: v for k, v in coords.items() if k != "lat"}
24842484
expected = DataArray(
@@ -2490,9 +2490,7 @@ def test_math_with_coords(self) -> None:
24902490
assert_identical(expected, actual)
24912491

24922492
actual = orig[0, 0] + orig[-1, -1]
2493-
expected = DataArray(
2494-
orig.values[0, 0] + orig.values[-1, -1],
2495-
{"c": -999})
2493+
expected = DataArray(orig.values[0, 0] + orig.values[-1, -1], {"c": -999})
24962494
assert_identical(expected, actual)
24972495

24982496
actual = orig[:, 0] + orig[0, :]
@@ -2512,7 +2510,7 @@ def test_math_with_coords(self) -> None:
25122510

25132511
alt = DataArray([1, 1], {"x": [-1, -2], "c": "foo", "d": 555}, "x")
25142512

2515-
with xr.set_options(arithmetic_compat='minimal'):
2513+
with xr.set_options(arithmetic_compat="minimal"):
25162514
actual = orig + alt
25172515
expected = orig + 1
25182516
expected.coords["d"] = 555
@@ -2530,15 +2528,15 @@ def test_math_with_arithmetic_compat_options(self) -> None:
25302528
coords={
25312529
"x": [1, 2, 3],
25322530
"foo": (["x"], [1.0, 2.0, np.nan]),
2533-
}
2531+
},
25342532
)
25352533
b = xr.DataArray(
25362534
data=[0, 0, 0],
25372535
dims=["x"],
25382536
coords={
25392537
"x": [1, 2, 3],
25402538
"foo": (["x"], [np.nan, 2.0, 3.0]),
2541-
}
2539+
},
25422540
)
25432541

25442542
with xr.set_options(arithmetic_compat="minimal"):

xarray/tests/test_dataset.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6841,14 +6841,14 @@ def test_binary_op_compat_setting(self) -> None:
68416841
coords={
68426842
"x": [1, 2, 3],
68436843
"foo": (["x"], [1.0, 2.0, np.nan]),
6844-
}
6844+
},
68456845
)
68466846
b = xr.Dataset(
68476847
data_vars={"var": (["x"], [0, 0, 0])},
68486848
coords={
68496849
"x": [1, 2, 3],
68506850
"foo": (["x"], [np.nan, 2.0, 3.0]),
6851-
}
6851+
},
68526852
)
68536853

68546854
with xr.set_options(arithmetic_compat="minimal"):
@@ -6869,7 +6869,6 @@ def test_binary_op_compat_setting(self) -> None:
68696869
with pytest.raises(MergeError):
68706870
b + a
68716871

6872-
68736872
@pytest.mark.parametrize(
68746873
["keep_attrs", "expected"],
68756874
(

xarray/tests/test_interp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,9 @@ def test_interpolate_chunk_1d(
940940
for dim in interp_dims:
941941
if dim in scalar_dims:
942942
# take the middle point
943-
dest[dim] = 0.5 * (da.coords[dim].data[0] + da.coords[dim].data[-1])
943+
dest[dim] = 0.5 * (
944+
da.coords[dim].data[0] + da.coords[dim].data[-1]
945+
)
944946
else:
945947
# pick some points, including outside the domain
946948
before = 2 * da.coords[dim].data[0] - da.coords[dim].data[1]

xarray/util/deprecation_helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def __eq__(self, other: Self | Any) -> bool:
175175
@property
176176
def _value(self) -> str | None:
177177
from xarray.core.options import OPTIONS # Break circular dependency.
178+
178179
return self._new if OPTIONS["use_new_combine_kwarg_defaults"] else self._old
179180

180181
def __hash__(self) -> int:

0 commit comments

Comments
 (0)