Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

[pre-commit.ci] pre-commit autoupdate (#2520)

pre-commit-ci[bot]b26137e9b626
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index be5225d4c..7294515c0 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -35,11 +35,11 @@ repos:
- id: python-check-blanket-noqa
name: Precision flake ignores
- repo: https://github.com/psf/black
- rev: 21.12b0
+ rev: 22.1.0
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
- rev: v1.12.0
+ rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
diff --git a/manim/animation/composition.py b/manim/animation/composition.py
index 15e666758..c42f75d92 100644
--- a/manim/animation/composition.py
+++ b/manim/animation/composition.py
@@ -33,7 +33,7 @@ class AnimationGroup(Animation):
run_time: float | None = None,
rate_func: Callable[[float], float] = linear,
lag_ratio: float = 0,
- **kwargs
+ **kwargs,
) -> None:
self.animations = [prepare_animation(anim) for anim in animations]
self.group = group
@@ -176,7 +176,7 @@ class LaggedStart(AnimationGroup):
self,
*animations: Animation,
lag_ratio: float = DEFAULT_LAGGED_START_LAG_RATIO,
- **kwargs
+ **kwargs,
):
super().__init__(*animations, lag_ratio=lag_ratio, **kwargs)
@@ -188,7 +188,7 @@ class LaggedStartMap(LaggedStart):
mobject: Mobject,
arg_creator: Callable[[Mobject], str] = None,
run_time: float = 2,
- **kwargs
+ **kwargs,
) -> None:
args_list = []
for submob in mobject:
diff --git a/manim/animation/fading.py b/manim/animation/fading.py
index 500e15f08..03519fd19 100644
--- a/manim/animation/fading.py
+++ b/manim/animation/fading.py
@@ -55,7 +55,7 @@ class _Fade(Transform):
shift: np.ndarray | None = None,
target_position: np.ndarray | Mobject | None = None,
scale: float = 1,
- **kwargs
+ **kwargs,
) -> None:
if not mobjects:
raise ValueError("At least one mobject must be passed.")
diff --git a/manim/animation/movement.py b/manim/animation/movement.py
index a7ce6b250..09d18f6f2 100644
--- a/manim/animation/movement.py
+++ b/manim/animation/movement.py
@@ -28,7 +28,7 @@ class Homotopy(Animation):
mobject: Mobject,
run_time: float = 3,
apply_function_kwargs: dict[str, Any] | None = None,
- **kwargs
+ **kwargs,
) -> None:
"""
Homotopy is a function from
@@ -94,7 +94,7 @@ class PhaseFlow(Animation):
virtual_time: float = 1,
suspend_mobject_updating: bool = False,
rate_func: Callable[[float], float] = linear,
- **kwargs
+ **kwargs,
) -> None:
self.virtual_time = virtual_time
self.function = function
@@ -102,7 +102,7 @@ class PhaseFlow(Animation):
mobject,
suspend_mobject_updating=suspend_mobject_updating,
rate_func=rate_func,
- **kwargs
+ **kwargs,
)
def interpolate_mobject(self, alpha: float) -> None:
@@ -135,7 +135,7 @@ class MoveAlongPath(Animation):
mobject: Mobject,
path: VMobject,
suspend_mobject_updating: bool | None = False,
- **kwargs
+ **kwargs,
) -> None:
self.path = path
super().__init__(
diff --git a/manim/animation/rotation.py b/manim/animation/rotation.py
index a5e2fc62a..da2bd391b 100644
--- a/manim/animation/rotation.py
+++ b/manim/animation/rotation.py
@@ -28,7 +28,7 @@ class Rotating(Animation):
about_edge: np.ndarray | None = None,
run_time: float = 5,
rate_func: Callable[[float], float] = linear,
- **kwargs
+ **kwargs,
) -> None:
self.axis = axis
self.radians = radians
@@ -54,7 +54,7 @@ class Rotate(Transform):
axis: np.ndarray = OUT,
about_point: Sequence[float] | None = None,
about_edge: Sequence[float] | None = None,
- **kwargs
+ **kwargs,
) -> None:
if "path_arc" not in kwargs:
kwargs["path_arc"] = angle
diff --git a/manim/animation/specialized.py b/manim/animation/specialized.py
index 7f8ce5973..2c9ed5c61 100644
--- a/manim/animation/specialized.py
+++ b/manim/animation/specialized.py
@@ -58,7 +58,7 @@ class Broadcast(LaggedStart):
remover: bool = True,
lag_ratio: float = 0.2,
run_time: float = 3,
- **kwargs: Any
+ **kwargs: Any,
):
self.focal_point = focal_point
self.n_mobs = n_mobs
diff --git a/manim/animation/transform_matching_parts.py b/manim/animation/transform_matching_parts.py
index 5f6387226..c289d28ef 100644
--- a/manim/animation/transform_matching_parts.py
+++ b/manim/animation/transform_matching_parts.py
@@ -72,7 +72,7 @@ class TransformMatchingAbstractBase(AnimationGroup):
transform_mismatches: bool = False,
fade_transform_mismatches: bool = False,
key_map: dict | None = None,
- **kwargs
+ **kwargs,
):
if isinstance(mobject, OpenGLVMobject):
@@ -203,7 +203,7 @@ class TransformMatchingShapes(TransformMatchingAbstractBase):
transform_mismatches: bool = False,
fade_transform_mismatches: bool = False,
key_map: dict | None = None,
- **kwargs
+ **kwargs,
):
super().__init__(
mobject,
@@ -211,7 +211,7 @@ class TransformMatchingShapes(TransformMatchingAbstractBase):
transform_mismatches=transform_mismatches,
fade_transform_mismatches=fade_transform_mismatches,
key_map=key_map,
- **kwargs
+ **kwargs,
)
@staticmethod
@@ -260,7 +260,7 @@ class TransformMatchingTex(TransformMatchingAbstractBase):
transform_mismatches: bool = False,
fade_transform_mismatches: bool = False,
key_map: dict | None = None,
- **kwargs
+ **kwargs,
):
assert hasattr(mobject, "tex_string")
assert hasattr(target_mobject, "tex_string")
@@ -270,7 +270,7 @@ class TransformMatchingTex(TransformMatchingAbstractBase):
transform_mismatches=transform_mismatches,
fade_transform_mismatches=fade_transform_mismatches,
key_map=key_map,
- **kwargs
+ **kwargs,
)
@staticmethod
diff --git a/manim/animation/update.py b/manim/animation/update.py
index 11d6dc3c3..268d1fa05 100644
--- a/manim/animation/update.py
+++ b/manim/animation/update.py
@@ -26,7 +26,7 @@ class UpdateFromFunc(Animation):
mobject: Mobject,
update_function: typing.Callable[[Mobject], typing.Any],
suspend_mobject_updating: bool = False,
- **kwargs
+ **kwargs,
) -> None:
self.update_function = update_function
super().__init__(
diff --git a/manim/camera/mapping_camera.py b/manim/camera/mapping_camera.py
index 86bf835cb..34561c3d9 100644
--- a/manim/camera/mapping_camera.py
+++ b/manim/camera/mapping_camera.py
@@ -26,7 +26,7 @@ class MappingCamera(Camera):
mapping_func=lambda p: p,
min_num_curves=50,
allow_object_intrusion=False,
- **kwargs
+ **kwargs,
):
self.mapping_func = mapping_func
self.min_num_curves = min_num_curves
diff --git a/manim/camera/moving_camera.py b/manim/camera/moving_camera.py
index 2df9f31fc..c0c2ad3d2 100644
--- a/manim/camera/moving_camera.py
+++ b/manim/camera/moving_camera.py
@@ -42,7 +42,7 @@ class MovingCamera(Camera):
fixed_dimension=0, # width
default_frame_stroke_color=WHITE,
default_frame_stroke_width=0,
- **kwargs
+ **kwargs,
):
"""
Frame is a Mobject, (should almost certainly be a rectangle)
diff --git a/manim/camera/multi_camera.py b/manim/camera/multi_camera.py
index 87b747296..a9eb74969 100644
--- a/manim/camera/multi_camera.py
+++ b/manim/camera/multi_camera.py
@@ -16,7 +16,7 @@ class MultiCamera(MovingCamera):
self,
image_mobjects_from_cameras=None,
allow_cameras_to_capture_their_own_display=False,
- **kwargs
+ **kwargs,
):
"""Initialises the MultiCamera
diff --git a/manim/camera/three_d_camera.py b/manim/camera/three_d_camera.py
index 5a60c1a5a..a15ca07f4 100644
--- a/manim/camera/three_d_camera.py
+++ b/manim/camera/three_d_camera.py
@@ -36,7 +36,7 @@ class ThreeDCamera(Camera):
theta=-90 * DEGREES,
gamma=0,
zoom=1,
- **kwargs
+ **kwargs,
):
"""Initializes the ThreeDCamera
@@ -316,7 +316,7 @@ class ThreeDCamera(Camera):
factor[lt0] = focal_distance / (focal_distance - zs[lt0])
else:
factor = focal_distance / (focal_distance - zs)
- factor[(focal_distance - zs) < 0] = 10 ** 6
+ factor[(focal_distance - zs) < 0] = 10**6
points[:, i] *= factor * zoom
return points
diff --git a/manim/mobject/changing.py b/manim/mobject/changing.py
index 9585738d3..b5bb17215 100644
--- a/manim/mobject/changing.py
+++ b/manim/mobject/changing.py
@@ -41,7 +41,7 @@ class AnimatedBoundary(VGroup):
back_and_forth=True,
draw_rate_func=smooth,
fade_rate_func=smooth,
- **kwargs
+ **kwargs,
):
super().__init__(**kwargs)
self.colors = colors
@@ -142,7 +142,7 @@ class TracedPath(VMobject, metaclass=ConvertToOpenGL):
stroke_width: float = 2,
stroke_color: Color = WHITE,
dissipating_time: float | None = None,
- **kwargs
+ **kwargs,
):
super().__init__(stroke_color=stroke_color, stroke_width=stroke_width, **kwargs)
self.traced_point_func = traced_point_func
diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.py
index f0a4a408b..ef0f4d5dc 100644
--- a/manim/mobject/coordinate_systems.py
+++ b/manim/mobject/coordinate_systems.py
@@ -200,7 +200,7 @@ class CoordinateSystem:
The coordinate radius (:math:`r`) and the coordinate azimuth (:math:`\theta`).
"""
x, y = self.point_to_coords(point)
- return np.sqrt(x ** 2 + y ** 2), np.arctan2(y, x)
+ return np.sqrt(x**2 + y**2), np.arctan2(y, x)
def c2p(self, *coords):
"""Abbreviation for coords_to_point"""
diff --git a/manim/mobject/functions.py b/manim/mobject/functions.py
index e6fda64b3..afc21d327 100644
--- a/manim/mobject/functions.py
+++ b/manim/mobject/functions.py
@@ -99,7 +99,7 @@ class ParametricFunction(VMobject, metaclass=ConvertToOpenGL):
dt: float = 1e-8,
discontinuities: Iterable[float] | None = None,
use_smoothing: bool = True,
- **kwargs
+ **kwargs,
):
self.function = function
t_range = [0, 1, 0.01] if t_range is None else t_range
@@ -211,7 +211,7 @@ class ImplicitFunction(VMobject, metaclass=ConvertToOpenGL):
min_depth: int = 5,
max_quads: int = 1500,
use_smoothing: bool = True,
- **kwargs
+ **kwargs,
):
"""An implicit function.
diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py
index 4231e082c..bc5d9b0cd 100644
--- a/manim/mobject/geometry.py
+++ b/manim/mobject/geometry.py
@@ -449,7 +449,7 @@ class ArcBetweenPoints(Arc):
"""ArcBetweenPoints called with a radius that is
smaller than half the distance between the points.""",
)
- arc_height = radius - math.sqrt(radius ** 2 - halfdist ** 2)
+ arc_height = radius - math.sqrt(radius**2 - halfdist**2)
angle = math.acos((radius - arc_height) / radius) * sign
super().__init__(radius=radius, angle=angle, **kwargs)
@@ -566,7 +566,7 @@ class Circle(Arc):
# TODO: Figure out and fix
self.replace(mobject, dim_to_match, stretch)
- self.width = np.sqrt(mobject.width ** 2 + mobject.height ** 2)
+ self.width = np.sqrt(mobject.width**2 + mobject.height**2)
return self.scale(buffer_factor)
def point_at_angle(self, angle):
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py
index c450b6da5..5c42cdd34 100644
--- a/manim/mobject/mobject.py
+++ b/manim/mobject/mobject.py
@@ -1282,7 +1282,7 @@ class Mobject:
alphas = np.dot(mob.points, np.transpose(axis))
alphas -= min(alphas)
alphas /= max(alphas)
- alphas = alphas ** wag_factor
+ alphas = alphas**wag_factor
mob.points += np.dot(
alphas.reshape((len(alphas), 1)),
np.array(direction).reshape((1, mob.dim)),
@@ -1944,14 +1944,11 @@ class Mobject:
def length_over_dim(self, dim):
"""Measure the length of an :class:`~.Mobject` in a certain direction."""
- return (
- self.reduce_across_dimension(
- np.max,
- np.max,
- dim,
- )
- - self.reduce_across_dimension(np.min, np.min, dim)
- )
+ return self.reduce_across_dimension(
+ np.max,
+ np.max,
+ dim,
+ ) - self.reduce_across_dimension(np.min, np.min, dim)
def get_coord(self, dim, direction=ORIGIN):
"""Meant to generalize ``get_x``, ``get_y`` and ``get_z``"""
diff --git a/manim/mobject/numbers.py b/manim/mobject/numbers.py
index ec1d005cb..183b25152 100644
--- a/manim/mobject/numbers.py
+++ b/manim/mobject/numbers.py
@@ -63,7 +63,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
font_size: float = DEFAULT_FONT_SIZE,
stroke_width: float = 0,
fill_opacity: float = 1.0,
- **kwargs
+ **kwargs,
):
super().__init__(**kwargs)
self.number = number
diff --git a/manim/mobject/opengl_geometry.py b/manim/mobject/opengl_geometry.py
index b0cb4e5e4..ffbc045e0 100644
--- a/manim/mobject/opengl_geometry.py
+++ b/manim/mobject/opengl_geometry.py
@@ -55,7 +55,7 @@ class OpenGLTipableVMobject(OpenGLVMobject):
tip_length=DEFAULT_ARROW_TIP_LENGTH,
normal_vector=OUT,
tip_config={},
- **kwargs
+ **kwargs,
):
self.tip_length = tip_length
self.normal_vector = normal_vector
@@ -203,7 +203,7 @@ class OpenGLArc(OpenGLTipableVMobject):
radius=1.0,
n_components=8,
arc_center=ORIGIN,
- **kwargs
+ **kwargs,
):
self.start_angle = start_angle
self.angle = angle
@@ -319,7 +319,7 @@ class OpenGLDot(OpenGLCircle):
stroke_width=0,
fill_opacity=1.0,
color=WHITE,
- **kwargs
+ **kwargs,
):
super().__init__(
arc_center=point,
@@ -327,7 +327,7 @@ class OpenGLDot(OpenGLCircle):
stroke_width=stroke_width,
fill_opacity=fill_opacity,
color=color,
- **kwargs
+ **kwargs,
)
@@ -348,7 +348,7 @@ class OpenGLAnnularSector(OpenGLArc):
fill_opacity=1,
stroke_width=0,
color=WHITE,
- **kwargs
+ **kwargs,
):
self.inner_radius = inner_radius
self.outer_radius = outer_radius
@@ -358,7 +358,7 @@ class OpenGLAnnularSector(OpenGLArc):
fill_opacity=fill_opacity,
stroke_width=stroke_width,
color=color,
- **kwargs
+ **kwargs,
)
def init_points(self):
@@ -392,7 +392,7 @@ class OpenGLAnnulus(OpenGLCircle):
stroke_width=0,
color=WHITE,
mark_paths_closed=False,
- **kwargs
+ **kwargs,
):
self.mark_paths_closed = mark_paths_closed # is this even used?
self.inner_radius = inner_radius
@@ -594,7 +594,7 @@ class OpenGLArrow(OpenGLLine):
tip_angle=PI / 3,
max_tip_length_to_length_ratio=0.5,
max_width_to_length_ratio=0.1,
- **kwargs
+ **kwargs,
):
self.thickness = thickness
self.tip_width_ratio = tip_width_ratio
@@ -609,7 +609,7 @@ class OpenGLArrow(OpenGLLine):
fill_color=fill_color,
fill_opacity=fill_opacity,
stroke_width=stroke_width,
- **kwargs
+ **kwargs,
)
def set_points_by_ends(self, start, end, buff=0, path_arc=0):
@@ -637,8 +637,8 @@ class OpenGLArrow(OpenGLLine):
# Solve for radius so that the tip-to-tail length matches |end - start|
a = 2 * (1 - np.cos(path_arc))
b = -2 * tip_length * np.sin(path_arc)
- c = tip_length ** 2 - length ** 2
- R = (-b + np.sqrt(b ** 2 - 4 * a * c)) / (2 * a)
+ c = tip_length**2 - length**2
+ R = (-b + np.sqrt(b**2 - 4 * a * c)) / (2 * a)
# Find arc points
points1 = OpenGLArc.create_quadratic_bezier_points(path_arc)
@@ -806,14 +806,14 @@ class OpenGLArrowTip(OpenGLTriangle):
width=DEFAULT_ARROW_TIP_WIDTH,
length=DEFAULT_ARROW_TIP_LENGTH,
angle=0,
- **kwargs
+ **kwargs,
):
super().__init__(
start_angle=0,
fill_opacity=fill_opacity,
fill_color=fill_color,
stroke_width=stroke_width,
- **kwargs
+ **kwargs,
)
self.set_width(width, stretch=True)
self.set_height(length, stretch=True)
diff --git a/manim/mobject/opengl_mobject.py b/manim/mobject/opengl_mobject.py
index 7e67aa4de..2757b857d 100644
--- a/manim/mobject/opengl_mobject.py
+++ b/manim/mobject/opengl_mobject.py
@@ -1575,7 +1575,7 @@ class OpenGLMobject:
alphas = np.dot(mob.points, np.transpose(axis))
alphas -= min(alphas)
alphas /= max(alphas)
- alphas = alphas ** wag_factor
+ alphas = alphas**wag_factor
mob.set_points(
mob.points
+ np.dot(
diff --git a/manim/mobject/opengl_three_dimensions.py b/manim/mobject/opengl_three_dimensions.py
index a469358f1..b7c081a12 100644
--- a/manim/mobject/opengl_three_dimensions.py
+++ b/manim/mobject/opengl_three_dimensions.py
@@ -15,7 +15,7 @@ class OpenGLSurfaceMesh(OpenGLVGroup):
normal_nudge=1e-2,
depth_test=True,
flat_stroke=False,
- **kwargs
+ **kwargs,
):
if not isinstance(uv_surface, OpenGLSurface):
raise Exception("uv_surface must be of type OpenGLSurface")
@@ -26,7 +26,7 @@ class OpenGLSurfaceMesh(OpenGLVGroup):
stroke_width=stroke_width,
depth_test=depth_test,
flat_stroke=flat_stroke,
- **kwargs
+ **kwargs,
)
def init_points(self):
diff --git a/manim/mobject/polyhedra.py b/manim/mobject/polyhedra.py
index db0409df9..678318165 100644
--- a/manim/mobject/polyhedra.py
+++ b/manim/mobject/polyhedra.py
@@ -103,7 +103,7 @@ class Polyhedron(VGroup):
"stroke_opacity": 0, # I find that having the edges visible makes the polyhedra look weird
},
},
- **graph_config
+ **graph_config,
)
self.vertex_coords = vertex_coords
self.vertex_indices = list(range(len(self.vertex_coords)))
@@ -182,7 +182,7 @@ class Tetrahedron(Polyhedron):
np.array([-unit, -unit, unit]),
],
faces_list=[[0, 1, 2], [3, 0, 2], [0, 1, 3], [3, 1, 2]],
- **kwargs
+ **kwargs,
)
@@ -228,7 +228,7 @@ class Octahedron(Polyhedron):
[2, 5, 1],
[0, 5, 2],
],
- **kwargs
+ **kwargs,
)
@@ -293,7 +293,7 @@ class Icosahedron(Polyhedron):
[10, 11, 7],
[10, 11, 6],
],
- **kwargs
+ **kwargs,
)
@@ -359,5 +359,5 @@ class Dodecahedron(Polyhedron):
[19, 5, 9, 10, 7],
[7, 10, 3, 14, 15],
],
- **kwargs
+ **kwargs,
)
diff --git a/manim/mobject/shape_matchers.py b/manim/mobject/shape_matchers.py
index 996ea673a..cf5b398e1 100644
--- a/manim/mobject/shape_matchers.py
+++ b/manim/mobject/shape_matchers.py
@@ -48,7 +48,7 @@ class SurroundingRectangle(RoundedRectangle):
width=mobject.width + 2 * buff,
height=mobject.height + 2 * buff,
corner_radius=corner_radius,
- **kwargs
+ **kwargs,
)
self.buff = buff
self.move_to(mobject)
@@ -88,7 +88,7 @@ class BackgroundRectangle(SurroundingRectangle):
stroke_opacity: float = 0,
fill_opacity: float = 0.75,
buff: float = 0,
- **kwargs
+ **kwargs,
):
if color is None:
color = config.background_color
@@ -100,7 +100,7 @@ class BackgroundRectangle(SurroundingRectangle):
stroke_opacity=stroke_opacity,
fill_opacity=fill_opacity,
buff=buff,
- **kwargs
+ **kwargs,
)
self.original_fill_opacity = self.fill_opacity
@@ -160,7 +160,7 @@ class Cross(VGroup):
stroke_color: Color = RED,
stroke_width: float = 6,
scale_factor: float = 1,
- **kwargs
+ **kwargs,
):
super().__init__(
Line(UP + LEFT, DOWN + RIGHT), Line(UP + RIGHT, DOWN + LEFT), **kwargs
diff --git a/manim/mobject/svg/brace.py b/manim/mobject/svg/brace.py
index 133b9b62b..8c2ba4f41 100644
--- a/manim/mobject/svg/brace.py
+++ b/manim/mobject/svg/brace.py
@@ -67,7 +67,7 @@ class Brace(SVGPathMobject):
fill_opacity=1.0,
background_stroke_width=0,
background_stroke_color=BLACK,
- **kwargs
+ **kwargs,
):
path_string_template = (
"m0.01216 0c-0.01152 0-0.01216 6.103e-4 -0.01216 0.01311v0.007762c0.06776 "
@@ -109,7 +109,7 @@ class Brace(SVGPathMobject):
fill_opacity=fill_opacity,
background_stroke_width=background_stroke_width,
background_stroke_color=background_stroke_color,
- **kwargs
+ **kwargs,
)
self.stretch_to_fit_width(target_width)
self.shift(left - self.get_corner(UP + LEFT) + self.buff * DOWN)
@@ -158,7 +158,7 @@ class BraceLabel(VMobject, metaclass=ConvertToOpenGL):
label_constructor=MathTex,
font_size=DEFAULT_FONT_SIZE,
buff=0.2,
- **kwargs
+ **kwargs,
):
self.label_constructor = label_constructor
super().__init__(**kwargs)
@@ -241,7 +241,7 @@ class BraceBetweenPoints(Brace):
point_1: Sequence[float] | None,
point_2: Sequence[float] | None,
direction: Sequence[float] | None = ORIGIN,
- **kwargs
+ **kwargs,
):
if all(direction == ORIGIN):
line_vector = np.array(point_2) - np.array(point_1)
@@ -308,7 +308,7 @@ class ArcBrace(Brace):
self,
arc: Arc = Arc(start_angle=-1, angle=2, radius=1),
direction: Sequence[float] = RIGHT,
- **kwargs
+ **kwargs,
):
arc_end_angle = arc.start_angle + arc.angle
line = Line(UP * arc.start_angle, UP * arc_end_angle)
diff --git a/manim/mobject/three_dimensions.py b/manim/mobject/three_dimensions.py
index 8cbfb8c05..b8ffb4ad1 100644
--- a/manim/mobject/three_dimensions.py
+++ b/manim/mobject/three_dimensions.py
@@ -92,7 +92,7 @@ class Surface(VGroup, metaclass=ConvertToOpenGL):
stroke_width: float = 0.5,
should_make_jagged: bool = False,
pre_function_handle_to_anchor_scale_factor: float = 0.00001,
- **kwargs
+ **kwargs,
) -> None:
self.u_range = u_range
self.v_range = v_range
@@ -304,7 +304,7 @@ class Sphere(Surface):
resolution=None,
u_range=(0, TAU),
v_range=(0, PI),
- **kwargs
+ **kwargs,
):
if config.renderer == "opengl":
res_value = (101, 51)
@@ -366,7 +366,7 @@ class Dot3D(Sphere):
radius=DEFAULT_DOT_RADIUS,
color=WHITE,
resolution=(8, 8),
- **kwargs
+ **kwargs,
):
super().__init__(center=point, radius=radius, resolution=resolution, **kwargs)
self.set_color(color)
@@ -379,7 +379,7 @@ class Cube(VGroup):
fill_opacity=0.75,
fill_color=BLUE,
stroke_width=0,
- **kwargs
+ **kwargs,
):
self.side_length = side_length
super().__init__(
@@ -477,7 +477,7 @@ class Cone(Surface):
v_range=[0, TAU],
u_min=0,
checkerboard_colors=False,
- **kwargs
+ **kwargs,
):
self.direction = direction
self.theta = PI - np.arctan(base_radius / height)
@@ -485,7 +485,7 @@ class Cone(Surface):
super().__init__(
self.func,
v_range=v_range,
- u_range=[u_min, np.sqrt(base_radius ** 2 + height ** 2)],
+ u_range=[u_min, np.sqrt(base_radius**2 + height**2)],
checkerboard_colors=checkerboard_colors,
**kwargs,
)
@@ -527,7 +527,7 @@ class Cone(Surface):
def _rotate_to_direction(self):
x, y, z = self.direction
- r = np.sqrt(x ** 2 + y ** 2 + z ** 2)
+ r = np.sqrt(x**2 + y**2 + z**2)
if r > 0:
theta = np.arccos(z / r)
else:
@@ -602,7 +602,7 @@ class Cylinder(Surface):
v_range=[0, TAU],
show_ends=True,
resolution=(24, 24),
- **kwargs
+ **kwargs,
):
self._height = height
self.radius = radius
@@ -658,7 +658,7 @@ class Cylinder(Surface):
def _rotate_to_direction(self):
x, y, z = self.direction
- r = np.sqrt(x ** 2 + y ** 2 + z ** 2)
+ r = np.sqrt(x**2 + y**2 + z**2)
if r > 0:
theta = np.arccos(z / r)
else:
@@ -885,7 +885,7 @@ class Arrow3D(Line3D):
height=0.3,
base_radius=0.08,
color=WHITE,
- **kwargs
+ **kwargs,
):
super().__init__(
start=start, end=end, thickness=thickness, color=color, **kwargs
@@ -936,7 +936,7 @@ class Torus(Surface):
u_range=(0, TAU),
v_range=(0, TAU),
resolution=None,
- **kwargs
+ **kwargs,
):
if config.renderer == "opengl":
res_value = (101, 101)
diff --git a/manim/mobject/types/opengl_surface.py b/manim/mobject/types/opengl_surface.py
index 2a69776ac..7834bbcdf 100644
--- a/manim/mobject/types/opengl_surface.py
+++ b/manim/mobject/types/opengl_surface.py
@@ -42,7 +42,7 @@ class OpenGLSurface(OpenGLMobject):
render_primitive=moderngl.TRIANGLES,
depth_test=True,
shader_folder=None,
- **kwargs
+ **kwargs,
):
self.passed_uv_func = uv_func
self.u_range = u_range if u_range is not None else (0, 1)
@@ -64,7 +64,7 @@ class OpenGLSurface(OpenGLMobject):
shader_folder=shader_folder if shader_folder is not None else "surface",
render_primitive=render_primitive,
depth_test=depth_test,
- **kwargs
+ **kwargs,
)
self.compute_triangle_indices()
diff --git a/manim/mobject/types/point_cloud_mobject.py b/manim/mobject/types/point_cloud_mobject.py
index f53f78d99..bd418e8a5 100644
--- a/manim/mobject/types/point_cloud_mobject.py
+++ b/manim/mobject/types/point_cloud_mobject.py
@@ -313,7 +313,7 @@ class PointCloudDot(Mobject1D):
stroke_width=2,
density=DEFAULT_POINT_DENSITY_1D,
color=YELLOW,
- **kwargs
+ **kwargs,
):
self.radius = radius
self.epsilon = 1.0 / density
diff --git a/manim/mobject/vector_field.py b/manim/mobject/vector_field.py
index 0d0f4cea6..726594a20 100644
--- a/manim/mobject/vector_field.py
+++ b/manim/mobject/vector_field.py
@@ -69,7 +69,7 @@ class VectorField(VGroup):
min_color_scheme_value: float = 0,
max_color_scheme_value: float = 2,
colors: Sequence[Color] = DEFAULT_SCALAR_FIELD_COLORS,
- **kwargs
+ **kwargs,
):
super().__init__(**kwargs)
self.func = func
@@ -529,7 +529,7 @@ class ArrowVectorField(VectorField):
length_func: Callable[[float], float] = lambda norm: 0.45 * sigmoid(norm),
opacity: float = 1.0,
vector_config: dict | None = None,
- **kwargs
+ **kwargs,
):
self.x_range = x_range or [
floor(-config["frame_width"] / 2),
@@ -707,7 +707,7 @@ class StreamLines(VectorField):
# Determining stream line appearance:
stroke_width=1,
opacity=1,
- **kwargs
+ **kwargs,
):
self.x_range = x_range or [
floor(-config["frame_width"] / 2),
@@ -831,7 +831,7 @@ class StreamLines(VectorField):
self,
lag_ratio: float | None = None,
run_time: Callable[[float], float] | None = None,
- **kwargs
+ **kwargs,
) -> AnimationGroup:
"""The creation animation of the stream lines.
@@ -890,7 +890,7 @@ class StreamLines(VectorField):
time_width: float = 0.3,
rate_func: Callable[[float], float] = linear,
line_animation_class: type[ShowPassingFlash] = ShowPassingFlash,
- **kwargs
+ **kwargs,
) -> None:
"""Animates the stream lines using an updater.
diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py
index c74f79c8b..789e56ef1 100644
--- a/manim/scene/vector_space_scene.py
+++ b/manim/scene/vector_space_scene.py
@@ -569,7 +569,7 @@ class LinearTransformationScene(VectorScene):
i_hat_color: Color = X_COLOR,
j_hat_color: Color = Y_COLOR,
leave_ghost_vectors: bool = False,
- **kwargs
+ **kwargs,
):
super().__init__(**kwargs)
diff --git a/manim/scene/zoomed_scene.py b/manim/scene/zoomed_scene.py
index 573c089ff..06bc2213e 100644
--- a/manim/scene/zoomed_scene.py
+++ b/manim/scene/zoomed_scene.py
@@ -85,7 +85,7 @@ class ZoomedScene(MovingCameraScene):
zoom_factor=0.15,
image_frame_stroke_width=3,
zoom_activated=False,
- **kwargs
+ **kwargs,
):
self.zoomed_display_height = zoomed_display_height
self.zoomed_display_width = zoomed_display_width
diff --git a/manim/utils/bezier.py b/manim/utils/bezier.py
index bb891fafd..d96b6af62 100644
--- a/manim/utils/bezier.py
+++ b/manim/utils/bezier.py
@@ -47,7 +47,7 @@ def bezier(
"""
n = len(points) - 1
return lambda t: sum(
- ((1 - t) ** (n - k)) * (t ** k) * choose(n, k) * point
+ ((1 - t) ** (n - k)) * (t**k) * choose(n, k) * point
for k, point in enumerate(points)
)
diff --git a/manim/utils/debug.py b/manim/utils/debug.py
index 0a1eca7c6..9a193dfb8 100644
--- a/manim/utils/debug.py
+++ b/manim/utils/debug.py
@@ -27,7 +27,7 @@ def index_labels(
label_height: float = 0.15,
background_stroke_width=5,
background_stroke_color=BLACK,
- **kwargs
+ **kwargs,
):
r"""Returns a :class:`~.VGroup` of :class:`~.Integer` mobjects
that shows the index of each submobject.
diff --git a/manim/utils/hashing.py b/manim/utils/hashing.py
index 6e015660f..f84f2770d 100644
--- a/manim/utils/hashing.py
+++ b/manim/utils/hashing.py
@@ -110,18 +110,15 @@ class _Memoizer:
obj,
default_function: typing.Callable[[Any], Any],
):
- if (
- isinstance(
- obj,
- (
- int,
- float,
- str,
- complex,
- ),
- )
- and obj not in [None, cls.ALREADY_PROCESSED_PLACEHOLDER]
- ):
+ if isinstance(
+ obj,
+ (
+ int,
+ float,
+ str,
+ complex,
+ ),
+ ) and obj not in [None, cls.ALREADY_PROCESSED_PLACEHOLDER]:
# It makes no sense (and it'd slower) to memoize objects of these primitive
# types. Hence, we simply return the object.
return obj
diff --git a/manim/utils/scale.py b/manim/utils/scale.py
index 9470b33a4..1b9ac384c 100644
--- a/manim/utils/scale.py
+++ b/manim/utils/scale.py
@@ -138,7 +138,7 @@ class LogBase(_ScaleBase):
def function(self, value: float) -> float:
"""Scales the value to fit it to a logarithmic scale.``self.function(5)==10**5``"""
- return self.base ** value
+ return self.base**value
def inverse_function(self, value: float) -> float:
"""Inverse of ``function``. The value must be greater than 0"""
diff --git a/tests/test_auto_zoom.py b/tests/test_auto_zoom.py
index 115e46a51..ad5da943b 100644
--- a/tests/test_auto_zoom.py
+++ b/tests/test_auto_zoom.py
@@ -15,11 +15,8 @@ def test_zoom():
scene.add(s1, s2)
scene.play(scene.camera.auto_zoom([s1, s2]))
- assert (
- scene.camera.frame_width
- == abs(
- s1.get_left()[0] - s2.get_right()[0],
- )
- and scene.camera.frame.get_center()[0]
- == (abs(s1.get_center()[0] + s2.get_center()[0]) / 2)
+ assert scene.camera.frame_width == abs(
+ s1.get_left()[0] - s2.get_right()[0],
+ ) and scene.camera.frame.get_center()[0] == (
+ abs(s1.get_center()[0] + s2.get_center()[0]) / 2
)
diff --git a/tests/test_axes_shift.py b/tests/test_axes_shift.py
index 803a7c8ea..1d826c7c0 100644
--- a/tests/test_axes_shift.py
+++ b/tests/test_axes_shift.py
@@ -20,10 +20,10 @@ def test_axes_origin_shift_logbase():
y_axis_config={"scaling": LogBase()},
)
assert np.allclose(
- ax.coords_to_point(10 ** 5, 10 ** 3), ax.x_axis.number_to_point(10 ** 5)
+ ax.coords_to_point(10**5, 10**3), ax.x_axis.number_to_point(10**5)
)
assert np.allclose(
- ax.coords_to_point(10 ** 5, 10 ** 3), ax.y_axis.number_to_point(10 ** 3)
+ ax.coords_to_point(10**5, 10**3), ax.y_axis.number_to_point(10**3)
)
@@ -44,14 +44,14 @@ def test_3daxes_origin_shift_logbase():
z_axis_config={"scaling": LogBase()},
)
assert np.allclose(
- ax.coords_to_point(10 ** 3, 10 ** 6, 10 ** 2),
- ax.x_axis.number_to_point(10 ** 3),
+ ax.coords_to_point(10**3, 10**6, 10**2),
+ ax.x_axis.number_to_point(10**3),
)
assert np.allclose(
- ax.coords_to_point(10 ** 3, 10 ** 6, 10 ** 2),
- ax.y_axis.number_to_point(10 ** 6),
+ ax.coords_to_point(10**3, 10**6, 10**2),
+ ax.y_axis.number_to_point(10**6),
)
assert np.allclose(
- ax.coords_to_point(10 ** 3, 10 ** 6, 10 ** 2),
- ax.z_axis.number_to_point(10 ** 2),
+ ax.coords_to_point(10**3, 10**6, 10**2),
+ ax.z_axis.number_to_point(10**2),
)
diff --git a/tests/test_graphical_units/test_axes.py b/tests/test_graphical_units/test_axes.py
index 8c6442620..0683a4682 100644
--- a/tests/test_graphical_units/test_axes.py
+++ b/tests/test_graphical_units/test_axes.py
@@ -22,7 +22,7 @@ def test_axes(scene):
@frames_comparison
def test_plot_functions(scene):
ax = Axes(x_range=(-10, 10.3), y_range=(-1.5, 1.5))
- graph = ax.plot(lambda x: x ** 2)
+ graph = ax.plot(lambda x: x**2)
scene.add(ax, graph)
@@ -71,7 +71,7 @@ def test_get_y_axis_label(scene):
def test_plot_derivative_graph(scene):
ax = NumberPlane(y_range=[-1, 7], background_line_style={"stroke_opacity": 0.4})
- curve_1 = ax.plot(lambda x: x ** 2, color=PURPLE_B)
+ curve_1 = ax.plot(lambda x: x**2, color=PURPLE_B)
curve_2 = ax.plot_derivative_graph(curve_1)
curve_3 = ax.plot_antiderivative_graph(curve_1)
curves = VGroup(curve_1, curve_2, curve_3)
@@ -216,7 +216,7 @@ def test_get_area_with_boundary_and_few_plot_points(scene):
@frames_comparison
def test_get_riemann_rectangles(scene):
ax = Axes(y_range=[-2, 10])
- quadratic = ax.plot(lambda x: 0.5 * x ** 2 - 0.5)
+ quadratic = ax.plot(lambda x: 0.5 * x**2 - 0.5)
# the rectangles are constructed from their top right corner.
# passing an iterable to `color` produces a gradient
diff --git a/tests/test_graphical_units/test_coordinate_systems.py b/tests/test_graphical_units/test_coordinate_systems.py
index 1e619386c..685ffe1e1 100644
--- a/tests/test_graphical_units/test_coordinate_systems.py
+++ b/tests/test_graphical_units/test_coordinate_systems.py
@@ -40,7 +40,7 @@ def test_line_graph(scene):
@frames_comparison
def test_implicit_graph(scene):
ax = Axes()
- graph = ax.plot_implicit_curve(lambda x, y: x ** 2 + y ** 2 - 4)
+ graph = ax.plot_implicit_curve(lambda x, y: x**2 + y**2 - 4)
scene.add(ax, graph)
diff --git a/tests/test_graphical_units/test_functions.py b/tests/test_graphical_units/test_functions.py
index 7a7b39bea..8c140a285 100644
--- a/tests/test_graphical_units/test_functions.py
+++ b/tests/test_graphical_units/test_functions.py
@@ -14,5 +14,5 @@ def test_FunctionGraph(scene):
@frames_comparison
def test_ImplicitFunction(scene):
- graph = ImplicitFunction(lambda x, y: x ** 2 + y ** 2 - 9)
+ graph = ImplicitFunction(lambda x, y: x**2 + y**2 - 9)
scene.add(graph)
diff --git a/tests/test_graphical_units/test_threed.py b/tests/test_graphical_units/test_threed.py
index d70657c65..eb2bd588a 100644
--- a/tests/test_graphical_units/test_threed.py
+++ b/tests/test_graphical_units/test_threed.py
@@ -123,7 +123,7 @@ def test_SurfaceColorscale(scene):
def param_trig(u, v):
x = u
y = v
- z = y ** 2 / 2 - x ** 2 / 2
+ z = y**2 / 2 - x**2 / 2
return z
trig_plane = Surface(
diff --git a/tests/test_space_ops.py b/tests/test_space_ops.py
index 36e529f46..108f586e0 100644
--- a/tests/test_space_ops.py
+++ b/tests/test_space_ops.py
@@ -108,6 +108,6 @@ def test_polar_coords():
b = (2, np.pi / 2, np.pi / 2)
assert np.all(
np.round(cartesian_to_spherical(a), 4)
- == np.round([2 ** 0.5, np.pi / 4, np.pi / 2], 4),
+ == np.round([2**0.5, np.pi / 4, np.pi / 2], 4),
)
assert np.all(np.round(spherical_to_cartesian(b), 4) == np.array([0, 2, 0]))