Skip to content

Commit

Permalink
block_signals -> _block_signals
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Peter Krone committed Dec 16, 2024
1 parent 6c5f02b commit 63e0082
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/iminuit/qtwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ def on_val_changed(self, val):
def on_min_changed(self):
tmin = self.tmin.value()
if tmin >= self.vmax:
with block_signals(self.tmin):
with _block_signals(self.tmin):
self.tmin.setValue(self.vmin)
return
self.vmin = tmin
with block_signals(self.slider):
with _block_signals(self.slider):
if tmin > self.val:
self.val = tmin
minuit.values[self.par] = tmin
Expand All @@ -136,11 +136,11 @@ def on_min_changed(self):
def on_max_changed(self):
tmax = self.tmax.value()
if tmax <= self.tmin.value():
with block_signals(self.tmax):
with _block_signals(self.tmax):
self.tmax.setValue(self.vmax)
return
self.vmax = tmax
with block_signals(self.slider):
with _block_signals(self.slider):
if tmax < self.val:
self.val = tmax
minuit.values[self.par] = tmax
Expand Down Expand Up @@ -169,21 +169,21 @@ def reset(self, val, limits=None):
step = _widget_guess_initial_step(val, vmin, vmax)
self.vmin = vmin if np.isfinite(vmin) else val - 100 * step
self.vmax = vmax if np.isfinite(vmax) else val + 100 * step
with block_signals(self.tmin, self.tmax):
with _block_signals(self.tmin, self.tmax):
self.tmin.setValue(self.vmin)
self.tmax.setValue(self.vmax)

self.val = val
if self.val < self.vmin:
self.vmin = self.val
with block_signals(self.tmin):
with _block_signals(self.tmin):
self.tmin.setValue(self.vmin)
elif self.val > self.vmax:
self.vmax = self.val
with block_signals(self.tmax):
with _block_signals(self.tmax):
self.tmax.setValue(self.vmax)

with block_signals(self.slider):
with _block_signals(self.slider):
self.slider.setValue(self._float_to_int(self.val))
self.value_label.setText(f"{self.val:.3g}")

Expand Down Expand Up @@ -371,7 +371,7 @@ def on_reset_button_clicked(self):


@contextmanager
def block_signals(*widgets):
def _block_signals(*widgets):
for w in widgets:
w.blockSignals(True)
try:
Expand Down

0 comments on commit 63e0082

Please sign in to comment.