Skip to content

Commit fe61993

Browse files
authored
Merge pull request #98 from invenia/pointsix-upgrade
Remove support for 0.5 and drop Compat
2 parents edd8884 + a63dc97 commit fe61993

10 files changed

+28
-89
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ os:
33
- linux
44
- osx
55
julia:
6-
- 0.5
76
- 0.6
87
- nightly
98
notifications:

REQUIRE

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
julia 0.5
1+
julia 0.6
22
IntervalSets 0.1
33
RangeArrays
4-
Compat 0.19

src/AxisArrays.jl

-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ module AxisArrays
44

55
using Base: tail
66
using RangeArrays, IntervalSets
7-
using Compat
87

98
export AxisArray, Axis, axisnames, axisvalues, axisdim, axes, atindex, atvalue
109

1110
# From IntervalSets:
1211
export ClosedInterval, ..
13-
Base.@deprecate_binding Interval ClosedInterval
1412

1513
include("core.jl")
1614
include("intervals.jl")

src/core.jl

+3-8
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,8 @@ end
293293
# Note that we only extend the following two methods, and then have it
294294
# dispatch to package-local `reduced_indices` and `reduced_indices0`
295295
# methods. This avoids a whole slew of ambiguities.
296-
if VERSION == v"0.5.0"
297-
Base.reduced_dims(A::AxisArray, region) = reduced_indices(axes(A), region)
298-
Base.reduced_dims0(A::AxisArray, region) = reduced_indices0(axes(A), region)
299-
else
300-
Base.reduced_indices(A::AxisArray, region) = reduced_indices(axes(A), region)
301-
Base.reduced_indices0(A::AxisArray, region) = reduced_indices0(axes(A), region)
302-
end
296+
Base.reduced_indices(A::AxisArray, region) = reduced_indices(axes(A), region)
297+
Base.reduced_indices0(A::AxisArray, region) = reduced_indices0(axes(A), region)
303298

304299
reduced_indices{N}(axs::Tuple{Vararg{Axis,N}}, ::Tuple{}) = axs
305300
reduced_indices0{N}(axs::Tuple{Vararg{Axis,N}}, ::Tuple{}) = axs
@@ -509,7 +504,7 @@ axes(A::AbstractArray) = default_axes(A)
509504
axes(A::AbstractArray, dim::Int) = default_axes(A)[dim]
510505

511506
### Axis traits ###
512-
@compat abstract type AxisTrait end
507+
abstract type AxisTrait end
513508
immutable Dimensional <: AxisTrait end
514509
immutable Categorical <: AxisTrait end
515510
immutable Unsupported <: AxisTrait end

src/indexing.jl

+9-39
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Base.show(io::IO, v::Value) =
2020
print(io, string("Value(", v.val, ", tol=", v.tol, ")"))
2121

2222
# Defer IndexStyle to the wrapped array
23-
@compat Base.IndexStyle{T,N,D,Ax}(::Type{AxisArray{T,N,D,Ax}}) = IndexStyle(D)
23+
Base.IndexStyle{T,N,D,Ax}(::Type{AxisArray{T,N,D,Ax}}) = IndexStyle(D)
2424

2525
# Simple scalar indexing where we just set or return scalars
2626
@propagate_inbounds Base.getindex(A::AxisArray, idxs::Int...) = A.data[idxs...]
@@ -55,7 +55,7 @@ reaxis(A::AxisArray, I::Idx...) = _reaxis(make_axes_match(axes(A), I), I)
5555
# Now we can reaxis without worrying about mismatched axes/indices
5656
@inline _reaxis(axs::Tuple{}, idxs::Tuple{}) = ()
5757
# Scalars are dropped
58-
const ScalarIndex = @compat Union{Real, AbstractArray{<:Any, 0}}
58+
const ScalarIndex = Union{Real, AbstractArray{<:Any, 0}}
5959
@inline _reaxis(axs::Tuple, idxs::Tuple{ScalarIndex, Vararg{Any}}) = _reaxis(tail(axs), tail(idxs))
6060
# Colon passes straight through
6161
@inline _reaxis(axs::Tuple, idxs::Tuple{Colon, Vararg{Any}}) = (axs[1], _reaxis(tail(axs), tail(idxs))...)
@@ -66,15 +66,15 @@ const ScalarIndex = @compat Union{Real, AbstractArray{<:Any, 0}}
6666
# Vectors simply create new axes with the same name; just subsetted by their value
6767
@inline _new_axes{name}(ax::Axis{name}, idx::AbstractVector) = (Axis{name}(ax.val[idx]),)
6868
# Arrays create multiple axes with _N appended to the axis name containing their indices
69-
@generated function _new_axes{name, N}(ax::Axis{name}, idx::@compat(AbstractArray{<:Any,N}))
69+
@generated function _new_axes{name, N}(ax::Axis{name}, idx::AbstractArray{<:Any,N})
7070
newaxes = Expr(:tuple)
7171
for i=1:N
7272
push!(newaxes.args, :($(Axis{Symbol(name, "_", i)})(indices(idx, $i))))
7373
end
7474
newaxes
7575
end
7676
# And indexing with an AxisArray joins the name and overrides the values
77-
@generated function _new_axes{name, N}(ax::Axis{name}, idx::@compat(AxisArray{<:Any, N}))
77+
@generated function _new_axes{name, N}(ax::Axis{name}, idx::AxisArray{<:Any, N})
7878
newaxes = Expr(:tuple)
7979
idxnames = axisnames(idx)
8080
for i=1:N
@@ -88,21 +88,8 @@ end
8888
end
8989

9090
# To resolve ambiguities, we need several definitions
91-
if VERSION >= v"0.6.0-dev.672"
92-
using Base.AbstractCartesianIndex
93-
@propagate_inbounds Base.view(A::AxisArray, idxs::Idx...) = AxisArray(view(A.data, idxs...), reaxis(A, idxs...))
94-
else
95-
@propagate_inbounds function Base.view{T,N}(A::AxisArray{T,N}, idxs::Vararg{Idx,N})
96-
AxisArray(view(A.data, idxs...), reaxis(A, idxs...))
97-
end
98-
@propagate_inbounds function Base.view(A::AxisArray, idx::Idx)
99-
AxisArray(view(A.data, idx), reaxis(A, idx))
100-
end
101-
@propagate_inbounds function Base.view{N}(A::AxisArray, idxs::Vararg{Idx,N})
102-
# this should eventually be deleted, see julia #14770
103-
AxisArray(view(A.data, idxs...), reaxis(A, idxs...))
104-
end
105-
end
91+
using Base.AbstractCartesianIndex
92+
@propagate_inbounds Base.view(A::AxisArray, idxs::Idx...) = AxisArray(view(A.data, idxs...), reaxis(A, idxs...))
10693

10794
# Setindex is so much simpler. Just assign it to the data:
10895
@propagate_inbounds Base.setindex!(A::AxisArray, v, idxs::Idx...) = (A.data[idxs...] = v)
@@ -111,26 +98,9 @@ end
11198
@propagate_inbounds Base.getindex(A::AxisArray, idxs...) = A[to_index(A,idxs...)...]
11299
@propagate_inbounds Base.setindex!(A::AxisArray, v, idxs...) = (A[to_index(A,idxs...)...] = v)
113100
# Deal with lots of ambiguities here
114-
if VERSION >= v"0.6.0-dev.672"
115-
@propagate_inbounds Base.view(A::AxisArray, idxs::ViewIndex...) = view(A, to_index(A,idxs...)...)
116-
@propagate_inbounds Base.view(A::AxisArray, idxs::Union{ViewIndex,AbstractCartesianIndex}...) = view(A, to_index(A,Base.IteratorsMD.flatten(idxs)...)...)
117-
@propagate_inbounds Base.view(A::AxisArray, idxs...) = view(A, to_index(A,idxs...)...)
118-
else
119-
for T in (:ViewIndex, :Any)
120-
@eval begin
121-
@propagate_inbounds function Base.view{T,N}(A::AxisArray{T,N}, idxs::Vararg{$T,N})
122-
view(A, to_index(A,idxs...)...)
123-
end
124-
@propagate_inbounds function Base.view(A::AxisArray, idx::$T)
125-
view(A, to_index(A,idx)...)
126-
end
127-
@propagate_inbounds function Base.view{N}(A::AxisArray, idsx::Vararg{$T,N})
128-
# this should eventually be deleted, see julia #14770
129-
view(A, to_index(A,idxs...)...)
130-
end
131-
end
132-
end
133-
end
101+
@propagate_inbounds Base.view(A::AxisArray, idxs::ViewIndex...) = view(A, to_index(A,idxs...)...)
102+
@propagate_inbounds Base.view(A::AxisArray, idxs::Union{ViewIndex,AbstractCartesianIndex}...) = view(A, to_index(A,Base.IteratorsMD.flatten(idxs)...)...)
103+
@propagate_inbounds Base.view(A::AxisArray, idxs...) = view(A, to_index(A,idxs...)...)
134104

135105
# First is indexing by named axis. We simply sort the axes and re-dispatch.
136106
# When indexing by named axis the shapes of omitted dimensions are preserved

src/intervals.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ immutable RepeatedInterval{T,S,A} <: AbstractVector{T}
6161
end
6262
RepeatedInterval{S,A<:AbstractVector}(window::ClosedInterval{S}, offsets::A) = RepeatedInterval{promote_type(ClosedInterval{S}, eltype(A)), S, A}(window, offsets)
6363
Base.size(r::RepeatedInterval) = size(r.offsets)
64-
@compat Base.IndexStyle(::Type{<:RepeatedInterval}) = IndexLinear()
64+
Base.IndexStyle(::Type{<:RepeatedInterval}) = IndexLinear()
6565
Base.getindex(r::RepeatedInterval, i::Int) = r.window + r.offsets[i]
6666
+(window::ClosedInterval, offsets::AbstractVector) = RepeatedInterval(window, offsets)
6767
+(offsets::AbstractVector, window::ClosedInterval) = RepeatedInterval(window, offsets)
@@ -83,5 +83,5 @@ immutable RepeatedIntervalAtIndexes{T,A<:AbstractVector{Int}} <: AbstractVector{
8383
end
8484
atindex(window::ClosedInterval, indexes::AbstractVector) = RepeatedIntervalAtIndexes(window, indexes)
8585
Base.size(r::RepeatedIntervalAtIndexes) = size(r.indexes)
86-
@compat Base.IndexStyle(::Type{<:RepeatedIntervalAtIndexes}) = IndexLinear()
86+
Base.IndexStyle(::Type{<:RepeatedIntervalAtIndexes}) = IndexLinear()
8787
Base.getindex(r::RepeatedIntervalAtIndexes, i::Int) = IntervalAtIndex(r.window, r.indexes[i])

src/search.jl

+4-17
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,10 @@ end
4545
st = oftype(f, f + (first(s)-1)*step(r))
4646
range(st, step(r)*step(s), length(s))
4747
end
48-
if VERSION < v"0.6.0-dev.2390"
49-
include_string("""
50-
@inline function inbounds_getindex{T}(r::FloatRange{T}, i::Integer)
51-
convert(T, (r.start + (i-1)*r.step)/r.divisor)
52-
end
53-
@inline function inbounds_getindex(r::FloatRange, s::OrdinalRange)
54-
FloatRange(r.start + (first(s)-1)*r.step, step(s)*r.step, length(s), r.divisor)
55-
end
56-
""")
57-
else
58-
include_string("""
59-
@inline inbounds_getindex(r::StepRangeLen, i::Integer) = Base.unsafe_getindex(r, i)
60-
@inline function inbounds_getindex(r::StepRangeLen, s::OrdinalRange)
61-
vfirst = Base.unsafe_getindex(r, first(s))
62-
StepRangeLen(vfirst, step(r)*step(s), length(s))
63-
end
64-
""")
48+
@inline inbounds_getindex(r::StepRangeLen, i::Integer) = Base.unsafe_getindex(r, i)
49+
@inline function inbounds_getindex(r::StepRangeLen, s::OrdinalRange)
50+
vfirst = Base.unsafe_getindex(r, first(s))
51+
StepRangeLen(vfirst, step(r)*step(s), length(s))
6552
end
6653

6754
function unsafe_searchsortedlast{T<:Number}(a::Range{T}, x::Number)

test/core.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -82,34 +82,34 @@ H = similar(A, Float64, 1,1,1)
8282
A = AxisArray(1:3)
8383
@test A.data == 1:3
8484
@test axisnames(A) == (:row,)
85-
VERSION >= v"0.5.0-dev" && @inferred(axisnames(A))
85+
@inferred(axisnames(A))
8686
@test axisvalues(A) == (1:3,)
8787
A = AxisArray(reshape(1:16, 2,2,2,2))
8888
@test A.data == reshape(1:16, 2,2,2,2)
8989
@test axisnames(A) == (:row,:col,:page,:dim_4)
90-
VERSION >= v"0.5.0-dev" && @inferred(axisnames(A))
90+
@inferred(axisnames(A))
9191
@test axisvalues(A) == (1:2, 1:2, 1:2, 1:2)
9292
# Just axis names
9393
A = AxisArray(1:3, :a)
9494
@test A.data == 1:3
9595
@test axisnames(A) == (:a,)
96-
VERSION >= v"0.5.0-dev" && @inferred(axisnames(A))
96+
@inferred(axisnames(A))
9797
@test axisvalues(A) == (1:3,)
9898
A = AxisArray([1 3; 2 4], :a)
9999
@test A.data == [1 3; 2 4]
100100
@test axisnames(A) == (:a, :col)
101-
VERSION >= v"0.5.0-dev" && @inferred(axisnames(A))
101+
@inferred(axisnames(A))
102102
@test axisvalues(A) == (1:2, 1:2)
103103
# Just axis values
104104
A = @inferred(AxisArray(1:3, .1:.1:.3))
105105
@test A.data == 1:3
106106
@test axisnames(A) == (:row,)
107-
VERSION >= v"0.5.0-dev" && @inferred(axisnames(A))
107+
@inferred(axisnames(A))
108108
@test axisvalues(A) == (.1:.1:.3,)
109109
A = @inferred(AxisArray(reshape(1:16, 2,2,2,2), .5:.5:1))
110110
@test A.data == reshape(1:16, 2,2,2,2)
111111
@test axisnames(A) == (:row,:col,:page,:dim_4)
112-
VERSION >= v"0.5.0-dev" && @inferred(axisnames(A))
112+
@inferred(axisnames(A))
113113
@test axisvalues(A) == (.5:.5:1, 1:2, 1:2, 1:2)
114114
A = AxisArray([0]', :x, :y)
115115
@test axisnames(squeeze(A, 1)) == (:y,)

test/indexing.jl

+2-8
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ D[1,1,1,1,1] = 10
3939
# Linear indexing across multiple dimensions drops tracking of those dims
4040
@test A[:].axes[1].val == 1:length(A)
4141
# TODO: remove the next 4 lines when we no longer feel we need to test for this
42-
VERSION >= v"0.6.0-dev" && info("partial linear indexing deprecation warning is expected")
42+
info("partial linear indexing deprecation warning is expected")
4343
B = A[1:2,:]
4444
@test B.axes[1].val == A.axes[1].val[1:2]
4545
@test B.axes[2].val == 1:Base.trailingsize(A,2)
@@ -193,10 +193,4 @@ A = AxisArray(OffsetArrays.OffsetArray([1 2; 3 4], 0:1, 1:2),
193193
@test_throws ArgumentError A[4.0]
194194
@test_throws ArgumentError A[BigFloat(1.0)]
195195
@test_throws ArgumentError A[1.0f0]
196-
if VERSION == v"0.5.2"
197-
# Cannot compose @test_broken with @test_throws (Julia #21098)
198-
# A[:,6.1] incorrectly throws a BoundsError instead of an ArgumentError on Julia 0.5.2
199-
@test_broken A[:,6.1]
200-
else
201-
@test_throws ArgumentError A[:,6.1]
202-
end
196+
@test_throws ArgumentError A[:,6.1]

test/runtests.jl

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ using AxisArrays
22
using Base.Test
33

44
@testset "AxisArrays" begin
5-
# during this time there was an ambiguity in base with checkbounds_linear_indices
6-
if VERSION < v"0.6.0-dev.2374" || VERSION >= v"0.6.0-dev.2884"
7-
@test isempty(detect_ambiguities(AxisArrays, Base, Core))
8-
end
5+
@test isempty(detect_ambiguities(AxisArrays, Base, Core))
96

107
@testset "Core" begin
118
include("core.jl")

0 commit comments

Comments
 (0)