Repository: ManimCommunity/manim
File: manim/animation/speedmodifier.py (Python)

Code before:
                [condition(self.rate_func(t)) for condition in self.conditions],
                self.functions,
            )
            if self.affects_speed_updaters:
                ChangeSpeed.dt = (new_t - self.t) * self.anim.run_time
                self.t = new_t
            return new_t

        self.anim.set_rate_func(func)

        super().__init__(
            self.anim.mobject,
            rate_func=self.rate_func,
            run_time=scaled_total_time * self.anim.run_time,
            **kwargs,
        )

    def setup(self, anim):
        if type(anim) is Wait:
            anim.interpolate = types.MethodType(
                lambda self, alpha: self.rate_func(alpha), anim
            )
        return prepare_animation(anim)

    # Time taken by the animation if `run_time` is assumed to be 1
    def get_scaled_total_time(self) -> float:
        prevnode = 0
        init_speed = self.speedinfo[0]
        total_time = 0
        for node, final_speed in list(self.speedinfo.items())[1:]:
            dur = node - prevnode
            total_time += dur * self.f_inv_1(init_speed, final_speed)
            prevnode = node
            init_speed = final_speed
        return total_time

    @classmethod
    def add_updater(
        self,
        mobject: Mobject,
        update_function: Updater,
        index: int | None = None,
        call_updater: bool = False,
    ):
        parameters = get_parameters(update_function)
        if "dt" in parameters:
            mobject.add_updater(
                lambda mob, dt: update_function(
                    mob, ChangeSpeed.dt if ChangeSpeed.is_changing_dt else dt
                ),
                index=index,

Review comment (suggestion):
This should be a docstring.

```suggestion
    def get_scaled_total_time(self) -> float:
        """The time taken by the animation under the assumption that the ``run_time`` is 1."""
```

Code after:
                    self.speed_modifier(
                        (scaled_total_time * t - curr_time) / dur,
                        init_speed,
                        final_speed,
                    )
                    * dur
                    + prevnode
                )

            self.functions.append(function)

            curr_time += self.f_inv_1(init_speed, final_speed) * dur
            prevnode = node
            init_speed = final_speed

        def func(t):
            if t == 1:
                ChangeSpeed.is_changing_dt = False
            new_t = piecewise(
                self.rate_func(t),
                [condition(self.rate_func(t)) for condition in self.conditions],
                self.functions,
            )
            if self.affects_speed_updaters:
                ChangeSpeed.dt = (new_t - self.t) * self.anim.run_time
                self.t = new_t
            return new_t

        self.anim.set_rate_func(func)

        super().__init__(
            self.anim.mobject,
            rate_func=self.rate_func,
            run_time=scaled_total_time * self.anim.run_time,
            **kwargs,
        )

    def setup(self, anim):
        if type(anim) is Wait:
            anim.interpolate = types.MethodType(
                lambda self, alpha: self.rate_func(alpha), anim
            )
        return prepare_animation(anim)

    def get_scaled_total_time(self) -> float:
        """The time taken by the animation under the assumption that the ``run_time`` is 1."""
        prevnode = 0
        init_speed = self.speedinfo[0]
        total_time = 0
        for node, final_speed in list(self.speedinfo.items())[1:]:
            dur = node - prevnode