Skip to content

Commit 395dbbb

Browse files
committed
check for unused keywords in OptimalControlProblem
1 parent 0060618 commit 395dbbb

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

control/optimal.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ def __init__(
134134
self.minimize_kwargs['options'] = kwargs.pop('minimize_options', {})
135135
self.minimize_kwargs.update(kwargs.pop('minimize_kwargs', {}))
136136

137+
if len(kwargs) > 0:
138+
raise ValueError(
139+
f'unrecognized keyword(s): {list(kwargs.keys())}')
140+
137141
# Process trajectory constraints
138142
if isinstance(trajectory_constraints, tuple):
139143
self.trajectory_constraints = [trajectory_constraints]

control/tests/optimal_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,11 @@ def test_ocp_argument_errors():
436436
res = opt.solve_ocp(
437437
sys, time, x0, cost, constraints, initial_guess=np.zeros((4,1,1)))
438438

439+
# Unrecognized arguments
440+
with pytest.raises(ValueError, match="unrecognized keyword"):
441+
res = opt.solve_ocp(
442+
sys, time, x0, cost, constraints, terminal_constraint=None)
443+
439444

440445
def test_optimal_basis_simple():
441446
sys = ct.ss2io(ct.ss([[1, 1], [0, 1]], [[1], [0.5]], np.eye(2), 0, 1))

0 commit comments

Comments
 (0)