lmfit / lmfit-py

Non-Linear Least Squares Minimization, with flexible Parameter settings, based on scipy.optimize, and with many additional classes and methods for curve fitting.
https://lmfit.github.io/lmfit-py/
Other
1.06k stars 274 forks source link

restore best-fit parameter values for high accuracy values of constrained values #907

Closed newville closed 1 year ago

newville commented 1 year ago

Description

This makes sure that the best-fit (or current) values are restored to their original values in Parameters.create_uvars.

As shown in #905, values for constraint expressions may be off slightly (around uncertainty or machine precision) without this fix.

Type of Changes
Tested on

Python: 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:17:34) [Clang 14.0.6 ]

lmfit: 1.2.2.post0+g8b2038a.d20230727, scipy: 1.11.1, numpy: 1.25.1, asteval: 0.9.31, uncertainties: 3.1.7

Verification

Have you

codecov[bot] commented 1 year ago

Codecov Report

Merging #907 (2a70f77) into master (8b2038a) will increase coverage by 0.62%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #907      +/-   ##
==========================================
+ Coverage   92.60%   93.23%   +0.62%     
==========================================
  Files          10       10              
  Lines        3693     3696       +3     
==========================================
+ Hits         3420     3446      +26     
+ Misses        273      250      -23     
Files Changed Coverage Δ
lmfit/parameter.py 98.48% <100.00%> (+<0.01%) :arrow_up:

... and 4 files with indirect coverage changes

newville commented 1 year ago

I think this is uncontroversial, so I'll just merge it.