From 5b315d5c7041d86bf01d4aeb151fc2f9fb97662c Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Mon, 9 Dec 2024 14:02:22 -0600 Subject: [PATCH] Get rid of the (hacky) solution to redefining Scene methods, since reload handles it better --- manimlib/scene/scene_embed.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/manimlib/scene/scene_embed.py b/manimlib/scene/scene_embed.py index e962f8c4..ff507dfd 100644 --- a/manimlib/scene/scene_embed.py +++ b/manimlib/scene/scene_embed.py @@ -123,29 +123,8 @@ class CheckpointManager: checkpoint_key = self.get_leading_comment(code_string) self.handle_checkpoint_key(scene, checkpoint_key) - code_string = self.handle_method_definitions(code_string) - shell.run_cell(code_string) - @staticmethod - def handle_method_definitions(code_string: str): - # Copied methods of a scene are handled specially - # A bit hacky, yes, but convenient - lines = code_string.split("\n") - method_pattern = r"^def\s+([a-zA-Z_]\w*)\s*\(self.*\):" - method_names = re.findall(method_pattern, lines[0].strip()) - if method_names: - method_name = method_names[0] - indent = " " * lines[0].index(lines[0].strip()) - return "\n".join([ - # Remove self from function signature - re.sub(r"self(,\s*)?", "", lines[0]), - *lines[1:], - # Attach to scene via self.func_name = func_name - f"{indent}self.{method_name} = {method_name}" - ]) - return code_string - @staticmethod def get_leading_comment(code_string: str): leading_line = code_string.partition("\n")[0].lstrip()