Cython Numpy warning about NPY_NO_DEPRECATED_API when using MemoryView

后端 未结 3 1581
南笙
南笙 2020-12-16 09:07

I am converting a Cython memoryview to a numpy array (to be able to use it in pure Python code):

from libc.stdlib cimport realloc
cimport numpy as np

DTYPE          


        
相关标签:
3条回答
  • 2020-12-16 09:42

    Just for a further reference, cython online docs says this is because Cython is using a deprecated Numpy API, and for the time being, it's just a warning that we can ignore.

    0 讨论(0)
  • 2020-12-16 09:42

    I also get the same warnings, and I'd say it's normal.

    With the numpy C API you need to put a line in front of the C script if you don't like this warning, but all it does is tell the compiler to ignore the "deprecated" message - it seems to work the same either way.

    I'm guessing the Cython compiler doesn't put this line of code when it generates the C code, and I don't think that's important.

    0 讨论(0)
  • 2020-12-16 10:05

    Assuming one wishes to hide the deprecation warning, the following compiler flag can be implemented with clang: extra_compile_args=['-Wno-#warnings'].

    For gcc, extra_compile_args=['-Wno-cpp'] achieves the same.

    Of course this also hides other preprocessor directive warnings.

    0 讨论(0)
提交回复
热议问题