From de61957fcdeb92d0e77d2bff909de26f61631f6b Mon Sep 17 00:00:00 2001 From: jishnub Date: Tue, 15 Jun 2021 22:34:54 +0400 Subject: [PATCH 01/10] reshape with an offset parent array --- src/OffsetArrays.jl | 29 +++++++++++++++++++---------- src/utils.jl | 18 ++++++++++++++++++ test/customranges.jl | 4 ++++ test/runtests.jl | 19 +++++++++++++++++++ 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/src/OffsetArrays.jl b/src/OffsetArrays.jl index c9563867..6a570fbc 100644 --- a/src/OffsetArrays.jl +++ b/src/OffsetArrays.jl @@ -11,16 +11,16 @@ export OffsetArray, OffsetMatrix, OffsetVector const IIUR = IdentityUnitRange{<:AbstractUnitRange{<:Integer}} -include("axes.jl") -include("utils.jl") -include("origin.jl") - # Technically we know the length of CartesianIndices but we need to convert it first, so here we # don't put it in OffsetAxisKnownLength. const OffsetAxisKnownLength = Union{Integer, AbstractUnitRange} const OffsetAxis = Union{OffsetAxisKnownLength, Colon} const ArrayInitializer = Union{UndefInitializer, Missing, Nothing} +include("axes.jl") +include("utils.jl") +include("origin.jl") + ## OffsetArray """ OffsetArray(A, indices...) @@ -347,15 +347,24 @@ end # Reshaping OffsetArrays can "pop" the original OffsetArray wrapper and return # an OffsetArray(reshape(...)) instead of an OffsetArray(reshape(OffsetArray(...))) +# try to pass on the indices as received to the parent. +# If the parent doesn't define an appropriate method, this will fall back to using the lengths +# Short-circuit the case with matching indices to circumvent the Base restriction to 1-based indices +_reshape(A::AbstractArray{<:Any,N}, ::NTuple{N,Union{Integer, AbstractUnitRange}}) where {N} = A +_reshape(A::AbstractArray{<:Any,N}, inds::NTuple{N,OffsetAxis}) where {N} = (_colon_check(inds); A) +_reshape(A, inds) = reshape(A, inds) +_reshape_nov(A, inds) = no_offset_view(_reshape(A, inds)) + Base.reshape(A::OffsetArray, inds::Tuple{OffsetAxis,Vararg{OffsetAxis}}) = - OffsetArray(reshape(parent(A), map(_indexlength, inds)), map(_indexoffset, inds)) + OffsetArray(_reshape(parent(A), inds), map(_toaxis, inds)) # And for non-offset axes, we can just return a reshape of the parent directly -Base.reshape(A::OffsetArray, inds::Tuple{Union{Integer,Base.OneTo},Vararg{Union{Integer,Base.OneTo}}}) = reshape(parent(A), inds) -Base.reshape(A::OffsetArray, inds::Dims) = reshape(parent(A), inds) -Base.reshape(A::OffsetArray, ::Colon) = reshape(parent(A), Colon()) +Base.reshape(A::OffsetArray, inds::Tuple{Union{Integer,Base.OneTo},Vararg{Union{Integer,Base.OneTo}}}) = _reshape_nov(parent(A), inds) +Base.reshape(A::OffsetArray, inds::Dims) = _reshape_nov(parent(A), inds) 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) +Base.reshape(A::OffsetVector, ::Tuple{Colon}) = A +Base.reshape(A::OffsetArray, ::Colon) = reshape(A, (Colon(),)) +Base.reshape(A::OffsetArray, inds::Union{Int,Colon}...) = reshape(A, inds) +Base.reshape(A::OffsetArray, inds::Tuple{Vararg{Union{Int,Colon}}}) = _reshape_nov(parent(A), inds) # permutedims in Base does not preserve axes, and can not be fixed in a non-breaking way # This is a stopgap solution diff --git a/src/utils.jl b/src/utils.jl index 117165aa..40d5f009 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -7,6 +7,9 @@ _indexlength(r::AbstractRange) = length(r) _indexlength(i::Integer) = Int(i) _indexlength(i::Colon) = Colon() +_toaxis(i::Integer) = Base.OneTo(i) +_toaxis(i::OffsetAxis) = i + _strip_IdOffsetRange(r::IdOffsetRange) = parent(r) _strip_IdOffsetRange(r) = r @@ -111,3 +114,18 @@ _filterreshapeinds(t::Tuple) = _filterreshapeinds(tail(t)) _filterreshapeinds(t::Tuple{}) = t _popreshape(A::AbstractArray, ax::Tuple{Vararg{Base.OneTo}}, inds::Tuple{}) = no_offset_view(A) _popreshape(A::AbstractArray, ax, inds) = A + +@inline function _colon_check(dims) + @noinline throw1(dims) = throw(DimensionMismatch(string("new dimensions $(dims) ", + "may have at most one omitted dimension specified by `Colon()`"))) + post = _after_colon(dims...) + _any_colon(post...) && throw1(dims) + nothing +end +@inline _any_colon() = false +@inline _any_colon(dim::Colon, tail...) = true +@inline _any_colon(dim::Any, tail...) = _any_colon(tail...) +@inline _before_colon(dim::Any, tail...) = (dim, _before_colon(tail...)...) +@inline _before_colon(dim::Colon, tail...) = () +@inline _after_colon(dim::Any, tail...) = _after_colon(tail...) +@inline _after_colon(dim::Colon, tail...) = tail diff --git a/test/customranges.jl b/test/customranges.jl index c413c511..d3baf0c6 100644 --- a/test/customranges.jl +++ b/test/customranges.jl @@ -65,6 +65,10 @@ for Z in [:ZeroBasedRange, :ZeroBasedUnitRange] @boundscheck checkbounds(A, r) OffsetArrays._indexedby(A[r.a], axes(r)) end + + @eval Base.reshape(z::$Z, inds::Tuple{}) = reshape(parent(z), inds) + @eval Base.reshape(z::$Z, inds::Tuple{Int, Vararg{Int}}) = reshape(parent(z), inds) + @eval Base.reshape(z::$Z, inds::Tuple{Union{Int, AbstractUnitRange{<:Integer}}, Vararg{Union{Int, AbstractUnitRange{<:Integer}}}}) = reshape(parent(z), inds) end # A basic range that does not have specialized vector indexing methods defined diff --git a/test/runtests.jl b/test/runtests.jl index 4ba44875..f8146890 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1756,6 +1756,25 @@ end @test axes(R) == (1:2, 1:3) R = reshape(zeros(6,1), 1:2, :) @test axes(R) == (1:2, 1:3) + + r = OffsetArray(ZeroBasedRange(3:4), 1); + @test reshape(r, 2) == 3:4 + @test reshape(r, (2,)) == 3:4 + @test reshape(r, :) == 3:4 + @test reshape(r, (:,)) == 3:4 + + @test reshape(r, (2,:,4:4)) == OffsetArray(reshape(3:4, 2, 1, 1), 1:2, 1:1, 4:4) + + # reshape works even if the parent doesn't have 1-based indices + # this works even if the parent doesn't support the reshape + r = OffsetArray(IdentityUnitRange(0:1), -1) + @test reshape(r, 2) == 0:1 + @test reshape(r, (2,)) == 0:1 + @test reshape(r, :) == OffsetArray(0:1, -1:0) + @test reshape(r, (:,)) == OffsetArray(0:1, -1:0) + + # more than one colon is not allowed + @test_throws Exception reshape(ones(3:4, 4:5, 1:2), :, :, 2) end @testset "permutedims" begin From e6b066e6058a55ed44b5824626e4b5f202a803d6 Mon Sep 17 00:00:00 2001 From: jishnub Date: Tue, 15 Jun 2021 23:04:17 +0400 Subject: [PATCH 02/10] fix test on v1.0 --- test/runtests.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index f8146890..1c582da4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1763,7 +1763,10 @@ end @test reshape(r, :) == 3:4 @test reshape(r, (:,)) == 3:4 - @test reshape(r, (2,:,4:4)) == OffsetArray(reshape(3:4, 2, 1, 1), 1:2, 1:1, 4:4) + # getindex for a reshaped array that wraps an offset array is broken on 1.0 + if VERSION >= v"1.1" + @test reshape(r, (2,:,4:4)) == OffsetArray(reshape(3:4, 2, 1, 1), 1:2, 1:1, 4:4) + end # reshape works even if the parent doesn't have 1-based indices # this works even if the parent doesn't support the reshape From ea23f9004a6f85e7d8a595c488c6d6db8e86cf12 Mon Sep 17 00:00:00 2001 From: jishnub Date: Tue, 15 Jun 2021 23:37:45 +0400 Subject: [PATCH 03/10] remove unnecesary functions --- src/utils.jl | 6 ++++-- test/runtests.jl | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 40d5f009..8052f0c6 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -115,6 +115,8 @@ _filterreshapeinds(t::Tuple{}) = t _popreshape(A::AbstractArray, ax::Tuple{Vararg{Base.OneTo}}, inds::Tuple{}) = no_offset_view(A) _popreshape(A::AbstractArray, ax, inds) = A +# derived from Base._reshape_uncolon +# https://github.com/JuliaLang/julia/blob/d29126a43ee289fc5ab8fcb3dc0e03f514605950/base/reshapedarray.jl#L119-L137 @inline function _colon_check(dims) @noinline throw1(dims) = throw(DimensionMismatch(string("new dimensions $(dims) ", "may have at most one omitted dimension specified by `Colon()`"))) @@ -125,7 +127,7 @@ end @inline _any_colon() = false @inline _any_colon(dim::Colon, tail...) = true @inline _any_colon(dim::Any, tail...) = _any_colon(tail...) -@inline _before_colon(dim::Any, tail...) = (dim, _before_colon(tail...)...) -@inline _before_colon(dim::Colon, tail...) = () +# @inline _before_colon(dim::Any, tail...) = (dim, _before_colon(tail...)...) +# @inline _before_colon(dim::Colon, tail...) = () @inline _after_colon(dim::Any, tail...) = _after_colon(tail...) @inline _after_colon(dim::Colon, tail...) = tail diff --git a/test/runtests.jl b/test/runtests.jl index 1c582da4..272845b0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1776,6 +1776,8 @@ end @test reshape(r, :) == OffsetArray(0:1, -1:0) @test reshape(r, (:,)) == OffsetArray(0:1, -1:0) + @test reshape(ones(2:3, 4:5), (2, :)) == ones(2,2) + # more than one colon is not allowed @test_throws Exception reshape(ones(3:4, 4:5, 1:2), :, :, 2) end From 1b12d8ac077f8be067e206c5a18866cb4a5fb783 Mon Sep 17 00:00:00 2001 From: jishnub Date: Tue, 15 Jun 2021 23:55:29 +0400 Subject: [PATCH 04/10] add test --- test/runtests.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/runtests.jl b/test/runtests.jl index 272845b0..7cf7bb3d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1780,6 +1780,7 @@ end # more than one colon is not allowed @test_throws Exception reshape(ones(3:4, 4:5, 1:2), :, :, 2) + @test_throws Exception reshape(ones(3:4, 4:5, 1:2), :, 2, :) end @testset "permutedims" begin From e8578eb0ef3bf22071d95f7a829bf96695aca269 Mon Sep 17 00:00:00 2001 From: jishnub Date: Wed, 16 Jun 2021 00:14:38 +0400 Subject: [PATCH 05/10] remove indexoffset for Colon --- src/utils.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index 8052f0c6..b680999b 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -2,7 +2,6 @@ _indexoffset(r::AbstractRange) = first(r) - 1 _indexoffset(i::Integer) = 0 -_indexoffset(i::Colon) = 0 _indexlength(r::AbstractRange) = length(r) _indexlength(i::Integer) = Int(i) _indexlength(i::Colon) = Colon() From 184d12e7888b157286701df9acf7de4c1d1e6e62 Mon Sep 17 00:00:00 2001 From: jishnub Date: Wed, 16 Jun 2021 12:43:27 +0400 Subject: [PATCH 06/10] fix reshape bug with differing sizes --- src/OffsetArrays.jl | 13 ++++++------- src/utils.jl | 19 +------------------ test/runtests.jl | 13 +++++++++++++ 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/OffsetArrays.jl b/src/OffsetArrays.jl index 6a570fbc..5324da03 100644 --- a/src/OffsetArrays.jl +++ b/src/OffsetArrays.jl @@ -11,16 +11,16 @@ export OffsetArray, OffsetMatrix, OffsetVector const IIUR = IdentityUnitRange{<:AbstractUnitRange{<:Integer}} +include("axes.jl") +include("utils.jl") +include("origin.jl") + # Technically we know the length of CartesianIndices but we need to convert it first, so here we # don't put it in OffsetAxisKnownLength. const OffsetAxisKnownLength = Union{Integer, AbstractUnitRange} const OffsetAxis = Union{OffsetAxisKnownLength, Colon} const ArrayInitializer = Union{UndefInitializer, Missing, Nothing} -include("axes.jl") -include("utils.jl") -include("origin.jl") - ## OffsetArray """ OffsetArray(A, indices...) @@ -350,10 +350,9 @@ end # try to pass on the indices as received to the parent. # If the parent doesn't define an appropriate method, this will fall back to using the lengths # Short-circuit the case with matching indices to circumvent the Base restriction to 1-based indices -_reshape(A::AbstractArray{<:Any,N}, ::NTuple{N,Union{Integer, AbstractUnitRange}}) where {N} = A -_reshape(A::AbstractArray{<:Any,N}, inds::NTuple{N,OffsetAxis}) where {N} = (_colon_check(inds); A) +_reshape(A::AbstractVector, ::Tuple{OffsetAxis}) = A _reshape(A, inds) = reshape(A, inds) -_reshape_nov(A, inds) = no_offset_view(_reshape(A, inds)) +_reshape_nov(A, inds) = _reshape(no_offset_view(A), inds) Base.reshape(A::OffsetArray, inds::Tuple{OffsetAxis,Vararg{OffsetAxis}}) = OffsetArray(_reshape(parent(A), inds), map(_toaxis, inds)) diff --git a/src/utils.jl b/src/utils.jl index b680999b..f92657cc 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -7,7 +7,7 @@ _indexlength(i::Integer) = Int(i) _indexlength(i::Colon) = Colon() _toaxis(i::Integer) = Base.OneTo(i) -_toaxis(i::OffsetAxis) = i +_toaxis(i) = i _strip_IdOffsetRange(r::IdOffsetRange) = parent(r) _strip_IdOffsetRange(r) = r @@ -113,20 +113,3 @@ _filterreshapeinds(t::Tuple) = _filterreshapeinds(tail(t)) _filterreshapeinds(t::Tuple{}) = t _popreshape(A::AbstractArray, ax::Tuple{Vararg{Base.OneTo}}, inds::Tuple{}) = no_offset_view(A) _popreshape(A::AbstractArray, ax, inds) = A - -# derived from Base._reshape_uncolon -# https://github.com/JuliaLang/julia/blob/d29126a43ee289fc5ab8fcb3dc0e03f514605950/base/reshapedarray.jl#L119-L137 -@inline function _colon_check(dims) - @noinline throw1(dims) = throw(DimensionMismatch(string("new dimensions $(dims) ", - "may have at most one omitted dimension specified by `Colon()`"))) - post = _after_colon(dims...) - _any_colon(post...) && throw1(dims) - nothing -end -@inline _any_colon() = false -@inline _any_colon(dim::Colon, tail...) = true -@inline _any_colon(dim::Any, tail...) = _any_colon(tail...) -# @inline _before_colon(dim::Any, tail...) = (dim, _before_colon(tail...)...) -# @inline _before_colon(dim::Colon, tail...) = () -@inline _after_colon(dim::Any, tail...) = _after_colon(tail...) -@inline _after_colon(dim::Colon, tail...) = tail diff --git a/test/runtests.jl b/test/runtests.jl index 7cf7bb3d..6bde9c27 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1781,6 +1781,19 @@ end # more than one colon is not allowed @test_throws Exception reshape(ones(3:4, 4:5, 1:2), :, :, 2) @test_throws Exception reshape(ones(3:4, 4:5, 1:2), :, 2, :) + + A = OffsetArray(rand(4, 4), -1, -1); + B = reshape(A, (2, :)) + @test axes(B, 1) == 1:2 + @test axes(B, 2) == 1:8 + + # some more exotic vector types + r = OffsetVector(CustomRange(ZeroBasedRange(0:2)), -2) + r2 = reshape(r, :) + @test r2 == r + r2 = reshape(r, 3) + @test axes(r2, 1) == 1:3 + @test r2 == no_offset_view(r) end @testset "permutedims" begin From 9f917603036455e3f133c3d94e42960c24b768e1 Mon Sep 17 00:00:00 2001 From: jishnub Date: Wed, 14 Jul 2021 23:16:00 +0400 Subject: [PATCH 07/10] check compatible sizes --- src/OffsetArrays.jl | 27 ++++++++++++++++++--------- src/utils.jl | 6 ++++++ test/runtests.jl | 8 ++++++++ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/OffsetArrays.jl b/src/OffsetArrays.jl index 5324da03..c2ca7545 100644 --- a/src/OffsetArrays.jl +++ b/src/OffsetArrays.jl @@ -340,30 +340,39 @@ _similar_axes_or_length(AT, ax::I, ::I) where {I} = similar(AT, map(_indexlength # reshape accepts a single colon Base.reshape(A::AbstractArray, inds::OffsetAxis...) = reshape(A, inds) function Base.reshape(A::AbstractArray, inds::Tuple{OffsetAxis,Vararg{OffsetAxis}}) - AR = reshape(A, map(_indexlength, inds)) + AR = reshape(no_offset_view(A), map(_indexlength, inds)) O = OffsetArray(AR, map(_offset, axes(AR), inds)) return _popreshape(O, axes(AR), _filterreshapeinds(inds)) end # Reshaping OffsetArrays can "pop" the original OffsetArray wrapper and return # an OffsetArray(reshape(...)) instead of an OffsetArray(reshape(OffsetArray(...))) -# try to pass on the indices as received to the parent. -# If the parent doesn't define an appropriate method, this will fall back to using the lengths -# Short-circuit the case with matching indices to circumvent the Base restriction to 1-based indices -_reshape(A::AbstractVector, ::Tuple{OffsetAxis}) = A -_reshape(A, inds) = reshape(A, inds) +# Short-circuit for AbstractVectors if the axes are compatible to get around the Base restriction +# to 1-based vectors +function _reshape(A::AbstractVector, inds::Tuple{OffsetAxis}) + @noinline throw_dimerr(ind::Integer) = throw( + DimensionMismatch("parent has $(size(A,1)) elements, which is incompatible with length $ind")) + @noinline throw_dimerr(ind) = throw( + DimensionMismatch("parent has $(size(A,1)) elements, which is incompatible with indices $ind")) + _checksize(first(inds), size(A,1)) || throw_dimerr(first(inds)) + A +end +_reshape(A, inds) = _reshape2(A, inds) +_reshape2(A, inds) = reshape(A, inds) +# avoid a stackoverflow by relegating to the parent if no_offset_view returns an offsetarray +_reshape2(A::OffsetArray, inds) = reshape(parent(A), inds) _reshape_nov(A, inds) = _reshape(no_offset_view(A), inds) Base.reshape(A::OffsetArray, inds::Tuple{OffsetAxis,Vararg{OffsetAxis}}) = OffsetArray(_reshape(parent(A), inds), map(_toaxis, inds)) # And for non-offset axes, we can just return a reshape of the parent directly -Base.reshape(A::OffsetArray, inds::Tuple{Union{Integer,Base.OneTo},Vararg{Union{Integer,Base.OneTo}}}) = _reshape_nov(parent(A), inds) -Base.reshape(A::OffsetArray, inds::Dims) = _reshape_nov(parent(A), inds) +Base.reshape(A::OffsetArray, inds::Tuple{Union{Integer,Base.OneTo},Vararg{Union{Integer,Base.OneTo}}}) = _reshape_nov(A, inds) +Base.reshape(A::OffsetArray, inds::Dims) = _reshape_nov(A, inds) Base.reshape(A::OffsetVector, ::Colon) = A Base.reshape(A::OffsetVector, ::Tuple{Colon}) = A Base.reshape(A::OffsetArray, ::Colon) = reshape(A, (Colon(),)) Base.reshape(A::OffsetArray, inds::Union{Int,Colon}...) = reshape(A, inds) -Base.reshape(A::OffsetArray, inds::Tuple{Vararg{Union{Int,Colon}}}) = _reshape_nov(parent(A), inds) +Base.reshape(A::OffsetArray, inds::Tuple{Vararg{Union{Int,Colon}}}) = _reshape_nov(A, inds) # permutedims in Base does not preserve axes, and can not be fixed in a non-breaking way # This is a stopgap solution diff --git a/src/utils.jl b/src/utils.jl index f92657cc..a803b73a 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -6,6 +6,12 @@ _indexlength(r::AbstractRange) = length(r) _indexlength(i::Integer) = Int(i) _indexlength(i::Colon) = Colon() +# utility methods used in reshape +# we don't use _indexlength in this to avoid converting the arguments to Int +_checksize(ind::Integer, s) = ind == s +_checksize(ind::AbstractUnitRange, s) = length(ind) == s +_checksize(::Colon, s) = true + _toaxis(i::Integer) = Base.OneTo(i) _toaxis(i) = i diff --git a/test/runtests.jl b/test/runtests.jl index 6bde9c27..91d7228e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1794,6 +1794,14 @@ end r2 = reshape(r, 3) @test axes(r2, 1) == 1:3 @test r2 == no_offset_view(r) + @test_throws Exception reshape(r, length(r) + 1) + @test_throws Exception reshape(r, 1:length(r) + 1) + rp = parent(r) + @test axes(reshape(rp, 4:6), 1) == 4:6 + @test axes(reshape(r, (3,1))) == (1:3, 1:1) + # the following is broken if rp doesn't define its own reshape + # we may fix it here but that's perhaps too much type-piracy + @test_broken reshape(rp, length(rp)) end @testset "permutedims" begin From 4699b0594a1181b26aa69cc5edb6c28a6d0eddbd Mon Sep 17 00:00:00 2001 From: jishnub Date: Thu, 15 Jul 2021 13:39:39 +0400 Subject: [PATCH 08/10] Add length for CustomRange in tests --- test/customranges.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/customranges.jl b/test/customranges.jl index d3baf0c6..9da30b86 100644 --- a/test/customranges.jl +++ b/test/customranges.jl @@ -79,6 +79,7 @@ struct CustomRange{T,A<:AbstractRange{T}} <: AbstractRange{T} end Base.parent(r::CustomRange) = r.a Base.size(r::CustomRange) = size(parent(r)) +Base.length(r::CustomRange) = length(parent(r)) Base.axes(r::CustomRange) = axes(parent(r)) Base.first(r::CustomRange) = first(parent(r)) Base.last(r::CustomRange) = last(parent(r)) From 2e829279ce2127b3bc32a05280c4098a66f8f59b Mon Sep 17 00:00:00 2001 From: jishnub Date: Thu, 15 Jul 2021 13:43:13 +0400 Subject: [PATCH 09/10] remove broken test for non-offsetarray type --- test/runtests.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 91d7228e..5f65eab1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1799,9 +1799,6 @@ end rp = parent(r) @test axes(reshape(rp, 4:6), 1) == 4:6 @test axes(reshape(r, (3,1))) == (1:3, 1:1) - # the following is broken if rp doesn't define its own reshape - # we may fix it here but that's perhaps too much type-piracy - @test_broken reshape(rp, length(rp)) end @testset "permutedims" begin From 4aef07c84b8124c2ecfa1520cf7abddab981effd Mon Sep 17 00:00:00 2001 From: jishnub Date: Thu, 15 Jul 2021 14:07:49 +0400 Subject: [PATCH 10/10] remove unnecessary method --- src/utils.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index a803b73a..0d5bcfb5 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -10,7 +10,6 @@ _indexlength(i::Colon) = Colon() # we don't use _indexlength in this to avoid converting the arguments to Int _checksize(ind::Integer, s) = ind == s _checksize(ind::AbstractUnitRange, s) = length(ind) == s -_checksize(::Colon, s) = true _toaxis(i::Integer) = Base.OneTo(i) _toaxis(i) = i