Skip to content

Breaking change in numpy changes the output of PyLanczos! #5

@LUK4S-B

Description

@LUK4S-B

Numpy was updated to version 2.x. This introduced some breaking changes that apparently strongly affect PyLanczos.
This is the output I get when running PyLanczos version 2.1.1 with the old numpy version 1.26.4 :

>>> import numpy as np
>>> np.version.version
'1.26.4'
>>> from pylanczos import PyLanczos
>>> M = np.array([[2.0, 0],[0,2]])
>>> M
array([[2., 0.],
       [0., 2.]])
>>> v, U = PyLanczos(-M, True, 2).run()
>>> v
array([-2., -2.])
>>> U
array([[-0.98037217, -0.1971558 ],
       [ 0.1971558 , -0.98037217]])

while this is the output when running the same version of PyLanczos 2.1.1 with the new numpy version 2.0.2 :

>>> import numpy as np
>>> np.version.version
'2.0.2'
>>> from pylanczos import PyLanczos
>>> M = np.array([[2.0, 0],[0,2]])
>>> M
array([[2., 0.],
       [0., 2.]])
>>> v, U = PyLanczos(-M, True, 2).run()
>>> v
array([-1.11022302e-16, -2.00000000e+00])
>>> U
array([[-1.11022302e-16,  1.00000000e+00],
       [-1.00000000e+00, -2.22044605e-16]])

The new results are wrong. This needs to be fixed very urgently. It took me a long time to figure out that my code was malfunctioning because of this issue. Presumably it has to do with changes described here in the numpy migration guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions