scikit-learn-contrib / hdbscan

A high performance implementation of HDBSCAN clustering.
http://hdbscan.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
2.8k stars 502 forks source link

"cimported module has no attribute" when compiling Cython code #153

Open m-dz opened 6 years ago

m-dz commented 6 years ago

After running the standard python setup.py install I got a series of errors:

cythoning hdbscan/_hdbscan_boruvka.pyx to hdbscan\_hdbscan_boruvka.c

Error compiling Cython file:
------------------------------------------------------------
...
# Fused type for certain operations
ctypedef fused DITYPE_t:
    ITYPE_t
    DTYPE_t

ITYPE = np.intp
         ^
------------------------------------------------------------

hdbscan\dist_metrics.pxd:22:10: cimported module has no attribute 'intp'

Error compiling Cython file:
------------------------------------------------------------
...
    ITYPE_t
    DTYPE_t

ITYPE = np.intp

DTYPE = np.double
         ^
------------------------------------------------------------

hdbscan\dist_metrics.pxd:24:10: cimported module has no attribute 'double'

Fixed by uninstalling Cython v. 0.27.3 and installing Cython v. 0.25.2, I will report there as well, but maybe it's worth to amend requirements.txt here as well?

Edit: system info: Win 10 64 bits, Python 2.7.14, up to date master of hdbscan.

m-dz commented 6 years ago

Discussed here: https://github.com/cython/cython/issues/1738

m-dz commented 6 years ago

It's strange as in _hdbscan_boruvka.pyx you are both importing and cimporting numpy, so this should not happen.

lmcinnes commented 6 years ago

Thanks, I was unaware of these apparent Cython changes. They will involve a lot of changes across the codebase :-( Worse still is the issue of backwards compatability.

m-dz commented 6 years ago

It still should work though as you have both (c)imports in place in this particular file (I was lucky enough to compile all using Cython 0.25.2 and then work only on boruvka after updating to 0.27.3).

robertwb commented 6 years ago

The "backwards incompatable" change in #1738 is that what was a runtime error (using an unimported module) becomes a compile time error instead.

robertwb commented 6 years ago

FWIW, it looks like _hdbscan_boruvka.pyx has been correctly importing and cimporting numpy for years now. I just tried building master with the latest Cython and could not reproduce the issue.

m-dz commented 6 years ago

Maybe it is system/Python version related then? I will try one more time.

Edit: @robertwb , I have checked on a different computer, same issue. Win 8.1, Python 2.7.14, pip-installed Cython 0.27.3. all working after installing Cython 0.25.2.

trevorboydsmith commented 5 years ago

i experience a similar issue with missing "np.intp" and "np.float64" causing compiler errors.

i tried cython 0.29.x. then 0.27.x. then with 0.25.2 i was successful.

i am using

(i am using 0.18.2 scikit-learn because it's reqs still mostly fit with centos7)