Skip to content

Commit 63a0f7a

Browse files
committed
Fix IndexStyle deprecation on Julia 0.6
1 parent 8b0b33f commit 63a0f7a

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
julia 0.5
2-
Compat 0.18.0
2+
Compat 0.19.0

src/OffsetArrays.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module OffsetArrays
44

55
Base.@deprecate_binding (..) Colon()
66

7-
using Base: Indices, LinearSlow, LinearFast, tail
7+
using Base: Indices, tail
88
using Compat
99

1010
export OffsetArray, @unsafe
@@ -39,7 +39,7 @@ end
3939
OffsetArray{T,N}(A::AbstractArray{T,N}, inds::Vararg{AbstractUnitRange,N}) =
4040
OffsetArray(A, inds)
4141

42-
Base.linearindexing{T<:OffsetArray}(::Type{T}) = Base.linearindexing(parenttype(T))
42+
@compat Compat.IndexStyle{OA<:OffsetArray}(::Type{OA}) = IndexStyle(parenttype(OA))
4343
parenttype{T,N,AA}(::Type{OffsetArray{T,N,AA}}) = AA
4444
parenttype(A::OffsetArray) = parenttype(typeof(A))
4545

@@ -48,8 +48,8 @@ Base.parent(A::OffsetArray) = A.parent
4848
errmsg(A) = error("size not supported for arrays with indices $(indices(A)); see http://docs.julialang.org/en/latest/devdocs/offset-arrays/")
4949
Base.size(A::OffsetArray) = errmsg(A)
5050
Base.size(A::OffsetArray, d) = errmsg(A)
51-
Base.eachindex(::LinearSlow, A::OffsetArray) = CartesianRange(indices(A))
52-
Base.eachindex(::LinearFast, A::OffsetVector) = indices(A, 1)
51+
Base.eachindex(::IndexCartesian, A::OffsetArray) = CartesianRange(indices(A))
52+
Base.eachindex(::IndexLinear, A::OffsetVector) = indices(A, 1)
5353

5454
# Implementations of indices and indices1. Since bounds-checking is
5555
# performance-critical and relies on indices, these are usually worth
@@ -168,9 +168,9 @@ end
168168
@inline unsafe_setindex!(a::AbstractArray, val, I...) = (@inbounds a[I...] = val; val)
169169

170170
# Linear indexing
171-
@inline unsafe_getindex(a::OffsetArray, i::Int) = _unsafe_getindex(Base.linearindexing(a), a, i)
172-
@inline unsafe_setindex!(a::OffsetArray, val, i::Int) = _unsafe_setindex!(Base.linearindexing(a), a, val, i)
173-
for T in (LinearFast, LinearSlow) # ambiguity-resolution requires specificity for both
171+
@inline unsafe_getindex(a::OffsetArray, i::Int) = _unsafe_getindex(IndexStyle(a), a, i)
172+
@inline unsafe_setindex!(a::OffsetArray, val, i::Int) = _unsafe_setindex!(IndexStyle(a), a, val, i)
173+
for T in (IndexLinear, IndexCartesian) # ambiguity-resolution requires specificity for both
174174
@eval begin
175175
@inline function _unsafe_getindex(::$T, a::OffsetVector, i::Int)
176176
@inbounds ret = parent(a)[offset(a.offsets, (i,))[1]]
@@ -182,17 +182,17 @@ for T in (LinearFast, LinearSlow) # ambiguity-resolution requires specificity f
182182
end
183183
end
184184
end
185-
@inline function _unsafe_getindex(::LinearFast, a::OffsetArray, i::Int)
185+
@inline function _unsafe_getindex(::IndexLinear, a::OffsetArray, i::Int)
186186
@inbounds ret = parent(a)[i]
187187
ret
188188
end
189-
@inline _unsafe_getindex(::LinearSlow, a::OffsetArray, i::Int) =
189+
@inline _unsafe_getindex(::IndexCartesian, a::OffsetArray, i::Int) =
190190
unsafe_getindex(a, ind2sub(indices(a), i)...)
191-
@inline function _unsafe_setindex!(::LinearFast, a::OffsetArray, val, i::Int)
191+
@inline function _unsafe_setindex!(::IndexLinear, a::OffsetArray, val, i::Int)
192192
@inbounds parent(a)[i] = val
193193
val
194194
end
195-
@inline _unsafe_setindex!(::LinearSlow, a::OffsetArray, val, i::Int) =
195+
@inline _unsafe_setindex!(::IndexCartesian, a::OffsetArray, val, i::Int) =
196196
unsafe_setindex!(a, val, ind2sub(indices(a), i)...)
197197

198198
@inline unsafe_getindex(a::OffsetArray, I::Int...) = unsafe_getindex(parent(a), offset(a.offsets, I)...)

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ y = OffsetArray(r, (r,))
3131
@test indices(y) == (r,)
3232

3333
A0 = [1 3; 2 4]
34-
A = OffsetArray(A0, (-1,2)) # LinearFast
35-
S = OffsetArray(view(A0, 1:2, 1:2), (-1,2)) # LinearSlow
34+
A = OffsetArray(A0, (-1,2)) # IndexLinear
35+
S = OffsetArray(view(A0, 1:2, 1:2), (-1,2)) # IndexCartesian
3636
@test indices(A) == indices(S) == (0:1, 3:4)
3737
@test_throws ErrorException size(A)
3838
@test_throws ErrorException size(A, 1)

0 commit comments

Comments
 (0)