jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
467 stars 107 forks source link

module 'quimb.tensor' has no attribute 'ham_heis' #99

Closed saraphys closed 2 years ago

saraphys commented 2 years ago

Hello. I just successfully installed qumib but getting the following error after running the example codes mentioned in quimb:

Code: import quimb as qu import quimb.tensor as qtn import numpy as np L = 44 zeros = '0' * ((L - 2) // 3) binary = zeros + '1' + zeros + '1' + zeros print('psi0:', f"|{binary}>") psi0 = qtn.MPS_computational_state(binary) psi0.show() # prints ascii representation of state H = qtn.ham1d_heis(L)

Error: Traceback (most recent call last): File "", line 1, in AttributeError: module 'quimb.tensor' has no attribute 'ham_heis'

I really appreciate any help. Thanks

jcmgray commented 2 years ago

Ah yes there is a missing underscore it should be ham_1d_heis - https://quimb.readthedocs.io/en/latest/_autosummary/quimb.tensor.tensor_gen.html?highlight=ham_1d_heis#quimb.tensor.tensor_gen.ham_1d_heis. Docs need to be updated.

saraphys commented 2 years ago

Thanks for the reply. I changed it to ham_1d_heis. Still getting the same error

jcmgray commented 2 years ago

Are you on the most recent version from github?

saraphys commented 2 years ago

yes

saraphys commented 2 years ago

Actually, there is no function called "ham_1d_heis" in tensor_gen.py produced in my quimb folder.

saraphys commented 2 years ago

This is my quimb version: (cotengra) (base) user@amst4:~$ pip show quimb Name: quimb Version: 1.3.0+368.g9c26756 Summary: Quantum information and many-body library. Home-page: http://quimb.readthedocs.io Author: Johnnie Gray Author-email: johnniemcgray@gmail.com License: Apache Location: /home/user/cotengra/lib/python3.8/site-packages Requires: cytoolz, numba, numpy, psutil, scipy, tqdm Required-by:

jcmgray commented 2 years ago

I can't recreate with a fresh install from github: https://colab.research.google.com/drive/1UAcO8pQUIU_kuHDuXXImSSojewRDL-Td?usp=sharing.

My hunch would be that the installation has somehow broken (can happen quite easily) - try uninstalling including manually deleting the quimb folder from your site-packages and re-installing.

saraphys commented 2 years ago

Ok. Thank you. I will do that and update this comment. Thank again

saraphys commented 2 years ago

Thank you the problem solved after reinstalling quimb.

HamidArianZad commented 2 years ago

Hi,

I have installed quimb on my system via Anaconda 3 (python-3.7). All quimb dependencies have been installed, as well. I am trying to test quimb to draw a tensor tree by running the defined code:


from quimb import * import quimb.tensor as qtn

Lx = Ly = Lz = 4 D = 2 tn = qtn.TN3D_rand(Lx, Ly, Lz, D=D) tn.add_tag('CUBE')

color = ['CUBE'] + [ f'I{i},{j},{k}' for i in (0, Lx - 1) for j in (0, Ly - 1) for k in (0, Lz - 1) ]

tn.draw(color=color)

but I get the error:

AttributeError: module 'quimb.tensor' has no attribute 'TN3D_rand'

Could you please help me to resolve this problem?

By the way, whenever I add line: %config InlineBackend.figure_formats = ['svg'] my python does not recognize it.

jcmgray commented 2 years ago

Hi @HamidArianZad, please consider opening a separate issue if the fix in this one (i.e. a fresh install from github) does not work for you.

By the way, whenever I add line: %config InlineBackend.figure_formats = ['svg']

This is just for jupyter notebooks (the format the docs are largely written in).