I am calling a python function in my c++ application using python-c API. The code is a little complex but the gist is this. Whenever I run the file I get warnings printed on the console which I can't disable.
There are three files. Main.cpp ; python_functions.h ; simple.py
1."python_functions.h" contains a function "my_func" which calls a function "arch_function" defined in
"simple.py".
2. Main.cpp calls this function "my_func" inside the main function.
Below is the function defined in simple.py
def arch_function(time_series):
from arch import arch_model
am = arch_model(time_series,p = 1 ,q = 1, o = 1 ,mean = 'constant')
res = am.fit(disp = 'off')
return res
Below is the warning received:
warnings.warn(
C://Anaconda3//envs//py39//Lib//site-packages\arch\univariate\base.py:753:
ConvergenceWarning: The optimizer returned code 8. The message is:
Positive directional derivative for linesearch
See scipy.optimize.fmin_slsqp for code meaning.
I have tried many ideas to disable the warnings in the console like :
a. ignoring all warnings in the .py file.<https://stackoverflow.com/questions/14463277/how-to-disable-python-warnings>
b. Redirecting output in cpp file to a txt file. <https://stackoverflow.com/questions/10150468/how-to-redirect-cin-and-cout-to-files>
c. enabling failbit from here. : <https://stackoverflow.com/questions/30184998/how-to-disable-cout-output-in-the-runtime>
But none of them worked. How to disable warnings being printed on the console.