Skip to content

Commit 343d5d6

Browse files
authored
Merge pull request #520 from murrayrm/install_examples
add github action to check setup.py, examples, and notebooks
2 parents 649215e + b6e73c7 commit 343d5d6

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: setup.py, examples
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-linux:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up Python
12+
uses: actions/setup-python@v2
13+
- name: Install Python dependencies
14+
run: |
15+
# Set up conda
16+
echo $CONDA/bin >> $GITHUB_PATH
17+
18+
# Set up (virtual) X11
19+
sudo apt install -y xvfb
20+
21+
# Install test tools
22+
conda install pip pytest
23+
24+
# Install python-control dependencies
25+
conda install numpy matplotlib scipy jupyter
26+
conda install -c conda-forge slycot pmw
27+
28+
- name: Install with setup.py
29+
run: python setup.py install
30+
31+
- name: Run examples
32+
run: |
33+
cd examples
34+
./run_examples.sh
35+
./run_notebooks.sh

examples/bode-and-nyquist-plots.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"import seaborn as sns\n",
109
"import scipy as sp\n",
1110
"import matplotlib.pyplot as plt\n",
1211
"import control as ct"
@@ -10025,9 +10024,9 @@
1002510024
],
1002610025
"metadata": {
1002710026
"kernelspec": {
10028-
"display_name": "Python (pctest)",
10027+
"display_name": "Python 3",
1002910028
"language": "python",
10030-
"name": "pctest"
10029+
"name": "python3"
1003110030
},
1003210031
"language_info": {
1003310032
"codemirror_mode": {

examples/run_notebooks.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# run_notbooks.sh - run Jupyter notebooks
3+
# RMM, 26 Jan 2021
4+
#
5+
# This script runs all of the Jupyter notebooks to make sure that there
6+
# are no errors.
7+
8+
# Keep track of files that generate errors
9+
notebook_errors=""
10+
11+
# Go through each Jupyter notebook
12+
for example in *.ipynb; do
13+
echo "Running ${example}"
14+
if ! jupyter nbconvert --to notebook --execute ${example}; then
15+
notebook_errors="${notebook_errors} ${example}"
16+
fi
17+
done
18+
19+
# Get rid of the output files
20+
rm *.nbconvert.ipynb
21+
22+
# List any files that generated errors
23+
if [ -n "${notebook_errors}" ]; then
24+
echo These examples had errors:
25+
echo "${notebook_errors}"
26+
exit 1
27+
else
28+
echo All examples ran successfully
29+
fi

examples/steering.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
" clsys = ct.StateSpace(A - B @ K, B, lateral_normalized.C, 0)\n",
313313
" \n",
314314
" # Compute the feedforward gain based on the zero frequency gain of the closed loop\n",
315-
" kf = np.real(1/clsys.evalfr(0))\n",
315+
" kf = np.real(1/clsys(0))\n",
316316
"\n",
317317
" # Scale the input by the feedforward gain\n",
318318
" clsys *= kf\n",
@@ -488,7 +488,7 @@
488488
"tau = v0 * T_curvy / b\n",
489489
"\n",
490490
"# Simulate the estimator, with a small initial error in y position\n",
491-
"t, y_est, x_est = ct.forced_response(est, tau, [delta_curvy, y_ref], [0.5, 0])\n",
491+
"t, y_est, x_est = ct.forced_response(est, tau, [delta_curvy, y_ref], [0.5, 0], return_x=True)\n",
492492
"\n",
493493
"# Configure matplotlib plots to be a bit bigger and optimize layout\n",
494494
"plt.figure(figsize=[9, 4.5])\n",
@@ -596,7 +596,7 @@
596596
" np.zeros((2,1)))\n",
597597
"\n",
598598
"# Simulate the system\n",
599-
"t, y, x = ct.forced_response(clsys, tau, y_ref, [0.4, 0, 0.0, 0])\n",
599+
"t, y, x = ct.forced_response(clsys, tau, y_ref, [0.4, 0, 0.0, 0], return_x=True)\n",
600600
"\n",
601601
"# Calcaluate the input used to generate the control response\n",
602602
"u_sfb = kf * y_ref - K @ x[0:2]\n",
@@ -1081,7 +1081,7 @@
10811081
"zc = 0.707\n",
10821082
"eigs = np.roots([1, 2*zc*wc, wc**2])\n",
10831083
"K = ct.place(A, B, eigs)\n",
1084-
"kr = np.real(1/clsys.evalfr(0))\n",
1084+
"kr = np.real(1/clsys(0))\n",
10851085
"print(\"K = \", np.squeeze(K))\n",
10861086
"\n",
10871087
"# Compute the estimator gain using eigenvalue placement\n",
@@ -1126,7 +1126,7 @@
11261126
"zc = 2.6\n",
11271127
"eigs = np.roots([1, 2*zc*wc, wc**2])\n",
11281128
"K = ct.place(A, B, eigs)\n",
1129-
"kr = np.real(1/clsys.evalfr(0))\n",
1129+
"kr = np.real(1/clsys(0))\n",
11301130
"print(\"K = \", np.squeeze(K))\n",
11311131
"\n",
11321132
"# Construct an output-based controller for the system\n",

0 commit comments

Comments
 (0)