make log-spacing explicit option for custom fit x values (#227)
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m53s
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m53s
closes #225
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from math import isnan
|
||||
|
||||
from pyqtgraph import mkBrush, mkPen
|
||||
@ -28,6 +30,7 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.extrapolate_box.stateChanged.connect(lambda x: self.maxx_line.setEnabled(x))
|
||||
self.extrapolate_box.stateChanged.connect(lambda x: self.minx_line.setEnabled(x))
|
||||
self.extrapolate_box.stateChanged.connect(lambda x: self.numx_line.setEnabled(x))
|
||||
self.extrapolate_box.stateChanged.connect(lambda x: self.newx_log_checkbox.setEnabled(x))
|
||||
|
||||
self._previous_fits = {}
|
||||
self._opts = []
|
||||
@ -352,7 +355,7 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
parts = self.partial_checkBox.checkState() == QtCore.Qt.CheckState.Checked
|
||||
|
||||
extrapolate = [None, None, None]
|
||||
extrapolate = [None, None, None, None]
|
||||
error = []
|
||||
if self.extrapolate_box.isChecked():
|
||||
try:
|
||||
@ -368,6 +371,8 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
|
||||
except (TypeError, ValueError):
|
||||
error.append('Number of points is missing')
|
||||
|
||||
extrapolate[3] = self.newx_log_checkbox.isChecked()
|
||||
|
||||
if error:
|
||||
msg = QtWidgets.QMessageBox.warning(self, 'Error', 'Extrapolation failed because:\n' + '\n'.join(error))
|
||||
return
|
||||
@ -405,10 +410,13 @@ class FitExtension(QtWidgets.QDialog):
|
||||
self.num_pts.setValidator(QtGui.QIntValidator())
|
||||
gridLayout.addWidget(self.num_pts, 2, 1, 1, 1)
|
||||
|
||||
self.logx_checkbox = QtWidgets.QCheckBox('Log-spaced?')
|
||||
gridLayout.addWidget(self.logx_checkbox, 3, 0, 1, 2)
|
||||
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox()
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok)
|
||||
gridLayout.addWidget(self.buttonBox, 3, 0, 1, 2)
|
||||
gridLayout.addWidget(self.buttonBox, 4, 0, 1, 2)
|
||||
|
||||
self.setLayout(gridLayout)
|
||||
|
||||
@ -416,12 +424,13 @@ class FitExtension(QtWidgets.QDialog):
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
def values(self) -> tuple[float, float, int, bool] | None:
|
||||
try:
|
||||
xmin = float(self.min_line.text())
|
||||
xmax = float(self.max_line.text())
|
||||
nums = int(self.num_pts.text())
|
||||
logx = self.logx_checkbox.isChecked()
|
||||
except TypeError:
|
||||
return None
|
||||
|
||||
return xmin, xmax, nums
|
||||
return xmin, xmax, nums, logx
|
||||
|
Reference in New Issue
Block a user