From 4f994c05a1ded0e4b32cdc3b7e7cce57af922e29 Mon Sep 17 00:00:00 2001 From: Abulafia Date: Fri, 28 Apr 2023 19:26:00 +0200 Subject: [PATCH 1/4] Small fix in the code of ArcBrace Avoiding the creation of an Arc object at import time --- manim/mobject/svg/brace.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manim/mobject/svg/brace.py b/manim/mobject/svg/brace.py index a595f05a2a..1e2b84ac6e 100644 --- a/manim/mobject/svg/brace.py +++ b/manim/mobject/svg/brace.py @@ -335,10 +335,12 @@ def construct(self): def __init__( self, - arc: Arc = Arc(start_angle=-1, angle=2, radius=1), + arc: Arc | None = None, direction: Sequence[float] = RIGHT, **kwargs, ): + if arc is None: + arc = Arc(start_angle=-1, angle=2, radius=1) arc_end_angle = arc.start_angle + arc.angle line = Line(UP * arc.start_angle, UP * arc_end_angle) scale_shift = RIGHT * np.log(arc.radius) From fdbb7950126382e44880e247c06b7ce5caaf1afa Mon Sep 17 00:00:00 2001 From: Adrien ANTON LUDWIG <42720099+Adrien-ANTON-LUDWIG@users.noreply.github.com> Date: Fri, 5 May 2023 08:57:15 +0000 Subject: [PATCH 2/4] Replace last `os.path` occurrencies by `pathlib` (#3224) This resolves [last comment](https://github.com/ManimCommunity/manim/issues/485#issuecomment-1523016291) of #485. Removes one line of dead code. Co-authored-by: Benjamin Hackl --- manim/scene/scene_file_writer.py | 3 +-- manim/utils/file_ops.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py index 1891588675..d9e509de89 100644 --- a/manim/scene/scene_file_writer.py +++ b/manim/scene/scene_file_writer.py @@ -700,9 +700,8 @@ def clean_cache(self): ) oldest_files_to_delete = sorted( cached_partial_movies, - key=os.path.getatime, + key=lambda path: path.stat().st_atime, )[:number_files_to_delete] - # oldest_file_path = min(cached_partial_movies, key=os.path.getatime) for file_to_delete in oldest_files_to_delete: file_to_delete.unlink() logger.info( diff --git a/manim/utils/file_ops.py b/manim/utils/file_ops.py index 1bbb048214..ae06561991 100644 --- a/manim/utils/file_ops.py +++ b/manim/utils/file_ops.py @@ -183,7 +183,7 @@ def modify_atime(file_path: str) -> None: file_path The path of the file. """ - os.utime(file_path, times=(time.time(), os.path.getmtime(file_path))) + os.utime(file_path, times=(time.time(), Path(file_path).stat().st_mtime)) def open_file(file_path, in_browser=False): From d3b18f7d71c880ed0d276feaf6fe16f89fb0b6ff Mon Sep 17 00:00:00 2001 From: Benjamin Hackl Date: Fri, 5 May 2023 10:59:20 +0200 Subject: [PATCH 3/4] Made docbuild errors easier to debug + fixed error from changed exception class (#3229) * Make errors during docbuild somewhat easier to debug * fix an issue with docbuild under py3.10+ --- manim/utils/docbuild/manim_directive.py | 11 +++++++---- manim/utils/hashing.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/manim/utils/docbuild/manim_directive.py b/manim/utils/docbuild/manim_directive.py index fe43764ed3..e4df6dc531 100644 --- a/manim/utils/docbuild/manim_directive.py +++ b/manim/utils/docbuild/manim_directive.py @@ -272,10 +272,13 @@ def run(self): f"{clsname}().render()", ] - with tempconfig(example_config): - run_time = timeit(lambda: exec("\n".join(code), globals()), number=1) - video_dir = config.get_dir("video_dir") - images_dir = config.get_dir("images_dir") + try: + with tempconfig(example_config): + run_time = timeit(lambda: exec("\n".join(code), globals()), number=1) + video_dir = config.get_dir("video_dir") + images_dir = config.get_dir("images_dir") + except Exception as e: + raise RuntimeError(f"Error while rendering example {clsname}") from e _write_rendering_stats( clsname, diff --git a/manim/utils/hashing.py b/manim/utils/hashing.py index 60e4422f15..f8a259b06c 100644 --- a/manim/utils/hashing.py +++ b/manim/utils/hashing.py @@ -207,7 +207,7 @@ def default(self, obj: Any): del cvardict[i] try: code = inspect.getsource(obj) - except OSError: + except (OSError, TypeError): # This happens when rendering videos included in the documentation # within doctests and should be replaced by a solution avoiding # hash collision (due to the same, empty, code strings) at some point. From 158ede3ca64a18d04358c5cca1fe762cadef95bc Mon Sep 17 00:00:00 2001 From: Abulafia Date: Wed, 10 May 2023 23:44:27 +0200 Subject: [PATCH 4/4] Make set_resampling_algorithm() return self --- manim/mobject/types/image_mobject.py | 1 + 1 file changed, 1 insertion(+) diff --git a/manim/mobject/types/image_mobject.py b/manim/mobject/types/image_mobject.py index 091c60a195..25ff084d2a 100644 --- a/manim/mobject/types/image_mobject.py +++ b/manim/mobject/types/image_mobject.py @@ -84,6 +84,7 @@ def set_resampling_algorithm(self, resampling_algorithm: int): "Available algorithms: 'bicubic', 'nearest', 'box', 'bilinear', " "'hamming', 'lanczos'.", ) + return self def reset_points(self): # Corresponding corners of image are fixed to these 3 points