-
Notifications
You must be signed in to change notification settings - Fork 44
Closed
Milestone
Description
julia> sa = StructArray{Complex}((randn(2), randn(2)));
julia> sa[1] = false
ERROR: type Bool has no field re
Stacktrace:
[1] getproperty(::Bool, ::Symbol) at ./Base.jl:33
[2] macro expansion at /home/cossio/.julia/packages/StructArrays/2PoXh/src/utils.jl:46 [inlined]
[3] foreachfield_gen(::NamedTuple{(:re, :im),Tuple{Array{Float64,1},Array{Float64,1}}}, ::StructArrays.var"#58#59"{Int64}, ::StructArray{Complex,1,NamedTuple{(:re, :im),Tuple{Array{Float64,1},Array{Float64,1}}},Int64}, ::Bool) at /home/cossio/.julia/packages/StructArrays/2PoXh/src/utils.jl:46
[4] foreachfield(::Function, ::StructArray{Complex,1,NamedTuple{(:re, :im),Tuple{Array{Float64,1},Array{Float64,1}}},Int64}, ::Bool) at /home/cossio/.julia/packages/StructArrays/2PoXh/src/utils.jl:51
[5] setindex!(::StructArray{Complex,1,NamedTuple{(:re, :im),Tuple{Array{Float64,1},Array{Float64,1}}},Int64}, ::Bool, ::Int64) at /home/cossio/.julia/packages/StructArrays/2PoXh/src/structarray.jl:166
[6] top-level scope at REPL[21]:1
Compare that with the behavior of normal arrays:
julia> X = randn(2,2) + randn(2,2) * im;
julia> X[1] = false;
julia> X
2×2 Array{Complex{Float64},2}:
0.0+0.0im 0.872904-2.44604im
0.300476-0.454121im -0.156811+0.00139102im
I think StructArray
should replicate the behavior of normal arrays, and promote the value being assigned.
saschatimme and fbanning
Metadata
Metadata
Assignees
Labels
No labels