Skip to content

Commit 797be52

Browse files
committed
resolve the argmin / argmax warnings by opting into the new behavior
1 parent a0b471d commit 797be52

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

xarray_array_testing/reduction.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from contextlib import nullcontext
22

33
import hypothesis.strategies as st
4+
import numpy as np
45
import pytest
56
import xarray.testing.strategies as xrst
67
from hypothesis import given
@@ -61,11 +62,13 @@ def test_variable_order_reduce_index(self, op, data):
6162

6263
with self.expected_errors(op, variable=variable):
6364
# compute using xr.Variable.<OP>()
64-
actual = getattr(variable, op)().data
65+
actual = {k: v.item() for k, v in getattr(variable, op)(dim=...).items()}
66+
6567
# compute using xp.<OP>(array)
66-
expected = getattr(self.xp, op)(variable.data)
68+
index = getattr(self.xp, op)(variable.data)
69+
unraveled = np.unravel_index(index, variable.shape)
70+
expected = dict(zip(variable.dims, unraveled))
6771

68-
assert isinstance(actual, self.array_type)
6972
self.assert_equal(actual, expected)
7073

7174
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)