Skip to content

Commit

Permalink
Code Cleanup: removing unused imports and global variables (#3620)
Browse files Browse the repository at this point in the history
* Remove unused import

* More security fixes

* Remove unused global variable

* More fixes

* Revert change (actual fix would require some rewrite)

* Add exception for edge case to satisfy warning

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Stuff

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
JasonGrace2282 and pre-commit-ci[bot] authored Apr 1, 2024
1 parent d1cf1c5 commit 7a794e3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
2 changes: 0 additions & 2 deletions manim/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import sys

import click
import cloup

Expand Down
4 changes: 2 additions & 2 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2700,13 +2700,13 @@ def push_self_into_submobjects(self) -> Self:

def add_n_more_submobjects(self, n: int) -> Self | None:
if n == 0:
return
return None

curr = len(self.submobjects)
if curr == 0:
# If empty, simply add n point mobjects
self.submobjects = [self.get_point_mobject() for k in range(n)]
return
return None

target = curr + n
# TODO, factor this out to utils so as to reuse
Expand Down
1 change: 0 additions & 1 deletion manim/mobject/opengl/opengl_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
)

DEFAULT_DOT_RADIUS = 0.08
DEFAULT_SMALL_DOT_RADIUS = 0.04
DEFAULT_DASH_LENGTH = 0.05
DEFAULT_ARROW_TIP_LENGTH = 0.35
DEFAULT_ARROW_TIP_WIDTH = 0.35
Expand Down
1 change: 0 additions & 1 deletion manim/mobject/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def construct(self):
from manim.mobject.text.tex_mobject import MathTex
from manim.mobject.text.text_mobject import Paragraph

from .. import config
from ..animation.animation import Animation
from ..animation.composition import AnimationGroup
from ..animation.creation import Create, Write
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/text/tex_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from manim.constants import *
from manim.mobject.geometry.line import Line
from manim.mobject.svg.svg_mobject import SVGMobject
from manim.mobject.types.vectorized_mobject import VectorizedPoint, VGroup, VMobject
from manim.mobject.types.vectorized_mobject import VGroup, VMobject
from manim.utils.tex import TexTemplate
from manim.utils.tex_file_writing import tex_to_svg_file

Expand Down
28 changes: 18 additions & 10 deletions manim/mobject/types/vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,37 @@
)

import numpy as np
import numpy.typing as npt
from PIL.Image import Image
from typing_extensions import Self

from manim import config
from manim.constants import *
from manim.mobject.mobject import Mobject
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject
from manim.mobject.three_d.three_d_utils import (
get_3d_vmob_gradient_start_and_end_points,
)

from ... import config
from ...constants import *
from ...mobject.mobject import Mobject
from ...utils.bezier import (
from manim.utils.bezier import (
bezier,
get_smooth_handle_points,
integer_interpolate,
interpolate,
partial_bezier_points,
proportions_along_bezier_curve_for_point,
)
from ...utils.color import BLACK, WHITE, ManimColor, ParsableManimColor
from ...utils.iterables import make_even, resize_array, stretch_array_to_length, tuplify
from ...utils.space_ops import rotate_vector, shoelace_direction
from manim.utils.color import BLACK, WHITE, ManimColor, ParsableManimColor
from manim.utils.iterables import (
make_even,
resize_array,
stretch_array_to_length,
tuplify,
)
from manim.utils.space_ops import rotate_vector, shoelace_direction

if TYPE_CHECKING:
import numpy.typing as npt
from typing_extensions import Self

from manim.typing import (
BezierPoints,
CubicBezierPoints,
Expand Down Expand Up @@ -1406,6 +1411,9 @@ def point_from_proportion(self, alpha: float) -> Point3D:
return curve(residue)

current_length += length
raise Exception(
"Not sure how you reached here, please file a bug report at https://github.com/ManimCommunity/manim/issues/new/choose"
)

def proportion_from_point(
self,
Expand Down
3 changes: 0 additions & 3 deletions manim/renderer/opengl_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ def interpolate(self, *args, **kwargs):
self.refresh_rotation_matrix()


points_per_curve = 3


class OpenGLRenderer:
def __init__(self, file_writer_class=SceneFileWriter, skip_animations=False):
# Measured in pixel widths, used for vector graphics
Expand Down

0 comments on commit 7a794e3

Please sign in to comment.