Skip to content

Commit 87dbf90

Browse files
committed
fix module/sub-package references (with developer notes)
1 parent d2c2359 commit 87dbf90

File tree

15 files changed

+133
-83
lines changed

15 files changed

+133
-83
lines changed

control/flatsys/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
trajectories for differentially flat systems.
1010
1111
A differentially flat system is defined by creating an object using the
12-
`flatsys.FlatSystem` class, which has member functions for mapping the
12+
`FlatSystem` class, which has member functions for mapping the
1313
system state and input into and out of flat coordinates. The
14-
`flatsys.point_to_point` function can be used to create a trajectory
14+
`point_to_point` function can be used to create a trajectory
1515
between two endpoints, written in terms of a set of basis functions defined
16-
using the `flatsys.BasisFamily` class. The resulting trajectory is return
17-
as a `flatsys.SystemTrajectory` object and can be evaluated using the
18-
`flatsys.SystemTrajectory.eval` member function. Alternatively, the
19-
`flatsys.solve_flat_ocp` function can be used to solve an optimal control
16+
using the `BasisFamily` class. The resulting trajectory is return
17+
as a `SystemTrajectory` object and can be evaluated using the
18+
`SystemTrajectory.eval` member function. Alternatively, the
19+
`solve_flat_ocp` function can be used to solve an optimal control
2020
problem with trajectory and final costs or constraints.
2121
2222
The docstring examples assume that the following import commands::

control/flatsys/basis.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# basis.py - BasisFamily class
22
# RMM, 10 Nov 2012
33

4-
"""The :mod:`control.flatsys.basis` module defines the
5-
`flatsys.BasisFamily` class that used to specify a set of basis
6-
functions for implementing differential flatness computations.
4+
"""Define base class for implementing basis functions.
5+
6+
This module defines the `BasisFamily` class that used to specify a set
7+
of basis functions for implementing differential flatness computations.
78
89
"""
910

control/flatsys/bezier.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
r"""1D Bezier curve basis functions.
55
6-
The :mod:`control.flatsys.bezier` module defines the
7-
`BezierFamily` class, which implements a set of basis functions
8-
based on Bezier curves:
6+
This module defines the `BezierFamily` class, which implements a set of
7+
basis functions based on Bezier curves:
98
109
.. math:: \phi_i(t) = \sum_{i=0}^n {n \choose i} (T - t)^{n-i} t^i
1110

control/flatsys/flatsys.py

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
class FlatSystem(NonlinearIOSystem):
2424
"""Base class for representing a differentially flat system.
2525
26-
The FlatSystem class is used as a base class to describe
27-
differentially flat systems for trajectory generation. The output
28-
of the system does not need to be the differentially flat output.
29-
Flat systems are usually created with the `~control.flatsys.flatsys`
30-
factory function.
26+
The FlatSystem class is used as a base class to describe differentially
27+
flat systems for trajectory generation. The output of the system does
28+
not need to be the differentially flat output. Flat systems are
29+
usually created with the `flatsys` factory function.
3130
3231
Parameters
3332
----------
@@ -334,12 +333,12 @@ def point_to_point(
334333
335334
Parameters
336335
----------
337-
sys : FlatSystem object
336+
sys : `FlatSystem` object
338337
Description of the differentially flat system. This object must
339-
define a function `flatsys.forward` that takes the system state and
340-
produceds the flag of flat outputs and a system `flatsys.reverse`
341-
that takes the flag of the flat output and prodes the state and
342-
input.
338+
define a function `~FlatSystem.forward` that takes the system state
339+
and produces the flag of flat outputs and a function
340+
`~FlatSystem.reverse` that takes the flag of the flat output and
341+
prodes the state and input.
343342
344343
timepts : float or 1D array_like
345344
The list of points for evaluating cost and constraints, as well as
@@ -355,9 +354,9 @@ def point_to_point(
355354
The initial time for the trajectory (corresponding to x0). If not
356355
specified, its value is taken to be zero.
357356
358-
basis : `flatsys.BasisFamily` object, optional
357+
basis : `BasisFamily` object, optional
359358
The basis functions to use for generating the trajectory. If not
360-
specified, the `flatsys.PolyFamily` basis family
359+
specified, the `PolyFamily` basis family
361360
will be used, with the minimal number of elements required to find a
362361
feasible trajectory (twice the number of system states)
363362
@@ -402,9 +401,9 @@ def point_to_point(
402401
403402
Returns
404403
-------
405-
traj : `flatsys.SystemTrajectory` object
404+
traj : `SystemTrajectory` object
406405
The system trajectory is returned as an object that implements the
407-
`~flatsys.SystemTrajectory.eval` function, we can be used to
406+
`~SystemTrajectory.eval` function, we can be used to
408407
compute the value of the state and input and a given time t.
409408
410409
Notes
@@ -667,12 +666,12 @@ def solve_flat_ocp(
667666
668667
Parameters
669668
----------
670-
sys : FlatSystem object
669+
sys : `FlatSystem` object
671670
Description of the differentially flat system. This object must
672-
define a function `flatsys.forward` that takes the system state and
673-
produceds the flag of flat outputs and a system `flatsys.reverse`
674-
that takes the flag of the flat output and prodes the state and
675-
input.
671+
define a function `~FlatSystem.forward` that takes the system state
672+
and produces the flag of flat outputs and a function
673+
`~FlatSystem.reverse` that takes the flag of the flat output and
674+
prodes the state and input.
676675
677676
timepts : float or 1D array_like
678677
The list of points for evaluating cost and constraints, as well as
@@ -684,9 +683,9 @@ def solve_flat_ocp(
684683
values are given as None, they are replaced by a vector of zeros of
685684
the appropriate dimension.
686685
687-
basis : `flatsys.BasisFamily` object, optional
686+
basis : `BasisFamily` object, optional
688687
The basis functions to use for generating the trajectory. If not
689-
specified, the `flatsys.PolyFamily` basis family
688+
specified, the `PolyFamily` basis family
690689
will be used, with the minimal number of elements required to find a
691690
feasible trajectory (twice the number of system states)
692691
@@ -735,22 +734,22 @@ def solve_flat_ocp(
735734
736735
Returns
737736
-------
738-
traj : `flatsys.SystemTrajectory` object
737+
traj : `SystemTrajectory`
739738
The system trajectory is returned as an object that implements the
740-
`~flatsys.SystemTrajectory.eval` function, we can be used to
741-
compute the value of the state and input and a given time t.
739+
`SystemTrajectory.eval` function, we can be used to
740+
compute the value of the state and input and a given time `t`.
742741
743742
Notes
744743
-----
745744
Additional keyword parameters can be used to fine tune the behavior of
746745
the underlying optimization function. See `minimize_*` keywords in
747-
`optimal.OptimalControlProblem` for more information.
746+
`control.optimal.OptimalControlProblem` for more information.
748747
749748
The return data structure includes the following additional attributes:
750749
751-
* success : bool indicating whether the optimization succeeded
752-
* cost : computed cost of the returned trajectory
753-
* message : message returned by optimization if success if False
750+
* `success` : bool indicating whether the optimization succeeded
751+
* `cost` : computed cost of the returned trajectory
752+
* `message` : message returned by optimization if success if False
754753
755754
A common failure in solving optimal control problem is that the default
756755
initial guess violates the constraints and the optimizer can't find a

control/flatsys/linflat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(self, linsys, **kwargs):
8484
def forward(self, x, u, params):
8585
"""Compute the flat flag given the states and input.
8686
87-
See `control.flatsys.FlatSystem.forward` for more info.
87+
See `FlatSystem.forward` for more info.
8888
8989
"""
9090
x = np.reshape(x, (-1, 1))
@@ -101,7 +101,7 @@ def forward(self, x, u, params):
101101
def reverse(self, zflag, params):
102102
"""Compute the states and input given the flat flag.
103103
104-
See `control.flatsys.FlatSystem.reverse` for more info.
104+
See `FlatSystem.reverse` for more info.
105105
106106
"""
107107
z = zflag[0][0:-1]

control/flatsys/systraj.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SystemTrajectory:
1818
1919
The `SystemTrajectory` class is used to represent the
2020
trajectory of a (differentially flat) system. Used by the
21-
`trajsys.point_to_point` function to return a trajectory.
21+
`point_to_point` function to return a trajectory.
2222
2323
Parameters
2424
----------
@@ -131,7 +131,7 @@ def response(self, tlist, transpose=False, return_x=False, squeeze=None):
131131
132132
Returns
133133
-------
134-
results : TimeResponseData
134+
results : `control.TimeResponseData`
135135
Time response represented as a `TimeResponseData` object
136136
containing the following properties:
137137

control/matlab/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
"""MATLAB compatibility sub-package.
66
7-
The :mod:`control.matlab` sub-package contains a number of functions
8-
that emulate some of the functionality of MATLAB. The intent of these
9-
functions is to provide a simple interface to the python control
10-
systems library (python-control) for people who are familiar with the
11-
MATLAB Control Systems Toolbox (tm).
7+
This sub-package contains a number of functions that emulate some of
8+
the functionality of MATLAB. The intent of these functions is to
9+
provide a simple interface to the python control systems library
10+
(python-control) for people who are familiar with the MATLAB Control
11+
Systems Toolbox (tm).
1212
1313
"""
1414

control/optimal.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
"""Optimization-based control module.
77
88
This module provides support for optimization-based controllers for
9-
nonlinear systems with state and input constraints.
9+
nonlinear systems with state and input constraints. An optimal
10+
control problem can be solved using the `solve_ocp` function or set up
11+
using the `OptimalControlProblem` class and then solved using the
12+
`~OptimalControlProblem.compute_trajectory` method. Utility functions
13+
are available to define common cost functions and input/state
14+
constraints. Optimal estimation problems can be solved using the
15+
`solve_oep` function or by using the `OptimalEstimationProblem` class
16+
and the `~OptimalEstimationProblem.compute_estimate` method..
1017
1118
The docstring examples assume the following import commands::
1219
@@ -49,7 +56,7 @@ class OptimalControlProblem():
4956
to specify an optimal control problem: the system dynamics, cost
5057
function, and constraints. As much as possible, the information used
5158
to specify an optimal control problem matches the notation and
52-
terminology of the SciPy `optimize.minimize` module, with the hope that
59+
terminology of `scipy.optimize` module, with the hope that
5360
this makes it easier to remember how to describe a problem.
5461
5562
Parameters
@@ -1190,7 +1197,7 @@ def create_mpc_iosystem(
11901197
11911198
constraints : list of tuples, optional
11921199
List of constraints that should hold at each point in the time
1193-
vector. See `optimal.solve_ocp` for more details.
1200+
vector. See `solve_ocp` for more details.
11941201
11951202
terminal_cost : callable, optional
11961203
Function that returns the terminal cost given the final state
@@ -1201,8 +1208,8 @@ def create_mpc_iosystem(
12011208
Same format as `constraints`.
12021209
12031210
**kwargs
1204-
Additional parameters, passed to `scipy.optimal.minimize` and
1205-
`NonlinearIOSystem`.
1211+
Additional parameters, passed to `scipy.optimize.minimize` and
1212+
`~control.NonlinearIOSystem`.
12061213
12071214
Returns
12081215
-------
@@ -2021,11 +2028,11 @@ def solve_oep(
20212028
control_indices : int, slice, or list of int or string, optional
20222029
Specify the indices in the system input vector that correspond to
20232030
the control inputs. For more information on possible values, see
2024-
`optimal.OptimalEstimationProblem`.
2031+
`OptimalEstimationProblem`.
20252032
disturbance_indices : int, list of int, or slice, optional
20262033
Specify the indices in the system input vector that correspond to
20272034
the input disturbances. For more information on possible values, see
2028-
`optimal.OptimalEstimationProblem`.
2035+
`OptimalEstimationProblem`.
20292036
initial_guess : 2D array_like, optional
20302037
Initial guess for the state estimate at each time point.
20312038
print_summary : bool, optional
@@ -2061,7 +2068,7 @@ def solve_oep(
20612068
-----
20622069
Additional keyword parameters can be used to fine-tune the behavior of
20632070
the underlying optimization and integration functions. See
2064-
`optimal.OptimalControlProblem` for more information.
2071+
`OptimalControlProblem` for more information.
20652072
20662073
"""
20672074
# Set up the optimal control problem

control/phaseplot.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
"""Generate 2D phase portraits.
88
99
This module contains functions for generating 2D phase plots. The base
10-
function for creating phase plane portraits is `phase_plane_plot`,
10+
function for creating phase plane portraits is `~control.phase_plane_plot`,
1111
which generates a phase plane portrait for a 2 state I/O system (with no
12-
inputs).
12+
inputs). Utility functions are available to customize the individual
13+
elements of a phase plane portrait.
1314
1415
The docstring examples assume the following import commands::
1516
@@ -85,8 +86,9 @@ def phase_plane_plot(
8586
a dict of parameters and values. For a callable, `params` should be
8687
dict with key 'args' and value given by a tuple (passed to callable).
8788
color : matplotlib color spec, optional
88-
Plot all elements in the given color (use `plot_<fcn>` = {'color': c}
89-
to set the color in one element of the phase plot.
89+
Plot all elements in the given color (use ``plot_<element>`` =
90+
{'color': c} to set the color in one element of the phase
91+
plot (equilpoints, separatrices, streamlines, etc).
9092
ax : matplotlib.axes.Axes, optional
9193
The matplotlib axes to draw the figure on. If not specified and
9294
the current figure has a single axes, that axes is used.
@@ -130,7 +132,7 @@ def phase_plane_plot(
130132
plot_streamlines : bool or dict, optional
131133
If True (default) then plot streamlines based on the pointdata
132134
and gridtype. If set to a dict, pass on the key-value pairs in
133-
the dict as keywords to `phaseplot.streamlines`.
135+
the dict as keywords to `streamlines`.
134136
plot_vectorfield : bool or dict, optional
135137
If True (default) then plot the vector field based on the pointdata
136138
and gridtype. If set to a dict, pass on the key-value pairs in

doc/develop.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,42 @@ The reference manual should provide a fairly comprehensive description
450450
of every class, function and configuration variable in the package.
451451

452452

453+
Modules and sub-packages
454+
------------------------
455+
456+
When documenting (independent) modules and sub-packages (refered to
457+
here collectively as modules), use the following guidelines for
458+
documentatation:
459+
460+
* In module docstrings, refer to module functions and classes without
461+
including the module prefix. This will let Sphinx set up the links
462+
to the functions in the proper way and has the advantage that it
463+
keeps the docstrings shorter.
464+
465+
* Objects in the parent (`control`) package should be referenced using
466+
the `~control` prefix, so that Sphinx generates the links properly
467+
(otherwise it looks within the package).
468+
469+
* In the User Guide, set ``currentmodule`` to ``control`` and refer to
470+
the module objects using the prefix `~prefix` in the text portions
471+
of the document but `px` (shortened prefix) in the code sections.
472+
This will let users copy and past code from the examples and is
473+
consistent with the use of the `ct` short prefix. Since this is in
474+
the User Guide, the additional characters are not as big an issue.
475+
476+
* If you include an `autosummary` of functions in the User Guide
477+
section, list the functions using the regular prefix (without ``~``)
478+
to remind everyone the function is in a module.
479+
480+
* When referring to a module function or class in a docstring or User
481+
Guide section that is not part of the module, use the fully
482+
qualified function or class (\'prefix.function\').
483+
484+
The main overarching principle should be to make sure that references
485+
to objects that have more detailed information should show up as a
486+
link, not as code.
487+
488+
453489
Utility Functions
454490
=================
455491

0 commit comments

Comments
 (0)