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 28, 2017
1 parent 8c8b389 commit eb7c2d6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ Deprecated or removed
Instead, reshape the array or add trailing indices so the dimensionality and number of indices
match ([#14770], [#23628]).

* Uninitialized `Array` constructors of the form
`Array[{T,N}](shape...)` have been deprecated in favor of equivalents
accepting `uninitialized` (an alias for `Uninitialized()`) as their first argument,
as in `Array[{T,N}](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,3}(11, 13, 17)` is now
`Array{Float32,3}(uninitialized, 11, 13, 17)` ([#24781]).

* `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
21 changes: 21 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,27 @@ end
# issue #24006
@deprecate linearindices(s::AbstractString) eachindex(s)

# deprecate Array(shape...)-like constructors to Array(uninitialized, shape...) equivalents
# --> former primitive constructors
@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)
# --> former convenience constructors
@deprecate Vector{T}(m::Integer) where {T} Vector{T}(uninitialized, m)
@deprecate Matrix{T}(m::Integer, n::Integer) where {T} Matrix{T}(uninitialized, m, n)
@deprecate Array{T}(m::Integer) where {T} Array{T}(uninitialized, m)
@deprecate Array{T}(m::Integer, n::Integer) where {T} Array{T}(uninitialized, m, n)
@deprecate Array{T}(m::Integer, n::Integer, o::Integer) where {T} Array{T}(uninitialized, m, n, o)
@deprecate Array{T}(d::Integer...) where {T} Array{T}(uninitialized, d)
@deprecate Vector(m::Integer) Vector(uninitialized, m)
@deprecate Matrix(m::Integer, n::Integer) Matrix(uninitialized, m, n)

# deprecate IntSet to BitSet
@deprecate_binding IntSet BitSet

Expand Down
13 changes: 0 additions & 13 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,6 @@ Matrix(::Uninitialized, m::Integer, n::Integer) = Matrix{Any}(uninitialized, Int
# empty vector constructor
Vector() = Vector{Any}(uninitialized, 0)

## preexisting dims-type-converting Array constructors for convenience, i.e. without uninitialized, to deprecate
# type and dimensionality specified, accepting dims as series of Integers
Vector{T}(m::Integer) where {T} = Vector{T}(uninitialized, Int(m))
Matrix{T}(m::Integer, n::Integer) where {T} = Matrix{T}(uninitialized, Int(m), Int(n))
# type but not dimensionality specified, accepting dims as series of Integers
Array{T}(m::Integer) where {T} = Vector{T}(uninitialized, Int(m))
Array{T}(m::Integer, n::Integer) where {T} = Array{T,2}(uninitialized, Int(m), Int(n))
Array{T}(m::Integer, n::Integer, o::Integer) where {T} = Array{T,3}(uninitialized, Int(m), Int(n), Int(o))
Array{T}(d::Integer...) where {T} = Array{T}(uninitialized, convert(Tuple{Vararg{Int}}, d))
# dimensionality but not type specified, accepting dims as series of Integers
Vector(m::Integer) = Vector{Any}(uninitialized, Int(m))
Matrix(m::Integer, n::Integer) = Matrix{Any}(uninitialized, Int(m), Int(n))


include("associative.jl")

Expand Down

0 comments on commit eb7c2d6

Please sign in to comment.