Skip to content

Commit b19ca11

Browse files
committed
DOC: update docstrings for system creation (see PR #163)
1 parent da0ddc1 commit b19ca11

7 files changed

Lines changed: 1266 additions & 33 deletions

File tree

control/ctrlutil.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
import numpy as np
4646
from numpy import pi
4747

48+
# Hack for sphinx.ext.autodoc: if numpy is a mock import, then numpy.pi
49+
# will be assigned to _Mock() and this generates a type error
50+
if not isinstance(pi, float):
51+
pi = 3.14
52+
4853
__all__ = ['unwrap', 'issys', 'db2mag', 'mag2db']
4954

5055
# Utility function to unwrap an angle measurement

control/frdata.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
__all__ = ['FRD', 'frd']
5858

5959
class FRD(LTI):
60-
"""A class for models defined by Frequency Response Data (FRD)
60+
"""FRD(d, w)
61+
62+
A class for models defined by frequency response data (FRD)
6163
6264
The FRD class is used to represent systems in frequency response data form.
6365
@@ -80,7 +82,9 @@ class FRD(LTI):
8082
epsw = 1e-8
8183

8284
def __init__(self, *args, **kwargs):
83-
"""Construct an FRD object
85+
"""FRD(d, w)
86+
87+
Construct an FRD object
8488
8589
The default constructor is FRD(d, w), where w is an iterable of
8690
frequency points, and d is the matching frequency data.
@@ -469,8 +473,9 @@ def _convertToFRD(sys, omega, inputs=1, outputs=1):
469473
sys.__class__)
470474

471475
def frd(*args):
472-
"""
473-
Construct a Frequency Response Data model, or convert a system
476+
"""frd(d, w)
477+
478+
Construct a frequency response data model
474479
475480
frd models store the (measured) frequency response of a system.
476481
@@ -500,6 +505,6 @@ def frd(*args):
500505
501506
See Also
502507
--------
503-
ss, tf
508+
FRD, ss, tf
504509
"""
505510
return FRD(*args)

control/margins.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
Date: 14 July 2011
4949
5050
$Id$
51-
5251
"""
5352

5453
import numpy as np
@@ -62,7 +61,7 @@
6261
# helper functions for stability_margins
6362
def _polyimsplit(pol):
6463
"""split a polynomial with (iw) applied into a real and an
65-
imaginary part with w applied"""
64+
imaginary part with w applied"""
6665
rpencil = np.zeros_like(pol)
6766
ipencil = np.zeros_like(pol)
6867
rpencil[-1::-4] = 1.
@@ -294,8 +293,7 @@ def dstab(w):
294293
# Contributed by Steffen Waldherr <waldherr@ist.uni-stuttgart.de>
295294
#! TODO - need to add test functions
296295
def phase_crossover_frequencies(sys):
297-
"""
298-
Compute frequencies and gains at intersections with real axis
296+
"""Compute frequencies and gains at intersections with real axis
299297
in Nyquist plot.
300298
301299
Call as:
@@ -360,8 +358,8 @@ def margin(*args):
360358
Wcp : float
361359
Phase crossover frequency (corresponding to gain margin) (in rad/sec)
362360
363-
Margins are of SISO open-loop. If more than one crossover frequency is
364-
detected, returns the lowest corresponding margin.
361+
Margins are of SISO open-loop. If more than one crossover frequency is
362+
detected, returns the lowest corresponding margin.
365363
366364
Examples
367365
--------

control/robust.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def h2syn(P,nmeas,ncon):
7272
>>> K = h2syn(P,nmeas,ncon)
7373
7474
"""
75-
7675
#Check for ss system object, need a utility for this?
7776

7877
#TODO: Check for continous or discrete, only continuous supported right now
@@ -116,11 +115,11 @@ def hinfsyn(P,nmeas,ncon):
116115
CL: closed loop system (State-space sys)
117116
gam: infinity norm of closed loop system
118117
rcond: 4-vector, reciprocal condition estimates of:
119-
1: control transformation matrix
120-
2: measurement transformation matrix
121-
3: X-Ricatti equation
122-
4: Y-Ricatti equation
123-
TODO: document significance of rcond
118+
1: control transformation matrix
119+
2: measurement transformation matrix
120+
3: X-Ricatti equation
121+
4: Y-Ricatti equation
122+
TODO: document significance of rcond
124123
125124
Raises
126125
------

control/statesp.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@
6868
__all__ = ['StateSpace', 'ss', 'rss', 'drss', 'tf2ss', 'ssdata']
6969

7070
class StateSpace(LTI):
71-
"""A class for representing state-space models
71+
"""StateSpace(A, B, C, D[, dt])
72+
73+
A class for representing state-space models
7274
7375
The StateSpace class is used to represent state-space realizations of linear
7476
time-invariant (LTI) systems:
@@ -88,15 +90,19 @@ class StateSpace(LTI):
8890
means the system timebase is not specified. If 'dt' is set to True, the
8991
system will be treated as a discrete time system with unspecified
9092
sampling time.
91-
9293
"""
9394

9495
def __init__(self, *args):
95-
"""Construct a state space object.
96+
"""
97+
StateSpace(A, B, C, D[, dt])
9698
97-
The default constructor is StateSpace(A, B, C, D), where A, B, C, D are
98-
matrices or equivalent objects. To call the copy constructor, call
99-
StateSpace(sys), where sys is a StateSpace object.
99+
Construct a state space object.
100+
101+
The default constructor is StateSpace(A, B, C, D), where A, B, C, D
102+
are matrices or equivalent objects. To create a discrete time system,
103+
use StateSpace(A, B, C, D, dt) where 'dt' is the sampling time (or
104+
True for unspecified sampling time). To call the copy constructor,
105+
call StateSpace(sys), where sys is a StateSpace object.
100106
101107
"""
102108

@@ -110,8 +116,7 @@ def __init__(self, *args):
110116
elif len(args) == 1:
111117
# Use the copy constructor.
112118
if not isinstance(args[0], StateSpace):
113-
raise TypeError("The one-argument constructor can only take in \
114-
a StateSpace object. Recived %s." % type(args[0]))
119+
raise TypeError("The one-argument constructor can only take in a StateSpace object. Received %s." % type(args[0]))
115120
A = args[0].A
116121
B = args[0].B
117122
C = args[0].C
@@ -956,7 +961,8 @@ def _mimo2simo(sys, input, warn_conversion=False):
956961
return sys
957962

958963
def ss(*args):
959-
"""
964+
"""ss(A, B, C, D[, dt])
965+
960966
Create a state space system.
961967
962968
The function accepts either 1, 4 or 5 parameters:
@@ -1014,6 +1020,7 @@ def ss(*args):
10141020
10151021
See Also
10161022
--------
1023+
StateSpace
10171024
tf
10181025
ss2tf
10191026
tf2ss

0 commit comments

Comments
 (0)