Repository navigation
generate_initializesystem inserts keys into the op dict while iterating it, so the loop can miss some keys - #5277
Merged
Conversation
…rating it, so the loop can miss some keys
Two loops that pin operating point values insert `Initial(k)` keys into
`op` inside `for (k, v) in op`. An insertion can rehash the `Dict`,
which moves the keys to new slots, so the loop sees some keys twice and
others 0 times:
```julia
ks = ["p4", "p5", "p6", "p7", "p8", "p9"]
d = Dict(k => i for (i, k) in enumerate(ks))
seen = String[]
for (k, v) in d # or collect(d)
push!(seen, k)
startswith(k, "Initial") || (d["Initial($k)"] = v)
end
[count(==(k), seen) for k in ks]
# (k, v) in d: [0, 2, 1, 2, 2, 2] Julia 1.13.1
# (k, v) in collect(d): [1, 1, 1, 1, 1, 1]
```
Both loops now iterate over `collect(op)` instead of `op`.
A new testset covers 128 states and 128 solvable parameters.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ChrisRackauckas
referenced
this pull request
Oct 17, 2026
…5284) Bump versions: ModelingToolkitBase 1.77.5, ModelingToolkit 11.45.5 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Agent-Harness: Claude Code 2.1.302 Agent-Model: claude-sonnet-5-5 Claude-Session: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq
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.
Two loops that pin operating point values insert
Initial(k)keys intoopinsidefor (k, v) in op. An insertion can rehash theDict, which moves the keys to new slots, so the loop sees some keys twice and others 0 times:Both loops now iterate over
collect(op)instead ofop. A new testset covers 128 states and 128 solvable parameters.Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.