如何使用任何pystan代码解决或抑制警告墙

时间:2019-04-02 15:24:15

标签: cython pystan

当我运行任何pystan代码时,输​​出是我所期望的,但是却出现了警告。

我已经尝试更新pystan和cython,因为警告墙中提到了这些。我的pystan现在是2.17.1版和cython 0.29.2版。我正在运行python3.7。

import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code)  # this will take a minute
y = model.sampling(n_jobs=1).extract()['y']
y.mean()  # should be close to 0

我收到的错误消息开始于:

/home/femke/anaconda3/lib/python3.7/site-packages/Cython/Compiler/Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/tmp8_plkepg/stanfit4anon_model_5944b02c79788fa0db5b3a93728ca2bf_5335140894361802645.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/femke/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1823:0,
                 from /home/femke/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                 from /home/femke/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from /tmp/tmp8_plkepg/stanfit4anon_model_5944b02c79788fa0db5b3a93728ca2bf_5335140894361802645.cpp:688:
/home/femke/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^~~~~~~
In file included from /home/femke/anaconda3/lib/python3.7/site-packages/pystan/stan/lib/stan_math/lib/boost_1.66.0/boost/numeric/ublas/matrix.hpp:19:0,
                 from /home/femke/anaconda3/lib/python3.7/site-packages/pystan/stan/lib/stan_math/lib/boost_1.66.0/boost/numeric/odeint/util/ublas_wrapper.hpp:24,
                 from /home/femke/anaconda3/lib/python3.7/site-packages

这值得担心吗?如果没有,如何专门禁用这些警告,而不是从代码的其他部分禁用这些警告?如果是这样,我应该怎么改变。

编辑:阅读问题Cython Numpy warning about NPY_NO_DEPRECATED_API when using MemoryView之后,我仍然不知道如何安全地禁用此警告。

0 个答案:

没有答案