10
10
from numpy import float , float16 , float32 , float64 , float128
11
11
from numpy import all , ndarray , array
12
12
13
- from control .xferfcn import _cleanPart
13
+ from control .xferfcn import _clean_part
14
14
15
15
class TestXferFcnInput (unittest .TestCase ):
16
16
"""These are tests for functionality of cleaning and validating
@@ -20,16 +20,16 @@ class TestXferFcnInput(unittest.TestCase):
20
20
def testBadInputType (self ):
21
21
"""Give the part cleaner invalid input type."""
22
22
23
- self .assertRaises (TypeError , _cleanPart , [[0. , 1. ], [2. , 3. ]])
23
+ self .assertRaises (TypeError , _clean_part , [[0. , 1. ], [2. , 3. ]])
24
24
25
25
def testBadInputType2 (self ):
26
26
"""Give the part cleaner another invalid input type."""
27
- self .assertRaises (TypeError , _cleanPart , [1 ,"a" ])
27
+ self .assertRaises (TypeError , _clean_part , [1 , "a" ])
28
28
29
29
def testScalar (self ):
30
30
"""Test single scalar value."""
31
31
num = 1
32
- num_ = _cleanPart (num )
32
+ num_ = _clean_part (num )
33
33
34
34
assert isinstance (num_ , list )
35
35
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -38,7 +38,7 @@ def testScalar(self):
38
38
def testListScalar (self ):
39
39
"""Test single scalar value in list."""
40
40
num = [1 ]
41
- num_ = _cleanPart (num )
41
+ num_ = _clean_part (num )
42
42
43
43
assert isinstance (num_ , list )
44
44
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -47,7 +47,7 @@ def testListScalar(self):
47
47
def testTupleScalar (self ):
48
48
"""Test single scalar value in tuple."""
49
49
num = (1 )
50
- num_ = _cleanPart (num )
50
+ num_ = _clean_part (num )
51
51
52
52
assert isinstance (num_ , list )
53
53
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -56,7 +56,7 @@ def testTupleScalar(self):
56
56
def testList (self ):
57
57
"""Test multiple values in a list."""
58
58
num = [1 , 2 ]
59
- num_ = _cleanPart (num )
59
+ num_ = _clean_part (num )
60
60
61
61
assert isinstance (num_ , list )
62
62
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -65,7 +65,7 @@ def testList(self):
65
65
def testTuple (self ):
66
66
"""Test multiple values in tuple."""
67
67
num = (1 , 2 )
68
- num_ = _cleanPart (num )
68
+ num_ = _clean_part (num )
69
69
70
70
assert isinstance (num_ , list )
71
71
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -75,7 +75,7 @@ def testAllScalarTypes(self):
75
75
"""Test single scalar value for all valid data types."""
76
76
for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
77
77
num = dtype (1 )
78
- num_ = _cleanPart (num )
78
+ num_ = _clean_part (num )
79
79
80
80
assert isinstance (num_ , list )
81
81
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -84,7 +84,7 @@ def testAllScalarTypes(self):
84
84
def testNpArray (self ):
85
85
"""Test multiple values in numpy array."""
86
86
num = np .array ([1 , 2 ])
87
- num_ = _cleanPart (num )
87
+ num_ = _clean_part (num )
88
88
89
89
assert isinstance (num_ , list )
90
90
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -94,7 +94,7 @@ def testAllNumpyArrayTypes(self):
94
94
"""Test scalar value in numpy array of ndim=0 for all data types."""
95
95
for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
96
96
num = np .array (1 , dtype = dtype )
97
- num_ = _cleanPart (num )
97
+ num_ = _clean_part (num )
98
98
99
99
assert isinstance (num_ , list )
100
100
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -104,7 +104,7 @@ def testAllNumpyArrayTypes2(self):
104
104
"""Test numpy array for all types."""
105
105
for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
106
106
num = np .array ([1 , 2 ], dtype = dtype )
107
- num_ = _cleanPart (num )
107
+ num_ = _clean_part (num )
108
108
109
109
assert isinstance (num_ , list )
110
110
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -114,7 +114,7 @@ def testListAllTypes(self):
114
114
"""Test list of a single value for all data types."""
115
115
for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
116
116
num = [dtype (1 )]
117
- num_ = _cleanPart (num )
117
+ num_ = _clean_part (num )
118
118
assert isinstance (num_ , list )
119
119
assert np .all ([isinstance (part , list ) for part in num_ ])
120
120
np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
@@ -123,7 +123,7 @@ def testListAllTypes2(self):
123
123
"""List of list of numbers of all data types."""
124
124
for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
125
125
num = [dtype (1 ), dtype (2 )]
126
- num_ = _cleanPart (num )
126
+ num_ = _clean_part (num )
127
127
assert isinstance (num_ , list )
128
128
assert np .all ([isinstance (part , list ) for part in num_ ])
129
129
np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 , 2.0 ], dtype = float ))
@@ -132,7 +132,7 @@ def testTupleAllTypes(self):
132
132
"""Test tuple of a single value for all data types."""
133
133
for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
134
134
num = (dtype (1 ),)
135
- num_ = _cleanPart (num )
135
+ num_ = _clean_part (num )
136
136
assert isinstance (num_ , list )
137
137
assert np .all ([isinstance (part , list ) for part in num_ ])
138
138
np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
@@ -141,31 +141,31 @@ def testTupleAllTypes2(self):
141
141
"""Test tuple of a single value for all data types."""
142
142
for dtype in [int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 ]:
143
143
num = (dtype (1 ), dtype (2 ))
144
- num_ = _cleanPart (num )
144
+ num_ = _clean_part (num )
145
145
assert isinstance (num_ , list )
146
146
assert np .all ([isinstance (part , list ) for part in num_ ])
147
147
np .testing .assert_array_equal (num_ [0 ][0 ], array ([1 , 2 ], dtype = float ))
148
148
149
149
def testListListListInt (self ):
150
150
""" Test an int in a list of a list of a list."""
151
151
num = [[[1 ]]]
152
- num_ = _cleanPart (num )
152
+ num_ = _clean_part (num )
153
153
assert isinstance (num_ , list )
154
154
assert np .all ([isinstance (part , list ) for part in num_ ])
155
155
np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
156
156
157
157
def testListListListFloat (self ):
158
158
""" Test a float in a list of a list of a list."""
159
159
num = [[[1.0 ]]]
160
- num_ = _cleanPart (num )
160
+ num_ = _clean_part (num )
161
161
assert isinstance (num_ , list )
162
162
assert np .all ([isinstance (part , list ) for part in num_ ])
163
163
np .testing .assert_array_equal (num_ [0 ][0 ], array ([1.0 ], dtype = float ))
164
164
165
165
def testListListListInts (self ):
166
166
"""Test 2 lists of ints in a list in a list."""
167
167
num = [[[1 ,1 ],[2 ,2 ]]]
168
- num_ = _cleanPart (num )
168
+ num_ = _clean_part (num )
169
169
170
170
assert isinstance (num_ , list )
171
171
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -175,7 +175,7 @@ def testListListListInts(self):
175
175
def testListListListFloats (self ):
176
176
"""Test 2 lists of ints in a list in a list."""
177
177
num = [[[1.0 ,1.0 ],[2.0 ,2.0 ]]]
178
- num_ = _cleanPart (num )
178
+ num_ = _clean_part (num )
179
179
180
180
assert isinstance (num_ , list )
181
181
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -186,7 +186,7 @@ def testListListArray(self):
186
186
"""List of list of numpy arrays for all valid types."""
187
187
for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
188
188
num = [[array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )]]
189
- num_ = _cleanPart (num )
189
+ num_ = _clean_part (num )
190
190
191
191
assert isinstance (num_ , list )
192
192
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -197,7 +197,7 @@ def testTupleListArray(self):
197
197
"""Tuple of list of numpy arrays for all valid types."""
198
198
for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
199
199
num = ([array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )],)
200
- num_ = _cleanPart (num )
200
+ num_ = _clean_part (num )
201
201
202
202
assert isinstance (num_ , list )
203
203
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -208,7 +208,7 @@ def testListTupleArray(self):
208
208
"""List of tuple of numpy array for all valid types."""
209
209
for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
210
210
num = [(array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype ))]
211
- num_ = _cleanPart (num )
211
+ num_ = _clean_part (num )
212
212
213
213
assert isinstance (num_ , list )
214
214
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -220,7 +220,7 @@ def testTupleTuplesArrays(self):
220
220
for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
221
221
num = ((array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )),
222
222
(array ([3 ,4 ], dtype = dtype ),array ([4 ,4 ], dtype = dtype )))
223
- num_ = _cleanPart (num )
223
+ num_ = _clean_part (num )
224
224
225
225
assert isinstance (num_ , list )
226
226
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -232,7 +232,7 @@ def testListTuplesArrays(self):
232
232
for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
233
233
num = [(array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )),
234
234
(array ([3 ,4 ], dtype = dtype ),array ([4 ,4 ], dtype = dtype ))]
235
- num_ = _cleanPart (num )
235
+ num_ = _clean_part (num )
236
236
237
237
assert isinstance (num_ , list )
238
238
assert np .all ([isinstance (part , list ) for part in num_ ])
@@ -244,7 +244,7 @@ def testListListArrays(self):
244
244
for dtype in int , int8 , int16 , int32 , int64 , float , float16 , float32 , float64 , float128 :
245
245
num = [[array ([1 ,1 ], dtype = dtype ),array ([2 ,2 ], dtype = dtype )],
246
246
[array ([3 ,3 ], dtype = dtype ),array ([4 ,4 ], dtype = dtype )]]
247
- num_ = _cleanPart (num )
247
+ num_ = _clean_part (num )
248
248
249
249
assert len (num_ ) == 2
250
250
assert np .all ([isinstance (part , list ) for part in num_ ])
0 commit comments