Is there a way to disable silent conversions in numpy?
import numpy as np a = np.empty(10, int) a[2] = 4 # OK a[3] = 4.9 # Will silently convert to 4,
Just an idea.
#Python 2.7.3 >>> def test(value): ... if '.' in str(value): ... return str(value) ... else: ... return value ... >>> a[3]=test(4.0) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for long() with base 10: '4.0'