Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

add deepcopy method - this should fix the tests on py3.6

leotrse1f3a1c9c91f
diff --git a/manim/config/utils.py b/manim/config/utils.py
index d383c8593..a8d60734a 100644
--- a/manim/config/utils.py
+++ b/manim/config/utils.py
@@ -176,6 +176,69 @@ class ManimConfig(MutableMapping):
def __delattr__(self, key):
raise AttributeError("'ManimConfig' object does not support item deletion")
+ # copy functions
+ def copy(self):
+ return copy.deepcopy(self)
+
+ def __copy__(self):
+ return copy.deepcopy(self)
+
+ def __deepcopy__(self, memo):
+ c = ManimConfig(self._parser)
+
+ for opt in [
+ "background_color",
+ "background_opacity",
+ "custom_folders",
+ "disable_caching",
+ "ffmpeg_loglevel",
+ "flush_cache",
+ "frame_height",
+ "frame_rate",
+ "frame_width",
+ "from_animation_number",
+ "js_renderer_path",
+ "leave_progress_bars",
+ "log_to_file",
+ "max_files_cached",
+ "movie_file_extension",
+ "pixel_height",
+ "pixel_width",
+ "png_mode",
+ "preview",
+ "progress_bar",
+ "save_as_gif",
+ "save_last_frame",
+ "save_pngs",
+ "scene_names",
+ "show_in_file_browser",
+ "skip_animations",
+ "sound",
+ "tex_template_file",
+ "upto_animation_number",
+ "use_js_renderer",
+ "verbosity",
+ "write_all",
+ "write_to_movie"
+ ]:
+ setattr(c, opt, getattr(self, opt))
+
+ # setattr() on the following options actually returns something
+ # different to their stored value, so we need to get the actual value
+ for opt in [
+ "media_dir",
+ "input_file",
+ "images_dir",
+ "log_dir",
+ "tex_dir",
+ "text_dir",
+ "video_dir",
+ ]:
+ c._d[opt] = self._d[opt]
+
+ return c
+
+
# helper type-checking methods
def _set_from_list(self, key, val, values):
if val in values:
@@ -378,10 +441,6 @@ class ManimConfig(MutableMapping):
def digest_file(self, filename, cascade=True):
return self
- # regular methods
- def copy(self):
- return copy.deepcopy(self)
-
# config options are properties
preview = property(
lambda self: self._d["preview"],