Here is a minimal code example:
import numpy as np
x = np.array(1e-35, dtype=np.double)
y = int(1e19)
print( type(x/y) )
y = int(1e20)
print( type(x/y) )
On my machine in the former case it prints numpy.float64, and in the latter case it prints float. I imagine the specific numbers will vary on different machines, but the point is that for small ints the division preserves type, while for large ints the type is cast to a Python float. I would like to know whether this is a bug in Numpy or not, and whether there are any solutions besides manually casting everything to be a double.
It seems harmless, but when I try to write a ufunc and the cast only happens on certain elements of an array, the return type becomes object, and the program throws a "could not be coerced to provided output parameter" error.