-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
- Qiskit Terra version: 0.23.2
- Python version: 3.9.7
- Operating system: Linux
What is happening?
I find the following code example puzzling:
>>> from qiskit.quantum_info import Pauli
>>> Pauli("X")[[]]
Pauli('')
>>> Pauli('')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/garrison/serverless/.direnv/python-3.9.7/lib/python3.9/site-packages/qiskit/quantum_info/operators/symplectic/pauli.py", line 182, in __init__
base_z, base_x, base_phase = self._from_label(data)
File "/home/garrison/serverless/.direnv/python-3.9.7/lib/python3.9/site-packages/qiskit/quantum_info/operators/symplectic/pauli.py", line 619, in _from_label
raise QiskitError(f'Pauli string label "{label}" is not valid.')
qiskit.exceptions.QiskitError: 'Pauli string label "" is not valid.'
The first REPL line allows me to construct an object whose __repr__
is Pauli('')
. However, if I try to instantiate Pauli('')
directly, it fails.
How can we reproduce the issue?
Code snippet above.
What should happen?
Either both statements should fail, or both should be allowed.
Any suggestions?
I currently see no reason not to simply support Pauli('')
, such that it works without raising an exception.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working