|
8 | 8 | import pytest |
9 | 9 |
|
10 | 10 | import control as ctrl |
11 | | -from control.xferfcn import TransferFunction |
| 11 | +from control.xferfcn import TransferFunction, _tf_close_coeff |
12 | 12 | from control.statesp import StateSpace |
13 | 13 | from control.bdalg import feedback, append, connect |
14 | 14 | from control.lti import zeros, poles |
@@ -870,50 +870,3 @@ def test_error_combine_tf(self, tf_array, exception): |
870 | 870 | """Test error cases.""" |
871 | 871 | with pytest.raises(exception): |
872 | 872 | ctrl.combine_tf(tf_array) |
873 | | - |
874 | | - |
875 | | -def _tf_close_coeff(tf_a, tf_b, rtol=1e-5, atol=1e-8): |
876 | | - """Check if two transfer functions have close coefficients. |
877 | | -
|
878 | | - Parameters |
879 | | - ---------- |
880 | | - tf_a : TransferFunction |
881 | | - First transfer function. |
882 | | - tf_b : TransferFunction |
883 | | - Second transfer function. |
884 | | - rtol : float |
885 | | - Relative tolerance for ``np.allclose``. |
886 | | - atol : float |
887 | | - Absolute tolerance for ``np.allclose``. |
888 | | -
|
889 | | - Returns |
890 | | - ------- |
891 | | - bool |
892 | | - True if transfer function cofficients are all close. |
893 | | - """ |
894 | | - # Check number of outputs and inputs |
895 | | - if tf_a.noutputs != tf_b.noutputs: |
896 | | - return False |
897 | | - if tf_a.ninputs != tf_b.ninputs: |
898 | | - return False |
899 | | - # Check timestep |
900 | | - if tf_a.dt != tf_b.dt: |
901 | | - return False |
902 | | - # Check coefficient arrays |
903 | | - for i in range(tf_a.noutputs): |
904 | | - for j in range(tf_a.ninputs): |
905 | | - if not np.allclose( |
906 | | - tf_a.num[i][j], |
907 | | - tf_b.num[i][j], |
908 | | - rtol=rtol, |
909 | | - atol=atol, |
910 | | - ): |
911 | | - return False |
912 | | - if not np.allclose( |
913 | | - tf_a.den[i][j], |
914 | | - tf_b.den[i][j], |
915 | | - rtol=rtol, |
916 | | - atol=atol, |
917 | | - ): |
918 | | - return False |
919 | | - return True |
0 commit comments