Skip to content

Commit 401355c

Browse files
Added typehints for ValueTracker (#1300)
* Added typehints * added import Co-authored-by: Jason Villanueva <[email protected]>
1 parent 875f2d1 commit 401355c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

manim/mobject/value_tracker.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
__all__ = ["ValueTracker", "ExponentialValueTracker", "ComplexValueTracker"]
44

55

6+
from typing import Union
7+
68
import numpy as np
79

810
from ..mobject.mobject import Mobject
@@ -52,25 +54,25 @@ def __init__(self, value=0, **kwargs):
5254
self.points = np.zeros((1, 3))
5355
self.set_value(value)
5456

55-
def get_value(self):
57+
def get_value(self) -> float:
5658
"""Get the current value of the ValueTracker. This value changes continuously when :attr:`animate` for the ValueTracker is called."""
5759
return self.points[0, 0]
5860

59-
def set_value(self, value):
60-
"""Sets a new value (float, int) to the ValueTracker"""
61+
def set_value(self, value: Union[float, int]):
62+
"""Sets a new scalar value to the ValueTracker"""
6163
self.points[0, 0] = value
6264
return self
6365

64-
def increment_value(self, d_value):
65-
"""Increments (adds) a value (float, int) to the ValueTracker"""
66+
def increment_value(self, d_value: Union[float, int]):
67+
"""Increments (adds) a scalar value to the ValueTracker"""
6668
self.set_value(self.get_value() + d_value)
6769

68-
def __iadd__(self, d_value):
70+
def __iadd__(self, d_value: Union[float, int]):
6971
"""adds ``+=`` syntax to increment the value of the ValueTracker"""
7072
self.increment_value(d_value)
7173
return self
7274

73-
def __isub__(self, d_value):
75+
def __isub__(self, d_value: Union[float, int]):
7476
"""adds ``-=`` syntax to decrement the value of the ValueTracker"""
7577
self.increment_value(-d_value)
7678
return self

0 commit comments

Comments
 (0)