popgenmethods / momi2

Infer demographic history with the Moran model
GNU General Public License v3.0
47 stars 11 forks source link

scipy.linalg pinv2 - deprecated #61

Closed trevorcousins closed 1 year ago

trevorcousins commented 1 year ago

Dear momi2 authors,

I was trying to optimise a model with a "pulse" probability; after I type pulse_model.optimize(method="TNC") I encounter the following error module 'scipy.linalg' has no attribute 'pinv2' I suspected this is simply a version issue with python / scipy. I dug around a bit and it seems the newer versions of scipy (1.7.0 and later I believe) do not support "pinv2". For example see https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.pinv.html .

Of course to fix this all one must do is go into /path/to/packages/momi/math_functions.py and change line 209 from: return scipy.linalg.pinv2(hypergeom_mat(N, n)) to return scipy.linalg.pinv(hypergeom_mat(N, n)) or even just use a different version of scipy (prior to 1.7.0 I believe).

Thought this would be good to report in case others find a similar problem.

jackkamm commented 1 year ago

Thanks for reporting the problem, and for identifying the fix. I've replaced the pinv2() call with pinv(), and uploaded a new version to pypi.