Implement SparseObservable.apply_layout
#13372
Merged
+302
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This is one more usability method to bring
SparseObservable
closer inline withSparsePauliOp
. The same functionality is relatively easily implementable by the user by iterating through the terms, mapping the indices, and putting the output back intoSparseObservable.from_sparse_list
, but given how heavily we promote the method forSparsePauliOp
, it probably forms part of the core of user expectations.Details and comments
Built on top of #13298 (though mostly just because it touches similar changes to the error structs).
I only finalised this after the 1.3 feature-freeze period. There's probably no huge necessity to rush it in since it's not going to be used by the primitives before Qiskit 2.0 anyway, though it's nice to get these things early.
There's still
compose
andevolve
to go forSparseObservable
, but those are definitely for a later release, because I haven't written them yet, and the tests will take a good amount of time to write still.