You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
statmodels sets warning filter "always" for all UserWarnings #4711
It very aggressively sets the "always" action for all UserWarnings, regardless of where they are defined or triggered.
Example issue: just by importing seaborn (which has statsmodels as dependency) in a jupyter notebook, I was flooded with repetitive warnings instead of just a single one: mwaskom/seaborn#1446
My guess is that statsmodels wants to use warnings to report (potential) problems with model specification, so there it makes sense (like, if you set up a bad model, and get a warning, and then change it to a different bad model, you want to get a second warning).
It's probably reasonable to think that UserWarning should often be issued in that kind of context (if the user keeps doing the bad thing, keep warning them), but numpy's VisibleDeprecationWarning inherits from UserWarning, which I guess is what makes it visible!
As a suggestion to statsmodels, what if you defined a subclass of UserWarning called, e.g, ModelWarning and set that to always fire, reducing side-effects for other packages?
what if you defined a subclass of UserWarning called, e.g, ModelWarning and set that to always fire
good idea, I thought we will have to add a loop to set each specific warning to always.
Thanks for reporting. I guess I was too enthusiastic about the warnings. (but I thought a DeprecationWarning or other python warnings would not be UserWarnings.)
Yes, the point is that we always want to warn when a model or function runs into problems with the data, similar to RuntimeWarnings issued by numpy
(Although we still have noise RuntimeWarnings where we don't silence the RuntimeWarnings even if it is expected by design.)
Activity
mwaskom commentedon Jun 5, 2018
My guess is that statsmodels wants to use warnings to report (potential) problems with model specification, so there it makes sense (like, if you set up a bad model, and get a warning, and then change it to a different bad model, you want to get a second warning).
It's probably reasonable to think that
UserWarningshould often be issued in that kind of context (if the user keeps doing the bad thing, keep warning them), but numpy'sVisibleDeprecationWarninginherits fromUserWarning, which I guess is what makes it visible!As a suggestion to statsmodels, what if you defined a subclass of
UserWarningcalled, e.g,ModelWarningand set that to always fire, reducing side-effects for other packages?josef-pkt commentedon Jun 5, 2018
good idea, I thought we will have to add a loop to set each specific warning to always.
Thanks for reporting. I guess I was too enthusiastic about the warnings. (but I thought a DeprecationWarning or other python warnings would not be UserWarnings.)
Yes, the point is that we always want to warn when a model or function runs into problems with the data, similar to RuntimeWarnings issued by numpy
(Although we still have noise RuntimeWarnings where we don't silence the RuntimeWarnings even if it is expected by design.)
We can backport this if we make a 0.9.1 release.
BUG: add ModelWarning base class to avoid warning filter on standard …
BUG: add ModelWarning base class to avoid warning filter on standard …
soxofaan commentedon Jun 5, 2018
created pull requests #4712 (for master) and #4713 (for 0.9.x branch)
soxofaan commentedon Jun 22, 2018
FYI, my current workaround to suppress repetitive user warnings in Jupyter notebooks is to add this to the notebook: