jcmgray / quimb

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

AttributeError in core.py #222

Closed kjm538 closed 3 months ago

kjm538 commented 3 months ago

What happened?

When calling import quimb.tensor with quimb version 1.7.3 I encountered an AttributeError related to scipy versioning. I have scipy version 1.13.0 in my environment.

What did you expect to happen?

No response

Minimal Complete Verifiable Example

import quimb.tensor

Relevant log output

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 1
----> 1 import quimb.tensor

File ~/miniconda3/envs/usc-pyL/lib/python3.11/site-packages/quimb/__init__.py:26
     23 from math import pi, cos, sin, tan, exp, log, log2, log10, sqrt
     25 # Core functions
---> 26 from .core import (
     27     qarray,
     28     prod,
     29     isket,
     30     isbra,
     31     isop,
     32     isvec,
     33     issparse,
     34     isdense,
     35     isreal,
     36     isherm,
     37     ispos,
     38     mul,
     39     dag,
     40     dot,
     41     vdot,
     42     rdot,
     43     ldmul,
     44     rdmul,
     45     outer,
     46     explt,
     47     get_thread_pool,
     48     normalize,
     49     chop,
     50     quimbify,
     51     qu,
     52     ket,
     53     bra,
     54     dop,
     55     sparse,
     56     infer_size,
     57     trace,
     58     identity,
     59     eye,
     60     speye,
     61     dim_map,
     62     dim_compress,
     63     kron,
     64     kronpow,
     65     ikron,
     66     pkron,
     67     permute,
     68     itrace,
     69     partial_trace,
     70     expectation,
     71     expec,
     72     nmlz,
     73     tr,
     74     ptr,
     75 )
     77 # Linear algebra functions
     78 from .linalg.base_linalg import (
     79     eigensystem,
     80     eig,
   (...)
     99     Lazy,
    100 )

File ~/miniconda3/envs/usc-pyL/lib/python3.11/site-packages/quimb/core.py:2186
   2181         return out
   2183     return qarrayed_fn
-> 2186 sp.csr_matrix._mul_vector = csr_mulvec_wrap(sp.csr_matrix._mul_vector)
   2187 sp.csc_matrix._mul_vector = sp_mulvec_wrap(sp.csc_matrix._mul_vector)
   2188 sp.coo_matrix._mul_vector = sp_mulvec_wrap(sp.coo_matrix._mul_vector)

AttributeError: type object 'csr_matrix' has no attribute '_mul_vector'

Anything else we need to know?

No response

Environment

quimb 1.7.3 scipy 1.13.0

Mac OS with ARM64

jcmgray commented 3 months ago

Hi @kjm538, thanks for the issue! Yes looks like this monkey patch (the purpose of which is to provide a faster and parallel sparse mat-vec than scipy) will need to be changed, or dropped.

jcmgray commented 3 months ago

Should be fixed by https://github.com/jcmgray/quimb/commit/6bc0064630eaedc7c1e68af9f0471d368b10a148, closing for now.