File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,7 +77,10 @@ QuantumPropagators.Interfaces.supports_inplace) is `true` (read-write vector):
7777
7878Note: When `supports_inplace(state)` is `true`, `similar(state)` is already
7979required to return the *same type* as `state` (see above). The vector interface
80- checks are weaker and complementary.
80+ checks are weaker and complementary. However, in all cases:
81+
82+ * `convert(typeof(state), mutable_state)` for `mutable_state = similar(state)`
83+ must be defined.
8184
8285It is strongly recommended to always support immutable operations (also for
8386mutable states)
@@ -558,6 +561,22 @@ function check_state(
558561 success = false
559562 end
560563
564+ try
565+ mutable_state = similar (state)
566+ converted = convert (typeof (state), mutable_state)
567+ if ! (converted isa typeof (state))
568+ quiet ||
569+ @error " $(px) `convert($(typeof (state)) , similar(state))` must return a `$(typeof (state)) `, not $(typeof (converted)) "
570+ success = false
571+ end
572+ catch exc
573+ quiet || @error (
574+ " $(px) `convert(typeof(state), mutable_state)` for `mutable_state = similar(state)` must be defined." ,
575+ exception = (exc, catch_abbreviated_backtrace ())
576+ )
577+ success = false
578+ end
579+
561580 if supports_inplace (state)
562581
563582 try
You can’t perform that action at this time.
0 commit comments