Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found Error in 11_VarQTE of Tutorial #171

Open
touwax42 opened this issue Apr 29, 2024 · 1 comment
Open

Found Error in 11_VarQTE of Tutorial #171

touwax42 opened this issue Apr 29, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@touwax42
Copy link

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 touwax42 added the bug Something isn't working label Apr 29, 2024
@woodsp-ibm
Copy link
Member

The tutorial is run in CI and passes fine. The code snippet above works fine for me locally - I just tried. The published tutorial https://qiskit-community.github.io/qiskit-algorithms/tutorials/11_VarQTE.html as you can see if you scroll to the bottom, where there is the version table, was run with Qiskit 1.0.2.

The file it is showing in your trace, where it's erroring out, is PauliTable and this was deprecated and removed from Qiskit some time ago. I would check the environment that you are running the notebook in and make sure its using the qiskit versions you believe. You can run that cell at the end which prints the versions if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants