8000 clean up docstrings, examples · python-control/python-control@aed5706 · GitHub
[go: up one dir, main page]

Skip to content

Commit aed5706

Browse files
committed
clean up docstrings, examples
1 parent 5eaee66 commit aed5706

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

control/nlsys.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
__all__ = ['NonlinearIOSystem', 'InterconnectedSystem', 'nlsys',
3434
'input_output_response', 'find_eqpt', 'linearize',
35-
'interconnect', 'connection_table', 'find_operating_point']
35+
'interconnect', 'connection_table', 'OperatingPoint',
36+
'find_operating_point']
3637

3738

3839
class NonlinearIOSystem(InputOutputSystem):
@@ -92,7 +93,7 @@ class NonlinearIOSystem(InputOutputSystem):
9293
generic name <sys[id]> is generated with a unique integer id.
9394
9495
params : dict, optional
95-
Parameter values for the system. Passed to the evaluation functions
96+
Parameter values for the system. Passed to the evaluation functions
9697
for the system as default values, overriding internal defaults.
9798
9899
See Also
@@ -1685,6 +1686,8 @@ class OperatingPoint(object):
16851686
State vector at the operating point.
16861687
inputs : array
16871688
Input vector at the operating point.
1689+
outputs : array, optional
1690+
Output vector at the operating point.
16881691
result : :class:`scipy.optimize.OptimizeResult`, optional
16891692
Result from the :func:`scipy.optimize.root` function, if available.
16901693
@@ -1740,7 +1743,7 @@ def find_operating_point(
17401743
for the desired inputs, outputs, states, or state updates of the system.
17411744
17421745
In its simplest form, `find_operating_point` finds an equilibrium point
1743-
given either the desired input or desired output:
1746+
given either the desired input or desired output::
17441747
17451748
xeq, ueq = find_operating_point(sys, x0, u0)
17461749
xeq, ueq = find_operating_point(sys, x0, u0, y0)
@@ -1810,19 +1813,15 @@ def find_operating_point(
18101813
18111814
Returns
18121815
-------
1813-
states : array of states
1814-
Value of the states at the equilibrium point, or `None` if no
1815-
equilibrium point was found and `return_result` was False.
1816-
inputs : array of input values
1817-
Value of the inputs at the equilibrium point, or `None` if no
1818-
equilibrium point was found and `return_result` was False.
1819-
outputs : array of output values, optional
1820-
If `return_y` is True, returns the value of the outputs at the
1821-
equilibrium point, or `None` if no equilibrium point was found and
1822-
`return_result` was False.
1823-
result : :class:`scipy.optimize.OptimizeResult`, optional
1824-
If `return_result` is True, returns the `result` from the
1825-
:func:`scipy.optimize.root` function.
1816+
op_point : OperatingPoint
1817+
The solution represented as an `OperatingPoint` object. The main
1818+
attributes are `states` and `inputs`, which represent the state
1819+
and input arrays at the operating point. See
1820+
:class:`OperatingPoint` for a description of other attributes.
1821+
1822+
If accessed as a tuple, returns `states`, `inputs`, and optionally
1823+
`outputs` and `result` based on the `return_y` and `return_result`
1824+
parameters.
18261825
18271826
Notes
18281827
-----
@@ -1839,7 +1838,7 @@ def find_operating_point(
18391838
`False`, the returned state and input for the operating point will be
18401839
`None`. If `return_result` is `True`, then the return values from
18411840
:func:`scipy.optimize.root` will be returned (but may not be valid).
1842-
If `root_method` is set to `lm`, then the least squares solution (in
1841+
If `root_method` is set to 'lm', then the least squares solution (in
18431842
the free variables) will be returned.
18441843
18451844
"""
@@ -1956,8 +1955,8 @@ def rootfun(z):
19561955
# * output_vars: indices of outputs that must be constrained
19571956
#
19581957
# This index lists can all be precomputed based on the `iu`, `iy`,
1959-
# `ix`, and `idx` lists that were passed as arguments to `find_eqpt`
1960-
# and were processed above.
1958+
# `ix`, and `idx` lists that were passed as arguments to
1959+
# `find_operating_point` and were processed above.
19611960

19621961
# Get the states and inputs that were not listed as fixed
19631962
state_vars = (range(nstates) if not len(ix)

control/phaseplot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
from .ctrlplot import ControlPlot, _add_arrows_to_line2D, _get_color, \
4040
_process_ax_keyword, _update_plot_title
4141
from .exception import ControlNotImplemented
42-
from .nlsys import NonlinearIOSystem, find_eqpt, input_output_response
42+
from .nlsys import NonlinearIOSystem, find_operating_point, \
43+
input_output_response
4344

4445
__all__ = ['phase_plane_plot', 'phase_plot', 'box_grid']
4546

@@ -853,7 +854,7 @@ def _find_equilpts(sys, points, params=None):
853854
equilpts = []
854855
for i, x0 in enumerate(points):
855856
# Look for an equilibrium point near this point
856-
xeq, ueq = find_eqpt(sys, x0, 0, params=params)
857+
xeq, ueq = find_operating_point(sys, x0, 0, params=params)
857858

858859
if xeq is None:
859860
continue # didn't find anything

control/tests/iosys_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,10 @@ def test_operating_point():
21422142
np.testing.assert_allclose(linsys_orig.C, linsys_oppt.C)
21432143
np.testing.assert_allclose(linsys_orig.D, linsys_oppt.D)
21442144

2145+
# Call find_operating point with method and keyword arguments
2146+
op_point = ct.find_operating_point(
2147+
sys, 0, 0, root_method='lm', root_kwargs={'tol': 1e-6})
2148+
21452149

21462150
def test_iosys_sample():
21472151
csys = ct.rss(2, 1, 1)

doc/iosys.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ Module classes and functions
544544
~control.InterconnectedSystem
545545
~control.LinearICSystem
546546
~control.NonlinearIOSystem
547+
~control.OperatingPoint
547548

548549
.. autosummary::
549550
:toctree: generated/

examples/cruise-control.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def motor_torque(omega, params={}):
165165

166166
for m in (1200, 1600, 2000):
167167
# Compute the equilibrium state for the system
168-
X0, U0 = ct.find_eqpt(
168+
X0, U0 = ct.find_operating_point(
169169
cruise_tf, [0, vref[0]], [vref[0], gear[0], theta0[0]],
170170
iu=[1, 2], y0=[vref[0], 0], iy=[0], params={'m': m})
171171

@@ -347,7 +347,7 @@ def cruise_plot(sys, t, y, label=None, t_hill=None, vref=20, antiwindup=False,
347347

348348
# Compute the equilibrium throttle setting for the desired speed (solve for x
349349
# and u given the gear, slope, and desired output velocity)
350-
X0, U0, Y0 = ct.find_eqpt(
350+
X0, U0, Y0 = ct.find_operating_point(
351351
cruise_pi, [vref[0], 0], [vref[0], gear[0], theta0[0]],
352352
y0=[0, vref[0]], iu=[1, 2], iy=[1], return_y=True)
353353

0 commit comments

Comments
 (0)
0