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

Code before:

if typing.TYPE_CHECKING:
    from ..mobject.types.vectorized_mobject import VGroup

__all__ = ["AnimationGroup", "Succession", "LaggedStart", "LaggedStartMap"]


DEFAULT_LAGGED_START_LAG_RATIO: float = 0.05


class AnimationGroup(Animation):
    def __init__(
        self,
        *animations: Animation,
        group: typing.Union[Group, "VGroup"] = None,
        run_time: float = None,
        rate_func: typing.Callable[[float], float] = linear,
        lag_ratio: float = 0,
        **kwargs
    ) -> None:
        self.animations = [prepare_animation(anim) for anim in animations]
        self.group = group
        if self.group is None:
            self.group = Group(
                *remove_list_redundancies(
                    [anim.mobject for anim in animations if not anim.is_dummy()]
                )
            )
        super().__init__(self.group, rate_func=rate_func, lag_ratio=lag_ratio, **kwargs)
        self.run_time = run_time
        self.init_run_time()

    def get_all_mobjects(self) -> Group:
        return self.group

    def get_run_time(self) -> float:
        if super().get_run_time() is None:
            self.init_run_time()
        return super().get_run_time()

    def begin(self) -> None:
        for anim in self.animations:
            anim.begin()

    def finish(self) -> None:
        for anim in self.animations:
            anim.finish()

    def clean_up_from_scene(self, scene: Scene) -> None:
        for anim in self.animations:
            anim.clean_up_from_scene(scene)

Review comment (suggestion):
```suggestion
                    [anim.mobject for anim in self.animations if not anim.is_dummy()]
```

Code after:

if typing.TYPE_CHECKING:
    from ..mobject.types.vectorized_mobject import VGroup

__all__ = ["AnimationGroup", "Succession", "LaggedStart", "LaggedStartMap"]


DEFAULT_LAGGED_START_LAG_RATIO: float = 0.05


class AnimationGroup(Animation):
    def __init__(
        self,
        *animations: Animation,
        group: typing.Union[Group, "VGroup"] = None,
        run_time: float = None,
        rate_func: typing.Callable[[float], float] = linear,
        lag_ratio: float = 0,
        **kwargs
    ) -> None:
        self.animations = [prepare_animation(anim) for anim in animations]
        self.group = group
        if self.group is None:
            self.group = Group(
                *remove_list_redundancies(
                    [anim.mobject for anim in self.animations if not anim.is_dummy()]
                )
            )
        super().__init__(self.group, rate_func=rate_func, lag_ratio=lag_ratio, **kwargs)
        self.run_time = run_time
        self.init_run_time()

    def get_all_mobjects(self) -> Group:
        return self.group

    def get_run_time(self) -> float:
        if super().get_run_time() is None:
            self.init_run_time()
        return super().get_run_time()

    def begin(self) -> None:
        for anim in self.animations:
            anim.begin()

    def finish(self) -> None:
        for anim in self.animations:
            anim.finish()

    def clean_up_from_scene(self, scene: Scene) -> None:
        for anim in self.animations:
            anim.clean_up_from_scene(scene)