ERROR: LoadError: MethodError: no method matching setindex_shape_check(::Int64, ::Int64, ::Int64)

Hello, using Julia 1.0.1, and i’m getting this error:

ERROR: LoadError: MethodError: no method matching setindex_shape_check(::Int64, ::Int64, ::Int64)
Closest candidates are:
  setindex_shape_check(::AbstractArray{#s57,1} where #s57, ::Integer, ::Integer) at indices.jl:221
  setindex_shape_check(::AbstractArray{#s57,2} where #s57, ::Integer, ::Integer) at indices.jl:225
  setindex_shape_check(::AbstractArray, ::Integer...) at indices.jl:179
  ...
Stacktrace:
 [1] macro expansion at .\multidimensional.jl:641 [inlined]
 [2] _unsafe_setindex!(::IndexLinear, ::Array{Float64,2}, ::Int64, ::Base.Slice{Base.OneTo{Int64}},
::Int64) at .\multidimensional.jl:636
 [3] _setindex! at .\multidimensional.jl:631 [inlined]
 [4] setindex!(::Array{Float64,2}, ::Int64, ::Function, ::Int64) at .\abstractarray.jl:998
 [5] top-level scope at C:\Users\Muril\Desktop\Murilo\UFPE\Dissertação\Julia\Arquivos Feitos 1.0.1\f
luxo_harm.jl:279 [inlined]
 [6] top-level scope at .\none:0
 [7] include_string(::Module, ::String, ::String) at .\loading.jl:1005
 [8] (::getfield(Atom, Symbol("##128#133")){String,String,Module})() at C:\Users\Muril\.julia\packag
es\Atom\Fha1N\src\eval.jl:120
 [9] withpath(::getfield(Atom, Symbol("##128#133")){String,String,Module}, ::String) at C:\Users\Mur
il\.julia\packages\CodeTools\hB4Hy\src\utils.jl:30
 [10] withpath at C:\Users\Muril\.julia\packages\Atom\Fha1N\src\eval.jl:46 [inlined]
 [11] #127 at C:\Users\Muril\.julia\packages\Atom\Fha1N\src\eval.jl:117 [inlined]
 [12] hideprompt(::getfield(Atom, Symbol("##127#132")){String,String,Module}) at C:\Users\Muril\.jul
ia\packages\Atom\Fha1N\src\repl.jl:84
 [13] macro expansion at C:\Users\Muril\.julia\packages\Atom\Fha1N\src\eval.jl:116 [inlined]
 [14] (::getfield(Atom, Symbol("##126#131")){Dict{String,Any}})() at .\task.jl:85
in expression starting at C:\Users\Muril\Desktop\Murilo\UFPE\Dissertação\Julia\Arquivos Feitos 1.0.1
\fluxo_harm.jl:193

It says it starts at line 193? If thats so, here it is:


if length(pos3) > 0 || length(posI) > 0
    if length(pos3) > 0
    println("text 1:\n\n", pos3, "\n")
    else
    println("text 2.\n")
    end
    if length(posI) > 0
    println("text 3:\n\n", posI, "\n")
    else
    println("text 4.\n")
    end
    println("text 5.\n")
    println("text 6.\n")

    
    barra_filtro = [2]; 
    hs = [13]; 
    Xcf = zeros(Nt);
    Cf = zeros(Nt);
    Xlf = zeros(Nt);
    Lf = zeros(Nt);
    ws = zeros(Nt);
    Xf = zeros(Nt);
    Rf = zeros(Nt);
    y5 = zeros(ComplexF64,Nt,hmax);

for h = 3:2:hmax
    for m = 1:length(barra_filtro)
        for i = 1:Nt
            if i == barra_filtro[m]
             Xcf[i] = u[i]^2/(kj*Qmod); 
             Cf[i] = 1/(2*pi*f*Xcf[i]); 
             Xlf[i] = Xcf[i]/(hs[m]^2); 
             Lf[i] = Xlf[i]/(2*pi*f); 
             ws[i] = 1/sqrt(Cf[i]*Lf[i]); 
             Xf[i] = ws[i]*Lf[i]; 
             Rf[i] = Xf[i]/fq; 
             y5[i,h] = 1/(Rf[i]+im*(h*Xlf[i]-Xcf[i]/h));
            end
        end
    end
end

    

    Yh_filtro = zeros(ComplexF64,Nt,Nt,hmax);
    for h = 3:2:hmax
      for L = 1:Nt
        for C = 1:Nt
          for i = 1:Nt 
            if L == C && (de[i] == L || para[i] == L)
                if i == L
                     Yh_filtro[L,C,h] = Yh_filtro[L,C,h]+y1[i,h]+y2[i,h]+y3[i,h]+y5[i,h];
                end
                if i != L
                    Yh_filtro[L,C,h] = Yh_filtro[L,C,h]+y1[i,h];
                end
            end
            if L != C && (de[i] == L && para[i] == C)
                     Yh_filtro[L,C,h] = Yh_filtro[L,C,h]-y1[i,h];
                     Yh_filtro[C,L,h] = Yh_filtro[L,C,h];
            end
          end
        end
      end
    end

    
    Vh_filtro = zeros(ComplexF64,Nt,hmax);
    for h = 3:2:hmax 
           Vh_filtro[:,h] = Yh_filtro[:,:,h]\Ih[:,h];
    end


    DHIv_filtro = zeros(Nt,hmax);
    for h = 3:2:hmax
        for i = 1:Nt
          DHIv_filtro[i,h] = abs(Vh_filtro[i,h])/u[i]*100;
        end
    end

    DHIv_filtro[:,1] = 1;

   

    DHTv3_filtro = zeros(Nt,1); 
    DHTvI_filtro = zeros(Nt,1); 
    for i = 1:Nt 
        DHTvaux3_filtro = 0;
        DHTvauxI_filtro = 0;
        for h = 3:2:hmax 
            if rem(h,3) == 0
                DHTvaux3_filtro = DHTvaux3_filtro + abs(Vh_filtro[i,h])^2;
            else
                DHTvauxI_filtro = DHTvauxI_filtro + abs(Vh_filtro[i,h])^2;
            end
        end
    DHTv3_filtro[i] = sqrt.(DHTvaux3_filtro)/u[i]*100;
    DHTvI_filtro[i] = sqrt.(DHTvauxI_filtro)/u[i]*100;
    end
else
    println("text 7.\n")
end

display(groupedbar([DHTvI DHTvI_filtro], group = barras, xlabel = "B", ylabel = "DHT3 (%)", title = "title", bar_position = :dodge, bar_width=0.7))

The code was working fine in 0.6, i’m trying to adapt it to 1.0.1, but i have no idea what this error means and how to fix it.

1 Like

Use 0.7 for updating code from 0.6 - it’ll tell you about deprecations.

1 Like

Maybe this is helpful: The error comes from something like:

julia> A = zeros(2, 2);

julia> A[:,1] = 4
ERROR: MethodError: no method matching setindex_shape_check(::Int64, ::Int64, ::Int64)

e.g. you try to assign a scalar to multiple locations in A. This should be written with broadcasting in Julia 1.0:

julia> A = zeros(2, 2);

julia> A[:,1] .= 4
2-element view(::Array{Float64,2}, :, 1) with eltype Float64:
 4.0
 4.0
3 Likes

Yes, i changed back to 0.7 and got the info that broadcasting would fix the problem, thanks guys!