From 9866e93ebdf1e9fc135aa6466827b492f9a915b0 Mon Sep 17 00:00:00 2001 From: Patrick Kofod Mogensen Date: Sun, 22 May 2016 21:08:22 +0200 Subject: [PATCH] Further changes. --- base/sharedarray.jl | 12 ++++---- base/tuple.jl | 2 +- doc/devdocs/subarrays.rst | 2 +- doc/manual/arrays.rst | 2 +- doc/manual/calling-c-and-fortran-code.rst | 6 ++-- doc/manual/constructors.rst | 2 +- doc/manual/interfaces.rst | 3 +- doc/manual/metaprogramming.rst | 4 +-- doc/manual/performance-tips.rst | 12 ++++---- doc/manual/style-guide.rst | 2 +- doc/manual/variables-and-scoping.rst | 6 ++-- doc/stdlib/arrays.rst | 3 +- examples/lru.jl | 4 +-- examples/ndgrid.jl | 2 +- examples/queens.jl | 2 +- test/abstractarray.jl | 8 ++--- test/arrayops.jl | 22 +++++++------- test/bitarray.jl | 2 +- test/core.jl | 36 +++++++++++------------ test/datafmt.jl | 3 +- test/dates/ranges.jl | 4 +-- test/fft.jl | 2 +- test/file.jl | 2 +- test/functional.jl | 2 +- test/grisu.jl | 2 +- test/iobuffer.jl | 4 +-- test/linalg/generic.jl | 2 +- test/linalg/matmul.jl | 20 ++++++------- test/linalg/pinv.jl | 9 +++--- test/mmap.jl | 8 ++--- test/mod2pi.jl | 2 +- test/netload/memtest.jl | 2 +- test/parallel_exec.jl | 4 +-- test/perf/cat/perf.jl | 9 +++--- test/perf/kernel/perf.jl | 2 +- test/perf/perfutil.jl | 2 +- test/perf/shootout/fannkuch.jl | 2 +- test/perf/shootout/fasta.jl | 2 +- test/perf/shootout/k_nucleotide.jl | 2 +- test/perf/shootout/meteor_contest.jl | 2 +- test/perf/sort/perf.jl | 8 ++--- test/perf/threads/laplace3d/laplace3d.jl | 9 +++--- test/perf/threads/lbm3d/lbm3d.jl | 21 +++++++------ test/perf/threads/stockcorr/pstockcorr.jl | 5 ++-- test/pollfd.jl | 6 ++-- test/random.jl | 36 +++++++++++------------ test/serialize.jl | 2 +- test/simdloop.jl | 10 +++---- test/sparsedir/sparse.jl | 10 +++---- test/sparsedir/sparsevector.jl | 2 +- test/staged.jl | 2 +- test/subarray.jl | 4 +-- test/threads.jl | 4 +-- test/unicode/utf32.jl | 2 +- 54 files changed, 166 insertions(+), 174 deletions(-) diff --git a/base/sharedarray.jl b/base/sharedarray.jl index abaa6c8b308a2..f887910b6e91a 100644 --- a/base/sharedarray.jl +++ b/base/sharedarray.jl @@ -77,7 +77,7 @@ function SharedArray(T::Type, dims::NTuple; init=false, pids=Int[]) func_mapshmem = () -> shm_mmap_array(T, dims, shm_seg_name, JL_O_RDWR) - refs = Array(Future, length(pids)) + refs = Array{Future}(length(pids)) for (i, p) in enumerate(pids) refs[i] = remotecall(func_mapshmem, p) end @@ -159,7 +159,7 @@ function SharedArray{T,N}(filename::AbstractString, ::Type{T}, dims::NTuple{N,In mode == "r" && !isfile(filename) && throw(ArgumentError("file $filename does not exist, but mode $mode cannot create it")) # Create the file if it doesn't exist, map it if it does - refs = Array(Future, length(pids)) + refs = Array{Future}(length(pids)) func_mmap = mode -> open(filename, mode) do io Mmap.mmap(io, Array{T,N}, dims, offset; shared=true) end @@ -224,7 +224,7 @@ function finalize_refs{T,N}(S::SharedArray{T,N}) empty!(S.refs) init_loc_flds(S) finalize(S.s) - S.s = Array(T, ntuple(d->0,N)) + S.s = Array{T}(ntuple(d->0,N)) end S end @@ -238,7 +238,7 @@ linearindexing{S<:SharedArray}(::Type{S}) = LinearFast() function reshape{T,N}(a::SharedArray{T}, dims::NTuple{N,Int}) (length(a) != prod(dims)) && throw(DimensionMismatch("dimensions must be consistent with array size")) - refs = Array(Future, length(a.pids)) + refs = Array{Future}(length(a.pids)) for (i, p) in enumerate(a.pids) refs[i] = remotecall(p, a.refs[i], dims) do r,d reshape(fetch(r),d) @@ -339,7 +339,7 @@ function init_loc_flds{T,N}(S::SharedArray{T,N}) S.loc_subarr_1d = sub_1dim(S, S.pidx) else S.pidx = 0 - S.loc_subarr_1d = sub(Array(T, ntuple(d->0,N)), 1:0) + S.loc_subarr_1d = sub(Array{T}(ntuple(d->0,N)), 1:0) end end @@ -506,7 +506,7 @@ function shm_mmap_array(T, dims, shm_seg_name, mode) local A = nothing if prod(dims) == 0 - return Array(T, dims) + return Array{T}(dims) end try diff --git a/base/tuple.jl b/base/tuple.jl index 65240d64af48e..a3ee59d1dca6e 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -90,7 +90,7 @@ map(f, t::Tuple) = (f(t[1]), map(f,tail(t))...) function map(f, t::Tuple{Any,Any,Any,Any,Any,Any,Any,Any, Any,Any,Any,Any,Any,Any,Any,Any,Vararg{Any}}) n = length(t) - A = Array(Any,n) + A = Array{Any}(n) for i=1:n A[i] = f(t[i]) end diff --git a/doc/devdocs/subarrays.rst b/doc/devdocs/subarrays.rst index 955e74a57f654..0f96cebf991af 100644 --- a/doc/devdocs/subarrays.rst +++ b/doc/devdocs/subarrays.rst @@ -126,7 +126,7 @@ parent array, whereas for ``S2`` one needs to apply them to the second and third. The simplest approach to indexing would be to do the type-analysis at runtime:: - parentindexes = Array(Any, 0) + parentindexes = Array{Any}(0) for i = 1:ndims(S.parent) ... if isa(thisindex, Int) diff --git a/doc/manual/arrays.rst b/doc/manual/arrays.rst index ee85263e9a273..c0b03cd4763c4 100644 --- a/doc/manual/arrays.rst +++ b/doc/manual/arrays.rst @@ -67,7 +67,7 @@ dimension sizes passed as a variable number of arguments. =================================================== ===================================================================== Function Description =================================================== ===================================================================== -:func:`Array(type, dims...) ` an uninitialized dense array +:func:`Array{type}(dims...) ` an uninitialized dense array :func:`cell(dims...) ` an uninitialized cell array (heterogeneous array) :func:`zeros(type, dims...) ` an array of all zeros of specified type, defaults to ``Float64`` if ``type`` not specified diff --git a/doc/manual/calling-c-and-fortran-code.rst b/doc/manual/calling-c-and-fortran-code.rst index b2ec6ed6bf2b4..b08264d2868cb 100644 --- a/doc/manual/calling-c-and-fortran-code.rst +++ b/doc/manual/calling-c-and-fortran-code.rst @@ -136,7 +136,7 @@ Here is a slightly more complex example that discovers the local machine's hostname:: function gethostname() - hostname = Array(UInt8, 128) + hostname = Array{UInt8}(128) ccall((:gethostname, "libc"), Int32, (Ptr{UInt8}, Csize_t), hostname, sizeof(hostname)) @@ -879,7 +879,7 @@ Here is a third example passing Julia arrays:: # double result_array[]) function sf_bessel_Jn_array(nmin::Integer, nmax::Integer, x::Real) if nmax` ``similar(A, eltype(A), size(A))`` Return a mutable array with the same shape and element type :func:`similar(A, ::Type{S}) ` ``similar(A, S, size(A))`` Return a mutable array with the same shape and the specified element type :func:`similar(A, dims::NTuple{Int}) ` ``similar(A, eltype(A), dims)`` Return a mutable array with the same element type and the specified dimensions -:func:`similar(A, ::Type{S}, dims::NTuple{Int}) ` ``Array(S, dims)`` Return a mutable array with the specified element type and dimensions +:func:`similar(A, ::Type{S}, dims::NTuple{Int}) ` ``Array{S}(dims)`` Return a mutable array with the specified element type and dimensions ============================================================================ ============================================ ======================================================================================= - If a type is defined as a subtype of ``AbstractArray``, it inherits a very large set of rich behaviors including iteration and multidimensional indexing built on top of single-element access. See the :ref:`arrays manual page ` and :ref:`standard library section ` for more supported methods. A key part in defining an ``AbstractArray`` subtype is :func:`Base.linearindexing`. Since indexing is such an important part of an array and often occurs in hot loops, it's important to make both indexing and indexed assignment as efficient as possible. Array data structures are typically defined in one of two ways: either it most efficiently accesses its elements using just one index (linear indexing) or it intrinsically accesses the elements with indices specified for every dimension. These two modalities are identified by Julia as ``Base.LinearFast()`` and ``Base.LinearSlow()``. Converting a linear index to multiple indexing subscripts is typically very expensive, so this provides a traits-based mechanism to enable efficient generic code for all array types. diff --git a/doc/manual/metaprogramming.rst b/doc/manual/metaprogramming.rst index 8be410842f55c..bc32d8c0a9019 100644 --- a/doc/manual/metaprogramming.rst +++ b/doc/manual/metaprogramming.rst @@ -102,7 +102,7 @@ objects: julia> dump(ex2) Expr head: Symbol call - args: Array(Any,(3,)) + args: Array{Any}((3,)) 1: Symbol + 2: Int64 1 3: Int64 1 @@ -619,7 +619,7 @@ Compare: julia> dump(:("a ($a) should equal b ($b)!")) Expr head: Symbol string - args: Array(Any,(5,)) + args: Array{Any}((5,)) 1: String "a (" 2: Symbol a 3: String ") should equal b (" diff --git a/doc/manual/performance-tips.rst b/doc/manual/performance-tips.rst index 8ed034b34f185..a101b10f2f0d1 100644 --- a/doc/manual/performance-tips.rst +++ b/doc/manual/performance-tips.rst @@ -827,7 +827,7 @@ adapted accordingly). We could conceivably do this in at least four ways function copy_cols{T}(x::Vector{T}) n = size(x, 1) - out = Array(eltype(x), n, n) + out = Array{eltype(x)}(n, n) for i=1:n out[:, i] = x end @@ -836,7 +836,7 @@ adapted accordingly). We could conceivably do this in at least four ways function copy_rows{T}(x::Vector{T}) n = size(x, 1) - out = Array(eltype(x), n, n) + out = Array{eltype(x)}(n, n) for i=1:n out[i, :] = x end @@ -845,7 +845,7 @@ adapted accordingly). We could conceivably do this in at least four ways function copy_col_row{T}(x::Vector{T}) n = size(x, 1) - out = Array(T, n, n) + out = Array{T}(n, n) for col=1:n, row=1:n out[row, col] = x[row] end @@ -854,7 +854,7 @@ adapted accordingly). We could conceivably do this in at least four ways function copy_row_col{T}(x::Vector{T}) n = size(x, 1) - out = Array(T, n, n) + out = Array{T}(n, n) for row=1:n, col=1:n out[row, col] = x[col] end @@ -920,7 +920,7 @@ with end function loopinc_prealloc() - ret = Array(Int, 3) + ret = Array{Int}(3) y = 0 for i = 1:10^7 xinc!(ret, i) @@ -1146,7 +1146,7 @@ evaluates the L2-norm of the result:: function main() n = 2000 - u = Array(Float64, n) + u = Array{Float64}(n) init!(u) du = similar(u) diff --git a/doc/manual/style-guide.rst b/doc/manual/style-guide.rst index 98dc69800a6f1..a752b37a20ba2 100644 --- a/doc/manual/style-guide.rst +++ b/doc/manual/style-guide.rst @@ -149,7 +149,7 @@ Avoid elaborate container types It is usually not much help to construct arrays like the following:: - a = Array(Union{Int,AbstractString,Tuple,Array}, n) + a = Array{Union{Int,AbstractString,Tuple,Array}}(n) In this case :func:`cell(n) ` is better. It is also more helpful to the compiler to annotate specific uses (e.g. ``a[i]::Int``) than to try to pack many diff --git a/doc/manual/variables-and-scoping.rst b/doc/manual/variables-and-scoping.rst index c7b08a8ebfff1..480e836bf9a82 100644 --- a/doc/manual/variables-and-scoping.rst +++ b/doc/manual/variables-and-scoping.rst @@ -397,7 +397,7 @@ has been introduced. Therefore it makes sense to write something like ``let x = x`` since the two ``x`` variables are distinct and have separate storage. Here is an example where the behavior of ``let`` is needed:: - Fs = Array(Any,2) + Fs = Array{Any}(2) i = 1 while i <= 2 Fs[i] = ()->i @@ -415,7 +415,7 @@ However, it is always the same variable ``i``, so the two closures behave identically. We can use ``let`` to create a new binding for ``i``:: - Fs = Array(Any,2) + Fs = Array{Any}(2) i = 1 while i <= 2 let i = i @@ -462,7 +462,7 @@ are freshly allocated for each loop iteration. This is in contrast to iterations. Therefore these constructs are similar to ``while`` loops with ``let`` blocks inside:: - Fs = Array(Any,2) + Fs = Array{Any}(2) for i = 1:2 Fs[i] = ()->i end diff --git a/doc/stdlib/arrays.rst b/doc/stdlib/arrays.rst index 45f1140a3b6f5..0250fc82b1933 100644 --- a/doc/stdlib/arrays.rst +++ b/doc/stdlib/arrays.rst @@ -235,7 +235,7 @@ Constructors Create an uninitialized mutable array with the given element type and size, based upon the given source array. The second and third arguments are both optional, defaulting to the given array's ``eltype`` and ``size``\ . The dimensions may be specified either as a single tuple argument or as a series of integer arguments. - Custom AbstractArray subtypes may choose which specific array type is best-suited to return for the given element type and dimensionality. If they do not specialize this method, the default is an ``Array(element_type, dims...)``\ . + Custom AbstractArray subtypes may choose which specific array type is best-suited to return for the given element type and dimensionality. If they do not specialize this method, the default is an ``Array{element_type}(dims...)``\ . For example, ``similar(1:10, 1, 4)`` returns an uninitialized ``Array{Int,2}`` since ranges are neither mutable nor support 2 dimensions: @@ -995,4 +995,3 @@ dense counterparts. The following functions are specific to sparse arrays. # perform sparse wizardry... end end - diff --git a/examples/lru.jl b/examples/lru.jl index cc8958ef015e8..f665132524f78 100644 --- a/examples/lru.jl +++ b/examples/lru.jl @@ -39,7 +39,7 @@ type UnboundedLRU{K,V} <: LRU{K,V} ht::Dict q::Vector{CacheItem} - UnboundedLRU() = new(Dict(), similar(Array(CacheItem,1), 0)) + UnboundedLRU() = new(Dict(), similar(Array{CacheItem}(1), 0)) end UnboundedLRU() = UnboundedLRU{Any, Any}() @@ -48,7 +48,7 @@ type BoundedLRU{K,V} <: LRU{K,V} q::Vector{CacheItem} maxsize::Int - BoundedLRU(m) = new(Dict(), similar(Array(CacheItem,1), 0), m) + BoundedLRU(m) = new(Dict(), similar(Array{CacheItem}(1), 0), m) BoundedLRU() = BoundedLRU(__MAXCACHE) end BoundedLRU(m) = BoundedLRU{Any, Any}(m) diff --git a/examples/ndgrid.jl b/examples/ndgrid.jl index 688a246b8b7ed..228c609ee7fa2 100644 --- a/examples/ndgrid.jl +++ b/examples/ndgrid.jl @@ -18,7 +18,7 @@ end function ndgrid{T}(vs::AbstractVector{T}...) n = length(vs) sz = map(length, vs) - out = ntuple(i->Array(T, sz), n) + out = ntuple(i->Array{T}(sz), n) s = 1 for i=1:n a = out[i]::Array diff --git a/examples/queens.jl b/examples/queens.jl index dba16fd5ad40f..a3d61ead1b6aa 100644 --- a/examples/queens.jl +++ b/examples/queens.jl @@ -5,7 +5,7 @@ addqueen(queens::Array{Vector{Int}}, queen::Vector{Int}) = push!(copy(queens), q hitsany(queen::Vector{Int}, queens::Array{Vector{Int}}) = any(x->hits(queen, x), queens) hits(a::Array{Int}, b::Array{Int}) = any(a .== b) || abs(a-b)[1] == abs(a-b)[2] -function solve(x, y, n, d=Array(Vector{Int}, 0)) +function solve(x, y, n, d=Array{Vector{Int}}(0)) if n == 0 return d end diff --git a/test/abstractarray.jl b/test/abstractarray.jl index 1d70b47be87f2..942e8e2464046 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -245,7 +245,7 @@ function test_primitives{T}(::Type{T}, shape, ::Type{TestAbstractArray}) @test_throws DimensionMismatch reshape(B, (0, 1)) # copy!(dest::AbstractArray, src::AbstractArray) - @test_throws BoundsError copy!(Array(Int, 10), [1:11...]) + @test_throws BoundsError copy!(Array{Int}(10), [1:11...]) # convert{T, N}(::Type{Array}, A::AbstractArray{T, N}) X = [1:10...] @@ -320,14 +320,14 @@ function test_cat(::Type{TestAbstractArray}) A = T24Linear([1:24...]) b_int = reshape([1:27...], 3, 3, 3) b_float = reshape(Float64[1:27...], 3, 3, 3) - b2hcat = Array(Float64, 3, 6, 3) + b2hcat = Array{Float64}(3, 6, 3) b1 = reshape([1:9...], 3, 3) b2 = reshape([10:18...], 3, 3) b3 = reshape([19:27...], 3, 3) b2hcat[:, :, 1] = hcat(b1, b1) b2hcat[:, :, 2] = hcat(b2, b2) b2hcat[:, :, 3] = hcat(b3, b3) - b3hcat = Array(Float64, 3, 9, 3) + b3hcat = Array{Float64}(3, 9, 3) b3hcat[:, :, 1] = hcat(b1, b1, b1) b3hcat[:, :, 2] = hcat(b2, b2, b2) b3hcat[:, :, 3] = hcat(b3, b3, b3) @@ -442,7 +442,7 @@ function test_map(::Type{TestAbstractArray}) end # AbstractArray map for N-arg case - A = Array(Int, 10) + A = Array{Int}(10) f(x, y, z) = x + y + z D = Float64[1:10...] diff --git a/test/arrayops.jl b/test/arrayops.jl index 99126d9f57380..0391c2b9656ee 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -59,7 +59,7 @@ a[[1 2], 1] = 0 a[:, [1 2]] = 2 @test a == 2ones(2,2) -a = Array(Float64, 2, 2, 2, 2, 2) +a = Array{Float64}(2, 2, 2, 2, 2) a[1,1,1,1,1] = 10 a[1,2,1,1,2] = 20 a[1,1,2,2,1] = 30 @@ -308,9 +308,9 @@ _array_equiv(a,b) = eltype(a) == eltype(b) && a == b @test_throws MethodError UInt8[1:3] @test_throws MethodError UInt8[1:3,] @test_throws MethodError UInt8[1:3,4:6] -a = Array(UnitRange{Int},1); a[1] = 1:3 +a = Array{UnitRange{Int}}(1); a[1] = 1:3 @test _array_equiv([1:3,], a) -a = Array(UnitRange{Int},2); a[1] = 1:3; a[2] = 4:6 +a = Array{UnitRange{Int}}(2); a[1] = 1:3; a[2] = 4:6 @test _array_equiv([1:3,4:6], a) # typed hvcat @@ -671,7 +671,7 @@ let R = repeat(A, inner = (1, 1, 2), outer = (1, 1, 1)) T = reshape([1:4; 1:4; 5:8; 5:8], 2, 2, 4) @test R == T - A = Array(Int, 2, 2, 2) + A = Array{Int}(2, 2, 2) A[:, :, 1] = [1 2; 3 4] A[:, :, 2] = [5 6; @@ -934,7 +934,7 @@ let end # fill -@test fill!(Array(Float64,1),-0.0)[1] === -0.0 +@test fill!(Array{Float64}(1),-0.0)[1] === -0.0 A = ones(3,3) S = sub(A, 2, 1:3) fill!(S, 2) @@ -943,11 +943,11 @@ fill!(S, 3) @test A == [1 1 3; 2 2 3; 1 1 1] rt = Base.return_types(fill!, Tuple{Array{Int32, 3}, UInt8}) @test length(rt) == 1 && rt[1] == Array{Int32, 3} -A = Array(Union{UInt8,Int8}, 3) +A = Array{Union{UInt8,Int8}}(3) fill!(A, UInt8(3)) @test A == [0x03, 0x03, 0x03] # Issue #9964 -A = Array(Vector{Float64}, 2) +A = Array{Vector{Float64}}(2) fill!(A, [1, 2]) @test A[1] == [1, 2] @test A[1] === A[2] @@ -1024,7 +1024,7 @@ end @test isequal(flipdim(1:10, 1), 10:-1:1) @test isequal(flipdim(1:10, 2), 1:10) @test_throws ArgumentError flipdim(1:10, -1) -@test isequal(flipdim(Array(Int,0,0),1), Array(Int,0,0)) # issue #5872 +@test isequal(flipdim(Array{Int}(0,0),1), Array{Int}(0,0)) # issue #5872 # isdiag, istril, istriu @test isdiag(3) @@ -1130,15 +1130,15 @@ end @test pr8622() == [0,3,1,0] #6828 - size of specific dimensions -a = Array(Float64, 10) +a = Array{Float64}(10) @test size(a) == (10,) @test size(a, 1) == 10 @test size(a,2,1) == (1,10) -a = Array(Float64, 2,3) +a = Array{Float64}(2,3) @test size(a) == (2,3) @test size(a,4,3,2,1) == (1,1,3,2) @test size(a,1,2) == (2,3) -a = Array(Float64, 9,8,7,6,5,4,3,2,1) +a = Array{Float64}(9,8,7,6,5,4,3,2,1) @test size(a,1,1) == (9,9) @test size(a,4) == 6 @test size(a,9,8,7,6,5,4,3,2,19,8,7,6,5,4,3,2,1) == (1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,9) diff --git a/test/bitarray.jl b/test/bitarray.jl index f0d705826016b..037b487643146 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -962,7 +962,7 @@ elts = (1:64:64*64+1) .+ (0:64) B1 = falses(maximum(elts)) B1[elts] = true B1′ = ~B1 -B2 = fill!(Array(Bool, maximum(elts)), false) +B2 = fill!(Array{Bool}(maximum(elts)), false) B2[elts] = true @test B1 == B2 @test all(B1 .== B2) diff --git a/test/core.jl b/test/core.jl index 8860ff48543c0..91e8e22ddc77d 100644 --- a/test/core.jl +++ b/test/core.jl @@ -66,8 +66,8 @@ let T = TypeVar(:T,true) Tuple{Number, Array{Number,1}}, isequal) @testintersect(Tuple{Array{T}, Array{T}}, Tuple{Array, Array{Any}}, Bottom, isnot) f47{T}(x::Vector{Vector{T}}) = 0 - @test_throws MethodError f47(Array(Vector,0)) - @test f47(Array(Vector{Int},0)) == 0 + @test_throws MethodError f47(Array{Vector}(0)) + @test f47(Array{Vector{Int}}(0)) == 0 @testintersect(Tuple{T,T}, Tuple{Union{Float64,Int64},Int64}, Tuple{Int64,Int64}) @testintersect(Tuple{T,T}, Tuple{Int64,Union{Float64,Int64}}, Tuple{Int64,Int64}) @@ -559,7 +559,7 @@ let @test !isdefined(a,1) && !isdefined(a,2) a[1] = 1 @test isdefined(a,1) && !isdefined(a,2) - a = Array(Float64,1) + a = Array{Float64}(1) @test isdefined(a,1) @test isdefined(a) @test !isdefined(a,2) @@ -582,7 +582,7 @@ let @test !isassigned(a,1) && !isassigned(a,2) a[1] = 1 @test isassigned(a,1) && !isassigned(a,2) - a = Array(Float64,1) + a = Array{Float64}(1) @test isassigned(a,1) @test isassigned(a) @test !isassigned(a,2) @@ -1068,7 +1068,7 @@ let # issue #1886 X = [1:4;] - r = Array(UnitRange{Int},1) + r = Array{UnitRange{Int}}(1) r[1] = 2:3 X[r...] *= 2 @test X == [1,4,6,4] @@ -1132,7 +1132,7 @@ immutable Foo2509; foo::Int; end # issue #2517 immutable Foo2517; end @test repr(Foo2517()) == "Foo2517()" -@test repr(Array(Foo2517,1)) == "Foo2517[Foo2517()]" +@test repr(Array{Foo2517}(1)) == "Foo2517[Foo2517()]" @test Foo2517() === Foo2517() # issue #1474 @@ -1261,13 +1261,13 @@ end # issue #3167 let function foo(x) - ret=Array(typeof(x[1]), length(x)) + ret=Array{typeof(x[1])}(length(x)) for j = 1:length(x) ret[j] = x[j] end return ret end - x = Array(Union{Dict{Int64,AbstractString},Array{Int64,3},Number,AbstractString,Void}, 3) + x = Array{Union{Dict{Int64,AbstractString},Array{Int64,3},Number,AbstractString,Void}}(3) x[1] = 1.0 x[2] = 2.0 x[3] = 3.0 @@ -1535,7 +1535,7 @@ end @test invalid_tupleref()==true # issue #5150 -f5150(T) = Array(Rational{T},1) +f5150(T) = Array{Rational{T}}(1) @test typeof(f5150(Int)) === Array{Rational{Int},1} @@ -1686,7 +1686,7 @@ type Polygon5884{T<:Real} end function test5884() - star = Array(Polygon5884,(3,)) + star = Array{Polygon5884}((3,)) star[1] = Polygon5884([Complex(1.0,1.0)]) p1 = star[1].points[1] @test p1 == Complex(1.0,1.0) @@ -1886,7 +1886,7 @@ end obj = ObjMember(DateRange6387{Int64}()) function v6387{T}(r::Range{T}) - a = Array(T,1) + a = Array{T}(1) a[1] = Core.Intrinsics.box(Date6387{Int64}, Core.Intrinsics.unbox(Int64,Int64(1))) a end @@ -1899,8 +1899,8 @@ end day_in(obj) # issue #6784 -@test ndims(Array(Array{Float64},3,5)) == 2 -@test ndims(Array(Array,3,5)) == 2 +@test ndims(Array{Array{Float64}}(3,5)) == 2 +@test ndims(Array{Array}(3,5)) == 2 # issue #6793 function segfault6793(;gamma=1) @@ -2147,7 +2147,7 @@ end # issue #9475 module I9475 - arr = Array(Any, 1) + arr = Array{Any}(1) @eval @eval $arr[1] = 1 end @@ -3213,7 +3213,7 @@ end # issue #12394 type Empty12394 end -let x = Array(Empty12394,1), y = [Empty12394()] +let x = Array{Empty12394}(1), y = [Empty12394()] @test_throws UndefRefError x==y @test_throws UndefRefError y==x end @@ -3358,7 +3358,7 @@ end #13433, read!(::IO, a::Vector{UInt8}) should return a type IO13433 <: IO end Base.read(::IO13433, ::Type{UInt8}) = 0x01 -@test read!(IO13433(), Array(UInt8, 4)) == [0x01, 0x01, 0x01, 0x01] +@test read!(IO13433(), Array{UInt8}(4)) == [0x01, 0x01, 0x01, 0x01] # issue #13647, comparing boxed isbits immutables immutable X13647 @@ -3408,7 +3408,7 @@ end # issue #8487 @test [x for x in 1:3] == [x for x ∈ 1:3] == [x for x = 1:3] -let A = Array(Int, 4,3) +let A = Array{Int}(4,3) for i ∈ 1:size(A,1), j ∈ 1:size(A,2) A[i,j] = 17*i + 51*j end @@ -3687,7 +3687,7 @@ end # issue #15180 function f15180{T}(x::T) - X = Array(T, 1) + X = Array{T}(1) X[1] = x @noinline ef{J}(::J) = (J,X[1]) # Use T ef{J}(::J, ::Int) = (T,J) diff --git a/test/datafmt.jl b/test/datafmt.jl index fe32b81f6408e..b801828e670ad 100644 --- a/test/datafmt.jl +++ b/test/datafmt.jl @@ -233,7 +233,7 @@ end for data in ["A B C", "A B C\n"] data,hdr = readdlm(IOBuffer(data), header=true) @test hdr == AbstractString["A" "B" "C"] - @test data == Array(Float64, 0, 3) + @test data == Array{Float64}(0, 3) end # fix #13179 parsing unicode lines with default delmiters @@ -262,4 +262,3 @@ for writefunc in ((io,x) -> writemime(io, "text/csv", x), @test vec(readcsv(io)) == x end end - diff --git a/test/dates/ranges.jl b/test/dates/ranges.jl index 3b5b3ff14bbf2..b21d6111b3102 100644 --- a/test/dates/ranges.jl +++ b/test/dates/ranges.jl @@ -272,7 +272,7 @@ end @test_throws MethodError dr + 1 a = Dates.DateTime(2013,1,1) b = Dates.DateTime(2013,2,1) -@test map!(x->x+Dates.Day(1),Array(Dates.DateTime,32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] +@test map!(x->x+Dates.Day(1),Array{Dates.DateTime}(32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->x+Dates.Day(1),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->a in x,drs[1:4]) == [true,true,false,true] @@ -350,7 +350,7 @@ end @test_throws MethodError dr + 1 a = Dates.Date(2013,1,1) b = Dates.Date(2013,2,1) -@test map!(x->x+Dates.Day(1),Array(Dates.Date,32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] +@test map!(x->x+Dates.Day(1),Array{Dates.Date}(32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->x+Dates.Day(1),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->a in x,drs[1:4]) == [true,true,false,true] diff --git a/test/fft.jl b/test/fft.jl index 22f5a731108f9..a15f0ab474262 100644 --- a/test/fft.jl +++ b/test/fft.jl @@ -32,7 +32,7 @@ b[3:6,9:12] = m4 sm4 = slice(b,3:6,9:12) m3d = map(Float32,copy(reshape(1:5*3*2, 5, 3, 2))) -true_fftd3_m3d = Array(Float32, 5, 3, 2) +true_fftd3_m3d = Array{Float32}(5, 3, 2) true_fftd3_m3d[:,:,1] = 17:2:45 true_fftd3_m3d[:,:,2] = -15 diff --git a/test/file.jl b/test/file.jl index 28d753560d617..f2f42213bd568 100644 --- a/test/file.jl +++ b/test/file.jl @@ -881,7 +881,7 @@ end ################### function test_LibcFILE(FILEp) - buf = Array(UInt8, 8) + buf = Array{UInt8}(8) str = ccall(:fread, Csize_t, (Ptr{Void}, Csize_t, Csize_t, Ptr{Void}), buf, 1, 8, FILEp) @test String(buf) == "Hello, w" @test position(FILEp) == 8 diff --git a/test/functional.jl b/test/functional.jl index db22d2fd89403..22770d455c91f 100644 --- a/test/functional.jl +++ b/test/functional.jl @@ -21,7 +21,7 @@ end # map over Bottom[] should return Bottom[] # issue #6719 -@test isequal(typeof(map(x -> x, Array(Union{},0))), Array{Union{},1}) +@test isequal(typeof(map(x -> x, Array{Union{}}(0))), Array{Union{},1}) # maps of tuples (formerly in test/core.jl) -- tuple.jl @test map((x,y)->x+y,(1,2,3),(4,5,6)) == (5,7,9) diff --git a/test/grisu.jl b/test/grisu.jl index 02bcb5bb7fe38..77674f05931f3 100644 --- a/test/grisu.jl +++ b/test/grisu.jl @@ -14,7 +14,7 @@ function trimrep(buffer) end const bufsize = 500 -buffer = Array(UInt8,bufsize); +buffer = Array{UInt8}(bufsize); fill!(buffer,0); bignums = [Grisu.Bignums.Bignum(),Grisu.Bignums.Bignum(),Grisu.Bignums.Bignum(),Grisu.Bignums.Bignum()] diff --git a/test/iobuffer.jl b/test/iobuffer.jl index 6c5a06965d346..1f6d3c62d249b 100644 --- a/test/iobuffer.jl +++ b/test/iobuffer.jl @@ -14,7 +14,7 @@ let io = IOBuffer() @test eof(io) seek(io, 0) @test read(io,UInt8) == convert(UInt8, 'a') -a = Array(UInt8, 2) +a = Array{UInt8}(2) @test read!(io, a) == a @test a == UInt8['b','c'] @test String(io) == "abc" @@ -128,7 +128,7 @@ end # issue 5453 let io=IOBuffer("abcdef") -a = Array(UInt8,1024) +a = Array{UInt8}(1024) @test_throws EOFError read!(io,a) @test eof(io) end diff --git a/test/linalg/generic.jl b/test/linalg/generic.jl index 2baa42b7aed46..84b06128b4324 100644 --- a/test/linalg/generic.jl +++ b/test/linalg/generic.jl @@ -131,7 +131,7 @@ let aa = reshape([1.:6;], (2,3)) @test scale!(similar(a), [1.; 2.], a) == a.*[1; 2] @test scale!(similar(a), [1; 2], a) == a.*[1; 2] @test_throws DimensionMismatch scale!(similar(a), ones(3), a) - @test_throws DimensionMismatch scale!(Array(Float64, 3, 2), a, ones(3)) + @test_throws DimensionMismatch scale!(Array{Float64}(3, 2), a, ones(3)) if atype == "Array" @test scale!(similar(a), a, [1.; 2.; 3.]) == a.*[1 2 3] diff --git a/test/linalg/matmul.jl b/test/linalg/matmul.jl index ec7070d7d6e4c..803d44b1ff654 100644 --- a/test/linalg/matmul.jl +++ b/test/linalg/matmul.jl @@ -12,10 +12,10 @@ using Base.Test @test ones(0,0)*ones(0,4) == zeros(0,4) @test ones(3,0)*ones(0,0) == zeros(3,0) @test ones(0,0)*ones(0,0) == zeros(0,0) -@test Array(Float64, 5, 0) |> t -> t't == zeros(0,0) -@test Array(Float64, 5, 0) |> t -> t*t' == zeros(5,5) -@test Array(Complex128, 5, 0) |> t -> t't == zeros(0,0) -@test Array(Complex128, 5, 0) |> t -> t*t' == zeros(5,5) +@test Array{Float64}(5, 0) |> t -> t't == zeros(0,0) +@test Array{Float64}(5, 0) |> t -> t*t' == zeros(5,5) +@test Array{Complex128}(5, 0) |> t -> t't == zeros(0,0) +@test Array{Complex128}(5, 0) |> t -> t*t' == zeros(5,5) # 2x2 let @@ -97,7 +97,7 @@ let end AA = rand(1:20, 5, 5) .- 10 BB = rand(1:20, 5, 5) .- 10 - CC = Array(Int, size(AA, 1), size(BB, 2)) + CC = Array{Int}(size(AA, 1), size(BB, 2)) for Atype = ["Array", "SubArray"], Btype = ["Array", "SubArray"], Ctype = ["Array", "SubArray"] A = Atype == "Array" ? AA : sub(AA, 1:5, 1:5) B = Btype == "Array" ? BB : sub(BB, 1:5, 1:5) @@ -116,7 +116,7 @@ let @test_throws DimensionMismatch Base.LinAlg.Ac_mul_Bt!(C,ones(Int,4,4),B) end vv = [1,2] - CC = Array(Int, 2, 2) + CC = Array{Int}(2, 2) for vtype = ["Array", "SubArray"], Ctype = ["Array", "SubArray"] v = vtype == "Array" ? vv : sub(vv, 1:2) C = Ctype == "Array" ? CC : sub(CC, 1:2, 1:2) @@ -135,14 +135,14 @@ let @test_throws DimensionMismatch Base.LinAlg.generic_matvecmul!(B,'N',A,zeros(6)) end vv = [1,2,3] - CC = Array(Int, 3, 3) + CC = Array{Int}(3, 3) for vtype = ["Array", "SubArray"], Ctype = ["Array", "SubArray"] v = vtype == "Array" ? vv : sub(vv, 1:3) C = Ctype == "Array" ? CC : sub(CC, 1:3, 1:3) @test A_mul_Bt!(C, v, v) == v*v' end vvf = map(Float64,vv) - CC = Array(Float64, 3, 3) + CC = Array{Float64}(3, 3) for vtype = ["Array", "SubArray"], Ctype = ["Array", "SubArray"] vf = vtype == "Array" ? vvf : sub(vvf, 1:3) C = Ctype == "Array" ? CC : sub(CC, 1:3, 1:3) @@ -276,12 +276,12 @@ end # Issue 11978 let - A = Array(Matrix{Float64}, 2, 2) + A = Array{Matrix{Float64}}(2, 2) A[1,1] = eye(3) A[1,2] = eye(3,2) A[2,1] = eye(2,3) A[2,2] = eye(2) - b = Array(Vector{Float64}, 2) + b = Array{Vector{Float64}}(2) b[1] = ones(3) b[2] = ones(2) @test A*b == Vector{Float64}[[2,2,1], [2,2]] diff --git a/test/linalg/pinv.jl b/test/linalg/pinv.jl index bb82798723be3..77d9d29749036 100644 --- a/test/linalg/pinv.jl +++ b/test/linalg/pinv.jl @@ -9,7 +9,7 @@ debug = false using Base.Test function hilb(T::Type, n::Integer) - a=Array(T,n,n) + a=Array{T}(n,n) for i=1:n for j=1:n a[j,i]=one(T)/(i+j-one(T)) @@ -20,7 +20,7 @@ end hilb(n::Integer) = hilb(Float64,n) function hilb(T::Type, m::Integer, n::Integer) - a=Array(T,m,n) + a=Array{T}(m,n) for i=1:n for j=1:m a[j,i]=one(T)/(i+j-one(T)) @@ -67,7 +67,7 @@ tridiag(m::Integer, n::Integer) = tridiag(Float64, m::Integer, n::Integer) function randn_float64(m::Integer, n::Integer) a=randn(m,n) - b=Array(Float64,m,n) + b=Array{Float64}(m,n) for i=1:n for j=1:m b[j,i]=convert(Float64,a[j,i]); @@ -78,7 +78,7 @@ end function randn_float32(m::Integer, n::Integer) a=randn(m,n) - b=Array(Float32,m,n) + b=Array{Float32}(m,n) for i=1:n for j=1:m b[j,i]=convert(Float32,a[j,i]); @@ -325,4 +325,3 @@ for eltya in (Float32, Float64) @test_approx_eq a.diag[1] 0.0 @test_approx_eq a.diag[2] 0.0 end - diff --git a/test/mmap.jl b/test/mmap.jl index b378427890926..432f6cf210306 100644 --- a/test/mmap.jl +++ b/test/mmap.jl @@ -9,12 +9,12 @@ gc(); gc() gc(); gc() @test Mmap.mmap(file, Array{UInt8,3}, (1,1,11)) == reshape(t,(1,1,11)) gc(); gc() -@test Mmap.mmap(file, Array{UInt8,3}, (11,0,1)) == Array(UInt8,(0,0,0)) +@test Mmap.mmap(file, Array{UInt8,3}, (11,0,1)) == Array{UInt8}((0,0,0)) @test Mmap.mmap(file, Vector{UInt8}, (11,)) == t gc(); gc() @test Mmap.mmap(file, Array{UInt8,2}, (1,11)) == t' gc(); gc() -@test Mmap.mmap(file, Array{UInt8,2}, (0,12)) == Array(UInt8,(0,0)) +@test Mmap.mmap(file, Array{UInt8,2}, (0,12)) == Array{UInt8}((0,0)) m = Mmap.mmap(file, Array{UInt8,3}, (1,2,1)) @test m == reshape("He".data,(1,2,1)) finalize(m); m=nothing; gc() @@ -46,8 +46,8 @@ close(s) gc(); gc() s = open(f->f,file,"w") -@test Mmap.mmap(file) == Array(UInt8, 0) # requested len=0 on empty file -@test Mmap.mmap(file,Vector{UInt8},0) == Array(UInt8, 0) +@test Mmap.mmap(file) == Array{UInt8}(0) # requested len=0 on empty file +@test Mmap.mmap(file,Vector{UInt8},0) == Array{UInt8}(0) m = Mmap.mmap(file,Vector{UInt8},12) m[:] = "Hello World\n".data Mmap.sync!(m) diff --git a/test/mod2pi.jl b/test/mod2pi.jl index e240bc0b47648..f73aecdb4ee69 100644 --- a/test/mod2pi.jl +++ b/test/mod2pi.jl @@ -155,7 +155,7 @@ function testModPi() numTestCases = size(testCases,1) modFns = [mod2pi] xDivisors = [2pi] - errsNew, errsOld = Array(Float64,0), Array(Float64,0) + errsNew, errsOld = Array{Float64}(0), Array{Float64}(0) for rowIdx in 1:numTestCases xExact = testCases[rowIdx,1] for colIdx in 1:1 diff --git a/test/netload/memtest.jl b/test/netload/memtest.jl index 38bab1e072623..fda4b973e2f39 100644 --- a/test/netload/memtest.jl +++ b/test/netload/memtest.jl @@ -22,7 +22,7 @@ immutable RUsage end function get_vmsize() - ru = Array(RUsage, 1) + ru = Array{RUsage}(1) ccall(:getrusage, Cint, (Cint, Ptr{Void}), 0, ru) return ru[1].ru_maxrss end diff --git a/test/parallel_exec.jl b/test/parallel_exec.jl index 0c804a9239f35..1a6c1d80639d9 100644 --- a/test/parallel_exec.jl +++ b/test/parallel_exec.jl @@ -255,7 +255,7 @@ end d = Base.shmem_rand(1:100, dims) a = convert(Array, d) -partsums = Array(Int, length(procs(d))) +partsums = Array{Int}(length(procs(d))) @sync begin for (i, p) in enumerate(procs(d)) @async partsums[i] = remotecall_fetch(p, d) do D @@ -354,7 +354,7 @@ write(fn3, ones(UInt8, 4)) S = SharedArray(fn3, UInt8, sz, 4, mode="a+", init=D->D[localindexes(D)]=0x02) len = prod(sz)+4 @test filesize(fn3) == len -filedata = Array(UInt8, len) +filedata = Array{UInt8}(len) read!(fn3, filedata) @test all(filedata[1:4] .== 0x01) @test all(filedata[5:end] .== 0x02) diff --git a/test/perf/cat/perf.jl b/test/perf/cat/perf.jl index c039158c2423d..33c2bc43d0491 100644 --- a/test/perf/cat/perf.jl +++ b/test/perf/cat/perf.jl @@ -14,7 +14,7 @@ function cat2d_perf2(n, iter) a = rand(n,n) b = rand(n,n) for i=1:iter - c = Array(Float64,2n,2n) + c = Array{Float64}(2n,2n) c[ 1:n, 1:n] = a c[ 1:n, n+1:end] = b c[n+1:end,1:n] = b @@ -35,7 +35,7 @@ function hcat_perf2(n, iter) a = rand(n,n) b = rand(n,n) for i=1:iter - c = Array(Float64, n, 4n) + c = Array{Float64}(n, 4n) c[:, 1: n] = a c[:, n+1: 2n] = b c[:, 2n+1: 3n] = b @@ -55,7 +55,7 @@ function vcat_perf2(n, iter) a = rand(n,n) b = rand(n,n) for i=1:iter - c = Array(Float64, 4n, n) + c = Array{Float64}(4n, n) c[ 1: n, :] = a c[ n+1:2n, :] = b c[2n+1:3n, :] = b @@ -75,7 +75,7 @@ function catnd_perf2(n, iter) a = rand(1,n,n,1) b = rand(1,n,n) for i = 1:iter - c = Array(Float64, 1, n, 4n, 1) + c = Array{Float64}(1, n, 4n, 1) c[1,:, 1: n,1] = a c[1,:, n+1:2n,1] = b c[1,:,2n+1:3n,1] = b @@ -93,4 +93,3 @@ testdata = [(cat2d_perf, "hvcat", "horizontal/vertical matrix concatenat (catnd_perf, "catnd", "N-dimensional matrix concatenation", problemsizes), (catnd_perf2, "catnd_setind", "N-dimensional matrix concatenation using setindex", problemsizes)] include("../perfgeneric.jl") - diff --git a/test/perf/kernel/perf.jl b/test/perf/kernel/perf.jl index 9977ac1383fcf..928ca1ef6f0b8 100644 --- a/test/perf/kernel/perf.jl +++ b/test/perf/kernel/perf.jl @@ -25,7 +25,7 @@ gc() # issue #1211 include("ziggurat.jl") -a = Array(Float64, 1000000) +a = Array{Float64}(1000000) @timeit randn_zig!(a) "randn_zig" "Ziggurat gaussian number generator" # issue #950 diff --git a/test/perf/perfutil.jl b/test/perf/perfutil.jl index c10650bc1c06d..da9a627e76d3b 100644 --- a/test/perf/perfutil.jl +++ b/test/perf/perfutil.jl @@ -99,7 +99,7 @@ end function maxrss(name) # FIXME: call uv_getrusage instead here @static if is_linux() - rus = Array(Int64, div(144,8)) + rus = Array{Int64}(div(144,8)) fill!(rus, 0x0) res = ccall(:getrusage, Int32, (Int32, Ptr{Void}), 0, rus) if res == 0 diff --git a/test/perf/shootout/fannkuch.jl b/test/perf/shootout/fannkuch.jl index 58da84581d23e..9db19200bdad5 100644 --- a/test/perf/shootout/fannkuch.jl +++ b/test/perf/shootout/fannkuch.jl @@ -8,7 +8,7 @@ # Based on the Javascript program # function fannkuch(n) - p = Array(Int32,n) + p = Array{Int32}(n) for i = 1:n p[i] = i end diff --git a/test/perf/shootout/fasta.jl b/test/perf/shootout/fasta.jl index 702f0853269ba..13bbec2c22875 100644 --- a/test/perf/shootout/fasta.jl +++ b/test/perf/shootout/fasta.jl @@ -42,7 +42,7 @@ function choose_char(cs) end function random_fasta(symb, pr, n) cs = cumsum(pr) - line = Array(UInt8, line_width) + line = Array{UInt8}(line_width) k = n while k > 0 m = min(k, line_width) diff --git a/test/perf/shootout/k_nucleotide.jl b/test/perf/shootout/k_nucleotide.jl index e81a3e44e2401..97f39624ff99d 100644 --- a/test/perf/shootout/k_nucleotide.jl +++ b/test/perf/shootout/k_nucleotide.jl @@ -40,7 +40,7 @@ function isless(x::KNuc, y::KNuc) end function sorted_array(m::Dict{AbstractString, Int}) - kn = Array(KNuc, length(m)) + kn = Array{KNuc}(length(m)) i = 1 for elem in m kn[i] = KNuc(elem...) diff --git a/test/perf/shootout/meteor_contest.jl b/test/perf/shootout/meteor_contest.jl index e7a22f8b4707c..ab9a235a28f68 100644 --- a/test/perf/shootout/meteor_contest.jl +++ b/test/perf/shootout/meteor_contest.jl @@ -44,7 +44,7 @@ const pieces = ( const solutions = Any[] const masks = zeros(UInt64, 10) -const masksAtCell = Array(Any, width*height, height) +const masksAtCell = Array{Any}(width*height, height) valid(x, y) = (0 <= x < width) && (0 <= y < height) legal(mask::UInt64, board::UInt64) = (mask & board) == 0 diff --git a/test/perf/sort/perf.jl b/test/perf/sort/perf.jl index e729dafde7787..81ab363141c8b 100644 --- a/test/perf/sort/perf.jl +++ b/test/perf/sort/perf.jl @@ -19,7 +19,7 @@ if codespeed for size in [2^6,2^16] for s in sorts if s == InsertionSort && size != 2^6; continue; end - data = Array(T, size) + data = Array{T}(size) gc() ## Random @@ -29,7 +29,7 @@ if codespeed name = "$(typename)_$(size)_$(string(s)[1:end-5])_append" desc = "$(string(s)) run on $(size) $(typename) elements pre-sorted 10 random elements appended" - @timeit_init(sort!(data, alg=s), begin data[end-9:end]=randfn!(Array(T,10)) end, name, "") + @timeit_init(sort!(data, alg=s), begin data[end-9:end]=randfn!(Array{T}(10)) end, name, "") end end end @@ -44,7 +44,7 @@ else if s == RadixSort && T == AbstractString continue end #Radix sort not implemented if s == InsertionSort && logsize >=14 continue end #Too slow println(s, s==RadixSort, s, typename, typename==AbstractString, logsize) - data = Array(T, size) + data = Array{T}(size) gc() ## Random @@ -73,7 +73,7 @@ else ## Sorted with 10 unsorted values appended name = "$(typename)_$(logsize)_$(string(s)[1:end-5])_append" - @timeit_init(sort!(data, alg=s), begin data[end-9:end]=randfn!(Array(T,10)) end, name, "") + @timeit_init(sort!(data, alg=s), begin data[end-9:end]=randfn!(Array{T}(10)) end, name, "") ## Random data with 4 unique values name = "$(typename)_$(logsize)_$(string(s)[1:end-5])_4unique" diff --git a/test/perf/threads/laplace3d/laplace3d.jl b/test/perf/threads/laplace3d/laplace3d.jl index f6dc15d838f84..c27956b25205d 100644 --- a/test/perf/threads/laplace3d/laplace3d.jl +++ b/test/perf/threads/laplace3d/laplace3d.jl @@ -87,8 +87,8 @@ end ## initialize and run function laplace3d(nx=290, ny=290, nz=290; iters=1000, verify=false) - u1 = Array(Float32, nx, ny, nz) - u3 = Array(Float32, nx, ny, nz) + u1 = Array{Float32}(nx, ny, nz) + u3 = Array{Float32}(nx, ny, nz) @nloops 3 k u1 begin if @nany 3 d->(k_d == 1 || k_d == size(u1, d)) (@nref 3 u3 k) = (@nref 3 u1 k) = 1.0 @@ -106,8 +106,8 @@ function laplace3d(nx=290, ny=290, nz=290; iters=1000, verify=false) u3 = foo end if verify - u1_orig = Array(Float32, nx, ny, nz) - u3_orig = Array(Float32, nx, ny, nz) + u1_orig = Array{Float32}(nx, ny, nz) + u3_orig = Array{Float32}(nx, ny, nz) @nloops 3 k u1_orig begin if @nany 3 d->(k_d == 1 || k_d == size(u1_orig, d)) (@nref 3 u3_orig k) = (@nref 3 u1_orig k) = 1.0 @@ -133,4 +133,3 @@ end @time laplace3d() #ccall(:jl_threading_profile, Void, ()) - diff --git a/test/perf/threads/lbm3d/lbm3d.jl b/test/perf/threads/lbm3d/lbm3d.jl index f1464a13f3b40..7639cdd2719de 100644 --- a/test/perf/threads/lbm3d/lbm3d.jl +++ b/test/perf/threads/lbm3d/lbm3d.jl @@ -46,7 +46,7 @@ function relax!(F, UX, UY, UZ, nx, ny, nz, deltaU, t1D, t2D, t3D, sSQU, chunkid, for l = 1:size(F,4) density = density + F[i,j,k,l] end - fs = Array(Float64, 6) + fs = Array{Float64}(6) for l = 1:6 fs[l] = 0.0 for m = 1:5 @@ -139,7 +139,7 @@ function lbm3d(n) CI = [0:matsize:matsize*19;]' - BOUND = Array(Float64,nx,ny,nz) + BOUND = Array{Float64}(nx,ny,nz) for i=1:nx, j=1:ny, k=1:nz BOUND[i,j,k] = ((i-5)^2 + (j-6)^2 + (k-7)^2) < 6 @@ -153,14 +153,14 @@ function lbm3d(n) TO_REFLECT = [ON+CI[2] ON+CI[3] ON+CI[4] ON+CI[5] ON+CI[6] ON+CI[7] ON+CI[8] ON+CI[9] ON+CI[10] ON+CI[11] ON+CI[12] ON+CI[13] ON+CI[14] ON+CI[15] ON+CI[16] ON+CI[17] ON+CI[18] ON+CI[19]] REFLECTED = [ON+CI[3] ON+CI[2] ON+CI[5] ON+CI[4] ON+CI[7] ON+CI[6] ON+CI[11] ON+CI[10] ON+CI[9] ON+CI[8] ON+CI[15] ON+CI[14] ON+CI[13] ON+CI[12] ON+CI[19] ON+CI[18] ON+CI[17] ON+CI[16]] - UX = Array(Float64,nx,ny,nz) - UY = Array(Float64,nx,ny,nz) - UZ = Array(Float64,nx,ny,nz) - U = Array(Float64,12,nchunk) - t1D = Array(Float64,nx,ny,nz) - t2D = Array(Float64,nx,ny,nz) - t3D = Array(Float64,nx,ny,nz) - sSQU = Array(Float64,nx,ny,nz) + UX = Array{Float64}(nx,ny,nz) + UY = Array{Float64}(nx,ny,nz) + UZ = Array{Float64}(nx,ny,nz) + U = Array{Float64}(12,nchunk) + t1D = Array{Float64}(nx,ny,nz) + t2D = Array{Float64}(nx,ny,nz) + t3D = Array{Float64}(nx,ny,nz) + sSQU = Array{Float64}(nx,ny,nz) avu = 1 prevavu = 1 @@ -220,4 +220,3 @@ end @time lbm3d(36) #ccall(:jl_threading_profile, Void, ()) - diff --git a/test/perf/threads/stockcorr/pstockcorr.jl b/test/perf/threads/stockcorr/pstockcorr.jl index cbf3790d6ef54..076feb7cc58b2 100644 --- a/test/perf/threads/stockcorr/pstockcorr.jl +++ b/test/perf/threads/stockcorr/pstockcorr.jl @@ -83,8 +83,8 @@ function pstockcorr(n) # Optimization: pre-allocate these for performance # NOTE: the new GC will hopefully fix this, but currently GC time # kills performance if we don't do in-place computations - Wiener = Array(Float64, T-1, 2) - CorrWiener = Array(Float64, T-1, 2) + Wiener = Array{Float64}(T-1, 2) + CorrWiener = Array{Float64}(T-1, 2) # Runtime requirement: need per-thread RNG since it stores state rngs = [MersenneTwister(777+x) for x in 1:nthreads()] @@ -108,4 +108,3 @@ end @time pstockcorr(1000000) #ccall(:jl_threading_profile, Void, ()) - diff --git a/test/pollfd.jl b/test/pollfd.jl index a151b42dd663a..7a44a99d83567 100644 --- a/test/pollfd.jl +++ b/test/pollfd.jl @@ -14,10 +14,10 @@ intvls = [2, .2, .1, .005] pipe_fds = cell(n) for i in 1:n @static if is_windows() - pipe_fds[i] = Array(Libc.WindowsRawSocket, 2) + pipe_fds[i] = Array{Libc.WindowsRawSocket}(2) 0 == ccall(:wsasocketpair, Cint, (Cint, Cuint, Cint, Ptr{Libc.WindowsRawSocket}), 1, 1, 6, pipe_fds[i]) || error(Libc.FormatMessage()) else - pipe_fds[i] = Array(RawFD, 2) + pipe_fds[i] = Array{RawFD}(2) @test 0 == ccall(:pipe, Cint, (Ptr{RawFD},), pipe_fds[i]) end end @@ -36,7 +36,7 @@ function pfd_tst_reads(idx, intvl) # Disabled since this assertion fails randomly, notably on build VMs (issue #12824) # @test t_elapsed <= (intvl + 1) - dout = Array(UInt8, 1) + dout = Array{UInt8}(1) @static if is_windows() 1 == ccall(:recv, stdcall, Cint, (Ptr{Void}, Ptr{UInt8}, Cint, Cint), pipe_fds[idx][1], dout, 1, 0) || error(Libc.FormatMessage()) else diff --git a/test/random.jl b/test/random.jl index 3c5ce09e1e556..5dd1c2aa4ba60 100644 --- a/test/random.jl +++ b/test/random.jl @@ -41,14 +41,14 @@ A = zeros(UInt128, 2, 2) let mt = MersenneTwister() srand(mt) @test rand(mt, 0:3:1000) in 0:3:1000 - @test issubset(rand!(mt, Array(Int, 100), 0:3:1000), 0:3:1000) + @test issubset(rand!(mt, Array{Int}(100), 0:3:1000), 0:3:1000) coll = Any[2, UInt128(128), big(619), "string"] @test rand(mt, coll) in coll @test issubset(rand(mt, coll, 2, 3), coll) # check API with default RNG: rand(0:3:1000) - rand!(Array(Int, 100), 0:3:1000) + rand!(Array{Int}(100), 0:3:1000) rand(coll) rand(coll, 2, 3) end @@ -119,13 +119,13 @@ emantissa = Int64(2)^52 ziggurat_exp_r = parse(BigFloat,"7.69711747013104971404462804811408952334296818528283253278834867283241051210533") exp_section_area = (ziggurat_exp_r + 1)*exp(-ziggurat_exp_r) -ki = Array(UInt64, ziggurat_table_size) -wi = Array(Float64, ziggurat_table_size) -fi = Array(Float64, ziggurat_table_size) +ki = Array{UInt64}(ziggurat_table_size) +wi = Array{Float64}(ziggurat_table_size) +fi = Array{Float64}(ziggurat_table_size) # Tables for exponential variates -ke = Array(UInt64, ziggurat_table_size) -we = Array(Float64, ziggurat_table_size) -fe = Array(Float64, ziggurat_table_size) +ke = Array{UInt64}(ziggurat_table_size) +we = Array{Float64}(ziggurat_table_size) +fe = Array{Float64}(ziggurat_table_size) function randmtzig_fill_ziggurat_tables() # Operates on the global arrays wib = big(wi) fib = big(fi) @@ -234,7 +234,7 @@ end # test code paths of rand! let mt = MersenneTwister(0) - A128 = Array(UInt128, 0) + A128 = Array{UInt128}(0) @test length(rand!(mt, A128)) == 0 for (i,n) in enumerate([1, 3, 5, 6, 10, 11, 30]) resize!(A128, n) @@ -251,8 +251,8 @@ let mt = MersenneTwister(0) srand(mt,0) for (i,T) in enumerate([Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, Float16, Float32]) - A = Array(T, 16) - B = Array(T, 31) + A = Array{T}(16) + B = Array{T}(31) rand!(mt, A) rand!(mt, B) @test A[end] == Any[21,0x7b,17385,0x3086,-1574090021,0xadcb4460,6797283068698303107,0x4e91c9c4d4f5f759, @@ -263,7 +263,7 @@ let mt = MersenneTwister(0) end srand(mt,0) - AF64 = Array(Float64, Base.Random.dsfmt_get_min_array_size()-1) + AF64 = Array{Float64}(Base.Random.dsfmt_get_min_array_size()-1) @test rand!(mt, AF64)[end] == 0.957735065345398 @test rand!(mt, AF64)[end] == 0.6492481059865669 resize!(AF64, 2*length(mt.vals)) @@ -272,10 +272,10 @@ end # Issue #9037 let mt = MersenneTwister() - a = Array(Float64, 0) + a = Array{Float64}(0) resize!(a, 1000) # could be 8-byte aligned - b = Array(Float64, 1000) # should be 16-byte aligned - c8 = Array(UInt64, 1001) + b = Array{Float64}(1000) # should be 16-byte aligned + c8 = Array{UInt64}(1001) pc8 = pointer(c8) if Int(pc8) % 16 == 0 # Make sure pc8 is not 16-byte aligned since that's what we want to test. @@ -306,8 +306,8 @@ for rng in ([], [MersenneTwister()], [RandomDevice()]) f(rng..., 2, 3) ::Array{Float64, 2} end for f! in [randn!, randexp!] - f!(rng..., Array(Float64, 5)) ::Vector{Float64} - f!(rng..., Array(Float64, 2, 3)) ::Array{Float64, 2} + f!(rng..., Array{Float64}(5)) ::Vector{Float64} + f!(rng..., Array{Float64}(2, 3)) ::Array{Float64, 2} end bitrand(rng..., 5) ::BitArray{1} @@ -324,7 +324,7 @@ for rng in ([], [MersenneTwister()], [RandomDevice()]) @test 0.0 <= a < 1.0 end end - for A in (Array(T, 5), Array(T, 2, 3)) + for A in (Array{T}(5), Array{T}(2, 3)) X = T == Bool ? T[0,1] : T[0,1,2] rand!(rng..., A) ::typeof(A) rand!(rng..., A, X) ::typeof(A) diff --git a/test/serialize.jl b/test/serialize.jl index 0e2f4b062079d..c1dd18e5a575a 100644 --- a/test/serialize.jl +++ b/test/serialize.jl @@ -204,7 +204,7 @@ create_serialization_stream() do s # small 1d array arr4 = reshape([true, false, false, false, true, false, false, false, true], 3, 3) serialize(s, arr4) # boolean array - arr5 = Array(TA1, 3) + arr5 = Array{TA1}(3) arr5[2] = TA1(0x01) serialize(s, arr5) diff --git a/test/simdloop.jl b/test/simdloop.jl index 771383aedf419..4ea2f82ba8355 100644 --- a/test/simdloop.jl +++ b/test/simdloop.jl @@ -103,27 +103,27 @@ end crng = CartesianRange(CartesianIndex{4}(2,0,1,3), CartesianIndex{4}(4,1,1,5)) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == vec(collect(crng)) crng = CartesianRange(CartesianIndex{2}(-1,1), CartesianIndex{2}(1,3)) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == vec(collect(crng)) crng = CartesianRange(CartesianIndex{2}(-1,1), CartesianIndex{2}(-1,3)) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == vec(collect(crng)) crng = CartesianRange(CartesianIndex{1}(2), CartesianIndex{1}(4)) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == collect(crng) crng = CartesianRange(CartesianIndex{0}(), CartesianIndex{0}()) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == vec(collect(crng)) # @simd with array as "range" diff --git a/test/sparsedir/sparse.jl b/test/sparsedir/sparse.jl index 9ed4ff2a882b8..cbfc014619bb0 100644 --- a/test/sparsedir/sparse.jl +++ b/test/sparsedir/sparse.jl @@ -333,10 +333,10 @@ end @test var(sparse(Int[])) === NaN for f in (sum, prod, minimum, maximum, var) - @test isequal(f(spzeros(0, 1), 1), f(Array(Int, 0, 1), 1)) - @test isequal(f(spzeros(0, 1), 2), f(Array(Int, 0, 1), 2)) - @test isequal(f(spzeros(0, 1), (1, 2)), f(Array(Int, 0, 1), (1, 2))) - @test isequal(f(spzeros(0, 1), 3), f(Array(Int, 0, 1), 3)) + @test isequal(f(spzeros(0, 1), 1), f(Array{Int}(0, 1), 1)) + @test isequal(f(spzeros(0, 1), 2), f(Array{Int}(0, 1), 2)) + @test isequal(f(spzeros(0, 1), (1, 2)), f(Array{Int}(0, 1), (1, 2))) + @test isequal(f(spzeros(0, 1), 3), f(Array{Int}(0, 1), 3)) end # spdiagm @@ -704,7 +704,7 @@ let S = spzeros(10,8), A = full(S) @test indmin(S) == indmin(A) == 1 end -let A = Array(Int,0,0), S = sparse(A) +let A = Array{Int}(0,0), S = sparse(A) iA = try indmax(A) end iS = try indmax(S) end @test iA === iS === nothing diff --git a/test/sparsedir/sparsevector.jl b/test/sparsedir/sparsevector.jl index 48fdf459c28ce..9db76dddae6ee 100644 --- a/test/sparsedir/sparsevector.jl +++ b/test/sparsedir/sparsevector.jl @@ -365,7 +365,7 @@ end ### Concatenation let m = 80, n = 100 - A = Array(SparseVector{Float64,Int}, n) + A = Array{SparseVector{Float64,Int}}(n) tnnz = 0 for i = 1:length(A) A[i] = sprand(m, 0.3) diff --git a/test/staged.jl b/test/staged.jl index 3caa679dd619b..0a635ee1a1ba4 100644 --- a/test/staged.jl +++ b/test/staged.jl @@ -74,7 +74,7 @@ B = slice(A, 1:3, 2, 1:3); end Ip = I.parameters NP = length(Ip) - indexexprs = Array(Expr, NP) + indexexprs = Array{Expr}(NP) j = 1 for i = 1:NP if Ip[i] == Int diff --git a/test/subarray.jl b/test/subarray.jl index 26204738c0300..9df96e9ccce8b 100644 --- a/test/subarray.jl +++ b/test/subarray.jl @@ -38,7 +38,7 @@ _Agen(A, i1, i2, i3) = [A[j1,j2,j3] for j1 in i1, j2 in i2, j3 in i3] _Agen(A, i1, i2, i3, i4) = [A[j1,j2,j3,j4] for j1 in i1, j2 in i2, j3 in i3, j4 in i4] function replace_colon(A::AbstractArray, I) - Iout = Array(Any, length(I)) + Iout = Array{Any}(length(I)) for d = 1:length(I)-1 Iout[d] = isa(I[d], Colon) ? (1:size(A,d)) : I[d] end @@ -51,7 +51,7 @@ end # it's good to copy the contents to an Array. This version protects against # `similar` ever changing its meaning. function copy_to_array(A::AbstractArray) - Ac = Array(eltype(A), size(A)) + Ac = Array{eltype(A)}(size(A)) copy!(Ac, A) end diff --git a/test/threads.jl b/test/threads.jl index a2083a13224d1..d2130690c5a70 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -47,8 +47,8 @@ function test_threaded_atomic_minmax{T}(m::T,n::T) mid = m + (n-m)>>1 x = Atomic{T}(mid) y = Atomic{T}(mid) - oldx = Array(T,n-m+1) - oldy = Array(T,n-m+1) + oldx = Array{T}(n-m+1) + oldy = Array{T}(n-m+1) @threads for i = m:n oldx[i-m+1] = atomic_min!(x, T(i)) oldy[i-m+1] = atomic_max!(y, T(i)) diff --git a/test/unicode/utf32.jl b/test/unicode/utf32.jl index dba0c4922a48f..875c22330749d 100644 --- a/test/unicode/utf32.jl +++ b/test/unicode/utf32.jl @@ -8,7 +8,7 @@ u32 = utf32(u8) @test length(u32) == 5 @test String(u32) == u8 @test collect(u8) == collect(u32) -@test u8 == utf32(u32.data[1:end-1]) == utf32(copy!(Array(UInt8, 20), 1, reinterpret(UInt8, u32.data), 1, 20)) +@test u8 == utf32(u32.data[1:end-1]) == utf32(copy!(Array{UInt8}(20), 1, reinterpret(UInt8, u32.data), 1, 20)) @test u8 == utf32(pointer(u32)) == utf32(convert(Ptr{Int32}, pointer(u32))) @test_throws UnicodeError utf32(UInt8[1,2,3])