-
Notifications
You must be signed in to change notification settings - Fork 274
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
Unsetting the default expression of 'VoigtModel' and 'SkewedVoigtModel' does not work as expected #859
Comments
@Julian-Hochhaus Thanks. I agree that is a bit of a wart. From a purely API point-of-view, I think it is not unusual for "set attribute" to have a different result from "call a function with a keyword argument". The function is almost certainly going to do more work unless there is a sort-of-magic "setter method". It's OK to expect that we might use these for a For a parameter that is already constrained with an expression, doing
is sort of ambiguous -- it does not specify whether the value should be varied or not. I think the current behavior is defensible, though I can also see that making it variable would be defensible too. As it happens, I think that changing the implementation of this behavior is a bit subtle. Doing
but not also un-setting the expression seems more problematic to me. There, the intent is clear, and the value of |
Indeed, I fully agree that the expected behavior of calling a function is different to setting single attributes . I have never thought about it enough. In addition, I suggest pointing out in the documentation the different behavior of |
With #860, doing Setting |
@Julian-Hochhaus I believe this is addressed in 1.2.0 |
First Time Issue Code
Yes, I read the instructions and I am sure this is a GitHub Issue
Hint: Potentially there are several different small bugs, if necessary, I will separate them into separate issues.
Description
According to the manual (see Notes of Parameter class), an expression is unset setting either
par.set(expr='')
orpar.set(vary=True)
.For the
VoigtModel
as well as for theSkewedVoigtModel
, thegamma
parameter is by default constrained to thesigma
parameter (compare l.734 and l.1284 in models.py respectively).To be able to independently vary
sigma
andgamma
, I tried unsetting the constraint of thegamma
parameter as described in the manual. However, the results for both commands (par.set(expr='')
andpar.set(vary=True)
) differ (BUG 1).In addition, normally I would have expected that there should be no difference in the behavior of
par.set(vary=True)
andpar.vary=True
. Trying to unset the default constraint of thegamma
parameter ofVoigtModel
andSkewedVoigtModel
using the two different methods, however, resulted in different behavior (BUG 2). In the Minimal working example below I have only shown the details including the output and some comments for theVoigtModel
, the behavior is the same for theSkewedVoigtModel
, which could be verified by the code snippet at the end of the MWE.But first, I will give some commented examples of the observed bugs:
Unsetting using
vary=True
Output:
Problem:
Behavior of
par.set(vary=True)
andpar.vary=True
is different, whilepar.set(vary=True)
does indeed unset the expression,par.vary=True
seems to do nothingUnsetting using
expr=''
Output:
Problem: The behavior of
par.set(expr='')
andpar.expr=''
is the same, and both are unsetting theexpr
. However, in addition the command results in addition in setting the parameter fixed in both cases (BUG 3).Complete MWE
Complete Output:
Version information
Python: 3.8.3 (default, Jul 2 2020, 16:21:59)
[GCC 7.3.0]
lmfit: 1.0.3.post46+g589c029, scipy: 1.5.0, numpy: 1.23.4,asteval: 0.9.26, uncertainties: 3.1.6
The text was updated successfully, but these errors were encountered: