diff --git a/src/build_function.jl b/src/build_function.jl index b19b9ca043..946226d3cd 100644 --- a/src/build_function.jl +++ b/src/build_function.jl @@ -207,7 +207,7 @@ function _build_function(target::JuliaTarget, rhss::AbstractArray, args...; end out = Sym{Any}(gensym("out")) - ip_expr = Func([out, dargs...], [], _set_array(out, outputidxs, rhss, skipzeros)) + ip_expr = Func([out, dargs...], [], _set_array(out, outputidxs, rhss, checkbounds, skipzeros)) if !isnothing(wrap_code[2]) ip_expr = wrap_code[2](ip_expr) @@ -231,18 +231,18 @@ function _make_array(rhss::AbstractSparseArray, similarto) end ## In-place version -function _set_array(out, outputidxs, rhss::AbstractArray, skipzeros) +function _set_array(out, outputidxs, rhss::AbstractArray, checkbounds, skipzeros) if rhss isa Union{SparseVector, SparseMatrixCSC} - return SetArray(false, LiteralExpr(:($out.nzval)), rhss.nzval) - elseif isnothing(outputidxs) + return SetArray(checkbounds, LiteralExpr(:($out.nzval)), rhss.nzval) + elseif outputidxs === nothing outputidxs = collect(eachindex(rhss)) end # sometimes outputidxs is a Tuple - ii = findall(i->!(rhss[i] isa AbstractArray) && !(skipzeros && iszero(rhss[i])), outputidxs) - jj = findall(i->rhss[i] isa AbstractArray, outputidxs) + ii = findall(i->!(rhss[i] isa AbstractArray) && !(skipzeros && _iszero(rhss[i])), eachindex(outputidxs)) + jj = findall(i->rhss[i] isa AbstractArray, eachindex(outputidxs)) exprs = [] - push!(exprs, SetArray(false, out, AtIndex.(vec(collect(outputidxs[ii])), vec(rhss[ii])))) + push!(exprs, SetArray(checkbounds, out, AtIndex.(vec(collect(outputidxs[ii])), vec(rhss[ii])))) for j in jj push!(exprs, _set_array(LiteralExpr(:($out[$j])), nothing, rhss[j], skipzeros)) end @@ -251,7 +251,7 @@ function _set_array(out, outputidxs, rhss::AbstractArray, skipzeros) end) end -_set_array(out, outputidxs, rhs, skipzeros) = rhs +_set_array(out, outputidxs, rhs, checkbounds, skipzeros) = rhs function _make_array(rhss::AbstractArray, similarto) diff --git a/test/runtests.jl b/test/runtests.jl index 45ebea3490..8be142e333 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,33 +1,33 @@ using SafeTestsets, Test -# @safetestset "Parsing Test" begin include("variable_parsing.jl") end -# @safetestset "Differentiation Test" begin include("derivatives.jl") end -# @safetestset "Simplify Test" begin include("simplify.jl") end -# @safetestset "Operation Overloads Test" begin include("operation_overloads.jl") end -# @safetestset "Direct Usage Test" begin include("direct.jl") end -# @safetestset "System Linearity Test" begin include("linearity.jl") end -# @safetestset "Build Function Test" begin include("build_function.jl") end -# @safetestset "ODESystem Test" begin include("odesystem.jl") end -# @safetestset "LabelledArrays Test" begin include("labelledarrays.jl") end -# @safetestset "Mass Matrix Test" begin include("mass_matrix.jl") end -# @safetestset "SteadyStateSystem Test" begin include("steadystatesystems.jl") end -# @safetestset "SDESystem Test" begin include("sdesystem.jl") end -# @safetestset "NonlinearSystem Test" begin include("nonlinearsystem.jl") end -# @safetestset "OptimizationSystem Test" begin include("optimizationsystem.jl") end -# @safetestset "ReactionSystem Test" begin include("reactionsystem.jl") end -# @safetestset "JumpSystem Test" begin include("jumpsystem.jl") end -# @safetestset "ControlSystem Test" begin include("controlsystem.jl") end -# @safetestset "Build Targets Test" begin include("build_targets.jl") end -# @safetestset "Domain Test" begin include("domains.jl") end -# @safetestset "Modelingtoolkitize Test" begin include("modelingtoolkitize.jl") end -# @safetestset "Constraints Test" begin include("constraints.jl") end -# @safetestset "Reduction Test" begin include("reduction.jl") end -# @safetestset "Components Test" begin include("components.jl") end -# @safetestset "PDE Construction Test" begin include("pde.jl") end -# @safetestset "Lowering Integration Test" begin include("lowering_solving.jl") end -# @safetestset "Test Big System Usage" begin include("bigsystem.jl") end -# @safetestset "Depdendency Graph Test" begin include("dep_graphs.jl") end -# @safetestset "Function Registration Test" begin include("function_registration.jl") end +@safetestset "Parsing Test" begin include("variable_parsing.jl") end +@safetestset "Differentiation Test" begin include("derivatives.jl") end +@safetestset "Simplify Test" begin include("simplify.jl") end +@safetestset "Operation Overloads Test" begin include("operation_overloads.jl") end +@safetestset "Direct Usage Test" begin include("direct.jl") end +@safetestset "System Linearity Test" begin include("linearity.jl") end +@safetestset "Build Function Test" begin include("build_function.jl") end +@safetestset "ODESystem Test" begin include("odesystem.jl") end +@safetestset "LabelledArrays Test" begin include("labelledarrays.jl") end +@safetestset "Mass Matrix Test" begin include("mass_matrix.jl") end +@safetestset "SteadyStateSystem Test" begin include("steadystatesystems.jl") end +@safetestset "SDESystem Test" begin include("sdesystem.jl") end +@safetestset "NonlinearSystem Test" begin include("nonlinearsystem.jl") end +@safetestset "OptimizationSystem Test" begin include("optimizationsystem.jl") end +@safetestset "ReactionSystem Test" begin include("reactionsystem.jl") end +@safetestset "JumpSystem Test" begin include("jumpsystem.jl") end +@safetestset "ControlSystem Test" begin include("controlsystem.jl") end +@safetestset "Build Targets Test" begin include("build_targets.jl") end +@safetestset "Domain Test" begin include("domains.jl") end +@safetestset "Modelingtoolkitize Test" begin include("modelingtoolkitize.jl") end +@safetestset "Constraints Test" begin include("constraints.jl") end +@safetestset "Reduction Test" begin include("reduction.jl") end +@safetestset "Components Test" begin include("components.jl") end +@safetestset "PDE Construction Test" begin include("pde.jl") end +@safetestset "Lowering Integration Test" begin include("lowering_solving.jl") end +@safetestset "Test Big System Usage" begin include("bigsystem.jl") end +@safetestset "Depdendency Graph Test" begin include("dep_graphs.jl") end +@safetestset "Function Registration Test" begin include("function_registration.jl") end @safetestset "Array of Array Test" begin include("build_function_arrayofarray.jl") end @testset "Distributed Test" begin include("distributed.jl") end @safetestset "Variable Utils Test" begin include("variable_utils.jl") end