Skip to content

Commit 18fd52e

Browse files
committed
Merge branch 'jgoppert-dev'
2 parents eb6f8c4 + 7d4e11f commit 18fd52e

37 files changed

Lines changed: 1798 additions & 1404 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
*.pyc
22
build/
3-
test/
3+
dist/
4+
.ropeproject/
5+
MANIFEST
46
control/version.py
57
build.log
68
*.egg-info/

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
include examples/*.py
22
include tests/*.py
3+
include README.rst
4+
include ChangeLog
5+
include Pending

README.rst

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,50 @@ Python Control System Library
33

44
.. image:: https://travis-ci.org/python-control/python-control.svg?branch=master
55
:target: https://travis-ci.org/python-control/python-control
6+
.. image:: https://coveralls.io/repos/python-control/python-control/badge.png
7+
:target: https://coveralls.io/r/python-control/python-control
68

79
RMM, 23 May 09
810

911
This directory contains the source code for the Python Control Systems
1012
Library (python-control). This package provides a library of standard
1113
control system algorithms in the python programming environment.
1214

13-
Installation instructions
14-
-------------------------
15-
Standard python package installation:
15+
Installation
16+
------------
1617

17-
python setup.py install
18+
Using pip
19+
~~~~~~~~~~~
20+
21+
Pip is a python packaging system. It can be installed on debian based
22+
linux distros with the command::
23+
24+
sudo apt-get install pip
25+
26+
Pip can then be used to install python-control::
27+
28+
sudo pip install control
29+
30+
31+
From Source
32+
~~~~~~~~~~~
33+
34+
Standard python package installation::
35+
36+
python setup.py install
1837

1938
To see if things are working, you can run the script
2039
examples/secord-matlab.py (using ipython -pylab). It should generate a step
2140
response, Bode plot and Nyquist plot for a simple second order linear
2241
system.
2342

24-
You can also run a set of unit tests to make sure that everything is working
25-
correctly. After installation, run
26-
27-
python tests/test_all.py
43+
Testing
44+
-------
2845

29-
from the source distribution directory (note: doesn't yet work in python
30-
3.x). Alternatively, if you have nosetests installed, you can simply run
31-
32-
nosetests
46+
You can also run a set of unit tests to make sure that everything is working
47+
correctly. After installation, run::
3348

34-
which gives a somewhat cleaner output (and works in python 3.x)
49+
python runtests.py
3550

3651
Slycot
3752
------
@@ -43,7 +58,8 @@ without slycot, but some functionality is limited or absent, and
4358
installation of Slycot is definitely recommended. The Slycot wrapper
4459
can be found at:
4560

46-
https://github.com/repagh/Slycot
61+
https://github.com/jgoppert/Slycot
62+
63+
and can be installed with::
4764

48-
(was forked from https://github.com/avventi/Slycot, but
49-
development/merging appear to have stopped there for now)
65+
sudo pip install slycot

control/__init__.py

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
#
1515
# 1. Redistributions of source code must retain the above copyright
1616
# notice, this list of conditions and the following disclaimer.
17-
#
17+
#
1818
# 2. Redistributions in binary form must reproduce the above copyright
1919
# notice, this list of conditions and the following disclaimer in the
2020
# documentation and/or other materials provided with the distribution.
21-
#
21+
#
2222
# 3. Neither the name of the California Institute of Technology nor
2323
# the names of its contributors may be used to endorse or promote
2424
# products derived from this software without specific prior
2525
# written permission.
26-
#
26+
#
2727
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2828
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2929
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -36,7 +36,7 @@
3636
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3737
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3838
# SUCH DAMAGE.
39-
#
39+
#
4040
# $Id$
4141

4242
"""Control System Library
@@ -56,50 +56,61 @@
5656
lqe linear quadratic estimator
5757
"""
5858

59-
# Import functions from within the control system library
60-
#! Should probably only import the exact functions we use...
61-
from control.bdalg import series, parallel, negate, feedback
62-
from control.delay import pade
63-
from control.dtime import sample_system
64-
from control.freqplot import bode_plot, nyquist_plot, gangof4_plot
65-
from control.freqplot import bode, nyquist, gangof4
66-
from control.lti import issiso, timebase, timebaseEqual, isdtime, isctime
67-
from control.margins import stability_margins, phase_crossover_frequencies
68-
from control.mateqn import lyap, dlyap, care, dare
69-
from control.modelsimp import hsvd, modred, balred, era, markov
70-
from control.nichols import nichols_plot, nichols
71-
from control.phaseplot import phase_plot, box_grid
72-
from control.rlocus import root_locus
73-
from control.statefbk import place, lqr, ctrb, obsv, gram, acker
74-
from control.statesp import StateSpace
75-
from control.timeresp import forced_response, initial_response, step_response, \
76-
impulse_response
77-
from control.xferfcn import TransferFunction
78-
from control.ctrlutil import unwrap, issys
79-
from control.frdata import FRD
80-
from control.canonical import canonical_form, reachable_form
59+
try:
60+
__CONTROL_SETUP__
61+
except NameError:
62+
__CONTROL_SETUP__ = False
63+
64+
if __CONTROL_SETUP__:
65+
import sys as _sys
66+
_sys.stderr.write('Running from control source directory.\n')
67+
del _sys
68+
else:
69+
70+
# Import functions from within the control system library
71+
# Should probably only import the exact functions we use...
72+
from .bdalg import series, parallel, negate, feedback
73+
from .delay import pade
74+
from .dtime import sample_system
75+
from .freqplot import bode_plot, nyquist_plot, gangof4_plot
76+
from .freqplot import bode, nyquist, gangof4
77+
from .lti import issiso, timebase, timebaseEqual, isdtime, isctime
78+
from .margins import stability_margins, phase_crossover_frequencies
79+
from .mateqn import lyap, dlyap, care, dare
80+
from .modelsimp import hsvd, modred, balred, era, markov
81+
from .nichols import nichols_plot, nichols
82+
from .phaseplot import phase_plot, box_grid
83+
from .rlocus import root_locus
84+
from .statefbk import place, lqr, ctrb, obsv, gram, acker
85+
from .statesp import StateSpace
86+
from .timeresp import forced_response, initial_response, step_response, \
87+
impulse_response
88+
from .xferfcn import TransferFunction
89+
from .ctrlutil import unwrap, issys
90+
from .frdata import FRD
91+
from .canonical import canonical_form, reachable_form
8192

82-
# Exceptions
83-
from control.exception import *
93+
# Exceptions
94+
from .exception import *
8495

85-
# Import some of the more common (and benign) MATLAB shortcuts
86-
# By default, don't import conflicting commands here
87-
#! TODO (RMM, 4 Nov 2012): remove MATLAB dependencies from __init__.py
88-
#!
89-
#! Eventually, all functionality should be in modules *other* than matlab.
90-
#! This will allow inclusion of the matlab module to set up a different set
91-
#! of defaults from the main package. At that point, the matlab module will
92-
#! allow provide compatibility with MATLAB but no package functionality.
93-
#!
94-
from control.matlab import ss, tf, ss2tf, tf2ss, drss
95-
from control.matlab import pole, zero, evalfr, freqresp, dcgain
96-
from control.matlab import nichols, rlocus, margin
97-
# bode and nyquist come directly from freqplot.py
98-
from control.matlab import step, impulse, initial, lsim
99-
from control.matlab import ssdata, tfdata
96+
# Import some of the more common (and benign) MATLAB shortcuts
97+
# By default, don't import conflicting commands here
98+
#! TODO (RMM, 4 Nov 2012): remove MATLAB dependencies from __init__.py
99+
#!
100+
#! Eventually, all functionality should be in modules *other* than matlab.
101+
#! This will allow inclusion of the matlab module to set up a different set
102+
#! of defaults from the main package. At that point, the matlab module will
103+
#! allow provide compatibility with MATLAB but no package functionality.
104+
#!
105+
from .matlab import ss, tf, ss2tf, tf2ss, drss
106+
from .matlab import pole, zero, evalfr, freqresp, dcgain
107+
from .matlab import nichols, rlocus, margin
108+
# bode and nyquist come directly from freqplot.py
109+
from .matlab import step, impulse, initial, lsim
110+
from .matlab import ssdata, tfdata
100111

101112
# The following is to use Numpy's testing framework
102113
# Tests go under directory tests/, benchmarks under directory benchmarks/
103-
from numpy.testing import Tester
104-
test = Tester().test
105-
bench = Tester().bench
114+
from numpy.testing import Tester
115+
test = Tester().test
116+
bench = Tester().bench

control/bdalg.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
"""
5555

5656
import scipy as sp
57-
import control.xferfcn as tf
58-
import control.statesp as ss
59-
import control.frdata as frd
57+
from . import xferfcn as tf
58+
from . import statesp as ss
59+
from . import frdata as frd
6060

6161
def series(sys1, sys2):
6262
"""Return the series connection sys2 * sys1 for --> sys1 --> sys2 -->.
@@ -97,7 +97,7 @@ def series(sys1, sys2):
9797
>>> sys3 = series(sys1, sys2) # Same as sys3 = sys2 * sys1.
9898
9999
"""
100-
100+
101101
return sys2 * sys1
102102

103103
def parallel(sys1, sys2):
@@ -117,12 +117,12 @@ def parallel(sys1, sys2):
117117
------
118118
ValueError
119119
if `sys1` and `sys2` do not have the same numbers of inputs and outputs
120-
120+
121121
See Also
122122
--------
123123
series
124124
feedback
125-
125+
126126
Notes
127127
-----
128128
This function is a wrapper for the __add__ function in the
@@ -140,7 +140,7 @@ def parallel(sys1, sys2):
140140
>>> sys3 = parallel(sys1, sys2) # Same as sys3 = sys1 + sys2.
141141
142142
"""
143-
143+
144144
return sys1 + sys2
145145

146146
def negate(sys):
@@ -170,7 +170,7 @@ def negate(sys):
170170
>>> sys2 = negate(sys1) # Same as sys2 = -sys1.
171171
172172
"""
173-
173+
174174
return -sys;
175175

176176
#! TODO: expand to allow sys2 default to work in MIMO case?
@@ -184,7 +184,7 @@ def feedback(sys1, sys2=1, sign=-1):
184184
The primary plant.
185185
sys2: scalar, StateSpace, TransferFunction, FRD
186186
The feedback plant (often a feedback controller).
187-
sign: scalar
187+
sign: scalar
188188
The sign of feedback. `sign` = -1 indicates negative feedback, and
189189
`sign` = 1 indicates positive feedback. `sign` is an optional
190190
argument; it assumes a value of -1 if not specified.
@@ -215,7 +215,7 @@ def feedback(sys1, sys2=1, sign=-1):
215215
object. If `sys1` is a scalar, then it is converted to `sys2`'s type, and
216216
the corresponding feedback function is used. If `sys1` and `sys2` are both
217217
scalars, then TransferFunction.feedback is used.
218-
218+
219219
"""
220220

221221
# Check for correct input types.
@@ -225,7 +225,7 @@ def feedback(sys1, sys2=1, sign=-1):
225225
"or FRD object, or a scalar.")
226226
if not isinstance(sys2, (int, float, complex, tf.TransferFunction,
227227
ss.StateSpace, frd.FRD)):
228-
raise TypeError("sys2 must be a TransferFunction, StateSpace " +
228+
raise TypeError("sys2 must be a TransferFunction, StateSpace " +
229229
"or FRD object, or a scalar.")
230230

231231
# If sys1 is a scalar, convert it to the appropriate LTI type so that we can
@@ -257,19 +257,19 @@ def append(*sys):
257257
sys1, sys2, ... sysn: StateSpace or Transferfunction
258258
LTI systems to combine
259259
260-
260+
261261
Returns
262262
-------
263263
sys: LTI system
264-
Combined LTI system, with input/output vectors consisting of all
264+
Combined LTI system, with input/output vectors consisting of all
265265
input/output vectors appended
266-
266+
267267
Examples
268268
--------
269269
>>> sys1 = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
270270
>>> sys2 = ss("-1.", "1.", "1.", "0.")
271271
>>> sys = append(sys1, sys2)
272-
272+
273273
.. todo::
274274
also implement for transfer function, zpk, etc.
275275
'''
@@ -327,12 +327,12 @@ def connect(sys, Q, inputv, outputv):
327327
elif outp < 0 and -outp >= -sys.outputs:
328328
K[inp,-outp-1] = -1.
329329
sys = sys.feedback(sp.matrix(K), sign=1)
330-
330+
331331
# now trim
332332
Ytrim = sp.zeros( (len(outputv), sys.outputs) )
333333
Utrim = sp.zeros( (sys.inputs, len(inputv)) )
334334
for i,u in enumerate(inputv):
335335
Utrim[u-1,i] = 1.
336336
for i,y in enumerate(outputv):
337337
Ytrim[i,y-1] = 1.
338-
return sp.matrix(Ytrim)*sys*sp.matrix(Utrim)
338+
return sp.matrix(Ytrim)*sys*sp.matrix(Utrim)

0 commit comments

Comments
 (0)