Skip to content

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

Open
@oleksandr-pavlyk

Description

@oleksandr-pavlyk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions