-
Notifications
You must be signed in to change notification settings - Fork 1
Improve isstored
logic
#46
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #46 +/- ##
==========================================
- Coverage 75.59% 75.21% -0.39%
==========================================
Files 7 7
Lines 463 472 +9
==========================================
+ Hits 350 355 +5
- Misses 113 117 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This breaks the current release of BlockSparseArrays.jl so I marked it as breaking, ITensor/BlockSparseArrays.jl#79 updates BlockSparseArrays.jl based on the changes here. |
Given what you already started doing here, and the reported ambiguities, it seems like the
|
That's definitely a possibility. The use case I still have in mind are types that don't follow a convenient type hierarchy, for example So, I think it can still potentially fit into the plan you outlined, since Partially I'm bringing that up to play devil's advocate, and also start a discussion about when and why we might want to make a function into an interface function. Probably we'll have to decide based on a case-by-case basis about what can really be made generic across types, and maybe |
I see what you mean about @derive (T=Diagonal,) isstored(::T, ::Int,::Int) isstored(A::Diagonal, i::Int, j::Int) = i == j or @derive (T=SparseMatrixCSC,) isstored(::T, ::Int, ::Int) function isstored(A::SparseMatrixCSC, i::Int, j::Int)
i in nzrange(A, j)
end It's not clear to me that these have good general definitions that would catch that, and even if they do, I'm not convinced the That being said, I'm okay with merging this as is, exactly because we should rework it in #39 , so if this fixes the issues you are describing for now that works for me. |
That's a reasonable argument. What I had in mind originally was trying to implement it as a generic function, with a definition like: isstored(a::AbstractArray{<:Any,N}, I::Vararg{Int,N}) where {N} = CartesianIndex(I) in eachstoredindex(a) and then as long as I'll go ahead and merge this PR, since I think it moves things in the right direction and we can make more ambitious changes in #39. |
The changes to the code logic of
isstored
in #44 and #45 turned out to cause a lot of method ambiguities that were difficult to circumvent, this PR is meant to improve that, which makes ITensor/BlockSparseArrays.jl#79 easier to implement.This may require marking it as a breaking change, we'll see from the downstream tests. Also as discussed, some of this logic will be superseded by #39, where we'll also have to think about which part of the
isstored
logic should be at the@interface
level. It seems like it is better to not put the logic handling wrappers and index canonicalization at the@interface
level from experiments here and in ITensor/BlockSparseArrays.jl#79, for the sake of minimizing method ambiguities.