-
-
Notifications
You must be signed in to change notification settings - Fork 59
Add Symbolics v7 and ModelingToolkit v11 compatibility #571
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
Merged
ChrisRackauckas
merged 3 commits into
SciML:master
from
ChrisRackauckas-Claude:update-symbolics-v7
Dec 16, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Local Difference operator for discrete-time systems | ||
| # This was removed from Symbolics.jl v7, so we define it locally for backwards compatibility | ||
| # See: https://github.com/SciML/DataDrivenDiffEq.jl/issues/563 | ||
|
|
||
| using Symbolics: Operator, value, unwrap, wrap | ||
| using SymbolicUtils: term | ||
|
|
||
| """ | ||
| Difference(t; dt, update=false) | ||
|
|
||
| Represents a difference operator for discrete-time systems. | ||
|
|
||
| # Fields | ||
|
|
||
| - `t`: The independent variable | ||
| - `dt`: The time step | ||
| - `update`: If true, represents a shift/update operator | ||
|
|
||
| # Examples | ||
|
|
||
| ```julia | ||
| @variables t | ||
| d = Difference(t; dt = 0.01) | ||
| ``` | ||
| """ | ||
| struct Difference <: Operator | ||
| t | ||
| dt | ||
| update::Bool | ||
| Difference(t; dt, update = false) = new(value(t), dt, update) | ||
| end | ||
|
|
||
| (D::Difference)(x) = term(D, unwrap(x)) | ||
| (D::Difference)(x::Num) = wrap(D(unwrap(x))) | ||
|
|
||
| # More specific method to avoid ambiguity with SymbolicUtils.Operator method | ||
| SymbolicUtils.promote_symtype(::Difference, ::Type{T}) where {T} = T | ||
|
|
||
| function Base.show(io::IO, D::Difference) | ||
| print(io, "Difference(", D.t, "; dt=", D.dt, ", update=", D.update, ")") | ||
| end | ||
| Base.nameof(::Difference) = :Difference | ||
|
|
||
| function Base.:(==)(D1::Difference, D2::Difference) | ||
| isequal(D1.t, D2.t) && isequal(D1.dt, D2.dt) && isequal(D1.update, D2.update) | ||
| end | ||
| Base.hash(D::Difference, u::UInt) = hash(D.dt, hash(D.t, xor(u, 0x055640d6d952f101))) | ||
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
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
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
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
Oops, something went wrong.
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.
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.
@AayushSabharwal is this the right approach here?
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.
I don't think so.
Differencewas MTK's old way of handling discrete systems. That doesn't work anymore.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.
@ChrisRackauckas have you already released this?
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.
Yes. It doesn't work anymore for MTK but this package needs a representation of it in order to not break.
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.
can it not use the new MTK discrete system interface?
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.
It doesn't even use MTK at all, why would it start?