New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Params eval #550
Params eval #550
Conversation
Codecov Report
@@ Coverage Diff @@
## master #550 +/- ##
==========================================
+ Coverage 83.28% 86.21% +2.93%
==========================================
Files 11 11
Lines 3170 3875 +705
==========================================
+ Hits 2640 3341 +701
- Misses 530 534 +4
Continue to review full report at Codecov.
|
@zobristnicholas Thanks! That looks good to me. Does anyone have an objection to merging this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, just two tiny things in the docstring that could be improved.
3efe5a0
to
2a728bf
Compare
the Travis failure is unrelated and due to a flaky test... I have changed it already in the other PR. @newville can I merge this one? |
@reneeotten yes, please merge! |
Description
This PR is in reference to the discussion here: https://groups.google.com/forum/#!topic/lmfit-py/pJWdxzYRGqI
Expressions derived from parameter values are often added to a Parameters() object using params.add("name", expr="expression"). These expressions can contain common numpy functions, user-defined functions, and parameter values. During a fit, they are evaluated every iteration.
If this updating behavior is not desired, an expression can be evaluated post-fitting using the parameter values directly using p = params.valuesdict(). However, there is currently no public method to retrieve user-defined symbols from the object.
This PR addresses this point by allowing the user to evaluate arbitrary expressions in the Parameters object's namespace via the params.eval() method. A test for this method is also included.
Type of Changes
Tested on
Python: 3.7.3 (default, Mar 27 2019, 16:54:48)
[Clang 4.0.1 (tags/RELEASE_401/final)]
lmfit: 0.9.13+7.gbcec209, scipy: 1.2.1, numpy: 1.16.3, asteval: 0.9.13, uncertainties: 3.0.3, six: 1.12.0
Verification
Not sure the best way to do these two