add value to namespace entries
This commit is contained in:
parent
fa7ed8810f
commit
37d93bb577
@ -22,51 +22,59 @@ class Namespace:
|
|||||||
|
|
||||||
if basic:
|
if basic:
|
||||||
self.add_namespace(
|
self.add_namespace(
|
||||||
{'x': (None, 'x values'),
|
{
|
||||||
'y': (None, 'x values'),
|
'x': (None, 'x values'),
|
||||||
'y_err': (None, 'y error values'),
|
'y': (None, 'x values'),
|
||||||
'fit': (None, 'dictionary of fit parameter', 'fit["PIKA"]'),
|
'y_err': (None, 'y error values'),
|
||||||
'np': (np, 'numpy module'),
|
'fit': (None, 'dictionary of fit parameter', 'fit["PIKA"]'),
|
||||||
|
'np': (np, 'numpy module'),
|
||||||
},
|
},
|
||||||
parents=('Basic', 'General'),
|
parents=('Basic', 'General'),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.add_namespace(
|
self.add_namespace(
|
||||||
{'sin': (np.sin, 'Sine', 'sin(PIKA)'),
|
{
|
||||||
'cos': (np.cos, 'Cosine', 'cos(PIKA)'),
|
'sin': (np.sin, 'Sine', 'sin(PIKA)'),
|
||||||
'tan': (np.tan, 'Tangens', 'tan(PIKA)'),
|
'cos': (np.cos, 'Cosine', 'cos(PIKA)'),
|
||||||
'ln': (np.log, 'Natural Logarithm', 'ln(PIKA)'),
|
'tan': (np.tan, 'Tangens', 'tan(PIKA)'),
|
||||||
'log': (np.log10, 'Logarithm (base 10)', 'log(PIKA)'),
|
'ln': (np.log, 'Natural Logarithm', 'ln(PIKA)'),
|
||||||
'exp': (np.exp, 'Exponential', 'exp(PIKA)'),
|
'log': (np.log10, 'Logarithm (base 10)', 'log(PIKA)'),
|
||||||
'sqrt': (np.sqrt, 'Root', 'sqrt(PIKA)'),
|
'exp': (np.exp, 'Exponential', 'exp(PIKA)'),
|
||||||
'lin_range': (np.linspace, 'N evenly spaced over interval [start, stop]', 'lin_range(start, stop, N)'),
|
'sqrt': (np.sqrt, 'Root', 'sqrt(PIKA)'),
|
||||||
'log_range': (np.geomspace, 'N evenly spaced (log-scale) over interval [start, stop]', 'lin_range(start, stop, N)'),
|
'lin_range': (np.linspace, 'N evenly spaced over interval [start, stop]', 'lin_range(start, stop, N)'),
|
||||||
},
|
'log_range': (np.geomspace, 'N evenly spaced (log-scale) over interval [start, stop]', 'lin_range(start, stop, N)'),
|
||||||
|
},
|
||||||
parents=('Basic', 'Functions'))
|
parents=('Basic', 'Functions'))
|
||||||
|
|
||||||
self.add_namespace(
|
self.add_namespace(
|
||||||
{'max': (np.max, 'Maximum value', 'max(PIKA)'),
|
{
|
||||||
'min': (np.min, 'Minimum value', 'min(PIKA)'),
|
'max': (np.max, 'Maximum value', 'max(PIKA)'),
|
||||||
'argmax': (np.argmax, 'Index of maximum value', 'argmax(PIKA)'),
|
'min': (np.min, 'Minimum value', 'min(PIKA)'),
|
||||||
'argmin': (np.argmax, 'Index of minimum value', 'argmin(PIKA)'),
|
'argmax': (np.argmax, 'Index of maximum value', 'argmax(PIKA)'),
|
||||||
},
|
'argmin': (np.argmax, 'Index of minimum value', 'argmin(PIKA)'),
|
||||||
|
},
|
||||||
parents=('Basic', 'Values')),
|
parents=('Basic', 'Values')),
|
||||||
|
|
||||||
if const:
|
if const:
|
||||||
self.add_namespace(
|
self.add_namespace(
|
||||||
{'e': (constants.e, 'e / As'),
|
{
|
||||||
'eps0': (constants.epsilon0, 'epsilon0 / As/Vm'),
|
'e': (constants.e, 'e / As'),
|
||||||
'Eu': (constants.Eu,), 'h': (constants.h, 'h / eVs'),
|
'eps0': (constants.epsilon0, 'epsilon0 / As/Vm'),
|
||||||
'hbar': (constants.hbar, 'hbar / eVs'), 'kB': (constants.kB, 'kB / eV/K'),
|
'Eu': (constants.Eu,),
|
||||||
'mu0': (constants.mu0, 'mu0 / Vs/Am'), 'NA': (constants.NA, 'NA / 1/mol'),
|
'h': (constants.h, 'h / eVs'),
|
||||||
'pi': (constants.pi,), 'R': (constants.R, 'R / eV'),
|
'hbar': (constants.hbar, 'hbar / eVs'),
|
||||||
},
|
'kB': (constants.kB, 'kB / eV/K'),
|
||||||
|
'mu0': (constants.mu0, 'mu0 / Vs/Am'),
|
||||||
|
'NA': (constants.NA, 'NA / 1/mol'),
|
||||||
|
'pi': (constants.pi,),
|
||||||
|
'R': (constants.R, 'R / eV'),
|
||||||
|
},
|
||||||
parents=('Constants', 'Maybe useful'),
|
parents=('Constants', 'Maybe useful'),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.add_namespace(
|
self.add_namespace(
|
||||||
{f'gamma["{k}"]': (v, k, f'gamma["{k}"]') for k, v in constants.gamma.items()},
|
{f'gamma["{k}"]': (v, k, f'gamma["{k}"]') for k, v in constants.gamma.items()},
|
||||||
parents=('Constants', 'Magnetogyric ratios (in 1/(sT))')
|
parents=('Constants', 'Gyromagnetic ratios (in 1/(sT))')
|
||||||
)
|
)
|
||||||
|
|
||||||
if fitfuncs:
|
if fitfuncs:
|
||||||
@ -199,7 +207,7 @@ class QNamespaceWidget(QtWidgets.QWidget, Ui_Form):
|
|||||||
|
|
||||||
for entry in subspace:
|
for entry in subspace:
|
||||||
key_item = QtWidgets.QTableWidgetItem(entry)
|
key_item = QtWidgets.QTableWidgetItem(entry)
|
||||||
key_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
key_item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||||
|
|
||||||
vals = self.namespace.namespace[entry]
|
vals = self.namespace.namespace[entry]
|
||||||
|
|
||||||
@ -214,12 +222,12 @@ class QNamespaceWidget(QtWidgets.QWidget, Ui_Form):
|
|||||||
display = vals[1]
|
display = vals[1]
|
||||||
|
|
||||||
value_item = QtWidgets.QTableWidgetItem(display)
|
value_item = QtWidgets.QTableWidgetItem(display)
|
||||||
value_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
value_item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||||
|
|
||||||
key_item.setData(QtCore.Qt.UserRole, alias)
|
key_item.setData(QtCore.Qt.ItemDataRole.UserRole, alias)
|
||||||
key_item.setData(QtCore.Qt.UserRole+1, entry)
|
key_item.setData(QtCore.Qt.ItemDataRole.UserRole+1, entry)
|
||||||
value_item.setData(QtCore.Qt.UserRole, alias)
|
value_item.setData(QtCore.Qt.ItemDataRole.UserRole, alias)
|
||||||
value_item.setData(QtCore.Qt.UserRole+1, entry)
|
value_item.setData(QtCore.Qt.ItemDataRole.UserRole+1, entry)
|
||||||
|
|
||||||
row = self.namespace_table.rowCount()
|
row = self.namespace_table.rowCount()
|
||||||
self.namespace_table.setRowCount(row+1)
|
self.namespace_table.setRowCount(row+1)
|
||||||
@ -241,5 +249,5 @@ class QNamespaceWidget(QtWidgets.QWidget, Ui_Form):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot(QtWidgets.QTableWidgetItem, name='on_namespace_table_itemDoubleClicked')
|
@QtCore.pyqtSlot(QtWidgets.QTableWidgetItem, name='on_namespace_table_itemDoubleClicked')
|
||||||
def item_selected(self, item: QtWidgets.QTableWidgetItem):
|
def item_selected(self, item: QtWidgets.QTableWidgetItem):
|
||||||
self.selected.emit(item.data(QtCore.Qt.UserRole))
|
self.selected.emit(item.data(QtCore.Qt.ItemDataRole.UserRole))
|
||||||
self.sendKey.emit(item.data(QtCore.Qt.UserRole+1))
|
self.sendKey.emit(item.data(QtCore.Qt.ItemDataRole.UserRole+1))
|
||||||
|
Loading…
Reference in New Issue
Block a user