1212
1313from control .xferfcn import _clean_part
1414
15+
1516class TestXferFcnInput (unittest .TestCase ):
16- """These are tests for functionality of cleaning and validating
17- XferFucnInput."""
17+ """These are tests for functionality of cleaning and validating XferFcnInput."""
1818
1919 # Tests for raising exceptions.
20- def testBadInputType (self ):
20+ def test_clean_part_bad_input_type (self ):
2121 """Give the part cleaner invalid input type."""
2222
2323 self .assertRaises (TypeError , _clean_part , [[0. , 1. ], [2. , 3. ]])
2424
25- def testBadInputType2 (self ):
25+ def test_clean_part_bad_input_type2 (self ):
2626 """Give the part cleaner another invalid input type."""
2727 self .assertRaises (TypeError , _clean_part , [1 , "a" ])
2828
29- def testScalar (self ):
29+ def test_clean_part_scalar (self ):
3030 """Test single scalar value."""
3131 num = 1
3232 num_ = _clean_part (num )
@@ -35,7 +35,7 @@ def testScalar(self):
3535 assert np .all ([isinstance (part , list ) for part in num_ ])
3636 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
3737
38- def testListScalar (self ):
38+ def test_clean_part_list_scalar (self ):
3939 """Test single scalar value in list."""
4040 num = [1 ]
4141 num_ = _clean_part (num )
@@ -44,7 +44,7 @@ def testListScalar(self):
4444 assert np .all ([isinstance (part , list ) for part in num_ ])
4545 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
4646
47- def testTupleScalar (self ):
47+ def test_clean_part_tuple_scalar (self ):
4848 """Test single scalar value in tuple."""
4949 num = (1 )
5050 num_ = _clean_part (num )
@@ -53,7 +53,7 @@ def testTupleScalar(self):
5353 assert np .all ([isinstance (part , list ) for part in num_ ])
5454 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
5555
56- def testList (self ):
56+ def test_clean_part_list (self ):
5757 """Test multiple values in a list."""
5858 num = [1 , 2 ]
5959 num_ = _clean_part (num )
@@ -62,7 +62,7 @@ def testList(self):
6262 assert np .all ([isinstance (part , list ) for part in num_ ])
6363 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 2.0 ], dtype = float ))
6464
65- def testTuple (self ):
65+ def test_clean_part_tuple (self ):
6666 """Test multiple values in tuple."""
6767 num = (1 , 2 )
6868 num_ = _clean_part (num )
@@ -71,7 +71,7 @@ def testTuple(self):
7171 assert np .all ([isinstance (part , list ) for part in num_ ])
7272 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 2.0 ], dtype = float ))
7373
74- def testAllScalarTypes (self ):
74+ def test_clean_part_all_scalar_types (self ):
7575 """Test single scalar value for all valid data types."""
7676 for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
7777 num = dtype (1 )
@@ -81,7 +81,7 @@ def testAllScalarTypes(self):
8181 assert np .all ([isinstance (part , list ) for part in num_ ])
8282 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
8383
84- def testNpArray (self ):
84+ def test_clean_part_np_array (self ):
8585 """Test multiple values in numpy array."""
8686 num = np .array ([1 , 2 ])
8787 num_ = _clean_part (num )
@@ -90,7 +90,7 @@ def testNpArray(self):
9090 assert np .all ([isinstance (part , list ) for part in num_ ])
9191 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 2.0 ], dtype = float ))
9292
93- def testAllNumpyArrayTypes (self ):
93+ def test_clean_part_all_np_array_types (self ):
9494 """Test scalar value in numpy array of ndim=0 for all data types."""
9595 for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
9696 num = np .array (1 , dtype = dtype )
@@ -100,7 +100,7 @@ def testAllNumpyArrayTypes(self):
100100 assert np .all ([isinstance (part , list ) for part in num_ ])
101101 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
102102
103- def testAllNumpyArrayTypes2 (self ):
103+ def test_clean_part_all_np_array_types2 (self ):
104104 """Test numpy array for all types."""
105105 for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
106106 num = np .array ([1 , 2 ], dtype = dtype )
@@ -110,7 +110,7 @@ def testAllNumpyArrayTypes2(self):
110110 assert np .all ([isinstance (part , list ) for part in num_ ])
111111 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 2.0 ], dtype = float ))
112112
113- def testListAllTypes (self ):
113+ def test_clean_part_list_all_types (self ):
114114 """Test list of a single value for all data types."""
115115 for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
116116 num = [dtype (1 )]
@@ -119,7 +119,7 @@ def testListAllTypes(self):
119119 assert np .all ([isinstance (part , list ) for part in num_ ])
120120 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
121121
122- def testListAllTypes2 (self ):
122+ def test_clean_part_list_all_types2 (self ):
123123 """List of list of numbers of all data types."""
124124 for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
125125 num = [dtype (1 ), dtype (2 )]
@@ -128,7 +128,7 @@ def testListAllTypes2(self):
128128 assert np .all ([isinstance (part , list ) for part in num_ ])
129129 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 2.0 ], dtype = float ))
130130
131- def testTupleAllTypes (self ):
131+ def test_clean_part_tuple_all_types (self ):
132132 """Test tuple of a single value for all data types."""
133133 for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
134134 num = (dtype (1 ),)
@@ -137,7 +137,7 @@ def testTupleAllTypes(self):
137137 assert np .all ([isinstance (part , list ) for part in num_ ])
138138 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
139139
140- def testTupleAllTypes2 (self ):
140+ def test_clean_part_tuple_all_types2 (self ):
141141 """Test tuple of a single value for all data types."""
142142 for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
143143 num = (dtype (1 ), dtype (2 ))
@@ -146,104 +146,104 @@ def testTupleAllTypes2(self):
146146 assert np .all ([isinstance (part , list ) for part in num_ ])
147147 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1 , 2 ], dtype = float ))
148148
149- def testListListListInt (self ):
149+ def test_clean_part_list_list_list_int (self ):
150150 """ Test an int in a list of a list of a list."""
151151 num = [[[1 ]]]
152152 num_ = _clean_part (num )
153153 assert isinstance (num_ , list )
154154 assert np .all ([isinstance (part , list ) for part in num_ ])
155155 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
156156
157- def testListListListFloat (self ):
157+ def test_clean_part_list_list_list_float (self ):
158158 """ Test a float in a list of a list of a list."""
159159 num = [[[1.0 ]]]
160160 num_ = _clean_part (num )
161161 assert isinstance (num_ , list )
162162 assert np .all ([isinstance (part , list ) for part in num_ ])
163163 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
164164
165- def testListListListInts (self ):
165+ def test_clean_part_list_list_list_ints (self ):
166166 """Test 2 lists of ints in a list in a list."""
167- num = [[[1 ,1 ],[2 ,2 ]]]
167+ num = [[[1 , 1 ], [2 , 2 ]]]
168168 num_ = _clean_part (num )
169169
170170 assert isinstance (num_ , list )
171171 assert np .all ([isinstance (part , list ) for part in num_ ])
172172 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 1.0 ], dtype = float ))
173173 np .testing .assert_array_equal (num_ [0 ][1 ], array ([2.0 , 2.0 ], dtype = float ))
174174
175- def testListListListFloats (self ):
175+ def test_clean_part_list_list_list_floats (self ):
176176 """Test 2 lists of ints in a list in a list."""
177- num = [[[1.0 ,1.0 ],[2.0 ,2.0 ]]]
177+ num = [[[1.0 , 1.0 ], [2.0 , 2.0 ]]]
178178 num_ = _clean_part (num )
179179
180180 assert isinstance (num_ , list )
181181 assert np .all ([isinstance (part , list ) for part in num_ ])
182182 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 1.0 ], dtype = float ))
183183 np .testing .assert_array_equal (num_ [0 ][1 ], array ([2.0 , 2.0 ], dtype = float ))
184184
185- def testListListArray (self ):
185+ def test_clean_part_list_list_array (self ):
186186 """List of list of numpy arrays for all valid types."""
187187 for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
188- num = [[array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )]]
188+ num = [[array ([1 , 1 ], dtype = dtype ), array ([2 , 2 ], dtype = dtype )]]
189189 num_ = _clean_part (num )
190190
191191 assert isinstance (num_ , list )
192192 assert np .all ([isinstance (part , list ) for part in num_ ])
193193 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 1.0 ], dtype = float ))
194194 np .testing .assert_array_equal (num_ [0 ][1 ], array ([2.0 , 2.0 ], dtype = float ))
195195
196- def testTupleListArray (self ):
196+ def test_clean_part_tuple_list_array (self ):
197197 """Tuple of list of numpy arrays for all valid types."""
198198 for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
199- num = ([array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )],)
199+ num = ([array ([1 , 1 ], dtype = dtype ), array ([2 , 2 ], dtype = dtype )],)
200200 num_ = _clean_part (num )
201201
202202 assert isinstance (num_ , list )
203203 assert np .all ([isinstance (part , list ) for part in num_ ])
204204 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 1.0 ], dtype = float ))
205205 np .testing .assert_array_equal (num_ [0 ][1 ], array ([2.0 , 2.0 ], dtype = float ))
206206
207- def testListTupleArray (self ):
207+ def test_clean_part_list_tuple_array (self ):
208208 """List of tuple of numpy array for all valid types."""
209209 for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
210- num = [(array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype ))]
210+ num = [(array ([1 , 1 ], dtype = dtype ), array ([2 , 2 ], dtype = dtype ))]
211211 num_ = _clean_part (num )
212212
213213 assert isinstance (num_ , list )
214214 assert np .all ([isinstance (part , list ) for part in num_ ])
215215 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 1.0 ], dtype = float ))
216216 np .testing .assert_array_equal (num_ [0 ][1 ], array ([2.0 , 2.0 ], dtype = float ))
217217
218- def testTupleTuplesArrays (self ):
218+ def test_clean_part_tuple_tuples_arrays (self ):
219219 """Tuple of tuples of numpy arrays for all valid types."""
220220 for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
221- num = ((array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )),
222- (array ([3 ,4 ], dtype = dtype ),array ([4 ,4 ], dtype = dtype )))
221+ num = ((array ([1 , 1 ], dtype = dtype ), array ([2 , 2 ], dtype = dtype )),
222+ (array ([3 , 4 ], dtype = dtype ), array ([4 , 4 ], dtype = dtype )))
223223 num_ = _clean_part (num )
224224
225225 assert isinstance (num_ , list )
226226 assert np .all ([isinstance (part , list ) for part in num_ ])
227227 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 1.0 ], dtype = float ))
228228 np .testing .assert_array_equal (num_ [0 ][1 ], array ([2.0 , 2.0 ], dtype = float ))
229229
230- def testListTuplesArrays (self ):
230+ def test_clean_part_list_tuples_arrays (self ):
231231 """List of tuples of numpy arrays for all valid types."""
232232 for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
233- num = [(array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )),
234- (array ([3 ,4 ], dtype = dtype ),array ([4 ,4 ], dtype = dtype ))]
233+ num = [(array ([1 , 1 ], dtype = dtype ), array ([2 , 2 ], dtype = dtype )),
234+ (array ([3 , 4 ], dtype = dtype ), array ([4 , 4 ], dtype = dtype ))]
235235 num_ = _clean_part (num )
236236
237237 assert isinstance (num_ , list )
238238 assert np .all ([isinstance (part , list ) for part in num_ ])
239239 np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 1.0 ], dtype = float ))
240240 np .testing .assert_array_equal (num_ [0 ][1 ], array ([2.0 , 2.0 ], dtype = float ))
241241
242- def testListListArrays (self ):
242+ def test_clean_part_list_list_arrays (self ):
243243 """List of list of numpy arrays for all valid types."""
244244 for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
245- num = [[array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )],
246- [array ([3 ,3 ], dtype = dtype ),array ([4 ,4 ], dtype = dtype )]]
245+ num = [[array ([1 , 1 ], dtype = dtype ), array ([2 , 2 ], dtype = dtype )],
246+ [array ([3 , 3 ], dtype = dtype ), array ([4 , 4 ], dtype = dtype )]]
247247 num_ = _clean_part (num )
248248
249249 assert len (num_ ) == 2
@@ -254,8 +254,10 @@ def testListListArrays(self):
254254 np .testing .assert_array_equal (num_ [1 ][0 ], array ([3.0 , 3.0 ], dtype = float ))
255255 np .testing .assert_array_equal (num_ [1 ][1 ], array ([4.0 , 4.0 ], dtype = float ))
256256
257+
257258def suite ():
258259 return unittest .TestLoader ().loadTestsFromTestCase (TestXferFcnInput )
259260
261+
260262if __name__ == "__main__" :
261263 unittest .main ()
0 commit comments