Repository navigation
fix: record the element type of indices into non-tunable array parameters in CopyParamsByTemplate - #5238
Merged
Conversation
…ters in `CopyParamsByTemplate`
The branch for an index into a non-tunable array parameter pushed the template entry without its type
to `elem_types`. With more than four entries, `__specialize_templates` then converted the template to
a vector of the union of the recorded types, which does not contain the type of these entries, and
failed with "cannot convert a value to Union{} for assignment", e.g. when building the
initialization problem of a system whose parameters include such arrays.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SYKqL6Rd8TvbY8hGUX4uLL
baggepinnen
marked this pull request as ready for review
October 1, 2026 10:59
Contributor
Benchmark Results (Julia vlts)Time benchmarks
Memory benchmarks
|
Contributor
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
AayushSabharwal
approved these changes
Oct 1, 2026
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.
Problem
CopyParamsByTemplate(srcsys, syms)records the type of each template entry inelem_types, and__specialize_templatesconverts a template of more than four entries to aVectorof the union of these types. The branch for an index into a non-tunable array parameter,_bufidx isa Tuple{Vararg{Int}}, pushed the entry to the template without recording its type. With more than four such entries, the conversion fails:This occurred when building the
ODEProblemof a closed-loop model with a linear MPC controller whose output dimension changed from four to five. The initialization problem then copies three non-tunable array parameters of five entries each, element by element. With four outputs the template has at most four entries and is converted to aTuple, so the missing type has no effect.Change
The branch records
typeof(symidx)inelem_types, as the other branches do.The new test in
test/initial_values.jlbuilds the template of the five elements of a non-tunable array parameter and evaluates it. Without the change it errors with the message above; with the change it passes (run with Julia 1.12.7 against this branch).Host: battomenstation · Claude Code session fab5403f-e741-4cad-a739-8ff803fe0f80
🤖 Generated with Claude Code
https://claude.ai/code/session_01SYKqL6Rd8TvbY8hGUX4uLL