Skip to content

Commit 11ef6f5

Browse files
committed
close plots in matplotlib integration
1 parent ea85f50 commit 11ef6f5

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

cebra/integrations/matplotlib.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ def __init__(self, axis: Optional[matplotlib.axes.Axes], figsize: tuple,
6868
if axis is None:
6969
self.fig = plt.figure(figsize=figsize, dpi=dpi)
7070

71+
def __del__(self):
72+
if hasattr(self, "fig") and self.fig is not None:
73+
plt.close(self.fig)
74+
self.fig = None
75+
7176
@abc.abstractmethod
7277
def _define_ax(
7378
self, axis: Optional[matplotlib.axes.Axes]) -> matplotlib.axes.Axes:

0 commit comments

Comments
 (0)