Skip to content

Commit

Permalink
add more tests of the exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
repagh committed May 11, 2020
1 parent 4ab8e2d commit 429989b
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 3 deletions.
2 changes: 1 addition & 1 deletion slycot/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@ def ab13fd(n, A, tol = 0.0):
'dwork' + hidden, 'ldwork' + hidden, 'cwork' + hidden,
'lcwork' + hidden, 'info' + hidden]
out = _wrapper.ab13fd(n, A, tol)
raise_if_slycot_error(out[-1], arg_list, ab13fd.__dict__)
raise_if_slycot_error(out[-1], arg_list, ab13fd.__doc__)
return out[0], out[1]

def ag08bd(l,n,m,p,A,E,B,C,D,equil='N',tol=0.0,ldwork=None):
Expand Down
2 changes: 1 addition & 1 deletion slycot/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,7 @@ def sg03ad(dico,job,fact,trans,uplo,N,A,E,Q,Z,X,ldwork=None):

out = _wrapper.sg03ad(dico,job,fact,trans,uplo,N,A,E,Q,Z,X,ldwork)

raise_if_slycot_error(out[-1], arg_list, sg03ad.__dict__)
raise_if_slycot_error(out[-1], arg_list, sg03ad.__doc__)

return out[:-1]

Expand Down
2 changes: 2 additions & 0 deletions slycot/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set(PYSOURCE
test_mb.py
test_mc.py
test_sb.py
test_analysis.py
test_transform.py
test_sg02ad.py
test_sg03ad.py
test_tb05ad.py
Expand Down
44 changes: 44 additions & 0 deletions slycot/tests/test_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python
#
# test_ab.py - generic tests for analysis programs
# repagh <[email protected], May 2020

import pytest
from .test_exceptions import assert_docstring_parse
from slycot import analysis
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning


@pytest.mark.parametrize(
'fun, exception_class, erange, checkvars',
((analysis.ab05nd, SlycotArithmeticError, 1, {'p1': 1}),
(analysis.ab07nd, SlycotResultWarning, 2, {'m': 1}),
(analysis.ab09ad, SlycotArithmeticError, 3, {'dico': 'C'}),
(analysis.ab09ad, SlycotArithmeticError, (2,), {'dico': 'D'}),
(analysis.ab09ad, SlycotResultWarning, ((1, 0), ), {'nr': 3,
'Nr': 2}),
(analysis.ab09ax, SlycotArithmeticError, 2, {'dico': 'C'}),
(analysis.ab09ax, SlycotResultWarning, ((1, 0), ), {'nr': 3,
'Nr': 2}),
(analysis.ab09ad, SlycotArithmeticError, 3, {'dico': 'C'}),
(analysis.ab09ad, SlycotResultWarning, ((1, 0), ), {'nr': 3,
'Nr': 2}),
(analysis.ab09md, SlycotArithmeticError, 3, {'alpha': -0.1}),
(analysis.ab09md, SlycotResultWarning, ((1, 0), (2, 0)), {'nr': 3,
'Nr': 2,
'alpha': -0.1}),
(analysis.ab09nd, SlycotArithmeticError, 3, {'alpha': -0.1}),
(analysis.ab09nd, SlycotResultWarning, ((1, 0), (2, 0)), {'nr': 3,
'Nr': 2,
'alpha': -0.1}),
(analysis.ab13bd, SlycotArithmeticError, 6, {'dico': 'C'}),
(analysis.ab13bd, SlycotResultWarning, ((1, 0),), {}),
(analysis.ab13dd, SlycotArithmeticError, 4, {}),
(analysis.ab13ed, SlycotArithmeticError, 1, {}),
(analysis.ab13fd, SlycotArithmeticError, (2,), {}),
(analysis.ab13fd, SlycotResultWarning, (1,), {})))
def test_ab_docparse(fun, exception_class, erange, checkvars):
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)



17 changes: 16 additions & 1 deletion slycot/tests/test_mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

import sys
import unittest
import pytest

from slycot import math
from slycot import mb03rd, mb03vd, mb03vy, mb03wd, mb05md, mb05nd
from slycot.exceptions import SlycotResultWarning
from slycot.exceptions import SlycotResultWarning, SlycotArithmeticError
from .test_exceptions import assert_docstring_parse

import numpy as np
from scipy.linalg import schur
Expand Down Expand Up @@ -306,5 +309,17 @@ def test_mb05nd(self):
assert_allclose(H, H_ref, atol=0.0001)


@pytest.mark.parametrize(
'fun, exception_class, erange, checkvars',
((math.mb03wd, SlycotResultWarning, (4,), {'ilo': 2,
'ihi': 5}),
(math.mb05md, SlycotResultWarning, (2, 3, 4), {'n': 2}),
(math.mb05nd, SlycotArithmeticError, (2, 3), {'n': 2,
'delta': 1000}),
(math.mc01td, SlycotResultWarning, (1, 2, (1, 0)), {'dico': 'C'})))
def test_mb_docparse(fun, exception_class, erange, checkvars):
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)


if __name__ == "__main__":
unittest.main()
21 changes: 21 additions & 0 deletions slycot/tests/test_transform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
#
# test_transform.py - generic tests for transform routines
# repagh <[email protected], May 2020

import pytest
from .test_exceptions import assert_docstring_parse
from slycot import transform as tf
from slycot.exceptions import SlycotArithmeticError


@pytest.mark.parametrize(
'fun, exception_class, erange, checkvars',
((tf.tb03ad, SlycotArithmeticError, 2, {}),
(tf.tb05ad, SlycotArithmeticError, 2, {'n30': 90,
'jomega': 2.0,
'rcond': 1e-12}),
(tf.td04ad, SlycotArithmeticError, (3,), {}),
(tf.tc04ad, SlycotArithmeticError, 1, {'leri': 'L'})))
def test_transform_docparse(fun, exception_class, erange, checkvars):
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)

0 comments on commit 429989b

Please sign in to comment.