diff --git a/README.md b/README.md index 8bf9aff78..4d2a0cc5f 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `range` supporting `stop` as positional argument ([#28708]). -* `selectdim` to obtain a view of an array with a specified index for a specified dimension ([#26009]). - * Single-argument `permutedims(x)` for matrices and vectors ([#24839]). * `fetch` for `Task`s ([#25940]). diff --git a/src/Compat.jl b/src/Compat.jl index 1342de441..453ad5418 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,17 +76,6 @@ end end end -if !isdefined(Base, :selectdim) # 0.7.0-DEV.3976 - export selectdim - @inline selectdim(A::AbstractArray, d::Integer, i) = _selectdim(A, d, i, Base.setindex(map(Base.Slice, axes(A)), i, d)) - @noinline function _selectdim(A, d, i, idxs) - d >= 1 || throw(ArgumentError("dimension must be ≥ 1")) - nd = ndims(A) - d > nd && (i == 1 || throw(BoundsError(A, (ntuple(k->Colon(),d-1)..., i)))) - return view(A, idxs...) - end -end - if VERSION < v"0.7.0-DEV.3977" #26039 Base.repeat(A::AbstractArray, counts::Integer...) = Base.repeat(A, outer = counts) Base.repeat(a::AbstractVecOrMat, m::Integer, n::Integer=1) = Base.repmat(a, m, n) diff --git a/test/old.jl b/test/old.jl index daed1615c..ca356cd7f 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1031,3 +1031,17 @@ end if VERSION < v"0.7.0-DEV.5165" @test_throws UndefKeywordError Compat.cat([1, 2], [3, 4]) end + +# 0.7.0-DEV.3976 +let A = rand(5,5) + @test selectdim(A, 1, 3) == A[3, :] + @test selectdim(A, 1, 1:3) == A[1:3, :] + @test selectdim(A, 2, 3) == A[:, 3] + @test selectdim(A, 2, 1:3) == A[:, 1:3] + selectdim(A, 1, 3)[3] = 42 + @test A[3,3] == 42 + B = rand(4, 3, 2) + @test IndexStyle(selectdim(B, 1, 1)) == IndexStyle(view(B, 1, :, :)) == IndexLinear() + @test IndexStyle(selectdim(B, 2, 1)) == IndexStyle(view(B, :, 1, :)) == IndexCartesian() + @test IndexStyle(selectdim(B, 3, 1)) == IndexStyle(view(B, :, :, 1)) == IndexLinear() +end diff --git a/test/runtests.jl b/test/runtests.jl index b7740a849..a67f6cc8b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,23 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3976 -let A = rand(5,5) - @test selectdim(A, 1, 3) == A[3, :] - @test selectdim(A, 1, 1:3) == A[1:3, :] - @test selectdim(A, 2, 3) == A[:, 3] - @test selectdim(A, 2, 1:3) == A[:, 1:3] - selectdim(A, 1, 3)[3] = 42 - @test A[3,3] == 42 - if VERSION < v"0.7.0-DEV.3976" || VERSION >= v"0.7.0-DEV.4739" - # in the omitted version range, Julia's selectdim always gives IndexCartesian() - B = rand(4, 3, 2) - @test IndexStyle(selectdim(B, 1, 1)) == IndexStyle(view(B, 1, :, :)) == IndexLinear() - @test IndexStyle(selectdim(B, 2, 1)) == IndexStyle(view(B, :, 1, :)) == IndexCartesian() - @test IndexStyle(selectdim(B, 3, 1)) == IndexStyle(view(B, :, :, 1)) == IndexLinear() - end -end - # 0.7.0-DEV.843 / 0.7.0-DEV.2337 let A = [1 2; 1 2; 1 2] if VERSION < v"0.7.0-DEV.5211"