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

PendingDeprecationWarning for numpy.matrix #287

Open
AckslD opened this issue Nov 19, 2018 · 2 comments
Open

PendingDeprecationWarning for numpy.matrix #287

AckslD opened this issue Nov 19, 2018 · 2 comments

Comments

@AckslD
Copy link

AckslD commented Nov 19, 2018

The matrix-class of numpy is currently being deprecated. I therefore get the following warning when running the below example using numpy>=1.15.0:

/path/projectq/ops/_gates.py:57: PendingDeprecationWarning: 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.
  return 1. / cmath.sqrt(2.) * np.matrix([[1, 1], [1, -1]])

Example:

import projectQ as pQ
import unittest

 class Test(unittest.TestCase):
         def test(self):
                 eng = pQ.MainEngine()
                 q = eng.allocate_qubit()[0]
                 pQ.ops.H | q
                 pQ.ops.Measure | q
                 eng.flush()
                 print(int(q))
@damiansteiger
Copy link
Contributor

Yes, we currently suppress this warning
https://github.com/ProjectQ-Framework/ProjectQ/blob/develop/pytest.ini#L6

The idea was waiting until Python2.7 is depricated so that everyone switches to Python3.5+ which allows to use @ for matrix multiplications (for which we currently can use * by using numpy.matrix)...

But I don't mind from changing already before, e.g., in the context of #282

Any thoughts?

@AckslD
Copy link
Author

AckslD commented Nov 20, 2018

An option would be to use numpy.dot instead of @ if you don't want to wait for Python2.7 to be deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants