mingzehuang/latentcor_py

Installation error: version: 0.2.4 Requires-Python >=3.9

Vlasovets opened this issue · 7 comments

hi @mingzehuang,

me and @muellsen are trying to marry latentcor and some other libraries we are developing in our lab,
and I was wondering if there is any specific reason the latest version of latentcor (0.2.4) requires Python >=3.9?

I remember in my previous issue you fixed the outdated version of scipy, so now scipy should be >=1.7 which is reasonable, but is it possible to avoid constraint here or at least make it Python>=3.8 since many big open-source do not catch up updating their python version, and it makes impossible to use latentcor with those libraries.

Here, I show one scenario when latentcor installation failed due to this issue, I also tried different environments including conda environments and Docker with macOS, Ubuntu 22.04:
Python 3.8.15 pip install latentcor==0.2.4 ERROR: Ignored the following versions that require a different python version: 0.2.4 Requires-Python >=3.9
Thank you in advance!

Sorry @Vlasovets I was very busy in job hunting. Let me look at your problem immediately:)

thank you, @mingzehuang!
I saw you relaxed the constraint on Python version in your setup file, I just quickly tried to run the test example you provide in the description and it give me the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/envs/qiime2-2022.8/lib/python3.8/site-packages/latentcor/latentcor.py", line 509, in latentcor
    R_lower[comb_select] = r_switch.r_approx(self = r_switch, K = K, zratio1 = zratio1, zratio2 = zratio2, comb = comb, tol = tol, ratio  = ratio)
  File "/opt/conda/envs/qiime2-2022.8/lib/python3.8/site-packages/latentcor/latentcor.py", line 248, in r_approx
    out = r_switch.r_ml(self = r_switch, K = K / bound, zratio1 = zratio1, zratio2 = zratio2, comb = comb)
  File "/opt/conda/envs/qiime2-2022.8/lib/python3.8/site-packages/latentcor/latentcor.py", line 242, in r_ml
    out = r_switch.ipol_switch(self = r_switch, comb = comb, K = K, zratio1 = zratio1, zratio2 = zratio2)
  File "/opt/conda/envs/qiime2-2022.8/lib/python3.8/site-packages/latentcor/latentcor.py", line 226, in ipol_switch
    out = ipol_30(numpy.column_stack((K, zratio1[0, : ], zratio1[1, : ])))
  File "/opt/conda/envs/qiime2-2022.8/lib/python3.8/site-packages/scipy/interpolate/_rgi.py", line 332, in __call__
    indices, norm_distances = self._find_indices(xi.T)
  File "/opt/conda/envs/qiime2-2022.8/lib/python3.8/site-packages/scipy/interpolate/_rgi.py", line 504, in _find_indices
    return find_indices(self.grid, xi)
  File "_rgi_cython.pyx", line 97, in scipy.interpolate._rgi_cython.find_indices
ValueError: Buffer dtype mismatch, expected 'const double' but got 'float'

I tracked the bug down and I believe it appears in line 226:
out = ipol_30(numpy.column_stack((K, zratio1[0, : ], zratio1[1, : ])))
and correspondingly to line 36 calling RegularGridInterpolator in this file

Here and here are the hints I found which might fix the issue, so basically there is a mismatch in data types between numpy and C interpreter.

Could you check if both and zratios have the same "float64" type, please?

you could explicitly specify datatype using this method:
out = ipol_30(numpy.column_stack((K.astype("float"), zratio1[0, : ].astype("float"), zratio1[1, : ].astype("float"))))

@Vlasovets Let me look into it immediately:)

I see. I've been able to reproduce your error. Let me try to fix it. Sorry about that!

I just specified the data type according to your suggestion. I'm not sure if it works. I'm testing.

@Vlasovets I'm afraid it roots in the change of interpolation package while I generated the grid as float...I'm still investigating it...

Hi, @Vlasovets, Sorry for delay. I've regenerated the interpolant and loose the version requirement. Now the 0.2.5 version on PyPI should work. Let me know if it's still incompatible with Python 3.7. Thanks.