|
15 | 15 | ss, ss2tf, tf, tf2ss, zpk) |
16 | 16 | from control.statesp import _convert_to_statespace |
17 | 17 | 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 |
19 | 19 |
|
20 | 20 |
|
21 | 21 | class TestXferFcn: |
@@ -643,6 +643,52 @@ def test_feedback_siso(self): |
643 | 643 | np.testing.assert_allclose(sys4.num, [[[-1., 7., -16., 16., 0.]]]) |
644 | 644 | np.testing.assert_allclose(sys4.den, [[[1., 0., 2., -8., 8., 0.]]]) |
645 | 645 |
|
| 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 | + |
646 | 692 | @slycotonly |
647 | 693 | def test_convert_to_transfer_function(self): |
648 | 694 | """Test for correct state space to transfer function conversion.""" |
|
0 commit comments