8000 add special processing for `sys` · murrayrm/python-control@b9cb89f · GitHub
[go: up one dir, main page]

Skip to content

Commit b9cb89f

Browse files
committed
add special processing for sys
1 parent 8b94a58 commit b9cb89f

File tree

15 files changed

+95
-67
lines changed

15 files changed

+95
-67
lines changed

control/frdata.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -928,12 +928,12 @@ def to_pandas(self):
928928
def _convert_to_frd(sys, omega, inputs=1, outputs=1):
929929
"""Convert a system to frequency response data form (if needed).
930930
931-
If sys is already an frd, and its frequency range matches or
932-
overlaps the range given in omega then it is returned. If sys is
933-
another LTI object or a transfer function, then it is converted to
934-
a frequency response data at the specified omega. If sys is a
935-
scalar, then the number of inputs and outputs can be specified
936-
manually, as in:
931+
If `sys` is already a frequency response data object, and its
932+
frequency range matches or overlaps the range given in omega then
933+
it is returned. If `sys` is another LTI object or a transfer
934+
function, then it is converted to a frequency response data at the
935+
specified omega. If `sys` is a scalar, then the number of inputs and
936+
outputs can be specified manually, as in:
937937
938938
>>> import numpy as np
939939
>>> from control.frdata import _convert_to_frd

control/lti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def frequency_response(
541541
frequency. If `squeeze` is True then single-dimensional axes are
542542
removed.
543543
544-
Returns a list of `FrequencyResponseData` objects if sys is
544+
Returns a list of `FrequencyResponseData` objects if `sys` is
545545
a list of systems.
546546
547547
Other Parameters

control/matlab/wrappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def bode(*args, **kwargs):
2929
sys : LTI, or list of LTI
3030
System for which the Bode response is plotted and give. Optionally
3131
a list of systems can be entered, or several systems can be
32-
specified (i.e. several parameters). The sys arguments may also be
32+
specified (i.e. several parameters). The `sys` arguments may also be
3333
interspersed with format strings. A frequency argument (array_like)
3434
may also be added (see Examples).
3535
omega : array

control/modelsimp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ def _expand_key(key):
255255

256256

257257
def balanced_reduction(sys, orders, method='truncate', alpha=None):
258-
"""Balanced reduced order model of sys of a given order.
258+
"""Balanced reduced order model of system of a given order.
259259
260-
States are eliminated based on Hankel singular value.
261-
If sys has unstable modes, they are removed, the
262-
balanced realization is done on the stable part, then
263-
reinserted in accordance with the reference below.
260+
States are eliminated based on Hankel singular value. If `sys` has
261+
unstable modes, they are removed, the balanced realization is done on
262+
the stable part, then reinserted in accordance with the reference
263+
below.
264264
265265
Reference: Hsu,C.S., and Hou,D., 1991,
266266
Reducing unstable linear control systems via real Schur transformation.

control/nlsys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ class InterconnectedSystem(NonlinearIOSystem):
585585
"""Interconnection of a set of input/output systems.
586586
587587
This class is used to implement a system that is an interconnection of
588-
input/output systems. The sys consists of a collection of subsystems
588+
input/output systems. The system consists of a collection of subsystems
589589
whose inputs and outputs are connected via a connection map. The overall
590590
system inputs and outputs are subsets of the subsystem inputs and outputs.
591591

control/sisotool.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ def sisotool(sys, initial_gain=None, xlim_rlocus=None, ylim_rlocus=None,
4141
Parameters
4242
----------
4343
sys : LTI object
44-
Linear input/output systems. If sys is SISO, use the same system for
45-
the root locus and step response. If it is desired to see a different
46-
step response than feedback(K*sys,1), such as a disturbance response,
47-
sys can be provided as a two-input, two-output system (e.g. by using
48-
`bdgalg.connect' or `iosys.interconnect`). For two-input,
49-
two-output system, sisotool inserts the negative of the selected gain
50-
K between the first output and first input and uses the second input
51-
and output for computing the step response. To see the disturbance
52-
response, configure your plant to have as its second input the
53-
disturbance input. To view the step response with a feedforward
54-
controller, give your plant two identical inputs, and sum your
55-
feedback controller and your feedforward controller and multiply them
56-
into your plant's second input. It is also possible to accomodate a
44+
Linear input/output systems. If `sys` is SISO, use the same system
45+
for the root locus and step response. If it is desired to see a
46+
different step response than ``feedback(K*sys, 1)``, such as a
47+
disturbance response, `sys` can be provided as a two-input,
48+
two-output system. For two-input, two-output system, sisotool
49+
inserts the negative of the selected gain `K` between the first
50+
output and first input and uses the second input and output for
51+
computing the step response. To see the disturbance response,
52+
configure your plant to have as its second input the disturbance
53+
input. To view the step response with a feedforward controller,
54+
give your plant two identical inputs, and sum your feedback
55+
controller and your feedforward controller and multiply them into
56+
your plant's second input. It is also possible to accomodate a
5757
system with a gain in the feedback.
5858
initial_gain : float, optional
5959
Initial gain to use for plotting root locus. Defaults to 1

control/statesp.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self, *args, **kwargs):
164164
are matrices or equivalent objects. To create a discrete-time
165165
system, use StateSpace(A, B, C, D, dt) where `dt` is the sampling
166166
time (or True for unspecified sampling time). To call the copy
167-
constructor, call StateSpace(sys), where sys is a StateSpace
167+
constructor, call ``StateSpace(sys)``, where `sys` is a `StateSpace`
168168
object.
169169
170170
See `StateSpace` and `ss` for more information.
@@ -1650,7 +1650,7 @@ def ss(*args, **kwargs):
16501650
``ss(sys)``
16511651
16521652
Convert a linear system into space system form. Always creates a
1653-
new system, even if sys is already a state space system.
1653+
new system, even if `sys` is already a state space system.
16541654
16551655
``ss(A, B, C, D)``
16561656
@@ -1819,7 +1819,7 @@ def tf2io(*args, **kwargs):
18191819
``tf2io(sys)``
18201820
18211821
Convert a linear system into space space form. Always creates
1822-
a new system, even if sys is already a `StateSpace` object.
1822+
a new system, even if `sys` is already a `StateSpace` object.
18231823
18241824
``tf2io(num, den)``
18251825
@@ -2356,9 +2356,9 @@ def _f2s(f):
23562356
def _convert_to_statespace(sys, use_prefix_suffix=False, method=None):
23572357
"""Convert a system to state space form (if needed).
23582358
2359-
If sys is already a state space, then it is returned. If sys is a
2360-
transfer function object, then it is converted to a state space and
2361-
returned.
2359+
If `sys` is already a state space object, then it is returned. If
2360+
`sys` is a transfer function object, then it is converted to a state
2361+
space and returned.
23622362
23632363
Note: no renaming of inputs and outputs is performed; this should be done
23642364
by the calling function.

control/timeresp.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,15 +1330,15 @@ def step_response(
13301330
I/O system(s) for which step response is computed.
13311331
13321332
T : array_like or float, optional
1333-
Time vector, or simulation time duration if a number. If T is not
1333+
Time vector, or simulation time duration if a number. If `T` is not
13341334
provided, an attempt is made to create it automatically from the
1335-
dynamics of sys. If sys is continuous time, the time increment dt
1336-
is chosen small enough to show the fastest mode, and the simulation
1337-
time period tfinal long enough to show the slowest mode, excluding
1338-
poles at the origin and pole-zero cancellations. If this results in
1339-
too many time steps (>5000), dt is reduced. If sys is discrete time,
1340-
only tfinal is computed, and final is reduced if it requires too
1341-
many simulation steps.
1335+
dynamics of the system. If the system continuous time, the time
1336+
increment dt is chosen small enough to show the fastest mode, and
1337+
the simulation time period tfinal long enough to show the slowest
1338+
mode, excluding poles at the origin and pole-zero cancellations. If
1339+
this results in too many time steps (>5000), dt is reduced. If the
1340+
system is discrete time, only tfinal is computed, and final is
1341+
reduced if it requires too many simulation steps.
13421342
13431343
X0 : array_like or float, optional
13441344
Initial condition (default = 0). This can be used for a nonlinear
@@ -1357,8 +1357,9 @@ def step_response(
13571357
If system is a nonlinear I/O system, set parameter values.
13581358
13591359
T_num : int, optional
1360-
Number of time steps to use in simulation if T is not provided as an
1361-
array (autocomputed if not given); ignored if sys is discrete time.
1360+
Number of time steps to use in simulation if `T` is not provided as
1361+
an array (autocomputed if not given); ignored if the system is
1362+
discrete time.
13621363
13631364
transpose : bool, optional
13641365
If True, transpose all input and output arrays (for backward
@@ -1484,8 +1485,7 @@ def step_response(
14841485

14851486
def step_info(sysdata, T=None, T_num=None, yfinal=None, params=None,
14861487
SettlingTimeThreshold=0.02, RiseTimeLimits=(0.1, 0.9)):
1487-
"""
1488-
Step response characteristics (rise time, settling time, etc).
1488+
"""Step response characteristics (rise time, settling time, etc).
14891489
14901490
Parameters
14911491
----------
@@ -1497,8 +1497,8 @@ def step_info(sysdata, T=None, T_num=None, yfinal=None, params=None,
14971497
autocomputed if not given, see `step_response` for more detail).
14981498
Required, if sysdata is a time series of response data.
14991499
T_num : int, optional
1500-
Number of time steps to use in simulation if T is not provided as an
1501-
array; autocomputed if not given; ignored if sysdata is a
1500+
Number of time steps to use in simulation if `T` is not provided as
1501+
an array; autocomputed if not given; ignored if sysdata is a
15021502
discrete-time system or a time series or response data.
15031503
yfinal : scalar or array_like, optional
15041504
Steady-state response. If not given, sysdata.dcgain() is used for
@@ -1586,6 +1586,7 @@ def step_info(sysdata, T=None, T_num=None, yfinal=None, params=None,
15861586
Peak: 1.209
15871587
PeakTime: 4.242
15881588
SteadyStateValue: -1.0
1589+
15891590
"""
15901591
from .nlsys import NonlinearIOSystem
15911592
from .statesp import StateSpace
@@ -1743,9 +1744,10 @@ def initial_response(
17431744
to None to not trim outputs.
17441745
17451746
T_num : int, optional
1746-
Number of time steps to use in simulation if T is not provided as an
1747-
array (autocomputed if not given); ignored if sys is discrete time.
1748-
1747+
Number of time steps to use in simulation if `T` is not provided as
1748+
an array (autocomputed if not given); ignored if the system is
1749+
discrete time.
1750+
17491751
params : dict, optional
17501752
If system is a nonlinear I/O system, set parameter values.
17511753
@@ -1864,8 +1866,9 @@ def impulse_response(
18641866
specified, all outputs are reported.
18651867
18661868
T_num : int, optional
1867-
Number of time steps to use in simulation if T is not provided as an
1868-
array (autocomputed if not given); ignored if sys is discrete time.
1869+
Number of time steps to use in simulation if `T` is not provided as
1870+
an array (autocomputed if not given); ignored if the system is
1871+
discrete time.
18691872
18701873
transpose : bool, optional
18711874
If True, transpose all input and output arrays (for backward

control/xferfcn.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ def __init__(self, *args, **kwargs):
163163
164164
Construct a transfer function.
165165
166-
The default constructor is TransferFunction(num, den), where num and
167-
den are 2D arrays of arrays containing polynomial coefficients.
168-
To create a discrete-time transfer function, use TransferFunction(num,
169-
den, dt) where 'dt' is the sampling time (or True for unspecified
170-
sampling time). To call the copy constructor, call
171-
TransferFunction(sys), where sys is a TransferFunction object
172-
(continuous or discrete).
166+
The default constructor is TransferFunction(num, den), where num
167+
and den are 2D arrays of arrays containing polynomial coefficients.
168+
To create a discrete-time transfer function, use
169+
``TransferFunction(num, den, dt)`` where `dt` is the sampling time
170+
(or True for unspecified sampling time). To call the copy
171+
constructor, call ``TransferFunction(sys)``, where `sys` is a
172+
TransferFunction object (continuous or discrete).
173173
174174
See `TransferFunction` and `tf` for more information.
175175
@@ -1623,7 +1623,7 @@ def tf(*args, **kwargs):
16231623
``tf(sys)``
16241624
16251625
Convert a linear system into transfer function form. Always creates
1626-
a new system, even if sys is already a `TransferFunction` object.
1626+
a new system, even if `sys` is already a `TransferFunction` object.
16271627
16281628
``tf(num, den)``
16291629

doc/conf.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
'python': ('https://docs.python.org/3/', None),
108108
}
109109

110+
# Don't generate external links to (local) keywords
111+
intersphinx_disabled_reftypes = ["py:keyword"]
112+
110113
# If this is True, todo and todolist produce output, else they produce nothing.
111114
# The default is False.
112115
todo_include_todos = True
@@ -220,7 +223,7 @@ def linkcode_resolve(domain, info):
220223
else: # specific version
221224
return base_url + "%s/control/%s%s" % (version, fn, linespec)
222225

223-
# Don't automaticall show all members of class in Methods & Attributes section
226+
# Don't automatically show all members of class in Methods & Attributes section
224227
numpydoc_show_class_members = False
225228

226229
# Don't create a Sphinx TOC for the lists of class methods and attributes
@@ -294,3 +297,16 @@ def linkcode_resolve(domain, info):
294297
import control.phaseplot as pp
295298
ct.reset_defaults()
296299
"""
300+
301+
# -- Customization for python-control ----------------------------------------
302+
#
303+
# This code does custom processing of docstrings for the python-control
304+
# package.
305+
306+
def process_docstring(app, what, name, obj, options, lines):
307+
# Loop through each line in docstring and replace `sys` with :code:`sys`
308+
for i in range(len(lines)):
309+
lines[i] = lines[i].replace("`sys`", ":code:`sys`")
310+
311+
def setup(app):
312+
app.connect('autodoc-process-docstring', process_docstring)

0 commit comments

Comments
 (0)
0