Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP] refactor: update to SymbolicUtils@4 and Symbolics@7#3953

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
AayushSabharwal wants to merge157 commits intomaster
base:master
Choose a base branch
Loading
fromas/su-v4

Conversation

@AayushSabharwal
Copy link
Member

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular theSciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

Copy link
Contributor

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

JuliaFormatter

[JuliaFormatter]reported byreviewdog 🐶

SymbolicUtils.promote_symtype(::typeof(instream_rt),::Type{T},::Type{S},::Type{R})where {T, S, R}= Real


[JuliaFormatter]reported byreviewdog 🐶


[JuliaFormatter]reported byreviewdog 🐶

const MaybeArrayIndexT= Union{Int, UnitRange{Int}, Base.ReshapedArray{Int, N, UnitRange{Int}}where {N}}


[JuliaFormatter]reported byreviewdog 🐶

parse_callbacks_for_discretes!(cevs, disc_param_callbacks, constant_buffers, nonnumeric_buffers,0)
parse_callbacks_for_discretes!(devs, disc_param_callbacks, constant_buffers, nonnumeric_buffers,length(cevs))


[JuliaFormatter]reported byreviewdog 🐶

push!(disc_syms_by_symtype_by_partition[i],filter(==(partition) Base.Fix1(getindex, disc_param_callbacks), buffer))


[JuliaFormatter]reported byreviewdog 🐶

push!(disc_buffer_templates,map(Base.Fix1(BufferTemplate, symtype) length, disc_syms_by_partition))


[JuliaFormatter]reported byreviewdog 🐶

BSImpl.Term(; f, args)=>begin
f=== getindex&& (idx=get(disc_idxs, args[1],nothing))!==nothing
end
_=>false


[JuliaFormatter]reported byreviewdog 🐶

functionparse_callbacks_for_discretes!(events::Vector, disc_param_callbacks::Dict{SymbolicT, BitSet}, constant_buffers::Dict{TypeT, Set{SymbolicT}}, nonnumeric_buffers::Dict{TypeT, Set{SymbolicT}}, offset::Int)


[JuliaFormatter]reported byreviewdog 🐶

function SymbolicIndexingInterface.parameter_index(ic::IndexCache, sym::Union{Num, Symbolics.Arr, Symbolics.CallAndWrap})


[JuliaFormatter]reported byreviewdog 🐶

functioncheck_index_map(idxmap::Dict{SymbolicT, V}, sym::SymbolicT)::Union{V, Nothing}where {V}


[JuliaFormatter]reported byreviewdog 🐶

mask[i]=!iscall(eq.rhs)||operation(eq.rhs)!== StructuralTransformations.change_origin


[JuliaFormatter]reported byreviewdog 🐶

if (checksisa Bool&& checks===true|| checksisa Int&& (checks& CheckComponents)>0)&& iv!==nothing


[JuliaFormatter]reported byreviewdog 🐶


[JuliaFormatter]reported byreviewdog 🐶

fullvars[i], discmap; filterer= Symbolics.FPSubFilterer{Union{Sample, Hold, Pre}}()))


[JuliaFormatter]reported byreviewdog 🐶

issym(op)&&returnSSym(nameof(op); type= FnType{Tuple{symtype(iv)}, Real}, shape= SU.ShapeVecT())(iv)


[JuliaFormatter]reported byreviewdog 🐶

BSImpl.Term(; f)&&if fisa Differentialend=>begin


[JuliaFormatter]reported byreviewdog 🐶

functionprocess_variables!(var_to_name::Dict{Symbol, SymbolicT}, defs::SymmapT, guesses::SymmapT, vars::Vector{SymbolicT})


[JuliaFormatter]reported byreviewdog 🐶

BSImpl.Term(; f, args)&&if f=== getindexend=> args[1]


[JuliaFormatter]reported byreviewdog 🐶

hasmetadata(x, VariableSource)||iscall(x)&&operation(x)=== getindex&&isvariable(arguments(x)[1])::Bool


[JuliaFormatter]reported byreviewdog 🐶

functioncollect_scoped_vars!(unknowns::OrderedSet{SymbolicT}, parameters::OrderedSet{SymbolicT}, sys::AbstractSystem, iv::Union{SymbolicT, Nothing}; depth=1, op= Differential)


[JuliaFormatter]reported byreviewdog 🐶

BSImpl.Term(; f)&&if fisa Oend=>true


[JuliaFormatter]reported byreviewdog 🐶

BSImpl.Term(; f)&&if fisa Operatorend=> fisa O


[JuliaFormatter]reported byreviewdog 🐶

functioncollect_vars!(unknowns::OrderedSet{SymbolicT}, parameters::OrderedSet{SymbolicT}, expr::SymbolicT, iv::Union{SymbolicT, Nothing}; depth=0, op= Symbolics.Operator)


[JuliaFormatter]reported byreviewdog 🐶

functioncollect_vars!(unknowns::OrderedSet{SymbolicT}, parameters::OrderedSet{SymbolicT}, expr::AbstractArray{SymbolicT}, iv::Union{SymbolicT, Nothing}; depth=0, op= Symbolics.Operator)


[JuliaFormatter]reported byreviewdog 🐶

check_scope_depth(getmetadata(var, SymScope,LocalScope())::AllScopes, depth)||returnnothing


[JuliaFormatter]reported byreviewdog 🐶

iscall(x)&&operation(x)=== getindex&&returnsafe_getmetadata(m,arguments(x)[1], default)


[JuliaFormatter]reported byreviewdog 🐶

BSImpl.Term(; f, args, shape, type, metadata)&&if fisa Operatorend=>begin


[JuliaFormatter]reported byreviewdog 🐶

getunshifted(x::SymbolicT)= Symbolics.getmetadata(x, VariableUnshifted,nothing)::Union{SymbolicT, Nothing}

Comment on lines +361 to +453
fold1=Val{false}()
using SymbolicUtils
using SymbolicUtils: shape
using Symbolics
@syms x yf(t) q[1:5]
SymbolicUtils.Sym{SymReal}(:a; type= Real, shape= SymbolicUtils.ShapeVecT())
x+ y
x* y
x/ y
x^ y
x^5
6^ x
x- y
-y
2y
z=2
dict= SymbolicUtils.ACDict{VartypeT}()
dict[x]=1
dict[y]=1
type::typeof(DataType)=rand()<0.5? Real: Float64
nt= (; type, shape, unsafe=true)
Base.pairs(nt)
BSImpl.AddMul{VartypeT}(1, dict, SymbolicUtils.AddMulVariant.MUL; type, shape= SymbolicUtils.ShapeVecT(), unsafe=true)
*(y, z)
*(z, y)
SymbolicUtils.symtype(y)
f(x)
(5x/5)
expand((x+ y)^2)
simplify(x^ (1//2)+ (sin(x)^2+cos(x)^2)+2(x+ y)- x- y)
ex= x+2y+sin(x)
rules1=Dict(x=> y)
rules2=Dict(x=>1)
Dx=Differential(x)
Differential(y)(ex)
uex=unwrap(ex)
Symbolics.executediff(Dx, uex)
# Running `fold = Val(true)` invalidates the precompiled statements
# for `fold = Val(false)` and itself doesn't precompile anyway.
# substitute(ex, rules1)
substitute(ex, rules1; fold= fold1)
substitute(ex, rules2; fold= fold1)
@variables foo
f(foo)
@variables x yf(::Real) q[1:5]
x+ y
x* y
x/ y
x^ y
x^5
# 6 ^ x
x- y
-y
2y
symtype(y)
z=2
*(y, z)
*(z, y)
f(x)
(5x/5)
[x, y]
[x, f, f]
promote_type(Int, Num)
promote_type(Real, Num)
promote_type(Float64, Num)
# expand((x + y) ^ 2)
# simplify(x ^ (1//2) + (sin(x) ^ 2 + cos(x) ^ 2) + 2(x + y) - x - y)
ex= x+2y+sin(x)
rules1=Dict(x=> y)
# rules2 = Dict(x => 1)
# Running `fold = Val(true)` invalidates the precompiled statements
# for `fold = Val(false)` and itself doesn't precompile anyway.
# substitute(ex, rules1)
substitute(ex, rules1; fold= fold1)
Symbolics.linear_expansion(ex, y)
# substitute(ex, rules2; fold = fold1)
# substitute(ex, rules2)
# substitute(ex, rules1; fold = fold2)
# substitute(ex, rules2; fold = fold2)
q[1]
q'q
using ModelingToolkit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change
fold1=Val{false}()
using SymbolicUtils
using SymbolicUtils: shape
using Symbolics
@syms x yf(t) q[1:5]
SymbolicUtils.Sym{SymReal}(:a; type= Real, shape= SymbolicUtils.ShapeVecT())
x+ y
x* y
x/ y
x^ y
x^5
6^ x
x- y
-y
2y
z=2
dict= SymbolicUtils.ACDict{VartypeT}()
dict[x]=1
dict[y]=1
type::typeof(DataType)=rand()<0.5? Real: Float64
nt= (; type, shape, unsafe=true)
Base.pairs(nt)
BSImpl.AddMul{VartypeT}(1, dict, SymbolicUtils.AddMulVariant.MUL; type, shape= SymbolicUtils.ShapeVecT(), unsafe=true)
*(y, z)
*(z, y)
SymbolicUtils.symtype(y)
f(x)
(5x/5)
expand((x+ y)^2)
simplify(x^ (1//2)+ (sin(x)^2+cos(x)^2)+2(x+ y)- x- y)
ex= x+2y+sin(x)
rules1=Dict(x=> y)
rules2=Dict(x=>1)
Dx=Differential(x)
Differential(y)(ex)
uex=unwrap(ex)
Symbolics.executediff(Dx, uex)
# Running `fold = Val(true)` invalidates the precompiled statements
# for `fold = Val(false)` and itself doesn't precompile anyway.
# substitute(ex, rules1)
substitute(ex, rules1; fold= fold1)
substitute(ex, rules2; fold= fold1)
@variables foo
f(foo)
@variables x yf(::Real) q[1:5]
x+ y
x* y
x/ y
x^ y
x^5
# 6 ^ x
x- y
-y
2y
symtype(y)
z=2
*(y, z)
*(z, y)
f(x)
(5x/5)
[x, y]
[x, f, f]
promote_type(Int, Num)
promote_type(Real, Num)
promote_type(Float64, Num)
# expand((x + y) ^ 2)
# simplify(x ^ (1//2) + (sin(x) ^ 2 + cos(x) ^ 2) + 2(x + y) - x - y)
ex= x+2y+sin(x)
rules1=Dict(x=> y)
# rules2 = Dict(x => 1)
# Running `fold = Val(true)` invalidates the precompiled statements
# for `fold = Val(false)` and itself doesn't precompile anyway.
# substitute(ex, rules1)
substitute(ex, rules1; fold= fold1)
Symbolics.linear_expansion(ex, y)
# substitute(ex, rules2; fold = fold1)
# substitute(ex, rules2)
# substitute(ex, rules1; fold = fold2)
# substitute(ex, rules2; fold = fold2)
q[1]
q'q
using ModelingToolkit
fold1=Val{false}()
using SymbolicUtils
using SymbolicUtils: shape
using Symbolics
@syms x yf(t) q[1:5]
SymbolicUtils.Sym{SymReal}(:a; type= Real, shape= SymbolicUtils.ShapeVecT())
x+ y
x* y
x/ y
x^ y
x^5
6^ x
x- y
-y
2y
z=2
dict= SymbolicUtils.ACDict{VartypeT}()
dict[x]=1
dict[y]=1
type::typeof(DataType)=rand()<0.5? Real: Float64
nt= (; type, shape, unsafe=true)
Base.pairs(nt)
BSImpl.AddMul{VartypeT}(1, dict, SymbolicUtils.AddMulVariant.MUL; type,
shape= SymbolicUtils.ShapeVecT(), unsafe=true)
*(y, z)
*(z, y)
SymbolicUtils.symtype(y)
f(x)
(5x/5)
expand((x+ y)^2)
simplify(x^ (1//2)+ (sin(x)^2+cos(x)^2)+2(x+ y)- x- y)
ex= x+2y+sin(x)
rules1=Dict(x=> y)
rules2=Dict(x=>1)
Dx=Differential(x)
Differential(y)(ex)
uex=unwrap(ex)
Symbolics.executediff(Dx, uex)
# Running `fold = Val(true)` invalidates the precompiled statements
# for `fold = Val(false)` and itself doesn't precompile anyway.
# substitute(ex, rules1)
substitute(ex, rules1; fold= fold1)
substitute(ex, rules2; fold= fold1)
@variables foo
f(foo)
@variables x yf(::Real) q[1:5]
x+ y
x* y
x/ y
x^ y
x^5
# 6 ^ x
x- y
-y
2y
symtype(y)
z=2
*(y, z)
*(z, y)
f(x)
(5x/5)
[x, y]
[x, f, f]
promote_type(Int, Num)
promote_type(Real, Num)
promote_type(Float64, Num)
# expand((x + y) ^ 2)
# simplify(x ^ (1//2) + (sin(x) ^ 2 + cos(x) ^ 2) + 2(x + y) - x - y)
ex= x+2y+sin(x)
rules1=Dict(x=> y)
# rules2 = Dict(x => 1)
# Running `fold = Val(true)` invalidates the precompiled statements
# for `fold = Val(false)` and itself doesn't precompile anyway.
# substitute(ex, rules1)
substitute(ex, rules1; fold= fold1)
Symbolics.linear_expansion(ex, y)
# substitute(ex, rules2; fold = fold1)
# substitute(ex, rules2)
# substitute(ex, rules1; fold = fold2)
# substitute(ex, rules2; fold = fold2)
q[1]
q'q
using ModelingToolkit

@named sys=System([ModelingToolkit.D_nounits(x)~-x], ModelingToolkit.t_nounits)
prob=ODEProblem(mtkcompile(sys), [x=>30.0], (0,100), jac=true)
isequal(ModelingToolkit.D_nounits.x, ModelingToolkit.t_nounits)
sys=System([ModelingToolkit.D_nounits(x)~ x], ModelingToolkit.t_nounits, [x], Num[]; name=:sys)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change
sys=System([ModelingToolkit.D_nounits(x)~ x], ModelingToolkit.t_nounits, [x], Num[]; name=:sys)
sys=System([ModelingToolkit.D_nounits(x)~ x],
ModelingToolkit.t_nounits, [x], Num[]; name=:sys)

Comment on lines +485 to +500
precompile(Tuple{typeof(Base.merge), NamedTuple{(:f,:args,:metadata,:hash,:hash2,:shape,:type,:id), Tuple{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, SymbolicUtils.SmallVec{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, Array{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},1}}, Nothing, UInt64, UInt64, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}, DataType, SymbolicUtils.IDType}}, NamedTuple{(:metadata,), Tuple{Base.ImmutableDict{DataType, Any}}}})
precompile(Tuple{typeof(Base.merge), NamedTuple{(:f,:args,:metadata,:hash,:hash2,:shape,:type,:id), Tuple{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, SymbolicUtils.SmallVec{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, Array{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},1}}, Base.ImmutableDict{DataType, Any}, UInt64, UInt64, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}, DataType, SymbolicUtils.IDType}}, NamedTuple{(:id,:hash,:hash2), Tuple{Nothing, Int64, Int64}}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:f,:args,:metadata,:hash,:hash2,:shape,:type,:id), Tuple{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, SymbolicUtils.SmallVec{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, Array{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},1}}, Base.ImmutableDict{DataType, Any}, Int64, Int64, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}, DataType, Nothing}}, Type{SymbolicUtils.BasicSymbolicImpl.Term{SymbolicUtils.SymReal}}})
precompile(Tuple{typeof(Symbolics.parse_vars), Symbol, Type, Tuple{Symbol, Symbol}, Function})
precompile(Tuple{typeof(Base.merge), NamedTuple{(:name,:metadata,:hash,:hash2,:shape,:type,:id), Tuple{Symbol, Base.ImmutableDict{DataType, Any}, UInt64, UInt64, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}, DataType, SymbolicUtils.IDType}}, NamedTuple{(:metadata,), Tuple{Base.ImmutableDict{DataType, Any}}}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change
precompile(Tuple{typeof(Base.merge), NamedTuple{(:f,:args,:metadata,:hash,:hash2,:shape,:type,:id), Tuple{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, SymbolicUtils.SmallVec{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, Array{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},1}}, Nothing, UInt64, UInt64, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}, DataType, SymbolicUtils.IDType}}, NamedTuple{(:metadata,), Tuple{Base.ImmutableDict{DataType, Any}}}})
precompile(Tuple{typeof(Base.merge), NamedTuple{(:f,:args,:metadata,:hash,:hash2,:shape,:type,:id), Tuple{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, SymbolicUtils.SmallVec{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, Array{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},1}}, Base.ImmutableDict{DataType, Any}, UInt64, UInt64, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}, DataType, SymbolicUtils.IDType}}, NamedTuple{(:id,:hash,:hash2), Tuple{Nothing, Int64, Int64}}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:f,:args,:metadata,:hash,:hash2,:shape,:type,:id), Tuple{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, SymbolicUtils.SmallVec{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, Array{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},1}}, Base.ImmutableDict{DataType, Any}, Int64, Int64, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}, DataType, Nothing}}, Type{SymbolicUtils.BasicSymbolicImpl.Term{SymbolicUtils.SymReal}}})
precompile(Tuple{typeof(Symbolics.parse_vars), Symbol, Type, Tuple{Symbol, Symbol}, Function})
precompile(Tuple{typeof(Base.merge), NamedTuple{(:name,:metadata,:hash,:hash2,:shape,:type,:id), Tuple{Symbol, Base.ImmutableDict{DataType, Any}, UInt64, UInt64, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}, DataType, SymbolicUtils.IDType}}, NamedTuple{(:metadata,), Tuple{Base.ImmutableDict{DataType, Any}}}})
precompile(Tuple{typeof(Base.merge),
NamedTuple{(:f,:args,:metadata,:hash,:hash2,:shape,:type,:id),
Tuple{
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},
SymbolicUtils.SmallVec{
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},
Array{
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},
1}},
Nothing,
UInt64,
UInt64,
SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}},
DataType,
SymbolicUtils.IDType}},
NamedTuple{(:metadata,), Tuple{Base.ImmutableDict{DataType, Any}}}})
precompile(Tuple{typeof(Base.merge),
NamedTuple{(:f,:args,:metadata,:hash,:hash2,:shape,:type,:id),
Tuple{
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},
SymbolicUtils.SmallVec{
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},
Array{
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},
1}},
Base.ImmutableDict{DataType, Any},
UInt64,
UInt64,
SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}},
DataType,
SymbolicUtils.IDType}},
NamedTuple{(:id,:hash,:hash2), Tuple{Nothing, Int64, Int64}}})
precompile(Tuple{typeof(Core.kwcall),
NamedTuple{(:f,:args,:metadata,:hash,:hash2,:shape,:type,:id),
Tuple{
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},
SymbolicUtils.SmallVec{
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},
Array{
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal},
1}},
Base.ImmutableDict{DataType, Any},
Int64,
Int64,
SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}},
DataType,
Nothing}},
Type{SymbolicUtils.BasicSymbolicImpl.Term{SymbolicUtils.SymReal}}})
precompile(Tuple{
typeof(Symbolics.parse_vars), Symbol, Type, Tuple{Symbol, Symbol}, Function})
precompile(Tuple{typeof(Base.merge),
NamedTuple{(:name,:metadata,:hash,:hash2,:shape,:type,:id),
Tuple{Symbol, Base.ImmutableDict{DataType, Any}, UInt64, UInt64,
SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}},
DataType, SymbolicUtils.IDType}},
NamedTuple{(:metadata,), Tuple{Base.ImmutableDict{DataType, Any}}}})

Comment on lines +491 to +503
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:name,:defaults), Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}}}, Type{ModelingToolkit.System}, Array{Symbolics.Equation,1}, Symbolics.Num, Array{Symbolics.Num,1}, Array{Symbolics.Num,1}})
precompile(Tuple{Type{NamedTuple{(:name,:defaults), T}where T<:Tuple}, Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:name,:defaults), Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}}}, Type{ModelingToolkit.System}, Array{Symbolics.Equation,1}, Symbolics.Num, Array{Symbolics.Num,1}, Array{Symbolics.Num,1}})
precompile(Tuple{Type{NamedTuple{(:name,:defaults), T}where T<:Tuple}, Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}}})
precompile(Tuple{typeof(Core.kwcall),
NamedTuple{(:name,:defaults), Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}}},
Type{ModelingToolkit.System}, Array{Symbolics.Equation,1},
Symbolics.Num, Array{Symbolics.Num,1}, Array{Symbolics.Num,1}})
precompile(Tuple{Type{NamedTuple{(:name,:defaults), T}where T<:Tuple},
Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}}})

Comment on lines +494 to +507
precompile(Tuple{Type{NamedTuple{(:name,:defaults,:guesses), T}where T<:Tuple}, Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}, Base.Dict{Symbolics.Num, Float64}}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:name,:defaults,:guesses), Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}, Base.Dict{Symbolics.Num, Float64}}}, Type{ModelingToolkit.System}, Array{Symbolics.Equation,1}, Symbolics.Num, Array{Symbolics.Num,1}, Array{Symbolics.Num,1}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:type,:shape), Tuple{DataType, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}}},typeof(SymbolicUtils.term), Any, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change
precompile(Tuple{Type{NamedTuple{(:name,:defaults,:guesses), T}where T<:Tuple}, Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}, Base.Dict{Symbolics.Num, Float64}}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:name,:defaults,:guesses), Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}, Base.Dict{Symbolics.Num, Float64}}}, Type{ModelingToolkit.System}, Array{Symbolics.Equation,1}, Symbolics.Num, Array{Symbolics.Num,1}, Array{Symbolics.Num,1}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:type,:shape), Tuple{DataType, SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}}},typeof(SymbolicUtils.term), Any, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}})
precompile(Tuple{Type{NamedTuple{(:name,:defaults,:guesses), T}where T<:Tuple},
Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}, Base.Dict{Symbolics.Num, Float64}}})
precompile(Tuple{typeof(Core.kwcall),
NamedTuple{(:name,:defaults,:guesses),
Tuple{Symbol, Base.Dict{Symbolics.Num, Float64}, Base.Dict{Symbolics.Num, Float64}}},
Type{ModelingToolkit.System},
Array{Symbolics.Equation,1},
Symbolics.Num,
Array{Symbolics.Num,1},
Array{Symbolics.Num,1}})
precompile(Tuple{typeof(Core.kwcall),
NamedTuple{(:type,:shape),
Tuple{DataType,
SymbolicUtils.SmallVec{Base.UnitRange{Int64}, Array{Base.UnitRange{Int64},1}}}},
typeof(SymbolicUtils.term),
Any,
SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}})

term=namespace_expr(term, sys, n; ivs)
end
expr=namespace_expr(expr, sys, n; ivs)
return BSImpl.ArrayOp{VartypeT}(output_idx, expr, reduce, term, ranges; type, shape, metadata)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change
return BSImpl.ArrayOp{VartypeT}(output_idx, expr, reduce, term, ranges; type, shape, metadata)
return BSImpl.ArrayOp{VartypeT}(
output_idx, expr, reduce, term, ranges; type, shape, metadata)

for (i, eq)inenumerate(eqs)
empty!(varsbuf)
vars!(varsbuf, eq;op= Union{Differential, Initial, Pre})
SU.search_variables!(varsbuf, eq;is_atomic=OperatorIsAtomic{Union{Differential, Initial, Pre}}())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change
SU.search_variables!(varsbuf, eq; is_atomic=OperatorIsAtomic{Union{Differential, Initial, Pre}}())
SU.search_variables!(varsbuf, eq; is_atomic= OperatorIsAtomic{Union{
Differential, Initial, Pre}}())

end

functionobserved2graph(eqs, unknowns)
functionobserved2graph(eqs::Vector{Equation}, unknowns::Vector{SymbolicT})::Tuple{BipartiteGraph{Int, Nothing}, Vector{Int}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change
functionobserved2graph(eqs::Vector{Equation}, unknowns::Vector{SymbolicT})::Tuple{BipartiteGraph{Int, Nothing}, Vector{Int}}
functionobserved2graph(eqs::Vector{Equation},
unknowns::Vector{SymbolicT})::Tuple{BipartiteGraph{Int, Nothing}, Vector{Int}}

@set! sys.unknowns=s(get_unknowns(sys))
@set! sys.ps=s(get_ps(sys))
AffectSystem(sys,s(aff.unknowns),s(aff.parameters),s(aff.discretes))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change

"""
const DDE_HISTORY_FUN=Sym{Symbolics.FnType{Tuple{Any, <:Real}, Vector{Real}}}(:___history___)
const BVP_SOLUTION=Sym{Symbolics.FnType{Tuple{<:Real}, Vector{Real}}}(:__sol__)
const DDE_HISTORY_FUN=SSym(:___history___; type= SU.FnType{Tuple{Any,<:Real}, Vector{Real}}, shape= SU.Unknown(1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[JuliaFormatter]reported byreviewdog 🐶

Suggested change
const DDE_HISTORY_FUN=SSym(:___history___; type= SU.FnType{Tuple{Any,<:Real}, Vector{Real}}, shape= SU.Unknown(1))
const DDE_HISTORY_FUN=SSym(
:___history___; type= SU.FnType{Tuple{Any,<:Real}, Vector{Real}}, shape= SU.Unknown(1))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

How are you now supporting a list of variables from which any collected variables must be members? That seems dropped in this new version of these functions.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Symbolics.get_variables does this, and is a wrapper overSymbolicUtils.search_variables! with the appropriate filter function. Now this is a common API forany sort of filter you might want to apply to the collected variables.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

So that is whatis_atomic does? (Just because from the name is unclear to me what it means.)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes. I'm working on improving docs in SymbolicUtils for all of the new stuff.is_atomic takes an expression and returns a boolean identifying whether the expression should be considered "atomic" and included in the list of variables. The function should probably be namedfind_atomics but now that requires amassive find-and-replace.

Copy link
MemberAuthor

@AayushSabharwalAayushSabharwalOct 14, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This isn't to say Iwon't do the renaming, but rather that I might wait a bit to get things working first.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sounds good! I just wanted to check the filtering wasn’t being inadvertently lost for MassActionJump stoichiometric species.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@isaacsasisaacsasisaacsas left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@AayushSabharwal@isaacsas

[8]ページ先頭

©2009-2025 Movatter.jp