11using Test
22
3+ import ArrayInterface
34using LinearAlgebra
45
56
@@ -36,8 +37,8 @@ Any `state` must support the following not-in-place operations:
3637If `supports_inplace(state)` is `true`, the `state` must also support the
3738following:
3839
39- * `similar(state)` must be defined and return a valid state of the same type a
40- `state`
40+ * `similar(state)` must be defined and return a valid state of the same type as
41+ the original `state`
4142* `copyto!(other, state)` must be defined
4243* `fill!(state, c)` must be defined
4344* `LinearAlgebra.lmul!(c, state)` for a scalar `c` must be defined
@@ -60,7 +61,8 @@ for one-dimensional arrays:
6061* `length(state)` must equal `prod(size(state))`
6162* `iterate(state)` must be defined
6263* `similar(state)` must be defined and return a mutable vector with the same
63- length and element type.
64+ length and element type. "Mutability" is determined by
65+ [`ArrayInterface.ismutable`](@extref).
6466* `similar(state, ::Type{S})` must return a mutable vector with the same length
6567 and element type `S`
6668* `similar(state, dims::Dims)` must return a mutable array with the same
@@ -454,9 +456,9 @@ function check_state(
454456
455457 try
456458 st2 = similar (state)
457- if ! supports_inplace (st2)
459+ if ! ArrayInterface . ismutable (st2)
458460 quiet ||
459- @error " $(px) `similar(state)` must return a mutable vector (`supports_inplace ` must be `true`), got $(typeof (st2)) "
461+ @error " $(px) `similar(state)` must return a mutable vector (`ArrayInterface.ismutable ` must be `true`), got $(typeof (st2)) "
460462 success = false
461463 end
462464 if size (st2) != size (state)
@@ -480,9 +482,9 @@ function check_state(
480482 try
481483 S = (eltype (state) == ComplexF64) ? ComplexF32 : ComplexF64
482484 st2 = similar (state, S)
483- if ! supports_inplace (st2)
485+ if ! ArrayInterface . ismutable (st2)
484486 quiet ||
485- @error " $(px) `similar(state, $S )` must return a mutable vector (`supports_inplace ` must be `true`), got $(typeof (st2)) "
487+ @error " $(px) `similar(state, $S )` must return a mutable vector (`ArrayInterface.ismutable ` must be `true`), got $(typeof (st2)) "
486488 success = false
487489 end
488490 if size (st2) != size (state)
@@ -506,9 +508,9 @@ function check_state(
506508 try
507509 dims = size (state)
508510 st2 = similar (state, dims)
509- if ! supports_inplace (st2)
511+ if ! ArrayInterface . ismutable (st2)
510512 quiet ||
511- @error " $(px) `similar(state, dims)` must return a mutable array (`supports_inplace ` must be `true`), got $(typeof (st2)) "
513+ @error " $(px) `similar(state, dims)` must return a mutable array (`ArrayInterface.ismutable ` must be `true`), got $(typeof (st2)) "
512514 success = false
513515 end
514516 if size (st2) != dims
@@ -533,9 +535,9 @@ function check_state(
533535 S = (eltype (state) == ComplexF64) ? ComplexF32 : ComplexF64
534536 dims = size (state)
535537 st2 = similar (state, S, dims)
536- if ! supports_inplace (st2)
538+ if ! ArrayInterface . ismutable (st2)
537539 quiet ||
538- @error " $(px) `similar(state, $S , dims)` must return a mutable array (`supports_inplace ` must be `true`), got $(typeof (st2)) "
540+ @error " $(px) `similar(state, $S , dims)` must return a mutable array (`ArrayInterface.ismutable ` must be `true`), got $(typeof (st2)) "
539541 success = false
540542 end
541543 if size (st2) != dims
0 commit comments