The following code:
>>> import numpy as np
>>> np.arange(2).astype(np.int8) * 127
produces for numpy 1.13.3
# On Windows
array([0, 127], dtype=int16)
# On Linux
array([0, 127], dtype=int8)
However, if I change the 127 to a 126, both return a np.int8 array. And if I change the 127 to a 128 both return a np.int16 array.
Questions:
- Is this expected behaviour?
- Why is it different for the two platforms for this one case?
numpy.can_cast(127, numpy.int8, casting='safe')returnsFalseon Windows.