Skip to content

Commit 45feeab

Browse files
committed
Annotate some reduction tests.
1 parent 2a1b12f commit 45feeab

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

xarray/tests/test_dataarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,7 @@ def test_cumops(self):
23922392
expected = DataArray([[-1, 0, 0], [-3, 0, 0]], coords, dims=["x", "y"])
23932393
assert_identical(expected, actual)
23942394

2395-
def test_reduce(self):
2395+
def test_reduce(self) -> None:
23962396
coords = {
23972397
"x": [-1, -2],
23982398
"y": ["ab", "cd", "ef"],
@@ -2433,7 +2433,7 @@ def test_reduce(self):
24332433
expected = DataArray(orig.values.astype(int), dims=["x", "y"]).mean("x")
24342434
assert_equal(actual, expected)
24352435

2436-
def test_reduce_keepdims(self):
2436+
def test_reduce_keepdims(self) -> None:
24372437
coords = {
24382438
"x": [-1, -2],
24392439
"y": ["ab", "cd", "ef"],

xarray/tests/test_dataset.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,7 +4432,7 @@ def test_where_drop_no_indexes(self):
44324432
actual = ds.where(ds == 1, drop=True)
44334433
assert_identical(expected, actual)
44344434

4435-
def test_reduce(self):
4435+
def test_reduce(self) -> None:
44364436
data = create_test_data()
44374437

44384438
assert len(data.mean().coords) == 0
@@ -4443,21 +4443,21 @@ def test_reduce(self):
44434443

44444444
assert_equal(data.min(dim=["dim1"]), data.min(dim="dim1"))
44454445

4446-
for reduct, expected in [
4446+
for reduct, expected_dims in [
44474447
("dim2", ["dim3", "time", "dim1"]),
44484448
(["dim2", "time"], ["dim3", "dim1"]),
44494449
(("dim2", "time"), ["dim3", "dim1"]),
44504450
((), ["dim2", "dim3", "time", "dim1"]),
44514451
]:
4452-
actual = list(data.min(dim=reduct).dims)
4453-
assert actual == expected
4452+
actual_dims = list(data.min(dim=reduct).dims)
4453+
assert actual_dims == expected_dims
44544454

44554455
assert_equal(data.mean(dim=[]), data)
44564456

44574457
with pytest.raises(ValueError):
44584458
data.mean(axis=0)
44594459

4460-
def test_reduce_coords(self):
4460+
def test_reduce_coords(self) -> None:
44614461
# regression test for GH1470
44624462
data = xr.Dataset({"a": ("x", [1, 2, 3])}, coords={"b": 4})
44634463
expected = xr.Dataset({"a": 2}, coords={"b": 4})
@@ -4481,7 +4481,7 @@ def test_mean_uint_dtype(self):
44814481
)
44824482
assert_identical(actual, expected)
44834483

4484-
def test_reduce_bad_dim(self):
4484+
def test_reduce_bad_dim(self) -> None:
44854485
data = create_test_data()
44864486
with pytest.raises(ValueError, match=r"Dataset does not contain"):
44874487
data.mean(dim="bad_dim")
@@ -4516,7 +4516,7 @@ def test_reduce_cumsum_test_dims(self, reduct, expected, func):
45164516
actual = getattr(data, func)(dim=reduct).dims
45174517
assert list(actual) == expected
45184518

4519-
def test_reduce_non_numeric(self):
4519+
def test_reduce_non_numeric(self) -> None:
45204520
data1 = create_test_data(seed=44)
45214521
data2 = create_test_data(seed=44)
45224522
add_vars = {"var4": ["dim1", "dim2"], "var5": ["dim1"]}
@@ -4533,7 +4533,7 @@ def test_reduce_non_numeric(self):
45334533
@pytest.mark.filterwarnings(
45344534
"ignore:Once the behaviour of DataArray:DeprecationWarning"
45354535
)
4536-
def test_reduce_strings(self):
4536+
def test_reduce_strings(self) -> None:
45374537
expected = Dataset({"x": "a"})
45384538
ds = Dataset({"x": ("y", ["a", "b"])})
45394539
ds.coords["y"] = [-10, 10]
@@ -4570,7 +4570,7 @@ def test_reduce_strings(self):
45704570
actual = ds.min()
45714571
assert_identical(expected, actual)
45724572

4573-
def test_reduce_dtypes(self):
4573+
def test_reduce_dtypes(self) -> None:
45744574
# regression test for GH342
45754575
expected = Dataset({"x": 1})
45764576
actual = Dataset({"x": True}).sum()
@@ -4585,7 +4585,7 @@ def test_reduce_dtypes(self):
45854585
actual = Dataset({"x": ("y", [1, 1j])}).sum()
45864586
assert_identical(expected, actual)
45874587

4588-
def test_reduce_keep_attrs(self):
4588+
def test_reduce_keep_attrs(self) -> None:
45894589
data = create_test_data()
45904590
_attrs = {"attr1": "value1", "attr2": 2929}
45914591

@@ -4627,7 +4627,7 @@ def test_reduce_scalars(self):
46274627
actual = ds.var("a")
46284628
assert_identical(expected, actual)
46294629

4630-
def test_reduce_only_one_axis(self):
4630+
def test_reduce_only_one_axis(self) -> None:
46314631
def mean_only_one_axis(x, axis):
46324632
if not isinstance(axis, integer_types):
46334633
raise TypeError("non-integer axis")
@@ -4643,7 +4643,7 @@ def mean_only_one_axis(x, axis):
46434643
):
46444644
ds.reduce(mean_only_one_axis)
46454645

4646-
def test_reduce_no_axis(self):
4646+
def test_reduce_no_axis(self) -> None:
46474647
def total_sum(x):
46484648
return np.sum(x.flatten())
46494649

@@ -4655,7 +4655,7 @@ def total_sum(x):
46554655
with pytest.raises(TypeError, match=r"unexpected keyword argument 'axis'"):
46564656
ds.reduce(total_sum, dim="x")
46574657

4658-
def test_reduce_keepdims(self):
4658+
def test_reduce_keepdims(self) -> None:
46594659
ds = Dataset(
46604660
{"a": (["x", "y"], [[0, 1, 2, 3, 4]])},
46614661
coords={

0 commit comments

Comments
 (0)