Skip to content

Commit a0e61c4

Browse files
committed
Small refactor
1 parent 5e46525 commit a0e61c4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/abstractblocksparsearray/wrappedabstractblocksparsearray.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,9 @@ function Base.Array(a::AnyAbstractBlockSparseArray)
344344
end
345345

346346
function SparseArraysBase.isstored(
347-
a::AnyAbstractBlockSparseArray{<:Any,N}, I::Vararg{Int,N}
348-
) where {N}
349-
bI = BlockIndex(findblockindex.(axes(a), I))
350-
blocks_a = blocks(a)
351-
return isstored(blocks_a, bI.I...) && isstored(blocks_a[bI.I...], bI.α...)
347+
a::AnyAbstractBlockSparseArray, I::Int...
348+
)
349+
return @interface interface(a) isstored(a, I...)
352350
end
353351

354352
# This circumvents issues passing certain kinds of SubArrays

src/blocksparsearrayinterface/blocksparsearrayinterface.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ struct BlockSparseArrayInterface <: AbstractBlockSparseArrayInterface end
9999
@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::AbstractArray) =
100100
error("Not implemented")
101101

102+
@interface ::AbstractBlockSparseArrayInterface function SparseArraysBase.isstored(
103+
a::AnyAbstractBlockSparseArray{<:Any,N}, I::Vararg{Int,N}
104+
) where {N}
105+
bI = BlockIndex(findblockindex.(axes(a), I))
106+
return isstored(blocks_a, bI.I...) && isstored(blocks_a[bI.I...], bI.α...)
107+
end
108+
102109
@interface ::AbstractBlockSparseArrayInterface function Base.getindex(
103110
a::AbstractArray{<:Any,N}, I::Vararg{Int,N}
104111
) where {N}

0 commit comments

Comments
 (0)