Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Dec 13, 2023
1 parent 85a3bd5 commit 7b8b266
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
16 changes: 11 additions & 5 deletions src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,14 @@ function SymbolicIndexingInterface.is_variable(sys::AbstractSystem, sym)
if unwrap(sym) isa Int # [x, 1] coerces 1 to a Num
return unwrap(sym) in 1:length(unknown_states(sys))

Check warning on line 188 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L186-L188

Added lines #L186 - L188 were not covered by tests
end
return any(isequal(sym), unknown_states(sys)) || hasname(sym) && is_variable(sys, getname(sym))
return any(isequal(sym), unknown_states(sys)) ||

Check warning on line 190 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L190

Added line #L190 was not covered by tests
hasname(sym) && is_variable(sys, getname(sym))
end

function SymbolicIndexingInterface.is_variable(sys::AbstractSystem, sym::Symbol)
return any(isequal(sym), getname.(unknown_states(sys))) || count('', string(sym)) == 1 && count(isequal(sym), Symbol.(sys.name, :₊, getname.(unknown_states(sys)))) == 1
return any(isequal(sym), getname.(unknown_states(sys))) ||

Check warning on line 195 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L194-L195

Added lines #L194 - L195 were not covered by tests
count('', string(sym)) == 1 &&
count(isequal(sym), Symbol.(sys.name, :₊, getname.(unknown_states(sys)))) == 1
end

function SymbolicIndexingInterface.variable_index(sys::AbstractSystem, sym)
Expand Down Expand Up @@ -224,12 +227,14 @@ function SymbolicIndexingInterface.is_parameter(sys::AbstractSystem, sym)
return unwrap(sym) in 1:length(parameters(sys))

Check warning on line 227 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L225-L227

Added lines #L225 - L227 were not covered by tests
end

return any(isequal(sym), parameters(sys)) || hasname(sym) && is_parameter(sys, getname(sym))
return any(isequal(sym), parameters(sys)) ||

Check warning on line 230 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L230

Added line #L230 was not covered by tests
hasname(sym) && is_parameter(sys, getname(sym))
end

function SymbolicIndexingInterface.is_parameter(sys::AbstractSystem, sym::Symbol)
return any(isequal(sym), getname.(parameters(sys))) ||

Check warning on line 235 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L234-L235

Added lines #L234 - L235 were not covered by tests
count('', string(sym)) == 1 && count(isequal(sym), Symbol.(sys.name, :₊, getname.(parameters(sys)))) == 1
count('', string(sym)) == 1 &&
count(isequal(sym), Symbol.(sys.name, :₊, getname.(parameters(sys)))) == 1
end

function SymbolicIndexingInterface.parameter_index(sys::AbstractSystem, sym)
Expand Down Expand Up @@ -270,7 +275,8 @@ function SymbolicIndexingInterface.independent_variable_symbols(sys::AbstractSys
end

function SymbolicIndexingInterface.is_observed(sys::AbstractSystem, sym)
return !is_variable(sys, sym) && !is_parameter(sys, sym) && !is_independent_variable(sys, sym) && symbolic_type(sym) != NotSymbolic()
return !is_variable(sys, sym) && !is_parameter(sys, sym) &&

Check warning on line 278 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L277-L278

Added lines #L277 - L278 were not covered by tests
!is_independent_variable(sys, sym) && symbolic_type(sym) != NotSymbolic()
end

SymbolicIndexingInterface.is_time_dependent(::AbstractTimeDependentSystem) = true
Expand Down
2 changes: 1 addition & 1 deletion src/systems/jumps/jumpsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ function (ratemap::JumpSysMajParamMapper{
U,
V,
W,
})(params) where {U <: AbstractArray,
})(params) where {U <: AbstractArray,
V <: AbstractArray, W}
updateparams!(ratemap, params)
[convert(W, value(substitute(paramexpr, ratemap.subdict)))
Expand Down
2 changes: 1 addition & 1 deletion src/systems/nonlinear/initializesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ function initializesystem(sys::ODESystem; name = nameof(sys), kwargs...)
kwargs...)

return sys_nl
end
end
2 changes: 1 addition & 1 deletion src/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,4 @@ function get_default_or_guess(x)
else
return getguess(x)
end
end
end
4 changes: 2 additions & 2 deletions test/nonlinearsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ end
@testset "Initialization System" begin
# Define the Lotka Volterra system which begins at steady state
@parameters t
pars = @parameters a=1.5 b=1.0 c=3.0 d=1.0 dx_ss = 1e-5
pars = @parameters a=1.5 b=1.0 c=3.0 d=1.0 dx_ss=1e-5

vars = @variables begin
dx(t),
Expand Down Expand Up @@ -274,4 +274,4 @@ end

# Confirm for all the states of the simplified system
@test all(.≈(sol[states(sys_simple)], [1e-5 / 1.5, 0]; atol = 1e-8))
end
end

0 comments on commit 7b8b266

Please sign in to comment.