Skip to content

ENH: test count_nonzero with tuple axes #372

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 1 commit into from
May 9, 2025
Merged
Changes from all commits
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
6 changes: 4 additions & 2 deletions array_api_tests/test_searching_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math

import pytest
from hypothesis import given, note
from hypothesis import given, note, assume
from hypothesis import strategies as st

from . import _array_module as xp
Expand Down Expand Up @@ -106,13 +106,15 @@ def test_argmin(x, data):
def test_count_nonzero(x, data):
kw = data.draw(
hh.kwargs(
axis=st.none() | st.integers(-x.ndim, max(x.ndim - 1, 0)),
axis=hh.axes(x.ndim),
keepdims=st.booleans(),
),
label="kw",
)
keepdims = kw.get("keepdims", False)

assume(kw.get("axis", None) != ()) # TODO clarify in the spec

out = xp.count_nonzero(x, **kw)

ph.assert_default_index("count_nonzero", out.dtype)
Expand Down