Always retain numerical keyword argument defaults #925
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This change has numerical default values of model functions be used as inital values for fitting corresponding fitting parameters when the fitting parameters are explicitly chosen using
Model
'sparam_names
argument, just like they are when the parameters are inferred from the function signature. This was proposed in #919 (though some of the discussion bled over to #920).This is completely backward compatible, no existing code needs to be changed.
A note on the code structure
In principle, it would have been more natural to first only generate
self._param_root_names
(if it wasNone
) and then fill the initial values (i.e.self.def_vals
) for all parameters where this is possible irrespective of howself._param_root_names
came to be (from theparam_names
argument or from automatic generation). However, in practice this made the code harder to read (and slightly less efficient) as essentially the same loop and tests would be performed twice in the case of automatic generation. I thus went with leaving the existing loop untouched and just handling the case whereparam_names
was used separately.Type of Changes
Tested on
Verification
Have you
(As the present behavior is not described in the docstring, no docstrings were changed.)
(I get several warnings and three skipped tests, though.)
(Except for issues that also appeared when building on
master
, as described in Documentation does not build #924.)(No tests were affected by the change. I can add some if you ask me to.)
(I did not add anything to
doc/whatsnew.rst
yet. I had a look at the file history and other PRs and it seems to be done in batch, separate from the PRs. I will add an entry if you ask me to.)(Same as for test, I don't think any example was affected and I did not add a new one. Can do so if you ask me to.)