[WIP] Silence std::cerr calls inside of python by stanleyjs · Pull Request #377 · PythonOT/POT

Types of changes

Adds flags to disable std::cerr reporting in the cpp backend. Adds parameter ot.backend.use_cerr as parameter and ot.backend.get_cerr() getter to enable/disable cerr reporting inside of python. The parameter defaults to False.

Motivation and context / Related issue

We are using POT inside of jupyter notebook and running into a problem that hits its iter limits. The warnings flood our console. Because the backend code is calling std::cerr directly, rather than passing the error string up to the python stderr stream, traditional context management based redirection (or simply killing sys.stderr inside of python) does not work.

How has this been tested (if it applies)

Have tested the basic use case and enable/disabling the cerr. Works in ipython on 3.9.7.

PR checklist

  • [x ] I have read the CONTRIBUTING document.
  • [x ] The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • [ x] I have added the PR and Issue fix to the RELEASES.md file.