Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 25, 2024
1 parent d9660b3 commit fd7c748
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
6 changes: 4 additions & 2 deletions src/iminuit/minuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2348,8 +2348,10 @@ def interactive(
Minuit.visualize
"""
try:
if (get_ipython().__class__.__name__ == "ZMQInteractiveShell"
and "IPKernelApp" in get_ipython().config):
if (
get_ipython().__class__.__name__ == "ZMQInteractiveShell"
and "IPKernelApp" in get_ipython().config
):
is_jupyter = True
else:
is_jupyter = False
Expand Down
46 changes: 24 additions & 22 deletions src/iminuit/qtwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,26 @@ def __init__(self, minuit, par, callback):

size_policy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Policy.MinimumExpanding,
QtWidgets.QSizePolicy.Policy.Fixed)
QtWidgets.QSizePolicy.Policy.Fixed,
)
self.setSizePolicy(size_policy)
layout = QtWidgets.QVBoxLayout()
self.setLayout(layout)

label = QtWidgets.QLabel(
par, alignment=QtCore.Qt.AlignmentFlag.AlignCenter)
label = QtWidgets.QLabel(par, alignment=QtCore.Qt.AlignmentFlag.AlignCenter)
label.setMinimumSize(QtCore.QSize(50, 0))
self.value_label = QtWidgets.QLabel(
alignment=QtCore.Qt.AlignmentFlag.AlignCenter)
alignment=QtCore.Qt.AlignmentFlag.AlignCenter
)
self.value_label.setMinimumSize(QtCore.QSize(50, 0))
self.slider = FloatSlider(self.value_label)
self.tmin = QtWidgets.QDoubleSpinBox(
alignment=QtCore.Qt.AlignmentFlag.AlignCenter)
alignment=QtCore.Qt.AlignmentFlag.AlignCenter
)
self.tmin.setRange(_make_finite(-np.inf), _make_finite(np.inf))
self.tmax = QtWidgets.QDoubleSpinBox(
alignment=QtCore.Qt.AlignmentFlag.AlignCenter)
alignment=QtCore.Qt.AlignmentFlag.AlignCenter
)
self.tmax.setRange(_make_finite(-np.inf), _make_finite(np.inf))
self.tmin.setSizePolicy(size_policy)
self.tmax.setSizePolicy(size_policy)
Expand All @@ -162,8 +165,8 @@ def __init__(self, minuit, par, callback):
self.fit.setCheckable(True)
self.fit.setChecked(False)
size_policy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Policy.Fixed,
QtWidgets.QSizePolicy.Policy.Fixed)
QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed
)
self.fix.setSizePolicy(size_policy)
self.fit.setSizePolicy(size_policy)
layout1 = QtWidgets.QHBoxLayout()
Expand Down Expand Up @@ -278,7 +281,8 @@ def __init__(self):
plot_group = QtWidgets.QGroupBox("", parent=interactive_tab)
size_policy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Policy.MinimumExpanding,
QtWidgets.QSizePolicy.Policy.MinimumExpanding)
QtWidgets.QSizePolicy.Policy.MinimumExpanding,
)
plot_group.setSizePolicy(size_policy)
plot_layout = QtWidgets.QVBoxLayout(plot_group)
fig, ax = plt.subplots()
Expand All @@ -290,24 +294,23 @@ def __init__(self):
button_group = QtWidgets.QGroupBox("", parent=interactive_tab)
size_policy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Policy.Expanding,
QtWidgets.QSizePolicy.Policy.Fixed)
QtWidgets.QSizePolicy.Policy.Fixed,
)
button_group.setSizePolicy(size_policy)
button_layout = QtWidgets.QHBoxLayout(button_group)
self.fit_button = QtWidgets.QPushButton("Fit", parent=button_group)
self.fit_button.setStyleSheet(
"background-color: #2196F3; color: white")
self.fit_button.setStyleSheet("background-color: #2196F3; color: white")
self.fit_button.clicked.connect(partial(self.do_fit, plot=True))
button_layout.addWidget(self.fit_button)
self.update_button = QtWidgets.QPushButton(
"Continuous", parent=button_group)
"Continuous", parent=button_group
)
self.update_button.setCheckable(True)
self.update_button.setChecked(True)
self.update_button.clicked.connect(self.on_update_button_clicked)
button_layout.addWidget(self.update_button)
self.reset_button = QtWidgets.QPushButton(
"Reset", parent=button_group)
self.reset_button.setStyleSheet(
"background-color: #F44336; color: white")
self.reset_button = QtWidgets.QPushButton("Reset", parent=button_group)
self.reset_button.setStyleSheet("background-color: #F44336; color: white")
self.reset_button.clicked.connect(self.on_reset_button_clicked)
button_layout.addWidget(self.reset_button)
self.algo_choice = QtWidgets.QComboBox(parent=button_group)
Expand All @@ -320,7 +323,8 @@ def __init__(self):
scroll_area.setWidgetResizable(True)
size_policy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Policy.MinimumExpanding,
QtWidgets.QSizePolicy.Policy.MinimumExpanding)
QtWidgets.QSizePolicy.Policy.MinimumExpanding,
)
scroll_area.setSizePolicy(size_policy)
scroll_area_contents = QtWidgets.QWidget()
parameter_layout = QtWidgets.QVBoxLayout(scroll_area_contents)
Expand Down Expand Up @@ -352,8 +356,7 @@ def fit(self):
assert False # pragma: no cover, should never happen
return True

def on_parameter_change(self, from_fit=False,
report_success=False):
def on_parameter_change(self, from_fit=False, report_success=False):
if not from_fit:
if any(x.fit.isChecked() for x in self.parameters):
saved = minuit.fixed[:]
Expand All @@ -378,8 +381,7 @@ def do_fit(self, plot=True):
x.reset(val=minuit.values[i])
if not plot:
return report_success
self.on_parameter_change(
from_fit=True, report_success=report_success)
self.on_parameter_change(from_fit=True, report_success=report_success)

def on_update_button_clicked(self):
for x in self.parameters:
Expand Down

0 comments on commit fd7c748

Please sign in to comment.