Clean up trash from ChangingDecimal

This commit is contained in:
Grant Sanderson 2021-01-13 00:09:10 -10:00
parent dd2a459eaa
commit 091cd355d4

View file

@ -1,5 +1,3 @@
import warnings
from manimlib.animation.animation import Animation from manimlib.animation.animation import Animation
from manimlib.mobject.numbers import DecimalNumber from manimlib.mobject.numbers import DecimalNumber
from manimlib.utils.bezier import interpolate from manimlib.utils.bezier import interpolate
@ -11,31 +9,10 @@ class ChangingDecimal(Animation):
} }
def __init__(self, decimal_mob, number_update_func, **kwargs): def __init__(self, decimal_mob, number_update_func, **kwargs):
self.check_validity_of_input(decimal_mob) assert(isinstance(decimal_mob, DecimalNumber))
self.yell_about_depricated_configuration(**kwargs)
self.number_update_func = number_update_func self.number_update_func = number_update_func
super().__init__(decimal_mob, **kwargs) super().__init__(decimal_mob, **kwargs)
def check_validity_of_input(self, decimal_mob):
if not isinstance(decimal_mob, DecimalNumber):
raise Exception(
"ChangingDecimal can only take "
"in a DecimalNumber"
)
def yell_about_depricated_configuration(self, **kwargs):
# Obviously this would optimally be removed at
# some point.
for attr in ["tracked_mobject", "position_update_func"]:
if attr in kwargs:
warnings.warn("""
Don't use {} for ChangingDecimal,
that functionality has been depricated
and you should use a mobject updater
instead
""".format(attr)
)
def interpolate_mobject(self, alpha): def interpolate_mobject(self, alpha):
self.mobject.set_value( self.mobject.set_value(
self.number_update_func(alpha) self.number_update_func(alpha)