Skip to content

Commit 435166e

Browse files
committed
Some random fix from the internet
1 parent 7a42663 commit 435166e

File tree

5 files changed

+43
-31
lines changed

5 files changed

+43
-31
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
run: |
5151
sudo apt update
5252
sudo apt install -y ffmpeg
53-
sudo apt-get -y install texlive texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-fonts-extra tipa freeglut3-dev
53+
sudo apt-get -y install texlive texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-fonts-extra tipa freeglut3-dev python-opengl
5454
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
5555
5656
- name: Install system dependencies (MacOS)
@@ -115,7 +115,7 @@ jobs:
115115
poetry install -E webgl_renderer
116116
117117
- name: Run tests
118-
run: poetry run pytest
118+
run: xvfb-run -s "-screen 0 1400x900x24" poetry run pytest
119119

120120
- name: Run module doctests
121121
run: poetry run pytest --doctest-modules manim

manim/_config/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,6 @@ def use_opengl_renderer(self, val: bool) -> None:
10651065
if val:
10661066
self["disable_caching"] = True
10671067

1068-
10691068
@property
10701069
def use_webgl_renderer(self):
10711070
"""Whether or not to use WebGL renderer."""

manim/mobject/mobject.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,16 @@ def get_bounding_box(self):
9494
return self.data["bounding_box"]
9595

9696
def compute_bounding_box(self):
97-
all_points = np.vstack([
98-
self.data["points"],
99-
*(
100-
mob.get_bounding_box()
101-
for mob in self.get_family()[1:]
102-
if mob.has_points()
103-
)
104-
])
97+
all_points = np.vstack(
98+
[
99+
self.data["points"],
100+
*(
101+
mob.get_bounding_box()
102+
for mob in self.get_family()[1:]
103+
if mob.has_points()
104+
),
105+
]
106+
)
105107
if len(all_points) == 0:
106108
return np.zeros((3, self.dim))
107109
else:
@@ -656,8 +658,8 @@ def shift(self, *vectors):
656658
for mob in self.family_members_with_points():
657659
mob.points = mob.points.astype("float")
658660
mob.points += total_vector
659-
if hasattr(mob, 'data') and 'points' in mob.data:
660-
mob.data['points'] += total_vector
661+
if hasattr(mob, "data") and "points" in mob.data:
662+
mob.data["points"] += total_vector
661663
return self
662664

663665
def scale(self, scale_factor, **kwargs):
@@ -674,7 +676,7 @@ def scale(self, scale_factor, **kwargs):
674676
self.apply_points_function(
675677
lambda points: scale_factor * points,
676678
works_on_bounding_box=True,
677-
**kwargs
679+
**kwargs,
678680
)
679681
return self
680682
else:
@@ -690,8 +692,7 @@ def rotate(self, angle, axis=OUT, **kwargs):
690692
if config["use_opengl_renderer"]:
691693
rot_matrix_T = rotation_matrix_transpose(angle, axis)
692694
self.apply_points_function(
693-
lambda points: np.dot(points, rot_matrix_T),
694-
**kwargs
695+
lambda points: np.dot(points, rot_matrix_T), **kwargs
695696
)
696697
return self
697698
else:
@@ -782,7 +783,9 @@ def repeat_array(array):
782783
# In place operations.
783784
# Note, much of these are now redundant with default behavior of
784785
# above methods
785-
def apply_points_function(self, func, about_point=None, about_edge=ORIGIN, works_on_bounding_box=False):
786+
def apply_points_function(
787+
self, func, about_point=None, about_edge=ORIGIN, works_on_bounding_box=False
788+
):
786789
if about_point is None and about_edge is not None:
787790
about_point = self.get_bounding_box_point(about_edge)
788791

@@ -1375,14 +1378,14 @@ def get_z(self, direction=ORIGIN):
13751378
def get_start(self):
13761379
self.throw_error_if_no_points()
13771380
if config["use_opengl_renderer"]:
1378-
return np.array(self.data['points'][0])
1381+
return np.array(self.data["points"][0])
13791382
else:
13801383
return np.array(self.points[0])
13811384

13821385
def get_end(self):
13831386
self.throw_error_if_no_points()
13841387
if config["use_opengl_renderer"]:
1385-
return np.array(self.data['points'][-1])
1388+
return np.array(self.data["points"][-1])
13861389
else:
13871390
return np.array(self.points[-1])
13881391

manim/mobject/opengl_mobject.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class OpenGLMobject:
3737
"""
3838
Mathematical Object
3939
"""
40-
shader_dtype=[
40+
41+
shader_dtype = [
4142
("point", np.float32, (3,)),
4243
]
4344
shader_folder = ""
@@ -448,7 +449,11 @@ def copy(self):
448449
# Make sure any mobject or numpy array attributes are copied
449450
family = self.get_family()
450451
for attr, value in list(self.__dict__.items()):
451-
if isinstance(value, OpenGLMobject) and value in family and value is not self:
452+
if (
453+
isinstance(value, OpenGLMobject)
454+
and value in family
455+
and value is not self
456+
):
452457
setattr(copy_mobject, attr, value.copy())
453458
if isinstance(value, np.ndarray):
454459
setattr(copy_mobject, attr, value.copy())
@@ -1386,11 +1391,12 @@ def set_color_by_xyz_func(
13861391

13871392
def get_shader_wrapper(self):
13881393
from ..renderer.shader_wrapper import ShaderWrapper
1394+
13891395
self.shader_wrapper = ShaderWrapper(
13901396
vert_data=self.get_shader_data(),
13911397
vert_indices=self.get_shader_vert_indices(),
1392-
uniforms = self.get_shader_uniforms(),
1393-
depth_test = self.depth_test,
1398+
uniforms=self.get_shader_uniforms(),
1399+
depth_test=self.depth_test,
13941400
texture_paths=self.texture_paths,
13951401
render_primitive=self.render_primitive,
13961402
shader_folder=self.__class__.shader_folder,

manim/mobject/types/vectorized_mobject.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class VMobject(Mobject):
6060
("stroke_width", np.float32, (1,)),
6161
("color", np.float32, (4,)),
6262
]
63+
6364
def __init__(
6465
self,
6566
fill_color=None,
@@ -113,10 +114,8 @@ def __init__(
113114
self.tolerance_for_point_equality = tolerance_for_point_equality
114115
self.n_points_per_cubic_curve = n_points_per_cubic_curve
115116

116-
117117
Mobject.__init__(self, **kwargs)
118118

119-
120119
def init_gl_data(self):
121120
self.needs_new_triangulation = True
122121
self.joint_type = "auto"
@@ -549,7 +548,7 @@ def set_anchors_and_handles(
549548
if config["use_opengl_renderer"]:
550549
handles = handles1
551550
anchors2 = handles2
552-
assert(len(anchors1) == len(handles) == len(anchors2))
551+
assert len(anchors1) == len(handles) == len(anchors2)
553552
nppc = 3
554553
new_points = np.zeros((nppc * len(anchors1), self.dim))
555554
arrays = [anchors1, handles, anchors2]
@@ -725,18 +724,23 @@ def set_points_as_corners(self, points: Iterable[float]) -> "VMobject":
725724
if config["use_opengl_renderer"]:
726725
nppc = self.n_points_per_curve
727726
points = np.array(points)
728-
self.set_anchors_and_handles(*[
729-
interpolate(points[:-1], points[1:], a)
730-
for a in np.linspace(0, 1, nppc)
731-
])
727+
self.set_anchors_and_handles(
728+
*[
729+
interpolate(points[:-1], points[1:], a)
730+
for a in np.linspace(0, 1, nppc)
731+
]
732+
)
732733
return self
733734
else:
734735
nppcc = self.n_points_per_cubic_curve
735736
points = np.array(points)
736737
# This will set the handles aligned with the anchors.
737738
# Id est, a bezier curve will be the segment from the two anchors such that the handles belongs to this segment.
738739
self.set_anchors_and_handles(
739-
*[interpolate(points[:-1], points[1:], a) for a in np.linspace(0, 1, nppcc)]
740+
*[
741+
interpolate(points[:-1], points[1:], a)
742+
for a in np.linspace(0, 1, nppcc)
743+
]
740744
)
741745
return self
742746

0 commit comments

Comments
 (0)