Error in eigenstates function

561 views
Skip to first unread message

Leonardo Castelano

unread,
Mar 11, 2021, 8:35:28 PM3/11/21
to QuTiP: Quantum Toolbox in Python
Dear all,
Two days ago, my code was working fine, but today I tried to run it again and I got the following error message:

File "ss3qubits.py", line 55, in <module>
    evals, ekets = HT.eigenstates()
  File "/home/leo/anaconda3/lib/python3.7/site-packages/qutip/qobj.py", line 1668, in eigenstates
    norms = np.array([ket.norm() for ket in ekets])
  File "/home/leo/anaconda3/lib/python3.7/site-packages/qutip/qobj.py", line 1668, in <listcomp>
    norms = np.array([ket.norm() for ket in ekets])
AttributeError: 'numpy.ndarray' object has no attribute 'norm'


It seems that the np.array is changing the type of the object and ket is no longer a quantum object, therefore the norm attribute is no longer applicable.
Does anyone know what happened and how to solve this problem completely?
Best,
Leo

Nícolas Morazotti

unread,
Mar 11, 2021, 8:50:12 PM3/11/21
to QuTiP: Quantum Toolbox in Python
Hello, Leonardo.
I've noticed this issue some days ago too, and decided to use np.linalg.eig to get eigenvalues and eigenstates. This is not ideal, but can be used while there is no real fix.

Jake Lishman

unread,
Mar 11, 2021, 9:17:55 PM3/11/21
to qu...@googlegroups.com
Hi both,

What versions of QuTiP are you running, and what versions of Numpy? This sounds like an issue caused by upgrading to Numpy 1.20 without updating QuTiP - Numpy changed the behaviour of array_like objects in that release.

You can probably fix this either by upgrading QuTiP to 4.5.3, or downgrading Numpy to 1.19.

Jake
> --
> You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/qutip/001aa3de-88ce-4460-9c6a-5493f5a0218dn%40googlegroups.com.

Nícolas Morazotti

unread,
Mar 11, 2021, 9:26:29 PM3/11/21
to QuTiP: Quantum Toolbox in Python
Yeah, that fixes it. Thanks!

Leonardo Castelano

unread,
Mar 12, 2021, 12:10:47 PM3/12/21
to qu...@googlegroups.com
Thank you all for the prompt responses.
I updated qutip to 4.5.3 version and now it's working perfectly.
Best,
Leo

You received this message because you are subscribed to a topic in the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qutip/R0kXhv1rtO8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qutip+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qutip/2dd34099-8e92-4654-903a-5dc060203394n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages