|
10 | 10 | import control as ct |
11 | 11 | from control import StateSpace, TransferFunction, rss, evalfr |
12 | 12 | from control import ss, ss2tf, tf, tf2ss, zpk |
13 | | -from control import isctime, isdtime, sample_system, defaults |
| 13 | +from control import isctime, isdtime, sample_system, defaults, reset_defaults |
14 | 14 | from control.statesp import _convert_to_statespace |
15 | 15 | from control.xferfcn import _convert_to_transfer_function |
16 | 16 | from control.tests.conftest import slycotonly, matrixfilter |
@@ -970,6 +970,33 @@ def test_printing_zpk(self, zeros, poles, gain, output): |
970 | 970 | res = str(G) |
971 | 971 | assert res == output |
972 | 972 |
|
| 973 | + @pytest.mark.parametrize( |
| 974 | + "zeros, poles, gain, format, output", |
| 975 | + [([1], [1 + 1j, 1 - 1j], 1, ".2f", |
| 976 | + '\n' |
| 977 | + ' 1.00\n' |
| 978 | + '-------------------------------------\n' |
| 979 | + '(s + (1.00-1.41j)) (s + (1.00+1.41j))\n'), |
| 980 | + ([1], [1 + 1j, 1 - 1j], 1, ".3f", |
| 981 | + '\n' |
| 982 | + ' 1.000\n' |
| 983 | + '-----------------------------------------\n' |
| 984 | + '(s + (1.000-1.414j)) (s + (1.000+1.414j))\n'), |
| 985 | + ([1], [1 + 1j, 1 - 1j], 1, ".6g", |
| 986 | + '\n' |
| 987 | + ' 1\n' |
| 988 | + '-------------------------------------\n' |
| 989 | + '(s + (1-1.41421j)) (s + (1+1.41421j))\n') |
| 990 | + ]) |
| 991 | + def test_printing_zpk_format(self, zeros, poles, gain, format, output): |
| 992 | + """Test _tf_polynomial_to_string for constant systems""" |
| 993 | + defaults['xferfcn.floating_point_format'] = format |
| 994 | + G = tf([1], [1,2,3], display_format='zpk') |
| 995 | + res = str(G) |
| 996 | + reset_defaults() |
| 997 | + |
| 998 | + assert res == output |
| 999 | + |
973 | 1000 | @pytest.mark.parametrize( |
974 | 1001 | "num, den, output", |
975 | 1002 | [([[[11], [21]], [[12], [22]]], |
|
0 commit comments