Skip to content

Commit

Permalink
In show support passing kwargs to Video and Image (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-ramadhan authored Nov 3, 2024
1 parent bee657e commit 3ec94ca
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions matplotloom/loom.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,20 @@ def save_video(self) -> None:
if frame_filename.exists():
frame_filename.unlink()

def show(self) -> Union[Video, Image]:
def show(self, **kwargs) -> Union[Video, Image]:
"""
Display the created animation in a Jupyter notebook.
This method returns an IPython display object that can be used to show
the animation directly in a Jupyter notebook cell. The type of object
returned depends on the file format of the animation.
Parameters
----------
**kwargs
Keyword arguments that will be passed to either IPython.display.Video
or IPython.display.Image constructor depending on the file format.
Returns
-------
Union[IPython.display.Video, IPython.display.Image]
Expand All @@ -256,8 +262,8 @@ def show(self) -> Union[Video, Image]:
method before calling this method.
"""
if self.file_format in {"mp4", "mkv"}:
return Video(str(self.output_filepath))
return Video(self.output_filepath, **kwargs)
elif self.file_format in {"gif", "apng"}:
return Image(str(self.output_filepath))
return Image(self.output_filepath, **kwargs)
else:
raise ValueError(f"Unsupported file format: {self.file_format}")

0 comments on commit 3ec94ca

Please sign in to comment.