scipy-based implementation of ss2tf · python-control/python-control@e539c72

@@ -10,9 +10,9 @@

1010

import pytest

11111212

import control as ct

13-

from control import (StateSpace, TransferFunction, defaults, evalfr, isctime,

14-

isdtime, reset_defaults, rss, sample_system, set_defaults,

15-

ss, ss2tf, tf, tf2ss, zpk)

13+

from control import StateSpace, TransferFunction, defaults, evalfr, isctime, \

14+

isdtime, reset_defaults, rss, sample_system, set_defaults, ss, ss2tf, tf, \

15+

tf2ss, zpk

1616

from control.statesp import _convert_to_statespace

1717

from control.tests.conftest import slycotonly

1818

from control.xferfcn import _convert_to_transfer_function, _tf_close_coeff

@@ -186,7 +186,6 @@ def test_reverse_sign_siso(self):

186186

np.testing.assert_allclose(sys2.num, [[[-1., -3., -5.]]])

187187

np.testing.assert_allclose(sys2.den, [[[1., 6., 2., -1.]]])

188188189-

@slycotonly

190189

def test_reverse_sign_mimo(self):

191190

"""Negate a MIMO system."""

192191

num1 = [[[1., 2.], [0., 3.], [2., -1.]],

@@ -228,7 +227,6 @@ def test_add_siso(self):

228227

np.testing.assert_allclose(sys3.num, [[[20., 4., -8]]])

229228

np.testing.assert_allclose(sys3.den, [[[1., 6., 1., -7., -2., 1.]]])

230229231-

@slycotonly

232230

def test_add_mimo(self):

233231

"""Add two MIMO systems."""

234232

num1 = [[[1., 2.], [0., 3.], [2., -1.]],

@@ -276,7 +274,6 @@ def test_subtract_siso(self):

276274

np.testing.assert_allclose(sys4.num, [[[-2., -6., 12., 10., 2.]]])

277275

np.testing.assert_allclose(sys4.den, [[[1., 6., 1., -7., -2., 1.]]])

278276279-

@slycotonly

280277

def test_subtract_mimo(self):

281278

"""Subtract two MIMO systems."""

282279

num1 = [[[1., 2.], [0., 3.], [2., -1.]],

@@ -327,7 +324,6 @@ def test_multiply_siso(self):

327324

np.testing.assert_allclose(sys3.num, sys4.num)

328325

np.testing.assert_allclose(sys3.den, sys4.den)

329326330-

@slycotonly

331327

def test_multiply_mimo(self):

332328

"""Multiply two MIMO systems."""

333329

num1 = [[[1., 2.], [0., 3.], [2., -1.]],

@@ -714,7 +710,6 @@ def test_call_dtime(self):

714710

sys = TransferFunction([1., 3., 5], [1., 6., 2., -1], 0.1)

715711

np.testing.assert_array_almost_equal(sys(1j), -0.5 - 0.5j)

716712717-

@slycotonly

718713

def test_call_mimo(self):

719714

"""Evaluate the frequency response of a MIMO system at one frequency."""

720715

@@ -755,7 +750,6 @@ def test_frequency_response_siso(self):

755750

np.testing.assert_array_almost_equal(phase, truephase)

756751

np.testing.assert_array_almost_equal(omega, trueomega)

757752758-

@slycotonly

759753

def test_freqresp_mimo(self):

760754

"""Evaluate the MIMO magnitude and phase at multiple frequencies."""

761755

num = [[[1., 2.], [0., 3.], [2., -1.]],

@@ -852,7 +846,6 @@ def test_common_den_nonproper(self):

852846

_, den2, _ = tf2._common_den(allow_nonproper=True)

853847

np.testing.assert_array_almost_equal(den2, common_den_ref)

854848855-

@slycotonly

856849

def test_pole_mimo(self):

857850

"""Test for correct MIMO poles."""

858851

sys = TransferFunction(

@@ -936,7 +929,6 @@ def test_append(self):

936929

tf_appended_2 = tf1.append(tf2).append(tf3)

937930

assert _tf_close_coeff(tf_exp_2, tf_appended_2)

938931939-

@slycotonly

940932

def test_convert_to_transfer_function(self):

941933

"""Test for correct state space to transfer function conversion."""

942934

A = [[1., -2.], [-3., 4.]]

@@ -1023,7 +1015,6 @@ def test_state_space_conversion_mimo(self):

10231015

np.testing.assert_array_almost_equal(H.num[1][0], H2.num[1][0])

10241016

np.testing.assert_array_almost_equal(H.den[1][0], H2.den[1][0])

102510171026-

@slycotonly

10271018

def test_indexing(self):

10281019

"""Test TF scalar indexing and slice"""

10291020

tm = ss2tf(rss(5, 3, 3))

@@ -1213,7 +1204,6 @@ def test_printing_polynomial(self, args, outputfmt, var, dt, dtstring):

12131204

assert len(polystr[0].split('\n')) == 4

12141205

assert polystr[2] == outputfmt.format(var=var)

121512061216-

@slycotonly

12171207

def test_printing_mimo(self):

12181208

"""Print MIMO, continuous time"""

12191209

sys = ss2tf(rss(4, 2, 3))

@@ -1332,7 +1322,6 @@ def test_printing_zpk_mimo(self, num, den, output):

13321322

res = str(G)

13331323

assert res.partition('\n\n')[2] == output

133413241335-

@slycotonly

13361325

def test_size_mismatch(self):

13371326

"""Test size mismacht"""

13381327

sys1 = ss2tf(rss(2, 2, 2))