Unverified Commit 45b08f59 authored by Peter Oehme's avatar Peter Oehme Committed by René Fritze
Browse files

Adds decorator in favour of manually checking dependencies

parent aa1001aa
......@@ -18,6 +18,7 @@ from pymor.algorithms.lyapunov import (
)
from pymor.core.config import config
from pymor.operators.numpy import NumpyMatrixOperator
from pymortests.base import skip_if_missing
n_list_small = [10, 20]
n_list_big = [300]
......@@ -118,25 +119,14 @@ def relative_residual(A, E, B, X, cont_time, trans=False):
return res / rhs
def _check_availability(lyap_solver):
if (lyap_solver.startswith('slycot')
and not os.environ.get('DOCKER_PYMOR', False)
and not config.HAVE_SLYCOT):
pytest.skip('slycot not available')
if (lyap_solver.startswith('pymess')
and not os.environ.get('DOCKER_PYMOR', False)
and not config.HAVE_PYMESS):
pytest.skip('pymess not available')
@pytest.mark.parametrize('m', m_list)
@pytest.mark.parametrize('with_E', [False, True])
@pytest.mark.parametrize('trans', [False, True])
@pytest.mark.parametrize('n,lyap_solver', chain(product(n_list_small, cont_lyap_dense_solver_list),
product(n_list_big, cont_lyap_lrcf_solver_list)))
@skip_if_missing('slycot')
@skip_if_missing('pymess')
def test_cont_lrcf(n, m, with_E, trans, lyap_solver):
_check_availability(lyap_solver)
if not with_E:
A = conv_diff_1d_fd(n, 1, 0.1, cont_time=True)
E = None
......@@ -163,6 +153,8 @@ def test_cont_lrcf(n, m, with_E, trans, lyap_solver):
@pytest.mark.parametrize('with_E', [False, True])
@pytest.mark.parametrize('trans', [False, True])
@pytest.mark.parametrize('lyap_solver', disc_lyap_dense_solver_list)
@skip_if_missing('slycot')
@skip_if_missing('pymess')
def test_disc_lrcf(n, m, with_E, trans, lyap_solver):
_check_availability(lyap_solver)
......@@ -193,9 +185,9 @@ def test_disc_lrcf(n, m, with_E, trans, lyap_solver):
@pytest.mark.parametrize('with_E', [False, True])
@pytest.mark.parametrize('trans', [False, True])
@pytest.mark.parametrize('lyap_solver', cont_lyap_dense_solver_list)
@skip_if_missing('slycot')
@skip_if_missing('pymess')
def test_cont_dense(n, m, with_E, trans, lyap_solver):
_check_availability(lyap_solver)
np.random.seed(0)
A = np.random.randn(n, n)
E = np.eye(n) + np.random.randn(n, n) / n if with_E else None
......@@ -214,9 +206,9 @@ def test_cont_dense(n, m, with_E, trans, lyap_solver):
@pytest.mark.parametrize('with_E', [False, True])
@pytest.mark.parametrize('trans', [False, True])
@pytest.mark.parametrize('lyap_solver', disc_lyap_dense_solver_list)
@skip_if_missing('slycot')
@skip_if_missing('pymess')
def test_disc_dense(n, m, with_E, trans, lyap_solver):
_check_availability(lyap_solver)
np.random.seed(0)
A = np.random.randn(n, n)
E = np.eye(n) + np.random.randn(n, n) / n if with_E else None
......
......@@ -11,7 +11,8 @@ import scipy.linalg as spla
from pymor.algorithms.lyapunov import _chol
from pymor.algorithms.riccati import solve_pos_ricc_lrcf, solve_ricc_dense, solve_ricc_lrcf
from pymor.operators.numpy import NumpyMatrixOperator
from pymortests.lyapunov import _check_availability, conv_diff_1d_fd, conv_diff_1d_fem, fro_norm
from pymortests.lyapunov import conv_diff_1d_fd, conv_diff_1d_fem, fro_norm
from pymortests.base import skip_if_missing
n_list_small = [10, 20]
n_list_big = [250]
......@@ -68,9 +69,9 @@ def relative_residual(A, E, B, C, R, Z, trans):
@pytest.mark.parametrize('trans', [False, True])
@pytest.mark.parametrize('n', n_list_small)
@pytest.mark.parametrize('solver', ricc_dense_solver_list)
@skip_if_missing('slycot')
@skip_if_missing('pymess')
def test_ricc_dense(n, m, p, with_E, with_R, trans, solver):
_check_availability(solver)
if not with_E:
A = conv_diff_1d_fd(n, 1, 1)
A = A.todense()
......@@ -102,9 +103,9 @@ def test_ricc_dense(n, m, p, with_E, with_R, trans, solver):
@pytest.mark.parametrize('trans', [False, True])
@pytest.mark.parametrize('n,solver', chain(product(n_list_small, ricc_lrcf_solver_list_small),
product(n_list_big, ricc_lrcf_solver_list_big)))
@skip_if_missing('slycot')
@skip_if_missing('pymess')
def test_ricc_lrcf(n, m, p, with_E, with_R, trans, solver):
_check_availability(solver)
if not with_E:
A = conv_diff_1d_fd(n, 1, 1)
E = None
......@@ -144,9 +145,9 @@ def test_ricc_lrcf(n, m, p, with_E, with_R, trans, solver):
@pytest.mark.parametrize('with_R', [False, True])
@pytest.mark.parametrize('trans', [False, True])
@pytest.mark.parametrize('solver', ricc_lrcf_solver_list_small)
@skip_if_missing('slycot')
@skip_if_missing('pymess')
def test_pos_ricc_lrcf(n, m, p, with_E, with_R, trans, solver):
_check_availability(solver)
if not with_E:
A = conv_diff_1d_fd(n, 1, 1)
E = None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment