Skip to content

Commit

Permalink
Deprecate Array(T, dims...)
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Jan 13, 2017
1 parent fd14951 commit 7025505
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 30 deletions.
9 changes: 9 additions & 0 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ typealias DenseVecOrMat{T} Union{DenseVector{T}, DenseMatrix{T}}

import Core: arraysize, arrayset, arrayref

"""
Array{T,N}(dims)
Construct an uninitialized `N`-dimensional dense array with element type `T`. `dims` may
be a tuple or a series of integer arguments corresponding to the length in each dimension.
If the rank `N` is omitted, i.e. `Array{T}(dims)`, the rank is determined based on `dims`.
"""
Array

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

Expand Down
2 changes: 1 addition & 1 deletion base/asyncmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ end

# Special handling for some types.
function asyncmap(f, s::AbstractString; kwargs...)
s2=Array(Char, length(s))
s2 = Array{Char,1}(length(s))
asyncmap!(f, s2, s; kwargs...)
return convert(String, s2)
end
Expand Down
7 changes: 0 additions & 7 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,6 @@ typealias NTuple{N,T} Tuple{Vararg{T,N}}
(::Type{Array{T,1}}){T}() = Array{T,1}(0)
(::Type{Array{T,2}}){T}() = Array{T,2}(0, 0)

# TODO: possibly turn these into deprecations
Array{T,N}(::Type{T}, d::NTuple{N,Int}) = Array{T,N}(d)
Array{T}(::Type{T}, d::Int...) = Array(T, d)
Array{T}(::Type{T}, m::Int) = Array{T,1}(m)
Array{T}(::Type{T}, m::Int,n::Int) = Array{T,2}(m,n)
Array{T}(::Type{T}, m::Int,n::Int,o::Int) = Array{T,3}(m,n,o)

# primitive Symbol constructors
function Symbol(s::String)
return ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Int),
Expand Down
11 changes: 11 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1674,4 +1674,15 @@ iteratoreltype(::Type{Task}) = EltypeUnknown()

isempty(::Task) = error("isempty not defined for Tasks")

# Deprecate Array(T, dims...) in favor of proper type constructors
@deprecate Array{T,N}(::Type{T}, d::NTuple{N,Int}) Array{T,N}(d)
@deprecate Array{T}(::Type{T}, d::Int...) Array{T,length(d)}(d...)
@deprecate Array{T}(::Type{T}, m::Int) Array{T,1}(m)
@deprecate Array{T}(::Type{T}, m::Int,n::Int) Array{T,2}(m,n)
@deprecate Array{T}(::Type{T}, m::Int,n::Int,o::Int) Array{T,3}(m,n,o)
@deprecate Array{T}(::Type{T}, d::Integer...) Array{T,length(d)}(convert(Tuple{Vararg{Int}}, d))
@deprecate Array{T}(::Type{T}, m::Integer) Array{T,1}(Int(m))
@deprecate Array{T}(::Type{T}, m::Integer,n::Integer) Array{T,2}(Int(m),Int(n))
@deprecate Array{T}(::Type{T}, m::Integer,n::Integer,o::Integer) Array{T,3}(Int(m),Int(n),Int(o))

# End deprecations scheduled for 0.6
9 changes: 0 additions & 9 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1676,15 +1676,6 @@ by `show` generally includes Julia-specific formatting and type information.
"""
show(x)

"""
Array(dims)
`Array{T}(dims)` constructs an uninitialized dense array with element type `T`. `dims` may
be a tuple or a series of integer arguments. The syntax `Array(T, dims)` is also available,
but deprecated.
"""
Array

"""
issubtype(type1, type2)
Expand Down
2 changes: 1 addition & 1 deletion base/libc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ if is_windows()
const FORMAT_MESSAGE_FROM_SYSTEM = UInt32(0x1000)
const FORMAT_MESSAGE_IGNORE_INSERTS = UInt32(0x200)
const FORMAT_MESSAGE_MAX_WIDTH_MASK = UInt32(0xFF)
lpMsgBuf = Array(Ptr{UInt16})
lpMsgBuf = Array{Ptr{UInt16},0}()
lpMsgBuf[1] = 0
len = ccall(:FormatMessageW,stdcall,UInt32,(Cint, Ptr{Void}, Cint, Cint, Ptr{Ptr{UInt16}}, Cint, Ptr{Void}),
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
Expand Down
2 changes: 1 addition & 1 deletion base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ speye_scaled(diag, m::Integer, n::Integer) = speye_scaled(typeof(diag), diag, m,
function speye_scaled(T, diag, m::Integer, n::Integer)
((m < 0) || (n < 0)) && throw(ArgumentError("invalid array dimensions"))
nnz = min(m,n)
colptr = Array(Int, 1+n)
colptr = Array{Int,1}(1+n)
colptr[1:nnz+1] = 1:nnz+1
colptr[nnz+2:end] = nnz+1
SparseMatrixCSC(Int(m), Int(n), colptr, Vector{Int}(1:nnz), fill!(Vector{T}(nnz), diag))
Expand Down
6 changes: 3 additions & 3 deletions base/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ end

function find{Tv,Ti}(x::SparseVector{Tv,Ti})
numnz = nnz(x)
I = Array(Ti, numnz)
I = Array{Ti,1}(numnz)

nzind = x.nzind
nzval = x.nzval
Expand All @@ -587,8 +587,8 @@ end
function findnz{Tv,Ti}(x::SparseVector{Tv,Ti})
numnz = nnz(x)

I = Array(Ti, numnz)
V = Array(Tv, numnz)
I = Array{Ti,1}(numnz)
V = Array{Tv,1}(numnz)

nzind = x.nzind
nzval = x.nzval
Expand Down
6 changes: 0 additions & 6 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ include("subarray.jl")
(::Type{Matrix{T}}){T}(m::Integer, n::Integer) = Matrix{T}(Int(m), Int(n))
(::Type{Matrix})(m::Integer, n::Integer) = Matrix{Any}(Int(m), Int(n))

# TODO: possibly turn these into deprecations
Array{T}(::Type{T}, d::Integer...) = Array(T, convert(Tuple{Vararg{Int}}, d))
Array{T}(::Type{T}, m::Integer) = Array{T,1}(Int(m))
Array{T}(::Type{T}, m::Integer,n::Integer) = Array{T,2}(Int(m),Int(n))
Array{T}(::Type{T}, m::Integer,n::Integer,o::Integer) = Array{T,3}(Int(m),Int(n),Int(o))

# numeric operations
include("hashing.jl")
include("rounding.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@
,.(map (lambda (v r) `(= ,v (call (top length) ,r))) lengths rv)
(scope-block
(block
(= ,result (call (core Array) ,atype ,@lengths))
(= ,result (call (curly Array ,atype ,(length lengths)) ,@lengths))
(= ,ri 1)
,(construct-loops (reverse ranges) (reverse rv) is states (reverse lengths))
,result)))))
Expand Down
2 changes: 1 addition & 1 deletion test/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@test 1234 === @test_nowarn(1234)
@test 5678 === @test_warn("WARNING: foo", begin warn("foo"); 5678; end)

a = Array(Float64, 2, 2, 2, 2, 2)
a = Array{Float64,5}(2, 2, 2, 2, 2)
a[1,1,1,1,1] = 10
@test a[1,1,1,1,1] == 10
@test a[1,1,1,1,1] != 2
Expand Down

0 comments on commit 7025505

Please sign in to comment.