Skip to content

Commit 334c354

Browse files
committed
Merge branch 'userguide-22Dec2024' into latest
2 parents a2c3b4c + ee8f4b7 commit 334c354

File tree

176 files changed

+5009
-2279
lines changed

Some content is hidden

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

176 files changed

+5009
-2279
lines changed

.github/conda-env/doctest-env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ dependencies:
1313
- nbsphinx
1414
- docutils
1515
- numpydoc
16+
- sphinx-copybutton

.github/conda-env/test-env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ dependencies:
99
- numpy
1010
- matplotlib
1111
- scipy
12+
- numpydoc

.github/workflows/doctest.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ jobs:
3636
make html
3737
make doctest
3838
39+
- name: Run pytest
40+
shell: bash -l {0}
41+
working-directory: doc
42+
run: |
43+
make html
44+
PYTHONPATH=../ pytest
45+
3946
- name: Archive results
4047
uses: actions/upload-artifact@v4
4148
with:

control/__init__.py

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,23 @@
11
# __init__.py - initialization for control systems toolbox
22
#
33
# Author: Richard M. Murray
4-
# Date: 24 May 09
5-
#
6-
# This file contains the initialization information from the control package.
7-
#
8-
# Copyright (c) 2009 by California Institute of Technology
9-
# All rights reserved.
10-
#
11-
# Redistribution and use in source and binary forms, with or without
12-
# modification, are permitted provided that the following conditions
13-
# are met:
14-
#
15-
# 1. Redistributions of source code must retain the above copyright
16-
# notice, this list of conditions and the following disclaimer.
17-
#
18-
# 2. Redistributions in binary form must reproduce the above copyright
19-
# notice, this list of conditions and the following disclaimer in the
20-
# documentation and/or other materials provided with the distribution.
21-
#
22-
# 3. Neither the name of the California Institute of Technology nor
23-
# the names of its contributors may be used to endorse or promote
24-
# products derived from this software without specific prior
25-
# written permission.
26-
#
27-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30-
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CALTECH
31-
# OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
34-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35-
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36-
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
37-
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38-
# SUCH DAMAGE.
39-
#
40-
# $Id$
4+
# Date: 24 May 2009
415

42-
"""
43-
The Python Control Systems Library :mod:`control` provides common functions
6+
"""The Python Control Systems Library :mod:`control` provides common functions
447
for analyzing and designing feedback control systems.
458
9+
The initial goal for the package is to implement all of the
10+
functionality required to work through the examples in the textbook
11+
`Feedback Systems <http://fbsbook.org>`_ by Astrom and Murray. In
12+
addition to standard techniques available for linear control systems,
13+
support for nonlinear systems (including trajectory generation, gain
14+
scheduling, phase plane diagrams, and describing functions) is also
15+
included. A :ref:`matlab-module` is available that provides many of
16+
the common functions corresponding to commands available in the MATLAB
17+
Control Systems Toolbox.
18+
4619
Documentation is available in two forms: docstrings provided with the code,
47-
and the python-control users guide, available from `the python-control
20+
and the python-control User Guide, available from the `python-control
4821
homepage <https://www.python-control.org>`_.
4922
5023
The docstring examples assume that the following import commands::

control/bdalg.py

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@
6969
'combine_tf', 'split_tf']
7070

7171

72-
def series(sys1, *sysn, **kwargs):
73-
r"""series(sys1, sys2, [..., sysn])
72+
def series(*sys, **kwargs):
73+
r"""series(sys1, sys2[, ..., sysn])
7474
75-
Return the series connection (`sysn` \* ...\ \*) `sys2` \* `sys1`.
75+
Return series connection (`sysn` \* ...\ \*) `sys2` \* `sys1`.
7676
7777
Parameters
7878
----------
@@ -136,15 +136,15 @@ def series(sys1, *sysn, **kwargs):
136136
(2, 1, 5)
137137
138138
"""
139-
sys = reduce(lambda x, y: y * x, sysn, sys1)
139+
sys = reduce(lambda x, y: y * x, sys[1:], sys[0])
140140
sys.update_names(**kwargs)
141141
return sys
142142

143143

144-
def parallel(sys1, *sysn, **kwargs):
145-
r"""parallel(sys1, sys2, [..., sysn])
144+
def parallel(*sys, **kwargs):
145+
r"""parallel(sys1, sys2[, ..., sysn])
146146
147-
Return the parallel connection `sys1` + `sys2` (+ ...\ + `sysn`).
147+
Return parallel connection `sys1` + `sys2` (+ ...\ + `sysn`).
148148
149149
Parameters
150150
----------
@@ -206,7 +206,7 @@ def parallel(sys1, *sysn, **kwargs):
206206
(3, 4, 7)
207207
208208
"""
209-
sys = reduce(lambda x, y: x + y, sysn, sys1)
209+
sys = reduce(lambda x, y: x + y, sys[1:], sys[0])
210210
sys.update_names(**kwargs)
211211
return sys
212212

@@ -354,16 +354,16 @@ def feedback(sys1, sys2=1, sign=-1, **kwargs):
354354
return sys
355355

356356
def append(*sys, **kwargs):
357-
"""append(sys1, sys2, [..., sysn])
357+
"""append(sys1, sys2[, ..., sysn])
358358
359-
Group LTI state space models by appending their inputs and outputs.
359+
Group LTI state space models by appending inputs and outputs.
360360
361361
Forms an augmented system model, and appends the inputs and
362362
outputs together.
363363
364364
Parameters
365365
----------
366-
sys1, sys2, ..., sysn: scalar, array, or :class:`StateSpace`
366+
sys1, sys2, ..., sysn : scalar, array, or :class:`StateSpace`
367367
I/O systems to combine.
368368
369369
Other Parameters
@@ -382,7 +382,7 @@ def append(*sys, **kwargs):
382382
383383
Returns
384384
-------
385-
out: :class:`StateSpace`
385+
out : :class:`StateSpace`
386386
Combined system, with input/output vectors consisting of all
387387
input/output vectors appended.
388388
@@ -439,9 +439,9 @@ def connect(sys, Q, inputv, outputv):
439439
values mean the feedback is negative. A zero value is ignored. Inputs
440440
and outputs are indexed starting at 1 to communicate sign information.
441441
inputv : 1D array
442-
list of final external inputs, indexed starting at 1
442+
List of final external inputs, indexed starting at 1.
443443
outputv : 1D array
444-
list of final external outputs, indexed starting at 1
444+
List of final external outputs, indexed starting at 1.
445445
446446
Returns
447447
-------
@@ -512,7 +512,7 @@ def connect(sys, Q, inputv, outputv):
512512
return Ytrim * sys * Utrim
513513

514514
def combine_tf(tf_array):
515-
"""Combine array-like of transfer functions into MIMO transfer function.
515+
"""Combine array of transfer functions into MIMO transfer function.
516516
517517
Parameters
518518
----------
@@ -541,26 +541,20 @@ def combine_tf(tf_array):
541541
--------
542542
Combine two transfer functions
543543
544-
>>> s = control.TransferFunction.s
545-
>>> control.combine_tf([
544+
>>> s = ct.tf('s')
545+
>>> ct.combine_tf([
546546
... [1 / (s + 1)],
547547
... [s / (s + 2)],
548548
... ])
549-
TransferFunction([[array([1])], [array([1, 0])]],
550-
[[array([1, 1])], [array([1, 2])]])
549+
TransferFunction([[array([1])], [array([1, 0])]], [[array([1, 1])], [array([1, 2])]])
551550
552551
Combine NumPy arrays with transfer functions
553552
554-
>>> control.combine_tf([
553+
>>> ct.combine_tf([
555554
... [np.eye(2), np.zeros((2, 1))],
556-
... [np.zeros((1, 2)), control.TransferFunction([1], [1, 0])],
555+
... [np.zeros((1, 2)), ct.tf([1], [1, 0])],
557556
... ])
558-
TransferFunction([[array([1.]), array([0.]), array([0.])],
559-
[array([0.]), array([1.]), array([0.])],
560-
[array([0.]), array([0.]), array([1])]],
561-
[[array([1.]), array([1.]), array([1.])],
562-
[array([1.]), array([1.]), array([1.])],
563-
[array([1.]), array([1.]), array([1, 0])]])
557+
TransferFunction([[array([1.]), array([0.]), array([0.])], [array([0.]), array([1.]), array([0.])], [array([0.]), array([0.]), array([1])]], [[array([1.]), array([1.]), array([1.])], [array([1.]), array([1.]), array([1.])], [array([1.]), array([1.]), array([1, 0])]])
564558
"""
565559
# Find common timebase or raise error
566560
dt_list = []
@@ -600,8 +594,8 @@ def combine_tf(tf_array):
600594
f"row {row_index}."
601595
)
602596
for j_in in range(col.ninputs):
603-
num_row.append(col.num[j_out][j_in])
604-
den_row.append(col.den[j_out][j_in])
597+
num_row.append(col.num_array[j_out, j_in])
598+
den_row.append(col.den_array[j_out, j_in])
605599
num.append(num_row)
606600
den.append(den_row)
607601
for row_index, row in enumerate(num):
@@ -619,7 +613,7 @@ def combine_tf(tf_array):
619613
return tf.TransferFunction(num, den, dt=dt)
620614

621615
def split_tf(transfer_function):
622-
"""Split MIMO transfer function into NumPy array of SISO tranfer functions.
616+
"""Split MIMO transfer function into SISO transfer functions.
623617
624618
Parameters
625619
----------
@@ -635,7 +629,7 @@ def split_tf(transfer_function):
635629
--------
636630
Split a MIMO transfer function
637631
638-
>>> G = control.TransferFunction(
632+
>>> G = ct.tf(
639633
... [
640634
... [[87.8], [-86.4]],
641635
... [[108.2], [-109.6]],
@@ -645,7 +639,7 @@ def split_tf(transfer_function):
645639
... [[1, 1], [1, 1]],
646640
... ],
647641
... )
648-
>>> control.split_tf(G)
642+
>>> ct.split_tf(G)
649643
array([[TransferFunction(array([87.8]), array([1, 1])),
650644
TransferFunction(array([-86.4]), array([1, 1]))],
651645
[TransferFunction(array([108.2]), array([1, 1])),
@@ -657,8 +651,8 @@ def split_tf(transfer_function):
657651
for i_in in range(transfer_function.ninputs):
658652
row.append(
659653
tf.TransferFunction(
660-
transfer_function.num[i_out][i_in],
661-
transfer_function.den[i_out][i_in],
654+
transfer_function.num_array[i_out, i_in],
655+
transfer_function.den_array[i_out, i_in],
662656
dt=transfer_function.dt,
663657
)
664658
)

0 commit comments

Comments
 (0)