sissa-data-science / DADApy

Distance-based Analysis of DAta-manifolds in python
https://dadapy.readthedocs.io/
Apache License 2.0
108 stars 18 forks source link

cannot import name 'cython_grads' #124

Closed wildromi closed 8 months ago

wildromi commented 8 months ago

Subject of the issue

I cannot import the MetricComparisons module because there seems to be a problem in 'density_advanced.py'

Your environment

Steps to reproduce

from dadapy.metric_comparisons import MetricComparisons

Expected behaviour

Should load module

Actual behaviour

`--------------------------------------------------------------------------- ImportError Traceback (most recent call last)

in 3 from itertools import combinations_with_replacement 4 ----> 5 from dadapy.metric_comparisons import MetricComparisons 6 from dadapy.feature_weighting import FeatureWeighting 7 [~/anaconda3/lib/python3.7/site-packages/dadapy/__init__.py](https://file+.vscode-resource.vscode-cdn.net/home/romi/Sync/GIT/DADApy/examples/~/anaconda3/lib/python3.7/site-packages/dadapy/__init__.py) in 2 from .base import Base 3 from .clustering import Clustering ----> 4 from .data import Data 5 from .data_sets import DataSets 6 from .density_advanced import DensityAdvanced [~/anaconda3/lib/python3.7/site-packages/dadapy/data.py](https://file+.vscode-resource.vscode-cdn.net/home/romi/Sync/GIT/DADApy/examples/~/anaconda3/lib/python3.7/site-packages/dadapy/data.py) in 28 from dadapy._utils import utils as ut 29 from dadapy.clustering import Clustering ---> 30 from dadapy.density_advanced import DensityAdvanced 31 from dadapy.feature_weighting import FeatureWeighting 32 from dadapy.metric_comparisons import MetricComparisons [~/anaconda3/lib/python3.7/site-packages/dadapy/density_advanced.py](https://file+.vscode-resource.vscode-cdn.net/home/romi/Sync/GIT/DADApy/examples/~/anaconda3/lib/python3.7/site-packages/dadapy/density_advanced.py) in 31 from scipy import sparse 32 ---> 33 from dadapy._cython import cython_grads as cgr 34 from dadapy._utils.density_estimation import return_not_normalised_density_kstarNN 35 from dadapy.density_estimation import DensityEstimation ImportError: cannot import name 'cython_grads' from 'dadapy._cython' (/home/romi/Sync/GIT/DADApy/dadapy/_cython/__init__.py)`
diegodoimo commented 8 months ago

With density_advaced, new cython code has been added to the repo. If you installed the package before the commit of density_advanced and now you are just pulling the updates from main, try to reinstall the package (this would recompile the new cython code). This should solve that issue.

AldoGl commented 8 months ago

I agree with @diegodoimo, probably this is the problem