-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deprecate spones #25037
deprecate spones #25037
Conversation
e13e4ce
to
a0ada0f
Compare
NEWS.md
Outdated
@@ -704,6 +704,9 @@ Deprecated or removed | |||
have been deprecated in favor of `spdiagm(d => x)` and `spdiagm(d[1] => x[1], d[2] => x[2], ...)` | |||
respectively. The new `spdiagm` implementation now always returns a square matrix ([#23757]). | |||
|
|||
* `spones(A::AbstractSparseArray{T})` has been deprecated in favor of | |||
`LinAlg.fillstored!(copy(A), one(T))` ([#TBD]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one(T)
could simplify to 1
in the vast majority of cases, as fillstored!
necessarily converts that 1
to eltype(A)
? Suggesting the simplest replacements first is nice :).
base/deprecated.jl
Outdated
@@ -1861,6 +1861,12 @@ end | |||
# PR #25030 | |||
@eval LinAlg @deprecate fillslots! fillstored! false | |||
|
|||
# PR #TBD | |||
@eval SparseArrays @deprecate spones(A::SparseMatrixCSC{T}) where {T} fillstored!(copy(A), one(T)) | |||
@eval SparseArrays @deprecate spones(A::SparseVector{T}) where {T} fillstored!(copy(A), one(T)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise here, perhaps simplify the suggested replacement as much as possible?
base/sparse/sparsematrix.jl
Outdated
""" | ||
spones(S::SparseMatrixCSC{T}) where {T} = | ||
SparseMatrixCSC(S.m, S.n, copy(S.colptr), copy(S.rowval), ones(T, S.colptr[end]-1)) | ||
LinAlg.fillstored!(S::SparseMatrixCSC, x) = (fill!(S.nzval, x); S) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fill!(view(S.nzval, 1:(S.colptr[S.n + 1] - 1)), x)
?
base/sparse/sparse.jl
Outdated
@@ -31,7 +31,7 @@ import Base: @get!, acos, acosd, acot, acotd, acsch, asech, asin, asind, asinh, | |||
|
|||
export AbstractSparseArray, AbstractSparseMatrix, AbstractSparseVector, | |||
SparseMatrixCSC, SparseVector, blkdiag, droptol!, dropzeros!, dropzeros, | |||
issparse, nonzeros, nzrange, rowvals, sparse, sparsevec, spdiagm, spones, | |||
issparse, nonzeros, nzrange, rowvals, sparse, sparsevec, spdiagm, fillstored!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why export fillstored!
from SparseArrays
while LinAlg
owns fillstored!
?
base/sparse/sparsevector.jl
Outdated
@@ -99,8 +99,7 @@ spzeros(len::Integer) = spzeros(Float64, len) | |||
spzeros(::Type{T}, len::Integer) where {T} = SparseVector(len, Int[], T[]) | |||
spzeros(::Type{Tv}, ::Type{Ti}, len::Integer) where {Tv,Ti<:Integer} = SparseVector(len, Ti[], Tv[]) | |||
|
|||
# Construction of same structure, but with all ones | |||
spones(x::SparseVector{T}) where {T} = SparseVector(x.n, copy(x.nzind), ones(T, length(x.nzval))) | |||
LinAlg.fillstored!(x::SparseVector{T}, y) where {T} = (fill!(x.nzval, y); x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps nix the unnecessary type parameter?
test/sparse/sparse.jl
Outdated
@testset "spones" begin | ||
@test spones(sparse(2.0I, 5, 5)) == Matrix(I, 5, 5) | ||
@testset "fillstored!" begin | ||
@test SparseArrays.fillstored!(sparse(2.0I, 5, 5), 1) == Matrix(I, 5, 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the SparseArrays
qualification when the definitions in SparseArrays
extend the name from LinAlg
? (Likewise below :).)
Much thanks for clearing this one @fredrikekre! :) |
bb8f554
to
9ec0111
Compare
Rebased, planning to merge this when ci is done. |
base/deprecated.jl
Outdated
@@ -1898,6 +1898,12 @@ end | |||
# PR #25030 | |||
@eval LinAlg @deprecate fillslots! fillstored! false | |||
|
|||
# PR #TBD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo! the CI jobs to seem to not have started yet, so it's still time to update this without having CI resources wasted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future maybe CI will check for #TBD
#TODO
, [#CATS]
etc!
I may have broken the build right when this was pushed, so probably worth fixing and rebasing. |
9ec0111
to
ddd292d
Compare
ddd292d
to
c4b83e0
Compare
Nevermind, I fixed it and pushed it for you. |
I think we did the same thing at the same time... |
I'm so confused... I only fixed the missing PR number that Rafael pointed out :) |
c4b83e0
to
462ee64
Compare
Ok, I did that plus I rebased on top of a newer master where I fixed the merge mistake. |
The i686 AV linalg/bunchkaufman failure is identical to that in #25083. Seems something broke AV i686 linalg/bunchkaufman recently but was nonetheless merged? Having a look at the AV queue... (Edit: Seems AV was out of commission for a bit, during which period the AV i686 linalg/bunchkaufman breaking change likely went through innocently.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm for the most recent version! Thanks @fredrikekre! :)
This is a rather useless function.
This is on top of #25030, relevant commit for this PR is a0ada0f
fix #22381