Skip to content

Open fit dialogs when the initial automatic fit fails - #27

Merged
PierreRaybaut merged 2 commits into
developfrom
fix/guifit-initial-autofit
Oct 28, 2026
Merged

PierreRaybaut merged 2 commits into
developfrom
fix/guifit-initial-autofit

Conversation

@PierreRaybaut

Copy link
Copy Markdown
Contributor

Fixes #26. Complements PlotPyStack/PlotPy#77 (PlotPyStack/PlotPy#76).

Problem

guifit runs an automatic fit before showing the fit dialog, and only ignored ValueError if it failed. Any other error propagated, and the dialog was never shown. For example, a fit with fewer points than parameters raises TypeError in leastsq. With PlotPy up to 2.11.1, a fitted value far outside its slider range raised OverflowError at this point.

Change

The initial fit only gives a better starting point. guifit now ignores any exception it raises (broad-except, as elsewhere in SigimaX), and the dialog opens with the initial parameter values.

Tests

  • test_guifit_opens_when_initial_fit_fails: FitDialog.autofit raises TypeError, OverflowError or ZeroDivisionError, and the dialog is still shown with the initial values.
  • test_gaussian_fit_dialog_opens_with_too_few_points: the real case of a Gaussian fit on 3 points.
  • These 4 tests fail without the fix, and sigimax/tests/widgets/test_fitdialog.py passes (38 tests). Ruff passes and Pylint gives 10/10 on fitdialog.py.

Documentation

Release note in "Curve fitting dialogs" (release_1.01.md), with its French translation. Only this entry was added to the catalog, which is already out of date for other recent entries.

`guifit` only ignored `ValueError` raised by the initial automatic fit: any
other error (e.g. `TypeError` from `leastsq` with fewer points than
parameters) propagated and the fit dialog was never shown. The initial fit only
gives a better starting point, so any failure now leaves the initial parameter
values in the dialog.

Fixes #26

Assisted-by: Claude Opus 5.5
@PierreRaybaut
PierreRaybaut merged commit 31f57f9 into develop Oct 28, 2026
8 checks passed
@PierreRaybaut
PierreRaybaut deleted the fix/guifit-initial-autofit branch October 29, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant