pythonnumpy

RuntimeWarning: overflow encountered in scalar negative


I am getting this warning when I upgrade my numpy from 1.23.3 to 1.25.0

#For 1.23.3 version

import numpy as np
x = np.uint64(0xffffffff)

print(-x)
#output
18446744069414584321

#For 1.25.0 version

import numpy as np
x = np.uint64(0xffffffff)

print(-x)
#output
18446744069414584321
<ipython-input-4-adbfb5bb01c0>:1: RuntimeWarning: overflow encountered in scalar negative
  print(-x)

Anyone else is getting this warning message or its just me?


Solution

  • I found a bug reported at numpy/issues which is very similar to my question:

    Here is the link:

    https://github.com/numpy/numpy/issues/24737

    They are planning to make the changes in numpy 1.26.2