A community-maintained Python framework for creating mathematical animations.
Fix background lines drawn twice in `NumberPlane` (#2634)
sparshg7f464cc5d3e1
diff --git a/manim/mobject/graphing/coordinate_systems.py b/manim/mobject/graphing/coordinate_systems.pyindex 5e35303d9..90afe66aa 100644--- a/manim/mobject/graphing/coordinate_systems.py+++ b/manim/mobject/graphing/coordinate_systems.py@@ -2422,8 +2422,9 @@ class NumberPlane(Axes):# min/max used in case range does not include 0. i.e. if (2,6):# the range becomes (0,4), not (0,6).ranges = (- np.arange(0, min(x_max - x_min, x_max), step),- np.arange(0, max(x_min - x_max, x_min), -step),+ [0],+ np.arange(step, min(x_max - x_min, x_max), step),+ np.arange(-step, max(x_min - x_max, x_min), -step),)for inputs in ranges:diff --git a/tests/test_coordinate_system.py b/tests/test_coordinate_system.pyindex 1695f5c54..8a359d7a1 100644--- a/tests/test_coordinate_system.py+++ b/tests/test_coordinate_system.py@@ -55,19 +55,16 @@ def test_NumberPlane():pos_y_range = (2, 6)neg_y_range = (-6, -2)- x_vals = [0, 1.5, 2, 2.8, 4, 6.25]- y_vals = [2, 5, 4.25, 6, 4.5, 2.75]-testing_data = [- (pos_x_range, pos_y_range, x_vals, y_vals),- (pos_x_range, neg_y_range, x_vals, [-v for v in y_vals]),- (neg_x_range, pos_y_range, [-v for v in x_vals], y_vals),- (neg_x_range, neg_y_range, [-v for v in x_vals], [-v for v in y_vals]),+ (pos_x_range, pos_y_range),+ (pos_x_range, neg_y_range),+ (neg_x_range, pos_y_range),+ (neg_x_range, neg_y_range),]for test_data in testing_data:- x_range, y_range, x_vals, y_vals = test_data+ x_range, y_range = test_datax_start, x_end = x_rangey_start, y_end = y_range@@ -89,8 +86,11 @@ def test_NumberPlane():assert len(plane.x_lines) == num_x_linesplane = NumberPlane((-5, 5, 0.5), (-8, 8, 2)) # <- test for different step values- assert len(plane.x_lines) == 8- assert len(plane.y_lines) == 20+ # horizontal lines: -6 -4, -2, 0, 2, 4, 6+ assert len(plane.x_lines) == 7+ # vertical lines: 0, +-0.5, +-1, +-1.5, +-2, +-2.5,+ # +-3, +-3.5, +-4, +-4.5+ assert len(plane.y_lines) == 19def test_point_to_coords():diff --git a/tests/test_graphical_units/control_data/coordinate_system/line_graph.npz b/tests/test_graphical_units/control_data/coordinate_system/line_graph.npzindex ad2a00d36..077dbbd22 100644Binary files a/tests/test_graphical_units/control_data/coordinate_system/line_graph.npz and b/tests/test_graphical_units/control_data/coordinate_system/line_graph.npz differdiff --git a/tests/test_graphical_units/control_data/coordinate_system/number_plane.npz b/tests/test_graphical_units/control_data/coordinate_system/number_plane.npzindex 3ca51a4ad..afb647aba 100644Binary files a/tests/test_graphical_units/control_data/coordinate_system/number_plane.npz and b/tests/test_graphical_units/control_data/coordinate_system/number_plane.npz differdiff --git a/tests/test_graphical_units/control_data/coordinate_system/number_plane_log.npz b/tests/test_graphical_units/control_data/coordinate_system/number_plane_log.npzindex dc9c4f0a6..894f2ebb6 100644Binary files a/tests/test_graphical_units/control_data/coordinate_system/number_plane_log.npz and b/tests/test_graphical_units/control_data/coordinate_system/number_plane_log.npz differdiff --git a/tests/test_graphical_units/control_data/plot/plot_derivative_graph.npz b/tests/test_graphical_units/control_data/plot/plot_derivative_graph.npzindex 7101141de..bf393eb22 100644Binary files a/tests/test_graphical_units/control_data/plot/plot_derivative_graph.npz and b/tests/test_graphical_units/control_data/plot/plot_derivative_graph.npz differdiff --git a/tests/test_graphical_units/control_data/vector_scene/vector_to_coords.npz b/tests/test_graphical_units/control_data/vector_scene/vector_to_coords.npzindex 0ec172436..a6a626912 100644Binary files a/tests/test_graphical_units/control_data/vector_scene/vector_to_coords.npz and b/tests/test_graphical_units/control_data/vector_scene/vector_to_coords.npz differ