When I import R in python, using rpy2, how do I suppress warnings?
It appears that in R you have to do just the following
options(warn=-1)
...but I'm not familiar with R. How do I do this in python?
When I import R in python, using rpy2, how do I suppress warnings?
It appears that in R you have to do just the following
options(warn=-1)
...but I'm not familiar with R. How do I do this in python?
Beginning with 3.0 version, rpy2 does not use Python's warnings module anymore. It now relies on logging instead. The new solution would be:
from rpy2.rinterface_lib.callbacks import logger as rpy2_logger
import logging
rpy2_logger.setLevel(logging.ERROR) # will display errors, but not warnings
If you want to filter specific warnings only, use:
rpy2_logger.addFilter(lambda record: 'notch went outside hinges' not in record.msg)
See LogRecord class specification for available fields for advanced filtering.