Skip to content

Commit cab7fa0

Browse files
authored
Merge pull request python-control#219 from murrayrm/fix_slycot-zero
Fix slycot zero Small fix of a bug that is blocking 0.8.0 release => merging without external review.
2 parents f79fbe4 + 87ec281 commit cab7fa0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

control/statesp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,11 @@ def zero(self):
525525
out = ab08nd(self.A.shape[0], self.B.shape[1], self.C.shape[0],
526526
self.A, self.B, self.C, self.D)
527527
nu = out[0]
528-
return sp.linalg.eigvals(out[8][0:nu,0:nu], out[9][0:nu,0:nu])
528+
if nu == 0:
529+
return np.array([])
530+
else:
531+
return sp.linalg.eigvals(out[8][0:nu,0:nu], out[9][0:nu,0:nu])
532+
529533
except ImportError: # Slycot unavailable. Fall back to scipy.
530534
if self.C.shape[0] != self.D.shape[1]:
531535
raise NotImplementedError("StateSpace.zero only supports "

control/tests/statesp_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ def testPole(self):
4242

4343
np.testing.assert_array_almost_equal(p, true_p)
4444

45+
def testEmptyZero(self):
46+
"""Test to make sure zero() works with no zeros in system"""
47+
sys = _convertToStateSpace(TransferFunction([1], [1,2,1]))
48+
np.testing.assert_array_equal(sys.zero(), np.array([]))
49+
4550
@unittest.skipIf(not slycot_check(), "slycot not installed")
4651
def testMIMOZero_nonsquare(self):
4752
"""Evaluate the zeros of a MIMO system."""

0 commit comments

Comments
 (0)