Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisonGrodin committed Jan 11, 2019
1 parent de20255 commit a1aa2f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ Base.show(io::IO, O::Operation) = print(io, convert(Expr, O))


"""
find_replace(O::Operation,x::Variable,y::Expression)
find_replace(O::Operation, x::Expression, y::Expression)
Finds the variable `x` in Operation `O` and replaces it with the Expression `y`
Finds the expression `x` in Operation `O` and replaces it with the Expression `y`
"""
function find_replace!(O::Operation,x::Variable,y::Expression)
function find_replace!(O::Operation, x::Expression, y::Expression)
for i in eachindex(O.args)
if isequal(O.args[i],x)
if isequal(O.args[i], x)
O.args[i] = y
elseif typeof(O.args[i]) <: Operation
find_replace!(O.args[i],x,y)
Expand Down
2 changes: 1 addition & 1 deletion src/systems/diffeqs/diffeqsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ isintermediate(eq::Equation) = eq.lhs.diff === nothing
function build_equals_expr(eq::Equation)
@assert typeof(eq.lhs) <: Variable

lhs = Symbol("$(eq.lhs.name)")
lhs = eq.lhs.name
isintermediate(eq) || (lhs = Symbol(lhs, :_, "$(eq.lhs.diff.x.name)"))

return :($lhs = $(convert(Expr, eq.rhs)))
Expand Down
2 changes: 1 addition & 1 deletion src/systems/nonlinear/nonlinear_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function generate_nlsys_function(sys::NonlinearSystem)
var_exprs = [:($(sys.vs[i].name) = u[$i]) for i in 1:length(sys.vs)]
param_exprs = [:($(sys.ps[i].name) = p[$i]) for i in 1:length(sys.ps)]
sys_eqs, calc_eqs = partition(eq -> isequal(eq.lhs, Constant(0)), sys.eqs)
calc_exprs = [:($(Symbol("$(eq.lhs.name)")) = $(eq.rhs)) for eq in calc_eqs]
calc_exprs = [:($(eq.lhs.name) = $(eq.rhs)) for eq in calc_eqs if isa(eq.lhs, Variable)]
sys_exprs = [:($(Symbol("resid[$i]")) = $(sys_eqs[i].rhs)) for i in eachindex(sys_eqs)]

exprs = vcat(var_exprs,param_exprs,calc_exprs,sys_exprs)
Expand Down

0 comments on commit a1aa2f2

Please sign in to comment.