Skip to content

ignore_warnings decorator ignored on python3.5? #7255

Closed

Description

@amueller

test_check_array
sklearn.preprocessing.tests.test_data.test_deprecation_minmax_scaler
both throw deprecation warnings despite the @ignore_warnings decorator.
Hum.

Activity

  1. added this to the 0.18 milestone on Aug 26, 2016
  2. 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
  3. lower-case commented on Aug 28, 2016

    @lower-case

    Hey @amueller I'd like to work on this issue.

  4. tguillemot commented on Aug 29, 2016

    @tguillemot
    Contributor

    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 ?

  5. amueller commented on Aug 29, 2016

    @amueller
    MemberAuthor

    huh... that is interesting behavior. Maybe we also shouldn't have an ignore_warnings decorator on functions that do assert_warnings...

  6. jnothman commented on Aug 29, 2016

    @jnothman
    Member

    Yes, it -- or equivalent -- is necessary, because of bugs in Python. Out of our control.

  7. amueller commented on Sep 8, 2016

    @amueller
    MemberAuthor

    done in #7368

  8. modified the milestones: 0.19, 0.18 on Sep 29, 2016
  9. jnothman commented on Sep 29, 2016

    @jnothman
    Member

    Was this fixed by #7296

  10. ldirer commented on Jun 9, 2017

    @ldirer
    Contributor

    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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions