Skip to content

Commit bad229a

Browse files
author
Henrik Sandberg
committed
* sysnorm: Changed default tolerance in norm to 1e-6.
* sysnorm_test: Use default tolerance in the tests.
1 parent b39710f commit bad229a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

control/sysnorm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def _h2norm_slycot(sys, print_warning=True):
8383

8484
#------------------------------------------------------------------------------
8585

86-
def norm(system, p=2, tol=1e-10, print_warning=True, method=None):
86+
def norm(system, p=2, tol=1e-6, print_warning=True, method=None):
8787
"""Computes norm of system.
8888
8989
Parameters

control/tests/sysnorm_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ def test_norm_1st_order_stable_system():
1616
s = ct.tf('s')
1717

1818
G1 = 1/(s+1)
19-
assert np.allclose(ct.norm(G1, p='inf', tol=1e-9 ), 1.0) # Comparison to norm computed in MATLAB
19+
assert np.allclose(ct.norm(G1, p='inf'), 1.0) # Comparison to norm computed in MATLAB
2020
assert np.allclose(ct.norm(G1, p=2), 0.707106781186547) # Comparison to norm computed in MATLAB
2121

2222
Gd1 = ct.sample_system(G1, 0.1)
23-
assert np.allclose(ct.norm(Gd1, p='inf', tol=1e-9), 1.0) # Comparison to norm computed in MATLAB
23+
assert np.allclose(ct.norm(Gd1, p='inf'), 1.0) # Comparison to norm computed in MATLAB
2424
assert np.allclose(ct.norm(Gd1, p=2), 0.223513699524858) # Comparison to norm computed in MATLAB
2525

2626

@@ -29,12 +29,12 @@ def test_norm_1st_order_unstable_system():
2929
s = ct.tf('s')
3030

3131
G2 = 1/(1-s)
32-
assert np.allclose(ct.norm(G2, p='inf', tol=1e-9), 1.0) # Comparison to norm computed in MATLAB
32+
assert np.allclose(ct.norm(G2, p='inf'), 1.0) # Comparison to norm computed in MATLAB
3333
with pytest.warns(UserWarning, match="System is unstable!"):
3434
assert ct.norm(G2, p=2) == float('inf') # Comparison to norm computed in MATLAB
3535

3636
Gd2 = ct.sample_system(G2, 0.1)
37-
assert np.allclose(ct.norm(Gd2, p='inf', tol=1e-9), 1.0) # Comparison to norm computed in MATLAB
37+
assert np.allclose(ct.norm(Gd2, p='inf'), 1.0) # Comparison to norm computed in MATLAB
3838
with pytest.warns(UserWarning, match="System is unstable!"):
3939
assert ct.norm(Gd2, p=2) == float('inf') # Comparison to norm computed in MATLAB
4040

@@ -66,9 +66,9 @@ def test_norm_3rd_order_mimo_system():
6666
[-0.863652821988714, -1.214117043615409, -0.006849328103348]])
6767
D = np.zeros((2,2))
6868
G4 = ct.ss(A,B,C,D) # Random system generated in MATLAB
69-
assert np.allclose(ct.norm(G4, p='inf', tol=1e-9), 4.276759162964244) # Comparison to norm computed in MATLAB
69+
assert np.allclose(ct.norm(G4, p='inf'), 4.276759162964244) # Comparison to norm computed in MATLAB
7070
assert np.allclose(ct.norm(G4, p=2), 2.237461821810309) # Comparison to norm computed in MATLAB
7171

7272
Gd4 = ct.sample_system(G4, 0.1)
73-
assert np.allclose(ct.norm(Gd4, p='inf', tol=1e-9), 4.276759162964228) # Comparison to norm computed in MATLAB
73+
assert np.allclose(ct.norm(Gd4, p='inf'), 4.276759162964228) # Comparison to norm computed in MATLAB
7474
assert np.allclose(ct.norm(Gd4, p=2), 0.707434962289554) # Comparison to norm computed in MATLAB

0 commit comments

Comments
 (0)