Skip to content

Commit 8e3ddd2

Browse files
committed
lti.evalfr now wraps sys._evalfr rather than sys.horner
1 parent d3142ff commit 8e3ddd2

File tree

5 files changed

+18
-25
lines changed

5 files changed

+18
-25
lines changed

control/lti.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -379,20 +379,16 @@ def damp(sys, doprint=True):
379379
(p.real, p.imag, d, w))
380380
return wn, damping, poles
381381

382-
def evalfr(sys, x):
382+
def evalfr(sys, omega):
383383
"""
384-
Evaluate the transfer function of an LTI system for a single complex
385-
number x.
386-
387-
To evaluate at a frequency, enter x = omega*j, where omega is the
388-
frequency in radians
384+
Evaluate the transfer function of an LTI system at a frequency omega.
389385
390386
Parameters
391387
----------
392388
sys: StateSpace or TransferFunction
393389
Linear system
394-
x: scalar
395-
Complex number
390+
omega: scalar
391+
frequency in rad/sec
396392
397393
Returns
398394
-------
@@ -405,22 +401,19 @@ def evalfr(sys, x):
405401
406402
Notes
407403
-----
408-
This function is a wrapper for StateSpace.evalfr and
409-
TransferFunction.evalfr.
404+
This function is a wrapper for StateSpace._evalfr and
405+
TransferFunction._evalfr.
410406
411407
Examples
412408
--------
413409
>>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
414-
>>> evalfr(sys, 1j)
410+
>>> evalfr(sys, 1)
415411
array([[ 44.8-21.4j]])
416-
>>> # This is the transfer function matrix evaluated at s = i.
412+
>>> # This is the transfer function matrix evaluated at s = 1.
417413
418414
.. todo:: Add example with MIMO system
419415
"""
420-
if issiso(sys):
421-
return sys.horner(x)[0][0]
422-
return sys.horner(x)
423-
416+
return sys._evalfr(omega)
424417

425418
def freqresp(sys, omega):
426419
"""

control/tests/matlab_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def testFreqresp(self):
369369
freqresp(self.siso_tf3, w)
370370

371371
def testEvalfr(self):
372-
w = 1j
372+
w = 1
373373
np.testing.assert_almost_equal(evalfr(self.siso_ss1, w), 44.8-21.4j)
374374
evalfr(self.siso_ss2, w)
375375
evalfr(self.siso_ss3, w)

control/tests/statesp_array_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def test_evalfr(self):
195195
0.128919037199125 - 0.143824945295405j]]
196196

197197
# Correct versions of the call
198-
np.testing.assert_almost_equal(evalfr(sys, 1j), resp)
198+
np.testing.assert_almost_equal(evalfr(sys, 1), resp)
199199
np.testing.assert_almost_equal(sys._evalfr(1.), resp)
200200

201201
# Deprecated version of the call (should generate warning)

control/tests/statesp_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def test_evalfr(self):
204204
0.128919037199125 - 0.143824945295405j]]
205205

206206
# Correct versions of the call
207-
np.testing.assert_almost_equal(evalfr(sys, 1j), resp)
207+
np.testing.assert_almost_equal(evalfr(sys, 1), resp)
208208
np.testing.assert_almost_equal(sys._evalfr(1.), resp)
209209

210210
# Deprecated version of the call (should generate warning)
@@ -668,8 +668,8 @@ def test_sample_system_prewarping(self):
668668
plant = StateSpace(A,B,C,0)
669669
plant_d_warped = plant.sample(Ts, 'bilinear', prewarp_frequency=wwarp)
670670
np.testing.assert_array_almost_equal(
671-
evalfr(plant, wwarp*1j),
672-
evalfr(plant_d_warped, np.exp(wwarp*1j*Ts)),
671+
evalfr(plant, wwarp),
672+
evalfr(plant_d_warped, wwarp),
673673
decimal=4)
674674

675675

control/tests/xferfcn_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,10 @@ def test_evalfr_siso(self):
391391

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

394-
np.testing.assert_array_almost_equal(evalfr(sys, 1j),
394+
np.testing.assert_array_almost_equal(evalfr(sys, 1),
395395
np.array([[-0.5 - 0.5j]]))
396396
np.testing.assert_array_almost_equal(
397-
evalfr(sys, 32j),
397+
evalfr(sys, 32),
398398
np.array([[0.00281959302585077 - 0.030628473607392j]]))
399399

400400
# Test call version as well
@@ -929,8 +929,8 @@ def test_sample_system_prewarping(self):
929929
plant = ss2tf(plant)
930930
plant_d_warped = plant.sample(Ts, 'bilinear', prewarp_frequency=wwarp)
931931
np.testing.assert_array_almost_equal(
932-
evalfr(plant, wwarp*1j),
933-
evalfr(plant_d_warped, np.exp(wwarp*1j*Ts)),
932+
evalfr(plant, wwarp),
933+
evalfr(plant_d_warped, wwarp),
934934
decimal=4)
935935

936936

0 commit comments

Comments
 (0)