-
Notifications
You must be signed in to change notification settings - Fork 156
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
[email protected] broke MTK #1364
[email protected] broke MTK #1364
Comments
After getting rid of my mildly annoyed state by posting this issue, curiosity took over. I don't actually get it, why does the following code behave so differently between an mtk equation and a "pure" equation? 🤔 using Pkg
pkg"activate --temp"
pkg"add [email protected], [email protected]"
using Symbolics, ModelingToolkit
@independent_variables t
@variables x(t) y(t);
get_variables(x ~ y)
# 2-element Vector{SymbolicUtils.BasicSymbolic}:
# x(t)
# y(t)
@mtkmodel Example begin
@variables begin
x(t)
y(t)
end
@equations begin
x ~ y
end
end
@named ex = Example()
get_variables(only(equations(ex)))
# 3-element Vector{SymbolicUtils.BasicSymbolic}:
# x
# t
# y |
I agree these should probably just be two different functions. One of the things the tests didn't catch though is I would've assumed the result was |
MTK needs to change the output. With a callable parameter |
Apparently it never returned |
What about adding the kwarg? |
I believe that it was for a good reason, and I don't mind the breakage. I only mind if it happens in a minor version. Feel free releasing breaking versions of MTK twice a weak if it helps developing the project. However, I don't want to dwell on that; things happen. On the concrete matter, I'd like to understand what the new desired behavior is to fix my code. Looking at the this example again I am getting mixed signals because two very similar calls behave completely different: using Pkg
pkg"activate --temp"
pkg"add [email protected], [email protected]"
using Symbolics, ModelingToolkit
@independent_variables t
@variables x(t) y(t);
get_variables(x ~ y)
# 2-element Vector{SymbolicUtils.BasicSymbolic}:
# x(t)
# y(t)
@mtkmodel Example begin
@variables begin
x(t)
y(t)
end
@equations begin
x ~ y
end
end
@named ex = Example()
get_variables(only(equations(ex)))
# 3-element Vector{SymbolicUtils.BasicSymbolic}:
# x
# t
# y To me, both look kinda broken since I'd expect
empty seems undesirable. PS: @independent_variables t
@variables x(t) y(t);
@named sys = ODESystem([x~y], t, [x, y], [])
get_variables(only(equations(sys)))
# 2-element Vector{SymbolicUtils.BasicSymbolic}:
# x(t)
# y(t) |
Yeah, |
I think so. Though the ability to get |
Turns out changing MTK to not use |
What I described is the opposite of breaking though? |
If we revert to the old behavior, then #1351 is still an issue. If we add a keyword to enable the current behavior and make MTK use it, then it's breaking because the method defined in Catalyst doesn't take that keyword so they'd end up with |
Catalyst should update to add the kwargs. You can do a hasmethod to do backwards compat |
|
julia> using ModelingToolkit, Symbolics
julia> @variables t A(t) B(t)
3-element Vector{Num}:
t
A(t)
B(t)
julia> ex = t*A*B
t*B(t)*A(t)
julia> get_variables(ex)
3-element Vector{SymbolicUtils.BasicSymbolic}:
t
B(t)
A(t)
julia> get_variables(A*B)
2-element Vector{SymbolicUtils.BasicSymbolic}:
A(t)
B(t) allowing one to distinguish an expression that explicitly depends on It should inspect arguments to external functions, i.e. this works julia> f(x,y) = x + y
f (generic function with 1 method)
julia> @register_symbolic f(x,y)
julia> get_variables(A*f(B,t))
3-element Vector{SymbolicUtils.BasicSymbolic}:
A(t)
B(t)
t
julia> get_variables(f(B,A*B))
2-element Vector{SymbolicUtils.BasicSymbolic}:
B(t)
A(t) Changing that convention is breaking at this point. When it was created unbound callable variables were never used as far as I am aware (their use is much more recent, so they weren't a consideration in how it should work). |
That is how it works now, with SciML/ModelingToolkit.jl#3217 |
Great! I just wanted to clarify how it has worked historically since there was a lot of discussion about it not returning |
Is this fixed now? I don't recall the revert on the symbolics side now. |
Symbolics isn't getting a revert, MTK is getting a fix SciML/ModelingToolkit.jl#3217 |
But wouldn't |
We're in a bit of a deadlock basically:
|
If there is a deadlock I would argue for reverting and avoiding having a breaking change in a non-breaking release (which can impact already released versions of downstream dependents that did not anticipate this change). Perhaps #1351 can be fixed without a breaking MTK release by adding a kwarg to the relevant dependency graph functions that takes an alternative to |
And we are happy to update Catalyst to have the needed kwargs / new API function for V15 if an interface is settled for that in the near future. (But then MTK probably needs a breaking release too for that new version.) |
With all that said, if I understand right the merged change should only impact callables declared without fixed arguments initially, which shouldn’t impact Catalyst’s existing releases I think (since we never intentionally use them, and only were generating them accidentally for observables). |
That's a good idea.
Yeah, which we can't do.
Yeah. The only case this impacts is |
I understand that #1351 needed to be fixed. But changing the semantics of an exported function in ModelingToolkit is quite a bad breakage, in my opinion. Well, that ship has sailed, so feel free to just close this issue. But I wanted to post it anyway to raise awareness that a PR was not considered breaking even though it explicitly aimed at changing the output of an exported function for the same input, which is like the definition of breaking.
The text was updated successfully, but these errors were encountered: