Skip to content

Commit 45b5ae4

Browse files
committed
Cleanup unittest
1 parent b36732d commit 45b5ae4

1 file changed

Lines changed: 85 additions & 13 deletions

File tree

control/tests/xferfcn_test.py

Lines changed: 85 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -908,24 +908,96 @@ def test_printing_mimo(self):
908908

909909
@pytest.mark.parametrize(
910910
"zeros, poles, gain, output",
911-
[([0], [-1], 1, "\n s\n-----\ns + 1\n"),
912-
([-1], [-1], 1, "\ns + 1\n-----\ns + 1\n"),
913-
([-1], [1], 1, "\ns + 1\n-----\ns - 1\n"),
914-
([1], [-1], 1, "\ns - 1\n-----\ns + 1\n"),
915-
([-1], [-1], 2, "\n2 (s + 1)\n---------\n s + 1\n"),
916-
([-1], [-1], 0, "\n0\n-\n1\n"),
917-
([-1], [1j, -1j], 1, "\n s + 1\n-----------------\n(s - 1j) (s + 1j)\n"),
918-
([4j, -4j], [2j, -2j], 2, "\n2 (s - 4j) (s + 4j)\n-------------------\n (s - 2j) (s + 2j)\n"),
919-
([1j, -1j], [-1, -4], 2, "\n2 (s - 1j) (s + 1j)\n-------------------\n (s + 1) (s + 4)\n"),
920-
([1], [-1 + 1j, -1 - 1j], 1, "\n s - 1\n-------------------------\n(s + (1-1j)) (s + (1+1j))\n"),
921-
([1], [1 + 1j, 1 - 1j], 1, "\n s - 1\n-------------------------\n(s - (1+1j)) (s - (1-1j))\n"),
911+
[([0], [-1], 1,
912+
'\n'
913+
' s\n'
914+
'-----\n'
915+
's + 1\n'),
916+
([-1], [-1], 1,
917+
'\n'
918+
's + 1\n'
919+
'-----\n'
920+
's + 1\n'),
921+
([-1], [1], 1,
922+
'\n'
923+
's + 1\n'
924+
'-----\n'
925+
's - 1\n'),
926+
([1], [-1], 1,
927+
'\n'
928+
's - 1\n'
929+
'-----\n'
930+
's + 1\n'),
931+
([-1], [-1], 2,
932+
'\n'
933+
'2 (s + 1)\n'
934+
'---------\n'
935+
' s + 1\n'),
936+
([-1], [-1], 0,
937+
'\n'
938+
'0\n'
939+
'-\n'
940+
'1\n'),
941+
([-1], [1j, -1j], 1,
942+
'\n'
943+
' s + 1\n'
944+
'-----------------\n'
945+
'(s - 1j) (s + 1j)\n'),
946+
([4j, -4j], [2j, -2j], 2,
947+
'\n'
948+
'2 (s - 4j) (s + 4j)\n'
949+
'-------------------\n'
950+
' (s - 2j) (s + 2j)\n'),
951+
([1j, -1j], [-1, -4], 2,
952+
'\n'
953+
'2 (s - 1j) (s + 1j)\n'
954+
'-------------------\n'
955+
' (s + 1) (s + 4)\n'),
956+
([1], [-1 + 1j, -1 - 1j], 1,
957+
'\n'
958+
' s - 1\n'
959+
'-------------------------\n'
960+
'(s + (1-1j)) (s + (1+1j))\n'),
961+
([1], [1 + 1j, 1 - 1j], 1,
962+
'\n'
963+
' s - 1\n'
964+
'-------------------------\n'
965+
'(s - (1+1j)) (s - (1-1j))\n'),
922966
])
923967
def test_printing_zpk(self, zeros, poles, gain, output):
924968
"""Test _tf_polynomial_to_string for constant systems"""
925969
G = zpk(zeros, poles, gain)
926-
print(G)
927970
res = G.to_zpk()
928-
print(res)
971+
assert res == output
972+
973+
@pytest.mark.parametrize(
974+
"num, den, output",
975+
[([[[11], [21]], [[12], [22]]],
976+
[[[1, -3, 2], [1, 1, -6]], [[1, 0, 1], [1, -1, -20]]],
977+
('\n'
978+
'Input 1 to output 1:\n'
979+
' 11\n'
980+
'---------------\n'
981+
'(s - 2) (s - 1)\n'
982+
'\n'
983+
'Input 1 to output 2:\n'
984+
' 12\n'
985+
'-----------------\n'
986+
'(s - 1j) (s + 1j)\n'
987+
'\n'
988+
'Input 2 to output 1:\n'
989+
' 21\n'
990+
'---------------\n'
991+
'(s - 2) (s + 3)\n'
992+
'\n'
993+
'Input 2 to output 2:\n'
994+
' 22\n'
995+
'---------------\n'
996+
'(s - 5) (s + 4)\n'))])
997+
def test_printing_zpk_mimo(self, num, den, output):
998+
"""Test _tf_polynomial_to_string for constant systems"""
999+
G = tf(num, den)
1000+
res = G.to_zpk()
9291001
assert res == output
9301002

9311003
def test_printing_zpk_invalid(self):

0 commit comments

Comments
 (0)