SparsePauliOp does not yield correct results
See original GitHub issueEnvironment
- Qiskit Terra version:0.20.0
- Python version: 3.10.4
- Operating system: MacOS
What is happening?
Two Z gates on the same qubit make the identity, not a single Z gate
How can we reproduce the issue?
>>> from qiskit.quantum_info import SparsePauliOp
>>> sparse_list = [("ZZ", [0,0], 1)]
>>> SparsePauliOp.from_sparse_list(sparse_list, num_qubits = 5)
SparsePauliOp(['IIIIZ'],
coeffs=[1.+0.j])
>>>
What should happen?
Ideally, it should return
SparsePauliOp(['IIIII'],
coeffs=[1.+0.j])
Any suggestions?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
SparsePauliOp does not respect phase of Pauli product #5603
The SparsePauliOp class does not obtain the correct phase when constructed from the product of two Paulis. Here are some example ...
Read more >qiskit.quantum_info.operators.symplectic.sparse_pauli_op
Args: other (SparsePauliOp): an operator object. atol: Absolute numerical tolerance for checking equivalence. Returns: bool: True if the operator is ...
Read more >Qiskit PrimitiveOp compose function giving weird output
I am executing the following code. ... It gives a warning and a very deeply nested numpy array. ... But if I set...
Read more >Get started with the Estimator primitive - IBM Cloud Docs
When you start a session, it caches the data you send so it doesn't have to be ... Higher levels generate more accurate...
Read more >Qiskit Pocket Guide
The views expressed in this work are those of the authors and do not ... Returns the result of right-multiplying this operator with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree raising an error would be good. For performance we could also add a
do_checks
flag or so that isTrue
per default but can be turned off if you know that you’re strings are valid? 😄Initialization with the same index should not be allowed and should be explicitly compose (@). The issue is whether to check for errors (/warning) or just document it.
Since this is a difficult behavior for users to find wrong cases, I think it would be better to make it Error. I don’t think it would be that so costly to check if it is already assigned (i.e., not I) here.