Not compatible with pandas >= 0.19.0
Opened this issue · 4 comments
pgkirsch commented
fit.py
uses pandas.Series.reshape
, which, per the pandas docs has been deprecated since pandas 0.19.0:
https://pandas.pydata.org/pandas-docs/version/0.22/generated/pandas.Series.reshape.html
bqpd commented
oh wild, where does it use it? probably the easiest fix is to convert to numpy before the reshape.
pgkirsch commented
I was mistaken. fit.py
doesn't use pandas.Series.reshape
; this occurs when I use a pd.Series
object as my input.
Example is if we make one of the input arrays for gpfit/examples/ex63.py
a pd.Series:
from numpy import log, exp, log10, vstack
from gpfit.fit import fit
from numpy.random import random_sample
import pandas as pd
Vdd = pd.Series(random_sample(1000,) + 1)
Vth = 0.2*random_sample(1000,) + 0.2
P = Vdd**2 + 30*Vdd*exp(-(Vth-0.06*Vdd)/0.039)
u = vstack((Vdd,Vth))
x = log(u)
y = log(P)
K = 4
cstrt, rmsErr = fit(x, y, K, "ISMA")
yields
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~/Optimization/gpfit/gpfit/examples/pd.py in <module>
12 K = 4
13
---> 14 cstrt, rmsErr = fit(x,y,K,"ISMA")
~/Optimization/gpfit/gpfit/fit.py in fit(xdata, ydata, K, ftype)
78 fitdata["ub%d" % i] = exp(max(xdata.T[i]))
79
---> 80 params = get_params(ftype, K, xdata, ydata)
81
82 # A: exponent parameters, B: coefficient parameters
~/Optimization/gpfit/gpfit/fit.py in get_params(ftype, K, xdata, ydata)
23 return r, drdp
24
---> 25 ba = ba_init(xdata, ydata.reshape(ydata.size, 1), K).flatten('F')
26
27 if ftype == "ISMA":
/opt/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py in __getattr__(self, name)
5137 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5138 return self[name]
-> 5139 return object.__getattribute__(self, name)
5140
5141 def __setattr__(self, name: str, value) -> None:
AttributeError: 'Series' object has no attribute 'reshape'
I agree with @bqpd's suggestion to make sure all input arrays are numpy arrays as a pre-process step.
pgkirsch commented
Or make it a ux change and raise an error if the input type isn't a numpy array.