Skip to content

Commit b1a7d7c

Browse files
committed
allow root locus maps with only 1 point
1 parent d810d5a commit b1a7d7c

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

control/pzmap.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,14 +607,16 @@ def _compute_root_locus_limits(response):
607607
# Find the local maxima of root locus curve
608608
xpeaks = np.where(
609609
np.diff(np.abs(locus.real)) < 0, locus.real[0:-1], 0)
610-
xlim = [
611-
min(xlim[0], np.min(xpeaks) * rho),
612-
max(xlim[1], np.max(xpeaks) * rho)
613-
]
610+
if xpeaks.size > 0:
611+
xlim = [
612+
min(xlim[0], np.min(xpeaks) * rho),
613+
max(xlim[1], np.max(xpeaks) * rho)
614+
]
614615

615616
ypeaks = np.where(
616617
np.diff(np.abs(locus.imag)) < 0, locus.imag[0:-1], 0)
617-
ylim = max(ylim, np.max(ypeaks) * rho)
618+
if ypeaks.size > 0:
619+
ylim = max(ylim, np.max(ypeaks) * rho)
618620

619621
if isctime(dt=response.dt):
620622
# Adjust the limits to include some space around features

control/rlocus.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ def root_locus_map(sysdata, gains=None):
5656
Returns
5757
-------
5858
rldata : PoleZeroData or list of PoleZeroData
59-
Root locus data object(s) corresponding to the . The loci of
60-
the root locus diagram are available in the array
61-
`rldata.loci`, indexed by the gain index and the locus index,
62-
and the gains are in the array `rldata.gains`.
59+
Root locus data object(s). The loci of the root locus diagram are
60+
available in the array `rldata.loci`, indexed by the gain index and
61+
the locus index, and the gains are in the array `rldata.gains`.
6362
6463
Notes
6564
-----

control/tests/rlocus_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,18 @@ def test_root_locus_documentation(savefigs=False):
287287

288288
# Run tests that generate plots for the documentation
289289
test_root_locus_documentation(savefigs=True)
290+
291+
292+
# https://github.com/python-control/python-control/issues/1063
293+
def test_rlocus_singleton():
294+
# Generate a root locus map for a singleton
295+
L = ct.tf([1, 1], [1, 2, 3])
296+
rldata = ct.root_locus_map(L, 1)
297+
np.testing.assert_equal(rldata.gains, np.array([1]))
298+
assert rldata.loci.shape == (1, 2)
299+
300+
# Generate the root locus plot (no loci)
301+
cplt = rldata.plot()
302+
assert len(cplt.lines[0, 0]) == 1 # poles (one set of markers)
303+
assert len(cplt.lines[0, 1]) == 1 # zeros
304+
assert len(cplt.lines[0, 2]) == 2 # loci (two 0-length lines)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy