Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docstrings for LTI class constructors #171

Merged
merged 7 commits into from
Jan 2, 2018
Merged
3 changes: 2 additions & 1 deletion control/bdalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ def feedback(sys1, sys2=1, sign=-1):
return sys1.feedback(sys2, sign)

def append(*sys):
'''
'''append(sys1, sys2, ... sysn)

Group models by appending their inputs and outputs

Forms an augmented system model, and appends the inputs and
Expand Down
5 changes: 5 additions & 0 deletions control/ctrlutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
import numpy as np
from numpy import pi

# Hack for sphinx.ext.autodoc: if numpy is a mock import, then numpy.pi
# will be assigned to _Mock() and this generates a type error
if not isinstance(pi, float):
pi = 3.14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about "from math import pi" here? Or does that result in a mocked instance of some sort too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better fix since math is included in the base python distribution.


__all__ = ['unwrap', 'issys', 'db2mag', 'mag2db']

# Utility function to unwrap an angle measurement
Expand Down
15 changes: 10 additions & 5 deletions control/frdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
__all__ = ['FRD', 'frd']

class FRD(LTI):
"""A class for models defined by Frequency Response Data (FRD)
"""FRD(d, w)

A class for models defined by frequency response data (FRD)

The FRD class is used to represent systems in frequency response data form.

Expand All @@ -80,7 +82,9 @@ class FRD(LTI):
epsw = 1e-8

def __init__(self, *args, **kwargs):
"""Construct an FRD object
"""FRD(d, w)

Construct an FRD object

The default constructor is FRD(d, w), where w is an iterable of
frequency points, and d is the matching frequency data.
Expand Down Expand Up @@ -469,8 +473,9 @@ def _convertToFRD(sys, omega, inputs=1, outputs=1):
sys.__class__)

def frd(*args):
"""
Construct a Frequency Response Data model, or convert a system
"""frd(d, w)

Construct a frequency response data model

frd models store the (measured) frequency response of a system.

Expand Down Expand Up @@ -500,6 +505,6 @@ def frd(*args):

See Also
--------
ss, tf
FRD, ss, tf
"""
return FRD(*args)
14 changes: 7 additions & 7 deletions control/margins.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
Date: 14 July 2011

$Id$

"""

import numpy as np
Expand All @@ -62,7 +61,7 @@
# helper functions for stability_margins
def _polyimsplit(pol):
"""split a polynomial with (iw) applied into a real and an
imaginary part with w applied"""
imaginary part with w applied"""
rpencil = np.zeros_like(pol)
ipencil = np.zeros_like(pol)
rpencil[-1::-4] = 1.
Expand Down Expand Up @@ -294,8 +293,7 @@ def dstab(w):
# Contributed by Steffen Waldherr <waldherr@ist.uni-stuttgart.de>
#! TODO - need to add test functions
def phase_crossover_frequencies(sys):
"""
Compute frequencies and gains at intersections with real axis
"""Compute frequencies and gains at intersections with real axis
in Nyquist plot.

Call as:
Expand Down Expand Up @@ -338,7 +336,9 @@ def phase_crossover_frequencies(sys):


def margin(*args):
"""Calculate gain and phase margins and associated crossover frequencies
"""margin(sys)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just below (line 345) the name "sysdata" is used; perhaps that should be used here?


Calculate gain and phase margins and associated crossover frequencies

Parameters
----------
Expand All @@ -360,8 +360,8 @@ def margin(*args):
Wcp : float
Phase crossover frequency (corresponding to gain margin) (in rad/sec)

Margins are of SISO open-loop. If more than one crossover frequency is
detected, returns the lowest corresponding margin.
Margins are of SISO open-loop. If more than one crossover frequency is
detected, returns the lowest corresponding margin.

Examples
--------
Expand Down
4 changes: 3 additions & 1 deletion control/matlab/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
__all__ = ['bode', 'ngrid', 'dcgain']

def bode(*args, **keywords):
"""Bode plot of the frequency response
"""bode(syslist[, omega, dB, Hz, deg, ...])

Bode plot of the frequency response

Plots a bode gain and phase diagram

Expand Down
11 changes: 5 additions & 6 deletions control/robust.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def h2syn(P,nmeas,ncon):
>>> K = h2syn(P,nmeas,ncon)

"""

#Check for ss system object, need a utility for this?

#TODO: Check for continous or discrete, only continuous supported right now
Expand Down Expand Up @@ -116,11 +115,11 @@ def hinfsyn(P,nmeas,ncon):
CL: closed loop system (State-space sys)
gam: infinity norm of closed loop system
rcond: 4-vector, reciprocal condition estimates of:
1: control transformation matrix
2: measurement transformation matrix
3: X-Ricatti equation
4: Y-Ricatti equation
TODO: document significance of rcond
1: control transformation matrix
2: measurement transformation matrix
3: X-Ricatti equation
4: Y-Ricatti equation
TODO: document significance of rcond

Raises
------
Expand Down
4 changes: 3 additions & 1 deletion control/statefbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ def acker(A, B, poles):
return K

def lqr(*args, **keywords):
"""Linear quadratic regulator design
"""lqr(A, B, Q, R[, N])

Linear quadratic regulator design

The lqr() function computes the optimal state feedback controller
that minimizes the quadratic cost
Expand Down
28 changes: 18 additions & 10 deletions control/statesp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
__all__ = ['StateSpace', 'ss', 'rss', 'drss', 'tf2ss', 'ssdata']

class StateSpace(LTI):
"""A class for representing state-space models
"""StateSpace(A, B, C, D[, dt])

A class for representing state-space models

The StateSpace class is used to represent state-space realizations of linear
time-invariant (LTI) systems:
Expand All @@ -88,15 +90,19 @@ class StateSpace(LTI):
means the system timebase is not specified. If 'dt' is set to True, the
system will be treated as a discrete time system with unspecified
sampling time.

"""

def __init__(self, *args):
"""Construct a state space object.
"""
StateSpace(A, B, C, D[, dt])

Construct a state space object.

The default constructor is StateSpace(A, B, C, D), where A, B, C, D are
matrices or equivalent objects. To call the copy constructor, call
StateSpace(sys), where sys is a StateSpace object.
The default constructor is StateSpace(A, B, C, D), where A, B, C, D
are matrices or equivalent objects. To create a discrete time system,
use StateSpace(A, B, C, D, dt) where 'dt' is the sampling time (or
True for unspecified sampling time). To call the copy constructor,
call StateSpace(sys), where sys is a StateSpace object.

"""

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

def ss(*args):
"""
"""ss(A, B, C, D[, dt])

Create a state space system.

The function accepts either 1, 4 or 5 parameters:
Expand Down Expand Up @@ -1014,6 +1020,7 @@ def ss(*args):

See Also
--------
StateSpace
tf
ss2tf
tf2ss
Expand Down Expand Up @@ -1045,7 +1052,8 @@ def ss(*args):
raise ValueError("Needs 1 or 4 arguments; received %i." % len(args))

def tf2ss(*args):
"""
"""tf2ss(sys)

Transform a transfer function to a state space system.

The function accepts either 1 or 2 parameters:
Expand Down