Skip to content

BUG: np.pad fails for sizes that do not fit in np.int_ #12023

@eric-wieser

Description

@eric-wieser
>>> np.pad(np.zeros((0, 0)), [(0, 2**30), (0, 0)],  'constant')
array([], shape=(1073741824, 0), dtype=float64)
>>> np.pad(np.zeros((0, 0)), [(0, 2**31), (0, 0)],  'constant')
ValueError: [(0, 2147483648), (0, 0)] cannot contain negative values.
>>> np.pad(np.zeros((0, 0)), [(0, 2**32), (0, 0)],  'constant')
array([], shape=(0, 0), dtype=float64)

Switching an internal cast to intp solves the issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions