'numpy.nan to int shows different results on 2 computers
I am facing a very strange problem with numpy using this MWE:
import numpy
print(numpy.array(numpy.nan).astype(int))
- On my Mac Pro (2019), macOS 12.2.1, Python 3.9.10 and numpy 1.22.2, the result is
-9223372036854775808(smallestint64value). - On a Debian 10, Python 3.7.3 and numpy 1.21.4, the result is
-9223372036854775808 - On my MacBook Air (M1, 2020), macOS 12.2.1, Python 3.9.10 and numpy 1.22.2, the result is
0.
As far as I remember, numpy used to throw an error when trying to convert numpy.nan to int. This behavior seems to have changed, but the result is inconsistent.
Is there a reason for this behavior? Is it possible to ensure that numpy behaves the same on every machine? I can't find anything in the doc about this behavior.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
