Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Un-deprecated GraphScene (will be deprecated later), fixed an old-style call to NumberPlane (#1430)

Benjamin Hackl40e427f05317
diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.py
index 90568b453..304a59a4e 100644
--- a/manim/mobject/coordinate_systems.py
+++ b/manim/mobject/coordinate_systems.py
@@ -52,8 +52,8 @@ class CoordinateSystem:
1.0,
]
- self.x_range = np.array(x_range)
- self.y_range = np.array(y_range)
+ self.x_range = x_range
+ self.y_range = y_range
self.x_length = x_length
self.y_length = y_length
self.num_sampled_graph_points_per_tick = 10
@@ -325,7 +325,12 @@ class Axes(VGroup, CoordinateSystem):
class LineGraphExample(Scene):
def construct(self):
- plane = NumberPlane(x_min=0, x_max=7, y_min=0, y_max=5, axis_config={"width": 7, "include_numbers": True})
+ plane = NumberPlane(
+ x_range = (0, 7),
+ y_range = (0, 5),
+ x_length = 7,
+ axis_config={"include_numbers": True},
+ )
plane.center()
line_graph = plane.get_line_graph(
x_values = [0, 1.5, 2, 2.8, 4, 6.25],
@@ -398,9 +403,9 @@ class ThreeDAxes(Axes):
def __init__(
self,
- x_range=np.array((-5.5, 5.5, 1)),
- y_range=np.array((-5.5, 5.5, 1)),
- z_range=np.array((-3.5, 3.5, 1)),
+ x_range=(-6, 6, 1),
+ y_range=(-5, 5, 1),
+ z_range=(-4, 4, 1),
x_length=config.frame_height + 2.5,
y_length=config.frame_height + 2.5,
z_length=config.frame_height - 1.5,
@@ -504,8 +509,8 @@ class NumberPlane(Axes):
def __init__(
self,
- x_range=np.array((-6, 6, 1)),
- y_range=np.array((-3, 3, 1)),
+ x_range=(-config["frame_x_radius"], config["frame_x_radius"], 1),
+ y_range=(-config["frame_y_radius"], config["frame_y_radius"], 1),
x_length=None,
y_length=None,
axis_config=None,
@@ -645,16 +650,19 @@ class NumberPlane(Axes):
step = (1 / ratio_faded_lines) * freq
lines1 = VGroup()
lines2 = VGroup()
- inputs = np.arange(
- axis_perpendicular_to.x_min, axis_perpendicular_to.x_max + step, step
+ unit_vector_axis_perp_to = axis_perpendicular_to.get_unit_vector()
+ ranges = (
+ np.arange(0, axis_perpendicular_to.x_max, step),
+ np.arange(0, axis_perpendicular_to.x_min, -step),
)
- for k, x in enumerate(inputs):
- new_line = line.copy()
- new_line.shift(axis_perpendicular_to.n2p(x) - axis_perpendicular_to.n2p(0))
- if k % ratio_faded_lines == 0:
- lines1.add(new_line)
- else:
- lines2.add(new_line)
+ for inputs in ranges:
+ for k, x in enumerate(inputs):
+ new_line = line.copy()
+ new_line.shift(unit_vector_axis_perp_to * x)
+ if k % ratio_faded_lines == 0:
+ lines1.add(new_line)
+ else:
+ lines2.add(new_line)
return lines1, lines2
def get_center_point(self):
diff --git a/manim/scene/graph_scene.py b/manim/scene/graph_scene.py
index f4467bbfd..d681e237c 100644
--- a/manim/scene/graph_scene.py
+++ b/manim/scene/graph_scene.py
@@ -79,8 +79,12 @@ from ..utils.space_ops import angle_of_vector
class GraphScene(Scene):
- """
- Deprecated - GraphScene
+ """A special scene intended for plotting functions.
+
+ .. note::
+
+ This class is in the process of being deprecated. Functionality is
+ currently being ported to :class:`~.Axes`.
"""
def __init__(
@@ -116,10 +120,6 @@ class GraphScene(Scene):
y_axis_config=None,
**kwargs,
):
- logger.warning(
- "GraphScene has been deprecated and will be removed in a future release. "
- "Use Axes instead."
- )
self.x_min = x_min
self.x_max = x_max
self.x_axis_width = x_axis_width
diff --git a/tests/control_data/graphical_units_data/coordinate_systems/NumberPlaneTest.npz b/tests/control_data/graphical_units_data/coordinate_systems/NumberPlaneTest.npz
index 1bc845d98..4115a51dd 100644
Binary files a/tests/control_data/graphical_units_data/coordinate_systems/NumberPlaneTest.npz and b/tests/control_data/graphical_units_data/coordinate_systems/NumberPlaneTest.npz differ
diff --git a/tests/control_data/graphical_units_data/threed/AxesTest.npz b/tests/control_data/graphical_units_data/threed/AxesTest.npz
index 2476f9e69..99df093fa 100644
Binary files a/tests/control_data/graphical_units_data/threed/AxesTest.npz and b/tests/control_data/graphical_units_data/threed/AxesTest.npz differ
diff --git a/tests/control_data/graphical_units_data/threed/FixedInFrameMObjectTest.npz b/tests/control_data/graphical_units_data/threed/FixedInFrameMObjectTest.npz
index 52b11443d..ba4b6057e 100644
Binary files a/tests/control_data/graphical_units_data/threed/FixedInFrameMObjectTest.npz and b/tests/control_data/graphical_units_data/threed/FixedInFrameMObjectTest.npz differ
diff --git a/tests/test_graphical_units/test_threed.py b/tests/test_graphical_units/test_threed.py
index add14dc03..931fb2490 100644
--- a/tests/test_graphical_units/test_threed.py
+++ b/tests/test_graphical_units/test_threed.py
@@ -66,14 +66,17 @@ class AmbientCameraMoveTest(ThreeDScene):
self.wait()
-class FixedInFrameMObjectTest(ThreeDScene):
- def construct(self):
- axes = ThreeDAxes()
- self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES)
- circ = Circle()
- self.add_fixed_in_frame_mobjects(circ)
- circ.to_corner(UL)
- self.add(axes)
+# TODO: bring test back after introducing testing tolerance
+# to account for OS-specific differences in numerics.
+
+# class FixedInFrameMObjectTest(ThreeDScene):
+# def construct(self):
+# axes = ThreeDAxes()
+# self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES)
+# circ = Circle()
+# self.add_fixed_in_frame_mobjects(circ)
+# circ.to_corner(UL)
+# self.add(axes)
class MovingVerticesTest(ThreeDScene):