Skip to content

Error in tutorial "Generating ReactionSystems Programmatically" #450

@bsvisser

Description

@bsvisser

When I try to run the code from the Generating ReactionSystems Programmatically tutorial, I get an error for generating reactions.

Code:

# vector to store the Reactions in
rx = []              
for n = 1:nr
    # for clusters of the same size, double the rate
    if (vᵢ[n] == vⱼ[n]) 
        push!(rx, Reaction(k[n], [X[vᵢ[n]]], [X[sum_vᵢvⱼ[n]]], [2], [1]))
    else
        push!(rx, Reaction(k[n], [X[vᵢ[n]], X[vⱼ[n]]], [X[sum_vᵢvⱼ[n]]], 
                           [1, 1], [1]))
    end
end
rs = ReactionSystem(rx, t, X, k)

Error message:

MethodError: no method matching CartesianIndices(::Tuple{Vector{Int64}})
Closest candidates are:
  (::Type{S})(::Complex{Num}) where S<:Union{AbstractFloat, Integer, Complex{var"#s145"} where var"#s145"<:AbstractFloat, Complex{var"#s144"} where var"#s144"<:Integer, AbstractArray} at C:\Users\admin-brent\.julia\packages\Symbolics\Cmx10\src\Symbolics.jl:124
  (::Type{S})(::Num) where S<:Union{AbstractFloat, Integer, Complex{var"#s145"} where var"#s145"<:AbstractFloat, Complex{var"#s144"} where var"#s144"<:Integer, AbstractArray} at C:\Users\.julia\packages\Symbolics\Cmx10\src\Symbolics.jl:124
  CartesianIndices(::Tuple{}) at multidimensional.jl:269
  ...

Stacktrace:
 [1] getindex(x::Symbolics.ArrayOp{AbstractVector{Real}}, idx::Int64)
   @ Symbolics C:\Users\.julia\packages\Symbolics\Cmx10\src\array-lib.jl:23
 [2] getindex(x::Symbolics.Arr{Num, 1}, idx::Int64)
   @ Symbolics C:\Users\.julia\packages\Symbolics\Cmx10\src\array-lib.jl:84
 [3] top-level scope
   @ .\In[6]:0
 [4] eval
   @ .\boot.jl:360 [inlined]
 [5] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base .\loading.jl:1116

Can anyone help me figure out where this is going wrong? Is this an error in the tutorial?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions