A community-maintained Python framework for creating mathematical animations.
renamed num_decimal_points -> num_decimal_places
Ben Hambrechtfd002c13e6c3
diff --git a/active_projects/eop/chapter1/area_model_erf.py b/active_projects/eop/chapter1/area_model_erf.pyindex cb9783600..36fd0ccea 100644--- a/active_projects/eop/chapter1/area_model_erf.py+++ b/active_projects/eop/chapter1/area_model_erf.py@@ -84,7 +84,7 @@ class IllustrateAreaModelErf(GraphScene):equals_sign = TexMobject("=").next_to(cdf_formula, buff = MED_LARGE_BUFF)- cdf_value = DecimalNumber(0, color = graph.color, num_decimal_points = 3)+ cdf_value = DecimalNumber(0, color = graph.color, num_decimal_places = 3)cdf_value.next_to(equals_sign)self.play(FadeIn(equals_sign),@@ -99,13 +99,13 @@ class IllustrateAreaModelErf(GraphScene):self.add(ContinualChangingDecimal(decimal_number_mobject = cdf_value,number_update_func = integral_update_func,- num_decimal_points = 3+ num_decimal_places = 3))self.add(ContinualChangingDecimal(decimal_number_mobject = cdf_percentage,number_update_func = integral_update_func_percent,- num_decimal_points = 1+ num_decimal_places = 1))diff --git a/active_projects/eop/chapter1/morph_brick_row_into_histogram.py b/active_projects/eop/chapter1/morph_brick_row_into_histogram.pyindex 213093b21..be3f744e3 100644--- a/active_projects/eop/chapter1/morph_brick_row_into_histogram.py+++ b/active_projects/eop/chapter1/morph_brick_row_into_histogram.py@@ -132,7 +132,7 @@ class MorphBrickRowIntoHistogram3(GenericMorphBrickRowIntoHistogram):area_color = YELLOWtotal_area_text = TextMobject("total area =", color = area_color)- area_decimal = DecimalNumber(0, color = area_color, num_decimal_points = 3)+ area_decimal = DecimalNumber(0, color = area_color, num_decimal_places = 3)area_decimal.next_to(total_area_text, RIGHT)total_area_group = VGroup(total_area_text, area_decimal)@@ -213,7 +213,7 @@ class MorphBrickRowIntoHistogram20(GenericMorphBrickRowIntoHistogram):y_guide_height = self.bar_anchor_height + i * float(self.row.width)y_guide_heights.append(y_guide_height)y_guide.move_to(y_guide_height * UP)- y_guide_label = DecimalNumber(i, num_decimal_points = 2, color = GRAY)+ y_guide_label = DecimalNumber(i, num_decimal_places = 2, color = GRAY)y_guide_label.scale(0.7)y_guide_label.next_to(y_guide, LEFT)y_guide.add(y_guide_label)diff --git a/active_projects/eop/chapter1/quiz_result.py b/active_projects/eop/chapter1/quiz_result.pyindex 4d7a0f38e..3488efea6 100644--- a/active_projects/eop/chapter1/quiz_result.py+++ b/active_projects/eop/chapter1/quiz_result.py@@ -159,7 +159,7 @@ class QuizResult(PiCreatureScene):anims = []for (label, percentage) in zip(grade_hist.y_labels_group, percentages):new_label = DecimalNumber(percentage,- num_decimal_points = 1,+ num_decimal_places = 1,unit = "\%",color = highlight_color)diff --git a/animation/numbers.py b/animation/numbers.pyindex f7b8d250b..428203f31 100644--- a/animation/numbers.py+++ b/animation/numbers.py@@ -10,7 +10,7 @@ from utils.config_ops import digest_configclass ChangingDecimal(Animation):CONFIG = {- "num_decimal_points": None,+ "num_decimal_places": None,"show_ellipsis": None,"position_update_func": None,"tracked_mobject": None,@@ -21,7 +21,7 @@ class ChangingDecimal(Animation):self.decimal_number_config = dict(decimal_number_mobject.initial_config)- for attr in "num_decimal_points", "show_ellipsis":+ for attr in "num_decimal_places", "show_ellipsis":value = getattr(self, attr)if value is not None:self.decimal_number_config[attr] = valuediff --git a/mobject/matrix.py b/mobject/matrix.pyindex 727f8f4db..cb8e1af2c 100644--- a/mobject/matrix.py+++ b/mobject/matrix.py@@ -139,7 +139,7 @@ class Matrix(VMobject):class DecimalMatrix(Matrix):CONFIG = {"element_to_mobject": DecimalNumber,- "element_to_mobject_config": {"num_decimal_points": 1}+ "element_to_mobject_config": {"num_decimal_places": 1}}diff --git a/mobject/numbers.py b/mobject/numbers.pyindex 5a6ff6820..e4986813b 100644--- a/mobject/numbers.py+++ b/mobject/numbers.py@@ -8,7 +8,7 @@ from mobject.types.vectorized_mobject import VMobjectclass DecimalNumber(VMobject):CONFIG = {- "num_decimal_points": 2,+ "num_decimal_places": 2,"digit_to_digit_buff": 0.05,"show_ellipsis": False,"unit": None, # Aligned to bottom unless it starts with "^"@@ -18,7 +18,7 @@ class DecimalNumber(VMobject):def __init__(self, number, **kwargs):VMobject.__init__(self, **kwargs)self.number = number- ndp = self.num_decimal_points+ ndp = self.num_decimal_places# Build number stringif isinstance(number, complex):@@ -71,5 +71,5 @@ class DecimalNumber(VMobject):class Integer(DecimalNumber):CONFIG = {- "num_decimal_points": 0,+ "num_decimal_places": 0,}diff --git a/old_projects/WindingNumber.py b/old_projects/WindingNumber.pyindex c2d20fef6..c12c5cbd2 100644--- a/old_projects/WindingNumber.py+++ b/old_projects/WindingNumber.py@@ -565,7 +565,7 @@ def walker_animation_with_display(number_update_func = None,show_arrows = True,scale_arrows = False,- num_decimal_points = 1,+ num_decimal_places = 1,include_background_rectangle = True,**kwargs):@@ -581,7 +581,7 @@ def walker_animation_with_display(if number_update_func != None:display = DecimalNumber(0,- num_decimal_points = num_decimal_points,+ num_decimal_places = num_decimal_places,fill_color = WHITE if include_background_rectangle else BLACK,include_background_rectangle = include_background_rectangle)if include_background_rectangle:@@ -732,7 +732,7 @@ class PiWalker(ColorMappedByFuncScene):"show_num_plane" : False,"draw_lines" : True,"num_checkpoints" : 10,- "num_decimal_points" : 1,+ "num_decimal_places" : 1,"include_background_rectangle" : False,}@@ -788,7 +788,7 @@ class PiWalker(ColorMappedByFuncScene):number_update_func = number_update_func,run_time = self.step_run_time,walker_stroke_color = WALKER_LIGHT_COLOR if self.color_foreground_not_background else BLACK,- num_decimal_points = self.num_decimal_points,+ num_decimal_places = self.num_decimal_places,include_background_rectangle = self.include_background_rectangle,)@@ -2751,7 +2751,7 @@ class OneFifthTwoFifthWinder(SpecifiedWinder):"step_size" : 0.01,"show_num_plane" : False,"step_run_time" : 6,- "num_decimal_points" : 2,+ "num_decimal_places" : 2,}class OneFifthOneFifthWinderWithReset(OneFifthTwoFifthWinder):diff --git a/old_projects/WindingNumber_G.py b/old_projects/WindingNumber_G.pyindex 501fc289c..4b65bb310 100644--- a/old_projects/WindingNumber_G.py+++ b/old_projects/WindingNumber_G.py@@ -386,7 +386,7 @@ class Introduce1DFunctionCase(Scene):)decimal = DecimalNumber(0,- num_decimal_points = 3,+ num_decimal_places = 3,show_ellipsis = True,)decimal.scale(0.7)@@ -484,7 +484,7 @@ class Introduce1DFunctionCase(Scene):if show_decimal:decimal = DecimalNumber(axes.x_axis.point_to_number(arrow.get_start()),- num_decimal_points = 3,+ num_decimal_places = 3,# show_ellipsis = True,)height = self.rect.get_height()@@ -2310,7 +2310,7 @@ class TransitionFromPathsToBoundaries(ColorMappedObjectsScene):))- label = DecimalNumber(0, num_decimal_points = 1)+ label = DecimalNumber(0, num_decimal_places = 1)label_upadte = ContinualChangingDecimal(label, get_total_winding,position_update_func = lambda l : l.next_to(dot, UP+LEFT, SMALL_BUFF)diff --git a/old_projects/basel/basel.py b/old_projects/basel/basel.pyindex 259c537cb..698091077 100644--- a/old_projects/basel/basel.py+++ b/old_projects/basel/basel.py@@ -119,7 +119,7 @@ class LightIndicator(VMobject):self.foreground.set_stroke(color=INDICATOR_STROKE_COLOR,width=INDICATOR_STROKE_WIDTH)self.add(self.background, self.foreground)- self.reading = DecimalNumber(self.intensity,num_decimal_points = self.precision)+ self.reading = DecimalNumber(self.intensity,num_decimal_places = self.precision)self.reading.set_fill(color=INDICATOR_TEXT_COLOR)self.reading.move_to(self.get_center())if self.show_reading:@@ -287,7 +287,7 @@ class IntroScene(PiCreatureScene):equals_sign = self.euler_sum.get_part_by_tex("=")self.partial_sum_decimal = DecimalNumber(partial_results_values[1],- num_decimal_points = 2)+ num_decimal_places = 2)self.partial_sum_decimal.next_to(equals_sign, RIGHT)@@ -313,7 +313,7 @@ class IntroScene(PiCreatureScene):self.partial_sum_decimal,partial_results_values[i+1],run_time = self.duration,- num_decimal_points = 6,+ num_decimal_places = 6,show_ellipsis = True,position_update_func = lambda m: m.next_to(equals_sign, RIGHT))@@ -863,7 +863,7 @@ class SingleLighthouseScene(PiCreatureScene):# angle msmt (decimal number)self.angle_indicator = DecimalNumber(arc_angle / DEGREES,- num_decimal_points = 0,+ num_decimal_places = 0,unit = "^\\circ",fill_opacity = 1.0,fill_color = WHITE)@@ -4262,7 +4262,7 @@ class LabeledArc(Arc):Arc.__init__(self,angle,**kwargs)- label = DecimalNumber(self.length, num_decimal_points = 0)+ label = DecimalNumber(self.length, num_decimal_places = 0)r = BUFFER * self.radiustheta = self.start_angle + self.angle/2label_pos = r * np.array([np.cos(theta), np.sin(theta), 0])diff --git a/old_projects/basel/basel2.py b/old_projects/basel/basel2.pyindex 1638a26f3..bdd41ccc3 100644--- a/old_projects/basel/basel2.py+++ b/old_projects/basel/basel2.py@@ -94,7 +94,7 @@ class LightIndicator(Mobject):self.foreground.set_fill(color = self.fill_color)self.add(self.background, self.foreground)- self.reading = DecimalNumber(self.intensity,num_decimal_points = self.precision)+ self.reading = DecimalNumber(self.intensity,num_decimal_places = self.precision)self.reading.set_fill(color=INDICATOR_TEXT_COLOR)self.reading.scale_to_fit_height(self.reading_height)self.reading.move_to(self.get_center())@@ -317,7 +317,7 @@ class IntroScene(PiCreatureScene):partial_sum_decimal = self.partial_sum_decimal = DecimalNumber(series_terms[1],- num_decimal_points = 2+ num_decimal_places = 2)partial_sum_decimal.next_to(equals_sign, RIGHT)@@ -418,7 +418,7 @@ class IntroScene(PiCreatureScene):partial_sum_decimal,series_terms[i+1],run_time = 1,- num_decimal_points = 6,+ num_decimal_places = 6,position_update_func = lambda m: m.next_to(equals_sign, RIGHT))]@@ -430,7 +430,7 @@ class IntroScene(PiCreatureScene):ChangeDecimalToValue(partial_sum_decimal,series_terms[i+1],- num_decimal_points = 6,+ num_decimal_places = 6,),]if i == 5:@@ -451,7 +451,7 @@ class IntroScene(PiCreatureScene):ChangeDecimalToValue(partial_sum_decimal,series_terms[-1],- num_decimal_points = 6,+ num_decimal_places = 6,),morty.change, "confused",)@@ -1295,7 +1295,7 @@ class IntroduceScreen(Scene):self.angle_indicator = DecimalNumber(arc_angle / DEGREES,- num_decimal_points = 0,+ num_decimal_places = 0,unit = "^\\circ")self.angle_indicator.next_to(self.angle_arc, RIGHT)@@ -3818,7 +3818,7 @@ class ThinkBackToHowAmazingThisIs(ThreeDScene):dot_pairs = it.starmap(VGroup, zip(positive_dots, negative_dots))# Decimal- decimal = DecimalNumber(0, num_decimal_points = 6)+ decimal = DecimalNumber(0, num_decimal_places = 6)decimal.to_edge(UP)terms = [2./(n**2) for n in range(1, 100, 2)]partial_sums = np.cumsum(terms)@@ -4250,7 +4250,7 @@ class LabeledArc(Arc):Arc.__init__(self,angle,**kwargs)- label = DecimalNumber(self.length, num_decimal_points = 0)+ label = DecimalNumber(self.length, num_decimal_places = 0)r = BUFFER * self.radiustheta = self.start_angle + self.angle/2label_pos = r * np.array([np.cos(theta), np.sin(theta), 0])diff --git a/old_projects/fourier.py b/old_projects/fourier.pyindex 830f8c78e..33d624e56 100644--- a/old_projects/fourier.py+++ b/old_projects/fourier.py@@ -728,7 +728,7 @@ class UnmixMixedPaint(Scene):class MachineThatTreatsOneFrequencyDifferently(Scene):def construct(self):graph = self.get_cosine_graph(0.5)- frequency_mob = DecimalNumber(220, num_decimal_points = 0)+ frequency_mob = DecimalNumber(220, num_decimal_places = 0)frequency_mob.next_to(graph, UP, buff = MED_LARGE_BUFF)self.graph = graph@@ -1273,7 +1273,7 @@ class WrapCosineGraphAroundCircle(FourierMachineScene):def get_winding_frequency_label(self):freq = self.initial_winding_frequencywinding_freq_label = VGroup(- DecimalNumber(freq, num_decimal_points = 2),+ DecimalNumber(freq, num_decimal_places = 2),TextMobject("cycles/second"))winding_freq_label.arrange_submobjects(RIGHT)diff --git a/old_projects/fractal_dimension.py b/old_projects/fractal_dimension.pyindex 27a053971..683f31547 100644--- a/old_projects/fractal_dimension.py+++ b/old_projects/fractal_dimension.py@@ -1805,7 +1805,7 @@ class BoxCountingScene(Scene):return labeldef count_boxes(self, boxes):- num = DecimalNumber(len(boxes), num_decimal_points = 0)+ num = DecimalNumber(len(boxes), num_decimal_places = 0)num.next_to(boxes, RIGHT)num.add_to_back(BackgroundRectangle(num))diff --git a/old_projects/nn/part1.py b/old_projects/nn/part1.pyindex b2d872fc2..cdd3618d4 100644--- a/old_projects/nn/part1.py+++ b/old_projects/nn/part1.py@@ -559,7 +559,7 @@ class WriteAProgram(Scene):rgb = square.fill_rgbnum = DecimalNumber(square.fill_rgb[0],- num_decimal_points = 1+ num_decimal_places = 1)num.set_stroke(width = 1)color = rgba_to_color(1 - (rgb + 0.2)/1.2)@@ -1113,7 +1113,7 @@ class IntroduceEachLayer(PreviewMNistNetwork):example_num = Nonefor neuron in neurons:o = neuron.get_fill_opacity()- num = DecimalNumber(o, num_decimal_points = 1)+ num = DecimalNumber(o, num_decimal_places = 1)num.scale_to_fit_width(0.7*neuron.get_width())num.move_to(neuron)if o > 0.8:diff --git a/old_projects/nn/part2.py b/old_projects/nn/part2.pyindex 114ddff92..f32e805b2 100644--- a/old_projects/nn/part2.py+++ b/old_projects/nn/part2.py@@ -962,14 +962,14 @@ class IntroduceCostFunction(PreviewLearning):terms = VGroup()term_updates = []for arrow, d1, d2 in zip(arrows, *self.decimal_groups):- term = DecimalNumber(0, num_decimal_points = 4)+ term = DecimalNumber(0, num_decimal_places = 4)term.scale_to_fit_height(d1.get_height())term.next_to(arrow, LEFT)term.num_update_func = generate_term_update_func(d1, d2)terms.add(term)term_updates.append(ChangingDecimalWithColor(term, term.num_update_func,- num_decimal_points = 4+ num_decimal_places = 4))brace.target.next_to(terms, LEFT)@@ -2780,7 +2780,7 @@ class TestPerformance(PreviewLearning):"wrong_wait_time" : 0.5,"stroke_width_exp" : 2,"decimal_kwargs" : {- "num_decimal_points" : 3,+ "num_decimal_places" : 3,}}def construct(self):diff --git a/old_projects/nn/part3.py b/old_projects/nn/part3.pyindex 5b14b69b5..ade62581e 100644--- a/old_projects/nn/part3.py+++ b/old_projects/nn/part3.py@@ -671,7 +671,7 @@ class WalkThroughTwoExample(ShowAveragingCost):decimals = VGroup()for neuron in neurons:activation = neuron.get_fill_opacity()- decimal = DecimalNumber(activation, num_decimal_points = 1)+ decimal = DecimalNumber(activation, num_decimal_places = 1)decimal.scale_to_fit_width(0.7*neuron.get_width())decimal.move_to(neuron)if activation > 0.8:@@ -748,7 +748,7 @@ class WalkThroughTwoExample(ShowAveragingCost):anims.append(ChangingDecimal(decimal,get_decimal_update(decimal.number, target),- num_decimal_points = 1+ num_decimal_places = 1))anims.append(UpdateFromFunc(self.decimals[i],@@ -1076,7 +1076,7 @@ class WalkThroughTwoExample(ShowAveragingCost):ChangingDecimal(two_decimal,lambda a : interpolate(two_activation, 1, a),- num_decimal_points = 1,+ num_decimal_places = 1,),UpdateFromFunc(two_decimal,@@ -1110,7 +1110,7 @@ class WalkThroughTwoExample(ShowAveragingCost):ChangingDecimal(two_decimal,lambda a : interpolate(1, two_activation, a),- num_decimal_points = 1,+ num_decimal_places = 1,),UpdateFromFunc(two_decimal,@@ -3613,7 +3613,7 @@ class SimplestNetworkExample(PreviewLearning):def get_neuron_activation_decimal(self, neuron):opacity = neuron.get_fill_opacity()- decimal = DecimalNumber(opacity, num_decimal_points = 2)+ decimal = DecimalNumber(opacity, num_decimal_places = 2)decimal.scale_to_fit_width(0.85*neuron.get_width())if decimal.number > 0.8:decimal.set_fill(BLACK)diff --git a/old_projects/pi_day.py b/old_projects/pi_day.pyindex ce4c2e36b..bea9b697e 100644--- a/old_projects/pi_day.py+++ b/old_projects/pi_day.py@@ -226,7 +226,7 @@ def get_circle_drawing_terms(radius = 1, positioning_func = lambda m : m.center(0.25*rotate_vector(radius.get_vector(), TAU/4)),)- decimal = DecimalNumber(0, num_decimal_points = 4, show_ellipsis = True)+ decimal = DecimalNumber(0, num_decimal_places = 4, show_ellipsis = True)decimal.scale(0.75)def reposition_decimal(decimal):vect = radius.get_vector()@@ -318,7 +318,7 @@ class PiTauDebate(PiCreatureScene):circum_line.next_to(circle, DOWN, buff = MED_LARGE_BUFF)# circum_line.to_edge(LEFT)brace = Brace(circum_line, DOWN, buff = SMALL_BUFF)- decimal = DecimalNumber(np.pi, num_decimal_points = 4, show_ellipsis = True)+ decimal = DecimalNumber(np.pi, num_decimal_places = 4, show_ellipsis = True)decimal.scale(0.75)decimal.next_to(brace, DOWN, SMALL_BUFF)diff --git a/old_projects/wallis.py b/old_projects/wallis.pyindex b2ffb1edd..707d7d941 100644--- a/old_projects/wallis.py+++ b/old_projects/wallis.py@@ -112,7 +112,7 @@ class Introduction(Scene):)get_arrow_update().update(1)decimal = DecimalNumber(- curr_product, num_decimal_points=5, show_ellipsis=True)+ curr_product, num_decimal_places=5, show_ellipsis=True)decimal.next_to(arrow, UP, SMALL_BUFF, submobject_to_align=decimal[:5])decimal_anim = ChangingDecimal(decimal,@@ -512,7 +512,7 @@ class ShowProduct(Scene):])brace = braces[0].copy()- decimal = DecimalNumber(partial_products[0], num_decimal_points=4)+ decimal = DecimalNumber(partial_products[0], num_decimal_places=4)decimal.next_to(brace, DOWN)self.add(brace, decimal, dots[0], parts[0])@@ -677,7 +677,7 @@ class ShowProduct(Scene):])brace = braces[0].copy()- decimal = DecimalNumber(partial_products_iter.next(), num_decimal_points=4)+ decimal = DecimalNumber(partial_products_iter.next(), num_decimal_places=4)decimal.next_to(brace, DOWN)self.play(*map(FadeIn, [brace, decimal, dots[0]]))@@ -894,7 +894,7 @@ class DistanceProductScene(MovingCameraScene):self.d_labels.add(d_label)return self.d_labels- def get_numeric_distance_labels(self, lines=None, num_decimal_points=3, show_ellipsis=True):+ def get_numeric_distance_labels(self, lines=None, num_decimal_places=3, show_ellipsis=True):radius = self.circle.get_width() / 2if lines is None:if not hasattr(self, "distance_lines"):@@ -904,7 +904,7 @@ class DistanceProductScene(MovingCameraScene):for line in lines:label = DecimalNumber(line.get_length() / radius,- num_decimal_points=num_decimal_points,+ num_decimal_places=num_decimal_places,show_ellipsis=show_ellipsis,include_background_rectangle=self.include_distance_labels_background_rectangle,)@@ -943,7 +943,7 @@ class DistanceProductScene(MovingCameraScene):product_decimal = DecimalNumber(self.get_distance_product(fraction),- num_decimal_points=3,+ num_decimal_places=3,show_ellipsis=True,include_background_rectangle=self.include_distance_labels_background_rectangle,)@@ -1632,7 +1632,7 @@ class FromGeometryToAlgebra(DistanceProductScene):values = map(plane.point_to_number, self.get_lh_points())complex_decimal = self.complex_decimal = DecimalNumber(values[3],- num_decimal_points=3,+ num_decimal_places=3,include_background_rectangle=True)complex_decimal.next_to(outer_arrow.get_start(), LEFT, SMALL_BUFF)@@ -2190,7 +2190,7 @@ class PlugObserverIntoPolynomial(DistanceProductScene):numeric_chord_label = DecimalNumber(np.sqrt(3),- num_decimal_points=4,+ num_decimal_places=4,include_background_rectangle=True,show_ellipsis=True,)@@ -2907,7 +2907,7 @@ class ProveLemma2(PlugObserverIntoPolynomial):product = DecimalNumber(self.num_lighthouses,- num_decimal_points=3,+ num_decimal_places=3,show_ellipsis=True)product.move_to(self.q_marks, LEFT)@@ -3235,7 +3235,7 @@ class KeeperAndSailor(DistanceProductScene, PiCreatureScene):new_keeper_dp_decimal = DecimalNumber(self.num_lighthouses,- num_decimal_points=3,+ num_decimal_places=3,)new_keeper_dp_decimal.replace(keeper_dp_decimal, dim_to_match=1)new_keeper_dp_decimal.set_color(YELLOW)