A community-maintained Python framework for creating mathematical animations.
Added depreaction for positive_space_ratio and dash_spacing (#1848)
Jason Villanuevae62425e4f2ed
diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.pyindex 394cd1b0e..ceddba58c 100644--- a/manim/mobject/geometry.py+++ b/manim/mobject/geometry.py@@ -79,6 +79,7 @@ from ..constants import *from ..mobject.mobject import Mobjectfrom ..mobject.types.vectorized_mobject import DashedVMobject, VGroup, VMobjectfrom ..utils.color import *+from ..utils.deprecation import deprecated_paramsfrom ..utils.iterables import adjacent_n_tuples, adjacent_pairsfrom ..utils.simple_functions import fdivfrom ..utils.space_ops import (@@ -1114,6 +1115,12 @@ class DashedLine(Line)::class:`~.DashedVMobject`"""+ @deprecated_params(+ params="positive_space_ratio dash_spacing",+ since="v0.9.0",+ message="Use dashed_ratio instead of positive_space_ratio.",+ redirections=[("positive_space_ratio", "dashed_ratio")],+ )def __init__(self,*args,@@ -1121,6 +1128,9 @@ class DashedLine(Line):dashed_ratio=0.5,**kwargs,):+ self.dash_spacing = kwargs.pop(+ "dash_spacing", None+ ) # Unused param, remove with deprecation warningself.dash_length = dash_lengthself.dashed_ratio = dashed_ratiosuper().__init__(*args, **kwargs)diff --git a/manim/mobject/opengl_geometry.py b/manim/mobject/opengl_geometry.pyindex 5835859e9..783d97c74 100644--- a/manim/mobject/opengl_geometry.py+++ b/manim/mobject/opengl_geometry.py@@ -9,7 +9,7 @@ from ..mobject.types.opengl_vectorized_mobject import (OpenGLVMobject,)from ..utils.color import *-from ..utils.deprecation import deprecated+from ..utils.deprecation import deprecated_paramsfrom ..utils.iterables import adjacent_n_tuples, adjacent_pairsfrom ..utils.simple_functions import clip, fdivfrom ..utils.space_ops import (@@ -525,11 +525,18 @@ class OpenGLLine(OpenGLTipableVMobject):class OpenGLDashedLine(OpenGLLine):+ @deprecated_params(+ params="positive_space_ratio dash_spacing",+ since="v0.9.0",+ message="Use dashed_ratio instead of positive_space_ratio.",+ )def __init__(self, *args, dash_length=DEFAULT_DASH_LENGTH, dashed_ratio=0.5, **kwargs):+ # Simplify with removal of deprecation warning+ self.dash_spacing = kwargs.pop("dash_spacing", None) # Unused param+ self.dashed_ratio = kwargs.pop("positive_space_ratio", None) or dashed_ratioself.dash_length = dash_length- self.dashed_ratio = dashed_ratiosuper().__init__(*args, **kwargs)dashed_ratio = self.dashed_rationum_dashes = self.calculate_num_dashes(dashed_ratio)diff --git a/manim/mobject/types/opengl_vectorized_mobject.py b/manim/mobject/types/opengl_vectorized_mobject.pyindex 31ad2bef9..88a4e6de0 100644--- a/manim/mobject/types/opengl_vectorized_mobject.py+++ b/manim/mobject/types/opengl_vectorized_mobject.py@@ -19,6 +19,7 @@ from ...utils.bezier import (partial_quadratic_bezier_points,)from ...utils.color import *+from ...utils.deprecation import deprecated_paramsfrom ...utils.iterables import listify, make_even, resize_with_interpolationfrom ...utils.space_ops import (angle_between_vectors,@@ -1227,11 +1228,18 @@ class OpenGLCurvesAsSubmobjects(OpenGLVGroup):class OpenGLDashedVMobject(OpenGLVMobject):+ @deprecated_params(+ params="positive_space_ratio dash_spacing",+ since="v0.9.0",+ message="Use dashed_ratio instead of positive_space_ratio.",+ )def __init__(self, vmobject, num_dashes=15, dashed_ratio=0.5, color=WHITE, **kwargs):+ # Simplify with removal of deprecation warning+ self.dash_spacing = kwargs.pop("dash_spacing", None) # Unused param+ self.dashed_ratio = kwargs.pop("positive_space_ratio", None) or dashed_ratioself.num_dashes = num_dashes- self.dashed_ratio = dashed_ratiosuper().__init__(color=color, **kwargs)r = self.dashed_ration = self.num_dashesdiff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.pyindex 3e83b10cd..69742d198 100644--- a/manim/mobject/types/vectorized_mobject.py+++ b/manim/mobject/types/vectorized_mobject.py@@ -33,6 +33,7 @@ from ...utils.bezier import (partial_bezier_points,)from ...utils.color import BLACK, WHITE, color_to_rgba+from ...utils.deprecation import deprecated_paramsfrom ...utils.iterables import make_even, stretch_array_to_length, tuplifyfrom ...utils.simple_functions import clip_in_placefrom ...utils.space_ops import rotate_vector, shoelace_direction@@ -2101,11 +2102,18 @@ class DashedVMobject(VMobject, metaclass=ConvertToOpenGL):"""+ @deprecated_params(+ params="positive_space_ratio dash_spacing",+ since="v0.9.0",+ message="Use dashed_ratio instead of positive_space_ratio.",+ )def __init__(self, vmobject, num_dashes=15, dashed_ratio=0.5, color=WHITE, **kwargs):+ # Simplify with removal of deprecation warning+ self.dash_spacing = kwargs.pop("dash_spacing", None) # Unused param+ self.dashed_ratio = kwargs.pop("positive_space_ratio", None) or dashed_ratioself.num_dashes = num_dashes- self.dashed_ratio = dashed_ratiosuper().__init__(color=color, **kwargs)r = self.dashed_ration = self.num_dashes