Conversation
- Test slices in constraints: x[1:3](0), x[1:end](0), x[1:n](0) - Test slices in dynamics: ∂(x[1:3])(t), ∂(x[1:end])(t), ∂(x[1:n])(t) - Test slices in Mayer cost: x[1:3](tf), x[1:end](tf), x[1:n](tf) - Mark broken tests for unsupported features (end keyword, variable n) - Literal integer ranges work for parsing, some broken for discretisation
Comprehensive Slice Notation TestsThis PR adds extensive tests for slice notation ( Test CoverageThe test suite covers 3 main contexts where slices can appear:
For each context, we test 3 slice variants:
Current Status✅ What Works (End-to-End)
|
| Context | Slice Type | Parsing | Discretisation |
|---|---|---|---|
| Dynamics | ∂(x[1:3])(t) |
✅ | ❌ |
| Dynamics | ∂(x[1:n])(t) |
✅ | ❌ |
| Mayer cost | x[1:3](tf) |
✅ | ❌ |
| Mayer cost | x[1:end](tf) |
✅ | ❌ |
| Mayer cost | x[1:n](tf) |
✅ | ❌ |
❌ What's Broken (Parsing Fails)
| Context | Slice Type | Error |
|---|---|---|
| Constraints | x[1:end](0) |
MethodError: no method matching (::Colon)(::Int64, ::Symbol) |
| Constraints | x[1:n](0) |
MethodError: no method matching (::Colon)(::Int64, ::Symbol) |
| Dynamics | ∂(x[1:end])(t) |
MethodError: no method matching (::Colon)(::Int64, ::Symbol) |
Key Findings
- Literal integer ranges (
x[1:3]) work everywhere for parsing endkeyword fails during parsing in constraints and dynamics contexts- Variable slices (
x[1:n]) work for parsing in dynamics and Mayer cost, but fail in constraints - Discretisation currently only works for constraints with literal ranges
Test Structure
Each context has:
- Model builders: Helper functions to create test problems
- Unit tests: Verify parsing and model construction
- Integration tests: Test discretisation and solver execution
All broken tests are marked with @test_broken to document known limitations without failing the test suite.
Next Steps
- High Priority: Fix
endkeyword support in slice parsing (affects all contexts) - High Priority: Fix variable slice support (
x[1:n]) in constraints - Medium Priority: Fix discretisation for sliced dynamics (
∂(x[1:3])(t)) - Medium Priority: Fix discretisation for sliced Mayer costs (
x[...](tf))
|
@ocots agreed
|
|
@ocots NB. Also need to allow see also: #22 (comment) PS. after a few years of usage, regarding the syntax, i find the instrumental parts are
|
|
Update (supersedes the earlier comment): the test file has been completely rebuilt as a systematic notation matrix. Current result: 111 passed, 42 broken, 0 errors (153 tests total). All broken cases use Comprehensive Slice / Index Notation Test MatrixThe file Notation forms tested
Summary table (✅ = @test passing · 🔧 = @test_broken · — = not tested)
Key findings
|
x[1:3](0),x[1:end](0),x[1:n](0)∂(x[1:3])(t),∂(x[1:end])(t),∂(x[1:n])(t)x[1:3](tf),x[1:end](tf),x[1:n](tf)