I’ve stared at this a long time and can’t figure out what’s wrong.
Here is a method call that works in the REPL:
julia> plus!([1,2,3,4,5], infectious, 1:5,1,1)
5-element view(::Array{Float64,4}, 2, 1, 1:5, 1) with eltype Float64:
6.0
7.0
8.0
9.0
10.0
(Note: the view is just for returning the result in the REPL.)
Here is the same method used in the body of a function the same .jl file:
function spread(locale)
# start with the number of infectious people # now we ignore what their condition and age are is: TODO fix
spreaders = Int(sum(grab(infectious, 1:5,1:11, locale)))
# how many people are touched
touched = how_many_touched(spreaders)
# by age group
byage = split_by_age(touched)
# move the people from unexposed:agegrp to infectious:agegrp
plus!(byage, infectious, agegrps, 1, locale)
end
Here is the resulting error message:
julia> spread(1)
ERROR: MethodError: no method matching plus!(::Array{Int64,1}, ::Int64, ::Array{Int64,1}, ::Int64, ::Int64)
Closest candidates are:
plus!(::Union{Real, Array}, ::Union{UnitRange{Int64}, Int64}, ::Union{UnitRange{Int64}, Int64}, ::Union{UnitRange{Int64}, Int64}, ::Union{UnitRange{Int64}, Int64}; dat) at /Users/lewis/Dropbox/Online Coursework/Covid/prototype.jl:290
Stacktrace:
[1] spread(::Int64) at /Users/~/Dropbox/Online Coursework/Covid/prototype.jl:178
[2] top-level scope at REPL[8]:1
Here is the method definition:
function plus!(val, condition::Union{Int, UnitRange{Int}}, agegrp::Union{Int, UnitRange{Int}},
lag::Union{Int, UnitRange{Int}}, locale::Union{Int, UnitRange{Int}}; dat=openmx)
dat[condition,locale, agegrp,lag] .+= val
end
I must be missing something obvious. Any thoughts?