Skip to content

Commit 1c8c7fa

Browse files
bugfixes for plotting
1 parent 71e8314 commit 1c8c7fa

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

sbmlsim/experiment/experiment.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

sbmlsim/experiment/report.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
from pathlib import Path
1111
from enum import Enum
1212

13-
from sbmlsim.experiment import SimulationExperiment, ExperimentResult
1413
from sbmlsim import __version__
14+
from sbmlsim.experiment import SimulationExperiment, ExperimentResult
1515
from sbmlsim import BASE_PATH
1616

17-
1817
TEMPLATE_PATH = BASE_PATH / "experiment" / "templates"
1918
logger = logging.getLogger(__name__)
2019

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
33
"""
4-
sbmlutils pip package
4+
sbmlsim pip package
55
"""
66
import io
77
import re

0 commit comments

Comments
 (0)