Skip to content

MAINT: remove a dead code branch from test_nonzero#419

Merged
ev-br merged 1 commit intodata-apis:masterfrom
ev-br:test_nonzero_dead_code
Feb 9, 2026
Merged

MAINT: remove a dead code branch from test_nonzero#419
ev-br merged 1 commit intodata-apis:masterfrom
ev-br:test_nonzero_dead_code

Conversation

@ev-br
Copy link
Member

@ev-br ev-br commented Feb 8, 2026

The branch is checking for x.ndim == 0, while the hypothesis decorator only generates arrays of at least ndim=1:

given(hh.arrays(dtype=hh.all_dtypes, shape=hh.shapes(min_dims=1, min_side=1)))

This is consistent with the spec:
https://data-apis.org/array-api/draft/API_specification/generated/array_api.nonzero.html

x (array) – input array. Must have one or more dimensions.
If x is zero-dimensional, the function must raise an exception.

closes #194

The branch is checking for x.ndim == 0, while the hypothesis
decorator only generates arrays of at least ndim=1:

`given(hh.arrays(dtype=hh.all_dtypes, shape=hh.shapes(min_dims=1, min_side=1)))`

This is consistent with the spec:
https://data-apis.org/array-api/draft/API_specification/generated/array_api.nonzero.html

> x (array) – input array. **Must** have one or more dimensions.
> If x is zero-dimensional, the function **must** raise an exception.
@ev-br
Copy link
Member Author

ev-br commented Feb 8, 2026

tested locally with cupy/torch/numpy

@ev-br ev-br merged commit fad527f into data-apis:master Feb 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_nonzero in test_searching_functions.py incorrectly handle 0d inputs

1 participant