Skip to content

Commit 1550852

Browse files
authored
Merge pull request #207 from bnavigator/remove-unittest
Replace unittest calls with pytest
2 parents 4401437 + 36a44f7 commit 1550852

19 files changed

+967
-1022
lines changed

slycot/tests/test_ab01.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from numpy import array
88
from numpy.testing import assert_allclose, assert_equal
9-
109
from scipy.linalg.lapack import dorgqr
1110

1211
from slycot.analysis import ab01nd

slycot/tests/test_ab04md.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from slycot import analysis
21
import numpy as np
3-
42
from numpy.testing import assert_allclose
53

4+
from slycot import analysis
5+
66

7-
class test_ab04md:
7+
class Test_ab04md:
88
"""Test ab04md.
99
1010
Example data taken from

slycot/tests/test_ab08n.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# ===================================================
22
# ab08n* tests
33

4-
import unittest
5-
from slycot import analysis
64
import numpy as np
7-
5+
from numpy.testing import assert_allclose, assert_equal
86
from scipy.linalg import eig
9-
from numpy.testing import assert_equal, assert_allclose
7+
8+
from slycot import analysis
109

1110

12-
class test_ab08nX(unittest.TestCase):
11+
class Test_ab08nX:
1312
""" Test regular pencil construction ab08nX with input parameters
1413
according to example in documentation """
1514

@@ -77,7 +76,3 @@ def test_ab08nz(self):
7776
Ac, Bc, Cc, Dc = [M.astype(np.complex128) for M in [self.A, self.B,
7877
self.C, self.D]]
7978
self.ab08nX(analysis.ab08nz, Ac, Bc, Cc, Dc)
80-
81-
82-
if __name__ == "__main__":
83-
unittest.main()

slycot/tests/test_ab13bd.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# ===================================================
22
# ab08n* tests
33

4-
import unittest
5-
from slycot import analysis
64
import numpy as np
5+
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
6+
from scipy import linalg, signal
7+
8+
from slycot import analysis
79

8-
from scipy import linalg
9-
from scipy import signal
10-
from numpy.testing import assert_equal, assert_allclose, assert_array_equal
1110

12-
class test_ab13bd(unittest.TestCase):
11+
class Test_ab13bd:
1312
""" Test regular pencil construction ab08nX with input parameters
1413
according to example in documentation """
1514

@@ -118,6 +117,3 @@ def test_ab13bd_2norm_dcase(self):
118117
print(h2norm, h2norm_Lo)
119118
assert_allclose(h2norm_Lo, h2norm, atol=1e-5)
120119

121-
122-
if __name__ == "__main__":
123-
unittest.main()

slycot/tests/test_ab13md.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import numpy as np
2-
from numpy.testing import assert_allclose, assert_array_less
3-
42
import pytest
3+
from numpy.testing import assert_allclose, assert_array_less
54

65
from slycot import ab13md
76

slycot/tests/test_ag08bd.py

Lines changed: 70 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# ===================================================
2-
# ag08bd tests
1+
"""Verify ag08bd with input parameters according to example in documentation."""
32

4-
import unittest
5-
from slycot import analysis
63
import numpy as np
7-
84
from numpy.testing import assert_almost_equal, assert_equal
95

6+
from slycot import analysis
7+
108
# test1 input parameters
119

1210
test1_l = 9
@@ -47,77 +45,70 @@
4745
[ 0, 0, 0]])
4846

4947

50-
class test_ag08bd(unittest.TestCase):
51-
"""Verify ag08bd with input parameters according to example in documentation."""
52-
53-
def test1_ag08bd(self):
54-
"""test [A-lambda*E]
55-
56-
B,C,D must have correct dimensions according to l,n,m and p, but cannot
57-
have zero length in any dimenstion. Then the wrapper will complain.
58-
The length is then set to one.
59-
"""
60-
61-
Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=0,p=0,A=test1_A,E=test1_E,B=np.zeros((test1_l,1)),C=np.zeros((1,test1_n)),D=np.zeros((1,1)),equil=test1_equil, tol=test1_tol)
62-
63-
assert_equal(Af, np.zeros((0,0)))
64-
assert_equal(Ef, np.zeros((0,0)))
65-
assert_equal(nrank, 9)
66-
assert_equal(niz, 6)
67-
assert_equal(infz, [0,3])
68-
assert_equal(kronr, [])
69-
assert_equal(infe, [3,3,3])
70-
assert_equal(kronl, [])
71-
72-
def test2_ag08bd(self):
73-
"""test [A-lambda*E;C]
74-
75-
B,D must have correct dimensions as before
76-
"""
77-
78-
Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=0,p=test1_p,A=test1_A,E=test1_E,B=np.zeros((test1_l,1)),C=test1_C,D=np.zeros((test1_p,1)),equil=test1_equil, tol=test1_tol)
79-
80-
assert_equal(Af, np.zeros((0,0)))
81-
assert_equal(Ef, np.zeros((0,0)))
82-
assert_equal(nrank, 9)
83-
assert_equal(niz, 4)
84-
assert_equal(infz, [0,2])
85-
assert_equal(kronr, [])
86-
assert_equal(infe, [1,3,3])
87-
assert_equal(kronl, [0,1,1])
88-
89-
def test3_ag08bd(self):
90-
"""test [A-lambda*E,B]
91-
92-
C,D must have correct dimensions as before
93-
"""
94-
95-
Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=test1_m,p=0,A=test1_A,E=test1_E,B=test1_B,C=np.zeros((1,test1_n)),D=np.zeros((1,test1_m)),equil=test1_equil, tol=test1_tol)
96-
97-
assert_equal(Af, np.zeros((0,0)))
98-
assert_equal(Ef, np.zeros((0,0)))
99-
assert_equal(nrank, 9)
100-
assert_equal(niz, 0)
101-
assert_equal(infz, [])
102-
assert_equal(kronr, [2,2,2])
103-
assert_equal(infe, [1,1,1])
104-
assert_equal(kronl, [])
105-
106-
def test4_ag08bd(self):
107-
"""test [A-lambda*E,B;C,D]"""
108-
109-
Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=test1_m,p=test1_p,A=test1_A,E=test1_E,B=test1_B,C=test1_C,D=test1_D,equil=test1_equil, tol=test1_tol)
110-
111-
# Af-lambda*Ef==0. => lambda==1. => Finite Smith zero of S(lambda) == 1.
112-
assert Af.shape == (1, 1)
113-
assert_almost_equal(Af, Ef)
114-
assert_equal(nrank, 11)
115-
assert_equal(niz, 2)
116-
assert_equal(infz, [0,1])
117-
assert_equal(kronr, [2])
118-
assert_equal(infe, [1,1,1,1,3])
119-
assert_equal(kronl, [1])
120-
121-
122-
if __name__ == "__main__":
123-
unittest.main()
48+
def test1_ag08bd():
49+
"""test [A-lambda*E]
50+
51+
B,C,D must have correct dimensions according to l,n,m and p, but cannot
52+
have zero length in any dimenstion. Then the wrapper will complain.
53+
The length is then set to one.
54+
"""
55+
56+
Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=0,p=0,A=test1_A,E=test1_E,B=np.zeros((test1_l,1)),C=np.zeros((1,test1_n)),D=np.zeros((1,1)),equil=test1_equil, tol=test1_tol)
57+
58+
assert_equal(Af, np.zeros((0,0)))
59+
assert_equal(Ef, np.zeros((0,0)))
60+
assert_equal(nrank, 9)
61+
assert_equal(niz, 6)
62+
assert_equal(infz, [0,3])
63+
assert_equal(kronr, [])
64+
assert_equal(infe, [3,3,3])
65+
assert_equal(kronl, [])
66+
67+
def test2_ag08bd():
68+
"""test [A-lambda*E;C]
69+
70+
B,D must have correct dimensions as before
71+
"""
72+
73+
Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=0,p=test1_p,A=test1_A,E=test1_E,B=np.zeros((test1_l,1)),C=test1_C,D=np.zeros((test1_p,1)),equil=test1_equil, tol=test1_tol)
74+
75+
assert_equal(Af, np.zeros((0,0)))
76+
assert_equal(Ef, np.zeros((0,0)))
77+
assert_equal(nrank, 9)
78+
assert_equal(niz, 4)
79+
assert_equal(infz, [0,2])
80+
assert_equal(kronr, [])
81+
assert_equal(infe, [1,3,3])
82+
assert_equal(kronl, [0,1,1])
83+
84+
def test3_ag08bd():
85+
"""test [A-lambda*E,B]
86+
87+
C,D must have correct dimensions as before
88+
"""
89+
90+
Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=test1_m,p=0,A=test1_A,E=test1_E,B=test1_B,C=np.zeros((1,test1_n)),D=np.zeros((1,test1_m)),equil=test1_equil, tol=test1_tol)
91+
92+
assert_equal(Af, np.zeros((0,0)))
93+
assert_equal(Ef, np.zeros((0,0)))
94+
assert_equal(nrank, 9)
95+
assert_equal(niz, 0)
96+
assert_equal(infz, [])
97+
assert_equal(kronr, [2,2,2])
98+
assert_equal(infe, [1,1,1])
99+
assert_equal(kronl, [])
100+
101+
def test4_ag08bd():
102+
"""test [A-lambda*E,B;C,D]"""
103+
104+
Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=test1_m,p=test1_p,A=test1_A,E=test1_E,B=test1_B,C=test1_C,D=test1_D,equil=test1_equil, tol=test1_tol)
105+
106+
# Af-lambda*Ef==0. => lambda==1. => Finite Smith zero of S(lambda) == 1.
107+
assert Af.shape == (1, 1)
108+
assert_almost_equal(Af, Ef)
109+
assert_equal(nrank, 11)
110+
assert_equal(niz, 2)
111+
assert_equal(infz, [0,1])
112+
assert_equal(kronr, [2])
113+
assert_equal(infe, [1,1,1,1,3])
114+
assert_equal(kronl, [1])

slycot/tests/test_analysis.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# repagh <rene.vanpaassen@gmail.com, May 2020
44

55
import pytest
6-
from .test_exceptions import assert_docstring_parse
6+
77
from slycot import analysis
88
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning
99

10+
from .test_exceptions import assert_docstring_parse
11+
1012

1113
@pytest.mark.parametrize(
1214
'fun, exception_class, erange, checkvars',

slycot/tests/test_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
from inspect import getmembers, isfunction
9+
910
import pytest
1011

1112
from slycot import examples

slycot/tests/test_exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
import pytest
2626

27-
from slycot.exceptions import raise_if_slycot_error, \
28-
SlycotError, SlycotWarning, SlycotParameterError
2927
from slycot import _wrapper
28+
from slycot.exceptions import (SlycotError, SlycotParameterError,
29+
SlycotWarning, raise_if_slycot_error)
3030

3131

3232
def assert_docstring_parse(docstring, exception_class, erange, checkvars={}):

0 commit comments

Comments
 (0)