opengate icon indicating copy to clipboard operation
opengate copied to clipboard

np.float_ or np.double ?

Open dsarrut opened this issue 10 months ago • 2 comments

in opengate/geometry/utility.py” Maybe “np.float_” should be “np.double”. Unsure if related to numpy 2.0 ?

dsarrut avatar Apr 23 '24 12:04 dsarrut

For the moment numpy is a rc version for version 2. ITK and pybind still have problem with that version. Check this commit: https://github.com/OpenGATE/opengate/commit/0036491c0d88aa6b25e1ba94b0e23d4af6b742cc

tbaudier avatar Apr 23 '24 15:04 tbaudier

You can test the following

import numpy as np

print(np.finfo(np.longdouble))
print(np.finfo(np.double))
print(np.finfo(np.float_))

you will get:

  • longdouble is equivalent to float64 on Windows but different in NIX
  • double is just the Python API “C-like” name of float64
  • float is just the default float for most systems which it's just float64 but can be different (especially for ARM based machines where is equivalent to float32)

Therefore, float shall be replaced by float64 if you want 64 bit precision at least, otherwise it's safe to be used Source: https://numpy.org/devdocs/user/basics.types.html

BishopWolf avatar Apr 30 '24 09:04 BishopWolf