|
3 | 3 | __all__ = ["ValueTracker", "ExponentialValueTracker", "ComplexValueTracker"]
|
4 | 4 |
|
5 | 5 |
|
| 6 | +from typing import Union |
| 7 | + |
6 | 8 | import numpy as np
|
7 | 9 |
|
8 | 10 | from ..mobject.mobject import Mobject
|
@@ -52,25 +54,25 @@ def __init__(self, value=0, **kwargs):
|
52 | 54 | self.points = np.zeros((1, 3))
|
53 | 55 | self.set_value(value)
|
54 | 56 |
|
55 |
| - def get_value(self): |
| 57 | + def get_value(self) -> float: |
56 | 58 | """Get the current value of the ValueTracker. This value changes continuously when :attr:`animate` for the ValueTracker is called."""
|
57 | 59 | return self.points[0, 0]
|
58 | 60 |
|
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""" |
61 | 63 | self.points[0, 0] = value
|
62 | 64 | return self
|
63 | 65 |
|
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""" |
66 | 68 | self.set_value(self.get_value() + d_value)
|
67 | 69 |
|
68 |
| - def __iadd__(self, d_value): |
| 70 | + def __iadd__(self, d_value: Union[float, int]): |
69 | 71 | """adds ``+=`` syntax to increment the value of the ValueTracker"""
|
70 | 72 | self.increment_value(d_value)
|
71 | 73 | return self
|
72 | 74 |
|
73 |
| - def __isub__(self, d_value): |
| 75 | + def __isub__(self, d_value: Union[float, int]): |
74 | 76 | """adds ``-=`` syntax to decrement the value of the ValueTracker"""
|
75 | 77 | self.increment_value(-d_value)
|
76 | 78 | return self
|
|
0 commit comments