Skip to content

Conversation

@QuirkyCroissant
Copy link

This PR resolves a build error that occurs when compiling FastDTW from source.
The Cython file _fastdtw.pyx contains a fallback cimport from numpy.math, which does not exist and breaks the build process.

  • Replaced:
    try:
        from libc.math cimport INFINITY
    except:
        from numpy.math cimport INFINITY  # file doesn't exist
  • With:
    from libc.math cimport INFINITY

This removes the broken fallback and ensures proper compilation of the C extension.

Without this fix, the build fails and FastDTW falls back to the pure Python implementation, which is up to 50× slower.
With the fix, the compiled .so extension is correctly built and used, unlocking FastDTW's intended performance.

NumPy seemingly removed numpy.math.pxd in version 2.0.0 as noted in their changelog:
https://github.com/numpy/numpy/blob/main/doc/changelog/2.0.0-changelog.rst

Related Issue

Closes #65

Let me know if any changes are needed — happy to adjust.

- Removed faulty fallback `from numpy.math cimport INFINITY`
- Replaced with `from libc.math cimport INFINITY`, which resolves build errors
- Fixes Cython compilation and enables proper FastDTW C extension usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastDTW fails to compile due to invalid fallback from numpy.math cimport INFINITY

1 participant