Closed BradenDKelly closed 4 years ago
Thanks for reporting. Can you provide a self contained runnable example that produces the error? Your snippet misses context and is not runnable. By the way, you can highlight code by wrapping it in backticks like this:
```julia
for k = 1:3
rᵢⱼ = @set rᵢⱼ[k] = vector1D(rᵢ[k], rⱼ[k], box)
end
```
(@jw3126 I guessed you might want to write something like above so I edited it in-place. Feel free to revert it back.)
Sorry about the very late reply. April was a busy month :S
I found the mistake, and it was mine not yours. I had accidentally used the same name twice, so upon using @set a second time, it was trying to @set a Float64 rather than a SVector{3,Float64}.
For future me, be careful when using Julias fancy fonts which allow subscripts etc...
When I apply the following and the "ij" are subscripts, the below error occurs after being called a few times for k = 1:3 rᵢⱼ = @set rᵢⱼ[k] = vector1D(rᵢ[k], rⱼ[k], box) end
however, it works fine if I use rij (no subscripts) instead of "rᵢⱼ"(ij are subscripts).
rᵢⱼ =rij= SVector{3}(0.0,0.0,0.0) initially. ri and rj are also the same size SVectors. The error happens after several successful calls, and, does not happen in a different function where this is also applied in the same manner.
Just thought I would let you know. The error message is below
ERROR: LoadError: MethodError: no method matching setindex(::Float64, ::Float64, ::Int64) Closest candidates are: setindex(::Tuple, ::Any, ::Integer) at tuple.jl:45 setindex(::SHermitianCompact{N,T,L}, ::Any, ::Int64) where {N, T, L} at C:\Users\Zarathustra.juliapro\JuliaPro_v1.4.0-1\packages\StaticArrays\1g9bq\src\SHermitianCompact.jl:116 setindex(::StaticArray, ::Any, ::Int64) at C:\Users\Zarathustra.juliapro\JuliaPro_v1.4.0-1\packages\StaticArrays\1g9bq\src\deque.jl:185 ... Stacktrace: [1] setindex at C:\Users\Zarathustra.juliapro\JuliaPro_v1.4.0-1\packages\Setfield\n9pIa\src\setindex.jl:2 [inlined] [2] set at C:\Users\Zarathustra.juliapro\JuliaPro_v1.4.0-1\packages\Setfield\n9pIa\src\lens.jl:170 [inlined] [3] macro expansion at C:\Users\Zarathustra.juliapro\JuliaPro_v1.4.0-1\packages\Setfield\n9pIa\src\sugar.jl:166 [inlined] [4] EwaldReal(::Array{SArray{Tuple{3},Float64,1,3},1}, ::Array{Float64,1}, ::Float64, ::Float64, ::Array{SArray{Tuple{2},Int64,1,2},1}, ::Int64, ::Float64) at C:\Users\Zarathustra\Julia\ToyMonteCarlo\ewalds.jl:90 [5] potential(::Requirements, ::Properties, ::EWALD{Int64}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Float64,1}, ::Array{SArray{Tuple{3},Float64,1,3},1}) at C:\Users\Zarathustra\Julia\ToyMonteCarlo\energy.jl:318 [6] top-level scope at C:\Users\Zarathustra\Julia\ToyMonteCarlo\main.jl:158 in expression starting at C:\Users\Zarathustra\Julia\ToyMonteCarlo\main.jl:158