mariaderrico / DPA

The DPA package is the scikit-learn compatible implementation of the Density Peaks Advanced clustering algorithm. The algorithm provides robust and visual information about the clusters, their statistical reliability and their hierarchical organization.
BSD 3-Clause "New" or "Revised" License
27 stars 9 forks source link

dtype mismtach expected 'long' but got 'long long' #5

Open ivan-marroquin opened 3 years ago

ivan-marroquin commented 3 years ago

Hi,

Many thanks for making this clustering package available!

I have a windows machine with Python 3.6.5, numpy 1.19.5, scipy 1.5.4, scikit-learn 0.24.2

I did a manual installation by running command "python setup.py install". It went OK and then, I tried to test the installation following Python code in one of examples:

data_F1= pd.read_csv('Fig1.dat', sep=" ", header= None) est= DPA.DensityPeakAdvanced(Z= 1.5) est.fit(data_F1)

The last line produced the following error message:

Traceback (most recent call last): File "", line 1, in File "C:\Temp\Python\Python3.6.5\lib\site-packages\dpapipeline-0.0.2-py3.6-win-amd64.egg\Pipeline\DPA.py", line 400, in fit frac=self.frac, dim=self.dim_, n_jobs=self.njobs).fit(X) File "C:\Temp\Python\Python3.6.5\lib\site-packages\dpapipeline-0.0.2-py3.6-win-amd64.egg\Pipeline\PAk.py", line 282, in fit dim=self.dim) File "C:\Temp\Python\Python3.6.5\lib\site-packages\dpapipeline-0.0.2-py3.6-win-amd64.egg\Pipeline\PAk.py", line 65, in _PointAdaptive_kNN k_hat, dc, densities, err_densities = _PAk.get_densities(dim, distances, k_max, D_thr, indices) File "src\Pipeline_PAk.pyx", line 84, in Pipeline._PAk.get_densities ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'

Thanks for your help,

Ivan

mariaderrico commented 3 years ago

Thanks for posting the bug error! I will provide an update shortly.

mariaderrico commented 3 years ago

Hi. The problem was that the long type in the Cython codes are long for Linux, but long long for Windows. I have replaced them with int64_t (see commits above for more details). Those changes should solve the issue, could you give it a try?

ivan-marroquin commented 3 years ago

Hi @mariaderrico ,

Many thanks for fixing the reported issue. I will give a try as soon as possible, and let you know.

Ivan

ivan-marroquin commented 3 years ago

Hi @mariaderrico

I downloaded the zip file and manually installed the package. Run the same Python code and it worked fine.

I noticed the following warnings during the installation:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -IC:\Temp\Python\Python3.6.5\lib\site-packages\numpy\core\include -IC:\Temp\Python\Python3.6.5\include -IC:\Temp\Python\Python3.6.5\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tcsrc\Pipeline_PAk.c /Fobuild\temp.win-amd64-3.6\Release\src\Pipeline_PAk.obj _PAk.c src\Pipeline_PAk.c(2729): warning C4244: '=': conversion from 'int64_t' to 'int', possible loss of data src\Pipeline_PAk.c(3066): warning C4244: '=': conversion from 'double' to 'float', possible loss of data src\Pipeline_PAk.c(3220): warning C4244: '=': conversion from 'double' to 'float', possible loss of data src\Pipeline_PAk.c(3229): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /nodefaultlib:libucrt.lib ucrt.lib /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Temp\Python\Python3.6.5\libs /LIBPATH:C:\Temp\Python\Python3.6.5\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64" /EXPORT:PyInit__PAk build\temp.win-amd64-3.6\Release\src\Pipeline_PAk.obj /OUT:build\lib.win-amd64-3.6\Pipeline_PAk.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\src\Pipeline_PAk.cp36-win_amd64.lib