Skip to content

Commit fc5fdfb

Browse files
committed
close_figures defaults to closing all figures
1 parent 171f8db commit fc5fdfb

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

gnss_lib_py/utils/visualizations.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,17 +521,22 @@ def plot_map(*args, sections=0, save=False, prefix="",
521521
width=width, height=height)
522522
return figs
523523

524-
def close_figures(figs):
524+
def close_figures(figs=None):
525525
"""Closes figures.
526526
527+
If figs is None, then will attempt to close all matplotlib figures
528+
with plt.close('all')
529+
527530
Parameters
528531
----------
529-
figs : list or matplotlib.pyplot.figure
532+
figs : list or matplotlib.pyplot.figure or None
530533
List of figures or single matplotlib figure object.
531534
532535
"""
533536

534-
if isinstance(figs,plt.Figure):
537+
if figs is None:
538+
plt.close('all')
539+
elif isinstance(figs,plt.Figure):
535540
plt.close(figs)
536541
elif isinstance(figs, list):
537542
for fig in figs:

tests/utils/test_visualizations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def test_plot_metrics_by_constellation(derived):
309309
for prefix in ["","test"]:
310310
fig = viz.plot_metric_by_constellation(derived, row,
311311
prefix=prefix,save=False)
312-
viz.close_figures(fig)
312+
viz.close_figures()
313313
else:
314314
# string rows should cause a KeyError
315315
with pytest.raises(KeyError) as excinfo:

0 commit comments

Comments
 (0)