Skip to content

Commit 9a03dd2

Browse files
committed
Change some tests to SS comparison instead of TF
1 parent 4a1e034 commit 9a03dd2

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

control/tests/statesp_test.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -569,18 +569,22 @@ def test_pow(self, sys222, sys322):
569569
# Power of 0
570570
result = sys**0
571571
expected = StateSpace([], [], [], np.eye(2), dt=0)
572-
assert _tf_close_coeff(
573-
ss2tf(expected).minreal(),
574-
ss2tf(result).minreal(),
575-
)
572+
np.testing.assert_allclose(expected.A, result.A)
573+
np.testing.assert_allclose(expected.B, result.B)
574+
np.testing.assert_allclose(expected.C, result.C)
575+
np.testing.assert_allclose(expected.D, result.D)
576576
# Power of 1
577577
result = sys**1
578578
expected = sys
579-
assert _tf_close_coeff(
580-
ss2tf(expected).minreal(),
581-
ss2tf(result).minreal(),
582-
)
579+
np.testing.assert_allclose(expected.A, result.A)
580+
np.testing.assert_allclose(expected.B, result.B)
581+
np.testing.assert_allclose(expected.C, result.C)
582+
np.testing.assert_allclose(expected.D, result.D)
583583
# Power of -1 (inverse of biproper system)
584+
# Testing transfer function representations to avoid the
585+
# non-uniqueness of the state-space representation. Once MIMO
586+
# canonical forms are supported, can check canonical state-space
587+
# matrices instead.
584588
result = (sys * sys**-1).minreal()
585589
expected = StateSpace([], [], [], np.eye(2), dt=0)
586590
assert _tf_close_coeff(
@@ -596,17 +600,17 @@ def test_pow(self, sys222, sys322):
596600
# Power of 3
597601
result = sys**3
598602
expected = sys * sys * sys
599-
assert _tf_close_coeff(
600-
ss2tf(expected).minreal(),
601-
ss2tf(result).minreal(),
602-
)
603+
np.testing.assert_allclose(expected.A, result.A)
604+
np.testing.assert_allclose(expected.B, result.B)
605+
np.testing.assert_allclose(expected.C, result.C)
606+
np.testing.assert_allclose(expected.D, result.D)
603607
# Power of -3
604608
result = sys**-3
605609
expected = sys**-1 * sys**-1 * sys**-1
606-
assert _tf_close_coeff(
607-
ss2tf(expected).minreal(),
608-
ss2tf(result).minreal(),
609-
)
610+
np.testing.assert_allclose(expected.A, result.A)
611+
np.testing.assert_allclose(expected.B, result.B)
612+
np.testing.assert_allclose(expected.C, result.C)
613+
np.testing.assert_allclose(expected.D, result.D)
610614

611615
@slycotonly
612616
def test_truediv(self, sys222, sys322):

0 commit comments

Comments
 (0)