Skip to content

Commit

Permalink
replace unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
bnavigator committed Aug 25, 2023
1 parent 4401437 commit 0175171
Show file tree
Hide file tree
Showing 11 changed files with 930 additions and 990 deletions.
2 changes: 1 addition & 1 deletion slycot/tests/test_ab04md.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from numpy.testing import assert_allclose


class test_ab04md:
class Test_ab04md:
"""Test ab04md.
Example data taken from
Expand Down
7 changes: 1 addition & 6 deletions slycot/tests/test_ab08n.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# ===================================================
# ab08n* tests

import unittest
from slycot import analysis
import numpy as np

from scipy.linalg import eig
from numpy.testing import assert_equal, assert_allclose


class test_ab08nX(unittest.TestCase):
class Test_ab08nX:
""" Test regular pencil construction ab08nX with input parameters
according to example in documentation """

Expand Down Expand Up @@ -77,7 +76,3 @@ def test_ab08nz(self):
Ac, Bc, Cc, Dc = [M.astype(np.complex128) for M in [self.A, self.B,
self.C, self.D]]
self.ab08nX(analysis.ab08nz, Ac, Bc, Cc, Dc)


if __name__ == "__main__":
unittest.main()
6 changes: 1 addition & 5 deletions slycot/tests/test_ab13bd.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# ===================================================
# ab08n* tests

import unittest
from slycot import analysis
import numpy as np

from scipy import linalg
from scipy import signal
from numpy.testing import assert_equal, assert_allclose, assert_array_equal

class test_ab13bd(unittest.TestCase):
class Test_ab13bd:
""" Test regular pencil construction ab08nX with input parameters
according to example in documentation """

Expand Down Expand Up @@ -118,6 +117,3 @@ def test_ab13bd_2norm_dcase(self):
print(h2norm, h2norm_Lo)
assert_allclose(h2norm_Lo, h2norm, atol=1e-5)


if __name__ == "__main__":
unittest.main()
145 changes: 68 additions & 77 deletions slycot/tests/test_ag08bd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# ===================================================
# ag08bd tests
"""Verify ag08bd with input parameters according to example in documentation."""

import unittest
from slycot import analysis
import numpy as np

Expand Down Expand Up @@ -47,77 +45,70 @@
[ 0, 0, 0]])


class test_ag08bd(unittest.TestCase):
"""Verify ag08bd with input parameters according to example in documentation."""

def test1_ag08bd(self):
"""test [A-lambda*E]
B,C,D must have correct dimensions according to l,n,m and p, but cannot
have zero length in any dimenstion. Then the wrapper will complain.
The length is then set to one.
"""

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)

assert_equal(Af, np.zeros((0,0)))
assert_equal(Ef, np.zeros((0,0)))
assert_equal(nrank, 9)
assert_equal(niz, 6)
assert_equal(infz, [0,3])
assert_equal(kronr, [])
assert_equal(infe, [3,3,3])
assert_equal(kronl, [])

def test2_ag08bd(self):
"""test [A-lambda*E;C]
B,D must have correct dimensions as before
"""

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)

assert_equal(Af, np.zeros((0,0)))
assert_equal(Ef, np.zeros((0,0)))
assert_equal(nrank, 9)
assert_equal(niz, 4)
assert_equal(infz, [0,2])
assert_equal(kronr, [])
assert_equal(infe, [1,3,3])
assert_equal(kronl, [0,1,1])

def test3_ag08bd(self):
"""test [A-lambda*E,B]
C,D must have correct dimensions as before
"""

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)

assert_equal(Af, np.zeros((0,0)))
assert_equal(Ef, np.zeros((0,0)))
assert_equal(nrank, 9)
assert_equal(niz, 0)
assert_equal(infz, [])
assert_equal(kronr, [2,2,2])
assert_equal(infe, [1,1,1])
assert_equal(kronl, [])

def test4_ag08bd(self):
"""test [A-lambda*E,B;C,D]"""

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)

# Af-lambda*Ef==0. => lambda==1. => Finite Smith zero of S(lambda) == 1.
assert Af.shape == (1, 1)
assert_almost_equal(Af, Ef)
assert_equal(nrank, 11)
assert_equal(niz, 2)
assert_equal(infz, [0,1])
assert_equal(kronr, [2])
assert_equal(infe, [1,1,1,1,3])
assert_equal(kronl, [1])


if __name__ == "__main__":
unittest.main()
def test1_ag08bd():
"""test [A-lambda*E]
B,C,D must have correct dimensions according to l,n,m and p, but cannot
have zero length in any dimenstion. Then the wrapper will complain.
The length is then set to one.
"""

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)

assert_equal(Af, np.zeros((0,0)))
assert_equal(Ef, np.zeros((0,0)))
assert_equal(nrank, 9)
assert_equal(niz, 6)
assert_equal(infz, [0,3])
assert_equal(kronr, [])
assert_equal(infe, [3,3,3])
assert_equal(kronl, [])

def test2_ag08bd():
"""test [A-lambda*E;C]
B,D must have correct dimensions as before
"""

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)

assert_equal(Af, np.zeros((0,0)))
assert_equal(Ef, np.zeros((0,0)))
assert_equal(nrank, 9)
assert_equal(niz, 4)
assert_equal(infz, [0,2])
assert_equal(kronr, [])
assert_equal(infe, [1,3,3])
assert_equal(kronl, [0,1,1])

def test3_ag08bd():
"""test [A-lambda*E,B]
C,D must have correct dimensions as before
"""

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)

assert_equal(Af, np.zeros((0,0)))
assert_equal(Ef, np.zeros((0,0)))
assert_equal(nrank, 9)
assert_equal(niz, 0)
assert_equal(infz, [])
assert_equal(kronr, [2,2,2])
assert_equal(infe, [1,1,1])
assert_equal(kronl, [])

def test4_ag08bd():
"""test [A-lambda*E,B;C,D]"""

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)

# Af-lambda*Ef==0. => lambda==1. => Finite Smith zero of S(lambda) == 1.
assert Af.shape == (1, 1)
assert_almost_equal(Af, Ef)
assert_equal(nrank, 11)
assert_equal(niz, 2)
assert_equal(infz, [0,1])
assert_equal(kronr, [2])
assert_equal(infe, [1,1,1,1,3])
assert_equal(kronl, [1])
Loading

0 comments on commit 0175171

Please sign in to comment.