Skip to content

Commit

Permalink
Drop compat code for selectdim from #522 and #531
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Oct 8, 2019
1 parent 84c459f commit 52c6ed7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]).
Expand Down
11 changes: 0 additions & 11 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions test/old.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1026,3 +1026,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
17 changes: 0 additions & 17 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,6 @@ end
@test length(Compat.CartesianIndices((1:2,))) == 2
@test length(Compat.CartesianIndices((1:2, -1:1))) == 6

# 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"
Expand Down

0 comments on commit 52c6ed7

Please sign in to comment.