Skip to content

Commit 0ff751d

Browse files
committed
Merge #19 from branch array-interface-support
2 parents 93391c3 + 40ce5d0 commit 0ff751d

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ QuantumControl = "8a270532-f23f-47a8-83a9-b33d10cad486"
99
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1010
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1111

12+
[weakdeps]
13+
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
14+
15+
[extensions]
16+
QuantumGradientGeneratorsArrayInterfaceExt = "ArrayInterface"
17+
1218
[compat]
19+
ArrayInterface = "7.0"
1320
LinearAlgebra = "1"
1421
QuantumControl = ">=0.11.0"
1522
Random = "1"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module QuantumGradientGeneratorsArrayInterfaceExt
2+
3+
import ArrayInterface
4+
import QuantumGradientGenerators: GradVector
5+
import QuantumControl.QuantumPropagators.Interfaces: supports_vector_interface
6+
7+
# The following methods are necessary for `check_state`, because `similar`
8+
# can return a `GradVector`, and the results of `similar` must be a mutable
9+
# array.
10+
11+
ArrayInterface.ismutable(::Type{GradVector{N,T}}) where {N,T} =
12+
ArrayInterface.ismutable(T) && supports_vector_interface(T)
13+
14+
15+
# Direct access to the elements of a `GradVector` is possible, but should be
16+
# discouraged
17+
18+
ArrayInterface.fast_scalar_indexing(::Type{<:GradVector}) = false
19+
20+
end

0 commit comments

Comments
 (0)