In Numpy I tried the following. I suspect that this is not a bug. In case it is a feature, I do not understand it. Can somebody explain this? Thanks.
>>> np.array([173], dtype = np.uint8) * [360]
array([62280])
>>> np.array([173], dtype = np.uint8) * 360
array([-3256], dtype=int16)
>>>
The difference between these outputs is probably is caused by a bug in your numpy version.
The code
np.array([173], dtype = np.uint8) * [360]
is shorthand for:
np.array([173], dtype = np.uint8) * np.array([360])
# output array([62280])
And thus [360] is transformed to a numpy array with dtype=int. Multiplication takes the highest precision and thus it returns an array with int precision.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With