Skip to content

Commit 94b6209

Browse files
committed
fix converstion exceptions to be TypeError
1 parent 4b7bf8a commit 94b6209

3 files changed

Lines changed: 7 additions & 13 deletions

File tree

control/iosys.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def __mul__(sys2, sys1):
220220
raise NotImplemented("Matrix multiplication not yet implemented")
221221

222222
elif not isinstance(sys1, InputOutputSystem):
223-
raise ValueError("Unknown I/O system object ", sys1)
223+
raise TypeError("Unknown I/O system object ", sys1)
224224

225225
# Make sure systems can be interconnected
226226
if sys1.noutputs != sys2.ninputs:
@@ -263,7 +263,7 @@ def __rmul__(sys1, sys2):
263263
raise NotImplemented("Matrix multiplication not yet implemented")
264264

265265
elif not isinstance(sys2, InputOutputSystem):
266-
raise ValueError("Unknown I/O system object ", sys1)
266+
raise TypeError("Unknown I/O system object ", sys1)
267267

268268
else:
269269
# Both systems are InputOutputSystems => use __mul__
@@ -281,7 +281,7 @@ def __add__(sys1, sys2):
281281
raise NotImplemented("Matrix addition not yet implemented")
282282

283283
elif not isinstance(sys2, InputOutputSystem):
284-
raise ValueError("Unknown I/O system object ", sys2)
284+
raise TypeError("Unknown I/O system object ", sys2)
285285

286286
# Make sure number of input and outputs match
287287
if sys1.ninputs != sys2.ninputs or sys1.noutputs != sys2.noutputs:

control/statesp.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,11 +1281,8 @@ def _convert_to_statespace(sys, **kw):
12811281
try:
12821282
D = _ssmatrix(sys)
12831283
return StateSpace([], [], [], D)
1284-
except Exception as e:
1285-
print("Failure to assume argument is matrix-like in"
1286-
" _convert_to_statespace, result %s" % e)
1287-
1288-
raise TypeError("Can't convert given type to StateSpace system.")
1284+
except:
1285+
raise TypeError("Can't convert given type to StateSpace system.")
12891286

12901287

12911288
# TODO: add discrete time option

control/xferfcn.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,11 +1290,8 @@ def _convert_to_transfer_function(sys, **kw):
12901290
num = [[[D[i, j]] for j in range(inputs)] for i in range(outputs)]
12911291
den = [[[1] for j in range(inputs)] for i in range(outputs)]
12921292
return TransferFunction(num, den)
1293-
except Exception as e:
1294-
print("Failure to assume argument is matrix-like in"
1295-
" _convertToTransferFunction, result %s" % e)
1296-
1297-
raise TypeError("Can't convert given type to TransferFunction system.")
1293+
except:
1294+
raise TypeError("Can't convert given type to TransferFunction system.")
12981295

12991296

13001297
def tf(*args, **kwargs):

0 commit comments

Comments
 (0)