Skip to content

Commit 5f20d54

Browse files
Merge pull request #27 from JuliaDiffEq/fbot/deps
Fix deprecations
2 parents a20b41e + 7e2528b commit 5f20d54

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

src/utils.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ https://github.com/JuliaDiffEq/RecursiveArrayTools.jl/issues/19.
77
Base.@pure is_mutable_type(x::DataType) = x.mutable
88

99

10-
function recursivecopy{T<:Number,N}(a::AbstractArray{T,N})
10+
function recursivecopy(a::AbstractArray{T,N}) where {T<:Number,N}
1111
copy(a)
1212
end
1313

14-
function recursivecopy{T<:AbstractArray,N}(a::AbstractArray{T,N})
14+
function recursivecopy(a::AbstractArray{T,N}) where {T<:AbstractArray,N}
1515
[recursivecopy(x) for x in a]
1616
end
1717

18-
function recursivecopy!{T<:StaticArray,T2<:StaticArray,N}(b::AbstractArray{T,N},a::AbstractArray{T2,N})
18+
function recursivecopy!(b::AbstractArray{T,N},a::AbstractArray{T2,N}) where {T<:StaticArray,T2<:StaticArray,N}
1919
@inbounds for i in eachindex(a)
2020
# TODO: Check for `setindex!`` and use `copy!(b[i],a[i])` or `b[i] = a[i]`, see #19
2121
b[i] = copy(a[i])
2222
end
2323
end
2424

25-
function recursivecopy!{T<:Number,T2<:Number,N}(b::AbstractArray{T,N},a::AbstractArray{T2,N})
25+
function recursivecopy!(b::AbstractArray{T,N},a::AbstractArray{T2,N}) where {T<:Number,T2<:Number,N}
2626
copy!(b,a)
2727
end
2828

29-
function recursivecopy!{T<:AbstractArray,T2<:AbstractArray,N}(b::AbstractArray{T,N},a::AbstractArray{T2,N})
29+
function recursivecopy!(b::AbstractArray{T,N},a::AbstractArray{T2,N}) where {T<:AbstractArray,T2<:AbstractArray,N}
3030
@inbounds for i in eachindex(a)
3131
recursivecopy!(b[i],a[i])
3232
end
@@ -51,15 +51,15 @@ function vecvecapply(f,v)
5151
f(sol)
5252
end
5353

54-
function vecvecapply{T<:Number}(f,v::Array{T})
54+
function vecvecapply(f,v::Array{T}) where T<:Number
5555
f(v)
5656
end
5757

58-
function vecvecapply{T<:Number}(f,v::T)
58+
function vecvecapply(f,v::T) where T<:Number
5959
f(v)
6060
end
6161

62-
@inline function copyat_or_push!{T,perform_copy}(a::AbstractVector{T},i::Int,x,nc::Type{Val{perform_copy}}=Val{true})
62+
@inline function copyat_or_push!(a::AbstractVector{T},i::Int,x,nc::Type{Val{perform_copy}}=Val{true}) where {T,perform_copy}
6363
@inbounds if length(a) >= i
6464
if T <: Number || T <: SArray || (T <: FieldVector && !is_mutable_type(T)) || !perform_copy
6565
# TODO: Check for `setindex!`` if T <: StaticArray and use `copy!(b[i],a[i])`
@@ -90,21 +90,21 @@ end
9090
end
9191

9292
recursive_one(a) = recursive_one(a[1])
93-
recursive_one{T<:Number}(a::T) = one(a)
93+
recursive_one(a::T) where {T<:Number} = one(a)
9494

9595
recursive_eltype(a) = recursive_eltype(eltype(a))
96-
recursive_eltype{T<:Number}(a::Type{T}) = eltype(a)
96+
recursive_eltype(a::Type{T}) where {T<:Number} = eltype(a)
9797

9898
recursive_mean(x...) = mean(x...)
99-
function recursive_mean{T<:AbstractArray}(vecvec::Vector{T})
99+
function recursive_mean(vecvec::Vector{T}) where T<:AbstractArray
100100
out = zeros(vecvec[1])
101101
for i in eachindex(vecvec)
102102
out+= vecvec[i]
103103
end
104104
out/length(vecvec)
105105
end
106106

107-
function recursive_mean{T<:AbstractArray}(matarr::Matrix{T},region=0)
107+
function recursive_mean(matarr::Matrix{T},region=0) where T<:AbstractArray
108108
if region == 0
109109
return recursive_mean(vec(matarr))
110110
elseif region == 1
@@ -122,7 +122,7 @@ end
122122
# From Iterators.jl. Moved here since Iterators.jl is not precompile safe anymore.
123123

124124
# Concatenate the output of n iterators
125-
immutable Chain{T<:Tuple}
125+
struct Chain{T<:Tuple}
126126
xss::T
127127
end
128128

@@ -149,7 +149,7 @@ chain(xss...) = Chain(xss)
149149
Base.length(it::Chain{Tuple{}}) = 0
150150
Base.length(it::Chain) = sum(length, it.xss)
151151

152-
Base.eltype{T}(::Type{Chain{T}}) = typejoin([eltype(t) for t in T.parameters]...)
152+
Base.eltype(::Type{Chain{T}}) where {T} = typejoin([eltype(t) for t in T.parameters]...)
153153

154154
function Base.start(it::Chain)
155155
i = 1

src/vector_of_array.jl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Based on code from M. Bauman Stackexchange answer + Gitter discussion
2-
type VectorOfArray{T, N, A} <: AbstractVectorOfArray{T, N}
2+
mutable struct VectorOfArray{T, N, A} <: AbstractVectorOfArray{T, N}
33
u::A # A <: AbstractVector{<: AbstractArray{T, N - 1}}
44
end
55
# VectorOfArray with an added series for time
6-
type DiffEqArray{T, N, A, B} <: AbstractDiffEqArray{T, N}
6+
mutable struct DiffEqArray{T, N, A, B} <: AbstractDiffEqArray{T, N}
77
u::A # A <: AbstractVector{<: AbstractArray{T, N - 1}}
88
t::B
99
end
1010

11-
VectorOfArray{T, N}(vec::AbstractVector{T}, dims::NTuple{N}) = VectorOfArray{eltype(T), N, typeof(vec)}(vec)
11+
VectorOfArray(vec::AbstractVector{T}, dims::NTuple{N}) where {T, N} = VectorOfArray{eltype(T), N, typeof(vec)}(vec)
1212
# Assume that the first element is representative all all other elements
1313
VectorOfArray(vec::AbstractVector) = VectorOfArray(vec, (size(vec[1])..., length(vec)))
1414

15-
DiffEqArray{T, N}(vec::AbstractVector{T}, ts, dims::NTuple{N}) = DiffEqArray{eltype(T), N, typeof(vec), typeof(ts)}(vec, ts)
15+
DiffEqArray(vec::AbstractVector{T}, ts, dims::NTuple{N}) where {T, N} = DiffEqArray{eltype(T), N, typeof(vec), typeof(ts)}(vec, ts)
1616
# Assume that the first element is representative all all other elements
1717
DiffEqArray(vec::AbstractVector,ts::AbstractVector) = DiffEqArray(vec, ts, (size(vec[1])..., length(vec)))
1818

@@ -24,38 +24,38 @@ DiffEqArray(vec::AbstractVector,ts::AbstractVector) = DiffEqArray(vec, ts, (size
2424
@inline Base.iteratorsize(VA::AbstractVectorOfArray) = Base.HasLength()
2525
# Linear indexing will be over the container elements, not the individual elements
2626
# unlike an true AbstractArray
27-
@inline Base.getindex{T, N}(VA::AbstractVectorOfArray{T, N}, I::Int) = VA.u[I]
28-
@inline Base.getindex{T, N}(VA::AbstractVectorOfArray{T, N}, I::Colon) = VA.u[I]
29-
@inline Base.getindex{T, N}(VA::AbstractVectorOfArray{T, N}, I::AbstractArray{Int}) = VA.u[I]
30-
@inline Base.getindex{T, N}(VA::AbstractVectorOfArray{T, N}, i::Int,::Colon) = [VA.u[j][i] for j in 1:length(VA)]
31-
@inline Base.setindex!{T, N}(VA::AbstractVectorOfArray{T, N}, v, I::Int) = VA.u[I] = v
32-
@inline Base.setindex!{T, N}(VA::AbstractVectorOfArray{T, N}, v, I::Colon) = VA.u[I] = v
33-
@inline Base.setindex!{T, N}(VA::AbstractVectorOfArray{T, N}, v, I::AbstractArray{Int}) = VA.u[I] = v
34-
@inline function Base.setindex!{T, N}(VA::AbstractVectorOfArray{T, N}, v, i::Int,::Colon)
27+
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Int) where {T, N} = VA.u[I]
28+
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Colon) where {T, N} = VA.u[I]
29+
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, I::AbstractArray{Int}) where {T, N} = VA.u[I]
30+
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, i::Int,::Colon) where {T, N} = [VA.u[j][i] for j in 1:length(VA)]
31+
@inline Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Int) where {T, N} = VA.u[I] = v
32+
@inline Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Colon) where {T, N} = VA.u[I] = v
33+
@inline Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::AbstractArray{Int}) where {T, N} = VA.u[I] = v
34+
@inline function Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, i::Int,::Colon) where {T, N}
3535
for j in 1:length(VA)
3636
VA.u[j][i] = v[j]
3737
end
3838
end
3939

4040
# Interface for the two dimensional indexing, a more standard AbstractArray interface
4141
@inline Base.size(VA::AbstractVectorOfArray) = (size(VA.u[1])..., length(VA.u))
42-
@inline Base.getindex{T, N}(VA::AbstractVectorOfArray{T, N}, I::Int...) = VA.u[I[end]][Base.front(I)...]
43-
@inline Base.getindex{T, N}(VA::AbstractVectorOfArray{T, N}, ::Colon, I::Int) = VA.u[I]
44-
@inline Base.setindex!{T, N}(VA::AbstractVectorOfArray{T, N}, v, I::Int...) = VA.u[I[end]][Base.front(I)...] = v
42+
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Int...) where {T, N} = VA.u[I[end]][Base.front(I)...]
43+
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, ::Colon, I::Int) where {T, N} = VA.u[I]
44+
@inline Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Int...) where {T, N} = VA.u[I[end]][Base.front(I)...] = v
4545

4646
# The iterator will be over the subarrays of the container, not the individual elements
4747
# unlike an true AbstractArray
48-
Base.start{T, N}(VA::AbstractVectorOfArray{T, N}) = 1
49-
Base.next{T, N}(VA::AbstractVectorOfArray{T, N}, state) = (VA[state], state + 1)
50-
Base.done{T, N}(VA::AbstractVectorOfArray{T, N}, state) = state >= length(VA.u) + 1
48+
Base.start(VA::AbstractVectorOfArray{T, N}) where {T, N} = 1
49+
Base.next(VA::AbstractVectorOfArray{T, N}, state) where {T, N} = (VA[state], state + 1)
50+
Base.done(VA::AbstractVectorOfArray{T, N}, state) where {T, N} = state >= length(VA.u) + 1
5151
tuples(VA::DiffEqArray) = tuple.(VA.t,VA.u)
5252

5353
# Growing the array simply adds to the container vector
5454
Base.copy(VA::AbstractVectorOfArray) = typeof(VA)(copy(VA.u))
55-
Base.sizehint!{T, N}(VA::AbstractVectorOfArray{T, N}, i) = sizehint!(VA.u, i)
56-
Base.push!{T, N}(VA::AbstractVectorOfArray{T, N}, new_item::AbstractVector) = push!(VA.u, new_item)
55+
Base.sizehint!(VA::AbstractVectorOfArray{T, N}, i) where {T, N} = sizehint!(VA.u, i)
56+
Base.push!(VA::AbstractVectorOfArray{T, N}, new_item::AbstractVector) where {T, N} = push!(VA.u, new_item)
5757

58-
function Base.append!{T, N}(VA::AbstractVectorOfArray{T, N}, new_item::AbstractVectorOfArray{T, N})
58+
function Base.append!(VA::AbstractVectorOfArray{T, N}, new_item::AbstractVectorOfArray{T, N}) where {T, N}
5959
for item in copy(new_item)
6060
push!(VA, item)
6161
end

0 commit comments

Comments
 (0)