Let OpenGLMobject.copy return a deep copy by default #1733
Merged
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.
Changelog / Overview
This adds a keyword
shallow
toOpenGLMobject.copy
that controls whether a shallow or deep copy is returned. By default (and this is a change to the current behavior), a deep copy is returned.Motivation
Returning a shallow mobject copy by default sometimes causes problems with (method) animations of complex mobjects, like
Graph.change_layout
(see the comment in #1202 for an example).Testing Status
Well, this is a problem: given the lack of OpenGL tests, I'm not sure in how far this could degrade rendering speed. From what I've tried locally, I didn't really see a difference in the rendering times, but that's of course no guarantee.
Further Comments
This is just one potential solution to this problem. The more "courageous" way would be to always return a deep copy (as in the case of
Mobject.copy
and to delete the shallow copy code entirely.Checklist
Reviewer Checklist