Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with pandas >= 0.19.0 #87

Open
pgkirsch opened this issue Jan 14, 2020 · 4 comments
Open

Not compatible with pandas >= 0.19.0 #87

pgkirsch opened this issue Jan 14, 2020 · 4 comments
Labels

Comments

@pgkirsch
Copy link
Contributor

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
Copy link
Contributor

bqpd commented Feb 4, 2020

oh wild, where does it use it? probably the easiest fix is to convert to numpy before the reshape.

@whoburg
Copy link
Collaborator

whoburg commented Feb 5, 2020

Thanks @pgkirsch. Do you have a simple test or example that produces this issue?

@pgkirsch
Copy link
Contributor Author

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
Copy link
Contributor Author

Or make it a ux change and raise an error if the input type isn't a numpy array.

@pgkirsch pgkirsch added the ux label Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants