Skip to content

Commit 0e93ad3

Browse files
committed
Provide a more helpful error message for constructor
1 parent 7a0b449 commit 0e93ad3

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ A specific version can be specified using
5252
```
5353
(v1.5) pkg> add [email protected]
5454
```
55-
Or you can check out the master branch with
55+
Or you can check out the main branch with
5656
```
57-
(v1.5) pkg> add TrajectoryOptimization#master
57+
(v1.5) pkg> add TrajectoryOptimization#main
5858
```
5959
Lastly, if you want to clone the repo into your `.julia/dev/` directory for development, you can use
6060
```

src/problem.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ function Problem(models::Vector{<:DiscreteDynamics}, obj::O, x0::AbstractVector,
8484
U0=[fill(0.0, RD.control_dim(model)) for model in models],
8585
kwargs...) where {O}
8686

87+
if :x0 in keys(kwargs)
88+
throw(ArgumentError("Cannot pass x0 as a keyword argument. It is now a positional argument, and xf is a keyword argument.\n" *
89+
"\tUse Problem(model, obj, x0, tf, xf=xf, kwargs...) instead."
90+
))
91+
end
92+
8793
# Check control dimensions
8894
nx,nu = RD.dims(models)
8995
same_state_dimension = all(x->x == nx[1], nx)

test/problems_tests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,6 @@ rollout!(prob)
213213

214214
@test RD.setinitialtime!(prob, 1.0) == 1.0 + tf
215215
@test prob.Z[1].t == 1.0
216-
@test prob.Z[end].t == 1.0 + tf
216+
@test prob.Z[end].t == 1.0 + tf
217+
218+
@test_throws ArgumentError Problem(dmodel, obj, xf, tf, x0=x0)

0 commit comments

Comments
 (0)