Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/OffsetArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ Base.reshape(A::OffsetVector, ::Colon) = A
Base.reshape(A::OffsetArray, inds::Union{Int,Colon}...) = reshape(parent(A), inds)
Base.reshape(A::OffsetArray, inds::Tuple{Vararg{Union{Int,Colon}}}) = reshape(parent(A), inds)

function Base.similar(::Type{T}, shape::Tuple{OffsetAxis,Vararg{OffsetAxis}}) where {T<:AbstractArray}
function Base.similar(::Type{T}, shape::Tuple{OffsetAxisKnownLength,Vararg{OffsetAxisKnownLength}}) where {T<:AbstractArray}
P = T(undef, map(_indexlength, shape))
OffsetArray(P, map(_offset, axes(P), shape))
end
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,10 @@ end
@test_throws MethodError similar(A, (: ,2))
@test_throws MethodError similar(A, Float64, (: ,:))
@test_throws MethodError similar(A, Float64, (: ,2))

@test_throws MethodError similar(Matrix{Float64}, (:, 2))
@test_throws MethodError similar(Matrix{Float64}, (:, 1:3))
@test_throws MethodError similar(Matrix{Float64}, (:, :))
end

@testset "reshape" begin
Expand Down