Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in /base/ #16498

Merged
merged 18 commits into from
May 25, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
effa667
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) for…
pkofod May 21, 2016
9ad7b84
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
c36e3ed
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
c25f198
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
b3e3a3f
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
b5bca76
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
1986cc4
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
fd5c99c
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
a689764
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
218a2eb
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
a8fae4a
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
0c31bfd
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
922fdbf
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
a7599e3
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
106f483
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
pkofod May 21, 2016
68d6eb8
Additional changes from Array(T, dim) to Array{T}(dim).
pkofod May 21, 2016
9866e93
Further changes.
pkofod May 22, 2016
b9057cf
fix constructors.rst
pkofod May 24, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in …
…base/ for files starting b-e.
  • Loading branch information
pkofod committed May 25, 2016
commit fd5c99cc8cee30fbbf5ddb826e78e45c98523ddf
4 changes: 2 additions & 2 deletions base/base.jl
Original file line number Diff line number Diff line change
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
26 changes: 13 additions & 13 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function gen_broadcast_body_cartesian_tobitarray(nd::Int, narrays::Int, f)
quote
@assert ndims(B) == $nd
@ncall $narrays check_broadcast_shape size(B) k->A_k
C = Array(Bool, bitcache_size)
C = Array{Bool}(bitcache_size)
Bc = B.chunks
ind = 1
cind = 1
Expand Down Expand Up @@ -140,7 +140,7 @@ function gen_broadcast_body_iter_tobitarray(nd::Int, narrays::Int, f)
quote
@assert ndims(B) == $nd
@ncall $narrays check_broadcast_shape size(B) k->A_k
C = Array(Bool, bitcache_size)
C = Array{Bool}(bitcache_size)
Bc = B.chunks
ind = 1
cind = 1
Expand Down Expand Up @@ -217,14 +217,14 @@ for (Bsig, Asig, gbf, gbb) in
end


broadcast(f, As...) = broadcast!(f, Array(promote_eltype_op(f, As...), broadcast_shape(As...)), As...)
broadcast(f, As...) = broadcast!(f, Array{promote_eltype_op(f, As...)}(broadcast_shape(As...)), As...)

bitbroadcast(f, As...) = broadcast!(f, BitArray(broadcast_shape(As...)), As...)

broadcast!_function(f) = (B, As...) -> broadcast!(f, B, As...)
broadcast_function(f) = (As...) -> broadcast(f, As...)

broadcast_getindex(src::AbstractArray, I::AbstractArray...) = broadcast_getindex!(Array(eltype(src), broadcast_shape(I...)), src, I...)
broadcast_getindex(src::AbstractArray, I::AbstractArray...) = broadcast_getindex!(Array{eltype(src)}(broadcast_shape(I...)), src, I...)
@generated function broadcast_getindex!(dest::AbstractArray, src::AbstractArray, I::AbstractArray...)
N = length(I)
Isplat = Expr[:(I[$d]) for d = 1:N]
Expand Down Expand Up @@ -278,22 +278,22 @@ end

eltype_plus(As::AbstractArray...) = promote_eltype_op(+, As...)

.+(As::AbstractArray...) = broadcast!(+, Array(eltype_plus(As...), broadcast_shape(As...)), As...)
.+(As::AbstractArray...) = broadcast!(+, Array{eltype_plus(As...)}(broadcast_shape(As...)), As...)

function .-(A::AbstractArray, B::AbstractArray)
broadcast!(-, Array(promote_op(-, eltype(A), eltype(B)), broadcast_shape(A,B)), A, B)
broadcast!(-, Array{promote_op(-, eltype(A), eltype(B))}(broadcast_shape(A,B)), A, B)
end

eltype_mul(As::AbstractArray...) = promote_eltype_op(*, As...)

.*(As::AbstractArray...) = broadcast!(*, Array(eltype_mul(As...), broadcast_shape(As...)), As...)
.*(As::AbstractArray...) = broadcast!(*, Array{eltype_mul(As...)}(broadcast_shape(As...)), As...)

function ./(A::AbstractArray, B::AbstractArray)
broadcast!(/, Array(promote_op(/, eltype(A), eltype(B)), broadcast_shape(A, B)), A, B)
broadcast!(/, Array{promote_op(/, eltype(A), eltype(B))}(broadcast_shape(A, B)), A, B)
end

function .\(A::AbstractArray, B::AbstractArray)
broadcast!(\, Array(promote_op(\, eltype(A), eltype(B)), broadcast_shape(A, B)), A, B)
broadcast!(\, Array{promote_op(\, eltype(A), eltype(B))}(broadcast_shape(A, B)), A, B)
end

typealias RatIntT{T<:Integer} Union{Type{Rational{T}},Type{T}}
Expand All @@ -303,11 +303,11 @@ type_rdiv{T<:Integer,S<:Integer}(::RatIntT{T}, ::RatIntT{S}) =
type_rdiv{T<:Integer,S<:Integer}(::CRatIntT{T}, ::CRatIntT{S}) =
Complex{Rational{promote_type(T,S)}}
function .//(A::AbstractArray, B::AbstractArray)
broadcast!(//, Array(type_rdiv(eltype(A), eltype(B)), broadcast_shape(A, B)), A, B)
broadcast!(//, Array{type_rdiv(eltype(A), eltype(B))}(broadcast_shape(A, B)), A, B)
end

function .^(A::AbstractArray, B::AbstractArray)
broadcast!(^, Array(promote_op(^, eltype(A), eltype(B)), broadcast_shape(A, B)), A, B)
broadcast!(^, Array{promote_op(^, eltype(A), eltype(B))}(broadcast_shape(A, B)), A, B)
end

## element-wise comparison operators returning BitArray ##
Expand Down Expand Up @@ -372,7 +372,7 @@ for (f, cachef, scalarf) in ((:.==, :bitcache_eq , :(==)),
l = length(F)
l == 0 && return F
Fc = F.chunks
C = Array(Bool, bitcache_size)
C = Array{Bool}(bitcache_size)
ind = 1
cind = 1
for i = 1:div(l + bitcache_size - 1, bitcache_size)
Expand Down Expand Up @@ -414,7 +414,7 @@ function (.^){T<:Integer}(A::BitArray, B::Array{T})
l == 0 && return F
Ac = A.chunks
Fc = F.chunks
C = Array(Bool, bitcache_size)
C = Array{Bool}(bitcache_size)
ind = 1
cind = 1
for i = 1:div(l + bitcache_size - 1, bitcache_size)
Expand Down
2 changes: 1 addition & 1 deletion base/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Channel{T} <: AbstractChannel

function Channel(sz)
sz_max = sz == typemax(Int) ? typemax(Int) - 1 : sz
new(Condition(), Condition(), :open, Array(T, 0), sz_max)
new(Condition(), Condition(), :open, Array{T}(0), sz_max)
end
end

Expand Down
4 changes: 2 additions & 2 deletions base/collections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type PriorityQueue{K,V,O<:Ordering} <: Associative{K,V}
index::Dict{K, Int}

function PriorityQueue(o::O)
new(Array(Pair{K,V}, 0), o, Dict{K, Int}())
new(Array{Pair{K,V}}(0), o, Dict{K, Int}())
end

PriorityQueue() = PriorityQueue{K,V,O}(Forward)
Expand All @@ -163,7 +163,7 @@ type PriorityQueue{K,V,O<:Ordering} <: Associative{K,V}
end

function PriorityQueue(itr, o::O)
xs = Array(Pair{K,V}, length(itr))
xs = Array{Pair{K,V}}(length(itr))
index = Dict{K, Int}()
for (i, (k, v)) in enumerate(itr)
xs[i] = Pair{K,V}(k, v)
Expand Down
10 changes: 5 additions & 5 deletions base/datafmt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const offs_chunk_size = 5000
countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int
function countlines(io::IO, eol::Char='\n')
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
a = Array(UInt8, 8192)
a = Array{UInt8}(8192)
nl = 0
while !eof(io)
nb = readbytes!(io, a)
Expand Down Expand Up @@ -78,8 +78,8 @@ type DLMOffsets <: DLMHandler
bufflen::Int

function DLMOffsets(sbuff::String)
offsets = Array(Array{Int,1}, 1)
offsets[1] = Array(Int, offs_chunk_size)
offsets = Array{Array{Int,1}}(1)
offsets[1] = Array{Int}(offs_chunk_size)
thresh = ceil(min(typemax(UInt), Base.Sys.total_memory()) / sizeof(Int) / 5)
new(offsets, 1, thresh, length(sbuff.data))
end
Expand All @@ -103,7 +103,7 @@ function store_cell(dlmoffsets::DLMOffsets, row::Int, col::Int,
return
end
end
offsets = Array(Int, offs_chunk_size)
offsets = Array{Int}(offs_chunk_size)
push!(oarr, offsets)
offidx = 1
end
Expand Down Expand Up @@ -142,7 +142,7 @@ function DLMStore{T}(::Type{T}, dims::NTuple{2,Integer},
nrows <= 0 && throw(ArgumentError("number of rows in dims must be > 0, got $nrows"))
ncols <= 0 && throw(ArgumentError("number of columns in dims must be > 0, got $ncols"))
hdr_offset = has_header ? 1 : 0
DLMStore{T}(fill(SubString(sbuff,1,0), 1, ncols), Array(T, nrows-hdr_offset, ncols),
DLMStore{T}(fill(SubString(sbuff,1,0), 1, ncols), Array{T}(nrows-hdr_offset, ncols),
nrows, ncols, 0, 0, hdr_offset, sbuff, auto, eol)
end

Expand Down
8 changes: 4 additions & 4 deletions base/dft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ complexfloat{T<:AbstractFloat}(x::AbstractArray{Complex{T}}) = x

# return an Array, rather than similar(x), to avoid an extra copy for FFTW
# (which only works on StridedArray types).
complexfloat{T<:Complex}(x::AbstractArray{T}) = copy!(Array(typeof(float(one(T))), size(x)), x)
complexfloat{T<:AbstractFloat}(x::AbstractArray{T}) = copy!(Array(typeof(complex(one(T))), size(x)), x)
complexfloat{T<:Real}(x::AbstractArray{T}) = copy!(Array(typeof(complex(float(one(T)))), size(x)), x)
complexfloat{T<:Complex}(x::AbstractArray{T}) = copy!(Array{typeof(float(one(T)))}(size(x)), x)
complexfloat{T<:AbstractFloat}(x::AbstractArray{T}) = copy!(Array{typeof(complex(one(T)))}(size(x)), x)
complexfloat{T<:Real}(x::AbstractArray{T}) = copy!(Array{typeof(complex(float(one(T))))}(size(x)), x)

# implementations only need to provide plan_X(x, region)
# for X in (:fft, :bfft, ...):
Expand Down Expand Up @@ -191,7 +191,7 @@ rfft{T<:Union{Integer,Rational}}(x::AbstractArray{T}, region=1:ndims(x)) = rfft(
plan_rfft{T<:Union{Integer,Rational}}(x::AbstractArray{T}, region; kws...) = plan_rfft(float(x), region; kws...)

# only require implementation to provide *(::Plan{T}, ::Array{T})
*{T}(p::Plan{T}, x::AbstractArray) = p * copy!(Array(T, size(x)), x)
*{T}(p::Plan{T}, x::AbstractArray) = p * copy!(Array{T}(size(x)), x)

# Implementations should also implement A_mul_B!(Y, plan, X) so as to support
# pre-allocated output arrays. We don't define * in terms of A_mul_B!
Expand Down
10 changes: 5 additions & 5 deletions base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function show{K,V}(io::IO, t::Associative{K,V})
rows -= 2 # Subtract the summary and final ⋮ continuation lines

# determine max key width to align the output, caching the strings
ks = Array(AbstractString, min(rows, length(t)))
ks = Array{AbstractString}(min(rows, length(t)))
keylen = 0
for (i, k) in enumerate(keys(t))
i > rows && break
Expand Down Expand Up @@ -251,7 +251,7 @@ function merge(d::Associative, others::Associative...)
end

function filter!(f, d::Associative)
badkeys = Array(keytype(d), 0)
badkeys = Array{keytype(d)}(0)
for (k,v) in d
# don't delete!(d, k) here, since associative types
# may not support mutation during iteration
Expand Down Expand Up @@ -426,7 +426,7 @@ type Dict{K,V} <: Associative{K,V}

function Dict()
n = 16
new(zeros(UInt8,n), Array(K,n), Array(V,n), 0, 0, false, 1, 0)
new(zeros(UInt8,n), Array{K}(n), Array{V}(n), 0, 0, false, 1, 0)
end
function Dict(kv)
h = Dict{K,V}()
Expand Down Expand Up @@ -540,8 +540,8 @@ function rehash!{K,V}(h::Dict{K,V}, newsz = length(h.keys))
end

slots = zeros(UInt8,newsz)
keys = Array(K, newsz)
vals = Array(V, newsz)
keys = Array{K}(newsz)
vals = Array{V}(newsz)
count0 = h.count
count = 0
maxprobe = h.maxprobe
Expand Down
2 changes: 1 addition & 1 deletion base/dsp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _zerosi(b,a,T) = zeros(promote_type(eltype(b), eltype(a), T), max(length(a), len

function filt{T,S}(b::Union{AbstractVector, Number}, a::Union{AbstractVector, Number},
x::AbstractArray{T}, si::AbstractArray{S}=_zerosi(b,a,T))
filt!(Array(promote_type(eltype(b), eltype(a), T, S), size(x)), b, a, x, si)
filt!(Array{promote_type(eltype(b), eltype(a), T, S)}(size(x)), b, a, x, si)
end

# in-place filtering: returns results in the out argument, which may shadow x
Expand Down
2 changes: 1 addition & 1 deletion base/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function next(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
pos = block[1]
blk = block[2]
len = ccall(:wcslen, UInt, (Ptr{UInt16},), pos)
buf = Array(UInt16, len)
buf = Array{UInt16}(len)
unsafe_copy!(pointer(buf), pos, len)
env = String(utf16to8(buf))
m = match(r"^(=?[^=]+)=(.*)$"s, env)
Expand Down
2 changes: 1 addition & 1 deletion base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function append_any(xs...)
# used by apply() and quote
# must be a separate function from append(), since apply() needs this
# exact function.
out = Array(Any, 4)
out = Array{Any}(4)
l = 4
i = 1
for x in xs
Expand Down