Draft: Improve handling of covariance calculation #813
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
In this PR we make two changes to the calculation of the covariance
None
. TheNone
value was already used when no covariance calculation was made, or for other issues with the calculation, so this should have limited impact on users.LinAlgError
orValueError
in the calculation aNone
is returned for the covariance (as before) and the original parameter values are restored.A discussion on the changes is in #812. Because of the first change, the warnings generated when the square root of the negative diagonal elements of the covariance matrix are taken have been removed. If this behaviour is not acceptable, I suggest adding a dedicated warning, e.g.
Type of Changes
Tested on
Python: 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)]
lmfit: 1.0.3, scipy: 1.9.2, numpy: 1.23.4, asteval: 0.9.27, uncertainties: 3.1.7
Verification
Have you
FileNotFoundError: test_splinepeak.dat not found.
)