From a4bf17b7900e26e20e93fda767bec53351fa7c94 Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Mon, 30 Dec 2024 18:18:40 +0100 Subject: [PATCH 1/9] fixed problem with type conversions in Line3D --- manim/mobject/three_d/three_dimensions.py | 4 ++++ tests/test_graphical_units/test_threed.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.py index 5732ebb98c..e8dd8d8e67 100644 --- a/manim/mobject/three_d/three_dimensions.py +++ b/manim/mobject/three_d/three_dimensions.py @@ -926,6 +926,10 @@ def __init__( ): self.thickness = thickness self.resolution = (2, resolution) if isinstance(resolution, int) else resolution + + start = np.array(start,np.float64) + end = np.array(end,np.float64) + self.set_start_and_end_attrs(start, end, **kwargs) if color is not None: self.set_color(color) diff --git a/tests/test_graphical_units/test_threed.py b/tests/test_graphical_units/test_threed.py index b6079e5e4c..0d0bb659b5 100644 --- a/tests/test_graphical_units/test_threed.py +++ b/tests/test_graphical_units/test_threed.py @@ -172,3 +172,10 @@ def test_get_start_and_end_Arrow3d(): assert np.allclose( arrow.get_end(), end, atol=0.01 ), "end points of Arrow3D do not match" + +def test_type_conversion_in_Line3D(): + start,end = [0,0,0],[1,1,1] + line = Line3D(start,end) + type_table = [type(item) for item in [*line.get_start(),*line.get_end()]] + bool_table = [t == np.float64 for t in type_table] + assert all(bool_table), "Types of start and end points are not np.float64" \ No newline at end of file From ca9642780b79fdcd7d5532bcb5a9eeacefbbbe69 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 17:36:28 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/mobject/three_d/three_dimensions.py | 8 ++++---- tests/test_graphical_units/test_threed.py | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.py index e8dd8d8e67..b040e4f6eb 100644 --- a/manim/mobject/three_d/three_dimensions.py +++ b/manim/mobject/three_d/three_dimensions.py @@ -926,10 +926,10 @@ def __init__( ): self.thickness = thickness self.resolution = (2, resolution) if isinstance(resolution, int) else resolution - - start = np.array(start,np.float64) - end = np.array(end,np.float64) - + + start = np.array(start, np.float64) + end = np.array(end, np.float64) + self.set_start_and_end_attrs(start, end, **kwargs) if color is not None: self.set_color(color) diff --git a/tests/test_graphical_units/test_threed.py b/tests/test_graphical_units/test_threed.py index 0d0bb659b5..7eaf255af6 100644 --- a/tests/test_graphical_units/test_threed.py +++ b/tests/test_graphical_units/test_threed.py @@ -173,9 +173,10 @@ def test_get_start_and_end_Arrow3d(): arrow.get_end(), end, atol=0.01 ), "end points of Arrow3D do not match" + def test_type_conversion_in_Line3D(): - start,end = [0,0,0],[1,1,1] - line = Line3D(start,end) - type_table = [type(item) for item in [*line.get_start(),*line.get_end()]] + start, end = [0, 0, 0], [1, 1, 1] + line = Line3D(start, end) + type_table = [type(item) for item in [*line.get_start(), *line.get_end()]] bool_table = [t == np.float64 for t in type_table] - assert all(bool_table), "Types of start and end points are not np.float64" \ No newline at end of file + assert all(bool_table), "Types of start and end points are not np.float64" From 7b81730cb69cdd21780ea02265b0c3c684449183 Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Mon, 30 Dec 2024 18:56:22 +0100 Subject: [PATCH 3/9] fixed broken test and Arrow3D --- manim/mobject/three_d/three_dimensions.py | 4 ++-- test.py | 25 +++++++++++++++++++++++ tests/test_graphical_units/test_threed.py | 9 +++++++- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 test.py diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.py index b040e4f6eb..7e2dc5bf0d 100644 --- a/manim/mobject/three_d/three_dimensions.py +++ b/manim/mobject/three_d/three_dimensions.py @@ -1187,8 +1187,8 @@ def __init__( height=height, **kwargs, ) - self.cone.shift(end) - self.end_point = VectorizedPoint(end) + self.cone.shift(np.array(end,np.float64)) + self.end_point = VectorizedPoint(np.array(end,np.float64)) self.add(self.end_point, self.cone) self.set_color(color) diff --git a/test.py b/test.py new file mode 100644 index 0000000000..60ed2ff5c7 --- /dev/null +++ b/test.py @@ -0,0 +1,25 @@ +from manim import * + + +class Example(Scene): + def construct(self): + t = MathTex(r"\int_{a}^{b} f(x) \;dx = F(b) - F(a)") + self.play(Write(t)) + self.wait() + self.play(Unwrite(t)) + self.wait() + + +class Intro(ThreeDScene): + def construct(self): + + v1 = Arrow3D([0, 0, 0], [1, 1, 0]) + + a = Tex("hi").move_to(v1.get_end()) + a.add_updater(lambda m: m.move_to(v1.get_end())) + + self.add(a, v1) + self.play(Rotate(v1)) + +with tempconfig({"quality": "low_quality", "preview": True}): + Intro().render() diff --git a/tests/test_graphical_units/test_threed.py b/tests/test_graphical_units/test_threed.py index 7eaf255af6..3525c48092 100644 --- a/tests/test_graphical_units/test_threed.py +++ b/tests/test_graphical_units/test_threed.py @@ -164,7 +164,7 @@ def param_surface(u, v): def test_get_start_and_end_Arrow3d(): - start, end = ORIGIN, np.array([2, 1, 0]) + start, end = ORIGIN, np.array([2, 1, 0],dtype=np.float64) arrow = Arrow3D(start, end) assert np.allclose( arrow.get_start(), start, atol=0.01 @@ -180,3 +180,10 @@ def test_type_conversion_in_Line3D(): type_table = [type(item) for item in [*line.get_start(), *line.get_end()]] bool_table = [t == np.float64 for t in type_table] assert all(bool_table), "Types of start and end points are not np.float64" + +def test_type_conversion_in_Arrow3D(): + start,end = [0,0,0],[1,1,1] + line = Arrow3D(start,end) + type_table = [type(item) for item in [*line.get_start(),*line.get_end()]] + bool_table = [t == np.float64 for t in type_table] + assert all(bool_table), "Types of start and end points are not np.float64" \ No newline at end of file From 4d26524dbff161175eafb9118b77c3b9a4707bd7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 17:57:56 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/mobject/three_d/three_dimensions.py | 4 ++-- test.py | 4 +++- tests/test_graphical_units/test_threed.py | 13 +++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.py index 7e2dc5bf0d..7925ed5ea9 100644 --- a/manim/mobject/three_d/three_dimensions.py +++ b/manim/mobject/three_d/three_dimensions.py @@ -1187,8 +1187,8 @@ def __init__( height=height, **kwargs, ) - self.cone.shift(np.array(end,np.float64)) - self.end_point = VectorizedPoint(np.array(end,np.float64)) + self.cone.shift(np.array(end, np.float64)) + self.end_point = VectorizedPoint(np.array(end, np.float64)) self.add(self.end_point, self.cone) self.set_color(color) diff --git a/test.py b/test.py index 60ed2ff5c7..49ff781e83 100644 --- a/test.py +++ b/test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from manim import * @@ -12,7 +14,6 @@ def construct(self): class Intro(ThreeDScene): def construct(self): - v1 = Arrow3D([0, 0, 0], [1, 1, 0]) a = Tex("hi").move_to(v1.get_end()) @@ -21,5 +22,6 @@ def construct(self): self.add(a, v1) self.play(Rotate(v1)) + with tempconfig({"quality": "low_quality", "preview": True}): Intro().render() diff --git a/tests/test_graphical_units/test_threed.py b/tests/test_graphical_units/test_threed.py index 3525c48092..64c003577b 100644 --- a/tests/test_graphical_units/test_threed.py +++ b/tests/test_graphical_units/test_threed.py @@ -164,7 +164,7 @@ def param_surface(u, v): def test_get_start_and_end_Arrow3d(): - start, end = ORIGIN, np.array([2, 1, 0],dtype=np.float64) + start, end = ORIGIN, np.array([2, 1, 0], dtype=np.float64) arrow = Arrow3D(start, end) assert np.allclose( arrow.get_start(), start, atol=0.01 @@ -180,10 +180,11 @@ def test_type_conversion_in_Line3D(): type_table = [type(item) for item in [*line.get_start(), *line.get_end()]] bool_table = [t == np.float64 for t in type_table] assert all(bool_table), "Types of start and end points are not np.float64" - + + def test_type_conversion_in_Arrow3D(): - start,end = [0,0,0],[1,1,1] - line = Arrow3D(start,end) - type_table = [type(item) for item in [*line.get_start(),*line.get_end()]] + start, end = [0, 0, 0], [1, 1, 1] + line = Arrow3D(start, end) + type_table = [type(item) for item in [*line.get_start(), *line.get_end()]] bool_table = [t == np.float64 for t in type_table] - assert all(bool_table), "Types of start and end points are not np.float64" \ No newline at end of file + assert all(bool_table), "Types of start and end points are not np.float64" From 72b8790fb53f81d30fbb3191a435ac375d65f9fa Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Mon, 30 Dec 2024 20:20:44 +0100 Subject: [PATCH 5/9] Update manim/mobject/three_d/three_dimensions.py Co-authored-by: Aarush Deshpande <110117391+JasonGrace2282@users.noreply.github.com> --- manim/mobject/three_d/three_dimensions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.py index 7925ed5ea9..70f3c88a61 100644 --- a/manim/mobject/three_d/three_dimensions.py +++ b/manim/mobject/three_d/three_dimensions.py @@ -927,8 +927,8 @@ def __init__( self.thickness = thickness self.resolution = (2, resolution) if isinstance(resolution, int) else resolution - start = np.array(start, np.float64) - end = np.array(end, np.float64) + start = np.array(start, dtype=np.float64) + end = np.array(end, dtype=np.float64) self.set_start_and_end_attrs(start, end, **kwargs) if color is not None: From ce1f9c8e960685d331ea10b05b4fa67d1bca7cdd Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Mon, 30 Dec 2024 20:21:25 +0100 Subject: [PATCH 6/9] Update manim/mobject/three_d/three_dimensions.py Co-authored-by: Aarush Deshpande <110117391+JasonGrace2282@users.noreply.github.com> --- manim/mobject/three_d/three_dimensions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.py index 70f3c88a61..b6124f66ab 100644 --- a/manim/mobject/three_d/three_dimensions.py +++ b/manim/mobject/three_d/three_dimensions.py @@ -1187,8 +1187,9 @@ def __init__( height=height, **kwargs, ) - self.cone.shift(np.array(end, np.float64)) - self.end_point = VectorizedPoint(np.array(end, np.float64)) + np_end = np.asarray(end, dtype=np.float64) + self.cone.shift(np_end) + self.end_point = VectorizedPoint(np_end) self.add(self.end_point, self.cone) self.set_color(color) From 9b4f28aafc5a22c60d690efd604feecdc35f3c8e Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Mon, 30 Dec 2024 20:24:26 +0100 Subject: [PATCH 7/9] Delete unnecessary file --- test.py | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 test.py diff --git a/test.py b/test.py deleted file mode 100644 index 49ff781e83..0000000000 --- a/test.py +++ /dev/null @@ -1,27 +0,0 @@ -from __future__ import annotations - -from manim import * - - -class Example(Scene): - def construct(self): - t = MathTex(r"\int_{a}^{b} f(x) \;dx = F(b) - F(a)") - self.play(Write(t)) - self.wait() - self.play(Unwrite(t)) - self.wait() - - -class Intro(ThreeDScene): - def construct(self): - v1 = Arrow3D([0, 0, 0], [1, 1, 0]) - - a = Tex("hi").move_to(v1.get_end()) - a.add_updater(lambda m: m.move_to(v1.get_end())) - - self.add(a, v1) - self.play(Rotate(v1)) - - -with tempconfig({"quality": "low_quality", "preview": True}): - Intro().render() From 5a0978824f1e46a4fb2667dc68663bfe4bf8506e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 19 Jan 2025 21:20:28 +0000 Subject: [PATCH 8/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_graphical_units/test_threed.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_graphical_units/test_threed.py b/tests/test_graphical_units/test_threed.py index 27b066cb83..33812d1120 100644 --- a/tests/test_graphical_units/test_threed.py +++ b/tests/test_graphical_units/test_threed.py @@ -166,12 +166,12 @@ def param_surface(u, v): def test_get_start_and_end_Arrow3d(): start, end = ORIGIN, np.array([2, 1, 0], dtype=np.float64) arrow = Arrow3D(start, end) - assert np.allclose( - arrow.get_start(), start, atol=0.01 - ), "start points of Arrow3D do not match" - assert np.allclose( - arrow.get_end(), end, atol=0.01 - ), "end points of Arrow3D do not match" + assert np.allclose(arrow.get_start(), start, atol=0.01), ( + "start points of Arrow3D do not match" + ) + assert np.allclose(arrow.get_end(), end, atol=0.01), ( + "end points of Arrow3D do not match" + ) def test_type_conversion_in_Line3D(): @@ -188,11 +188,10 @@ def test_type_conversion_in_Arrow3D(): type_table = [type(item) for item in [*line.get_start(), *line.get_end()]] bool_table = [t == np.float64 for t in type_table] assert all(bool_table), "Types of start and end points are not np.float64" - + assert np.allclose(arrow.get_start(), start, atol=0.01), ( "start points of Arrow3D do not match" ) assert np.allclose(arrow.get_end(), end, atol=0.01), ( "end points of Arrow3D do not match" ) - From 85fde60ba6e558cb297e7b7b2d77d6320217b774 Mon Sep 17 00:00:00 2001 From: Sir James Clark Maxwell <71722499+SirJamesClarkMaxwell@users.noreply.github.com> Date: Sun, 19 Jan 2025 23:21:10 +0100 Subject: [PATCH 9/9] fixed typo in variable nam --- tests/test_graphical_units/test_threed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_graphical_units/test_threed.py b/tests/test_graphical_units/test_threed.py index 33812d1120..108472f840 100644 --- a/tests/test_graphical_units/test_threed.py +++ b/tests/test_graphical_units/test_threed.py @@ -184,8 +184,8 @@ def test_type_conversion_in_Line3D(): def test_type_conversion_in_Arrow3D(): start, end = [0, 0, 0], [1, 1, 1] - line = Arrow3D(start, end) - type_table = [type(item) for item in [*line.get_start(), *line.get_end()]] + arrow = Arrow3D(start, end) + type_table = [type(item) for item in [*arrow.get_start(), *arrow.get_end()]] bool_table = [t == np.float64 for t in type_table] assert all(bool_table), "Types of start and end points are not np.float64"