GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix return shape for place_acker (#1190) · python-control/python-control@3215681

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • control
    • statefbk.py
    • tests
      • statefbk_test.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎control/statefbk.py‎

Copy file name to clipboardExpand all lines: control/statefbk.py
+1-1Lines 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

Collapse file

‎control/tests/statefbk_test.py‎

Copy file name to clipboardExpand all lines: control/tests/statefbk_test.py
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,3 +1272,20 @@ 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('method', [place, place_varga, place_acker])
1279+
def test_place_variants(ny, nu, method):
1280+
sys = ct.rss(states=2, inputs=nu, outputs=ny)
1281+
desired_poles = -np.arange(1, sys.nstates + 1, 1)
1282+
1283+
if method == place_acker and sys.ninputs != 1:
1284+
with pytest.raises(np.linalg.LinAlgError, match="must be square"):
1285+
K = method(sys.A, sys.B, desired_poles)
1286+
else:
1287+
K = method(sys.A, sys.B, desired_poles)
1288+
1289+
placed_poles = np.linalg.eigvals(sys.A - sys.B @ K)
1290+
np.testing.assert_array_almost_equal(
1291+
np.sort(desired_poles), np.sort(placed_poles))

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.