Skip to content

Commit

Permalink
Deprecate Array(shape...)-like constructors to Array(uninitialized, s…
Browse files Browse the repository at this point in the history
…hape...) equivalents.
  • Loading branch information
Sacha0 committed Nov 25, 2017
1 parent b15024f commit af2b168
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]).

Expand Down
14 changes: 0 additions & 14 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit af2b168

Please sign in to comment.