Skip to content

Commit

Permalink
Deprecate fill!(A::[Diagonal|AbstractTriangular], x) = fillslots!(A, …
Browse files Browse the repository at this point in the history
…x) methods.
  • Loading branch information
Sacha0 committed Oct 30, 2017
1 parent 268f878 commit c924edc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ Deprecated or removed
Instead, reshape the array or add trailing indices so the dimensionality and number of indices
match ([#14770], [#23628]).

* `fill!(A::Diagonal, x)` and `fill!(A::AbstractTriangular, x)` have been deprecated
in favor of `Base.LinAlg.fillslots!(A, x)` ([#24413]).

* Using Bool values directly as indices is now deprecated and will be an error in the future. Convert
them to `Int` before indexing if you intend to access index `1` for `true` and `0` for `false`.

Expand Down
4 changes: 4 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,10 @@ end
# After deprecation is removed, enable the @testset "indexing by Bool values" in test/arrayops.jl
# Also un-comment the new definition in base/indices.jl

# deprecate odd fill! methods
@deprecate fill!(D::Diagonal, x) fillslots!(D, x)
@deprecate fill!(A::Base.LinAlg.AbstractTriangular, x) fillslots!(A, x)

function diagm(v::BitVector)
depwarn(string("diagm(v::BitVector) is deprecated, use diagm(0 => v) or ",
"BitMatrix(Diagonal(v)) instead"), :diagm)
Expand Down
4 changes: 0 additions & 4 deletions base/linalg/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,6 @@ function fillslots!(A::SpecialArrays, x)
return A
end

# for historical reasons:
fill!(a::AbstractTriangular, x) = fillslots!(a, x)
fill!(D::Diagonal, x) = fillslots!(D, x)

_small_enough(A::Bidiagonal) = size(A, 1) <= 1
_small_enough(A::Tridiagonal) = size(A, 1) <= 2
_small_enough(A::SymTridiagonal) = size(A, 1) <= 2
Expand Down
5 changes: 5 additions & 0 deletions base/linalg/diagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ convert(::Type{Array}, D::Diagonal) = convert(Matrix, D)
similar(D::Diagonal, ::Type{T}) where {T} = Diagonal(similar(D.diag, T))
similar(D::Diagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)

zeros(D::Diagonal) = Diagonal(fill!(similar(D.diag), 0))
zeros(D::Diagonal, ::Type{T}) where {T} = Diagonal(fill!(similar(D, T), 0))
zeros(D::Diagonal, ::Type{T}, dims::Dims) where {T} = fill!(similar(D, T, dims), 0)
zeros(D::Diagonal, ::Type{T}, dims::Integer...) where {T} = fill!(similar(D, T, dims), 0)

copy!(D1::Diagonal, D2::Diagonal) = (copy!(D1.diag, D2.diag); D1)

size(D::Diagonal) = (length(D.diag),length(D.diag))
Expand Down
3 changes: 0 additions & 3 deletions test/linalg/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa
# full!
@test full!(copy(A1)) == A1

# fill!
@test full!(fill!(copy(A1), 1)) == t1(ones(size(A1)...))

# similar
@test isa(similar(A1), t1)
@test eltype(similar(A1)) == elty1
Expand Down

0 comments on commit c924edc

Please sign in to comment.