Skip to content
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

test_nonzero in test_searching_functions.py incorrectly handle 0d inputs #194

Open
oleksandr-pavlyk opened this issue Aug 8, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@oleksandr-pavlyk
Copy link
Contributor

xp.nonzero is documented in the spec to require an exception for 0d arrays:

x (array) – input array. Must have a positive rank. If x is zero-dimensional, the function must raise an exception.

Yet the code exercises xp.nonzero for zero-dimensional arrays and expects the function to returns a tuple of size 1:

out = xp.nonzero(x)
if x.ndim == 0:
assert len(out) == 1, f"{len(out)=}, but should be 1 for 0-dimensional arrays"
else:
assert len(out) == x.ndim, f"{len(out)=}, but should be {x.ndim=}"
out_size = math.prod(out[0].shape)

This discrepancy should be fixed, or the spec modified.

@honno honno added the bug Something isn't working label Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants