Skip to content

Commit 6cd2b0f

Browse files
committed
Don't require setindex! for operators
That's not implementable for a "lazy sum".
1 parent bfd6997 commit 6cd2b0f

2 files changed

Lines changed: 0 additions & 25 deletions

File tree

src/interfaces/operator.jl

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ for two-dimensional arrays:
6060
* `similar(op, ::Type{S}, dims::Dims)` must return a mutable array with the
6161
given element type and dimensions
6262
63-
If additionally [`QuantumPropagators.Interfaces.supports_inplace(op)`](@ref
64-
QuantumPropagators.Interfaces.supports_inplace) is `true` (read-write matrix):
65-
66-
* `setindex!(op, v, i, j)` must be defined
67-
6863
The function returns `true` for a valid operator and `false` for an invalid
6964
operator. Unless `quiet=true`, it will log an error to indicate which of the
7065
conditions failed.
@@ -435,24 +430,6 @@ function check_operator(
435430
success = false
436431
end
437432

438-
if supports_inplace(op)
439-
440-
try
441-
s = size(op)
442-
if length(s) == 2 && all(d -> d > 0, s)
443-
v = op[1, 1]
444-
op[1, 1] = v # write back the same value
445-
end
446-
catch exc
447-
quiet || @error(
448-
"$(px)`setindex!(op, v, i, j)` must be defined for an in-place operator.",
449-
exception = (exc, catch_abbreviated_backtrace())
450-
)
451-
success = false
452-
end
453-
454-
end
455-
456433
end
457434

458435
return success

test/test_invalid_interfaces.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ end
140140
@test contains(captured.output, "`similar(op, ::Type{S})` must be defined")
141141
@test contains(captured.output, "`similar(op, dims::Dims)` must be defined")
142142
@test contains(captured.output, "`similar(op, ::Type{S}, dims::Dims)` must be defined")
143-
@test contains(captured.output, "`setindex!(op, v, i, j)` must be defined")
144143

145144
end
146145

@@ -159,7 +158,6 @@ end
159158
Base.size(op::BadSimilarMatrixOp, d::Int) = size(op.data, d)
160159
Base.eltype(::Type{BadSimilarMatrixOp}) = ComplexF64
161160
Base.getindex(op::BadSimilarMatrixOp, i, j) = op.data[i, j]
162-
Base.setindex!(op::BadSimilarMatrixOp, v, i, j) = (op.data[i, j] = v)
163161
Base.length(op::BadSimilarMatrixOp) = length(op.data)
164162
Base.iterate(op::BadSimilarMatrixOp, args...) = iterate(op.data, args...)
165163
Base.similar(::BadSimilarMatrixOp, args...) = ImmutableResult()

0 commit comments

Comments
 (0)