19

I have some python code that, at some point, takes the axis means of a reasonably sparse array with nans in. Every time I run the code it raises a RuntimeWarning.

I know what's causing the warning, it's intentional, and it doesn't affect the output. It is, however, quite irritating to be presented with the warning every time I run the program - so, is there a cheap and nasty way to prevent them from being printed to the terminal?

Kieran Hunt
  • 1,738
  • 4
  • 17
  • 29

2 Answers2

14

This may be useful to you, I think the issue has been pretty solved in this question: How to disable python warnings

Community
  • 1
  • 1
Palmer
  • 493
  • 4
  • 13
4

All what you need is suppress it exactly as described in official documentation: https://docs.python.org/2/library/warnings.html#temporarily-suppressing-warnings

ZedXter
  • 163
  • 1
  • 6