-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingmod: quantum infoRelated to the Quantum Info module (States & Operators)Related to the Quantum Info module (States & Operators)
Description
Environment
- Qiskit Terra version: 0.24.1
- Python version: any
- Operating system: any
What is happening?
Setting the paulis
attribute (it has a @setter
) on a SparsePauliOp
instance does not update the BaseOperator
shape attributes.
How can we reproduce the issue?
import qiskit.quantum_info as qi
pauli_x = qi.SparsePauliOp(["X"], [1])
pauli_x.paulis = ["XX"]
print(pauli_x, pauli_x.dim)
What should happen?
The above snippet produces the output
SparsePauliOp(['XX'],
coeffs=[1.+0.j]) (2, 2)
whereas it should produce
SparsePauliOp(['XX'],
coeffs=[1.+0.j]) (4, 4)
if changing the dimension is allowed, or raise an exception if it's not allowed.
Any suggestions?
I haven't looked closely, but it's possible that just updating _op_shape
will be sufficient to fix the bug.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmod: quantum infoRelated to the Quantum Info module (States & Operators)Related to the Quantum Info module (States & Operators)