A community-maintained Python framework for creating mathematical animations.
Fix coords_to_point treating single list/array as batch of x-values (#4596)
Daniel Bates7eab4c5450f6
diff --git a/manim/mobject/graphing/coordinate_systems.py b/manim/mobject/graphing/coordinate_systems.pyindex a57ab2f16..6b8237827 100644--- a/manim/mobject/graphing/coordinate_systems.py+++ b/manim/mobject/graphing/coordinate_systems.py@@ -2089,6 +2089,10 @@ class Axes(VGroup, CoordinateSystem, metaclass=ConvertToOpenGL):``ax.coords_to_point( [[x_0, y_0, z_0], [x_1, y_1, z_1]] )``+ A single coordinate can also be passed as a flat list or 1D array:++ ``ax.coords_to_point( [x, y, z] )``+Returns-------np.ndarray@@ -2117,6 +2121,10 @@ class Axes(VGroup, CoordinateSystem, metaclass=ConvertToOpenGL):array([[0. , 0.86, 0.86],[0.75, 0.75, 0. ],[0. , 0. , 0. ]])+ >>> np.around(ax.coords_to_point([1, 0, 0]), 2)+ array([0.86, 0. , 0. ])+ >>> np.around(ax.coords_to_point(np.array([1, 0])), 2)+ array([0.86, 0. , 0. ]).. manim:: CoordsToPointExample:save_last_frame:@@ -2159,6 +2167,10 @@ class Axes(VGroup, CoordinateSystem, metaclass=ConvertToOpenGL):else:coords = coords.Tare_coordinates_transposed = True+ # If coords is in the format ([x, y, z]) -- a single flat list/array passed as one argument:+ elif coords.ndim == 2 and coords.shape[0] == 1:+ # Extract the single list so [x, y, z] is treated like c2p(x, y, z).+ coords = coords[0]# Otherwise, coords already looked like (x, y, z) or ([x1 x2 ...], [y1 y2 ...], [z1 z2 ...]),# so no further processing is needed.