Commit 5239583e authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Fix leaking matplotlib figure (#2771)

Summary:
In StreamWriter basic usage tutorial, matplotlib is used to generate raster images of waveforms, and the figure used is left unshown in the resulting tutorial with the use of ``sphinx_gallery_defer_figures`` command.

It turned out that this figure is shown in the next code block executed by Sphinx Gallery, and the figure is placed in totally unrelated place. https://pytorch.org/audio/main/tutorials/audio_feature_extractions_tutorial.html

<img width="951" alt="Screen Shot 2022-10-14 at 10 06 58 PM" src="https://user-images.githubusercontent.com/855818/195855124-ecd9be49-5085-4acd-9a93-608d9d1ee9ce.png">

This commit fixes it by closing the figure.

Pull Request resolved: https://github.com/pytorch/audio/pull/2771

Reviewed By: nateanl

Differential Revision: D40382076

Pulled By: mthrok

fbshipit-source-id: 015f2bab8492d3b4fbe70e1174c7776a5aa2679a
parent 000d7526
...@@ -654,7 +654,7 @@ with s.open(): ...@@ -654,7 +654,7 @@ with s.open():
s.write_video_chunk(1, torch.stack(frames)) s.write_video_chunk(1, torch.stack(frames))
i += frame_rate i += frame_rate
# sphinx_gallery_defer_figures plt.close(fig)
###################################################################### ######################################################################
# #
...@@ -667,8 +667,6 @@ with s.open(): ...@@ -667,8 +667,6 @@ with s.open():
Video(get_path("example.mp4"), embed=True) Video(get_path("example.mp4"), embed=True)
# sphinx_gallery_defer_figures
###################################################################### ######################################################################
# #
# Carefully watching the video, it can be # Carefully watching the video, it can be
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment