FelSiq / DBCV

Efficient implementation in Python of Density-Based Clustering Validation (DBCV) metric, fully compatible with the original MATLAB implementation.
MIT License
11 stars 5 forks source link

Import Error [import dbvc] #4

Closed devanshmalhotra1002 closed 5 months ago

devanshmalhotra1002 commented 5 months ago

TypeError Traceback (most recent call last) Cell In[36], line 21 19 from kneed import KneeLocator 20 from sklearn.metrics import silhouette_score ---> 21 import dbcv 22 from scipy.spatial.distance import euclidean

File ~/opt/anaconda3/lib/python3.8/site-packages/dbcv/init.py:1 ----> 1 from .core import dbcv 4 version = "0.1.0"

File ~/opt/anaconda3/lib/python3.8/site-packages/dbcv/core.py:101 91 np.maximum(mutual_reach_dists, core_dists.T, out=mutual_reach_dists) 92 return (core_dists, mutual_reach_dists) 95 def fn_density_sparseness( 96 cls_inds: npt.NDArray[np.int32], 97 dists: npt.NDArray[np.float64], 98 d: int, 99 enable_dynamic_precision: bool, 100 use_original_mst_implementation: bool, --> 101 ) -> tuple[float, npt.NDArray[np.float32], npt.NDArray[np.int32]]: 102 (core_dists, mutual_reach_dists) = compute_mutual_reach_dists(dists=dists, d=d, enable_dynamic_precision=enable_dynamic_precision) 103 internal_node_inds, internal_edge_weights = get_internal_objects( 104 mutual_reach_dists, use_original_mst_implementation=use_original_mst_implementation 105 )

TypeError: 'type' object is not subscriptable

FelSiq commented 5 months ago

Hi @devanshmalhotra1002 , thanks for reporting this error.

This error happens because your Python version doesn't support the generic type hint syntax as per PEP 585, only available for Python version 3.9 onward (yours is 3.8).

I updated the type hints to a broader supported format (tuple -> t.Tuple), so that this issue should be now fixed.

Please use the updated version of this package from the main branch.

If the error persists or if you find any other issue, please let me know.

Felipe.