Skip to content

Commit 066d47e

Browse files
committed
test that rss and drss return strictly_proper, if desired
1 parent 203cae8 commit 066d47e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

control/tests/statesp_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,17 @@ def test_pole(self, states, outputs, inputs):
855855
for z in p:
856856
assert z.real < 0
857857

858+
@pytest.mark.parametrize('strictly_proper', [True, False])
859+
def test_strictly_proper(self, strictly_proper):
860+
"""Test that the strictly_proper argument returns a correct D."""
861+
for i in range(100):
862+
# The probability that drss(..., strictly_proper=False) returns an
863+
# all zero D 100 times in a row is 0.5**100 = 7.89e-31
864+
sys = rss(1, 1, 1, strictly_proper=strictly_proper)
865+
if np.all(sys.D == 0.) == strictly_proper:
866+
break
867+
assert np.all(sys.D == 0.) == strictly_proper
868+
858869

859870
class TestDrss:
860871
"""These are tests for the proper functionality of statesp.drss."""
@@ -884,6 +895,17 @@ def test_pole(self, states, outputs, inputs):
884895
for z in p:
885896
assert abs(z) < 1
886897

898+
@pytest.mark.parametrize('strictly_proper', [True, False])
899+
def test_strictly_proper(self, strictly_proper):
900+
"""Test that the strictly_proper argument returns a correct D."""
901+
for i in range(100):
902+
# The probability that drss(..., strictly_proper=False) returns an
903+
# all zero D 100 times in a row is 0.5**100 = 7.89e-31
904+
sys = drss(1, 1, 1, strictly_proper=strictly_proper)
905+
if np.all(sys.D == 0.) == strictly_proper:
906+
break
907+
assert np.all(sys.D == 0.) == strictly_proper
908+
887909

888910
class TestLTIConverter:
889911
"""Test returnScipySignalLTI method"""

0 commit comments

Comments
 (0)