Skip to content

Commit

Permalink
Merge pull request #950 from AayushSabharwal/as/format
Browse files Browse the repository at this point in the history
refactor: format
  • Loading branch information
ChrisRackauckas authored Mar 7, 2025
2 parents 23f6936 + a26c52b commit f5b6ba7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/src/interfaces/Problems.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ defaults `Dict(:a => :(2b), :c => 0.1)`. Then:
`3.0` for `:a`, `:b` and `:c` respectively. Note how the explicitly specified value for
`:a` overrides the dependent default.


### Aliasing Specification

An `AbstractAliasSpecifier` is associated with each SciMLProblem type. Each holds fields specifying which variables to alias
when solving. For example, to tell an ODE solver to alias the `u0` array, you can use an `ODEAliases` object,
and the `alias_u0` keyword argument, e.g. `solve(prob,alias = ODEAliases(alias_u0 = true))`.
Expand Down
8 changes: 5 additions & 3 deletions src/problems/problem_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ function Base.summary(io::IO, prob::AbstractDEProblem)
no_color,
". In-place: ", type_color, isinplace(prob), no_color)
init = initialization_status(prob)
!isnothing(init) && begin
!isnothing(init) && begin
println(io)
print(io, "Initialization status: ", type_color, initialization_status(prob), no_color)
print(io, "Initialization status: ", type_color,
initialization_status(prob), no_color)
end

hasproperty(prob.f, :mass_matrix) && begin
println(io)
print(io, "Non-trivial mass matrix: ", type_color, !(prob.f.mass_matrix isa LinearAlgebra.UniformScaling{Bool}), no_color)
print(io, "Non-trivial mass matrix: ", type_color,
!(prob.f.mass_matrix isa LinearAlgebra.UniformScaling{Bool}), no_color)
end
end

Expand Down
6 changes: 4 additions & 2 deletions src/problems/sde_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ function ConstructionBase.constructorof(::Type{P}) where {P <: SDEProblem}
if g !== f.g
f = remake(f; g)
end
return SDEProblem{iip}(f, u0, tspan, p; kw..., noise, noise_rate_prototype, seed)
return SDEProblem{iip}(
f, u0, tspan, p; kw..., noise, noise_rate_prototype, seed)
else
iip = isinplace(f, 4)
return SDEProblem{iip}(f, g, u0, tspan, p; kw..., noise, noise_rate_prototype, seed)
return SDEProblem{iip}(
f, g, u0, tspan, p; kw..., noise, noise_rate_prototype, seed)
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions src/solutions/save_idxs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function as_diffeq_array(vt::Vector{VectorTemplate}, t)
end

function get_root_indp(indp)
if hasmethod(symbolic_container, Tuple{typeof(indp)}) && (sc = symbolic_container(indp)) !== indp
if hasmethod(symbolic_container, Tuple{typeof(indp)}) &&
(sc = symbolic_container(indp)) !== indp
return get_root_indp(sc)
end
return indp
Expand Down Expand Up @@ -125,7 +126,8 @@ function SavedSubsystem(indp, pobj, saved_idxs::Union{AbstractArray, Tuple})
end
if eltype(saved_idxs) == Int
state_map = Dict{Int, Int}(v => k for (k, v) in enumerate(saved_idxs))
return SavedSubsystem(state_map, nothing, nothing, nothing, nothing, nothing, nothing)
return SavedSubsystem(
state_map, nothing, nothing, nothing, nothing, nothing, nothing)
end

# array state symbolics must be scalarized
Expand Down
4 changes: 2 additions & 2 deletions test/downstream/modelingtoolkit_remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ k = ShiftIndex(t)
discprob = DiscreteProblem(discsys, [], (0, 10), p)
for (var, v) in u0
discprob[var] = v
discprob[var(k-1)] = 0.0
discprob[var(k - 1)] = 0.0
end
push!(syss, discsys)
push!(probs, discprob)
Expand Down Expand Up @@ -268,7 +268,7 @@ end
newval = ModelingToolkit.fixpoint_sub(sym, varmap; maxiters = 10)
vs = ModelingToolkit.vars(newval)
if !isempty(vars) && any(in(Set(vars)), vs)
NotSymbolic()
NotSymbolic()
return true
end
end
Expand Down

0 comments on commit f5b6ba7

Please sign in to comment.