diff --git a/Project.toml b/Project.toml index 97958cff..d0aab94f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BlockSparseArrays" uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4" authors = ["ITensor developers and contributors"] -version = "0.7.4" +version = "0.7.5" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -31,7 +31,7 @@ Adapt = "4.1.1" Aqua = "0.8.9" ArrayLayouts = "1.10.4" BlockArrays = "1.2.0" -DerivableInterfaces = "0.4" +DerivableInterfaces = "0.5" DiagonalArrays = "0.3" Dictionaries = "0.4.3" FillArrays = "1.13.0" diff --git a/src/blocksparsearrayinterface/blocksparsearrayinterface.jl b/src/blocksparsearrayinterface/blocksparsearrayinterface.jl index 9025c8f2..5c1ed5be 100644 --- a/src/blocksparsearrayinterface/blocksparsearrayinterface.jl +++ b/src/blocksparsearrayinterface/blocksparsearrayinterface.jl @@ -101,18 +101,21 @@ blockstype(a::BlockArray) = blockstype(typeof(a)) blocktype(arraytype::Type{<:BlockArray}) = eltype(blockstype(arraytype)) blocktype(a::BlockArray) = eltype(blocks(a)) -abstract type AbstractBlockSparseArrayInterface <: AbstractSparseArrayInterface end +abstract type AbstractBlockSparseArrayInterface{N} <: AbstractSparseArrayInterface{N} end # TODO: Also support specifying the `blocktype` along with the `eltype`. -function DerivableInterfaces.arraytype(::AbstractBlockSparseArrayInterface, T::Type) - return BlockSparseArray{T} +function Base.similar(::AbstractBlockSparseArrayInterface, T::Type, ax::Tuple) + return similar(BlockSparseArray{T}, ax) end -struct BlockSparseArrayInterface <: AbstractBlockSparseArrayInterface end +struct BlockSparseArrayInterface{N} <: AbstractBlockSparseArrayInterface{N} end +BlockSparseArrayInterface(::Val{N}) where {N} = BlockSparseArrayInterface{N}() +BlockSparseArrayInterface{M}(::Val{N}) where {M,N} = BlockSparseArrayInterface{N}() +BlockSparseArrayInterface() = BlockSparseArrayInterface{Any}() -@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::AbstractArray) = error( - "Not implemented" -) +@interface ::AbstractBlockSparseArrayInterface function BlockArrays.blocks(a::AbstractArray) + return error("Not implemented") +end @interface ::AbstractBlockSparseArrayInterface function SparseArraysBase.isstored( a::AbstractArray{<:Any,N}, I::Vararg{Int,N}