-
-
Notifications
You must be signed in to change notification settings - Fork 224
Fix _varmap_to_vars
, re-enable dde.jl test
#2545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/variables.jl
Outdated
if symbolic_type(val) === NotSymbolic() | ||
values[var] = val | ||
end | ||
values[var] = val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? This could fail in cases where a dependent initialization is not fully defined. For example, if x => 2y
but y
is not specified, val
will be 2y
when we want it to not be a symbolic quantity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just restores the v8 behaviour. In v8 we had
function _varmap_to_vars(varmap::Dict, varlist; defaults = Dict(), check = false,
toterm = Symbolics.diff2term)
varmap = merge(defaults, varmap) # prefers the `varmap`
varmap = Dict(toterm(value(k)) => value(varmap[k]) for k in keys(varmap))
# resolve symbolic parameter expressions
for (p, v) in pairs(varmap)
varmap[p] = fixpoint_sub(v, varmap)
end
missingvars = setdiff(varlist, collect(keys(varmap)))
check && (isempty(missingvars) || throw_missingvars(missingvars))
out = [varmap[var] for var in varlist]
end
which was changed in v9 to only allow values
to have non-symbolic entries, which caused this bug.
e.g. in v8, for the test case linked above, _varmap_to_vars
would take in arguments
varmap = Dict{Num, Num}(x₂(t) => 1.0 - 10q1*t, x₀(t) => 1.0 - 10q1*t, x₁(t) => 1.0 - 10q1*t)
varlist = SymbolicUtils.BasicSymbolic{Real}[x₀(t), x₁(t), x₂(t)]
defaults = Dict{Any, Any}(x₂(t) => 1.0 - 10q1*t, d2 => 1, beta0 => 1, v0 => 1, p0 => 0.2, d0 => 5, beta1 => 1, p1 => 0.2, q0 => 0.3, x₁(t) => 1.0 - 10q1*t, q1 => 0.3, d1 => 1, v1 => 1, x₀(t) => 1.0 - 10q1*t)
and compute
out = SymbolicUtils.BasicSymbolic{Real}[1.0 - 3.0t, 1.0 - 3.0t, 1.0 - 3.0t]
whereas in v9 we also have it taking in the identical arguments:
varmap = Dict{Num, Num}(x₂(t) => 1.0 - 10q1*t, x₀(t) => 1.0 - 10q1*t, x₁(t) => 1.0 - 10q1*t)
varlist = SymbolicUtils.BasicSymbolic{Real}[x₀(t), x₁(t), x₂(t)]
defaults = Dict{Any, Any}(x₂(t) => 1.0 - 10q1*t, d2 => 1, beta0 => 1, v0 => 1, p0 => 0.2, d0 => 5, beta1 => 1, p1 => 0.2, q0 => 0.3, x₁(t) => 1.0 - 10q1*t, q1 => 0.3, d1 => 1, v1 => 1, x₀(t) => 1.0 - 10q1*t)
and erroring. This change makes it so that for the same inputs as before, _varmap_to_vars
produces the same outputs as before:
out = SymbolicUtils.BasicSymbolic{Real}[1.0 - 3.0t, 1.0 - 3.0t, 1.0 - 3.0t]
It's totally possible there's another way to fix this, but I think what I did is just the minimal change to un-break the change in v9.
Please rebase and format so CI runs |
Those commits shouldn't have appeared here after the rebase 😅 |
hmm, not sure what went wrong, I just configured |
Try resetting to before the rebase using
usually works for me |
Aha, yeah I think I just did a bad order of operations or something, thank you for spelling it out. |
So, comparing with #2548, it seems that there's an overall improvement here with a couple of previously failing suites now passing (in addition to the Neuroblox tests which need this change in order to upgrade to MTK v9), and I'm not seeing any new regressions. |
The failures in #2548 that don't fail here are due to codecov being flaky. This PR does have test regressions in
|
ah okay. Yeah, two of those are easy fixes, one is a bit deeper and is related to your concern about the core change here. I'll dig into it today. |
So I think that modulo codecov flakiness, this should just leave https://github.com/SciML/ModelingToolkit.jl/actions/runs/8279178750/job/22653091634?pr=2545#step:6:726 failing (unless I just introduced real new problems) |
What is the state of this? |
94cd946
to
834ddcb
Compare
Okay, this is finally working and ready to go. The failing downstream test is unrelated, and also present on other current PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple minor comments. Looks good otherwise. Please also rebase this to remove commits such as retrigger CI
.
fix useage of `h`. update project re-trigger CI clean whitespace don't store self in `values` use `@mtkbuild`
I've rebased it, but you can also just use the |
Closes #2543
cc @AayushSabharwal
It turns out the problem was actually just that we weren't putting symbolic constraints into the
values
dict, it wasn't aboutt
being missing from the initialu0map
(adding that gives the wrong answer actually). I thought I had checked this before but I must have done something else that was breaking alongside it, so this took me way longer to track down than it should have.This has made it so I can now re-enable the
dde.jl
test file which was previously excluded from the test suite.Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.