PyEIS
PyEIS copied to clipboard
Error using Lin_kk function
Running the ex4.Lin_KK(legend='potential') function in the tutorial gives me the following error:
~\anaconda3\lib\site-packages\PyEIS\PyEIS.py", line 2639, in Lin_KK
self.KK_rr_re.append(residual_real(re=self.df[i].re, fit_re=self.KK_circuit_fit[i].real, fit_im=-self.KK_circuit_fit[i].imag)) #relative residuals for the real part
~\anaconda3\lib\site-packages\pandas\core\generic.py", line 5139, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'real'
I am able to successful run all previous tutorial examples. Has anyone experienced a similar issue and discovered a solution? I am running Python 3.8.3 on Windows 10. Thanks.
yep. It's a known issue. You're going to have to make the circuit fit a numpy value
You might just want to grab n-block's version. He seems to be on top of things (https://github.com/n-bock/PyEIS)
I've fixed the this issue, but have no authority of "pull request" but I've tested attached code, works well.
Reason why issue happened is self.KK_circuit_fit[i].real and self.KK_circuit_fit[i].imag not aligned to array data format.
so it should be changed following (I'm in office so not possible to upload the screen shot and code)
#changed by Gim
length_of_kk_circuit_fit = len(self.KK_circuit_fit[i])
KK_circuit_fit_real = []
KK_circuit_fit_imag = []
for idx in range(length_of_kk_circuit_fit):
KK_circuit_fit_real.append(self.KK_circuit_fit[i][idx+length_of_kk_circuit_fit].real)
KK_circuit_fit_imag.append(self.KK_circuit_fit[i][idx + length_of_kk_circuit_fit].imag)
KK_circuit_fit_real = np.array(KK_circuit_fit_real)
KK_circuit_fit_imag = np.array(KK_circuit_fit_imag)
self.KK_rr_re.append(residual_real(re=self.df[i].re, fit_re=KK_circuit_fit_real, fit_im=-KK_circuit_fit_imag))#relative residuals for the real part
self.KK_rr_im.append(residual_imag(im=self.df[i].im, fit_re=KK_circuit_fit_real, fit_im=-KK_circuit_fit_imag)) #relative residuals for the imag part
# changed by Gim
#self.KK_rr_re.append(residual_real(re=self.df[i].re, fit_re=self.KK_circuit_fit[i].real, fit_im=-self.KK_circuit_fit[i].imag)) #relative residuals for the real part
#self.KK_rr_im.append(residual_imag(im=self.df[i].im, fit_re=self.KK_circuit_fit[i].real, fit_im=-self.KK_circuit_fit[i].imag)) #relative residuals for the imag part
yep. It's a known issue. You're going to have to make the circuit fit a numpy value
yes,the method you offered can let the code run fluently,3Q