Repository navigation
Open
1 / 11 of 1 issue completedLabels
Description
For example, I just got this error when trying to copy a SampleModel:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[13], [line 2](vscode-notebook-cell:?execution_count=13&line=2)
1 # Now make a new analysis with this sample model
----> [2](vscode-notebook-cell:?execution_count=13&line=2) mag_sample_model = copy(sample_model)
3 DHO1 = DampedHarmonicOscillator(display_name = 'DHO1', area=100, center=0.2, width=0.2)
4 DHO2 = DampedHarmonicOscillator(display_name = 'DHO2', area=10, center=1.1, width=0.2)
File ~\Documents\easyScience\dynamics-lib\.pixi\envs\default\Lib\copy.py:79, in copy(x)
77 copier = getattr(cls, "__copy__", None)
78 if copier is not None:
---> [79](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/henrikjacobsen3/Documents/easyScience/dynamics-lib/docs/docs/tutorials/~/Documents/easyScience/dynamics-lib/.pixi/envs/default/Lib/copy.py:79) return copier(x)
81 reductor = dispatch_table.get(cls)
82 if reductor is not None:
File ~\Documents\easyScience\dynamics-lib\.pixi\envs\default\Lib\site-packages\easyscience\base_classes\new_base.py:138, in NewBase.__copy__(self)
136 """Return a copy of the object."""
137 temp = self.to_dict(skip=['unique_name'])
--> [138](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/henrikjacobsen3/Documents/easyScience/dynamics-lib/docs/docs/tutorials/~/Documents/easyScience/dynamics-lib/.pixi/envs/default/Lib/site-packages/easyscience/base_classes/new_base.py:138) new_obj = self.__class__.from_dict(temp)
139 return new_obj
File ~\Documents\easyScience\dynamics-lib\.pixi\envs\default\Lib\site-packages\easyscience\base_classes\model_base.py:108, in ModelBase.from_dict(cls, obj_dict)
106 parameter_placeholder[key] = value
107 kwargs[key] = value.value
--> [108](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/henrikjacobsen3/Documents/easyScience/dynamics-lib/docs/docs/tutorials/~/Documents/easyScience/dynamics-lib/.pixi/envs/default/Lib/site-packages/easyscience/base_classes/model_base.py:108) cls_instance = cls(**kwargs)
...
81 )
83 self._components = ComponentCollection()
84 if isinstance(components, (ModelComponent, ComponentCollection)):
TypeError: Components must be a ModelComponent, a ComponentCollection or None, got list
Sub-issues
Collapse Sub-issuesSub-issues
Loading 1 sub-issues
Activity
henrikjacobsenfys commentedon Apr 22, 2026
Worse,
SampleModeldoes not respect all bounds from the template components. This is because the mixin class that creates parameters sets the .min value of various parameters to either 0 or a very small number. This happens in__init__and overwrites the .min the parameter already had.Make copy and to_dict/from_dict work for the model classes
Make the dependents of a copied model follow the copy (#304)
Make copy and to_dict/from_dict work for the model classes (#294)