-
Notifications
You must be signed in to change notification settings - Fork 10
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
UserCommands object is mutable and it is not copied when instantiating OpticalTrain #187
Comments
To fix this, I propose to make a deepcopy of the |
Thanks. This non-copying has been a frustration for many people. My main problem wast that if you do a @astronomyk made me deputy ScopeSim maintainer. However, I don't feel comfortable merging #186 just now because of Chesterton’s Fence. That is, there might be a reason for this specific behavior that we're not aware of and that merging #186 would break something (and the CI fails since yesterday because of #184). I expect it was just an oversight though. Next week @astronomyk will be back, so we can probably merge it then. Maybe it would also be time to add type annotations, thanks for updating the docstring. |
I was also worried that this was done for a reason or that this fix could break something, but so far that doesn't seem to be the case. Nevertheless, I have only been using his package for the past few weeks, so I am far from proficient in it and I might be overlooking something, so I agree that feedback from other contributors is invaluable. As for the type annotations, in other projects I have been using type hints and type checkers, such as |
When instantiating the
OpticalTrain
class, if aUserCommands
object is used, theOpticalTrain.cmds
attribute will be set with theUserCommands
object without a copy being made. As a results, changing a simulation parameter/commmand in oneOpticalTrain
object will lead to every other object of this class being modified too if they were instantiated with the sameUserCommands
object. To exemplify:Output:
I believe this shoulnd't happen and that every
OpticalTrain
obejct should be independent of eachother, even if they were instantiated with the sameUserCommands
object.The text was updated successfully, but these errors were encountered: