@@ -75,79 +75,74 @@ def test_kwarg_search(module, prefix):
75
75
test_kwarg_search (obj , prefix + obj .__name__ + '.' )
76
76
77
77
78
- @pytest .mark .usefixtures ('editsdefaults' )
79
- def test_unrecognized_kwargs ():
78
+ @pytest .mark .parametrize (
79
+ "function, nsssys, ntfsys, moreargs, kwargs" ,
80
+ [(control .dlqe , 1 , 0 , ([[1 ]], [[1 ]]), {}),
81
+ (control .dlqr , 1 , 0 , ([[1 , 0 ], [0 , 1 ]], [[1 ]]), {}),
82
+ (control .drss , 0 , 0 , (2 , 1 , 1 ), {}),
83
+ (control .input_output_response , 1 , 0 , ([0 , 1 , 2 ], [1 , 1 , 1 ]), {}),
84
+ (control .lqe , 1 , 0 , ([[1 ]], [[1 ]]), {}),
85
+ (control .lqr , 1 , 0 , ([[1 , 0 ], [0 , 1 ]], [[1 ]]), {}),
86
+ (control .linearize , 1 , 0 , (0 , 0 ), {}),
87
+ (control .pzmap , 1 , 0 , (), {}),
88
+ (control .rlocus , 0 , 1 , ( ), {}),
89
+ (control .root_locus , 0 , 1 , ( ), {}),
90
+ (control .rss , 0 , 0 , (2 , 1 , 1 ), {}),
91
+ (control .set_defaults , 0 , 0 , ('control' ,), {'default_dt' : True }),
92
+ (control .ss , 0 , 0 , (0 , 0 , 0 , 0 ), {'dt' : 1 }),
93
+ (control .ss2io , 1 , 0 , (), {}),
94
+ (control .ss2tf , 1 , 0 , (), {}),
95
+ (control .summing_junction , 0 , 0 , (2 ,), {}),
96
+ (control .tf , 0 , 0 , ([1 ], [1 , 1 ]), {}),
97
+ (control .tf2io , 0 , 1 , (), {}),
98
+ (control .tf2ss , 0 , 1 , (), {}),
99
+ (control .InputOutputSystem , 0 , 0 , (),
100
+ {'inputs' : 1 , 'outputs' : 1 , 'states' : 1 }),
101
+ (control .InputOutputSystem .linearize , 1 , 0 , (0 , 0 ), {}),
102
+ (control .StateSpace , 0 , 0 , ([[- 1 , 0 ], [0 , - 1 ]], [[1 ], [1 ]], [[1 , 1 ]], 0 ), {}),
103
+ (control .TransferFunction , 0 , 0 , ([1 ], [1 , 1 ]), {})]
104
+ )
105
+ def test_unrecognized_kwargs (function , nsssys , ntfsys , moreargs , kwargs ,
106
+ mplcleanup , editsdefaults ):
107
+ # Create SISO systems for use in parameterized tests
108
+ sssys = control .ss ([[- 1 , 1 ], [0 , - 1 ]], [[0 ], [1 ]], [[1 , 0 ]], 0 , dt = None )
109
+ tfsys = control .tf ([1 ], [1 , 1 ])
110
+
111
+ args = (sssys , )* nsssys + (tfsys , )* ntfsys + moreargs
112
+
113
+ # Call the function normally and make sure it works
114
+ function (* args , ** kwargs )
115
+
116
+ # Now add an unrecognized keyword and make sure there is an error
117
+ with pytest .raises (TypeError , match = "unrecognized keyword" ):
118
+ function (* args , ** kwargs , unknown = None )
119
+
120
+
121
+ @pytest .mark .parametrize (
122
+ "function, nsysargs, moreargs, kwargs" ,
123
+ [(control .bode , 1 , (), {}),
124
+ (control .bode_plot , 1 , (), {}),
125
+ (control .describing_function_plot , 1 ,
126
+ (control .descfcn .saturation_nonlinearity (1 ), [1 , 2 , 3 , 4 ]), {}),
127
+ (control .gangof4 , 2 , (), {}),
128
+ (control .gangof4_plot , 2 , (), {}),
129
+ (control .nyquist , 1 , (), {}),
130
+ (control .nyquist_plot , 1 , (), {}),
131
+ (control .singular_values_plot , 1 , (), {})]
132
+ )
133
+ def test_matplotlib_kwargs (function , nsysargs , moreargs , kwargs , mplcleanup ):
80
134
# Create a SISO system for use in parameterized tests
81
135
sys = control .ss ([[- 1 , 1 ], [0 , - 1 ]], [[0 ], [1 ]], [[1 , 0 ]], 0 , dt = None )
82
136
83
- table = [
84
- [control .dlqe , (sys , [[1 ]], [[1 ]]), {}],
85
- [control .dlqr , (sys , [[1 , 0 ], [0 , 1 ]], [[1 ]]), {}],
86
- [control .drss , (2 , 1 , 1 ), {}],
87
- [control .input_output_response , (sys , [0 , 1 , 2 ], [1 , 1 , 1 ]), {}],
88
- [control .lqe , (sys , [[1 ]], [[1 ]]), {}],
89
- [control .lqr , (sys , [[1 , 0 ], [0 , 1 ]], [[1 ]]), {}],
90
- [control .linearize , (sys , 0 , 0 ), {}],
91
- [control .pzmap , (sys ,), {}],
92
- [control .rlocus , (control .tf ([1 ], [1 , 1 ]), ), {}],
93
- [control .root_locus , (control .tf ([1 ], [1 , 1 ]), ), {}],
94
- [control .rss , (2 , 1 , 1 ), {}],
95
- [control .set_defaults , ('control' ,), {'default_dt' : True }],
96
- [control .ss , (0 , 0 , 0 , 0 ), {'dt' : 1 }],
97
- [control .ss2io , (sys ,), {}],
98
- [control .ss2tf , (sys ,), {}],
99
- [control .summing_junction , (2 ,), {}],
100
- [control .tf , ([1 ], [1 , 1 ]), {}],
101
- [control .tf2io , (control .tf ([1 ], [1 , 1 ]),), {}],
102
- [control .tf2ss , (control .tf ([1 ], [1 , 1 ]),), {}],
103
- [control .InputOutputSystem , (),
104
- {'inputs' : 1 , 'outputs' : 1 , 'states' : 1 }],
105
- [control .InputOutputSystem .linearize , (sys , 0 , 0 ), {}],
106
- [control .StateSpace , ([[- 1 , 0 ], [0 , - 1 ]], [[1 ], [1 ]], [[1 , 1 ]], 0 ), {}],
107
- [control .TransferFunction , ([1 ], [1 , 1 ]), {}],
108
- ]
109
-
110
- for function , args , kwargs in table :
111
- # Call the function normally and make sure it works
112
- function (* args , ** kwargs )
113
-
114
- # Now add an unrecognized keyword and make sure there is an error
115
- with pytest .raises (TypeError , match = "unrecognized keyword" ):
116
- function (* args , ** kwargs , unknown = None )
117
-
118
- # If we opened any figures, close them to avoid matplotlib warnings
119
- if plt .gca ():
120
- plt .close ('all' )
121
-
122
-
123
- def test_matplotlib_kwargs ():
124
- # Create a SISO system for use in parameterized tests
125
- sys = control .ss ([[- 1 , 1 ], [0 , - 1 ]], [[0 ], [1 ]], [[1 , 0 ]], 0 , dt = None )
126
- ctl = control .ss ([[- 1 , 1 ], [0 , - 1 ]], [[0 ], [1 ]], [[1 , 0 ]], 0 , dt = None )
127
-
128
- table = [
129
- [control .bode , (sys , ), {}],
130
- [control .bode_plot , (sys , ), {}],
131
- [control .describing_function_plot ,
132
- (sys , control .descfcn .saturation_nonlinearity (1 ), [1 , 2 , 3 , 4 ]), {}],
133
- [control .gangof4 , (sys , ctl ), {}],
134
- [control .gangof4_plot , (sys , ctl ), {}],
135
- [control .nyquist , (sys , ), {}],
136
- [control .nyquist_plot , (sys , ), {}],
137
- [control .singular_values_plot , (sys , ), {}],
138
- ]
139
-
140
- for function , args , kwargs in table :
141
- # Call the function normally and make sure it works
142
- function (* args , ** kwargs )
143
-
144
- # Now add an unrecognized keyword and make sure there is an error
145
- with pytest .raises (AttributeError , match = "has no property" ):
146
- function (* args , ** kwargs , unknown = None )
147
-
148
- # If we opened any figures, close them to avoid matplotlib warnings
149
- if plt .gca ():
150
- plt .close ('all' )
137
+ # Call the function normally and make sure it works
138
+ args = (sys , )* nsysargs + moreargs
139
+ function (* args , ** kwargs )
140
+
141
+ # Now add an unrecognized keyword and make sure there is an error
142
+ with pytest .raises (AttributeError ,
143
+ match = "(has no property|unexpected keyword)" ):
144
+ function (* args , ** kwargs , unknown = None )
145
+
151
146
152
147
153
148
#
0 commit comments