Skip to content

Commit be9e7ea

Browse files
committed
add a few more unit tests for coverage
1 parent 8912b77 commit be9e7ea

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

control/iosys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def _find_signal(self, name, sigdict): return sigdict.get(name, None)
423423

424424
# Update parameters used for _rhs, _out (used by subclasses)
425425
def _update_params(self, params, warning=False):
426-
if (warning):
426+
if warning:
427427
warn("Parameters passed to InputOutputSystem ignored.")
428428

429429
def _rhs(self, t, x, u, params={}):

control/tests/iosys_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,32 @@ def test_operand_incompatible(self, Pout, Pin, C, op):
13071307
with pytest.raises(ValueError, match="incompatible"):
13081308
PC = op(P, C)
13091309

1310+
@pytest.mark.parametrize(
1311+
"C, op", [
1312+
(None, ct.LinearIOSystem.__mul__),
1313+
(None, ct.LinearIOSystem.__rmul__),
1314+
(None, ct.LinearIOSystem.__add__),
1315+
(None, ct.LinearIOSystem.__radd__),
1316+
(None, ct.LinearIOSystem.__sub__),
1317+
(None, ct.LinearIOSystem.__rsub__),
1318+
])
1319+
def test_operand_badtype(self, C, op):
1320+
P = ct.LinearIOSystem(
1321+
ct.rss(2, 2, 2, strictly_proper=True), name='P')
1322+
with pytest.raises(TypeError, match="Unknown"):
1323+
op(P, C)
1324+
1325+
def test_neg_badsize(self):
1326+
# Create a system of unspecified size
1327+
sys = ct.InputOutputSystem()
1328+
with pytest.raises(ValueError, match="Can't determine"):
1329+
-sys
1330+
1331+
def test_bad_signal_list(self):
1332+
# Create a ystem with a bad signal list
1333+
with pytest.raises(TypeError, match="Can't parse"):
1334+
ct.InputOutputSystem(inputs=[1, 2, 3])
1335+
13101336
def test_docstring_example(self):
13111337
P = ct.LinearIOSystem(
13121338
ct.rss(2, 2, 2, strictly_proper=True), name='P')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy