Skip to content

dpt.nonzero returns array of int32 dtype #1322

Closed

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.

Activity

  1. added 2 commits that reference this issue on Aug 2, 2023
    8ded9c3
    3fe2718
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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