Skip to content

Commit 16c7850

Browse files
committed
boolean reduce
1 parent 6a83950 commit 16c7850

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

xarray_array_testing/reduction.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@ def test_variable_numerical_reduce(self, op, data):
2525
expected = getattr(self.xp, op)(variable.data)
2626

2727
self.assert_equal(actual, expected)
28+
29+
@pytest.mark.parametrize("op", ["all", "any"])
30+
@given(st.data())
31+
def test_variable_boolean_reduce(self, op, data):
32+
variable = data.draw(xrst.variables(array_strategy_fn=self.array_strategy_fn))
33+
34+
with self.expected_errors(op, variable=variable):
35+
# compute using xr.Variable.<OP>()
36+
actual = getattr(variable, op)().data
37+
# compute using xp.<OP>(array)
38+
expected = getattr(self.xp, op)(variable.data)
39+
40+
assert isinstance(actual, self.array_type)
41+
self.assert_equal(actual, expected)

0 commit comments

Comments
 (0)