Skip to content

Fix voigt DomainError during optimization - #5

Merged
garrekstemo merged 1 commit into
mainfrom
fix/voigt-domain-error
Mar 24, 2026
Merged

Fix voigt DomainError during optimization#5
garrekstemo merged 1 commit into
mainfrom
fix/voigt-domain-error

Conversation

@garrekstemo

Copy link
Copy Markdown
Owner

Summary

Use abs on σ and γ width parameters inside the voigt function to prevent DomainError when the optimizer explores negative parameter space.

Problem

The Thompson et al. (1987) FWHM approximation uses odd powers (fG^5, fL^5) that preserve the sign of the input. When σ or γ go negative during optimization, f5 becomes negative, and f5^(1/5) raises a DomainError because Julia can't raise negative reals to fractional powers.

Other models (gaussian, lorentzian) don't have this issue because they square their width parameters (σ^2, Γ^2), making them always positive.

Test plan

  • All 262 CurveFitModels tests pass
  • Fixes QPSLab CI issue #8 (voigt model fit returns 500)

During optimization, σ and γ can go negative. The Thompson et al.
approximation uses odd powers (fG^5, fL^5) that preserve sign, making
f5 negative. f5^(1/5) then raises DomainError for negative reals.
@garrekstemo
garrekstemo merged commit 1bde9b8 into main Mar 24, 2026
3 checks passed
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ee8dcc1) to head (a1eabd3).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #5   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          101       101           
=========================================
  Hits           101       101           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@garrekstemo garrekstemo mentioned this pull request Mar 24, 2026
@garrekstemo
garrekstemo deleted the fix/voigt-domain-error branch June 22, 2026 08:03
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.

2 participants