You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It correctly works when eltypeisbitstype since then you don't end up with undef but instead an "unitialized" value, for example
julia> x =Vector{Float32}(undef, 2)
2-element Vector{Float32}:1.0f-451.7f-44
julia>@set! x[1] =1.02-element Vector{Float64}:1.01.6815581571897805e-44
Maybe the way to go is:
Base.@propagate_inboundsfunctionsetindex(xs::AbstractArray, v, I...)
T =promote_type(eltype(xs), typeof(v))
ys =similar(xs, T)
ifisbitstype(T)
copy!(ys, xs)
elseifeltype(xs) !== Union{}
for index inCartesianIndices(xs)
ifisassigned(xs, Tuple(index)...)
ys[index] = xs[index]
endendend
ys[I...] = v
return ys
end
? Seems sub-optimal though.
This is not an urgent issue to resolve for our sake, but figured I'd at least raise it here for now. In the meantime (and this is what we'll do anyways as it aligns better with the behavior we want) one can use BangBang.@set!! which uses BangBang.prefermutation instead of identity in setmacro.
The text was updated successfully, but these errors were encountered:
It correctly works when
eltype
isbitstype
since then you don't end up withundef
but instead an "unitialized" value, for exampleMaybe the way to go is:
? Seems sub-optimal though.
This is not an urgent issue to resolve for our sake, but figured I'd at least raise it here for now. In the meantime (and this is what we'll do anyways as it aligns better with the behavior we want) one can use
BangBang.@set!!
which usesBangBang.prefermutation
instead ofidentity
insetmacro
.The text was updated successfully, but these errors were encountered: