A community-maintained Python framework for creating mathematical animations.
Get rid of ContinuallyChangingDecimal
Grant Sandersonfd6a6482f98b
diff --git a/active_projects/eop/chapter1/area_model_erf.py b/active_projects/eop/chapter1/area_model_erf.pyindex 36fd0ccea..0b9758363 100644--- a/active_projects/eop/chapter1/area_model_erf.py+++ b/active_projects/eop/chapter1/area_model_erf.py@@ -92,22 +92,13 @@ class IllustrateAreaModelErf(GraphScene):)self.add_foreground_mobject(cdf_value)- cdf_percentage = DecimalNumber(0, unit = "\%")+ cdf_percentage = DecimalNumber(0, unit = "\\%")cdf_percentage.move_to(self.coords_to_point(0,0.2))self.add_foreground_mobject(cdf_percentage)- self.add(ContinualChangingDecimal(- decimal_number_mobject = cdf_value,- number_update_func = integral_update_func,- num_decimal_places = 3- ))-- self.add(ContinualChangingDecimal(- decimal_number_mobject = cdf_percentage,- number_update_func = integral_update_func_percent,- num_decimal_places = 1- ))-+ cdf_value.add_updater(+ lambda m: m.set_value(integral_update_func())+ )anim = self.get_animation_integral_bounds_change(graph, x_min_2, x_max_2,diff --git a/active_projects/shadows.py b/active_projects/shadows.pyindex c9e14601c..1ffb92ebf 100644--- a/active_projects/shadows.py+++ b/active_projects/shadows.py@@ -117,16 +117,17 @@ class ShowShadows(ThreeDScene):# self.add_fixed_in_frame_mobjects(decimal)# decimal.add_updater(update_decimal)- continual_update = ContinualChangingDecimal(- decimal,- lambda a: get_area(self.shadow),- position_update_func=lambda d: self.add_fixed_in_frame_mobjects(d)+ decimal.add_updater(+ lambda d: d.set_value(get_area(self.shadow))+ )+ decimal.add_updater(+ lambda d: self.add_fixed_in_frame_mobjects(d))# self.add_fixed_orientation_mobjects(label)self.add_fixed_in_frame_mobjects(label)self.add(label)- self.add(continual_update)+ self.add(decimal)def add_surface_area_label(self):text = TextMobject("Surface area: ")diff --git a/big_ol_pile_of_manim_imports.py b/big_ol_pile_of_manim_imports.pyindex eda100f63..7ac299141 100644--- a/big_ol_pile_of_manim_imports.py+++ b/big_ol_pile_of_manim_imports.py@@ -35,7 +35,6 @@ from manimlib.camera.moving_camera import *from manimlib.camera.three_d_camera import *from manimlib.continual_animation.continual_animation import *-from manimlib.continual_animation.numbers import *from manimlib.continual_animation.update import *from manimlib.mobject.coordinate_systems import *diff --git a/manimlib/continual_animation/numbers.py b/manimlib/continual_animation/numbers.pydeleted file mode 100644index a08396f89..000000000--- a/manimlib/continual_animation/numbers.py+++ /dev/null@@ -1,9 +0,0 @@-# from manimlib.animation.numbers import ChangingDecimal-# from manimlib.continual_animation.from_animation import NormalAnimationAsContinualAnimation---# class ContinualChangingDecimal(NormalAnimationAsContinualAnimation):-# def __init__(self, *args, **kwargs):-# NormalAnimationAsContinualAnimation.__init__(-# self, ChangingDecimal(*args, **kwargs)-# )diff --git a/old_projects/WindingNumber.py b/old_projects/WindingNumber.pyindex ae9b3d589..d24fca526 100644--- a/old_projects/WindingNumber.py+++ b/old_projects/WindingNumber.py@@ -1,4 +1,3 @@-from big_ol_pile_of_manim_imports import *import time@@ -6,6 +5,12 @@ import timeimport mpmathmpmath.mp.dps = 7++# Warning, this file uses ContinualChangingDecimal,+# which has since been been deprecated. Use a mobject+# updater instead++# Useful constants to play around withUL = UP + LEFTUR = UP + RIGHTdiff --git a/old_projects/WindingNumber_G.py b/old_projects/WindingNumber_G.pyindex a62997864..c643095c1 100644--- a/old_projects/WindingNumber_G.py+++ b/old_projects/WindingNumber_G.py@@ -5,6 +5,12 @@ from big_ol_pile_of_manim_imports import *from old_projects.uncertainty import Flashfrom old_projects.WindingNumber import *++# Warning, this file uses ContinualChangingDecimal,+# which has since been been deprecated. Use a mobject+# updater instead++class AltTeacherStudentsScene(TeacherStudentsScene):def setup(self):TeacherStudentsScene.setup(self)diff --git a/old_projects/alt_calc.py b/old_projects/alt_calc.pyindex 5bb80b87e..6d57206d0 100644--- a/old_projects/alt_calc.py+++ b/old_projects/alt_calc.py@@ -1209,9 +1209,11 @@ class StandardDerivativeVisual(GraphScene):slope_decimal = DecimalNumber(slope_line.get_slope())slope_decimal.match_color(slope_line)- slope_decimal_update = ContinualChangingDecimal(- slope_decimal, lambda dt: slope_line.get_slope(),- position_update_func=lambda m: m.next_to(+ slope_decimal.add_updater(+ lambda d: d.set_value(slope_line.get_slope())+ )+ slope_decimal.add_upater(+ lambda d: d.next_to(deriv_label, RIGHT, SMALL_BUFF).shift(0.2 * SMALL_BUFF * DOWN))@@ -1226,7 +1228,6 @@ class StandardDerivativeVisual(GraphScene):self.add(slope_line_update,# deriv_label_update,- slope_decimal_update,)for x in 9, 2, 4:self.play(diff --git a/old_projects/basel/basel.py b/old_projects/basel/basel.pyindex 954309cb2..7eb77dba3 100644--- a/old_projects/basel/basel.py+++ b/old_projects/basel/basel.py@@ -871,8 +871,10 @@ class SingleLighthouseScene(PiCreatureScene):self.angle_indicator.next_to(self.angle_arc,RIGHT)angle_update_func = lambda x: self.light_source.spotlight.opening_angle() / DEGREES- ca1 = ContinualChangingDecimal(self.angle_indicator,angle_update_func)- self.add(ca1)+ self.angle_indicator.add_updater(+ lambda d: d.set_value(angle_update_func())+ )+ self.add(self.angle_indicator)ca2 = AngleUpdater(self.angle_arc, self.light_source.spotlight)self.add(ca2)diff --git a/old_projects/basel/basel2.py b/old_projects/basel/basel2.pyindex 0e547ccb1..efe3da142 100644--- a/old_projects/basel/basel2.py+++ b/old_projects/basel/basel2.py@@ -1302,10 +1302,10 @@ class IntroduceScreen(Scene):self.angle_indicator.next_to(self.angle_arc, RIGHT)angle_update_func = lambda x: self.light_source.spotlight.opening_angle() / DEGREES- angle_tracker = ContinualChangingDecimal(- self.angle_indicator, angle_update_func+ self.angle_indicator.add_updater(+ lambda d: d.set_value(angle_update_func()))- self.add(angle_tracker)+ self.add(self.angle_indicator)arc_tracker = AngleUpdater(self.angle_arc,diff --git a/old_projects/dandelin.py b/old_projects/dandelin.pyindex 496fda958..bd2d288ef 100644--- a/old_projects/dandelin.py+++ b/old_projects/dandelin.py@@ -679,10 +679,10 @@ class EccentricityInThumbtackCase(ShowArrayOfEccentricities):def get_eccentricity_value_update(self, eccentricity_label, ellipse):decimal = eccentricity_label[1]- return ContinualChangingDecimal(- decimal,- lambda a: self.get_eccentricity(ellipse)- )+ decimal.add_updater(lambda d: d.set_value(+ self.get_eccentricity(ellipse)+ ))+ return decimaldef get_outer_dashed_lines(self, ellipse):line = DashedLine(2.5 * UP, 2.5 * DOWN)diff --git a/old_projects/div_curl.py b/old_projects/div_curl.pyindex 32c154e3a..396e0783b 100644--- a/old_projects/div_curl.py+++ b/old_projects/div_curl.py@@ -18,6 +18,11 @@ FOX_COLOR = "#DF7F20"RABBIT_COLOR = "#C6D6EF"+# Warning, this file uses ContinualChangingDecimal,+# which has since been been deprecated. Use a mobject+# updater instead++# Helper functionsdef get_flow_start_points(x_min=-8, x_max=8,y_min=-5, y_max=5,@@ -1108,9 +1113,11 @@ class ElectricField(CylinderModel, MovingCameraScene):y = voltage_point.get_center()[1]return 10 - y- voltage_update = ContinualChangingDecimal(- voltage, get_voltage,- position_update_func=lambda v: v.next_to(+ voltage_update = voltage.add_updater(+ lambda d: d.set_value(get_voltage),+ )+ voltage.add_updater(+ lambda d: d.next_to(voltage_point, UP, SMALL_BUFF))diff --git a/old_projects/gradient.py b/old_projects/gradient.pyindex be6ab7542..8511c0921 100644--- a/old_projects/gradient.py+++ b/old_projects/gradient.py@@ -1,6 +1,11 @@from big_ol_pile_of_manim_imports import *+# Warning, this file uses ContinualChangingDecimal,+# which has since been been deprecated. Use a mobject+# updater instead++class GradientDescentWrapper(Scene):def construct(self):title = TextMobject("Gradient descent")diff --git a/old_projects/lost_lecture.py b/old_projects/lost_lecture.pyindex a7f494dfe..46aefa172 100644--- a/old_projects/lost_lecture.py+++ b/old_projects/lost_lecture.py@@ -7,6 +7,11 @@ from old_projects.div_curl import get_force_field_funcCOBALT = "#0047AB"+# Warning, this file uses ContinualChangingDecimal,+# which has since been been deprecated. Use a mobject+# updater instead++class Orbiting(ContinualAnimation):CONFIG = {"rate": 7.5,diff --git a/old_projects/pi_day.py b/old_projects/pi_day.pyindex 0f6ed921a..81b532262 100644--- a/old_projects/pi_day.py+++ b/old_projects/pi_day.py@@ -15,6 +15,10 @@ DECIMAL_WIDTH = 0.5HIGHLIGHT_COLOR = YELLOW+# Warning, this file uses ContinualChangingDecimal,+# which has since been been deprecated. Use a mobject+# updater instead+class ArcLengthChange(Animation):def __init__(self, mobject = None, new_angle = TAU/3, **kwargs):diff --git a/old_projects/quaternions.py b/old_projects/quaternions.pyindex 848c83fae..ebc7b97be 100644--- a/old_projects/quaternions.py+++ b/old_projects/quaternions.py@@ -3319,10 +3319,10 @@ class SphereExamplePointsDecimal(Scene):def generate_decimal_updater(decimal, index):shifted_i = (index - 1) % 3- return ContinualChangingDecimal(- decimal,- lambda a: point.get_location()[shifted_i]- )+ decimal.add_updater(lambda d: d.set_value(+ point.get_location()[shifted_i]+ ))+ return decimalfor i, decimal in enumerate(decimals):self.add(generate_decimal_updater(decimal, i))