preserve Parameter subclass when copying Parameters #964
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
If an instance of a type derived from
Parameter
is added to aParameters
instance,and the
Parameters
instance is then copied, the copy contains a parameter of typeParameter
.This PR changes the contained parameter type to the derived one.
I moved the code copying
Parameter
instances toParameter.__deepcopy__
so that the derived class can adds attributes.This should not break any existing code unless someone uses
__deepcopy__
for something else than copying.Type of Changes
Tested on
Python: 3.9.13
lmfit: 0.0.post2850+gb250ed7.d20240807,
scipy: 1.13.1,
numpy: 2.0.0,
asteval: 1.0.2,
uncertainties: 3.2.2
Verification
No, I have not opened nor found a relevant Issue.
Tests do not pass, but the result is the same as on the master branch (the added test passes).
FAILED tests/test_parameters.py::test_check_ast_errors - Failed: DID NOT RAISE <class 'NameError'>
1 failed, 650 passed, 12 skipped, 6 warnings in 127.66s (0:02:07)
Does not build:
Extension error:
Could not import extension sphinx.builders.epub3 (exception: cannot import name 'jsonimpl' from partially initialized
module 'sphinxcontrib.serializinghtml' (most likely due to a circular import)