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

Code before:

import typing
from typing import Callable, Optional, Sequence

import numpy as np

from ..animation.animation import Animation
from ..animation.transform import Transform
from ..constants import OUT, PI, TAU
from ..utils.rate_functions import linear

if typing.TYPE_CHECKING:
    from ..mobject.mobject import Mobject


class Rotating(Animation):
    """A mobject revolves about a certain point.

    Examples
    --------
    .. manim:: UsingRotating

        class UsingRotating(Scene):
            def construct(self):
                self.add(Dot(ORIGIN))
                self.play(Rotating(Square(side_length=0.5).shift(UP*2), about_point=ORIGIN), run_time=5)

    """

    def __init__(
        self,
        mobject: "Mobject",
        axis: np.ndarray = OUT,
        radians: np.ndarray = TAU,
        about_point: Optional[np.ndarray] = None,
        about_edge: Optional[np.ndarray] = None,
        run_time: float = 5,
        rate_func: Callable[[float], float] = linear,
        **kwargs
    ) -> None:
        self.axis = axis
        self.radians = radians
        self.about_point = about_point
        self.about_edge = about_edge
        super().__init__(mobject, run_time=run_time, rate_func=rate_func, **kwargs)

    def interpolate_mobject(self, alpha: float) -> None:
        self.mobject.become(self.starting_mobject)
        self.mobject.rotate(
            self.rate_func(alpha) * self.radians,
            axis=self.axis,

Review comment (suggestion):
This example has a few too many characters in one line, consider running `python -m black` on a a file which has this example so that it can fit in the window:
<img width="641" alt="image" src="https://user-images.githubusercontent.com/70682032/149073998-cf1764b1-ca19-4240-83ce-244d51f7a477.png">

Code after:

__all__ = ["Rotating", "Rotate"]

import typing
from typing import Callable, Sequence

import numpy as np

from ..animation.animation import Animation
from ..animation.transform import Transform
from ..constants import OUT, PI, TAU
from ..utils.rate_functions import linear

if typing.TYPE_CHECKING:
    from ..mobject.mobject import Mobject


class Rotating(Animation):
    def __init__(
        self,
        mobject: Mobject,
        axis: np.ndarray = OUT,
        radians: np.ndarray = TAU,
        about_point: np.ndarray | None = None,
        about_edge: np.ndarray | None = None,
        run_time: float = 5,
        rate_func: Callable[[float], float] = linear,
        **kwargs,
    ) -> None:
        self.axis = axis
        self.radians = radians
        self.about_point = about_point
        self.about_edge = about_edge
        super().__init__(mobject, run_time=run_time, rate_func=rate_func, **kwargs)

    def interpolate_mobject(self, alpha: float) -> None:
        self.mobject.become(self.starting_mobject)
        self.mobject.rotate(
            self.rate_func(alpha) * self.radians,
            axis=self.axis,
            about_point=self.about_point,
            about_edge=self.about_edge,
        )


class Rotate(Transform):
    """Animation that rotates a Mobject.

    Parameters
    ----------
    mobject