Skip to content

Commit 8bc96d1

Browse files
committed
Resolve merge conflicts
2 parents fe9c657 + c297c03 commit 8bc96d1

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Adapt = "4.1.1"
3131
Aqua = "0.8.9"
3232
ArrayLayouts = "1.10.4"
3333
BlockArrays = "1.2.0"
34-
DerivableInterfaces = "0.4"
34+
DerivableInterfaces = "0.5"
3535
DiagonalArrays = "0.3"
3636
Dictionaries = "0.4.3"
3737
FillArrays = "1.13.0"

src/blocksparsearrayinterface/blocksparsearrayinterface.jl

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,37 @@ blockstype(a::BlockArray) = blockstype(typeof(a))
102102
blocktype(arraytype::Type{<:BlockArray}) = eltype(blockstype(arraytype))
103103
blocktype(a::BlockArray) = eltype(blocks(a))
104104

105-
abstract type AbstractBlockSparseArrayInterface <: AbstractSparseArrayInterface end
105+
abstract type AbstractBlockSparseArrayInterface{N} <: AbstractSparseArrayInterface{N} end
106106

107107
# TODO: Also support specifying the `blocktype` along with the `eltype`.
108-
function DerivableInterfaces.arraytype(
109-
interface::AbstractBlockSparseArrayInterface, T::Type
110-
)
111-
B = DerivableInterfaces.arraytype(interface.blockinterface, T)
112-
return BlockSparseArray{T,<:Any,B}
108+
function Base.similar(interface::AbstractBlockSparseArrayInterface, T::Type, ax::Tuple)
109+
N = length(ax)
110+
block_axt = Tuple{blockaxistype.(ax)...}
111+
B = _similartype(blockinterface(interface), Type{T}, block_axt)
112+
return similar(BlockSparseArray{T,N,B}, ax)
113113
end
114114

115-
struct BlockSparseArrayInterface{B<:AbstractArrayInterface} <:
116-
AbstractBlockSparseArrayInterface
115+
struct BlockSparseArrayInterface{N,B<:AbstractArrayInterface{N}} <:
116+
AbstractBlockSparseArrayInterface{N}
117117
blockinterface::B
118118
end
119+
blockinterface(interface::BlockSparseArrayInterface) = getfield(interface, :blockinterface)
120+
function BlockSparseArrayInterface{N}(blockinterface::AbstractArrayInterface{N}) where {N}
121+
return BlockSparseArrayInterface{N,typeof(blockinterface)}(blockinterface)
122+
end
123+
function BlockSparseArrayInterface{N}() where {N}
124+
return BlockSparseArrayInterface{N}(DefaultArrayInterface{N}())
125+
end
126+
BlockSparseArrayInterface(::Val{N}) where {N} = BlockSparseArrayInterface{N}()
127+
BlockSparseArrayInterface{M}(::Val{N}) where {M,N} = BlockSparseArrayInterface{N}()
128+
function BlockSparseArrayInterface{M,B}(::Val{N}) where {M,B<:AbstractArrayInterface{M},N}
129+
return BlockSparseArrayInterface{N,B}(B(Val(N)))
130+
end
131+
BlockSparseArrayInterface() = BlockSparseArrayInterface{Any}()
119132

120-
@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::AbstractArray) = error(
121-
"Not implemented"
122-
)
133+
@interface ::AbstractBlockSparseArrayInterface function BlockArrays.blocks(a::AbstractArray)
134+
return error("Not implemented")
135+
end
123136

124137
@interface ::AbstractBlockSparseArrayInterface function SparseArraysBase.isstored(
125138
a::AbstractArray{<:Any,N}, I::Vararg{Int,N}

src/blocksparsearrayinterface/broadcast.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ end
2424
# return BlockSparseArrayStyle{ndims(arraytype)}()
2525
# end
2626

27+
BlockSparseArrayStyle{N}() where {N} = BlockSparseArrayStyle{N}(DefaultArrayStyle{N}())
2728
BlockSparseArrayStyle(::Val{N}) where {N} = BlockSparseArrayStyle{N}()
2829
BlockSparseArrayStyle{M}(::Val{N}) where {M,N} = BlockSparseArrayStyle{N}()
2930

0 commit comments

Comments
 (0)