Skip to content

Commit c297c03

Browse files
authored
Update for DerivableInterfaces.jl v0.5 (#137)
1 parent 6be3e32 commit c297c03

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BlockSparseArrays"
22
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
33
authors = ["ITensor developers <support@itensor.org> and contributors"]
4-
version = "0.7.4"
4+
version = "0.7.5"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -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: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,21 @@ blockstype(a::BlockArray) = blockstype(typeof(a))
101101
blocktype(arraytype::Type{<:BlockArray}) = eltype(blockstype(arraytype))
102102
blocktype(a::BlockArray) = eltype(blocks(a))
103103

104-
abstract type AbstractBlockSparseArrayInterface <: AbstractSparseArrayInterface end
104+
abstract type AbstractBlockSparseArrayInterface{N} <: AbstractSparseArrayInterface{N} end
105105

106106
# TODO: Also support specifying the `blocktype` along with the `eltype`.
107-
function DerivableInterfaces.arraytype(::AbstractBlockSparseArrayInterface, T::Type)
108-
return BlockSparseArray{T}
107+
function Base.similar(::AbstractBlockSparseArrayInterface, T::Type, ax::Tuple)
108+
return similar(BlockSparseArray{T}, ax)
109109
end
110110

111-
struct BlockSparseArrayInterface <: AbstractBlockSparseArrayInterface end
111+
struct BlockSparseArrayInterface{N} <: AbstractBlockSparseArrayInterface{N} end
112+
BlockSparseArrayInterface(::Val{N}) where {N} = BlockSparseArrayInterface{N}()
113+
BlockSparseArrayInterface{M}(::Val{N}) where {M,N} = BlockSparseArrayInterface{N}()
114+
BlockSparseArrayInterface() = BlockSparseArrayInterface{Any}()
112115

113-
@interface ::AbstractBlockSparseArrayInterface BlockArrays.blocks(a::AbstractArray) = error(
114-
"Not implemented"
115-
)
116+
@interface ::AbstractBlockSparseArrayInterface function BlockArrays.blocks(a::AbstractArray)
117+
return error("Not implemented")
118+
end
116119

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

0 commit comments

Comments
 (0)