-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
The Julia documentation says that empty(v::AbstractVector) returns "an empty vector similar to v". Currently similar preserves indices for OffsetVector,
julia> v = OffsetVector([1,2], 0:1)
2-element OffsetArray(::Vector{Int64}, 0:1) with eltype Int64 with indices 0:1:
1
2
julia> similar(v)
2-element OffsetArray(::Vector{Int64}, 0:1) with eltype Int64 with indices 0:1:
139997918114896
139997785055648
but empty does not because it returns a Vector:
julia> empty(v)
Int64[]
Since empty reduces the length of the vector to zero, one can at most preserve either the first or the last index. Assuming that 0-based vectors are the most common use case for OffsetVector, I think it would make sense to preserve the first index in general.
Metadata
Metadata
Assignees
Labels
No labels