-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Closed
Labels
Description
full and full_like permit out-of-bounds Python integers, which is inconsistent as of Numpy 2.0.
In [2]: import numpy as np
In [3]: np.full(10, -1, dtype="u1")
Out[3]: array([255, 255, 255, 255, 255, 255, 255, 255, 255, 255], dtype=uint8)
In [4]: np.full_like(np.ones(10, dtype="u1"), -1, dtype="u1")
Out[4]: array([255, 255, 255, 255, 255, 255, 255, 255, 255, 255], dtype=uint8)
In [5]: np.arange(-5, 0, 1, dtype="u1")
---------------------------------------------------------------------------
OverflowError Traceback (most recent call last)
Cell In[5], line 1
----> 1 np.arange(-5, 0, 1, dtype="u1")
OverflowError: Python integer -5 out of bounds for uint8
asarray and arange don't permit it, and this is a (very) malformed workflow, so it seems logical to change.
Reactions are currently unavailable