Skip to content

Update for DerivableInterfaces.jl v0.5 #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SparseArraysBase"
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.5.9"
version = "0.5.10"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/abstractsparsearrayinterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/sparsearraydok.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 9 additions & 1 deletion src/sparsearrayinterface.jl
Original file line number Diff line number Diff line change
@@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/test_sparsearraydok.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading