@@ -267,6 +267,7 @@ def run(self, simulator, output_path: Path = None, show_figures: bool = True,
267267 self .show_figures (mpl_figures = mpl_figures )
268268 if output_path :
269269 self .save_figures (output_path , mpl_figures = mpl_figures )
270+ self .clear_figures (mpl_figures = mpl_figures )
270271
271272 return ExperimentResult (experiment = self , output_path = output_path )
272273
@@ -420,9 +421,13 @@ def create_mpl_figures(self) -> Dict[str, FigureMPL]:
420421
421422 @timeit
422423 def show_figures (self , mpl_figures : Dict [str , FigureMPL ]):
423- # plt.show()
424- pool = multiprocessing .Pool ()
425- pool .map (self ._show_figure , mpl_figures .values ())
424+
425+ for fig_key , fig_mpl in mpl_figures .items ():
426+ fig_mpl .show ()
427+
428+ # multiprocessing with matplotlib creates issues
429+ # pool = multiprocessing.Pool()
430+ # pool.map(self._show_figure, mpl_figures.values())
426431 # pool.map_async(self._show_figure, mpl_figures.values())
427432
428433 @staticmethod
@@ -439,21 +444,25 @@ def save_figures(self, results_path: Path, mpl_figures: Dict[str, FigureMPL]) ->
439444 """
440445 paths = []
441446 input = []
442- for fkey , fig_mpl in mpl_figures .items ():
447+ for fkey , fig_mpl in mpl_figures .items (): # type
443448 path_svg = results_path / f"{ self .sid } _{ fkey } .svg"
444449 fig_mpl .savefig (path_svg , bbox_inches = "tight" )
445450 # fig_mpl.savefig(path_png, bbox_inches="tight")
446451
447452 input .append ([path_svg , fig_mpl ])
448453 paths .append (path_svg )
449454
450- # multiprocessing of figures
451- pool = multiprocessing .Pool ()
452- pool .map (self ._save_figure , input )
455+ # multiprocessing of figures (problems in travis)
456+ # pool = multiprocessing.Pool()
457+ # pool.map(self._save_figure, input)
453458 # pool.map_async(self._save_figure, input)
454459
455460 return paths
456461
462+ def clear_figures (self , mpl_figures : Dict [str , FigureMPL ]):
463+ for fig_key , fig_mpl in mpl_figures .items ():
464+ plt .close (fig_mpl )
465+
457466 @staticmethod
458467 def _save_figure (args ):
459468 path_svg , fig_mpl = args
0 commit comments