Skip to content

fix bug in root_locus_plot identified by @NikolaiVChr in issue #1016 #1021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions control/pzmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,19 +496,17 @@ def _find_root_locus_gain(event, sys, ax):
# Get the current axis limits to set various thresholds
xlim, ylim = ax.get_xlim(), ax.get_ylim()

# Catch type error when event click is in the figure but not in an axis
# Catch type error when event click is in the figure but not on curve
try:
s = complex(event.xdata, event.ydata)
K = -1. / sys(s)
K_xlim = -1. / sys(
complex(event.xdata + 0.05 * abs(xlim[1] - xlim[0]), event.ydata))
K_ylim = -1. / sys(
complex(event.xdata, event.ydata + 0.05 * abs(ylim[1] - ylim[0])))

except TypeError:
K = float('inf')
K_xlim = float('inf')
K_ylim = float('inf')
K, s = float('inf'), None
K_xlim = K_ylim = float('inf')

#
# Compute tolerances for deciding if we clicked on the root locus
Expand All @@ -526,9 +524,8 @@ def _find_root_locus_gain(event, sys, ax):
if abs(K.real) > 1e-8 and abs(K.imag / K.real) < gain_tolerance and \
event.inaxes == ax.axes and K.real > 0.:
return K.real, s

else:
return None, s
return None, None


# Mark points corresponding to a given gain on root locus plot
Expand Down
Loading