Skip to content

Commit 09fca2c

Browse files
committed
Add append TF tests
1 parent b6b032f commit 09fca2c

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

control/tests/xferfcn_test.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ss, ss2tf, tf, tf2ss, zpk)
1616
from control.statesp import _convert_to_statespace
1717
from control.tests.conftest import slycotonly
18-
from control.xferfcn import _convert_to_transfer_function
18+
from control.xferfcn import _convert_to_transfer_function, _tf_close_coeff
1919

2020

2121
class TestXferFcn:
@@ -643,6 +643,52 @@ def test_feedback_siso(self):
643643
np.testing.assert_allclose(sys4.num, [[[-1., 7., -16., 16., 0.]]])
644644
np.testing.assert_allclose(sys4.den, [[[1., 0., 2., -8., 8., 0.]]])
645645

646+
def test_append(self):
647+
"""Test ``TransferFunction.append()``."""
648+
tf1 = TransferFunction(
649+
[
650+
[[1], [1]]
651+
],
652+
[
653+
[[10, 1], [20, 1]]
654+
],
655+
)
656+
tf2 = TransferFunction(
657+
[
658+
[[2], [2]]
659+
],
660+
[
661+
[[10, 1], [1, 1]]
662+
],
663+
)
664+
tf3 = TransferFunction([100], [100, 1])
665+
tf_exp_1 = TransferFunction(
666+
[
667+
[[1], [1], [0], [0]],
668+
[[0], [0], [2], [2]],
669+
],
670+
[
671+
[[10, 1], [20, 1], [1], [1]],
672+
[[1], [1], [10, 1], [1, 1]],
673+
],
674+
)
675+
tf_exp_2 = TransferFunction(
676+
[
677+
[[1], [1], [0], [0], [0]],
678+
[[0], [0], [2], [2], [0]],
679+
[[0], [0], [0], [0], [100]],
680+
],
681+
[
682+
[[10, 1], [20, 1], [1], [1], [1]],
683+
[[1], [1], [10, 1], [1, 1], [1]],
684+
[[1], [1], [1], [1], [100, 1]],
685+
],
686+
)
687+
tf_appended_1 = tf1.append(tf2)
688+
assert _tf_close_coeff(tf_exp_1, tf_appended_1)
689+
tf_appended_2 = tf1.append(tf2).append(tf3)
690+
assert _tf_close_coeff(tf_exp_2, tf_appended_2)
691+
646692
@slycotonly
647693
def test_convert_to_transfer_function(self):
648694
"""Test for correct state space to transfer function conversion."""

0 commit comments

Comments
 (0)