X Tutup
Skip to content

Commit 7204aa2

Browse files
authored
Merge branch 'main' into test-norm-methods
2 parents 843d747 + 854f5f7 commit 7204aa2

File tree

5 files changed

+47
-35
lines changed

5 files changed

+47
-35
lines changed

control/statefbk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def place_acker(A, B, poles):
251251
pmat = pmat + p[n-i-1] * np.linalg.matrix_power(A, i)
252252
K = np.linalg.solve(ct, pmat)
253253

254-
K = K[-1, :] # Extract the last row
254+
K = K[-1:, :] # Extract the last row
255255
return K
256256

257257

control/tests/statefbk_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,3 +1272,23 @@ def test_create_statefbk_params(unicycle):
12721272
assert [k for k in clsys.params.keys()] == ['K', 'a', 'b']
12731273
assert clsys.params['a'] == 2
12741274
assert clsys.params['b'] == 1
1275+
1276+
1277+
@pytest.mark.parametrize('ny, nu', [(1, 1), (2, 2), (2, 1)])
1278+
@pytest.mark.parametrize(
1279+
'method', [
1280+
place, place_acker,
1281+
pytest.param(place_varga, marks=pytest.mark.slycot)])
1282+
def test_place_variants(ny, nu, method):
1283+
sys = ct.rss(states=2, inputs=nu, outputs=ny)
1284+
desired_poles = -np.arange(1, sys.nstates + 1, 1)
1285+
1286+
if method == place_acker and sys.ninputs != 1:
1287+
with pytest.raises(np.linalg.LinAlgError, match="must be square"):
1288+
K = method(sys.A, sys.B, desired_poles)
1289+
else:
1290+
K = method(sys.A, sys.B, desired_poles)
1291+
1292+
placed_poles = np.linalg.eigvals(sys.A - sys.B @ K)
1293+
np.testing.assert_array_almost_equal(
1294+
np.sort(desired_poles), np.sort(placed_poles))

examples/cds110-L8a_maglev-limits.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
"omega = np.linspace(0, 1e6, 100000)\n",
254254
"for name, sys in zip(['C1', 'C2', 'C3'], [magS1, magS2, magS3]):\n",
255255
" freqresp = ct.frequency_response(sys, omega)\n",
256-
" bodeint = sp.trapezoid(np.log(freqresp.magnitude), omega)\n",
256+
" bodeint = np.trapezoid(np.log(freqresp.magnitude), omega)\n",
257257
" print(\"Bode integral for\", name, \"=\", bodeint)\n",
258258
"\n",
259259
"print(\"pi * sum[ Re(pk) ]\", pi * np.sum(magP.poles()[magP.poles().real > 0]))"

examples/cds112-L6_stochastic-linsys.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"source": [
9393
"# Calculate the sample properties and make sure they match\n",
9494
"print(\"mean(V) [0.0] = \", np.mean(V))\n",
95-
"print(\"cov(V) * dt [%0.3g] = \" % Q, np.round(np.cov(V), decimals=3) * dt)"
95+
"print(\"cov(V) * dt [%0.3g] = \" % Q.item(), np.round(np.cov(V), decimals=3) * dt)"
9696
]
9797
},
9898
{

examples/stochresp.ipynb

Lines changed: 24 additions & 32 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
X Tutup