Skip to content

Commit cecc98f

Browse files
committed
Deprecate sparse(s::UniformScaling, m::Integer) in favor of the three-arg equivalent.
1 parent 33763a0 commit cecc98f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ Deprecated or removed
393393
* `readcsv(io[, T::Type]; opts...)` has been deprecated in favor of
394394
`readdlm(io, ','[, T]; opts...)` ([#23530]).
395395

396+
* `sparse(s::UniformScaling, m::Integer)` has been deprecated in favor of the
397+
three-argument equivalent `sparse(s::UniformScaling, m, n)` ([#24472]).
398+
396399
* The `cholfact`/`cholfact!` methods that accepted an `uplo` symbol have been deprecated
397400
in favor of using `Hermitian` (or `Symmetric`) views ([#22187], [#22188]).
398401

base/deprecated.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,8 @@ function toc()
18211821
return t
18221822
end
18231823

1824+
@eval Base.SparseArrays @deprecate sparse(s::UniformScaling, m::Integer) sparse(s, m, m)
1825+
18241826
# A[I...] .= with scalar indices should modify the element at A[I...]
18251827
function Broadcast.dotview(A::AbstractArray, args::Number...)
18261828
depwarn("the behavior of `A[I...] .= X` with scalar indices will change in the future. Use `A[I...] = X` instead.", :broadcast!)

base/sparse/sparsematrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ if not specified.
15301530
multiple `α` of the identity matrix.
15311531
"""
15321532
speye(::Type{T}, m::Integer, n::Integer) where {T} = SparseMatrixCSC{T}(UniformScaling(one(T)), Dims((m, n)))
1533-
sparse(s::UniformScaling, m::Integer, n::Integer=m) = SparseMatrixCSC(s, Dims((m, n)))
1533+
sparse(s::UniformScaling, m::Integer, n::Integer) = SparseMatrixCSC(s, Dims((m, n)))
15341534

15351535
function one(S::SparseMatrixCSC{T}) where T
15361536
m,n = size(S)

0 commit comments

Comments
 (0)