The numpy polynomial fit function for masked arrays, ma.polyfit, crashes on integer iput:
import numpy.ma as ma
x = ma.arange(2)
y = ma.arange(2)
p1 = ma.polyfit(np.float32(x), y, deg=1)
p2 = ma.polyfit( x , y, deg=1)
The last line results in an error:
ValueError: data type <type 'numpy.int64'> not inexact
Why can’t I fit data with integer x-values (it’s no problem with the normal numpy.polyfit function), is this a (known) bug?
It is indeed a bug from
numpy.ma: thercond(a parameter to exclude some values ) takeslen(x)*np.finfo(x.dtypes).epsas a default value, andnp.int32does not have anyepsfield (because an int does not have a relative precision).I’ve looked quickly into numpy’s issues, and this bug does not seems to figured there. It might be a good idea to raise a new issue : New Issue