Skip to content

Commit d6d9105

Browse files
committed
fix syntax errrors in test_sb.py
1 parent 80563c2 commit d6d9105

File tree

1 file changed

+46
-45
lines changed

1 file changed

+46
-45
lines changed

slycot/tests/test_sb.py

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# sb* synthesis tests
33

44
from slycot import synthesis
5-
import numpy as np
5+
from numpy import array, eye, zeros
66
from numpy.testing import assert_allclose
77

88

@@ -18,20 +18,22 @@ def test_sb02mt():
1818

1919
def test_sb10ad():
2020
"""Test sb10ad, Hinf synthesis"""
21-
a = np.array([[-1]])
22-
b = np.array([[1, 1]])
23-
c = np.array([[1], [1]])
24-
d = np.array([[0, 1], [1, 0]])
21+
a = array([[-1]])
22+
b = array([[1, 1]])
23+
c = array([[1],
24+
[1]])
25+
d = array([[0, 1],
26+
[1, 0]])
2527

2628
n = 1
2729
m = 2
28-
np_ = 2
30+
np = 2
2931
ncon = 1
3032
nmeas = 1
3133
gamma = 10
3234

3335
gamma_est, Ak, Bk, Ck, Dk, Ac, Bc, Cc, Dc, rcond = synthesis.sb10ad(
34-
n, m, np_, ncon, nmeas, gamma, a, b, c, d)
36+
n, m, np, ncon, nmeas, gamma, a, b, c, d)
3537
# from Octave, which also uses SB10AD:
3638
# a= -1; b1= 1; b2= 1; c1= 1; c2= 1; d11= 0; d12= 1; d21= 1; d22= 0;
3739
# g = ss(a,[b1,b2],[c1;c2],[d11,d12;d21,d22]);
@@ -40,9 +42,9 @@ def test_sb10ad():
4042
# gamma values don't match; not sure that's critical
4143
# this is a bit fragile
4244
# a simpler, more robust check might be to check stability of Ac
43-
assert_allclose(Ak, np.array([[-3.]]))
44-
assert_allclose(Ac, np.array([[-1., -1.]
45-
[1., -3.]]))
45+
assert_allclose(Ak, array([[-3.]]))
46+
assert_allclose(Ac, array([[-1., -1.],
47+
[1., -3.]]))
4648

4749

4850
def test_sb10jd():
@@ -53,46 +55,45 @@ def test_sb10jd():
5355
m = 1
5456
np = 6
5557

56-
A = np.array([[ 0, 0, 0, -1, 1, 0],
57-
[ 0, 32, 0, 0, -1, 1],
58-
[ 0, 0, 1, 0, 0, 0],
59-
[ 0, 0, 0, 1, 0, 0],
60-
[-1, 1, 0, 0, 0, 0],
61-
[ 0, -1, 1, 0, 0, 0]])
62-
E = np.array([[ 0, 0, 0, 0, 0, 0],
63-
[ 0, 0, 0, 0, 0, 0],
64-
[ 0, 0, 0, -10, 0, 10],
65-
[ 0, 0, 0, 0, 0, 0],
66-
[ 0, 0, 0, 0, 0, 0],
67-
[ 0, 0, 0, 0, 0, 0]])
68-
B = np.array([[-7.1],
69-
[ 0. ],
70-
[ 0. ],
71-
[ 0. ],
72-
[ 0. ],
73-
[ 0. ]])
74-
C = np.eye(6)
75-
D = np.zeros((7,1))
58+
A = array([[ 0, 0, 0, -1, 1, 0],
59+
[ 0, 32, 0, 0, -1, 1],
60+
[ 0, 0, 1, 0, 0, 0],
61+
[ 0, 0, 0, 1, 0, 0],
62+
[-1, 1, 0, 0, 0, 0],
63+
[ 0, -1, 1, 0, 0, 0]])
64+
E = array([[ 0, 0, 0, 0, 0, 0],
65+
[ 0, 0, 0, 0, 0, 0],
66+
[ 0, 0, 0, -10, 0, 10],
67+
[ 0, 0, 0, 0, 0, 0],
68+
[ 0, 0, 0, 0, 0, 0],
69+
[ 0, 0, 0, 0, 0, 0]])
70+
B = array([[-7.1],
71+
[ 0. ],
72+
[ 0. ],
73+
[ 0. ],
74+
[ 0. ],
75+
[ 0. ]])
76+
C = eye(6)
77+
D = zeros((7, 1))
7678

7779
# test1 expected results
78-
Aexp = np.array([[-0.00312500]])
79-
Bexp = np.array([[ 0.05899985]])
80-
Cexp = np.array([[-1.17518847e-02],
81-
[-1.17518847e-02],
82-
[-1.17518847e-02],
83-
[ 0.00000000e+00],
84-
[ 0.00000000e+00],
85-
[ 3.76060309e-01]])
86-
Dexp = np.array([[ 2.21875000e-01],
87-
[ 2.21875000e-01],
88-
[ 2.21875000e-01],
89-
[ 0.00000000e+00],
90-
[ 7.10000000e+00],
91-
[ 0.00000000e+00]])
80+
Aexp = array([[-0.00312500]])
81+
Bexp = array([[ 0.05899985]])
82+
Cexp = array([[-1.17518847e-02],
83+
[-1.17518847e-02],
84+
[-1.17518847e-02],
85+
[ 0.00000000e+00],
86+
[ 0.00000000e+00],
87+
[ 3.76060309e-01]])
88+
Dexp = array([[ 2.21875000e-01],
89+
[ 2.21875000e-01],
90+
[ 2.21875000e-01],
91+
[ 0.00000000e+00],
92+
[ 7.10000000e+00],
93+
[ 0.00000000e+00]])
9294

9395
A_r, B_r, C_r, D_r = synthesis.sb10jd(n, m, np, A, B, C, D, E)
9496
assert_allclose(A, Aexp)
9597
assert_allclose(B, Bexp)
9698
assert_allclose(C, Cexp)
9799
assert_allclose(D, Dexp)
98-

0 commit comments

Comments
 (0)