Skip to content

Commit b743fb8

Browse files
authored
Merge pull request #448 from pybricks/docwarnings
Fix documentation and math display errors
2 parents 7af3fbf + c70fbeb commit b743fb8

File tree

15 files changed

+108
-99
lines changed

15 files changed

+108
-99
lines changed

control/freqplot.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ def bode_plot(syslist, omega=None,
110110
config.defaults['freqplot.number_of_samples'].
111111
margins : bool
112112
If True, plot gain and phase margin.
113-
*args : `matplotlib` plot positional properties, optional
113+
*args : :func:`matplotlib.pyplot.plot` positional properties, optional
114114
Additional arguments for `matplotlib` plots (color, linestyle, etc)
115-
**kwargs : `matplotlib` plot keyword properties, optional
115+
**kwargs : :func:`matplotlib.pyplot.plot` keyword properties, optional
116116
Additional keywords (passed to `matplotlib`)
117117
118118
Returns
@@ -128,21 +128,22 @@ def bode_plot(syslist, omega=None,
128128
----------------
129129
grid : bool
130130
If True, plot grid lines on gain and phase plots. Default is set by
131-
config.defaults['bode.grid'].
131+
`config.defaults['bode.grid']`.
132+
132133
133134
The default values for Bode plot configuration parameters can be reset
134135
using the `config.defaults` dictionary, with module name 'bode'.
135136
136137
Notes
137138
-----
138-
1. Alternatively, you may use the lower-level method (mag, phase, freq)
139-
= sys.freqresp(freq) to generate the frequency response for a system,
140-
but it returns a MIMO response.
139+
1. Alternatively, you may use the lower-level method
140+
``(mag, phase, freq) = sys.freqresp(freq)`` to generate the frequency
141+
response for a system, but it returns a MIMO response.
141142
142143
2. If a discrete time model is given, the frequency response is plotted
143-
along the upper branch of the unit circle, using the mapping z = exp(j
144-
\\omega dt) where omega ranges from 0 to pi/dt and dt is the discrete
145-
timebase. If not timebase is specified (dt = True), dt is set to 1.
144+
along the upper branch of the unit circle, using the mapping z = exp(j
145+
\\omega dt) where omega ranges from 0 to pi/dt and dt is the discrete
146+
timebase. If not timebase is specified (dt = True), dt is set to 1.
146147
147148
Examples
148149
--------
@@ -464,9 +465,9 @@ def nyquist_plot(syslist, omega=None, plot=True, label_freq=0,
464465
Label every nth frequency on the plot
465466
arrowhead_width : arrow head width
466467
arrowhead_length : arrow head length
467-
*args : `matplotlib` plot positional properties, optional
468+
*args : :func:`matplotlib.pyplot.plot` positional properties, optional
468469
Additional arguments for `matplotlib` plots (color, linestyle, etc)
469-
**kwargs : `matplotlib` plot keyword properties, optional
470+
**kwargs : :func:`matplotlib.pyplot.plot` keyword properties, optional
470471
Additional keywords (passed to `matplotlib`)
471472
472473
Returns
@@ -539,13 +540,13 @@ def nyquist_plot(syslist, omega=None, plot=True, label_freq=0,
539540
ax = plt.gca()
540541
# Plot arrow to indicate Nyquist encirclement orientation
541542
ax.arrow(x[0], y[0], (x[1]-x[0])/2, (y[1]-y[0])/2, fc=c, ec=c,
542-
head_width=arrowhead_width,
543+
head_width=arrowhead_width,
543544
head_length=arrowhead_length)
544545

545546
plt.plot(x, -y, '-', color=c, *args, **kwargs)
546547
ax.arrow(
547548
x[-1], -y[-1], (x[-1]-x[-2])/2, (y[-1]-y[-2])/2,
548-
fc=c, ec=c, head_width=arrowhead_width,
549+
fc=c, ec=c, head_width=arrowhead_width,
549550
head_length=arrowhead_length)
550551

551552
# Mark the -1 point
@@ -601,7 +602,7 @@ def gangof4_plot(P, C, omega=None, **kwargs):
601602
Linear input/output systems (process and control)
602603
omega : array
603604
Range of frequencies (list or bounds) in rad/sec
604-
**kwargs : `matplotlib` plot keyword properties, optional
605+
**kwargs : :func:`matplotlib.pyplot.plot` keyword properties, optional
605606
Additional keywords (passed to `matplotlib`)
606607
607608
Returns

control/iosys.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,8 +1514,9 @@ def find_eqpt(sys, x0, u0=[], y0=None, t=0, params={},
15141514
return_y : bool, optional
15151515
If True, return the value of output at the equilibrium point.
15161516
return_result : bool, optional
1517-
If True, return the `result` option from the scipy root function used
1518-
to compute the equilibrium point.
1517+
If True, return the `result` option from the
1518+
:func:`scipy.optimize.root` function used to compute the equilibrium
1519+
point.
15191520
15201521
Returns
15211522
-------
@@ -1529,9 +1530,9 @@ def find_eqpt(sys, x0, u0=[], y0=None, t=0, params={},
15291530
If `return_y` is True, returns the value of the outputs at the
15301531
equilibrium point, or `None` if no equilibrium point was found and
15311532
`return_result` was False.
1532-
result : scipy root() result object, optional
1533-
If `return_result` is True, returns the `result` from the scipy root
1534-
function.
1533+
result : :class:`scipy.optimize.OptimizeResult`, optional
1534+
If `return_result` is True, returns the `result` from the
1535+
:func:`scipy.optimize.root` function.
15351536
15361537
"""
15371538
from scipy.optimize import root

control/nichols.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,9 @@ def nichols_grid(cl_mags=None, cl_phases=None, line_style='dotted'):
135135
Array of closed-loop phases defining the iso-phase lines on a custom
136136
Nichols chart. Must be in the range -360 < cl_phases < 0
137137
line_style : string, optional
138-
.. seealso:: https://matplotlib.org/gallery/lines_bars_and_markers/linestyles.html
138+
:doc:`Matplotlib linestyle \
139+
<matplotlib:gallery/lines_bars_and_markers/linestyles>`
139140
140-
Returns
141-
-------
142-
None
143141
"""
144142
# Default chart size
145143
ol_phase_min = -359.99

control/phaseplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def phase_plot(odefun, X=None, Y=None, scale=1, X0=None, T=None,
7373
func : callable(x, t, ...)
7474
Computes the time derivative of y (compatible with odeint).
7575
The function should be the same for as used for
76-
scipy.integrate. Namely, it should be a function of the form
76+
:mod:`scipy.integrate`. Namely, it should be a function of the form
7777
dxdt = F(x, t) that accepts a state x of dimension 2 and
7878
returns a derivative dx/dt of dimension 2.
7979

control/pzmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def pzmap(sys, plot=True, grid=False, title='Pole Zero Map', **kwargs):
6666
----------
6767
sys: LTI (StateSpace or TransferFunction)
6868
Linear system for which poles and zeros are computed.
69-
plot: bool
69+
plot: bool, optional
7070
If ``True`` a graph is generated with Matplotlib,
7171
otherwise the poles and zeros are only computed and returned.
7272
grid: boolean (default = False)

control/rlocus.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
# Main function: compute a root locus diagram
7777
def root_locus(sys, kvect=None, xlim=None, ylim=None,
78-
plotstr=None, plot=True, print_gain=None, grid=None, ax=None,
78+
plotstr=None, plot=True, print_gain=None, grid=None, ax=None,
7979
**kwargs):
8080

8181
"""Root locus plot
@@ -91,18 +91,22 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
9191
kvect : list or ndarray, optional
9292
List of gains to use in computing diagram.
9393
xlim : tuple or list, optional
94-
Set limits of x axis, normally with tuple (see matplotlib.axes).
94+
Set limits of x axis, normally with tuple
95+
(see :doc:`matplotlib:api/axes_api`).
9596
ylim : tuple or list, optional
96-
Set limits of y axis, normally with tuple (see matplotlib.axes).
97+
Set limits of y axis, normally with tuple
98+
(see :doc:`matplotlib:api/axes_api`).
99+
plotstr : :func:`matplotlib.pyplot.plot` format string, optional
100+
plotting style specification
97101
plot : boolean, optional
98102
If True (default), plot root locus diagram.
99103
print_gain : bool
100104
If True (default), report mouse clicks when close to the root locus
101105
branches, calculate gain, damping and print.
102106
grid : bool
103107
If True plot omega-damping grid. Default is False.
104-
ax : Matplotlib axis
105-
axis on which to create root locus plot
108+
ax : :class:`matplotlib.axes.Axes`
109+
Axes on which to create root locus plot
106110
107111
Returns
108112
-------
@@ -160,7 +164,7 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
160164
fig = kwargs['fig']
161165
ax = fig.axes[1]
162166
else:
163-
if ax is None:
167+
if ax is None:
164168
ax = plt.gca()
165169
fig = ax.figure
166170
ax.set_title('Root Locus')

control/robust.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def hinfsyn(P, nmeas, ncon):
119119
rcond: 4-vector, reciprocal condition estimates of:
120120
1: control transformation matrix
121121
2: measurement transformation matrix
122-
3: X-Ricatti equation
123-
4: Y-Ricatti equation
122+
3: X-Riccati equation
123+
4: Y-Riccati equation
124124
TODO: document significance of rcond
125125
126126
Raises

control/sisotool.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ def sisotool(sys, kvect = None, xlim_rlocus = None, ylim_rlocus = None,
2626
kvect : list or ndarray, optional
2727
List of gains to use for plotting root locus
2828
xlim_rlocus : tuple or list, optional
29-
control of x-axis range, normally with tuple (see matplotlib.axes)
29+
control of x-axis range, normally with tuple
30+
(see :doc:`matplotlib:api/axes_api`).
3031
ylim_rlocus : tuple or list, optional
3132
control of y-axis range
32-
plotstr_rlocus : Additional options to matplotlib
33+
plotstr_rlocus : :func:`matplotlib.pyplot.plot` format string, optional
3334
plotting style for the root locus plot(color, linestyle, etc)
3435
rlocus_grid: boolean (default = False)
3536
If True plot s-plane grid.

control/statefbk.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
# Pole placement
5454
def place(A, B, p):
5555
"""Place closed loop eigenvalues
56+
5657
K = place(A, B, p)
5758
5859
Parameters
@@ -69,21 +70,24 @@ def place(A, B, p):
6970
K : 2-d array
7071
Gain such that A - B K has eigenvalues given in p
7172
72-
Algorithm
73-
---------
74-
This is a wrapper function for scipy.signal.place_poles, which
75-
implements the Tits and Yang algorithm [1]. It will handle SISO,
76-
MISO, and MIMO systems. If you want more control over the algorithm,
77-
use scipy.signal.place_poles directly.
7873
79-
[1] A.L. Tits and Y. Yang, "Globally convergent algorithms for robust
80-
pole assignment by state feedback, IEEE Transactions on Automatic
81-
Control, Vol. 41, pp. 1432-1452, 1996.
74+
Notes
75+
-----
76+
Algorithm
77+
This is a wrapper function for :func:`scipy.signal.place_poles`, which
78+
implements the Tits and Yang algorithm [1]_. It will handle SISO,
79+
MISO, and MIMO systems. If you want more control over the algorithm,
80+
use :func:`scipy.signal.place_poles` directly.
8281
8382
Limitations
84-
-----------
85-
The algorithm will not place poles at the same location more
86-
than rank(B) times.
83+
The algorithm will not place poles at the same location more
84+
than rank(B) times.
85+
86+
References
87+
----------
88+
.. [1] A.L. Tits and Y. Yang, "Globally convergent algorithms for robust
89+
pole assignment by state feedback, IEEE Transactions on Automatic
90+
Control, Vol. 41, pp. 1432-1452, 1996.
8791
8892
Examples
8993
--------
@@ -227,11 +231,11 @@ def lqe(A, G, C, QN, RN, NN=None):
227231
Linear quadratic estimator design (Kalman filter) for continuous-time
228232
systems. Given the system
229233
230-
Given the system
231234
.. math::
232-
x = Ax + Bu + Gw
233-
y = Cx + Du + v
234-
235+
236+
x &= Ax + Bu + Gw \\\\
237+
y &= Cx + Du + v
238+
235239
with unbiased process noise w and measurement noise v with covariances
236240
237241
.. math:: E{ww'} = QN, E{vv'} = RN, E{wv'} = NN
@@ -260,11 +264,14 @@ def lqe(A, G, C, QN, RN, NN=None):
260264
Kalman estimator gain
261265
P: 2D array
262266
Solution to Riccati equation
267+
263268
.. math::
264-
A P + P A^T - (P C^T + G N) R^-1 (C P + N^T G^T) + G Q G^T = 0
269+
270+
A P + P A^T - (P C^T + G N) R^{-1} (C P + N^T G^T) + G Q G^T = 0
271+
265272
E: 1D array
266273
Eigenvalues of estimator poles eig(A - L C)
267-
274+
268275
269276
Examples
270277
--------
@@ -381,7 +388,7 @@ def lqr(*args, **keywords):
381388
See Also
382389
--------
383390
lqe
384-
391+
385392
"""
386393

387394
# Make sure that SLICOT is installed

control/statesp.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
_statesp_defaults = {
7373
'statesp.use_numpy_matrix': True,
7474
'statesp.default_dt': None,
75-
'statesp.remove_useless_states': True,
75+
'statesp.remove_useless_states': True,
7676
}
7777

7878

@@ -154,7 +154,7 @@ class StateSpace(LTI):
154154
Setting dt = 0 specifies a continuous system, while leaving dt = None
155155
means the system timebase is not specified. If 'dt' is set to True, the
156156
system will be treated as a discrete time system with unspecified sampling
157-
time. The default value of 'dt' is None and can be changed by changing the
157+
time. The default value of 'dt' is None and can be changed by changing the
158158
value of ``control.config.defaults['statesp.default_dt']``.
159159
160160
"""
@@ -801,15 +801,15 @@ def minreal(self, tol=0.0):
801801

802802
# TODO: add discrete time check
803803
def returnScipySignalLTI(self):
804-
"""Return a list of a list of scipy.signal.lti objects.
804+
"""Return a list of a list of :class:`scipy.signal.lti` objects.
805805
806806
For instance,
807807
808808
>>> out = ssobject.returnScipySignalLTI()
809809
>>> out[3][5]
810810
811-
is a signal.scipy.lti object corresponding to the transfer function from
812-
the 6th input to the 4th output."""
811+
is a :class:`scipy.signal.lti` object corresponding to the transfer
812+
function from the 6th input to the 4th output."""
813813

814814
# Preallocate the output.
815815
out = [[[] for _ in range(self.inputs)] for _ in range(self.outputs)]
@@ -822,8 +822,9 @@ def returnScipySignalLTI(self):
822822
return out
823823

824824
def append(self, other):
825-
"""Append a second model to the present model. The second
826-
model is converted to state-space if necessary, inputs and
825+
"""Append a second model to the present model.
826+
827+
The second model is converted to state-space if necessary, inputs and
827828
outputs are appended and their order is preserved"""
828829
if not isinstance(other, StateSpace):
829830
other = _convertToStateSpace(other)
@@ -883,8 +884,8 @@ def sample(self, Ts, method='zoh', alpha=None, prewarp_frequency=None):
883884
884885
prewarp_frequency : float within [0, infinity)
885886
The frequency [rad/s] at which to match with the input continuous-
886-
time system's magnitude and phase (the gain=1 crossover frequency,
887-
for example). Should only be specified with method='bilinear' or
887+
time system's magnitude and phase (the gain=1 crossover frequency,
888+
for example). Should only be specified with method='bilinear' or
888889
'gbt' with alpha=0.5 and ignored otherwise.
889890
890891
Returns
@@ -894,7 +895,7 @@ def sample(self, Ts, method='zoh', alpha=None, prewarp_frequency=None):
894895
895896
Notes
896897
-----
897-
Uses the command 'cont2discrete' from scipy.signal
898+
Uses :func:`scipy.signal.cont2discrete`
898899
899900
Examples
900901
--------
@@ -909,7 +910,7 @@ def sample(self, Ts, method='zoh', alpha=None, prewarp_frequency=None):
909910
if (method=='bilinear' or (method=='gbt' and alpha==0.5)) and \
910911
prewarp_frequency is not None:
911912
Twarp = 2*np.tan(prewarp_frequency*Ts/2)/prewarp_frequency
912-
else:
913+
else:
913914
Twarp = Ts
914915
Ad, Bd, C, D, _ = cont2discrete(sys, Twarp, method, alpha)
915916
return StateSpace(Ad, Bd, C, D, Ts)

0 commit comments

Comments
 (0)