diff --git a/Project.toml b/Project.toml index 3d49dd6..357437b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SparseArraysBase" uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208" authors = ["ITensor developers and contributors"] -version = "0.5.9" +version = "0.5.10" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" @@ -17,7 +17,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Accessors = "0.1.41" Aqua = "0.8.9" ArrayLayouts = "1.11.0" -DerivableInterfaces = "0.4" +DerivableInterfaces = "0.5" Dictionaries = "0.4.3" FillArrays = "1.13.0" LinearAlgebra = "1.10" diff --git a/src/abstractsparsearrayinterface.jl b/src/abstractsparsearrayinterface.jl index cad34d5..f31ca8a 100644 --- a/src/abstractsparsearrayinterface.jl +++ b/src/abstractsparsearrayinterface.jl @@ -37,7 +37,7 @@ end # TODO: This isn't used to define interface functions right now. # Currently, `@interface` expects an instance, probably it should take a # type instead so fallback functions can use abstract types. -abstract type AbstractSparseArrayInterface <: AbstractArrayInterface end +abstract type AbstractSparseArrayInterface{N} <: AbstractArrayInterface{N} end function DerivableInterfaces.combine_interface_rule( interface1::AbstractSparseArrayInterface, interface2::AbstractSparseArrayInterface diff --git a/src/sparsearraydok.jl b/src/sparsearraydok.jl index 7365127..8d123dc 100644 --- a/src/sparsearraydok.jl +++ b/src/sparsearraydok.jl @@ -64,7 +64,9 @@ end using DerivableInterfaces: DerivableInterfaces # This defines the destination type of various operations in DerivableInterfaces.jl. -DerivableInterfaces.arraytype(::AbstractSparseArrayInterface, T::Type) = SparseArrayDOK{T} +function Base.similar(::AbstractSparseArrayInterface, T::Type, ax::Tuple) + return similar(SparseArrayDOK{T}, ax) +end using DerivableInterfaces: @array_aliases # Define `SparseMatrixDOK`, `AnySparseArrayDOK`, etc. diff --git a/src/sparsearrayinterface.jl b/src/sparsearrayinterface.jl index 61fb6b8..7cc1c01 100644 --- a/src/sparsearrayinterface.jl +++ b/src/sparsearrayinterface.jl @@ -1,8 +1,16 @@ using DerivableInterfaces: DerivableInterfaces -struct SparseArrayInterface <: AbstractSparseArrayInterface end +struct SparseArrayInterface{N} <: AbstractSparseArrayInterface{N} end +SparseArrayInterface() = SparseArrayInterface{Any}() +SparseArrayInterface(::Val{N}) where {N} = SparseArrayInterface{N}() +SparseArrayInterface{M}(::Val{N}) where {M,N} = SparseArrayInterface{N}() # Fix ambiguity error. +function DerivableInterfaces.combine_interface_rule( + ::SparseArrayInterface{N}, ::SparseArrayInterface{N} +) where {N} + return SparseArrayInterface{N}() +end function DerivableInterfaces.combine_interface_rule( ::SparseArrayInterface, ::SparseArrayInterface ) diff --git a/test/Project.toml b/test/Project.toml index c8abf0a..0d9f3a5 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -17,7 +17,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Adapt = "4.2.0" Aqua = "0.8.11" ArrayLayouts = "1.11.1" -DerivableInterfaces = "0.4" +DerivableInterfaces = "0.5" Dictionaries = "0.4.4" JLArrays = "0.2.0" LinearAlgebra = "<0.0.1, 1" diff --git a/test/test_sparsearraydok.jl b/test/test_sparsearraydok.jl index 91f76d2..4e2b229 100644 --- a/test/test_sparsearraydok.jl +++ b/test/test_sparsearraydok.jl @@ -19,7 +19,7 @@ using SparseArraysBase: storedpairs, storedvalues using StableRNGs: StableRNG -using Test: @test, @testset +using Test: @test, @test_throws, @testset elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) # arrayts = (Array, JLArray)