-
Notifications
You must be signed in to change notification settings - Fork 44
Description
setindex! does not perform type conversion and therefore does not behave as expected from Base.setindex!
In particular
a = zeros(ComplexF64, 2);
setindex!(a, 5.0, 2)
works as expected, while the corresponding StructArray version
a = StructArray(zeros(ComplexF64, 2));
setindex!(a, 5.0, 2)`
errors with
ERROR: type Float64 has no field re
Stacktrace:
[1] component(x::Float64, i::Symbol)
@ StructArrays ~/.julia/packages/StructArrays/0C03x/src/interface.jl:10
[2] macro expansion
@ ~/.julia/packages/StructArrays/0C03x/src/utils.jl:82 [inlined]
[3] foreachfield_gen(::StructVector{ComplexF64, NamedTuple{(:re, :im), Tuple{Vector{Float64}, Vector{Float64}}}, Int64}, ::StructArrays.var"#39#40"{Int64}, ::StructVector{ComplexF64, NamedTuple{(:re, :im), Tuple{Vector{Float64}, Vector{Float64}}}, Int64}, ::Float64)
@ StructArrays ~/.julia/packages/StructArrays/0C03x/src/utils.jl:82
[4] foreachfield(f::StructArrays.var"#39#40"{Int64}, x::StructVector{ComplexF64, NamedTuple{(:re, :im), Tuple{Vector{Float64}, Vector{Float64}}}, Int64}, xs::Float64)
@ StructArrays ~/.julia/packages/StructArrays/0C03x/src/utils.jl:85
[5] setindex!(s::StructVector{ComplexF64, NamedTuple{(:re, :im), Tuple{Vector{Float64}, Vector{Float64}}}, Int64}, vals::Float64, I::Int64)
@ StructArrays ~/.julia/packages/StructArrays/0C03x/src/structarray.jl:361
Not sure, if that is intended behavior, but it prevents StructArrays behaving as a drop-in replacement for Base Arrays.