v0.22.2 - Input Validation for Threshold Fitting (2026-06-18)¶
What Changed?¶
This release adds input validation to fit_thresholds.py to catch bad measurement data before it causes a crash in plot_thresholds.py.
When a threshold scan is performed outside the detector's response region, the fitting now fails with a clear warning instead of silently producing corrupt output.
What's New¶
Main Feature: Early Validation in fit_channel_data()¶
What it does:
Detects two categories of bad fit data before calling scipy.curve_fit:
- Flat data: all threshold counts are identical (scan range too low)
- Non-finite parameters: fitted
muorsigmaisinfornan - Non-positive sigma:
sigma <= 0(physically meaningless fit)
When any of these conditions is detected, the affected channel is skipped with a yellow warning message. Other channels continue to be processed normally.
How to use it:
No change required. Run fit_thresholds.py as before. If a channel has bad data, you will now see:
Warning: Channel 1: all counts are identical (3). Threshold scan range may be too low. Skipping channel 1.
Installation¶
Quick Start¶
What's Different from the Last Version?¶
✅ Added¶
fit_thresholds.py: validation that raisesValueErrorwhen all counts are identical before callingcurve_fitfit_thresholds.py: validation that raisesValueErrorwhen fittedmuorsigmais non-finite (inf/nan)fit_thresholds.py: validation that raisesValueErrorwhen fittedsigmais non-positivefit_thresholds.py: warning when covariance matrix contains non-finite values
🐛 Fixed¶
plot_thresholds.pyno longer crashes withRendererAgg incompatible constructor argumentswhenthresholds_fitted.jsoncontainsInfinityincurve_y
Is It Safe to Upgrade?¶
Backward Compatible: Yes
- Users with valid measurement data will see no change in behavior
- Users with flat or out-of-range data will now get actionable warnings instead of a downstream crash
Tests Passed¶
- ✅ Builds without errors
- ✅ Valid data: fitting proceeds normally for all channels
- ✅ Flat data (all counts identical): channel skipped with warning
- ✅ Non-finite parameters after fit: channel skipped with warning
Release Details¶
- Date: 2026-06-18
- Version: v0.22.2
- Files Changed: 4
- Commits: 765110a (bump), fix(examples) commits
Next Steps¶
- Consider adding a warning when the scan range covers fewer than N data points for reliable fitting