Skip to content

Commit

Permalink
Merge pull request #25450 from Sacha0/decollect
Browse files Browse the repository at this point in the history
presently possible rewrites for potential collect deprecation
  • Loading branch information
Sacha0 authored Jan 10, 2018
2 parents 0abc263 + 07586ad commit bc56748
Show file tree
Hide file tree
Showing 32 changed files with 126 additions and 126 deletions.
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ for all `i` and `j`.
# Examples
```jldoctest
julia> a = reshape(collect(1:16),(2,2,2,2))
julia> a = reshape(Vector(1:16),(2,2,2,2))
2×2×2×2 Array{Int64,4}:
[:, :, 1, 1] =
1 3
Expand Down
4 changes: 2 additions & 2 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Elements of `dims` must be unique and within the range `1:ndims(A)`.
# Examples
```jldoctest
julia> a = reshape(collect(1:4),(2,2,1,1))
julia> a = reshape(Vector(1:4),(2,2,1,1))
2×2×1×1 Array{Int64,4}:
[:, :, 1, 1] =
1 3
Expand Down Expand Up @@ -186,7 +186,7 @@ first dimension.
# Examples
```jldoctest
julia> b = reshape(collect(1:16), (4,4))
julia> b = reshape(Vector(1:16), (4,4))
4×4 Array{Int64,2}:
1 5 9 13
2 6 10 14
Expand Down
6 changes: 3 additions & 3 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ for reverse-order iteration without making a copy.
# Examples
```jldoctest
julia> A = collect(1:5)
julia> A = Vector(1:5)
5-element Array{Int64,1}:
1
2
Expand Down Expand Up @@ -1399,7 +1399,7 @@ In-place version of [`reverse`](@ref).
# Examples
```jldoctest
julia> A = collect(1:5)
julia> A = Vector(1:5)
5-element Array{Int64,1}:
1
2
Expand Down Expand Up @@ -2124,7 +2124,7 @@ The function `f` is passed one argument.
# Examples
```jldoctest
julia> filter!(isodd, collect(1:10))
julia> filter!(isodd, Vector(1:10))
5-element Array{Int64,1}:
1
3
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ end

function qrfactPivotedUnblocked!(A::StridedMatrix)
m, n = size(A)
piv = collect(UnitRange{BlasInt}(1,n))
piv = Vector(UnitRange{BlasInt}(1,n))
τ = Vector{eltype(A)}(uninitialized, min(m,n))
for j = 1:min(m,n)

Expand Down
8 changes: 4 additions & 4 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module IteratorsMD
# Examples
```jldoctest
julia> A = reshape(collect(1:16), (2, 2, 2, 2))
julia> A = reshape(Vector(1:16), (2, 2, 2, 2))
2×2×2×2 Array{Int64,4}:
[:, :, 1, 1] =
1 3
Expand Down Expand Up @@ -1306,7 +1306,7 @@ arrays have overlapping indices, then on the domain of the overlap
# Examples
```julia-repl
julia> src = reshape(collect(1:16), (4,4))
julia> src = reshape(Vector(1:16), (4,4))
4×4 Array{Int64,2}:
1 5 9 13
2 6 10 14
Expand Down Expand Up @@ -1706,7 +1706,7 @@ Return unique regions of `A` along dimension `dim`.
# Examples
```jldoctest
julia> A = map(isodd, reshape(collect(1:8), (2,2,2)))
julia> A = map(isodd, reshape(Vector(1:8), (2,2,2)))
2×2×2 Array{Bool,3}:
[:, :, 1] =
true true
Expand Down Expand Up @@ -1816,7 +1816,7 @@ Compute the minimum and maximum elements of an array over the given dimensions.
# Examples
```jldoctest
julia> A = reshape(collect(1:2:16), (2,2,2))
julia> A = reshape(Vector(1:2:16), (2,2,2))
2×2×2 Array{Int64,3}:
[:, :, 1] =
1 5
Expand Down
2 changes: 1 addition & 1 deletion base/permuteddimsarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ See also: [`PermutedDimsArray`](@ref).
# Examples
```jldoctest
julia> A = reshape(collect(1:8), (2,2,2))
julia> A = reshape(Vector(1:8), (2,2,2))
2×2×2 Array{Int64,3}:
[:, :, 1] =
1 3
Expand Down
4 changes: 2 additions & 2 deletions base/random/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ optionally supplying the random-number generator `rng`.
```jldoctest
julia> rng = MersenneTwister(1234);
julia> shuffle!(rng, collect(1:16))
julia> shuffle!(rng, Vector(1:16))
16-element Array{Int64,1}:
2
15
Expand Down Expand Up @@ -204,7 +204,7 @@ indices, see [`randperm`](@ref).
```jldoctest
julia> rng = MersenneTwister(1234);
julia> shuffle(rng, collect(1:10))
julia> shuffle(rng, Vector(1:10))
10-element Array{Int64,1}:
6
1
Expand Down
4 changes: 2 additions & 2 deletions base/reducedim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ faster because the intermediate array is avoided.
# Examples
```jldoctest
julia> a = reshape(collect(1:16), (4,4))
julia> a = reshape(Vector(1:16), (4,4))
4×4 Array{Int64,2}:
1 5 9 13
2 6 10 14
Expand Down Expand Up @@ -289,7 +289,7 @@ associativity, e.g. left-to-right, you should write your own loop. See documenta
# Examples
```jldoctest
julia> a = reshape(collect(1:16), (4,4))
julia> a = reshape(Vector(1:16), (4,4))
4×4 Array{Int64,2}:
1 5 9 13
2 6 10 14
Expand Down
2 changes: 1 addition & 1 deletion base/reshapedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ the specified dimensions is equal to the length of the original array
`A`. The total number of elements must not change.
```jldoctest
julia> A = collect(1:16)
julia> A = Vector(1:16)
16-element Array{Int64,1}:
1
2
Expand Down
2 changes: 1 addition & 1 deletion base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ end

function sparse(D::Diagonal{T}) where T
m = length(D.diag)
return SparseMatrixCSC(m, m, collect(1:(m+1)), collect(1:m), Vector{T}(D.diag))
return SparseMatrixCSC(m, m, Vector(1:(m+1)), Vector(1:m), Vector{T}(D.diag))
end

## Transposition and permutation methods
Expand Down
10 changes: 5 additions & 5 deletions base/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function sparsevec(I::AbstractVector{<:Integer}, V::AbstractVector, combine::Fun
len = i
end
end
_sparsevector!(collect(I), collect(V), len, combine)
_sparsevector!(Vector(I), Vector(V), len, combine)
end

function sparsevec(I::AbstractVector{<:Integer}, V::AbstractVector, len::Integer, combine::Function)
Expand All @@ -196,7 +196,7 @@ function sparsevec(I::AbstractVector{<:Integer}, V::AbstractVector, len::Integer
for i in I
1 <= i <= len || throw(ArgumentError("An index is out of bound."))
end
_sparsevector!(collect(I), collect(V), len, combine)
_sparsevector!(Vector(I), Vector(V), len, combine)
end

sparsevec(I::AbstractVector, V::Union{Number, AbstractVector}, args...) =
Expand Down Expand Up @@ -866,8 +866,8 @@ function SparseMatrixCSC{Tv,Ti}(x::AbstractSparseVector) where {Tv,Ti}
colptr = Ti[1, m+1]
# Note that this *cannot* share data like normal array conversions, since
# modifying one would put the other in an inconsistent state
rowval = collect(Ti, xnzind)
nzval = collect(Tv, xnzval)
rowval = Vector{Ti}(xnzind)
nzval = Vector{Tv}(xnzval)
SparseMatrixCSC(n, 1, colptr, rowval, nzval)
end

Expand Down Expand Up @@ -1951,7 +1951,7 @@ function sort(x::SparseVector{Tv,Ti}; kws...) where {Tv,Ti}
sinds = sortperm(allvals;kws...)
n,k = length(x),length(allvals)
z = findfirst(equalto(k),sinds)
newnzind = collect(Ti,1:k-1)
newnzind = Vector{Ti}(1:k-1)
newnzind[z:end] .+= n-k+1
newnzvals = allvals[deleteat!(sinds[1:k],z)]
SparseVector(n,newnzind,newnzvals)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Dates/src/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ end
(-)(y::T, x::AbstractArray{T}) where {T<:TimeType} = y .- x

# AbstractArray{TimeType}, AbstractArray{TimeType}
(-)(x::OrdinalRange{T}, y::OrdinalRange{T}) where {T<:TimeType} = collect(x) - collect(y)
(-)(x::AbstractRange{T}, y::AbstractRange{T}) where {T<:TimeType} = collect(x) - collect(y)
(-)(x::OrdinalRange{T}, y::OrdinalRange{T}) where {T<:TimeType} = Vector(x) - Vector(y)
(-)(x::AbstractRange{T}, y::AbstractRange{T}) where {T<:TimeType} = Vector(x) - Vector(y)
2 changes: 1 addition & 1 deletion stdlib/Distributed/test/topology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function launch(manager::TopoTestManager, params::Dict, launched::Array, c::Cond
wconfig.process = io
wconfig.io = io.out
wconfig.ident = i
wconfig.connect_idents = collect(i+2:2:manager.np)
wconfig.connect_idents = Vector(i+2:2:manager.np)
push!(launched, wconfig)
end

Expand Down
18 changes: 9 additions & 9 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ end
@test CartesianIndices(0:3,3:5,-101:-100)[l] == CartesianIndex(i-1, j+2, k-102)
end

local A = reshape(collect(1:9), (3,3))
local A = reshape(Vector(1:9), (3,3))
@test CartesianIndices(size(A))[6] == CartesianIndex(3,2)
@test LinearIndices(size(A))[3, 2] == 6
@test CartesianIndices(A)[6] == CartesianIndex(3,2)
Expand Down Expand Up @@ -256,7 +256,7 @@ Base.setindex!(A::TSlow{T,5}, v, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) wh
const can_inline = Base.JLOptions().can_inline != 0
function test_scalar_indexing(::Type{T}, shape, ::Type{TestAbstractArray}) where T
N = prod(shape)
A = reshape(collect(1:N), shape)
A = reshape(Vector(1:N), shape)
B = T(A)
@test A == B
# Test indexing up to 5 dimensions
Expand Down Expand Up @@ -379,7 +379,7 @@ end
function test_vector_indexing(::Type{T}, shape, ::Type{TestAbstractArray}) where T
@testset "test_vector_indexing{$(T)}" begin
N = prod(shape)
A = reshape(collect(1:N), shape)
A = reshape(Vector(1:N), shape)
B = T(A)
trailing5 = CartesianIndex(ntuple(x->1, max(ndims(B)-5, 0)))
trailing4 = CartesianIndex(ntuple(x->1, max(ndims(B)-4, 0)))
Expand Down Expand Up @@ -425,7 +425,7 @@ end

function test_primitives(::Type{T}, shape, ::Type{TestAbstractArray}) where T
N = prod(shape)
A = reshape(collect(1:N), shape)
A = reshape(Vector(1:N), shape)
B = T(A)

# last(a)
Expand Down Expand Up @@ -489,7 +489,7 @@ mutable struct UnimplementedArray{T, N} <: AbstractArray{T, N} end

function test_getindex_internals(::Type{T}, shape, ::Type{TestAbstractArray}) where T
N = prod(shape)
A = reshape(collect(1:N), shape)
A = reshape(Vector(1:N), shape)
B = T(A)

@test getindex(A, 1) == 1
Expand All @@ -509,7 +509,7 @@ end

function test_setindex!_internals(::Type{T}, shape, ::Type{TestAbstractArray}) where T
N = prod(shape)
A = reshape(collect(1:N), shape)
A = reshape(Vector(1:N), shape)
B = T(A)

Base.unsafe_setindex!(B, 2, 1)
Expand Down Expand Up @@ -609,7 +609,7 @@ function test_ind2sub(::Type{TestAbstractArray})
n = rand(2:5)
dims = tuple(rand(1:5, n)...)
len = prod(dims)
A = reshape(collect(1:len), dims...)
A = reshape(Vector(1:len), dims...)
I = CartesianIndices(dims)
for i in 1:len
@test A[I[i]] == A[i]
Expand Down Expand Up @@ -790,7 +790,7 @@ for A in (rand(2), rand(2,3))
for (i, v) in pairs(A)
@test A[i] == v
end
@test collect(values(A)) == collect(A)
@test Array(values(A)) == A
end

# nextind
Expand All @@ -806,7 +806,7 @@ end

@testset "zero-dimensional copy" begin
Z = Array{Int,0}(uninitialized); Z[] = 17
@test Z == collect(Z) == copy(Z)
@test Z == Array(Z) == copy(Z)
end

@testset "empty" begin
Expand Down
Loading

0 comments on commit bc56748

Please sign in to comment.