-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Make isstored
public
#56421
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
base: master
Are you sure you want to change the base?
Make isstored
public
#56421
Conversation
Co-authored-by: Lars Göttgens <lars.goettgens@gmail.com>
@LilithHafner could this get an assigned reviewer? I'm not sure how the bot system for it works or if it can be done retroactively. |
This PR proposes expanding the public API of Julia so it should get discussed at Triage before merging. It seems reasonable to me, but I don't have the expertise to know for sure. @stevengj, are you willing to weigh in here? |
What about using a default of |
@MasonProtter, do you know of anyone that is using this function? I can't find anything on JuliaHub. As far as I can tell, it is used only in stdlib/SparseArrays, and even there only in a single place: in the printing code in order to decide when to print a dot instead of a zero. Without a better sense of its practical utility, I'm a little cautious about exporting it. |
I'd like to use it in GraphDynamics.jl and Neuroblox.jl . We have sparse connection matrix structures that describe the interaction between subsystems, and there are somecases where I care if something is "stored" vs just a zero connection. Maybe this is a sign I need to stop using SparseArrays though and go build a new type that better exposes this difference. It'd be too bad though if I had to do that though because there's a lot of features of SparseArrays I really like for what I'm doing here. |
Using it for graphs is a good example. In that case, I'm in favor of just making this public. |
From triage, why can't this live in LinearAlgebra (or possibly even SparseArrays with a weak dependency on LinearAlgebra)? |
I don't see why it should be moved to another package. julia> methods(Base.isstored)
# 6 methods for generic function "isstored" from Base:
[1] isstored(A::Bidiagonal, i::Int64, j::Int64)
@ ~/.julia/juliaup/julia-1.12.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/bidiag.jl:131
[2] isstored(D::Diagonal, i::Int64, j::Int64)
@ ~/.julia/juliaup/julia-1.12.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/diagonal.jl:157
[3] isstored(A::Union{LowerTriangular{T, S}, UnitLowerTriangular{T, S}, UnitUpperTriangular{T, S}, UpperTriangular{T, S}} where {T, S}, i::Int64, j::Int64)
@ ~/.julia/juliaup/julia-1.12.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/triangular.jl:230
[4] isstored(A::Tridiagonal, i::Int64, j::Int64)
@ ~/.julia/juliaup/julia-1.12.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/tridiag.jl:693
[5] isstored(A::SymTridiagonal, i::Int64, j::Int64)
@ ~/.julia/juliaup/julia-1.12.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/tridiag.jl:450
[6] isstored(A::AbstractArray{<:Any, N}, I::Vararg{Integer, N}) where N
@ abstractarray.jl:610
`` |
This is a useful function when working with sparse arrays, I think we should make it public but give a weak guarantee, letting people know that a result of
true
could be wrong (though a value offalse
should be trustworthy).