当我使用numpy参数运行cython.inline
时,编译器会发出一个numpy弃用警告。例如:
import cython
import numpy
y = numpy.zeros((1, ))
print(cython.inline('x = y + 1', quiet=True, force=True)['x'])
输出(Python 3.5.2,Cython 0.27.3,numpy 1.13.3):
In file included from /Users/alex/Library/Caches/cython/inline/_cython_inline_71247e2c4c276ce71de47a12a21f4fd3.c:504:
In file included from /Users/alex/.virtualenvs/pysb3/lib/python3.5/site-packages/numpy/core/include/numpy/arrayobject.h:4:
In file included from /Users/alex/.virtualenvs/pysb3/lib/python3.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:18:
In file included from /Users/alex/.virtualenvs/pysb3/lib/python3.5/site-packages/numpy/core/include/numpy/ndarraytypes.h:1788:
/Users/alex/.virtualenvs/pysb3/lib/python3.5/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it by " \
^
1 warning generated.
[ 1.]
我无法抑制此警告。 cython docs表示警告是正常的并且没有什么可担心的,但我的应用程序使用cython.inline
编译了大量代码,警告可能会掩盖真正的错误并使新用户感到困惑。
我尝试使用distutils声明来抑制警告,这似乎无法正常工作。
cython.inline('# distutils: define_macros = NPY_NO_DEPRECATED_API '
'NPY_1_7_API_VERSION\n'
'x = y + 1',
quiet=True, force=True)
如何取消cython.inline
的弃用警告?