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
ignore_warnings decorator ignored on python3.5? #7255
changed the title [-]sklearn.preprocessing.tests.test_data.test_deprecation_minmax_scaler throws deprecation warning[/-][+]ignore_warnings decorator ignored on python3.5?[/+]on Aug 26, 2016
The problem comes from the function clean_warning_registry() that remove all previous filters.
As you use ignore_warning with assert_warnings, the simple_filter(ignore) done ignore_warnings is removed and all the warning are visible (see test_testing.py )
I understand the need of clean_warning_registry but is it really necessary ? By definition, after a with warning block everything is reseted as it was before the with warning.
@amueller@ogrisel I can fix the problem by removing the clean_warning_registry() but are you agree with that behavior ?
Just because I ran into some confusing issues with ignore_warnings:
As @tguillemot mentioned, ignore_warnings has side effects as it removes existing warning filters.
I think safe usage would be to use EITHER decorator OR inline calls.
Otherwise the inline calls may clear the warning filters, and a later line emit a warning that wont be caught anymore, which is super confusing when the decorator is there.
Activity
[-]sklearn.preprocessing.tests.test_data.test_deprecation_minmax_scaler throws deprecation warning[/-][+]ignore_warnings decorator ignored on python3.5?[/+]lower-case commentedon Aug 28, 2016
Hey @amueller I'd like to work on this issue.
tguillemot commentedon Aug 29, 2016
The problem comes from the function
clean_warning_registry()that remove all previous filters.As you use
ignore_warningwithassert_warnings, thesimple_filter(ignore)doneignore_warningsis removed and all the warning are visible (see test_testing.py )I understand the need of
clean_warning_registrybut is it really necessary ? By definition, after awith warningblock everything is reseted as it was before thewith warning.@amueller @ogrisel I can fix the problem by removing the
clean_warning_registry()but are you agree with that behavior ?amueller commentedon Aug 29, 2016
huh... that is interesting behavior. Maybe we also shouldn't have an
ignore_warningsdecorator on functions that doassert_warnings...jnothman commentedon Aug 29, 2016
Yes, it -- or equivalent -- is necessary, because of bugs in Python. Out of our control.
amueller commentedon Sep 8, 2016
done in #7368
jnothman commentedon Sep 29, 2016
Was this fixed by #7296
ldirer commentedon Jun 9, 2017
Just because I ran into some confusing issues with
ignore_warnings:ignore_warningshas side effects as it removes existing warning filters.Otherwise the inline calls may clear the warning filters, and a later line emit a warning that wont be caught anymore, which is super confusing when the decorator is there.