Skip to content

Commit 641d6db

Browse files
committed
update class documentation (+ unit tests)
1 parent 87dbf90 commit 641d6db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1115
-705
lines changed

control/bdalg.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def series(*sys, **kwargs):
5353
'<subsys_name>.<state_name>' for interconnected nonlinear systems.
5454
name : string, optional
5555
System name (used for specifying signals). If unspecified, a generic
56-
name <sys[id]> is generated with a unique integer id.
56+
name 'sys[id]' is generated with a unique integer id.
5757
5858
Raises
5959
------
@@ -124,7 +124,7 @@ def parallel(*sys, **kwargs):
124124
'<subsys_name>.<state_name>' for interconnected nonlinear systems.
125125
name : string, optional
126126
System name (used for specifying signals). If unspecified, a generic
127-
name <sys[id]> is generated with a unique integer id.
127+
name 'sys[id]' is generated with a unique integer id.
128128
129129
Raises
130130
------
@@ -139,7 +139,7 @@ def parallel(*sys, **kwargs):
139139
Notes
140140
-----
141141
This function is a wrapper for the __add__ function in the
142-
StateSpace and TransferFunction classes. The output type is usually
142+
`StateSpace` and `TransferFunction` classes. The output type is usually
143143
the type of `sys1`. If `sys1` is a scalar, then the output type is
144144
the type of `sys2`.
145145
@@ -168,8 +168,7 @@ def parallel(*sys, **kwargs):
168168
return sys
169169

170170
def negate(sys, **kwargs):
171-
"""
172-
Return the negative of a system.
171+
"""Return the negative of a system.
173172
174173
Parameters
175174
----------
@@ -193,16 +192,17 @@ def negate(sys, **kwargs):
193192
'<subsys_name>.<state_name>' for interconnected nonlinear systems.
194193
name : string, optional
195194
System name (used for specifying signals). If unspecified, a generic
196-
name <sys[id]> is generated with a unique integer id.
195+
name 'sys[id]' is generated with a unique integer id.
197196
198197
See Also
199198
--------
200199
append, feedback, interconnect, parallel, series
201200
202201
Notes
203202
-----
204-
This function is a wrapper for the __neg__ function in the StateSpace and
205-
TransferFunction classes. The output type is the same as the input type.
203+
This function is a wrapper for the __neg__ function in the `StateSpace`
204+
and `TransferFunction` classes. The output type is the same as the
205+
input type.
206206
207207
Examples
208208
--------
@@ -248,16 +248,16 @@ def feedback(sys1, sys2=1, sign=-1, **kwargs):
248248
'<subsys_name>.<state_name>' for interconnected nonlinear systems.
249249
name : string, optional
250250
System name (used for specifying signals). If unspecified, a generic
251-
name <sys[id]> is generated with a unique integer id.
251+
name 'sys[id]' is generated with a unique integer id.
252252
253253
Raises
254254
------
255255
ValueError
256-
if `sys1` does not have as many inputs as `sys2` has outputs, or if
257-
`sys2` does not have as many inputs as `sys1` has outputs
256+
If `sys1` does not have as many inputs as `sys2` has outputs, or if
257+
`sys2` does not have as many inputs as `sys1` has outputs.
258258
NotImplementedError
259-
if an attempt is made to perform a feedback on a MIMO TransferFunction
260-
object
259+
If an attempt is made to perform a feedback on a MIMO `TransferFunction`
260+
object.
261261
262262
See Also
263263
--------
@@ -334,7 +334,7 @@ def append(*sys, **kwargs):
334334
'<subsys_name>.<state_name>' for interconnected nonlinear systems.
335335
name : string, optional
336336
System name (used for specifying signals). If unspecified, a generic
337-
name <sys[id]> is generated with a unique integer id.
337+
name 'sys[id]' is generated with a unique integer id.
338338
339339
Returns
340340
-------
@@ -471,16 +471,16 @@ def combine_tf(tf_array, **kwargs):
471471
472472
Parameters
473473
----------
474-
tf_array : list of list of TransferFunction or array_like
474+
tf_array : list of list of `TransferFunction` or array_like
475475
Transfer matrix represented as a two-dimensional array or
476-
list-of-lists containing TransferFunction objects. The
476+
list-of-lists containing `TransferFunction` objects. The
477477
`TransferFunction` objects can have multiple outputs and inputs, as
478478
long as the dimensions are compatible.
479479
480480
Returns
481481
-------
482-
TransferFunction
483-
Transfer matrix represented as a single MIMO TransferFunction object.
482+
`TransferFunction`
483+
Transfer matrix represented as a single MIMO `TransferFunction` object.
484484
485485
Other Parameters
486486
----------------
@@ -490,7 +490,7 @@ def combine_tf(tf_array, **kwargs):
490490
or 'y'). See `InputOutputSystem` for more information.
491491
name : string, optional
492492
System name (used for specifying signals). If unspecified, a generic
493-
name <sys[id]> is generated with a unique integer id.
493+
name 'sys[id]' is generated with a unique integer id.
494494
495495
Raises
496496
------
@@ -602,7 +602,7 @@ def split_tf(transfer_function):
602602
603603
Parameters
604604
----------
605-
transfer_function : TransferFunction
605+
transfer_function : `TransferFunction`
606606
MIMO transfer function to split.
607607
608608
Returns
@@ -657,11 +657,11 @@ def split_tf(transfer_function):
657657
return np.array(tf_split_lst, dtype=object)
658658

659659
def _ensure_tf(arraylike_or_tf, dt=None):
660-
"""Convert an array-like to a transfer function.
660+
"""Convert an array_like to a transfer function.
661661
662662
Parameters
663663
----------
664-
arraylike_or_tf : TransferFunction or array_like
664+
arraylike_or_tf : `TransferFunction` or array_like
665665
Array-like or transfer function.
666666
dt : None, True or float, optional
667667
System timebase. 0 (default) indicates continuous
@@ -672,7 +672,7 @@ def _ensure_tf(arraylike_or_tf, dt=None):
672672
673673
Returns
674674
-------
675-
TransferFunction
675+
`TransferFunction`
676676
Transfer function.
677677
678678
Raises
@@ -706,7 +706,7 @@ def _ensure_tf(arraylike_or_tf, dt=None):
706706
)
707707
except TypeError:
708708
raise ValueError(
709-
"`arraylike_or_tf` must only contain array-likes or transfer "
709+
"`arraylike_or_tf` must only contain array_likes or transfer "
710710
"functions."
711711
)
712712
return tfn

control/canonical.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def canonical_form(xsys, form='reachable'):
2525
2626
Parameters
2727
----------
28-
xsys : StateSpace object
28+
xsys : `StateSpace` object
2929
System to be transformed, with state 'x'.
3030
form : str
3131
Canonical form for transformation. Chosen from:
@@ -35,7 +35,7 @@ def canonical_form(xsys, form='reachable'):
3535
3636
Returns
3737
-------
38-
zsys : StateSpace object
38+
zsys : `StateSpace` object
3939
System in desired canonical form, with state 'z'.
4040
T : (M, M) real ndarray
4141
Coordinate transformation matrix, z = T * x.
@@ -77,12 +77,12 @@ def reachable_form(xsys):
7777
7878
Parameters
7979
----------
80-
xsys : StateSpace object
80+
xsys : `StateSpace` object
8181
System to be transformed, with state `x`.
8282
8383
Returns
8484
-------
85-
zsys : StateSpace object
85+
zsys : `StateSpace` object
8686
System in reachable canonical form, with state `z`.
8787
T : (M, M) real ndarray
8888
Coordinate transformation: z = T * x.
@@ -142,12 +142,12 @@ def observable_form(xsys):
142142
143143
Parameters
144144
----------
145-
xsys : StateSpace object
145+
xsys : `StateSpace` object
146146
System to be transformed, with state `x`.
147147
148148
Returns
149149
-------
150-
zsys : StateSpace object
150+
zsys : `StateSpace` object
151151
System in observable canonical form, with state `z`.
152152
T : (M, M) real ndarray
153153
Coordinate transformation: z = T * x.
@@ -203,7 +203,7 @@ def similarity_transform(xsys, T, timescale=1, inverse=False):
203203
204204
Parameters
205205
----------
206-
xsys : StateSpace object
206+
xsys : `StateSpace` object
207207
System to transform.
208208
T : (M, M) array_like
209209
The matrix `T` defines the new set of coordinates z = T x.
@@ -215,7 +215,7 @@ def similarity_transform(xsys, T, timescale=1, inverse=False):
215215
216216
Returns
217217
-------
218-
zsys : StateSpace object
218+
zsys : `StateSpace` object
219219
System in transformed coordinates, with state 'z'.
220220
221221
See Also
@@ -497,7 +497,7 @@ def modal_form(xsys, condmax=None, sort=False):
497497
498498
Parameters
499499
----------
500-
xsys : StateSpace object
500+
xsys : `StateSpace` object
501501
System to be transformed, with state x.
502502
condmax : None or float, optional
503503
An upper bound on individual transformations. If None, use
@@ -508,9 +508,9 @@ def modal_form(xsys, condmax=None, sort=False):
508508
509509
Returns
510510
-------
511-
zsys : StateSpace object
511+
zsys : `StateSpace` object
512512
System in modal canonical form, with state z.
513-
T : (M, M) ndarray
513+
T : (M, M) array
514514
Coordinate transformation: z = T * x.
515515
516516
Examples

control/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
class DefaultDict(collections.UserDict):
32-
"""Map names for settings from older version to their renamed ones.
32+
"""Default parameters dictionary, with legacy warnings.
3333
3434
If a user wants to write to an old setting, issue a warning and write to
3535
the renamed setting instead. Accessing the old setting returns the value

control/ctrlplot.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
#
123123

124124
class ControlPlot():
125-
"""A class for representing control figures.
125+
"""Return class for control platting functions.
126126
127127
This class is used as the return type for control plotting functions.
128128
It contains the information required to access portions of the plot
@@ -136,17 +136,17 @@ class ControlPlot():
136136
137137
Parameters
138138
----------
139-
lines : array of list of `matplotlib:Line2D`
139+
lines : array of list of `matplotlib.lines.Line2D`
140140
Array of Line2D objects for each line in the plot. Generally, the
141141
shape of the array matches the subplots shape and the value of the
142142
array is a list of Line2D objects in that subplot. Some plotting
143143
functions will return variants of this structure, as described in
144144
the individual documentation for the functions.
145-
axes : 2D array of `matplotlib:Axes`
145+
axes : 2D array of `matplotlib.axes.Axes`
146146
Array of Axes objects for each subplot in the plot.
147-
figure : `matplotlib:Figure`
147+
figure : `matplotlib.figure.Figure`
148148
Figure on which the Axes are drawn.
149-
legend : `matplotlib:.legend.Legend` (instance or ndarray)
149+
legend : `matplotlib.legend.Legend` (instance or ndarray)
150150
Legend object(s) for the plot. If more than one legend is
151151
included, this will be an array with each entry being either None
152152
(for no legend) or a legend object.
@@ -176,6 +176,7 @@ def __setitem__(self, item, val):
176176
self.lines[item] = val
177177
shape = property(lambda self: self.lines.shape, None)
178178
def reshape(self, *args):
179+
"""Reshape lines array (legacy)."""
179180
return self.lines.reshape(*args)
180181

181182
def set_plot_title(self, title, frame='axes'):
@@ -310,11 +311,11 @@ def pole_zero_subplots(
310311
case 'empty', _: # empty grid
311312
ax_array[row, col] = fig.add_subplot(nrows, ncols, index+1)
312313

313-
case True, True: # continuous time grid
314+
case True, True: # continuous-time grid
314315
ax_array[row, col], _ = sgrid(
315316
(nrows, ncols, index+1), scaling=scaling)
316317

317-
case True, False: # discrete time grid
318+
case True, False: # discrete-time grid
318319
ax_array[row, col] = fig.add_subplot(nrows, ncols, index+1)
319320
zgrid(ax=ax_array[row, col], scaling=scaling)
320321

0 commit comments

Comments
 (0)