Navigation Menu

Skip to content

Commit

Permalink
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
Browse files Browse the repository at this point in the history
…/base/ (#16498)

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) for arrays.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/pkg/.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/linalg/.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/strings/.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/unicode/.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/grisu/.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/fft/.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting b-e.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/docs/.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting with f-i.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/dSFMT.jl, base/Enums.jl, and base/LineEdit.jl.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting with l-m.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting with p-r.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting with s-t.

* Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/special/.

* Additional changes from Array(T, dim) to Array{T}(dim).

* Further changes.

* fix constructors.rst
  • Loading branch information
pkofod authored and tkelman committed May 25, 2016
1 parent ea492c4 commit 2152bf9
Show file tree
Hide file tree
Showing 136 changed files with 715 additions and 723 deletions.
2 changes: 1 addition & 1 deletion base/Enums.jl
Expand Up @@ -34,7 +34,7 @@ macro enum(T,syms...)
throw(ArgumentError("invalid type expression for enum $T"))
end
typename = T
vals = Array(Tuple{Symbol,Integer},0)
vals = Array{Tuple{Symbol,Integer}}(0)
lo = hi = 0
i = Int32(-1)
hasexpr = false
Expand Down
2 changes: 1 addition & 1 deletion base/LineEdit.jl
Expand Up @@ -854,7 +854,7 @@ function keymap_merge(target,source)
for key in setdiff(keys(source), keys(direct_keys))
# We first resolve redirects in the source
value = source[key]
visited = Array(Any,0)
visited = Array{Any}(0)
while isa(value, Union{Char,AbstractString})
value = normalize_key(value)
if value in visited
Expand Down
28 changes: 14 additions & 14 deletions base/abstractarray.jl
Expand Up @@ -9,14 +9,14 @@ typealias RangeIndex Union{Int, Range{Int}, UnitRange{Int}, Colon}

## Basic functions ##

vect() = Array(Any, 0)
vect() = Array{Any}(0)
vect{T}(X::T...) = T[ X[i] for i=1:length(X) ]

function vect(X...)
T = promote_typeof(X...)
#T[ X[i] for i=1:length(X) ]
# TODO: this is currently much faster. should figure out why. not clear.
copy!(Array(T,length(X)), X)
copy!(Array{T}(length(X)), X)
end

size{T,N}(t::AbstractArray{T,N}, d) = d <= N ? size(t)[d] : 1
Expand Down Expand Up @@ -156,7 +156,7 @@ similar{T}(a::AbstractArray{T}, dims::Integer...) = similar(a, T, dims)
similar( a::AbstractArray, T::Type, dims::Integer...) = similar(a, T, dims)
# similar creates an Array by default
similar( a::AbstractArray, T::Type, dims::DimsInteger) = similar(a, T, convert(Dims, dims))
similar( a::AbstractArray, T::Type, dims::Dims) = Array(T, dims)
similar( a::AbstractArray, T::Type, dims::Dims) = Array{T}(dims)

## from general iterable to any array

Expand Down Expand Up @@ -597,23 +597,23 @@ promote_eltype() = Bottom
promote_eltype(v1, vs...) = promote_type(eltype(v1), promote_eltype(vs...))

#TODO: ERROR CHECK
cat(catdim::Integer) = Array(Any, 0)
cat(catdim::Integer) = Array{Any}(0)

vcat() = Array(Any, 0)
hcat() = Array(Any, 0)
typed_vcat(T::Type) = Array(T, 0)
typed_hcat(T::Type) = Array(T, 0)
vcat() = Array{Any}(0)
hcat() = Array{Any}(0)
typed_vcat(T::Type) = Array{T}(0)
typed_hcat(T::Type) = Array{T}(0)

## cat: special cases
vcat{T}(X::T...) = T[ X[i] for i=1:length(X) ]
vcat{T<:Number}(X::T...) = T[ X[i] for i=1:length(X) ]
hcat{T}(X::T...) = T[ X[j] for i=1, j=1:length(X) ]
hcat{T<:Number}(X::T...) = T[ X[j] for i=1, j=1:length(X) ]

vcat(X::Number...) = hvcat_fill(Array(promote_typeof(X...),length(X)), X)
hcat(X::Number...) = hvcat_fill(Array(promote_typeof(X...),1,length(X)), X)
typed_vcat(T::Type, X::Number...) = hvcat_fill(Array(T,length(X)), X)
typed_hcat(T::Type, X::Number...) = hvcat_fill(Array(T,1,length(X)), X)
vcat(X::Number...) = hvcat_fill(Array{promote_typeof(X...)}(length(X)), X)
hcat(X::Number...) = hvcat_fill(Array{promote_typeof(X...)}(1,length(X)), X)
typed_vcat(T::Type, X::Number...) = hvcat_fill(Array{T}(length(X)), X)
typed_hcat(T::Type, X::Number...) = hvcat_fill(Array{T}(1,length(X)), X)

vcat(V::AbstractVector...) = typed_vcat(promote_eltype(V...), V...)
vcat{T}(V::AbstractVector{T}...) = typed_vcat(T, V...)
Expand Down Expand Up @@ -833,7 +833,7 @@ function hvcat{T<:Number}(rows::Tuple{Vararg{Int}}, xs::T...)
nr = length(rows)
nc = rows[1]

a = Array(T, nr, nc)
a = Array{T}(nr, nc)
if length(a) != length(xs)
throw(ArgumentError("argument count does not match specified shape (expected $(length(a)), got $(length(xs)))"))
end
Expand Down Expand Up @@ -874,7 +874,7 @@ function typed_hvcat(T::Type, rows::Tuple{Vararg{Int}}, xs::Number...)
if nr*nc != len
throw(ArgumentError("argument count $(len) does not match specified shape $((nr,nc))"))
end
hvcat_fill(Array(T, nr, nc), xs)
hvcat_fill(Array{T}(nr, nc), xs)
end

function hvcat(rows::Tuple{Vararg{Int}}, xs::Number...)
Expand Down
2 changes: 1 addition & 1 deletion base/abstractarraymath.jl
Expand Up @@ -167,7 +167,7 @@ end
## ipermutedims in terms of permutedims ##

function ipermutedims(A::AbstractArray,perm)
iperm = Array(Int,length(perm))
iperm = Array{Int}(length(perm))
for (i,p) = enumerate(perm)
iperm[p] = i
end
Expand Down
58 changes: 29 additions & 29 deletions base/array.jl
Expand Up @@ -118,19 +118,19 @@ end

## Constructors ##

similar(a::Array, T::Type, dims::Dims) = Array(T, dims)
similar{T}(a::Array{T,1}) = Array(T, size(a,1))
similar{T}(a::Array{T,2}) = Array(T, size(a,1), size(a,2))
similar{T}(a::Array{T,1}, dims::Dims) = Array(T, dims)
similar{T}(a::Array{T,1}, m::Int) = Array(T, m)
similar{T}(a::Array{T,1}, S::Type) = Array(S, size(a,1))
similar{T}(a::Array{T,2}, dims::Dims) = Array(T, dims)
similar{T}(a::Array{T,2}, m::Int) = Array(T, m)
similar{T}(a::Array{T,2}, S::Type) = Array(S, size(a,1), size(a,2))
similar(a::Array, T::Type, dims::Dims) = Array{T}(dims)
similar{T}(a::Array{T,1}) = Array{T}(size(a,1))
similar{T}(a::Array{T,2}) = Array{T}(size(a,1), size(a,2))
similar{T}(a::Array{T,1}, dims::Dims) = Array{T}(dims)
similar{T}(a::Array{T,1}, m::Int) = Array{T}(m)
similar{T}(a::Array{T,1}, S::Type) = Array{S}(size(a,1))
similar{T}(a::Array{T,2}, dims::Dims) = Array{T}(dims)
similar{T}(a::Array{T,2}, m::Int) = Array{T}(m)
similar{T}(a::Array{T,2}, S::Type) = Array{S}(size(a,1), size(a,2))

# T[x...] constructs Array{T,1}
function getindex(T::Type, vals...)
a = Array(T,length(vals))
a = Array{T}(length(vals))
@inbounds for i = 1:length(vals)
a[i] = vals[i]
end
Expand All @@ -139,7 +139,7 @@ end
getindex(T::Type) = Array{T}(0)

function getindex(::Type{Any}, vals::ANY...)
a = Array(Any,length(vals))
a = Array{Any}(length(vals))
@inbounds for i = 1:length(vals)
a[i] = vals[i]
end
Expand All @@ -160,16 +160,16 @@ function fill!{T<:Union{Integer,AbstractFloat}}(a::Array{T}, x)
return a
end

fill(v, dims::Dims) = fill!(Array(typeof(v), dims), v)
fill(v, dims::Integer...) = fill!(Array(typeof(v), dims...), v)
fill(v, dims::Dims) = fill!(Array{typeof(v)}(dims), v)
fill(v, dims::Integer...) = fill!(Array{typeof(v)}(dims...), v)

cell(dims::Integer...) = Array(Any, dims...)
cell(dims::Tuple{Vararg{Integer}}) = Array(Any, convert(Tuple{Vararg{Int}}, dims))
cell(dims::Integer...) = Array{Any}(dims...)
cell(dims::Tuple{Vararg{Integer}}) = Array{Any}(convert(Tuple{Vararg{Int}}, dims))

for (fname, felt) in ((:zeros,:zero), (:ones,:one))
@eval begin
($fname)(T::Type, dims...) = fill!(Array(T, dims...), ($felt)(T))
($fname)(dims...) = fill!(Array(Float64, dims...), ($felt)(Float64))
($fname)(T::Type, dims...) = fill!(Array{T}(dims...), ($felt)(T))
($fname)(dims...) = fill!(Array{Float64}(dims...), ($felt)(Float64))
($fname){T}(A::AbstractArray{T}) = fill!(similar(A), ($felt)(T))
end
end
Expand Down Expand Up @@ -198,7 +198,7 @@ convert{T,n}(::Type{Array{T}}, x::Array{T,n}) = x
convert{T,n}(::Type{Array{T,n}}, x::Array{T,n}) = x

convert{T,n,S}(::Type{Array{T}}, x::AbstractArray{S, n}) = convert(Array{T, n}, x)
convert{T,n,S}(::Type{Array{T,n}}, x::AbstractArray{S,n}) = copy!(Array(T, size(x)), x)
convert{T,n,S}(::Type{Array{T,n}}, x::AbstractArray{S,n}) = copy!(Array{T}(size(x)), x)

promote_rule{T,n,S}(::Type{Array{T,n}}, ::Type{Array{S,n}}) = Array{promote_type(T,S),n}

Expand Down Expand Up @@ -691,7 +691,7 @@ function vcat{T}(arrays::Vector{T}...)
for a in arrays
n += length(a)
end
arr = Array(T, n)
arr = Array{T}(n)
ptr = pointer(arr)
offset = 0
if isbits(T)
Expand Down Expand Up @@ -792,13 +792,13 @@ findlast(testf::Function, A) = findprev(testf, A, length(A))
function find(testf::Function, A)
# use a dynamic-length array to store the indexes, then copy to a non-padded
# array for the return
tmpI = Array(Int, 0)
tmpI = Array{Int}(0)
for (i,a) = enumerate(A)
if testf(a)
push!(tmpI, i)
end
end
I = Array(Int, length(tmpI))
I = Array{Int}(length(tmpI))
copy!(I, tmpI)
I
end
Expand All @@ -816,8 +816,8 @@ function find(A)
return I
end

find(x::Number) = x == 0 ? Array(Int,0) : [1]
find(testf::Function, x::Number) = !testf(x) ? Array(Int,0) : [1]
find(x::Number) = x == 0 ? Array{Int}(0) : [1]
find(testf::Function, x::Number) = !testf(x) ? Array{Int}(0) : [1]

findn(A::AbstractVector) = find(A)

Expand All @@ -840,7 +840,7 @@ function findnz{T}(A::AbstractMatrix{T})
nnzA = countnz(A)
I = zeros(Int, nnzA)
J = zeros(Int, nnzA)
NZs = Array(T, nnzA)
NZs = Array{T}(nnzA)
count = 1
if nnzA > 0
for j=1:size(A,2), i=1:size(A,1)
Expand Down Expand Up @@ -903,7 +903,7 @@ function indexin(a::AbstractArray, b::AbstractArray)
end

function findin(a, b)
ind = Array(Int, 0)
ind = Array{Int}(0)
bset = Set(b)
@inbounds for (i,ai) in enumerate(a)
ai in bset && push!(ind, i)
Expand Down Expand Up @@ -952,7 +952,7 @@ function filter!(f, a::Vector)
end

function filter(f, a::Vector)
r = Array(eltype(a), 0)
r = Array{eltype(a)}(0)
for ai in a
if f(ai)
push!(r, ai)
Expand All @@ -965,7 +965,7 @@ end
# These are moderately efficient, preserve order, and remove dupes.

function intersect(v1, vs...)
ret = Array(eltype(v1),0)
ret = Array{eltype(v1)}(0)
for v_elem in v1
inall = true
for vsi in vs
Expand All @@ -981,7 +981,7 @@ function intersect(v1, vs...)
end

function union(vs...)
ret = Array(promote_eltype(vs...),0)
ret = Array{promote_eltype(vs...)}(0)
seen = Set()
for v in vs
for v_elem in v
Expand All @@ -997,7 +997,7 @@ end
function setdiff(a, b)
args_type = promote_type(eltype(a), eltype(b))
bset = Set(b)
ret = Array(args_type,0)
ret = Array{args_type}(0)
seen = Set{eltype(a)}()
for a_elem in a
if !in(a_elem, seen) && !in(a_elem, bset)
Expand Down
4 changes: 2 additions & 2 deletions base/base.jl
Expand Up @@ -85,15 +85,15 @@ gc_enable(on::Bool) = ccall(:jl_gc_enable, Cint, (Cint,), on)!=0
# used by { } syntax
function cell_1d(xs::ANY...)
n = length(xs)
a = Array(Any,n)
a = Array{Any}(n)
for i=1:n
arrayset(a,xs[i],i)
end
a
end

function cell_2d(nr, nc, xs::ANY...)
a = Array(Any,nr,nc)
a = Array{Any}(nr,nc)
for i=1:(nr*nc)
arrayset(a,xs[i],i)
end
Expand Down
22 changes: 11 additions & 11 deletions base/bitarray.jl
Expand Up @@ -18,7 +18,7 @@ type BitArray{N} <: DenseArray{Bool, N}
i += 1
end
nc = num_bit_chunks(n)
chunks = Array(UInt64, nc)
chunks = Array{UInt64}(nc)
nc > 0 && (chunks[end] = UInt64(0))
b = new(chunks, n)
N != 1 && (b.dims = dims)
Expand Down Expand Up @@ -365,7 +365,7 @@ similar(B::BitArray, dims::Dims) = BitArray(dims...)
similar(B::BitArray, T::Type{Bool}, dims::Dims) = BitArray(dims)
# changing type to a non-Bool returns an Array
# (this triggers conversions like float(bitvector) etc.)
similar(B::BitArray, T::Type, dims::Dims) = Array(T, dims)
similar(B::BitArray, T::Type, dims::Dims) = Array{T}(dims)

function fill!(B::BitArray, x)
y = convert(Bool, x)
Expand Down Expand Up @@ -474,7 +474,7 @@ end
convert{T,N}(::Type{Array{T}}, B::BitArray{N}) = convert(Array{T,N}, B)
convert{T,N}(::Type{Array{T,N}}, B::BitArray{N}) = _convert(Array{T,N}, B) # see #15801
function _convert{T,N}(::Type{Array{T,N}}, B::BitArray{N})
A = Array(T, size(B))
A = Array{T}(size(B))
Bc = B.chunks
@inbounds for i = 1:length(A)
A[i] = unsafe_bitgetindex(Bc, i)
Expand Down Expand Up @@ -1021,7 +1021,7 @@ end

for f in (:+, :-)
@eval function ($f)(A::BitArray, B::BitArray)
r = Array(Int, promote_shape(size(A), size(B)))
r = Array{Int}(promote_shape(size(A), size(B)))
ai = start(A)
bi = start(B)
ri = 1
Expand All @@ -1040,7 +1040,7 @@ for (f) in (:.+, :.-)
(:(x::Bool) , :(B::BitArray), Int , :(x, b)),
(:(x::Number) , :(B::BitArray), :(promote_array_type($f, typeof(x), BitArray)), :(x, b)))
@eval function ($f)($arg1, $arg2)
r = Array($T, size(B))
r = Array{$T}(size(B))
bi = start(B)
ri = 1
while !done(B, bi)
Expand Down Expand Up @@ -1106,7 +1106,7 @@ end
for f in (:div, :mod)
@eval begin
function ($f)(B::BitArray, x::Number)
F = Array(promote_array_type($f, BitArray, typeof(x)), size(B))
F = Array{promote_array_type($f, BitArray, typeof(x))}(size(B))
for i = 1:length(F)
F[i] = ($f)(B[i], x)
end
Expand Down Expand Up @@ -1198,7 +1198,7 @@ function (.^){T<:Number}(B::BitArray, x::T)
else
t = typeof(u)
end
F = Array(t, size(B))
F = Array{t}(size(B))
for i = 1:length(B)
if B[i]
if uerr === nothing
Expand Down Expand Up @@ -1607,7 +1607,7 @@ end
function find(B::BitArray)
l = length(B)
nnzB = countnz(B)
I = Array(Int, nnzB)
I = Array{Int}(nnzB)
nnzB == 0 && return I
Bc = B.chunks
Bcount = 1
Expand Down Expand Up @@ -1641,8 +1641,8 @@ findn(B::BitVector) = find(B)

function findn(B::BitMatrix)
nnzB = countnz(B)
I = Array(Int, nnzB)
J = Array(Int, nnzB)
I = Array{Int}(nnzB)
J = Array{Int}(nnzB)
count = 1
for j = 1:size(B,2), i = 1:size(B,1)
if B[i,j]
Expand Down Expand Up @@ -1969,7 +1969,7 @@ function cat(catdim::Integer, X::Union{BitArray, Integer}...)
if !has_integer || typeC == Bool
C = BitArray(dimsC)
else
C = Array(typeC, dimsC)
C = Array{typeC}(dimsC)
end

range = 1
Expand Down

0 comments on commit 2152bf9

Please sign in to comment.