-
Notifications
You must be signed in to change notification settings - Fork 47
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
Added deepcpy functionality and small test for roadrunner. #1347
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #1347 +/- ##
===========================================
+ Coverage 84.33% 84.49% +0.16%
===========================================
Files 157 157
Lines 12911 12906 -5
===========================================
+ Hits 10888 10905 +17
+ Misses 2023 2001 -22 ☔ View full report in Codecov by Sentry. |
other_rr = roadrunner.RoadRunner() | ||
state = self.roadrunner_instance.saveStateS() | ||
other_rr.loadStateS(state=state) | ||
other.roadrunner_instance = other_rr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can check with the RR devs if __deepcopy__
could be provided by RR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also can use their __setstate__
and __getstate__
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if we remove
pyPESTO/pypesto/objective/base.py
Lines 59 to 64 in 321ee9d
def __deepcopy__(self, memodict=None) -> "ObjectiveBase": | |
"""Create deepcopy of objective object.""" | |
other = type(self)() # maintain type for derived classes | |
for attr, val in self.__dict__.items(): | |
other.__dict__[attr] = copy.deepcopy(val) | |
return other |
this __deepcopy__
function here wouldn't be needed.
Does anybody recall the purpose of ObjectiveBase.__deepcopy__
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an option that deepcopy
s the objective at Problem
instantiation.
pyPESTO/pypesto/problem/base.py
Lines 107 to 108 in 34e89b3
if copy_objective: | |
objective = copy.deepcopy(objective) |
But I'm not sure why __deepcopy__
is defined, I would expect a default deepcopy(...)
to do what is defined in ObjectiveBase.__deepcopy__
already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect a default
deepcopy(...)
to do what is defined inObjectiveBase.__deepcopy__
already.
Exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. Will remove the default deep copy and see whether all tests still work, then merge for now. Might be reverted when RR developers add a deepcopy function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove the default deep copy and see whether all tests still work, then merge for now.
Not only ObjectiveBase.__deepcopy__
, but also RoadRunnerObjective.__deepcopy__
.
Might be reverted when RR developers add a deepcopy function.
No, that wouldn't require any change then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah so deepcopy
in its original behaviour would use the __set/getstate__
functionality from RR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deepcopy
will fall back to __getstate__
/ __setstate__
, which exist (see Dilan's comment above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good 👍🏼 will remove it but keep the tests, as I think we should still make sure it is working?
Co-authored-by: Daniel Weindl <[email protected]>
Co-authored-by: Daniel Weindl <[email protected]>
Deepcopy functionality is needed for profiling.