Why can’t I suppress numpy warnings

Warnings can often be useful and in most cases I wouldn’t advise this, but you can always make use of the Warnings module to ignore all warnings with filterwarnings:

warnings.filterwarnings('ignore')

Should you want to suppress uniquely your particular error, you could specify it with:

with warnings.catch_warnings():
    warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered')

Leave a Comment