Skip to content

Commit ad3d1d2

Browse files
committed
update linear.rst and associated doc files and function docstrings
1 parent 53bc4e4 commit ad3d1d2

File tree

17 files changed

+284
-120
lines changed

17 files changed

+284
-120
lines changed

control/lti.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ def frequency_response(self, omega=None, squeeze=None):
124124
outputs=self.output_labels, plot_type='bode')
125125

126126
def dcgain(self):
127-
"""Return the zero-frequency gain"""
128-
raise NotImplementedError("dcgain not implemented for %s objects" %
129-
str(self.__class__))
127+
"""Return the zero-frequency (DC) gain."""
128+
return NotImplemented
130129

131130
def _dcgain(self, warn_infinite):
132131
zeroresp = self(0 if self.isctime() else 1,

control/margins.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,14 @@ def stability_margins(sysdata, returnall=False, epsw=0.0, method='best'):
267267
and not returned as margin.
268268
method : string, optional
269269
Method to use (default is 'best'):
270-
'poly': use polynomial method if passed a :class:`LTI` system.
271-
'frd': calculate crossover frequencies using numerical interpolation
272-
of a :class:`FrequencyResponseData` representation of the system if
273-
passed a :class:`LTI` system.
274-
'best': use the 'poly' method if possible, reverting to 'frd' if it is
275-
detected that numerical inaccuracy is likey to arise in the 'poly'
276-
method for for discrete-time systems.
270+
271+
* 'poly': use polynomial method if passed a :class:`LTI` system.
272+
* 'frd': calculate crossover frequencies using numerical
273+
interpolation of a :class:`FrequencyResponseData` representation
274+
of the system if passed a :class:`LTI` system.
275+
* 'best': use the 'poly' method if possible, reverting to 'frd' if
276+
it is detected that numerical inaccuracy is likey to arise in the
277+
'poly' method for for discrete-time systems.
277278
278279
Returns
279280
-------

control/robust.py

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,10 @@
22
#
33
# Author: Steve Brunton, Kevin Chen, Lauren Padilla
44
# Date: 24 Dec 2010
5-
#
6-
# This file contains routines for obtaining reduced order models
7-
#
8-
# Copyright (c) 2010 by California Institute of Technology
9-
# All rights reserved.
10-
#
11-
# Redistribution and use in source and binary forms, with or without
12-
# modification, are permitted provided that the following conditions
13-
# are met:
14-
#
15-
# 1. Redistributions of source code must retain the above copyright
16-
# notice, this list of conditions and the following disclaimer.
17-
#
18-
# 2. Redistributions in binary form must reproduce the above copyright
19-
# notice, this list of conditions and the following disclaimer in the
20-
# documentation and/or other materials provided with the distribution.
21-
#
22-
# 3. Neither the name of the California Institute of Technology nor
23-
# the names of its contributors may be used to endorse or promote
24-
# products derived from this software without specific prior
25-
# written permission.
26-
#
27-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30-
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CALTECH
31-
# OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
34-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35-
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36-
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
37-
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38-
# SUCH DAMAGE.
39-
#
40-
# $Id$
5+
6+
"""
7+
This file contains routines for obtaining reduced order models.
8+
"""
419

4210
import warnings
4311

control/statesp.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ def sample(self, Ts, method='zoh', alpha=None, prewarp_frequency=None,
12931293
return StateSpace(sysd, **kwargs)
12941294

12951295
def dcgain(self, warn_infinite=False):
1296-
"""Return the zero-frequency gain.
1296+
"""Return the zero-frequency ("DC") gain.
12971297
12981298
The zero-frequency gain of a continuous-time state-space
12991299
system is given by:
@@ -1841,9 +1841,6 @@ def ssdata(sys):
18411841
def linfnorm(sys, tol=1e-10):
18421842
"""L-infinity norm of a linear system.
18431843
1844-
.. deprecated:: 0.10.2
1845-
This functionality is now available in :func:`sysnorm`.
1846-
18471844
Parameters
18481845
----------
18491846
sys : LTI (StateSpace or TransferFunction)
@@ -1867,8 +1864,6 @@ def linfnorm(sys, tol=1e-10):
18671864
--------
18681865
slycot.ab13dd : the Slycot routine linfnorm that does the calculation
18691866
"""
1870-
warn("linfnorm() is deprecated; use sysnorm(sys, p='inf')", FutureWarning)
1871-
18721867
if ab13dd is None:
18731868
raise ControlSlycot("Can't find slycot module 'ab13dd'")
18741869

control/sysnorm.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import control as ct
2020

21-
__all__ = ['norm']
21+
__all__ = ['system_norm', 'norm']
2222

2323
#------------------------------------------------------------------------------
2424

@@ -83,24 +83,26 @@ def _h2norm_slycot(sys, print_warning=True):
8383

8484
#------------------------------------------------------------------------------
8585

86-
def norm(system, p=2, tol=1e-6, print_warning=True, method=None):
87-
"""Computes norm of system.
86+
def system_norm(system, p=2, tol=1e-6, print_warning=True, method=None):
87+
"""Computes the input/output norm of system.
8888
8989
Parameters
9090
----------
9191
system : LTI (:class:`StateSpace` or :class:`TransferFunction`)
92-
System in continuous or discrete time for which the norm should be computed.
92+
System in continuous or discrete time for which the norm should
93+
be computed.
9394
p : int or str
94-
Type of norm to be computed. ``p=2`` gives the H2 norm, and ``p='inf'`` gives the L-infinity norm.
95+
Type of norm to be computed. `p=2` gives the H2 norm, and
96+
`p='inf'` gives the L-infinity norm.
9597
tol : float
9698
Relative tolerance for accuracy of L-infinity norm computation. Ignored
97-
unless ``p='inf'``.
99+
unless `p='inf'`.
98100
print_warning : bool
99101
Print warning message in case norm value may be uncertain.
100102
method : str, optional
101103
Set the method used for computing the result. Current methods are
102-
``'slycot'`` and ``'scipy'``. If set to ``None`` (default), try ``'slycot'`` first
103-
and then ``'scipy'``.
104+
'slycot' and 'scipy'. If set to `None` (default), try 'slycot' first
105+
and then 'scipy'.
104106
105107
Returns
106108
-------
@@ -121,7 +123,8 @@ def norm(system, p=2, tol=1e-6, print_warning=True, method=None):
121123
"""
122124

123125
if not isinstance(system, (ct.StateSpace, ct.TransferFunction)):
124-
raise TypeError('Parameter ``system``: must be a ``StateSpace`` or ``TransferFunction``')
126+
raise TypeError(
127+
"Parameter `system`: must be a `StateSpace` or `TransferFunction`")
125128

126129
G = ct.ss(system)
127130
A = G.A
@@ -292,3 +295,5 @@ def _Hamilton_matrix(gamma):
292295
else:
293296
raise ct.ControlArgument(f"Norm computation for p={p} currently not supported.")
294297

298+
299+
norm = system_norm

control/xferfcn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ def sample(self, Ts, method='zoh', alpha=None, prewarp_frequency=None,
12021202
return TransferFunction(sysd, name=name, **kwargs)
12031203

12041204
def dcgain(self, warn_infinite=False):
1205-
"""Return the zero-frequency (or DC) gain.
1205+
"""Return the zero-frequency ("DC") gain.
12061206
12071207
For a continous-time transfer function G(s), the DC gain is G(0)
12081208
For a discrete-time transfer function G(z), the DC gain is G(1)

doc/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@
121121
# Set the default role to render items in backticks as code
122122
default_role = 'py:obj'
123123

124+
# Align inline math with text
125+
imgmath_use_preview = True
126+
124127
# Theme options are theme-specific and customize the look and feel of a theme
125128
# further. For a list of options available for each theme, see the
126129
# documentation.

doc/functions.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ Control system analysis
112112
get_input_ff_index
113113
get_output_fb_index
114114
ispassive
115+
linfnorm
115116
margin
116-
norm
117117
solve_passivity_LMI
118118
stability_margins
119119
step_info
120+
system_norm
120121
phase_crossover_frequencies
121122
poles
122123
zeros

doc/intro.rst

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Guide. This guide contains information on using the python-control
77
package, including documentation for all functions in the package and
88
examples illustrating their use.
99

10+
1011
Package overview
1112
================
1213

@@ -16,6 +17,7 @@ Package overview
1617
:no-inherited-members:
1718
:no-special-members:
1819

20+
1921
Installation
2022
============
2123

@@ -82,6 +84,35 @@ control package::
8284
Note that Google colab does not currently support Slycot, so some
8385
functionality may not be available.
8486

87+
88+
Package conventions
89+
===================
90+
91+
The python-control package makes use of a few naming and calling conventions:
92+
93+
* Function names are written in lower case with underscores between
94+
words ('frequency_response').
95+
96+
* Class names use camel case ('StateSpace', 'ControlPlot', etc) and
97+
instances of the class are created with "factory functions" ('ss')
98+
or as the output of an operation ('bode_plot').
99+
100+
* Functions that return multiple values use either objects (with
101+
elements for each return value) or tuples. For those functions that
102+
return tuples, the underscore variable can be used if only some of
103+
the return values are needed::
104+
105+
K, _, _ = lqr(sys)
106+
107+
* Python-control supports both single-input, single-output (SISO)
108+
systems and mullti-input, multi-output (MIMO) systems, including
109+
time and frequency responses. By default, SISO systems will
110+
typically generate objects that have the input and output dimensions
111+
supressed (using the NumPy :func:`~numpy.squeeze` function). The
112+
`squeeze` keyword can be set to `False` to force functions to return
113+
objects that include the input and output dimensions.
114+
115+
85116
Some differences from MATLAB
86117
============================
87118

@@ -102,11 +133,11 @@ some things to keep in mind:
102133
vectors implemented as nested list . So [1 2 3] must be written as
103134
[1, 2, 3] and matrices are written using 2D nested lists, e.g., [[1,
104135
2], [3, 4]].
105-
* Functions that return multiple values use either objects (with
106-
elements for each return value) or tuples. The number of elements
107-
in a tuple is fixed and so functions that return variable numbers of
108-
return values will have a parameter of the form `return_<val>`
109-
that is used to return additional data.
136+
* Functions that in MATLAB would return variable numbers of values
137+
will have a parameter of the form `return_<val>` that is used to
138+
return additional data. (These functions usually return an object of
139+
a class that has attributpes that can be used to access the
140+
information and this is the preferred usage pattern.)
110141
* You cannot use braces for collections; use tuples instead.
111142
* Time series data have time as the final index (see
112143
:ref:`time-series-convention`).

0 commit comments

Comments
 (0)