Numpy surprises
From Tech
Jump to navigationJump to search
New in numpy version 2: numpy int types aren't promoted to bigger types.
>>> np.uint8(1) + 255 <python-input-21>:1: RuntimeWarning: overflow encountered in scalar add np.uint8(0)
>>> np.__version__ '2.2.4'
The old numpy 1.24 used to promote numpy int types to 64-bit:
>>> type(np.uint8(1) + 1) <class 'numpy.int64'> >>> np.__version__ '1.24.2'