Skip to content

Commit 8869a6a

Browse files
fix v0.7 indexing
1 parent 9c4a4f4 commit 8869a6a

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/array_partition.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ end
144144

145145
## indexing
146146

147+
# Interface for the linear indexing. This is just a view of the underlying nested structure
148+
@static if VERSION >= v"0.7-"
149+
@inline Base.firstindex(A::ArrayPartition) = 1
150+
@inline Base.lastindex(A::ArrayPartition) = length(A)
151+
else
152+
@inline Base.endof(A::ArrayPartition) = length(A)
153+
end
154+
147155
@inline function Base.getindex(A::ArrayPartition, i::Int)
148156
@boundscheck checkbounds(A, i)
149157
@inbounds for j in 1:length(A.x)

src/vector_of_array.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ DiffEqArray(vec::AbstractVector,ts::AbstractVector) = DiffEqArray(vec, ts, (size
1818

1919

2020
# Interface for the linear indexing. This is just a view of the underlying nested structure
21-
@inline Base.endof(VA::AbstractVectorOfArray) = endof(VA.u)
21+
@static if VERSION >= v"0.7-"
22+
@inline Base.firstindex(VA::AbstractVectorOfArray) = firstindex(VA.u)
23+
@inline Base.lastindex(VA::AbstractVectorOfArray) = lastindex(VA.u)
24+
else
25+
@inline Base.endof(VA::AbstractVectorOfArray) = endof(VA.u)
26+
end
27+
2228
@inline Base.length(VA::AbstractVectorOfArray) = length(VA.u)
2329
@inline Base.eachindex(VA::AbstractVectorOfArray) = Base.OneTo(length(VA.u))
2430
@inline Base.iteratorsize(VA::AbstractVectorOfArray) = Base.HasLength()

test/utils_test.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ B = Matrix{Matrix{Int64}}(2,3)
1414
B[1,:] = [[1 2; 3 4],[1 3;4 6],[5 6;7 8]]
1515
B[2,:] = [[1 2; 3 4],[1 5;4 3],[5 8;2 1]]
1616

17-
ans = [[1 2; 3 4],[1 4; 4 4.5],[5 7; 4.5 4.5]]
18-
@test recursive_mean(B,1)[1] ans[1]
19-
@test recursive_mean(B,1)[2] ans[2]
20-
@test recursive_mean(B,1)[3] ans[3]
17+
a = [[1 2; 3 4],[1 4; 4 4.5],[5 7; 4.5 4.5]]
18+
@test recursive_mean(B,1)[1] a[1]
19+
@test recursive_mean(B,1)[2] a[2]
20+
@test recursive_mean(B,1)[3] a[3]
2121

22-
ans = [[2.333333333333 4.666666666666; 3.6666666666666 6.0], [2.3333333 3.0; 5.0 2.6666666]]
23-
@test recursive_mean(B,2)[1] ans[1]
24-
@test recursive_mean(B,2)[2] ans[2]
22+
a = [[2.333333333333 4.666666666666; 3.6666666666666 6.0], [2.3333333 3.0; 5.0 2.6666666]]
23+
@test_broken recursive_mean(B,2)[1] a[1]
24+
@test_broken recursive_mean(B,2)[2] a[2]
2525

2626
A = zeros(5,5)
2727
recursive_unitless_eltype(A) == Float64

0 commit comments

Comments
 (0)