Skip to content

more reduction tests #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
boolean reduce
  • Loading branch information
keewis committed Aug 28, 2024
commit 16c785026414f89d9cc6e8d2d5ecbc7a6017a95e
14 changes: 14 additions & 0 deletions xarray_array_testing/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,17 @@ def test_variable_numerical_reduce(self, op, data):
expected = getattr(self.xp, op)(variable.data)

self.assert_equal(actual, expected)

@pytest.mark.parametrize("op", ["all", "any"])
@given(st.data())
def test_variable_boolean_reduce(self, op, data):
variable = data.draw(xrst.variables(array_strategy_fn=self.array_strategy_fn))

with self.expected_errors(op, variable=variable):
# compute using xr.Variable.<OP>()
actual = getattr(variable, op)().data
# compute using xp.<OP>(array)
expected = getattr(self.xp, op)(variable.data)

assert isinstance(actual, self.array_type)
self.assert_equal(actual, expected)