From 1bd6a77151cf1f12d801d58ec35036a6b1775f94 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 26 Jan 2023 20:59:36 -0800 Subject: [PATCH] Don't use @stash_mobject_pointers on copy, be more explicit --- manimlib/mobject/mobject.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index c1774f95..1323b1da 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -591,19 +591,22 @@ class Mobject(object): result._shaders_initialized = False result._data_has_changed = True - @stash_mobject_pointers def copy(self, deep: bool = False): if deep: return self.deepcopy() result = copy.copy(self) - # The line above is only a shallow copy, so the internal - # data which are numpyu arrays or other mobjects still + result.parents = [] + result.target = None + result.save_state = None + + # copy.copy is only a shallow copy, so the internal + # data which are numpy arrays or other mobjects still # need to be further copied. result.data = self.data.copy() result.uniforms = { - key: np.array(value) + key: value.copy() if isinstance(value, np.ndarray) else value for key, value in self.uniforms.items() }