jonniedie / ComponentArrays.jl

Arrays with arbitrarily nested named components.
MIT License
291 stars 35 forks source link

`convert(T, y)` is not always a `T` #266

Open gdalle opened 2 months ago

gdalle commented 2 months ago

Is this expected?

julia> using ComponentArrays

julia> x = ComponentVector(a = [1, 2])
ComponentVector{Int64}(a = [1, 2])

julia> M = hcat(x, x)
2×2 ComponentMatrix{Int64} with axes Axis(a = 1:2,) × FlatAxis()
 1  1
 2  2

julia> y = convert(typeof(x), view(M, :, 1))
ComponentVector{Int64,SubArray...}(a = [1, 2])

julia> y isa typeof(x)
false