Skip to content

Commit 140ca08

Browse files
fix PEP8 compliance style and preserve pole type
1 parent 78b6fc2 commit 140ca08

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

control/lti.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ def damp(self):
159159
poles = self.pole()
160160

161161
if isdtime(self, strict=True):
162-
poles = poles.astype(complex)
163-
splane_poles = np.log(poles)/self.dt
162+
splane_poles = np.log(poles.astype(complex))/self.dt
164163
else:
165164
splane_poles = poles
166165
wn = absolute(splane_poles)

control/tests/lti_test.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,14 @@ def test_damp(self):
7070
np.testing.assert_almost_equal(sys_dt.damp(), expected_dt)
7171
np.testing.assert_almost_equal(damp(sys_dt), expected_dt)
7272

73-
#also check that for a discrete system with a negative real pole the damp function can extract wn and theta.
73+
#also check that for a discrete system with a negative real pole the damp function can extract wn and zeta.
7474
p2_zplane = -0.2
75-
sys_dt2 = tf(1,[1,-p2_zplane],dt)
76-
wn2, zeta2, _ = sys_dt2.damp()
77-
p2 = -wn2 * zeta2 + 1j * wn2 * np.sqrt(1 - zeta2**2)
78-
p2_zplane = np.exp(p2*dt)
79-
np.testing.assert_almost_equal(sys_dt2.pole(),p2_zplane)
75+
sys_dt2 = tf(1, [1, -p2_zplane], dt)
76+
wn2, zeta2, p2 = sys_dt2.damp()
77+
p2_splane = -wn2 * zeta2 + 1j * wn2 * np.sqrt(1 - zeta2**2)
78+
p2_zplane = np.exp(p2_splane * dt)
79+
np.testing.assert_almost_equal(p2, p2_zplane)
8080

81-
8281
def test_dcgain(self):
8382
sys = tf(84, [1, 2])
8483
np.testing.assert_allclose(sys.dcgain(), 42)

0 commit comments

Comments
 (0)