Skip to content

Commit f69f254

Browse files
fmuenkelchopan050
andauthored
Rename SceneFileWriter.save_final_image() to save_image() (#4378)
* Rename save_final_image() to save_image() * Rename SceneFileWriter.save_final_image() to save_image() and fix docstring * fix some type annotations * make docstrings consistent * Update manim/scene/scene_file_writer.py Co-authored-by: Francisco Manríquez Novoa <[email protected]> --------- Co-authored-by: Francisco Manríquez Novoa <[email protected]>
1 parent 48d5a36 commit f69f254

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

manim/renderer/cairo_renderer.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
class CairoRenderer:
2727
"""A renderer using Cairo.
2828
29-
num_plays : Number of play() functions in the scene.
30-
time: time elapsed since initialisation of scene.
29+
Attributes
30+
----------
31+
num_plays : int
32+
Number of play() functions in the scene.
33+
34+
time : float
35+
Time elapsed since initialisation of scene.
3136
"""
3237

3338
def __init__(
@@ -138,7 +143,6 @@ def update_frame( # TODO Description in Docstring
138143
ignore_skipping
139144
140145
**kwargs
141-
142146
"""
143147
if self.skip_animations and not ignore_skipping:
144148
return
@@ -160,20 +164,18 @@ def render(self, scene, time, moving_mobjects):
160164
self.add_frame(self.get_frame())
161165

162166
def get_frame(self) -> PixelArray:
163-
"""
164-
Gets the current frame as NumPy array.
167+
"""Gets the current frame as NumPy array.
165168
166169
Returns
167170
-------
168171
np.array
169172
NumPy array of pixel values of each pixel in screen.
170-
The shape of the array is height x width x 3
173+
The shape of the array is height x width x 3.
171174
"""
172175
return np.array(self.camera.pixel_array)
173176

174177
def add_frame(self, frame: np.ndarray, num_frames: int = 1):
175-
"""
176-
Adds a frame to the video_file_stream
178+
"""Adds a frame to the video_file_stream
177179
178180
Parameters
179181
----------
@@ -203,10 +205,7 @@ def freeze_current_frame(self, duration: float):
203205
)
204206

205207
def show_frame(self):
206-
"""
207-
Opens the current frame in the Default Image Viewer
208-
of your system.
209-
"""
208+
"""Opens the current frame in the Default Image Viewer of your system."""
210209
self.update_frame(ignore_skipping=True)
211210
self.camera.get_image().show()
212211

@@ -223,7 +222,7 @@ def save_static_frame_data(
223222
scene
224223
The scene played.
225224
static_mobjects
226-
Static mobjects of the scene. If None, self.static_image is set to None
225+
Static mobjects of the scene. If None, self.static_image is set to None.
227226
228227
Returns
229228
-------
@@ -276,4 +275,4 @@ def scene_finished(self, scene: Scene) -> None:
276275
if config["save_last_frame"]:
277276
self.static_image = None
278277
self.update_frame(scene)
279-
self.file_writer.save_final_image(self.camera.get_image())
278+
self.file_writer.save_image(self.camera.get_image())

manim/renderer/opengl_renderer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ def get_texture_id(self, path):
403403
return self.path_to_texture_id[repr(path)]
404404

405405
def update_skipping_status(self) -> None:
406-
"""
407-
This method is used internally to check if the current
406+
"""This method is used internally to check if the current
408407
animation needs to be skipped or not. It also checks if
409408
the number of animations that were played correspond to
410409
the number of animations that need to be played, and
@@ -506,7 +505,7 @@ def scene_finished(self, scene):
506505
if self.should_save_last_frame():
507506
config.save_last_frame = True
508507
self.update_frame(scene)
509-
self.file_writer.save_final_image(self.get_image())
508+
self.file_writer.save_image(self.get_image())
510509

511510
def should_save_last_frame(self):
512511
if config["save_last_frame"]:

manim/scene/scene_file_writer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,17 +483,16 @@ def write_frame(
483483
)
484484

485485
def output_image(
486-
self, image: Image.Image, target_dir: StrPath, ext: str, zero_pad: bool
486+
self, image: Image.Image, target_dir: StrPath, ext: str, zero_pad: int
487487
) -> None:
488488
if zero_pad:
489489
image.save(f"{target_dir}{str(self.frame_count).zfill(zero_pad)}{ext}")
490490
else:
491491
image.save(f"{target_dir}{self.frame_count}{ext}")
492492
self.frame_count += 1
493493

494-
def save_final_image(self, image: Image.Image) -> None:
495-
"""The name is a misnomer. This method saves the image
496-
passed to it as an in the default image directory.
494+
def save_image(self, image: Image.Image) -> None:
495+
"""This method saves the image passed to it in the default image directory.
497496
498497
Parameters
499498
----------

0 commit comments

Comments
 (0)