3

When I run any pystan code, the output is what I expect, but I get a wall of warnings.

I've tried updating pystan and cython, as these are mentioned in the wall of warnings. My pystan is now version 2.17.1 and cython 0.29.2. I'm running 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

The error message that I get starts with:

/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

Is this something to worry about? If not, how do I specifically disable these warnings, but not from other parts of my code? If so, what should I change.

Edit: after having read the question Cython Numpy warning about NPY_NO_DEPRECATED_API when using MemoryView, I still don't know how to safely disable this warning.

Femkemilene
  • 183
  • 2
  • 15
  • Possible duplicate of [Cython Numpy warning about NPY\_NO\_DEPRECATED\_API when using MemoryView](https://stackoverflow.com/questions/25789055/cython-numpy-warning-about-npy-no-deprecated-api-when-using-memoryview) – DavidW Apr 02 '19 at 16:06
  • 1
    It isn't something you should worry about. The duplicate I suggested doesn't have any (useful) information about how to disable it (so may only be half useful) – DavidW Apr 02 '19 at 16:09
  • 1
    Wait for Cython3.0: https://github.com/cython/cython/issues/2498 – ead Apr 03 '19 at 08:51
  • Thanks. That is unfortunate, as the wall makes it impossible to see print statement that come before in my spyder IPython console. Hope they fix it soon! – Femkemilene Apr 03 '19 at 08:58
  • I think in the short term if you can define `NPY_NO_DEPRECATED_API` to be `NPY_1_7_API_VERSION-1` it should work. I don't know how to do that from pystan though. – DavidW Apr 03 '19 at 08:58
  • Don't know that either.. What kind of file should I be looking for to change that in? – Femkemilene Apr 03 '19 at 09:03
  • There looks to be an undocumented `extra_compile_args` option for `StanModel`. Try passing `extra_compile_args=['-DNPY_NO_DEPRECATED_API=6']` or something similar. I have real way of testing this though – DavidW Apr 03 '19 at 09:18
  • Unfortunately, the wall of warnings doesn't change if I do that :(. I wouldn't know what something similar is here. – Femkemilene Apr 03 '19 at 09:28

0 Answers0