Skip to content

Commit 5ddc195

Browse files
committed
test some invalid parameters
1 parent 8ac1d22 commit 5ddc195

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

control/sysnorm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _h2norm_slycot(sys, print_warning=True):
2828
try:
2929
from slycot import ab13bd
3030
except ImportError:
31-
ct.ControlSlycot("Can't find slycot module ab13bd")
31+
raise ct.ControlSlycot("Can't find slycot module ab13bd")
3232

3333
try:
3434
from slycot.exceptions import SlycotArithmeticError

control/tests/sysnorm_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,23 @@ def test_norm_3rd_order_mimo_system(method):
7676
Gd4 = ct.sample_system(G4, 0.1)
7777
assert np.allclose(ct.norm(Gd4, p='inf', method=method), 4.276759162964228) # Comparison to norm computed in MATLAB
7878
assert np.allclose(ct.norm(Gd4, p=2, method=method), 0.707434962289554) # Comparison to norm computed in MATLAB
79+
80+
81+
@pytest.mark.noslycot
82+
def test_sysnorm_no_slycot():
83+
"""Test that sysnorm raises ControlSlycot when slycot is requested but not available"""
84+
s = ct.tf('s')
85+
G = 1/(s+1)
86+
87+
with pytest.raises(ct.ControlSlycot, match="Can't find slycot module ab13bd"):
88+
ct.norm(G, p=2, method='slycot')
89+
90+
91+
def test_norm_invalid_p():
92+
"""Test that norm raises Error for invalid norm request"""
93+
s = ct.tf('s')
94+
G = 1/(s+1)
95+
96+
with pytest.raises(ct.ControlArgument,
97+
match="Norm computation for p=myownnorm currently not supported."):
98+
ct.norm(G, p='myownnorm', method=None)

0 commit comments

Comments
 (0)