Skip to content

Commit da0972e

Browse files
committed
Running pre-commit
1 parent 8081617 commit da0972e

File tree

6 files changed

+30
-29
lines changed

6 files changed

+30
-29
lines changed

manim_slides/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .slide import Slide, ThreeDSlide
21
from .__version__ import __version__
2+
from .slide import Slide, ThreeDSlide

manim_slides/commons.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import click
2+
23
from .defaults import CONFIG_PATH
34

45

manim_slides/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from . import __version__
55
from .present import present
6-
from .wizard import wizard, init
6+
from .wizard import init, wizard
77

88

99
@click.group(cls=DefaultGroup, default="present", default_if_no_args=True)

manim_slides/present.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import cv2
1010
import numpy as np
1111

12+
from .commons import config_path_option
1213
from .config import Config
1314
from .defaults import CONFIG_PATH, FOLDER_PATH
14-
from .commons import config_path_option
1515

1616

1717
class State(Enum):
@@ -42,7 +42,7 @@ def __init__(self, config, last_frame_next: bool = False):
4242
self.lastframe = []
4343

4444
self.caps = [None for _ in self.files]
45-
self.reset()
45+
self.reset()
4646
self.add_last_slide()
4747

4848
def add_last_slide(self):
@@ -62,22 +62,22 @@ def reset(self):
6262
self.load_this_cap(0)
6363
self.current_slide_i = 0
6464
self.slides[-1]["terminated"] = False
65-
65+
6666
def next(self):
6767
if self.current_slide["type"] == "last":
6868
self.current_slide["terminated"] = True
6969
else:
7070
self.current_slide_i = min(len(self.slides) - 1, self.current_slide_i + 1)
7171
self.rewind_slide()
72-
72+
7373
def prev(self):
7474
self.current_slide_i = max(0, self.current_slide_i - 1)
7575
self.rewind_slide()
7676

7777
def rewind_slide(self):
7878
self.current_animation = self.current_slide["start_animation"]
7979
self.current_cap.set(cv2.CAP_PROP_POS_FRAMES, 0)
80-
80+
8181
def load_this_cap(self,cap_number):
8282
if self.caps[cap_number] == None:
8383
# unload other caps
@@ -91,7 +91,7 @@ def load_this_cap(self,cap_number):
9191
@property
9292
def current_slide(self):
9393
return self.slides[self.current_slide_i]
94-
94+
9595
@property
9696
def current_cap(self):
9797
self.load_this_cap(self.current_animation)
@@ -143,7 +143,7 @@ def update_state(self, state):
143143
self.load_this_cap(self.current_animation)
144144
# Reset video to position zero if it has been played before
145145
self.current_cap.set(cv2.CAP_PROP_POS_FRAMES, 0)
146-
146+
147147
return self.lastframe, state
148148

149149

@@ -163,11 +163,11 @@ def __init__(self, presentations, config, start_paused=False, fullscreen=False):
163163
if fullscreen:
164164
cv2.namedWindow("Video", cv2.WND_PROP_FULLSCREEN)
165165
cv2.setWindowProperty("Video", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
166-
166+
167167
@property
168168
def current_presentation(self):
169169
return self.presentations[self.current_presentation_i]
170-
170+
171171
def run(self):
172172
while True:
173173
self.lastframe, self.state = self.current_presentation.update_state(self.state)
@@ -184,11 +184,11 @@ def run(self):
184184
self.handle_key()
185185
self.show_video()
186186
self.show_info()
187-
187+
188188
def show_video(self):
189189
self.lag = now() - self.last_time
190190
self.last_time = now()
191-
cv2.imshow("Video", self.lastframe)
191+
cv2.imshow("Video", self.lastframe)
192192

193193
def show_info(self):
194194
info = np.zeros((130, 420), np.uint8)
@@ -230,11 +230,11 @@ def show_info(self):
230230
)
231231

232232
cv2.imshow("Info", info)
233-
233+
234234
def handle_key(self):
235235
sleep_time = math.ceil(1000/self.current_presentation.fps)
236236
key = cv2.waitKeyEx(fix_time(sleep_time - self.lag))
237-
237+
238238
if self.config.QUIT.match(key):
239239
self.quit()
240240
elif self.state == State.PLAYING and self.config.PLAY_PAUSE.match(key):
@@ -258,7 +258,7 @@ def handle_key(self):
258258
self.current_presentation.rewind_slide()
259259
self.state = State.PLAYING
260260

261-
261+
262262
def quit(self):
263263
cv2.destroyAllWindows()
264264
sys.exit()

manim_slides/slide.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, *args, output_folder=FOLDER_PATH, **kwargs):
2020
def play(self, *args, **kwargs):
2121
super(Slide, self).play(*args, **kwargs)
2222
self.current_animation += 1
23-
23+
2424
def pause(self):
2525
self.slides.append(dict(
2626
type="slide",
@@ -30,11 +30,11 @@ def pause(self):
3030
))
3131
self.current_slide += 1
3232
self.pause_start_animation = self.current_animation
33-
33+
3434
def start_loop(self):
3535
assert self.loop_start_animation is None, "You cannot nest loops"
3636
self.loop_start_animation = self.current_animation
37-
37+
3838
def end_loop(self):
3939
assert self.loop_start_animation is not None, "You have to start a loop before ending it"
4040
self.slides.append(dict(
@@ -46,32 +46,32 @@ def end_loop(self):
4646
self.current_slide += 1
4747
self.loop_start_animation = None
4848
self.pause_start_animation = self.current_animation
49-
49+
5050
def render(self, *args, **kwargs):
5151
# We need to disable the caching limit since we rely on intermidiate files
5252
max_files_cached = config["max_files_cached"]
5353
config["max_files_cached"] = float("inf")
54-
54+
5555
super(Slide, self).render(*args, **kwargs)
5656

5757
config["max_files_cached"] = max_files_cached
5858

5959
if not os.path.exists(self.output_folder):
6060
os.mkdir(self.output_folder)
61-
61+
6262
files_folder = os.path.join(self.output_folder, "files")
6363
if not os.path.exists(files_folder):
6464
os.mkdir(files_folder)
65-
65+
6666
scene_name = type(self).__name__
6767
scene_files_folder = os.path.join(files_folder, scene_name)
68-
68+
6969
if os.path.exists(scene_files_folder):
7070
shutil.rmtree(scene_files_folder)
71-
72-
if not os.path.exists(scene_files_folder):
71+
72+
if not os.path.exists(scene_files_folder):
7373
os.mkdir(scene_files_folder)
74-
74+
7575
files = list()
7676
for src_file in self.renderer.file_writer.partial_movie_files:
7777
dst_file = os.path.join(scene_files_folder, os.path.basename(src_file))

manim_slides/wizard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import cv2
66
import numpy as np
77

8-
from .config import Config
98
from .commons import config_options
9+
from .config import Config
1010
from .defaults import CONFIG_PATH
1111

1212

@@ -37,7 +37,7 @@ def _init(config_path, force, merge, skip_interactive=False):
3737

3838
if os.path.exists(config_path):
3939
click.secho(f"The `{CONFIG_PATH}` configuration file exists")
40-
40+
4141
if not force and not merge:
4242
choice = click.prompt("Do you want to continue and (o)verwrite / (m)erge it, or (q)uit?", type=click.Choice(["o", "m", "q"], case_sensitive=False))
4343

0 commit comments

Comments
 (0)