Skip to content

Commit

Permalink
version-limit methods with Colon
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Dec 18, 2024
1 parent 2070987 commit 18e1a3a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/OffsetArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,13 @@ _reshape2(A::OffsetArray, inds) = reshape(parent(A), inds)
_reshape_nov(A, inds) = _reshape(no_offset_view(A), inds)

# And for non-offset axes, we can just return a reshape of the parent directly
Base.reshape(A::OffsetArray, inds::Tuple{Vararg{Integer}}) = _reshape_nov(A, inds)

Check warning on line 379 in src/OffsetArrays.jl

View check run for this annotation

Codecov / codecov/patch

src/OffsetArrays.jl#L379

Added line #L379 was not covered by tests
Base.reshape(A::OffsetArray, inds::Dims) = _reshape_nov(A, inds)
Base.reshape(A::OffsetVector, ::Tuple{Colon}) = A
Base.reshape(A::OffsetArray, inds::Tuple{Vararg{Union{Int,Colon}}}) = _reshape_nov(A, inds)
if VERSION < v"1.10.7"
# the specialized reshape(parent::AbstractVector, ::Tuple{Colon}) is available in Base at least on this version
Base.reshape(A::OffsetVector, ::Tuple{Colon}) = A
Base.reshape(A::OffsetArray, inds::Tuple{Vararg{Union{Int,Colon}}}) = _reshape_nov(A, inds)
end

# permutedims in Base does not preserve axes, and can not be fixed in a non-breaking way
# This is a stopgap solution
Expand Down

0 comments on commit 18e1a3a

Please sign in to comment.