Skip to content

Commit b4f5a37

Browse files
authored
Use MapBroadcast.jl and DerivableInterfaces.jl (#12)
1 parent 13b38d0 commit b4f5a37

File tree

7 files changed

+29
-27
lines changed

7 files changed

+29
-27
lines changed

Project.toml

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

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
8-
BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2"
9-
Derive = "a07dfc7f-7d04-4eb5-84cc-a97f051f655a"
8+
DerivableInterfaces = "6c5e35bf-e59e-4898-b73c-732dcc4ba65f"
109
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
1110
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
11+
MapBroadcast = "ebd9b9da-f48d-417c-9660-449667d60261"
1212

1313
[compat]
1414
Aqua = "0.8.9"
1515
ArrayLayouts = "1.11.0"
16-
BroadcastMapConversion = "0.1.0"
17-
Derive = "0.3.6"
16+
DerivableInterfaces = "0.3.7"
1817
Dictionaries = "0.4.3"
1918
LinearAlgebra = "1.10"
19+
MapBroadcast = "0.1.5"
2020
SafeTestsets = "0.1"
2121
Suppressor = "0.2"
2222
Test = "1.10"

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- Updates for latest Derive.
1+
- Updates for latest DerivableInterfaces.

src/abstractsparsearray.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
abstract type AbstractSparseArray{T,N} <: AbstractArray{T,N} end
22

3-
using Derive: @array_aliases
3+
using DerivableInterfaces: @array_aliases
44
# Define AbstractSparseVector, AnyAbstractSparseArray, etc.
55
@array_aliases AbstractSparseArray
66

7-
using Derive: Derive
8-
function Derive.interface(::Type{<:AbstractSparseArray})
7+
using DerivableInterfaces: DerivableInterfaces
8+
function DerivableInterfaces.interface(::Type{<:AbstractSparseArray})
99
return SparseArrayInterface()
1010
end
1111

12-
using Derive: @derive
12+
using DerivableInterfaces: @derive
1313

1414
# TODO: These need to be loaded since `AbstractArrayOps`
1515
# includes overloads of functions from these modules.
@@ -18,7 +18,7 @@ using Derive: @derive
1818
using ArrayLayouts: ArrayLayouts
1919
using LinearAlgebra: LinearAlgebra
2020

21-
# Derive `Base.getindex`, `Base.setindex!`, etc.
21+
# DerivableInterfaces `Base.getindex`, `Base.setindex!`, etc.
2222
# TODO: Define `AbstractMatrixOps` and overload for
2323
# `AnyAbstractSparseMatrix` and `AnyAbstractSparseVector`,
2424
# which is where matrix multiplication and factorizations

src/abstractsparsearrayinterface.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Derive: Derive, @derive, @interface, AbstractArrayInterface
1+
using DerivableInterfaces: DerivableInterfaces, @derive, @interface, AbstractArrayInterface
22

33
# This is to bring `ArrayLayouts.zero!` into the namespace
44
# since it is considered part of the sparse array interface.
@@ -71,7 +71,7 @@ end
7171
@interface ::AbstractArrayInterface getunstoredindex(a::AbstractArray, I::Int...) =
7272
zero(eltype(a))
7373

74-
# Derived interface.
74+
# DerivableInterfacesd interface.
7575
@interface ::AbstractArrayInterface storedlength(a::AbstractArray) = length(storedvalues(a))
7676
@interface ::AbstractArrayInterface storedpairs(a::AbstractArray) =
7777
map(I -> I => getstoredindex(a, I), eachstoredindex(a))
@@ -104,22 +104,22 @@ end
104104
# type instead so fallback functions can use abstract types.
105105
abstract type AbstractSparseArrayInterface <: AbstractArrayInterface end
106106

107-
function Derive.combine_interface_rule(
107+
function DerivableInterfaces.combine_interface_rule(
108108
interface1::AbstractSparseArrayInterface, interface2::AbstractSparseArrayInterface
109109
)
110110
return error("Rule not defined.")
111111
end
112-
function Derive.combine_interface_rule(
112+
function DerivableInterfaces.combine_interface_rule(
113113
interface1::Interface, interface2::Interface
114114
) where {Interface<:AbstractSparseArrayInterface}
115115
return interface1
116116
end
117-
function Derive.combine_interface_rule(
117+
function DerivableInterfaces.combine_interface_rule(
118118
interface1::AbstractSparseArrayInterface, interface2::AbstractArrayInterface
119119
)
120120
return interface1
121121
end
122-
function Derive.combine_interface_rule(
122+
function DerivableInterfaces.combine_interface_rule(
123123
interface1::AbstractArrayInterface, interface2::AbstractSparseArrayInterface
124124
)
125125
return interface2

src/sparsearraydok.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ struct SparseArrayDOK{T,N,F} <: AbstractSparseArray{T,N}
1010
getunstoredindex::F
1111
end
1212

13-
using Derive: Derive
14-
# This defines the destination type of various operations in Derive.jl.
15-
Derive.arraytype(::AbstractSparseArrayInterface, T::Type) = SparseArrayDOK{T}
13+
using DerivableInterfaces: DerivableInterfaces
14+
# This defines the destination type of various operations in DerivableInterfaces.jl.
15+
DerivableInterfaces.arraytype(::AbstractSparseArrayInterface, T::Type) = SparseArrayDOK{T}
1616

1717
function SparseArrayDOK{T,N}(size::Vararg{Int,N}) where {T,N}
1818
getunstoredindex = default_getunstoredindex
@@ -28,7 +28,7 @@ function SparseArrayDOK{T}(size::Int...) where {T}
2828
return SparseArrayDOK{T,length(size)}(size...)
2929
end
3030

31-
using Derive: @array_aliases
31+
using DerivableInterfaces: @array_aliases
3232
# Define `SparseMatrixDOK`, `AnySparseArrayDOK`, etc.
3333
@array_aliases SparseArrayDOK
3434

src/sparsearrayinterface.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
using Derive: Derive
1+
using DerivableInterfaces: DerivableInterfaces
22

33
struct SparseArrayInterface <: AbstractSparseArrayInterface end
44

55
# Fix ambiguity error.
6-
function Derive.combine_interface_rule(::SparseArrayInterface, ::SparseArrayInterface)
6+
function DerivableInterfaces.combine_interface_rule(
7+
::SparseArrayInterface, ::SparseArrayInterface
8+
)
79
return SparseArrayInterface()
810
end
9-
function Derive.combine_interface_rule(
11+
function DerivableInterfaces.combine_interface_rule(
1012
interface1::SparseArrayInterface, interface2::AbstractSparseArrayInterface
1113
)
1214
return interface1
1315
end
14-
function Derive.combine_interface_rule(
16+
function DerivableInterfaces.combine_interface_rule(
1517
interface1::AbstractSparseArrayInterface, interface2::SparseArrayInterface
1618
)
1719
return interface2
@@ -23,4 +25,4 @@ end
2325
# version of `map`.
2426
# const sparse = SparseArrayInterface()
2527

26-
Derive.interface(::Type{<:AbstractSparseArrayStyle}) = SparseArrayInterface()
28+
DerivableInterfaces.interface(::Type{<:AbstractSparseArrayStyle}) = SparseArrayInterface()

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
33
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
44
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
5-
Derive = "a07dfc7f-7d04-4eb5-84cc-a97f051f655a"
5+
DerivableInterfaces = "6c5e35bf-e59e-4898-b73c-732dcc4ba65f"
66
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
77
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
88
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"

0 commit comments

Comments
 (0)