Skip to content

Add 's' and 'z' variable support to tf() #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions control/tests/matlab_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,22 @@ def testCombi01(self):
self.assertAlmostEqual(wg, 0.176469728448)
self.assertAlmostEqual(wp, 0.0616288455466)

def test_tf_string_args(self):
# Make sure that the 's' variable is defined properly
s = tf('s')
G = (s + 1)/(s**2 + 2*s + 1)
np.testing.assert_array_almost_equal(G.num, [[[1, 1]]])
np.testing.assert_array_almost_equal(G.den, [[[1, 2, 1]]])
self.assertTrue(isctime(G, strict=True))

# Make sure that the 'z' variable is defined properly
z = tf('z')
G = (z + 1)/(z**2 + 2*z + 1)
np.testing.assert_array_almost_equal(G.num, [[[1, 1]]])
np.testing.assert_array_almost_equal(G.den, [[[1, 2, 1]]])
self.assertTrue(isdtime(G, strict=True))


#! TODO: not yet implemented
# def testMIMOtfdata(self):
# sisotf = ss2tf(self.siso_ss1)
Expand Down
17 changes: 16 additions & 1 deletion control/tests/xferfcn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
ss2tf
from control.lti import evalfr
from control.exception import slycot_check
from control.lti import isctime, isdtime
from control.dtime import sample_system
# from control.lti import isdtime


class TestXferFcn(unittest.TestCase):
Expand Down Expand Up @@ -704,6 +704,21 @@ def test_ss2tf(self):
np.testing.assert_almost_equal(sys.num, true_sys.num)
np.testing.assert_almost_equal(sys.den, true_sys.den)

def test_class_constants(self):
# Make sure that the 's' variable is defined properly
s = TransferFunction.s
G = (s + 1)/(s**2 + 2*s + 1)
np.testing.assert_array_almost_equal(G.num, [[[1, 1]]])
np.testing.assert_array_almost_equal(G.den, [[[1, 2, 1]]])
self.assertTrue(isctime(G, strict=True))

# Make sure that the 'z' variable is defined properly
z = TransferFunction.z
G = (z + 1)/(z**2 + 2*z + 1)
np.testing.assert_array_almost_equal(G.num, [[[1, 1]]])
np.testing.assert_array_almost_equal(G.den, [[[1, 2, 1]]])
self.assertTrue(isdtime(G, strict=True))

def test_printing(self):
# SISO, continuous time
sys = ss2tf(rss(4, 1, 1))
Expand Down
Loading