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 11e0938
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
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::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 11e0938

Please sign in to comment.