From af2b1687524225dd833ed988f06dfa9190866efc Mon Sep 17 00:00:00 2001 From: Sacha Verweij Date: Sat, 25 Nov 2017 12:17:39 -0800 Subject: [PATCH] Deprecate Array(shape...)-like constructors to Array(uninitialized, shape...) equivalents. --- NEWS.md | 8 ++++++++ base/boot.jl | 14 -------------- base/deprecated.jl | 11 +++++++++++ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1cee9e536ba0f..2e699c644453f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -408,6 +408,14 @@ Deprecated or removed Instead, reshape the array or add trailing indices so the dimensionality and number of indices match ([#14770], [#23628]). + * Uninitialized `Array`/`Matrix`/`Vector `constructors of the form + `{Array|Matrix|Vector}[{T}](shape...)` have been deprecated in favor of equivalents + accepting `uninitialized` (an alias for `Uninitialized()`) as their first argument, + as in `{Array|Matrix|Vector}[{T}](uninitialized, shape...)`. For example, + `Vector(3)` is now `Vector(uninitialized, 3)`, `Matrix{Int}((2, 4))` is now, + `Matrix{Int}(uninitialized, (2, 4))`, and `Array{Float32}(11, 13, 17)` is now + `Array{Float32}(uninitialized, 11, 13, 17)` ([#LIKETEARSINRAIN]). + * `fill!(A::Diagonal, x)` and `fill!(A::AbstractTriangular, x)` have been deprecated in favor of `Base.LinAlg.fillslots!(A, x)` ([#24413]). diff --git a/base/boot.jl b/base/boot.jl index b357c5ec45ad2..40baf0f84b314 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -373,20 +373,6 @@ Array{T}(::Uninitialized, d::NTuple{N,Int}) where {T,N} = Array{T,N}(uninitializ # empty vector constructor Array{T,1}() where {T} = Array{T,1}(uninitialized, 0) -## preexisting Array constructors, i.e. without uninitialized, to deprecate -# type and dimensionality specified, accepting dims as series of Ints -Array{T,1}(m::Int) where {T} = Array{T,1}(uninitialized, m) -Array{T,2}(m::Int, n::Int) where {T} = Array{T,2}(uninitialized, m, n) -Array{T,3}(m::Int, n::Int, o::Int) where {T} = Array{T,3}(uninitialized, m, n, o) -Array{T,N}(d::Vararg{Int,N}) where {T,N} = Array{T,N}(uninitialized, d) -# type and dimensionality specified, accepting dims as tuples of Ints -Array{T,N}(d::NTuple{N,Int}) where {T,N} = Array{T,N}(uninitialized, d) -# type but not dimensionality specified -Array{T}(m::Int) where {T} = Array{T}(uninitialized, m) -Array{T}(m::Int, n::Int) where {T} = Array{T}(uninitialized, m, n) -Array{T}(m::Int, n::Int, o::Int) where {T} = Array{T}(uninitialized, m, n, o) -Array{T}(d::NTuple{N,Int}) where {T,N} = Array{T}(uninitialized, d) - # primitive Symbol constructors function Symbol(s::String) diff --git a/base/deprecated.jl b/base/deprecated.jl index 18e9ee6d93d41..5e8ab76e550c1 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -2027,6 +2027,17 @@ end # also remove deprecation warnings in find* functions in array.jl, sparse/sparsematrix.jl, # and sparse/sparsevector.jl. +# deprecate Array(shape...)-like constructors to Array(uninitialized, shape...) (ref. #24595) +@deprecate Array{T,1}(m::Int) where {T} Array{T,1}(uninitialized, m) +@deprecate Array{T,2}(m::Int, n::Int) where {T} Array{T,2}(uninitialized, m, n) +@deprecate Array{T,3}(m::Int, n::Int, o::Int) where {T} Array{T,3}(uninitialized, m, n, o) +@deprecate Array{T,N}(d::Vararg{Int,N}) where {T,N} Array{T,N}(uninitialized, d) +@deprecate Array{T,N}(d::NTuple{N,Int}) where {T,N} Array{T,N}(uninitialized, d) +@deprecate Array{T}(m::Int) where {T} Array{T}(uninitialized, m) +@deprecate Array{T}(m::Int, n::Int) where {T} Array{T}(uninitialized, m, n) +@deprecate Array{T}(m::Int, n::Int, o::Int) where {T} Array{T}(uninitialized, m, n, o) +@deprecate Array{T}(d::NTuple{N,Int}) where {T,N} Array{T}(uninitialized, d) + # issue #22849 @deprecate reinterpret(::Type{T}, a::Array{S}, dims::NTuple{N,Int}) where {T, S, N} reshape(reinterpret(T, vec(a)), dims) @deprecate reinterpret(::Type{T}, a::SparseMatrixCSC{S}, dims::NTuple{N,Int}) where {T, S, N} reinterpret(T, reshape(a, dims))