sissa-data-science / DADApy

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

Cython type #85

Closed daveb-dev closed 1 year ago

daveb-dev commented 1 year ago

Subject of the issue

Bug in cython wrapper between type

Error : File cythondensity.pyx:21, in dadapy.cython.cython_density._compute_kstar() ValueError: Buffer dtype mismatch, expected 'DTYPE_t' but got 'long long'

Your environment

Steps to reproduce

Tell us how to reproduce this issue. Simple reproducible example

import numpy as np
X = np.random.rand(1000,3).astype(np.float32)
cl = dadapy.Clustering(coordinates=X)
cl.compute_density_kstarNN()

Expected behaviour

compute kstar that is necessary for clustering.

Actual behaviour

Error in type casting

AldoGl commented 1 year ago

Hi @daveb-dev, thank you for your issue.

Unfortunately I am unable to reproduce your error. I am on MacOS 12.6.2 and I tried the following:

1) create a fresh 3.9 environment either with miniconda or venv (e.g., by running python3 -m venv . and source bin/activate) 2) install dadapy either via pip install dadapy or by running pip install . in the latest commit of the main branch 3) run your command

import dadapy
import numpy as np
X = np.random.rand(1000,3).astype(np.float32)
cl = dadapy.Clustering(coordinates=X)
cl.compute_density_kstarNN()

Everything works fine for me. Can you give more details on the error you get (perhaps also via copying and pasting it) and the steps you followed to get it?

daveb-dev commented 1 year ago

i fix it. It is related to windows compiler 3.9. It work in python 3.11, it depends on windows-cython. The bug is not reproducible in ubuntu nor Mac OS.

AldoGl commented 1 year ago

Thank you @daveb-dev for making us aware of this issue. In fact, none of the main maintainers develops on Windows. I am glad the problem disappeared with python 3.11!