You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Curve fitting: OverflowError when a fitted value is far outside the parameter slider range #76
In the curve fitting dialog (plotpy.widgets.fit), running the automatic fit may raise an unhandled exception when a fitted parameter value ends up far outside the [min, max] range of its slider:
Traceback (most recent call last):
File "plotpy/widgets/fit.py", line 749, in autofit
prm.update()
File "plotpy/widgets/fit.py", line 354, in update
self.update_slider_value()
File "plotpy/widgets/fit.py", line 328, in update_slider_value
self.slider.setValue(intval)
OverflowError: argument 1 overflowed: value must be in the range -2147483648 to 2147483647
Besides the error message, the dialog is left in an inconsistent state:
the slider of the faulty parameter stays unresponsive: the exception is raised between blockSignals(True) and blockSignals(False), so moving the slider no longer changes the value;
the fields of the parameters following the faulty one are not updated, while the fit curve already shows the new values.
To Reproduce
Open a fit dialog on a Gaussian peak (e.g. y = 5 exp(-x²/2) on [-10, 10], with parameters ranges of a few units)
Click "Bounds" and restrict the fit range to the tail of the peak, e.g. [8, 10]
In "Settings", choose the Powell method
Click "Run"
The amplitude diverges and the exception above is raised (the computed slider position is about 1e14)
Only L-BFGS-B uses the [min, max] bounds of the parameters: the other methods (including the default least squares method) are unconstrained, so any ill-posed fit may move a parameter far away from its slider range.
Expected behavior
The fit result is displayed without error: the slider stays at the nearest end of its range, remains usable, and all parameter fields show the fitted values. A value outside the slider range should be visible as such.
Additional context
The cause is in FitParam.update_slider_value, which converts the value into a slider position without clipping it to the slider range:
With steps = 5000, a value about 430 000 times the range width away from min exceeds the 32-bit range of QSlider.setValue. The same code path fails in other situations:
min == max and a different value: division by zero, then OverflowError: cannot convert float infinity to integer (or ZeroDivisionError when the dialog is created)
log scale with a value below min - 1: ValueError: cannot convert float NaN to integer
nan or inf typed in a parameter field: accepted as values, then ValueError/OverflowError
a "Steps" value of 1 in the parameter properties dialog: ZeroDivisionError when the slider is moved
Activity
fix(fit): keep parameter sliders usable when a value is outside their…
PierreRaybaut commentedon Oct 28, 2026
Fixed in 2.11.2 by #77 (merged into
release), and cherry-picked intodevelop(42d5da4, 42451a3).