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
Member
Author
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))
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)