Skip to content

typeof(zero(x)) != typeof(x) for BlockVector #420

@DanielVandH

Description

@DanielVandH
julia> using BlockArrays

julia> using BlockArrays: BlockedOneTo

julia> b = BlockVector([1,2,3,4,5,6,7,8,9,10], (BlockedOneTo(5:5:10),));

julia> typeof(b) == typeof(zero(b))
false

julia> typeof(b)
BlockVector{Int64, Vector{Vector{Int64}}, Tuple{BlockedOneTo{Int64, StepRange{Int64, Int64}}}} (alias for BlockArray{Int64, 1, Array{Array{Int64, 1}, 1}, Tuple{BlockedOneTo{Int64, StepRange{Int64, Int64}}}})

julia> typeof(similar(b))
BlockVector{Int64, Vector{Vector{Int64}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}}} (alias for BlockArray{Int64, 1, Array{Array{Int64, 1}, 1}, Tuple{BlockedOneTo{Int64, Array{Int64, 1}}}})

I think the issue is because typeof(similar(b)) != typeof(b) in this case, since it collects the axes

julia> axes(b)
(BlockedOneTo(5:5:10),)

julia> axes(similar(b))
(BlockedOneTo([5, 10]),)

Would this be a bug? Should it preserve the axes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions