Skip to content

Commit a8c3e63

Browse files
committed
Refactor all pytest of analysis.py routines
1 parent 63caadf commit a8c3e63

19 files changed

+395
-148
lines changed

slycot/tests/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
set(PYSOURCE
22

33
__init__.py
4-
test_ab01.py
4+
test_ab01nd.py
55
test_ab04md.py
6+
test_ab05md.py
7+
test_ab05nd.py
8+
test_ab07nd.py
69
test_ab08n.py
10+
test_ab08nd.py
11+
test_ab08nz.py
12+
test_ab09ad.py
13+
test_ab09ax.py
14+
test_ab09bd.py
15+
test_ab09md.py
16+
test_ab09nd.py
17+
test_ab13bd.py
18+
test_ab13dd.py
19+
test_ab13ed.py
20+
test_ab13fd.py
21+
test_ab13md.py
722
test_ag08bd.py
23+
test_analysis.py
824
test_examples.py
925
test_exceptions.py
1026
test_mb.py
1127
test_mc.py
1228
test_sb.py
13-
test_analysis.py
1429
test_transform.py
1530
test_sg02ad.py
1631
test_sg03ad.py

slycot/tests/test_ab01.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

slycot/tests/test_ab01nd.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""
2+
Test ab01 wrappers
3+
4+
@author: bnavigator
5+
"""
6+
7+
from numpy import array
8+
from numpy.testing import assert_allclose, assert_equal
9+
from scipy.linalg.lapack import dorgqr
10+
11+
from slycot.analysis import ab01nd
12+
13+
14+
class Test_ab01nd:
15+
16+
def test_ab01nd(self):
17+
"""SLICOT doc example
18+
19+
http://slicot.org/objects/software/shared/doc/AB01ND.html"""
20+
21+
# Example program data
22+
n = 3
23+
m = 2
24+
tol = 0.0
25+
26+
A = array([[-1., 0., 0.],
27+
[-2., -2., -2.],
28+
[-1., 0., -3.]])
29+
B = array([[1., 0.],
30+
[0, 2.],
31+
[0., 1.]])
32+
33+
for jobz in ['N', 'I', 'F']:
34+
Ac, Bc, ncont, indcon, nblk, Z, tau = ab01nd(n, m, A, B,
35+
jobz=jobz, tol=tol)
36+
37+
# The transformed state dynamics matrix of a controllable realization
38+
assert_allclose(Ac[:ncont, :ncont], array([[-3.0000, 2.2361],
39+
[ 0.0000, -1.0000]]),
40+
atol=0.0001)
41+
42+
# and the dimensions of its diagonal blocks are
43+
assert_equal(nblk[:indcon], array([2]))
44+
45+
# The transformed input/state matrix B of a controllable realization
46+
assert_allclose(Bc[:ncont, :],array([[ 0.0000, -2.2361],
47+
[ 1.0000, 0.0000]]),
48+
atol=0.0001)
49+
50+
# The controllability index of the transformed system representation
51+
assert indcon == 1
52+
53+
if jobz == 'N':
54+
assert Z is None
55+
continue
56+
elif jobz == 'I':
57+
Z_ = Z
58+
elif jobz == 'F':
59+
Z_, _, info = dorgqr(Z, tau)
60+
assert info == 0
61+
62+
# The similarity transformation matrix Z
63+
assert_allclose(Z_, array([[ 0.0000, 1.0000, 0.0000],
64+
[-0.8944, 0.0000, -0.4472],
65+
[-0.4472, 0.0000, 0.8944]]),
66+
atol=0.0001)
67+

slycot/tests/test_ab05md.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import numpy as np
2+
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
4+
from scipy import linalg, signal
5+
6+
from slycot import analysis
7+
8+
9+
class Test_ab05md:
10+
11+
@pytest.mark.skip("not implemented yet, TODO")
12+
def test_ab05md():
13+
pass

slycot/tests/test_ab05nd.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pytest
2+
3+
from slycot import analysis
4+
from slycot.exceptions import SlycotArithmeticError
5+
6+
from .test_exceptions import assert_docstring_parse
7+
8+
9+
class Test_ab05nd:
10+
11+
@pytest.mark.parametrize(
12+
'fun, exception_class, erange, checkvars',
13+
((analysis.ab05nd, SlycotArithmeticError, 1, {'p1': 1}),))
14+
def test_ab_docparse(self, fun, exception_class, erange, checkvars):
15+
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)

slycot/tests/test_ab07nd.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import numpy as np
2+
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
4+
from scipy import linalg, signal
5+
6+
from slycot import analysis
7+
8+
9+
class Test_ab07nd:
10+
11+
@pytest.mark.skip("not implemented yet, TODO")
12+
def test_ab07nd():
13+
pass

slycot/tests/test_ab08nd.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import numpy as np
2+
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
4+
from scipy import linalg, signal
5+
6+
from slycot import analysis
7+
8+
9+
class Test_ab08nd:
10+
11+
@pytest.mark.skip("not implemented yet, TODO")
12+
def test_ab08nd():
13+
pass

slycot/tests/test_ab08nz.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import numpy as np
2+
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
4+
from scipy import linalg, signal
5+
6+
from slycot import analysis
7+
8+
9+
class Test_ab08nz:
10+
11+
@pytest.mark.skip("not implemented yet, TODO")
12+
def test_ab08nz():
13+
pass

slycot/tests/test_ab09ad.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import numpy as np
2+
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
4+
from scipy import linalg, signal
5+
6+
from slycot import analysis
7+
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning
8+
9+
from .test_exceptions import assert_docstring_parse
10+
11+
12+
class Test_ab09ad:
13+
14+
@pytest.mark.parametrize(
15+
'fun, exception_class, erange, checkvars',
16+
((analysis.ab09ad, SlycotArithmeticError, 3, {'dico': 'C'}),
17+
(analysis.ab09ad, SlycotArithmeticError, (2,), {'dico': 'D'}),
18+
(analysis.ab09ad, SlycotResultWarning, ((1, 0), ), {'nr': 3,
19+
'Nr': 2}),))
20+
def test_ab09ad_docparse(self, fun, exception_class, erange, checkvars):
21+
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)

slycot/tests/test_ab09ax.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import numpy as np
2+
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
4+
from scipy import linalg, signal
5+
6+
from slycot import analysis
7+
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning
8+
9+
from .test_exceptions import assert_docstring_parse
10+
11+
12+
class Test_ab09ax:
13+
14+
@pytest.mark.parametrize(
15+
'fun, exception_class, erange, checkvars',
16+
((analysis.ab09ax, SlycotArithmeticError, 2, {'dico': 'C'}),
17+
(analysis.ab09ax, SlycotResultWarning, ((1, 0), ), {'nr': 3, 'Nr': 2}),))
18+
def test_ab09ax_docparse(self, fun, exception_class, erange, checkvars):
19+
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)

slycot/tests/test_ab09bd.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import numpy as np
2+
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
4+
from scipy import linalg, signal
5+
6+
from slycot import analysis
7+
8+
9+
class Test_ab09bd:
10+
11+
@pytest.mark.skip("not implemented yet, TODO")
12+
def test_ab09bd():
13+
pass

slycot/tests/test_ab09md.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import numpy as np
2+
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
4+
from scipy import linalg, signal
5+
6+
7+
from slycot import analysis
8+
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning
9+
10+
from .test_exceptions import assert_docstring_parse
11+
12+
13+
class Test_ab09md:
14+
15+
@pytest.mark.parametrize(
16+
'fun, exception_class, erange, checkvars',
17+
((analysis.ab09md, SlycotArithmeticError, 3, {'alpha': -0.1}),
18+
(analysis.ab09md, SlycotResultWarning, ((1, 0), (2, 0)), {'nr': 3,
19+
'Nr': 2,
20+
'alpha': -0.1}),))
21+
def test_ab09md_docparse(self, fun, exception_class, erange, checkvars):
22+
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)

slycot/tests/test_ab09nd.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import numpy as np
2+
import pytest
3+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
4+
from scipy import linalg, signal
5+
6+
from slycot import analysis
7+
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning
8+
9+
from .test_exceptions import assert_docstring_parse
10+
11+
12+
class Test_ab09nd:
13+
14+
@pytest.mark.parametrize(
15+
'fun, exception_class, erange, checkvars',
16+
((analysis.ab09nd, SlycotArithmeticError, 3, {'alpha': -0.1}),
17+
(analysis.ab09nd, SlycotResultWarning, ((1, 0), (2, 0)), {'nr': 3,
18+
'Nr': 2,
19+
'alpha': -0.1}),))
20+
def test_ab09nd_docparse(self, fun, exception_class, erange, checkvars):
21+
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)

slycot/tests/test_ab13bd.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
# ab08n* tests
33

44
import numpy as np
5+
import pytest
56
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
67
from scipy import linalg, signal
78

89
from slycot import analysis
10+
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning
11+
12+
from .test_exceptions import assert_docstring_parse
913

1014

1115
class Test_ab13bd:
@@ -19,6 +23,13 @@ class Test_ab13bd:
1923

2024
Ad, Bd, Cd, Dd, dt = signal.cont2discrete((A, B, C, D), 0.1, method='zoh')
2125

26+
@pytest.mark.parametrize(
27+
'fun, exception_class, erange, checkvars',
28+
((analysis.ab13bd, SlycotArithmeticError, 6, {'dico': 'C'}),
29+
(analysis.ab13bd, SlycotResultWarning, ((1, 0),), {}),))
30+
def test_ab13bd_docparse(self, fun, exception_class, erange, checkvars):
31+
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)
32+
2233
def test_no_change_args_ccase(self):
2334
""" ab13md must not change its arguments. continuous system case.
2435
"""

0 commit comments

Comments
 (0)