mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Cleaning up some imports + Minor Bug fixed in VectorField (#2253)
* cleaning up imports * sample_points -> sample_coords
This commit is contained in:
parent
8239f1bf35
commit
5d3f730824
21 changed files with 25 additions and 51 deletions
|
@ -6,7 +6,6 @@ from manimlib.mobject.mobject import _AnimationBuilder
|
|||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.utils.iterables import remove_list_redundancies
|
||||
from manimlib.utils.rate_functions import smooth
|
||||
from manimlib.utils.rate_functions import squish_rate_func
|
||||
from manimlib.utils.simple_functions import clip
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from manimlib.animation.animation import Animation
|
||||
from manimlib.animation.animation import prepare_animation
|
||||
from manimlib.mobject.mobject import _AnimationBuilder
|
||||
|
|
|
@ -5,7 +5,6 @@ from abc import ABC, abstractmethod
|
|||
import numpy as np
|
||||
|
||||
from manimlib.animation.animation import Animation
|
||||
from manimlib.constants import WHITE
|
||||
from manimlib.mobject.svg.string_mobject import StringMobject
|
||||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||
from manimlib.utils.bezier import integer_interpolate
|
||||
|
|
|
@ -5,9 +5,7 @@ import numpy as np
|
|||
from manimlib.animation.animation import Animation
|
||||
from manimlib.animation.transform import Transform
|
||||
from manimlib.constants import ORIGIN
|
||||
from manimlib.mobject.mobject import Group
|
||||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
from manimlib.utils.bezier import interpolate
|
||||
from manimlib.utils.rate_functions import there_and_back
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from manimlib.animation.transform import Transform
|
||||
from manimlib.constants import PI
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
from os import remove
|
||||
import numpy as np
|
||||
|
||||
from manimlib.animation.animation import Animation
|
||||
|
|
|
@ -5,7 +5,6 @@ import warnings
|
|||
|
||||
import numpy as np
|
||||
from scipy.spatial.transform import Rotation
|
||||
from pyrr import Matrix44
|
||||
|
||||
from manimlib.constants import DEGREES, RADIANS
|
||||
from manimlib.constants import FRAME_SHAPE
|
||||
|
|
|
@ -37,6 +37,7 @@ class FullScreenRectangle(ScreenRectangle):
|
|||
fill_color=fill_color,
|
||||
fill_opacity=fill_opacity,
|
||||
stroke_width=stroke_width,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
import numbers
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
@ -13,9 +12,7 @@ from manimlib.mobject.mobject import Mobject
|
|||
from manimlib.mobject.types.vectorized_mobject import DashedVMobject
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||
from manimlib.utils.bezier import bezier
|
||||
from manimlib.utils.bezier import quadratic_bezier_points_for_arc
|
||||
from manimlib.utils.bezier import partial_quadratic_bezier_points
|
||||
from manimlib.utils.iterables import adjacent_n_tuples
|
||||
from manimlib.utils.iterables import adjacent_pairs
|
||||
from manimlib.utils.simple_functions import clip
|
||||
|
@ -30,7 +27,6 @@ from manimlib.utils.space_ops import normalize
|
|||
from manimlib.utils.space_ops import rotate_vector
|
||||
from manimlib.utils.space_ops import rotation_matrix_transpose
|
||||
from manimlib.utils.space_ops import rotation_between_vectors
|
||||
from manimlib.utils.space_ops import rotation_about_z
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import itertools as it
|
||||
|
||||
import numpy as np
|
||||
|
||||
from manimlib.constants import DOWN, LEFT, RIGHT, ORIGIN
|
||||
|
@ -14,7 +12,7 @@ from manimlib.mobject.types.vectorized_mobject import VMobject
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Sequence, Union, Tuple, Optional
|
||||
from typing import Sequence, Union, Optional
|
||||
from manimlib.typing import ManimColor, Vect3, VectNArray, Self
|
||||
|
||||
StringMatrixType = Union[Sequence[Sequence[str]], np.ndarray[int, np.dtype[np.str_]]]
|
||||
|
|
|
@ -14,7 +14,8 @@ from manimlib.utils.bezier import interpolate
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import TypeVar
|
||||
from typing import TypeVar, Callable
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.typing import ManimColor, Vect3, Self
|
||||
|
||||
T = TypeVar("T", bound=VMobject)
|
||||
|
|
|
@ -6,7 +6,7 @@ import copy
|
|||
import numpy as np
|
||||
|
||||
from manimlib.constants import DEFAULT_MOBJECT_TO_MOBJECT_BUFFER, SMALL_BUFF
|
||||
from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP, DL, DR, UL
|
||||
from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, DL, DR, UL
|
||||
from manimlib.constants import PI
|
||||
from manimlib.animation.composition import AnimationGroup
|
||||
from manimlib.animation.fading import FadeIn
|
||||
|
|
|
@ -25,7 +25,6 @@ from manimlib.constants import LEFT
|
|||
from manimlib.constants import LEFT
|
||||
from manimlib.constants import MED_LARGE_BUFF
|
||||
from manimlib.constants import MED_SMALL_BUFF
|
||||
from manimlib.constants import LARGE_BUFF
|
||||
from manimlib.constants import ORIGIN
|
||||
from manimlib.constants import OUT
|
||||
from manimlib.constants import PI
|
||||
|
@ -52,12 +51,9 @@ from manimlib.mobject.geometry import Polygon
|
|||
from manimlib.mobject.geometry import Rectangle
|
||||
from manimlib.mobject.geometry import Square
|
||||
from manimlib.mobject.geometry import AnnularSector
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.mobject.numbers import Integer
|
||||
from manimlib.mobject.shape_matchers import SurroundingRectangle
|
||||
from manimlib.mobject.svg.svg_mobject import SVGMobject
|
||||
from manimlib.mobject.svg.tex_mobject import Tex
|
||||
from manimlib.mobject.svg.tex_mobject import TexText
|
||||
from manimlib.mobject.svg.special_tex import TexTextFromPresetString
|
||||
from manimlib.mobject.three_dimensions import Prismify
|
||||
from manimlib.mobject.three_dimensions import VCube
|
||||
|
@ -421,7 +417,7 @@ class Bubble(VGroup):
|
|||
super().flip(axis=axis, **kwargs)
|
||||
if only_body:
|
||||
# Flip in place, don't use kwargs
|
||||
self.content.flip(axis=axis)
|
||||
self.content.flip(axis=axis)
|
||||
if abs(axis[1]) > 0:
|
||||
self.direction = -np.array(self.direction)
|
||||
return self
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
|
@ -16,14 +15,11 @@ from manimlib.mobject.geometry import Polyline
|
|||
from manimlib.mobject.geometry import Rectangle
|
||||
from manimlib.mobject.geometry import RoundedRectangle
|
||||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||
from manimlib.utils.directories import get_mobject_data_dir
|
||||
from manimlib.utils.images import get_full_vector_image_path
|
||||
from manimlib.utils.iterables import hash_obj
|
||||
from manimlib.utils.simple_functions import hash_string
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
if TYPE_CHECKING:
|
||||
from typing import Tuple
|
||||
from manimlib.typing import ManimColor, Vect3Array
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ from manimlib.logger import log
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from manimlib.typing import ManimColor, Span, Selector
|
||||
from manimlib.typing import ManimColor, Span, Selector, Self
|
||||
|
||||
|
||||
SCALE_FACTOR_PER_FONT_POINT = 0.001
|
||||
|
|
|
@ -6,28 +6,23 @@ import numpy as np
|
|||
from scipy.integrate import solve_ivp
|
||||
|
||||
from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH
|
||||
from manimlib.constants import BLUE, WHITE
|
||||
from manimlib.constants import ORIGIN
|
||||
from manimlib.constants import WHITE
|
||||
from manimlib.animation.indication import VShowPassingFlash
|
||||
from manimlib.mobject.geometry import Arrow
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||
from manimlib.utils.bezier import interpolate
|
||||
from manimlib.utils.bezier import inverse_interpolate
|
||||
from manimlib.utils.color import get_colormap_list
|
||||
from manimlib.utils.color import rgb_to_color
|
||||
from manimlib.utils.color import get_color_map
|
||||
from manimlib.utils.dict_ops import merge_dicts_recursively
|
||||
from manimlib.utils.iterables import cartesian_product
|
||||
from manimlib.utils.rate_functions import linear
|
||||
from manimlib.utils.simple_functions import sigmoid
|
||||
from manimlib.utils.space_ops import get_norm
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Callable, Iterable, Sequence, TypeVar, Tuple
|
||||
from manimlib.typing import ManimColor, Vect3, VectN, Vect2Array, Vect3Array, Vect4Array
|
||||
from typing import Callable, Iterable, Sequence, TypeVar, Tuple, Optional
|
||||
from manimlib.typing import ManimColor, Vect3, VectN, VectArray, Vect3Array, Vect4Array
|
||||
|
||||
from manimlib.mobject.coordinate_systems import CoordinateSystem
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
|
@ -113,8 +108,8 @@ def move_points_along_vector_field(
|
|||
cs = coordinate_system
|
||||
origin = cs.get_origin()
|
||||
|
||||
def apply_nudge(self, dt):
|
||||
mobject.apply_function(
|
||||
def apply_nudge(mob, dt):
|
||||
mob.apply_function(
|
||||
lambda p: p + (cs.c2p(*func(*cs.p2c(p))) - origin) * dt
|
||||
)
|
||||
mobject.add_updater(apply_nudge)
|
||||
|
@ -133,7 +128,7 @@ def get_sample_coords(
|
|||
return np.array(list(it.product(*ranges)))
|
||||
|
||||
|
||||
def vectorize(pointwise_function: Callable[Tuple, Tuple]):
|
||||
def vectorize(pointwise_function: Callable[[Tuple], Tuple]):
|
||||
def v_func(coords_array: VectArray) -> VectArray:
|
||||
return np.array([pointwise_function(*coords) for coords in coords_array])
|
||||
|
||||
|
@ -237,7 +232,7 @@ class VectorField(VMobject):
|
|||
arr[7::8] = 0
|
||||
self.base_stroke_width_array = arr
|
||||
|
||||
def set_sample_coords(self, sample_points: VectArray):
|
||||
def set_sample_coords(self, sample_coords: VectArray):
|
||||
self.sample_coords = sample_coords
|
||||
return self
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ from manimlib.mobject.types.vectorized_mobject import VHighlight
|
|||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||
from manimlib.scene.scene import Scene
|
||||
from manimlib.scene.scene import SceneState
|
||||
from manimlib.scene.scene import PAN_3D_KEY
|
||||
from manimlib.utils.family_ops import extract_mobject_family_members
|
||||
from manimlib.utils.space_ops import get_norm
|
||||
from manimlib.utils.tex_file_writing import LatexError
|
||||
|
|
|
@ -11,7 +11,6 @@ from functools import lru_cache
|
|||
|
||||
from manimlib.config import parse_cli
|
||||
from manimlib.config import get_configuration
|
||||
from manimlib.utils.iterables import resize_array
|
||||
from manimlib.utils.shaders import get_shader_code_from_file
|
||||
from manimlib.utils.shaders import get_shader_program
|
||||
from manimlib.utils.shaders import image_path_to_texture
|
||||
|
@ -20,8 +19,10 @@ from manimlib.utils.shaders import set_program_uniform
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import List, Optional, Dict
|
||||
from typing import Optional, Tuple, Iterable
|
||||
from manimlib.typing import UniformDict
|
||||
from moderngl.vertex_array import VertexArray
|
||||
from moderngl.framebuffer import Framebuffer
|
||||
|
||||
# Mobjects that should be rendered with
|
||||
# the same shader will be organized and
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Union, Tuple, Annotated, Literal, Iterable
|
||||
from typing import Union, Tuple, Annotated, Literal, Iterable, Dict
|
||||
from colour import Color
|
||||
import numpy as np
|
||||
import re
|
||||
|
||||
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
|
@ -28,7 +28,7 @@ if TYPE_CHECKING:
|
|||
|
||||
# These are various alternate names for np.ndarray meant to specify
|
||||
# certain shapes.
|
||||
#
|
||||
#
|
||||
# In theory, these annotations could be used to check arrays sizes
|
||||
# at runtime, but at the moment nothing actually uses them, and
|
||||
# the names are here primarily to enhance readibility and allow
|
||||
|
@ -40,6 +40,7 @@ if TYPE_CHECKING:
|
|||
Vect4 = Annotated[FloatArray, Literal[4]]
|
||||
VectN = Annotated[FloatArray, Literal["N"]]
|
||||
Matrix3x3 = Annotated[FloatArray, Literal[3, 3]]
|
||||
VectArray = Annotated[FloatArray, Literal["N", 1]]
|
||||
Vect2Array = Annotated[FloatArray, Literal["N", 2]]
|
||||
Vect3Array = Annotated[FloatArray, Literal["N", 3]]
|
||||
Vect4Array = Annotated[FloatArray, Literal["N", 4]]
|
||||
|
|
|
@ -13,10 +13,7 @@ from manimlib.utils.file_ops import find_file
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Sequence, Optional, Tuple
|
||||
from manimlib.typing import UniformDict
|
||||
from moderngl.vertex_array import VertexArray
|
||||
from moderngl.framebuffer import Framebuffer
|
||||
from typing import Sequence, Optional
|
||||
|
||||
|
||||
# Global maps to reflect uniform status
|
||||
|
|
|
@ -14,8 +14,11 @@ from manimlib.utils.customization import get_customization
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Callable, TypeVar
|
||||
from manimlib.scene.scene import Scene
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class Window(PygletWindow):
|
||||
fullscreen: bool = False
|
||||
|
|
Loading…
Add table
Reference in a new issue