-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
mod: quantum infoRelated to the Quantum Info module (States & Operators)Related to the Quantum Info module (States & Operators)type: feature requestNew feature or requestNew feature or request
Description
What should we add?
The following code raises an error. I don't think it should. I think it should return the zero operator. @ikkoham
from qiskit.quantum_info import SparsePauliOp
SparsePauliOp.from_sparse_list([], num_qubits=1)
---------------------------------------------------------------------------
QiskitError Traceback (most recent call last)
Cell In[2], line 3
1 from qiskit.quantum_info import SparsePauliOp
----> 3 SparsePauliOp.from_sparse_list([], num_qubits=1)
File ~/projects/qiskit-terra/qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py:839, in SparsePauliOp.from_sparse_list(obj, num_qubits, do_checks, dtype)
837 size = len(obj) # number of Pauli terms
838 if size == 0:
--> 839 raise QiskitError("Input Pauli list is empty.")
841 coeffs = np.zeros(size, dtype=dtype)
842 labels = np.zeros(size, dtype=f"<U{num_qubits}")
QiskitError: 'Input Pauli list is empty.'
Metadata
Metadata
Assignees
Labels
mod: quantum infoRelated to the Quantum Info module (States & Operators)Related to the Quantum Info module (States & Operators)type: feature requestNew feature or requestNew feature or request