Error reported in a blank line (MethodError: no method matching getindex(::Float64, ::UnitRange{Int64})

Question solved: At the end this is found to be due to multiplying a constant with a vector, while the error report is a bit distracting (in line much ).

for i in 1:nDemes
        println("deme### ", i)
        NDeme = N_vec[i]
        println("begin_NDeme ",NDeme)
 #error reported in this line
        x = D[i]
        xwt = x[end,t-1]
        X = x[1:end-1,t-1]
        if !isempty(X)
               ss=xwt*s0
               xx=X+ss.*X #but actually is caused by this line
...

:laughing:

Two questions:

  • are you using Revise? If so, does it happen if you don’t use Revise?
  • does this persist on more recent Julia versions?
1 Like

Thanks. I havn’t used package Revise, after updating the version from 1.2.0 to 1.3.1, the error report remains in the same blank line.

At the end this is found to be due to multiplying a constant with a vector while the error report is a bit distracting.

Instead of editing your original question to put the solution, it can be much more helpful to post the solution as a new post — you can even mark it with a :white_check_mark: to say it’s solved. That way folks who have similar issues can continue to read, understand, and even find the thread from Google in the future.

1 Like

I thought the orginal long debugging process doesn’t contain any useful information pointing to the cause of error :yum:.