Skip to content

Commit bc56748

Browse files
authored
Merge pull request #25450 from Sacha0/decollect
presently possible rewrites for potential collect deprecation
2 parents 0abc263 + 07586ad commit bc56748

32 files changed

+126
-126
lines changed

base/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ for all `i` and `j`.
17271727
17281728
# Examples
17291729
```jldoctest
1730-
julia> a = reshape(collect(1:16),(2,2,2,2))
1730+
julia> a = reshape(Vector(1:16),(2,2,2,2))
17311731
2×2×2×2 Array{Int64,4}:
17321732
[:, :, 1, 1] =
17331733
1 3

base/abstractarraymath.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Elements of `dims` must be unique and within the range `1:ndims(A)`.
5151
5252
# Examples
5353
```jldoctest
54-
julia> a = reshape(collect(1:4),(2,2,1,1))
54+
julia> a = reshape(Vector(1:4),(2,2,1,1))
5555
2×2×1×1 Array{Int64,4}:
5656
[:, :, 1, 1] =
5757
1 3
@@ -186,7 +186,7 @@ first dimension.
186186
187187
# Examples
188188
```jldoctest
189-
julia> b = reshape(collect(1:16), (4,4))
189+
julia> b = reshape(Vector(1:16), (4,4))
190190
4×4 Array{Int64,2}:
191191
1 5 9 13
192192
2 6 10 14

base/array.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ for reverse-order iteration without making a copy.
13411341
13421342
# Examples
13431343
```jldoctest
1344-
julia> A = collect(1:5)
1344+
julia> A = Vector(1:5)
13451345
5-element Array{Int64,1}:
13461346
1
13471347
2
@@ -1399,7 +1399,7 @@ In-place version of [`reverse`](@ref).
13991399
14001400
# Examples
14011401
```jldoctest
1402-
julia> A = collect(1:5)
1402+
julia> A = Vector(1:5)
14031403
5-element Array{Int64,1}:
14041404
1
14051405
2
@@ -2124,7 +2124,7 @@ The function `f` is passed one argument.
21242124
21252125
# Examples
21262126
```jldoctest
2127-
julia> filter!(isodd, collect(1:10))
2127+
julia> filter!(isodd, Vector(1:10))
21282128
5-element Array{Int64,1}:
21292129
1
21302130
3

base/linalg/qr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ end
161161

162162
function qrfactPivotedUnblocked!(A::StridedMatrix)
163163
m, n = size(A)
164-
piv = collect(UnitRange{BlasInt}(1,n))
164+
piv = Vector(UnitRange{BlasInt}(1,n))
165165
τ = Vector{eltype(A)}(uninitialized, min(m,n))
166166
for j = 1:min(m,n)
167167

base/multidimensional.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module IteratorsMD
3131
3232
# Examples
3333
```jldoctest
34-
julia> A = reshape(collect(1:16), (2, 2, 2, 2))
34+
julia> A = reshape(Vector(1:16), (2, 2, 2, 2))
3535
2×2×2×2 Array{Int64,4}:
3636
[:, :, 1, 1] =
3737
1 3
@@ -1306,7 +1306,7 @@ arrays have overlapping indices, then on the domain of the overlap
13061306
13071307
# Examples
13081308
```julia-repl
1309-
julia> src = reshape(collect(1:16), (4,4))
1309+
julia> src = reshape(Vector(1:16), (4,4))
13101310
4×4 Array{Int64,2}:
13111311
1 5 9 13
13121312
2 6 10 14
@@ -1706,7 +1706,7 @@ Return unique regions of `A` along dimension `dim`.
17061706
17071707
# Examples
17081708
```jldoctest
1709-
julia> A = map(isodd, reshape(collect(1:8), (2,2,2)))
1709+
julia> A = map(isodd, reshape(Vector(1:8), (2,2,2)))
17101710
2×2×2 Array{Bool,3}:
17111711
[:, :, 1] =
17121712
true true
@@ -1816,7 +1816,7 @@ Compute the minimum and maximum elements of an array over the given dimensions.
18161816
18171817
# Examples
18181818
```jldoctest
1819-
julia> A = reshape(collect(1:2:16), (2,2,2))
1819+
julia> A = reshape(Vector(1:2:16), (2,2,2))
18201820
2×2×2 Array{Int64,3}:
18211821
[:, :, 1] =
18221822
1 5

base/permuteddimsarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ See also: [`PermutedDimsArray`](@ref).
8787
8888
# Examples
8989
```jldoctest
90-
julia> A = reshape(collect(1:8), (2,2,2))
90+
julia> A = reshape(Vector(1:8), (2,2,2))
9191
2×2×2 Array{Int64,3}:
9292
[:, :, 1] =
9393
1 3

base/random/misc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ optionally supplying the random-number generator `rng`.
158158
```jldoctest
159159
julia> rng = MersenneTwister(1234);
160160
161-
julia> shuffle!(rng, collect(1:16))
161+
julia> shuffle!(rng, Vector(1:16))
162162
16-element Array{Int64,1}:
163163
2
164164
15
@@ -204,7 +204,7 @@ indices, see [`randperm`](@ref).
204204
```jldoctest
205205
julia> rng = MersenneTwister(1234);
206206
207-
julia> shuffle(rng, collect(1:10))
207+
julia> shuffle(rng, Vector(1:10))
208208
10-element Array{Int64,1}:
209209
6
210210
1

base/reducedim.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ faster because the intermediate array is avoided.
255255
256256
# Examples
257257
```jldoctest
258-
julia> a = reshape(collect(1:16), (4,4))
258+
julia> a = reshape(Vector(1:16), (4,4))
259259
4×4 Array{Int64,2}:
260260
1 5 9 13
261261
2 6 10 14
@@ -289,7 +289,7 @@ associativity, e.g. left-to-right, you should write your own loop. See documenta
289289
290290
# Examples
291291
```jldoctest
292-
julia> a = reshape(collect(1:16), (4,4))
292+
julia> a = reshape(Vector(1:16), (4,4))
293293
4×4 Array{Int64,2}:
294294
1 5 9 13
295295
2 6 10 14

base/reshapedarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ the specified dimensions is equal to the length of the original array
5252
`A`. The total number of elements must not change.
5353
5454
```jldoctest
55-
julia> A = collect(1:16)
55+
julia> A = Vector(1:16)
5656
16-element Array{Int64,1}:
5757
1
5858
2

base/sparse/sparsematrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ end
729729

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

735735
## Transposition and permutation methods

base/sparse/sparsevector.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function sparsevec(I::AbstractVector{<:Integer}, V::AbstractVector, combine::Fun
187187
len = i
188188
end
189189
end
190-
_sparsevector!(collect(I), collect(V), len, combine)
190+
_sparsevector!(Vector(I), Vector(V), len, combine)
191191
end
192192

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

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

@@ -1951,7 +1951,7 @@ function sort(x::SparseVector{Tv,Ti}; kws...) where {Tv,Ti}
19511951
sinds = sortperm(allvals;kws...)
19521952
n,k = length(x),length(allvals)
19531953
z = findfirst(equalto(k),sinds)
1954-
newnzind = collect(Ti,1:k-1)
1954+
newnzind = Vector{Ti}(1:k-1)
19551955
newnzind[z:end] .+= n-k+1
19561956
newnzvals = allvals[deleteat!(sinds[1:k],z)]
19571957
SparseVector(n,newnzind,newnzvals)

stdlib/Dates/src/arithmetic.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,5 @@ end
9595
(-)(y::T, x::AbstractArray{T}) where {T<:TimeType} = y .- x
9696

9797
# AbstractArray{TimeType}, AbstractArray{TimeType}
98-
(-)(x::OrdinalRange{T}, y::OrdinalRange{T}) where {T<:TimeType} = collect(x) - collect(y)
99-
(-)(x::AbstractRange{T}, y::AbstractRange{T}) where {T<:TimeType} = collect(x) - collect(y)
98+
(-)(x::OrdinalRange{T}, y::OrdinalRange{T}) where {T<:TimeType} = Vector(x) - Vector(y)
99+
(-)(x::AbstractRange{T}, y::AbstractRange{T}) where {T<:TimeType} = Vector(x) - Vector(y)

stdlib/Distributed/test/topology.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function launch(manager::TopoTestManager, params::Dict, launched::Array, c::Cond
5151
wconfig.process = io
5252
wconfig.io = io.out
5353
wconfig.ident = i
54-
wconfig.connect_idents = collect(i+2:2:manager.np)
54+
wconfig.connect_idents = Vector(i+2:2:manager.np)
5555
push!(launched, wconfig)
5656
end
5757

test/abstractarray.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ end
157157
@test CartesianIndices(0:3,3:5,-101:-100)[l] == CartesianIndex(i-1, j+2, k-102)
158158
end
159159

160-
local A = reshape(collect(1:9), (3,3))
160+
local A = reshape(Vector(1:9), (3,3))
161161
@test CartesianIndices(size(A))[6] == CartesianIndex(3,2)
162162
@test LinearIndices(size(A))[3, 2] == 6
163163
@test CartesianIndices(A)[6] == CartesianIndex(3,2)
@@ -256,7 +256,7 @@ Base.setindex!(A::TSlow{T,5}, v, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) wh
256256
const can_inline = Base.JLOptions().can_inline != 0
257257
function test_scalar_indexing(::Type{T}, shape, ::Type{TestAbstractArray}) where T
258258
N = prod(shape)
259-
A = reshape(collect(1:N), shape)
259+
A = reshape(Vector(1:N), shape)
260260
B = T(A)
261261
@test A == B
262262
# Test indexing up to 5 dimensions
@@ -379,7 +379,7 @@ end
379379
function test_vector_indexing(::Type{T}, shape, ::Type{TestAbstractArray}) where T
380380
@testset "test_vector_indexing{$(T)}" begin
381381
N = prod(shape)
382-
A = reshape(collect(1:N), shape)
382+
A = reshape(Vector(1:N), shape)
383383
B = T(A)
384384
trailing5 = CartesianIndex(ntuple(x->1, max(ndims(B)-5, 0)))
385385
trailing4 = CartesianIndex(ntuple(x->1, max(ndims(B)-4, 0)))
@@ -425,7 +425,7 @@ end
425425

426426
function test_primitives(::Type{T}, shape, ::Type{TestAbstractArray}) where T
427427
N = prod(shape)
428-
A = reshape(collect(1:N), shape)
428+
A = reshape(Vector(1:N), shape)
429429
B = T(A)
430430

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

490490
function test_getindex_internals(::Type{T}, shape, ::Type{TestAbstractArray}) where T
491491
N = prod(shape)
492-
A = reshape(collect(1:N), shape)
492+
A = reshape(Vector(1:N), shape)
493493
B = T(A)
494494

495495
@test getindex(A, 1) == 1
@@ -509,7 +509,7 @@ end
509509

510510
function test_setindex!_internals(::Type{T}, shape, ::Type{TestAbstractArray}) where T
511511
N = prod(shape)
512-
A = reshape(collect(1:N), shape)
512+
A = reshape(Vector(1:N), shape)
513513
B = T(A)
514514

515515
Base.unsafe_setindex!(B, 2, 1)
@@ -609,7 +609,7 @@ function test_ind2sub(::Type{TestAbstractArray})
609609
n = rand(2:5)
610610
dims = tuple(rand(1:5, n)...)
611611
len = prod(dims)
612-
A = reshape(collect(1:len), dims...)
612+
A = reshape(Vector(1:len), dims...)
613613
I = CartesianIndices(dims)
614614
for i in 1:len
615615
@test A[I[i]] == A[i]
@@ -790,7 +790,7 @@ for A in (rand(2), rand(2,3))
790790
for (i, v) in pairs(A)
791791
@test A[i] == v
792792
end
793-
@test collect(values(A)) == collect(A)
793+
@test Array(values(A)) == A
794794
end
795795

796796
# nextind
@@ -806,7 +806,7 @@ end
806806

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

812812
@testset "empty" begin

0 commit comments

Comments
 (0)