Skip to content

Commit

Permalink
close figures
Browse files Browse the repository at this point in the history
  • Loading branch information
yannikschaelte committed Aug 25, 2023
1 parent 677b6fd commit 736ad58
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/base/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
These tests are not for correctness, but for basic functionality.
"""

from functools import wraps

import matplotlib.pyplot as plt

import pypesto
import pypesto.optimize as optimize
import pypesto.profile as profile
Expand All @@ -12,6 +16,18 @@
from ..util import CRProblem


def close_fig(fun):
"""Close figure."""

@wraps(fun)
def wrapped_fun(*args, **kwargs):
ret = fun(*args, **kwargs)
plt.close('all')
return ret

return wrapped_fun


def test_objective():
"""Test a simple objective function."""
crproblem = CRProblem()
Expand All @@ -27,6 +43,7 @@ def test_objective():
assert (grad == crproblem.get_fsnllh()(p)).all()


@close_fig
def test_optimize():
"""Test a simple multi-start optimization."""
crproblem = CRProblem()
Expand Down Expand Up @@ -59,6 +76,7 @@ def test_optimize():
visualize.waterfall(result)


@close_fig
def test_profile():
"""Test a simple profile calculation."""
crproblem = CRProblem()
Expand Down Expand Up @@ -88,6 +106,7 @@ def test_profile():
visualize.profiles(profile_result)


@close_fig
def test_sample():
"""Test a simple sampling."""
crproblem = CRProblem()
Expand Down

0 comments on commit 736ad58

Please sign in to comment.