Skip to content

dpt.nonzero returns array of int32 dtype #1322

Closed
@antonwolfy

Description

@antonwolfy

After merging #1300, the result array type of dpt.nonzero is changed:

a = dpt.ones(10, dtype="i8")
dpt.nonzero(a)[0].dtype
# Out: dtype('int32')

The result dtype depends now on array size and may vary between int32 and int64 on the same platform:

sz = numpy.iinfo("i4").max
a = dpt.ones(sz, dtype="i8")
dpt.nonzero(a)[0].dtype
# Out: dtype('int32')

sz = numpy.iinfo("i4").max + 1
a = dpt.ones(sz, dtype="i8")
dpt.nonzero(a)[0].dtype
# Out: dtype('int64')

The python array API states that:

The returned array must have the default array index data type.

and here is about the default array index type:

a default array index data type (either int32 or int64).
...
The default array index data type may be int32 on 32-bit platforms, but the default should be int64 otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions