Skip to content

Commit a6af7f3

Browse files
josiestbehackl
andauthored
Cleanup TipableVMobject: avoid mutable default and fix assign_tip_attr typo (#4503)
* Small touch-ups before fixing tip bugs - fixed mutable default argument in Tipable VMobject constructor - fixed typo in method name assign_tip_attr - added two todo's which outline unexpected behavior in tip placement and how to solve * refactor: align tip attr naming and remove TODO comments --------- Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
1 parent e34e707 commit a6af7f3

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

manim/mobject/geometry/arc.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ def __init__(
101101
self,
102102
tip_length: float = DEFAULT_ARROW_TIP_LENGTH,
103103
normal_vector: Vector3DLike = OUT,
104-
tip_style: dict = {},
104+
tip_style: dict | None = None,
105105
**kwargs: Any,
106106
) -> None:
107107
self.tip_length: float = tip_length
108108
self.normal_vector = normal_vector
109-
self.tip_style: dict = tip_style
109+
self.tip_style: dict = tip_style if tip_style is not None else {}
110110
super().__init__(**kwargs)
111111

112112
# Adding, Creating, Modifying tips
@@ -128,7 +128,7 @@ def add_tip(
128128
else:
129129
self.position_tip(tip, at_start)
130130
self.reset_endpoints_based_on_tip(tip, at_start)
131-
self.asign_tip_attr(tip, at_start)
131+
self.assign_tip_attr(tip, at_start)
132132
self.add(tip)
133133
return self
134134

@@ -201,6 +201,7 @@ def position_tip(self, tip: tips.ArrowTip, at_start: bool = False) -> tips.Arrow
201201
axis=axis,
202202
) # Rotates the tip along the vertical wrt the axis
203203
self._init_positioning_axis = axis
204+
204205
tip.shift(anchor - tip.tip_point)
205206
return tip
206207

@@ -215,7 +216,7 @@ def reset_endpoints_based_on_tip(self, tip: tips.ArrowTip, at_start: bool) -> Se
215216
self.put_start_and_end_on(self.get_start(), tip.base)
216217
return self
217218

218-
def asign_tip_attr(self, tip: tips.ArrowTip, at_start: bool) -> Self:
219+
def assign_tip_attr(self, tip: tips.ArrowTip, at_start: bool) -> Self:
219220
if at_start:
220221
self.start_tip = tip
221222
else:

manim/mobject/opengl/opengl_geometry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def add_tip(self, at_start: bool = False, **kwargs: Any) -> Self:
107107
"""
108108
tip = self.create_tip(at_start, **kwargs)
109109
self.reset_endpoints_based_on_tip(tip, at_start)
110-
self.asign_tip_attr(tip, at_start)
110+
self.assign_tip_attr(tip, at_start)
111111
self.add(tip)
112112
return self
113113

@@ -160,7 +160,7 @@ def reset_endpoints_based_on_tip(self, tip: OpenGLArrowTip, at_start: bool) -> S
160160
self.put_start_and_end_on(start, end)
161161
return self
162162

163-
def asign_tip_attr(self, tip: OpenGLArrowTip, at_start: bool) -> Self:
163+
def assign_tip_attr(self, tip: OpenGLArrowTip, at_start: bool) -> Self:
164164
if at_start:
165165
self.start_tip = tip
166166
else:

0 commit comments

Comments
 (0)