Skip to content

Commit 6738bee

Browse files
authored
Update for DerivableInterfaces.jl v0.5 (#61)
1 parent dfe4fd8 commit 6738bee

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseArraysBase"
22
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.5.9"
4+
version = "0.5.10"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
@@ -17,7 +17,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1717
Accessors = "0.1.41"
1818
Aqua = "0.8.9"
1919
ArrayLayouts = "1.11.0"
20-
DerivableInterfaces = "0.4"
20+
DerivableInterfaces = "0.5"
2121
Dictionaries = "0.4.3"
2222
FillArrays = "1.13.0"
2323
LinearAlgebra = "1.10"

src/abstractsparsearrayinterface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ end
3737
# TODO: This isn't used to define interface functions right now.
3838
# Currently, `@interface` expects an instance, probably it should take a
3939
# type instead so fallback functions can use abstract types.
40-
abstract type AbstractSparseArrayInterface <: AbstractArrayInterface end
40+
abstract type AbstractSparseArrayInterface{N} <: AbstractArrayInterface{N} end
4141

4242
function DerivableInterfaces.combine_interface_rule(
4343
interface1::AbstractSparseArrayInterface, interface2::AbstractSparseArrayInterface

src/sparsearraydok.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ end
6464

6565
using DerivableInterfaces: DerivableInterfaces
6666
# This defines the destination type of various operations in DerivableInterfaces.jl.
67-
DerivableInterfaces.arraytype(::AbstractSparseArrayInterface, T::Type) = SparseArrayDOK{T}
67+
function Base.similar(::AbstractSparseArrayInterface, T::Type, ax::Tuple)
68+
return similar(SparseArrayDOK{T}, ax)
69+
end
6870

6971
using DerivableInterfaces: @array_aliases
7072
# Define `SparseMatrixDOK`, `AnySparseArrayDOK`, etc.

src/sparsearrayinterface.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
using DerivableInterfaces: DerivableInterfaces
22

3-
struct SparseArrayInterface <: AbstractSparseArrayInterface end
3+
struct SparseArrayInterface{N} <: AbstractSparseArrayInterface{N} end
4+
SparseArrayInterface() = SparseArrayInterface{Any}()
5+
SparseArrayInterface(::Val{N}) where {N} = SparseArrayInterface{N}()
6+
SparseArrayInterface{M}(::Val{N}) where {M,N} = SparseArrayInterface{N}()
47

58
# Fix ambiguity error.
9+
function DerivableInterfaces.combine_interface_rule(
10+
::SparseArrayInterface{N}, ::SparseArrayInterface{N}
11+
) where {N}
12+
return SparseArrayInterface{N}()
13+
end
614
function DerivableInterfaces.combine_interface_rule(
715
::SparseArrayInterface, ::SparseArrayInterface
816
)

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1717
Adapt = "4.2.0"
1818
Aqua = "0.8.11"
1919
ArrayLayouts = "1.11.1"
20-
DerivableInterfaces = "0.4"
20+
DerivableInterfaces = "0.5"
2121
Dictionaries = "0.4.4"
2222
JLArrays = "0.2.0"
2323
LinearAlgebra = "<0.0.1, 1"

test/test_sparsearraydok.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using SparseArraysBase:
1919
storedpairs,
2020
storedvalues
2121
using StableRNGs: StableRNG
22-
using Test: @test, @testset
22+
using Test: @test, @test_throws, @testset
2323

2424
elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
2525
# arrayts = (Array, JLArray)

0 commit comments

Comments
 (0)