Skip to content

Commit ba7817c

Browse files
committed
cover TransferFunction.returnScipySignalLTI() (backported from #438)
1 parent d3142ff commit ba7817c

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

control/tests/xferfcn_test.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# RMM, 30 Mar 2011 (based on TestXferFcn from v0.4a)
55

66
import unittest
7+
import pytest
8+
79
import sys as pysys
810
import numpy as np
911
from control.statesp import StateSpace, _convertToStateSpace, rss
@@ -912,8 +914,8 @@ def test_repr(self):
912914
np.testing.assert_array_almost_equal(
913915
H.den[p][m], H2.den[p][m])
914916
self.assertEqual(H.dt, H2.dt)
915-
916-
def test_sample_system_prewarping(self):
917+
918+
def test_sample_system_prewarping(self):
917919
"""test that prewarping works when converting from cont to discrete time system"""
918920
A = np.array([
919921
[ 0.00000000e+00, 1.00000000e+00, 0.00000000e+00, 0.00000000e+00],
@@ -929,10 +931,29 @@ def test_sample_system_prewarping(self):
929931
plant = ss2tf(plant)
930932
plant_d_warped = plant.sample(Ts, 'bilinear', prewarp_frequency=wwarp)
931933
np.testing.assert_array_almost_equal(
932-
evalfr(plant, wwarp*1j),
933-
evalfr(plant_d_warped, np.exp(wwarp*1j*Ts)),
934+
evalfr(plant, wwarp*1j),
935+
evalfr(plant_d_warped, np.exp(wwarp*1j*Ts)),
934936
decimal=4)
935937

938+
@pytest.mark.parametrize("dt",
939+
[None,
940+
0,
941+
pytest.param(1, marks=pytest.mark.xfail(
942+
reason="not implemented")),
943+
pytest.param(1, marks=pytest.mark.xfail(
944+
reason="not implemented"))])
945+
def test_returnScipySignalLTI(dt):
946+
"""Test returnScipySignalLTI method"""
947+
sys = TransferFunction([[[11], [12], [13]],
948+
[[21], [22], [23]]],
949+
[[[1, -1]] * 3] * 2,
950+
dt)
951+
sslti = sys.returnScipySignalLTI()
952+
for i in range(2):
953+
for j in range(3):
954+
np.testing.assert_allclose(sslti[i][j].num, sys.num[i][j])
955+
np.testing.assert_allclose(sslti[i][j].den, sys.den[i][j])
956+
936957

937958
if __name__ == "__main__":
938959
unittest.main()

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