Skip to content

Commit

Permalink
Added fmin display to qtwidget
Browse files Browse the repository at this point in the history
  • Loading branch information
adryyan committed Dec 13, 2024
1 parent 0ec2969 commit f034929
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/iminuit/qtwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,20 @@ def __init__(self):
scroll_area_contents = QtWidgets.QWidget()
parameter_layout = QtWidgets.QVBoxLayout(scroll_area_contents)
par_scroll_area.setWidget(scroll_area_contents)
interactive_layout.addWidget(par_scroll_area, 1, 1, 1, 1)
interactive_layout.addWidget(par_scroll_area, 1, 1, 2, 1)
self.parameters = []
for par in minuit.parameters:
parameter = Parameter(minuit, par, self.on_parameter_change)
self.parameters.append(parameter)
parameter_layout.addWidget(parameter)
parameter_layout.addStretch()

self.results_text = QtWidgets.QTextEdit(parent=self)
self.results_text.setReadOnly(True)
self.results_text.setSizePolicy(size_policy)
self.results_text.setMaximumHeight(144)
interactive_layout.addWidget(self.results_text, 2, 0, 1, 1)

self.plot_with_frame(from_fit=False, report_success=False)

def plot_with_frame(self, from_fit, report_success):
Expand Down Expand Up @@ -330,6 +336,12 @@ def on_parameter_change(self, from_fit=False, report_success=False):
report_success = self.do_fit(plot=False)
minuit.fixed = saved

if from_fit:
self.results_text.clear()
self.results_text.setHtml(f"<div style='text-align: center;'>{minuit.fmin._repr_html_()}</div>")
else:
self.results_text.clear()

plt.clf()
self.plot_with_frame(from_fit, report_success)
self.canvas.draw_idle()
Expand Down

0 comments on commit f034929

Please sign in to comment.