Since yesterday I'm facing this issue I can't solve by myself. Can anyone please suggest a solution ?
File "C:/Myproj_python/pertesCVS.py", line 67, in recupVariables
Eon1 = float((self.Eon1_lineEdit.text()))
As shown in the code, I'm importing a GUI called pertesCVSUI
parametres generated by Qt designer.
In the method defined as RecupeVariables
I'm trying to store as variables what the user writes in some QlineEdits
and to do calculation on those float values in the method defined as fitenergy
.
import numpy as np
import pertesCVSUI
from PyQt5 import QtGui, QtWidgets
class PertesCVS(pertesCVSUI.Ui_PertesCVS):
def __init__(self, parent=None):
# super(PertesCVS, self).__init__(parent)
self.setupUi(parent)
self.recupVariables()
self.btnstate()
self.fitenergy()
def setupUi(self, parent):
super(PertesCVS, self).setupUi(parent)
# setup validators
self.Eon1_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Eon2_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Eon3_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Ion1_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Ion2_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Ion3_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Eoff1_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Eoff2_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Eoff3_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Ioff1_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Ioff2_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Ioff3_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Vcc_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Imax_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Fd_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Mod_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Rdson_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Dc_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
self.Tf_lineEdit.setValidator(QtGui.QDoubleValidator(0.99, 99.99, 3))
# setup connection
self.calculate.clicked.connect(self.recupVariables)
self.radioButton1.toggled.connect(self.btnstate)
self.radioButton2.toggled.connect(self.btnstate)
def btnstate(self):
if self.radioButton1.isChecked():
self.Mod_lineEdit.hide()
self.label_19.hide()
self.Dc_lineEdit.show()
self.label_22.show()
else:
self.Mod_lineEdit.show()
self.Dc_lineEdit.hide()
self.label_22.hide()
self.label_19.show()
def recupVariables(self):
Eon1 = float((self.Eon1_lineEdit.text()))
Eon2 = float((self.Eon2_lineEdit.text()))
Eon3 = float((self.Eon3_lineEdit.text()))
Ion1 = float((self.Ion1_lineEdit.text()))
Ion2 = float((self.Ion2_lineEdit.text()))
Ion3 = float((self.Ion3_lineEdit.text()))
Eoff1 = float((self.Eoff1_lineEdit.text()))
Eoff2 = float((self.Eoff2_lineEdit.text()))
Eoff3 = float((self.Eoff3_lineEdit.text()))
Ioff1 = float((self.Ioff1_lineEdit.text()))
Ioff2 = float((self.Ioff2_lineEdit.text()))
Ioff3 = float((self.Ioff3_lineEdit.text()))
Imax = (self.Imax_lineEdit.text())
Fd = (self.Fd_lineEdit.text())
def fitenergy(self):
##Energy on
Aon = np.array([[1, Ion1, Ion1 * Ion1], [1, Ion2, Ion2 * Ion2],
[1, Ion3, Ion3 * Ion3]]) ## the error appears here
Aon_inv = np.linalg.inv(Aon)
*strong
text *
Bon = np.array([Eon1, Eon2, Eon3])
xon = np.linalg.solve(Aon_inv, Bon)
##Energy_off
Aoff = np.array(
[[1, Ioff1, Ioff1 * Ioff1], [1, Ioff2, Ioff2 * Ioff2], [1, Ioff3, Ioff3 * Ioff3]])
Aoff_inv = np.linalg.inv(Aoff)
Boff = np.array([Eon1, Eon2, Eon3])
xoff = np.linalg.solve(Aoff_inv, Boff)
###
xon_T = np.transpose(xon)
xoff_T = np.transpose(xoff)
print(xon_T, xoff_T)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
main_widget = QtWidgets.QTabWidget()
ui = PertesCVS(main_widget)
main_widget.show()
sys.exit(app.exec_())