Skip to content

argmin() and argmax() buggy with NULL objects #6032

@pitrou

Description

@pitrou

The source code for argmin() and argmax() purports to handle NULL objects (for object arrays), but the code handling them is buggy:

a = np.empty(4, dtype='O')
ctypes.memset(a.ctypes.data, 0, a.nbytes)
a[1] = 10
a[3] = 30

print(np.argmin(a))  # should be 1, returns 0
print(np.argmax(a))  # should be 3, returns 0

min() and max() take another approach: they interpret the NULL pointers as references to None.

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