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 12, 2017
1 parent 29a3563 commit 91f7cb9
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
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 @@ -1540,4 +1540,15 @@ unsafe_wrap(::Type{String}, p::Cstring, len::Integer, own::Bool=false) =
# Rename LibGit2.GitAnyObject to LibGit2.GitUnknownObject (part of #19839)
eval(LibGit2, :(Base.@deprecate_binding GitAnyObject GitUnknownObject))

# 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
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 91f7cb9

Please sign in to comment.