jcmgray / quimb

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

Deprecation warning #91

Closed maxtremblay closed 3 years ago

maxtremblay commented 3 years ago

Hello,

I have the following deprecation warning when I use quimb. It seems related to quimb/core.py.

PendingDeprecationWarning: Importing from numpy.matlib is deprecated since 1.19.0. 
The matrix subclass is not the recommended way to represent matrices or deal with linear algebra 
(see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). 
Please adjust your code to use regular ndarray.
    from numpy.matlib import zeros

-- Docs: https://docs.pytest.org/en/latest/warnings.html

Not that it affects the results or performance in any noticeable way, but I wanted to let you know. In case it is relevant, I have Python 3.9.5 with numpy 1.20.3.

jcmgray commented 3 years ago

Thanks for the issue @maxtremblay. In quimb itself I can only find this line: https://github.com/jcmgray/quimb/blob/e1cdbf5fcacdf777b919116f8fbb4b57250eca90/quimb/tensor/array_ops.py#L17 which doesn't seem to trigger the warning on its own (and can probably be removed), and most of the numpy.matrix stuff was removed a few years ago so not quite sure the origin of this...

FWIW if I run:

python -Wd -c "import quimb as qu; import quimb.tensor as qtn

I don't get any warnings shown. That's using numpy==1.20.2 so maybe its a very recent numpy==1.20.3 change.

maxtremblay commented 3 years ago

Same warning with numpy 1.20.2.

Also, I am using the version 1.3.0 of quimb which is the most recent release on PyPi, but doesn't seem to but up-to-date with the github repo. For example, in the core.py file, I have

"""Core functions for manipulating quantum objects.
"""

import os
import math
import cmath
import operator
import itertools
import functools
from numbers import Integral

import numpy as np
from numpy.matlib import zeros
import scipy.sparse as sp
from cytoolz import partition_all

with the from numpy.matlib import zeros at line 13 which is not in the develop branch of the repository anymore.

I guess the simplest way for me to update is to locally build the package directly from the git repo? Or is there a more up-to-date release somewhere that I can easily pull?

jcmgray commented 3 years ago

Ah yes sorry the released version is a bit out of date now. The quickest way yes is just to install directly from github:

pip install --no-deps -U git+git://github.com/jcmgray/quimb.git@develop

(or clone and install locally if you want to play around with modifying things yourself).

maxtremblay commented 3 years ago

Great. I will do that for now. Thanks