Closed as not planned
Description
Hi there,
I'm using OffsetArrays in image manipulation, and I've come across something where the behaviour of an OffsetArray is a bit disappointing. When concatenating a vector to the end (or beginning) of an offset matrix, I expect this to still return an OffsetArray.
oa = OffsetArrays.OffsetArray([1 2; 3 4], -1:0, 3:4)
hcat(oa, oa[:, begin]) |> axes # (Base.OneTo(2), Base.OneTo(3))
I think I can get the desired behaviour by implementing
function Base.hcat(
mat::OffsetMatrix{T, Matrix{T}}, vec::OffsetVector{T, Vector{T}}
) where {T}
ax = axes(mat, 2)
new_ax = first(ax):(last(ax)+1)
content = hcat(mat.parent, vec)
result = OffsetMatrix{T, Matrix{T}}(content, axes(mat, 1), new_ax)
end
hcat(oa, oa[:, begin]) |> axes # (IdOffsetRange(values=-1:0, indices=-1:0), IdOffsetRange(values=3:5, indices=3:5))
Is this something worth implementing? It would also have to be done for hcat(vec, mat)
and both vcat
options. What do you think?
Metadata
Metadata
Assignees
Labels
No labels