Repository: python-control/python-control

Issue:
ValueError raised for certain systems with nyquist_response
For certain systems, when "indent_direction" is set to 'none', a ValueError is thrown on https://github.com/python-control/python-control/blob/71bd7319fe324f7b7ff14b8210420843bf06d7d2/control/freqplot.py#L1456 when there is an attempt at casting the number of encirclements to an integer, but the number of encirclements is not a valid number (NaN).

Code to reproduce:
```Python
import sympy as smp
from control import tf, nyquist_response
s = tf('s')

tf1 = ((1 + 5/s)/(1 + 0.5/s))**2   # Double-Lag-Compensator

nyquist_response(tf1, warn_encirclements=False, indent_direction='none')
```

Hints from issue comments:

Solution patch:
diff --git a/control/freqplot.py b/control/freqplot.py
index 3bc3a0c24..456431f38 100644
--- a/control/freqplot.py
+++ b/control/freqplot.py
@@ -1447,6 +1447,12 @@ def nyquist_response(
         else:
             contour = np.exp(splane_contour * sys.dt)
 
+        # Make sure we don't try to evaluate at a pole
+        if isinstance(sys, (StateSpace, TransferFunction)):
+            if any([pole in contour for pole in sys.poles()]):
+                raise RuntimeError(
+                    "attempt to evaluate at a pole; indent required")
+
         # Compute the primary curve
         resp = sys(contour)
 


Test patch:
diff --git a/control/tests/nyquist_test.py b/control/tests/nyquist_test.py
index 0d6907b64..8d6fd8561 100644
--- a/control/tests/nyquist_test.py
+++ b/control/tests/nyquist_test.py
@@ -517,6 +517,15 @@ def test_nyquist_frd():
     warnings.resetwarnings()
 
 
+def test_no_indent_pole():
+    s = ct.tf('s')
+    sys = ((1 + 5/s)/(1 + 0.5/s))**2   # Double-Lag-Compensator
+
+    with pytest.raises(RuntimeError, match="evaluate at a pole"):
+        resp = ct.nyquist_response(
+            sys, warn_encirclements=False, indent_direction='none')
+
+
 if __name__ == "__main__":
     #
     # Interactive mode: generate plots for manual viewing