@@ -4432,7 +4432,7 @@ def test_where_drop_no_indexes(self):
4432
4432
actual = ds .where (ds == 1 , drop = True )
4433
4433
assert_identical (expected , actual )
4434
4434
4435
- def test_reduce (self ):
4435
+ def test_reduce (self ) -> None :
4436
4436
data = create_test_data ()
4437
4437
4438
4438
assert len (data .mean ().coords ) == 0
@@ -4443,21 +4443,21 @@ def test_reduce(self):
4443
4443
4444
4444
assert_equal (data .min (dim = ["dim1" ]), data .min (dim = "dim1" ))
4445
4445
4446
- for reduct , expected in [
4446
+ for reduct , expected_dims in [
4447
4447
("dim2" , ["dim3" , "time" , "dim1" ]),
4448
4448
(["dim2" , "time" ], ["dim3" , "dim1" ]),
4449
4449
(("dim2" , "time" ), ["dim3" , "dim1" ]),
4450
4450
((), ["dim2" , "dim3" , "time" , "dim1" ]),
4451
4451
]:
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
4454
4454
4455
4455
assert_equal (data .mean (dim = []), data )
4456
4456
4457
4457
with pytest .raises (ValueError ):
4458
4458
data .mean (axis = 0 )
4459
4459
4460
- def test_reduce_coords (self ):
4460
+ def test_reduce_coords (self ) -> None :
4461
4461
# regression test for GH1470
4462
4462
data = xr .Dataset ({"a" : ("x" , [1 , 2 , 3 ])}, coords = {"b" : 4 })
4463
4463
expected = xr .Dataset ({"a" : 2 }, coords = {"b" : 4 })
@@ -4481,7 +4481,7 @@ def test_mean_uint_dtype(self):
4481
4481
)
4482
4482
assert_identical (actual , expected )
4483
4483
4484
- def test_reduce_bad_dim (self ):
4484
+ def test_reduce_bad_dim (self ) -> None :
4485
4485
data = create_test_data ()
4486
4486
with pytest .raises (ValueError , match = r"Dataset does not contain" ):
4487
4487
data .mean (dim = "bad_dim" )
@@ -4516,7 +4516,7 @@ def test_reduce_cumsum_test_dims(self, reduct, expected, func):
4516
4516
actual = getattr (data , func )(dim = reduct ).dims
4517
4517
assert list (actual ) == expected
4518
4518
4519
- def test_reduce_non_numeric (self ):
4519
+ def test_reduce_non_numeric (self ) -> None :
4520
4520
data1 = create_test_data (seed = 44 )
4521
4521
data2 = create_test_data (seed = 44 )
4522
4522
add_vars = {"var4" : ["dim1" , "dim2" ], "var5" : ["dim1" ]}
@@ -4533,7 +4533,7 @@ def test_reduce_non_numeric(self):
4533
4533
@pytest .mark .filterwarnings (
4534
4534
"ignore:Once the behaviour of DataArray:DeprecationWarning"
4535
4535
)
4536
- def test_reduce_strings (self ):
4536
+ def test_reduce_strings (self ) -> None :
4537
4537
expected = Dataset ({"x" : "a" })
4538
4538
ds = Dataset ({"x" : ("y" , ["a" , "b" ])})
4539
4539
ds .coords ["y" ] = [- 10 , 10 ]
@@ -4570,7 +4570,7 @@ def test_reduce_strings(self):
4570
4570
actual = ds .min ()
4571
4571
assert_identical (expected , actual )
4572
4572
4573
- def test_reduce_dtypes (self ):
4573
+ def test_reduce_dtypes (self ) -> None :
4574
4574
# regression test for GH342
4575
4575
expected = Dataset ({"x" : 1 })
4576
4576
actual = Dataset ({"x" : True }).sum ()
@@ -4585,7 +4585,7 @@ def test_reduce_dtypes(self):
4585
4585
actual = Dataset ({"x" : ("y" , [1 , 1j ])}).sum ()
4586
4586
assert_identical (expected , actual )
4587
4587
4588
- def test_reduce_keep_attrs (self ):
4588
+ def test_reduce_keep_attrs (self ) -> None :
4589
4589
data = create_test_data ()
4590
4590
_attrs = {"attr1" : "value1" , "attr2" : 2929 }
4591
4591
@@ -4627,7 +4627,7 @@ def test_reduce_scalars(self):
4627
4627
actual = ds .var ("a" )
4628
4628
assert_identical (expected , actual )
4629
4629
4630
- def test_reduce_only_one_axis (self ):
4630
+ def test_reduce_only_one_axis (self ) -> None :
4631
4631
def mean_only_one_axis (x , axis ):
4632
4632
if not isinstance (axis , integer_types ):
4633
4633
raise TypeError ("non-integer axis" )
@@ -4643,7 +4643,7 @@ def mean_only_one_axis(x, axis):
4643
4643
):
4644
4644
ds .reduce (mean_only_one_axis )
4645
4645
4646
- def test_reduce_no_axis (self ):
4646
+ def test_reduce_no_axis (self ) -> None :
4647
4647
def total_sum (x ):
4648
4648
return np .sum (x .flatten ())
4649
4649
@@ -4655,7 +4655,7 @@ def total_sum(x):
4655
4655
with pytest .raises (TypeError , match = r"unexpected keyword argument 'axis'" ):
4656
4656
ds .reduce (total_sum , dim = "x" )
4657
4657
4658
- def test_reduce_keepdims (self ):
4658
+ def test_reduce_keepdims (self ) -> None :
4659
4659
ds = Dataset (
4660
4660
{"a" : (["x" , "y" ], [[0 , 1 , 2 , 3 , 4 ]])},
4661
4661
coords = {
0 commit comments