qiskit-algorithms icon indicating copy to clipboard operation
qiskit-algorithms copied to clipboard

Found Error in 11_VarQTE of Tutorial

Open touwax42 opened this issue 9 months ago • 1 comments

Environment

  • Qiskit Algorithms version: 0.3.0
  • Python version: 3.8.5
  • Operating system: Windows
  • Qiskit version: 1.0.2

What is happening?

When I tried the 11_VarQTE.ipynb in tutorial, I face an QiskitError: 'Invalid shape for PauliTable.' Then I reinstall the qiskit and qiskit-algorithms but it doesn't work.

How can we reproduce the issue?

The full message is below:

from qiskit.quantum_info import SparsePauliOp

hamiltonian = SparsePauliOp(["ZZ", "IX", "XI"], coeffs=[-0.2, -1, -1])

magnetization = SparsePauliOp(["IZ", "ZI"], coeffs=[1, 1])

and the error said:

---------------------------------------------------------------------------
QiskitError                               Traceback (most recent call last)
<ipython-input-1-594b2ee73c35> in <module>
      1 from qiskit.quantum_info import SparsePauliOp
      2 
----> 3 hamiltonian = SparsePauliOp(["ZZ", "IX", "XI"], coeffs=[-0.2, -1, -1])
      4 
      5 magnetization = SparsePauliOp(["IZ", "ZI"], coeffs=[1, 1])

[~\AppData\Roaming\Python\Python38\site-packages\qiskit\quantum_info\operators\symplectic\sparse_pauli_op.py] in __init__(self, data, coeffs)
     57             coeffs = data._coeffs
     58         else:
---> 59             table = PauliTable(data)
     60             if coeffs is None:
     61                 coeffs = np.ones(table.size, dtype=complex)

[~\AppData\Roaming\Python\Python38\site-packages\qiskit\quantum_info\operators\symplectic\pauli_table.py] in __init__(self, data)
    161             self._array = np.reshape(self._array, (1, self._array.size))
    162         if self._array.ndim != 2 or self._array.shape[1] % 2 != 0:
--> 163             raise QiskitError("Invalid shape for PauliTable.")
    164 
    165         # Set size properties

QiskitError: 'Invalid shape for PauliTable.'

What should happen?

The tutorial works well.

Any suggestions?

No response

touwax42 avatar Apr 29 '24 15:04 touwax42