mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Add white space after assert statements
This commit is contained in:
parent
3f15715ff1
commit
902a4f264e
15 changed files with 30 additions and 30 deletions
|
@ -49,7 +49,7 @@ class Animation(object):
|
||||||
self.lag_ratio = lag_ratio
|
self.lag_ratio = lag_ratio
|
||||||
self.suspend_mobject_updating = suspend_mobject_updating
|
self.suspend_mobject_updating = suspend_mobject_updating
|
||||||
|
|
||||||
assert(isinstance(mobject, Mobject))
|
assert isinstance(mobject, Mobject)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -133,7 +133,7 @@ class Succession(AnimationGroup):
|
||||||
super().__init__(*animations, lag_ratio=lag_ratio, **kwargs)
|
super().__init__(*animations, lag_ratio=lag_ratio, **kwargs)
|
||||||
|
|
||||||
def begin(self) -> None:
|
def begin(self) -> None:
|
||||||
assert(len(self.animations) > 0)
|
assert len(self.animations) > 0
|
||||||
self.active_animation = self.animations[0]
|
self.active_animation = self.animations[0]
|
||||||
self.active_animation.begin()
|
self.active_animation.begin()
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ class DrawBorderThenFill(Animation):
|
||||||
fill_animation_config: dict = {},
|
fill_animation_config: dict = {},
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
assert(isinstance(vmobject, VMobject))
|
assert isinstance(vmobject, VMobject)
|
||||||
self.sm_to_index = {hash(sm): 0 for sm in vmobject.get_family()}
|
self.sm_to_index = {hash(sm): 0 for sm in vmobject.get_family()}
|
||||||
self.stroke_width = stroke_width
|
self.stroke_width = stroke_width
|
||||||
self.stroke_color = stroke_color
|
self.stroke_color = stroke_color
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ChangingDecimal(Animation):
|
||||||
suspend_mobject_updating: bool = False,
|
suspend_mobject_updating: bool = False,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
assert(isinstance(decimal_mob, DecimalNumber))
|
assert isinstance(decimal_mob, DecimalNumber)
|
||||||
self.number_update_func = number_update_func
|
self.number_update_func = number_update_func
|
||||||
super().__init__(
|
super().__init__(
|
||||||
decimal_mob,
|
decimal_mob,
|
||||||
|
|
|
@ -179,7 +179,7 @@ class ApplyMethod(Transform):
|
||||||
"Whoops, looks like you accidentally invoked "
|
"Whoops, looks like you accidentally invoked "
|
||||||
"the method you want to animate"
|
"the method you want to animate"
|
||||||
)
|
)
|
||||||
assert(isinstance(method.__self__, Mobject))
|
assert isinstance(method.__self__, Mobject)
|
||||||
|
|
||||||
def create_target(self) -> Mobject:
|
def create_target(self) -> Mobject:
|
||||||
method = self.method
|
method = self.method
|
||||||
|
|
|
@ -99,7 +99,7 @@ class Camera(object):
|
||||||
self.light_source = Point(self.light_source_position)
|
self.light_source = Point(self.light_source_position)
|
||||||
|
|
||||||
def use_window_fbo(self, use: bool = True):
|
def use_window_fbo(self, use: bool = True):
|
||||||
assert(self.window is not None)
|
assert self.window is not None
|
||||||
if use:
|
if use:
|
||||||
self.fbo = self.window_fbo
|
self.fbo = self.window_fbo
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -20,12 +20,12 @@ class EventDispatcher(object):
|
||||||
self.draggable_object_listners: list[EventListener] = []
|
self.draggable_object_listners: list[EventListener] = []
|
||||||
|
|
||||||
def add_listner(self, event_listner: EventListener):
|
def add_listner(self, event_listner: EventListener):
|
||||||
assert(isinstance(event_listner, EventListener))
|
assert isinstance(event_listner, EventListener)
|
||||||
self.event_listners[event_listner.event_type].append(event_listner)
|
self.event_listners[event_listner.event_type].append(event_listner)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def remove_listner(self, event_listner: EventListener):
|
def remove_listner(self, event_listner: EventListener):
|
||||||
assert(isinstance(event_listner, EventListener))
|
assert isinstance(event_listner, EventListener)
|
||||||
try:
|
try:
|
||||||
while event_listner in self.event_listners[event_listner.event_type]:
|
while event_listner in self.event_listners[event_listner.event_type]:
|
||||||
self.event_listners[event_listner.event_type].remove(event_listner)
|
self.event_listners[event_listner.event_type].remove(event_listner)
|
||||||
|
@ -56,7 +56,7 @@ class EventDispatcher(object):
|
||||||
|
|
||||||
if event_type == EventType.MouseDragEvent:
|
if event_type == EventType.MouseDragEvent:
|
||||||
for listner in self.draggable_object_listners:
|
for listner in self.draggable_object_listners:
|
||||||
assert(isinstance(listner, EventListener))
|
assert isinstance(listner, EventListener)
|
||||||
propagate_event = listner.callback(listner.mobject, event_data)
|
propagate_event = listner.callback(listner.mobject, event_data)
|
||||||
if propagate_event is not None and propagate_event is False:
|
if propagate_event is not None and propagate_event is False:
|
||||||
return propagate_event
|
return propagate_event
|
||||||
|
|
|
@ -37,7 +37,7 @@ class MotionMobject(Mobject):
|
||||||
"""
|
"""
|
||||||
def __init__(self, mobject: Mobject, **kwargs):
|
def __init__(self, mobject: Mobject, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
assert(isinstance(mobject, Mobject))
|
assert isinstance(mobject, Mobject)
|
||||||
self.mobject = mobject
|
self.mobject = mobject
|
||||||
self.mobject.add_mouse_drag_listner(self.mob_on_mouse_drag)
|
self.mobject.add_mouse_drag_listner(self.mob_on_mouse_drag)
|
||||||
# To avoid locking it as static mobject
|
# To avoid locking it as static mobject
|
||||||
|
@ -58,7 +58,7 @@ class Button(Mobject):
|
||||||
|
|
||||||
def __init__(self, mobject: Mobject, on_click: Callable[[Mobject]], **kwargs):
|
def __init__(self, mobject: Mobject, on_click: Callable[[Mobject]], **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
assert(isinstance(mobject, Mobject))
|
assert isinstance(mobject, Mobject)
|
||||||
self.on_click = on_click
|
self.on_click = on_click
|
||||||
self.mobject = mobject
|
self.mobject = mobject
|
||||||
self.mobject.add_mouse_press_listner(self.mob_on_mouse_press)
|
self.mobject.add_mouse_press_listner(self.mob_on_mouse_press)
|
||||||
|
@ -119,7 +119,7 @@ class EnableDisableButton(ControlMobject):
|
||||||
self.add_mouse_press_listner(self.on_mouse_press)
|
self.add_mouse_press_listner(self.on_mouse_press)
|
||||||
|
|
||||||
def assert_value(self, value: bool) -> None:
|
def assert_value(self, value: bool) -> None:
|
||||||
assert(isinstance(value, bool))
|
assert isinstance(value, bool)
|
||||||
|
|
||||||
def set_value_anim(self, value: bool) -> None:
|
def set_value_anim(self, value: bool) -> None:
|
||||||
if value:
|
if value:
|
||||||
|
@ -168,7 +168,7 @@ class Checkbox(ControlMobject):
|
||||||
self.add_mouse_press_listner(self.on_mouse_press)
|
self.add_mouse_press_listner(self.on_mouse_press)
|
||||||
|
|
||||||
def assert_value(self, value: bool) -> None:
|
def assert_value(self, value: bool) -> None:
|
||||||
assert(isinstance(value, bool))
|
assert isinstance(value, bool)
|
||||||
|
|
||||||
def toggle_value(self) -> None:
|
def toggle_value(self) -> None:
|
||||||
super().set_value(not self.get_value())
|
super().set_value(not self.get_value())
|
||||||
|
@ -252,7 +252,7 @@ class LinearNumberSlider(ControlMobject):
|
||||||
super().__init__(value, self.bar, self.slider, self.slider_axis, **kwargs)
|
super().__init__(value, self.bar, self.slider, self.slider_axis, **kwargs)
|
||||||
|
|
||||||
def assert_value(self, value: float) -> None:
|
def assert_value(self, value: float) -> None:
|
||||||
assert(self.min_value <= value <= self.max_value)
|
assert self.min_value <= value <= self.max_value
|
||||||
|
|
||||||
def set_value_anim(self, value: float) -> None:
|
def set_value_anim(self, value: float) -> None:
|
||||||
prop = (value - self.min_value) / (self.max_value - self.min_value)
|
prop = (value - self.min_value) / (self.max_value - self.min_value)
|
||||||
|
@ -351,7 +351,7 @@ class ColorSliders(Group):
|
||||||
grid.move_to(self.selected_color_box)
|
grid.move_to(self.selected_color_box)
|
||||||
|
|
||||||
for idx, square in enumerate(grid):
|
for idx, square in enumerate(grid):
|
||||||
assert(isinstance(square, Square))
|
assert isinstance(square, Square)
|
||||||
square.set_stroke(width=0.0, opacity=0.0)
|
square.set_stroke(width=0.0, opacity=0.0)
|
||||||
square.set_fill(colors[idx % len(colors)], 1.0)
|
square.set_fill(colors[idx % len(colors)], 1.0)
|
||||||
|
|
||||||
|
|
|
@ -125,11 +125,11 @@ class Mobject(object):
|
||||||
return self.__class__.__name__
|
return self.__class__.__name__
|
||||||
|
|
||||||
def __add__(self, other: Mobject) -> Mobject:
|
def __add__(self, other: Mobject) -> Mobject:
|
||||||
assert(isinstance(other, Mobject))
|
assert isinstance(other, Mobject)
|
||||||
return self.get_group_class()(self, other)
|
return self.get_group_class()(self, other)
|
||||||
|
|
||||||
def __mul__(self, other: int) -> Mobject:
|
def __mul__(self, other: int) -> Mobject:
|
||||||
assert(isinstance(other, int))
|
assert isinstance(other, int)
|
||||||
return self.replicate(other)
|
return self.replicate(other)
|
||||||
|
|
||||||
def init_data(self, length: int = 0):
|
def init_data(self, length: int = 0):
|
||||||
|
@ -228,7 +228,7 @@ class Mobject(object):
|
||||||
# Only these methods should directly affect points
|
# Only these methods should directly affect points
|
||||||
@affects_data
|
@affects_data
|
||||||
def set_data(self, data: np.ndarray) -> Self:
|
def set_data(self, data: np.ndarray) -> Self:
|
||||||
assert(data.dtype == self.data.dtype)
|
assert data.dtype == self.data.dtype
|
||||||
self.resize_points(len(data))
|
self.resize_points(len(data))
|
||||||
self.data[:] = data
|
self.data[:] = data
|
||||||
return self
|
return self
|
||||||
|
|
|
@ -18,9 +18,9 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
|
|
||||||
def assert_is_mobject_method(method):
|
def assert_is_mobject_method(method):
|
||||||
assert(inspect.ismethod(method))
|
assert inspect.ismethod(method)
|
||||||
mobject = method.__self__
|
mobject = method.__self__
|
||||||
assert(isinstance(mobject, Mobject))
|
assert isinstance(mobject, Mobject)
|
||||||
|
|
||||||
|
|
||||||
def always(method, *args, **kwargs):
|
def always(method, *args, **kwargs):
|
||||||
|
|
|
@ -153,7 +153,7 @@ class SampleSpace(Rectangle):
|
||||||
direction: np.ndarray = LEFT,
|
direction: np.ndarray = LEFT,
|
||||||
**kwargs
|
**kwargs
|
||||||
) -> VGroup:
|
) -> VGroup:
|
||||||
assert(hasattr(self, "horizontal_parts"))
|
assert hasattr(self, "horizontal_parts")
|
||||||
parts = self.horizontal_parts
|
parts = self.horizontal_parts
|
||||||
return self.get_subdivision_braces_and_labels(parts, labels, direction, **kwargs)
|
return self.get_subdivision_braces_and_labels(parts, labels, direction, **kwargs)
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class SampleSpace(Rectangle):
|
||||||
labels: str,
|
labels: str,
|
||||||
**kwargs
|
**kwargs
|
||||||
) -> VGroup:
|
) -> VGroup:
|
||||||
assert(hasattr(self, "vertical_parts"))
|
assert hasattr(self, "vertical_parts")
|
||||||
parts = self.vertical_parts
|
parts = self.vertical_parts
|
||||||
return self.get_subdivision_braces_and_labels(parts, labels, UP, **kwargs)
|
return self.get_subdivision_braces_and_labels(parts, labels, UP, **kwargs)
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ class SampleSpace(Rectangle):
|
||||||
labels: str,
|
labels: str,
|
||||||
**kwargs
|
**kwargs
|
||||||
) -> VGroup:
|
) -> VGroup:
|
||||||
assert(hasattr(self, "vertical_parts"))
|
assert hasattr(self, "vertical_parts")
|
||||||
parts = self.vertical_parts
|
parts = self.vertical_parts
|
||||||
return self.get_subdivision_braces_and_labels(parts, labels, DOWN, **kwargs)
|
return self.get_subdivision_braces_and_labels(parts, labels, DOWN, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ class Surface(Mobject):
|
||||||
b: float,
|
b: float,
|
||||||
axis: int | None = None
|
axis: int | None = None
|
||||||
) -> Self:
|
) -> Self:
|
||||||
assert(isinstance(smobject, Surface))
|
assert isinstance(smobject, Surface)
|
||||||
if axis is None:
|
if axis is None:
|
||||||
axis = self.prefered_creation_axis
|
axis = self.prefered_creation_axis
|
||||||
if a <= 0 and b >= 1:
|
if a <= 0 and b >= 1:
|
||||||
|
|
|
@ -473,7 +473,7 @@ class VMobject(Mobject):
|
||||||
if len(anchors) == 0:
|
if len(anchors) == 0:
|
||||||
self.clear_points()
|
self.clear_points()
|
||||||
return self
|
return self
|
||||||
assert(len(anchors) == len(handles) + 1)
|
assert len(anchors) == len(handles) + 1
|
||||||
points = resize_array(self.get_points(), 2 * len(anchors) - 1)
|
points = resize_array(self.get_points(), 2 * len(anchors) - 1)
|
||||||
points[0::2] = anchors
|
points[0::2] = anchors
|
||||||
points[1::2] = handles
|
points[1::2] = handles
|
||||||
|
@ -1057,7 +1057,7 @@ class VMobject(Mobject):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def pointwise_become_partial(self, vmobject: VMobject, a: float, b: float) -> Self:
|
def pointwise_become_partial(self, vmobject: VMobject, a: float, b: float) -> Self:
|
||||||
assert(isinstance(vmobject, VMobject))
|
assert isinstance(vmobject, VMobject)
|
||||||
vm_points = vmobject.get_points()
|
vm_points = vmobject.get_points()
|
||||||
self.data["joint_product"] = vmobject.data["joint_product"]
|
self.data["joint_product"] = vmobject.data["joint_product"]
|
||||||
if a <= 0 and b >= 1:
|
if a <= 0 and b >= 1:
|
||||||
|
@ -1259,7 +1259,7 @@ class VMobject(Mobject):
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def set_points(self, points: Vect3Array, refresh_joints: bool = True) -> Self:
|
def set_points(self, points: Vect3Array, refresh_joints: bool = True) -> Self:
|
||||||
assert(len(points) == 0 or len(points) % 2 == 1)
|
assert len(points) == 0 or len(points) % 2 == 1
|
||||||
super().set_points(points)
|
super().set_points(points)
|
||||||
self.refresh_triangulation()
|
self.refresh_triangulation()
|
||||||
if refresh_joints:
|
if refresh_joints:
|
||||||
|
@ -1269,7 +1269,7 @@ class VMobject(Mobject):
|
||||||
|
|
||||||
@triggers_refreshed_triangulation
|
@triggers_refreshed_triangulation
|
||||||
def append_points(self, points: Vect3Array) -> Self:
|
def append_points(self, points: Vect3Array) -> Self:
|
||||||
assert(len(points) % 2 == 0)
|
assert len(points) % 2 == 0
|
||||||
super().append_points(points)
|
super().append_points(points)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
|
@ -868,7 +868,7 @@ class Scene(object):
|
||||||
point: Vect3,
|
point: Vect3,
|
||||||
d_point: Vect3
|
d_point: Vect3
|
||||||
) -> None:
|
) -> None:
|
||||||
assert(self.window is not None)
|
assert self.window is not None
|
||||||
self.mouse_point.move_to(point)
|
self.mouse_point.move_to(point)
|
||||||
|
|
||||||
event_data = {"point": point, "d_point": d_point}
|
event_data = {"point": point, "d_point": d_point}
|
||||||
|
|
|
@ -219,7 +219,7 @@ class ShaderWrapper(object):
|
||||||
self.set_ctx_clip_plane(self.use_clip_plane())
|
self.set_ctx_clip_plane(self.use_clip_plane())
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
assert(self.vao is not None)
|
assert self.vao is not None
|
||||||
self.vao.render()
|
self.vao.render()
|
||||||
|
|
||||||
def update_program_uniforms(self, camera_uniforms: UniformDict):
|
def update_program_uniforms(self, camera_uniforms: UniformDict):
|
||||||
|
|
Loading…
Add table
Reference in a new issue