Skip to content

Commit 9a54e0c

Browse files
committed
Remove filters for warnings from argmin/argmax from tests
Pass an explicit axis or dim argument instead to avoid the warning.
1 parent a758b0f commit 9a54e0c

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

xarray/tests/test_units.py

+6-18
Original file line numberDiff line numberDiff line change
@@ -1408,8 +1408,8 @@ def test_real_and_imag(self):
14081408
(
14091409
method("all"),
14101410
method("any"),
1411-
method("argmax"),
1412-
method("argmin"),
1411+
method("argmax", axis=0),
1412+
method("argmin", axis=0),
14131413
method("argsort"),
14141414
method("cumprod"),
14151415
method("cumsum"),
@@ -1427,9 +1427,6 @@ def test_real_and_imag(self):
14271427
),
14281428
ids=repr,
14291429
)
1430-
@pytest.mark.filterwarnings(
1431-
"ignore:Behaviour of argmin/argmax with neither dim nor :DeprecationWarning"
1432-
)
14331430
def test_aggregation(self, func, dtype):
14341431
array = np.linspace(0, 1, 10).astype(dtype) * (
14351432
unit_registry.m if func.name != "cumprod" else unit_registry.dimensionless
@@ -2280,8 +2277,8 @@ def test_repr(self, func, variant, dtype):
22802277
function("cumprod"),
22812278
method("all"),
22822279
method("any"),
2283-
method("argmax"),
2284-
method("argmin"),
2280+
method("argmax", axis=0),
2281+
method("argmin", axis=0),
22852282
method("max"),
22862283
method("mean"),
22872284
method("median"),
@@ -2298,9 +2295,6 @@ def test_repr(self, func, variant, dtype):
22982295
),
22992296
ids=repr,
23002297
)
2301-
@pytest.mark.filterwarnings(
2302-
"ignore:Behaviour of argmin/argmax with neither dim nor :DeprecationWarning"
2303-
)
23042298
def test_aggregation(self, func, dtype):
23052299
array = np.arange(10).astype(dtype) * (
23062300
unit_registry.m if func.name != "cumprod" else unit_registry.dimensionless
@@ -3853,8 +3847,8 @@ def test_repr(self, func, variant, dtype):
38533847
function("cumprod"),
38543848
method("all"),
38553849
method("any"),
3856-
method("argmax"),
3857-
method("argmin"),
3850+
method("argmax", axis=0),
3851+
method("argmin", axis=0),
38583852
method("max"),
38593853
method("min"),
38603854
method("mean"),
@@ -3871,12 +3865,6 @@ def test_repr(self, func, variant, dtype):
38713865
),
38723866
ids=repr,
38733867
)
3874-
@pytest.mark.filterwarnings(
3875-
"ignore:Once the behaviour of DataArray:DeprecationWarning"
3876-
)
3877-
@pytest.mark.filterwarnings(
3878-
"ignore:Behaviour of argmin/argmax with neither dim nor :DeprecationWarning"
3879-
)
38803868
def test_aggregation(self, func, dtype):
38813869
unit_a, unit_b = (
38823870
(unit_registry.Pa, unit_registry.degK)

xarray/tests/test_variable.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1639,9 +1639,6 @@ def test_big_endian_reduce(self):
16391639
expected = Variable([], 5)
16401640
assert_identical(expected, v.sum())
16411641

1642-
@pytest.mark.filterwarnings(
1643-
"ignore:Behaviour of argmin/argmax with neither dim nor :DeprecationWarning"
1644-
)
16451642
def test_reduce_funcs(self):
16461643
v = Variable("x", np.array([1, np.nan, 2, 3]))
16471644
assert_identical(v.mean(), Variable([], 2))
@@ -1660,7 +1657,7 @@ def test_reduce_funcs(self):
16601657
assert_identical(v.all(dim="x"), Variable([], False))
16611658

16621659
v = Variable("t", pd.date_range("2000-01-01", periods=3))
1663-
assert v.argmax(skipna=True) == 2
1660+
assert v.argmax(skipna=True, dim="t") == 2
16641661

16651662
assert_identical(v.max(), Variable([], pd.Timestamp("2000-01-03")))
16661663

0 commit comments

Comments
 (0)