Skip to content

xfail_checks tag only works with parametrize_with_checks #16958

Closed

Description

@NicolasHug

Working towards #16890, I'm discovering that the xfail_checks tag only work when one uses @parametrize_with_checks.

I feel like developers would expect it to work when simply calling check_estimator() as well. Any reason this isn't supported?

CC @thomasjpfan @rth

Activity

  1. thomasjpfan commented on Apr 19, 2020

    @thomasjpfan
    Member

    Marking a test as xfail is very specific to pytest.

    To make it work in check_estimator, I guess we would need to still assert the test, but catch it when it fails (since it is expected to) and convert it into a warning?

  2. NicolasHug commented on Apr 19, 2020

    @NicolasHug
    MemberAuthor

    Shouldn't we make the tag more general such that:

    • the check is marked with pytest.xfail when using @parametrize_with_checks
    • the check is skipped when using check_estimator(), possibly with a warning?
  3. rth commented on Apr 19, 2020

    @rth
    Member

    I feel like developers would expect it to work when simply calling check_estimator() as well. Any reason this isn't supported?

    It should works, in the sense that xfail marked tests should be skipped (as far as I remember the PRs where it was introduced). If they aren't that's it indeed a bug.

  4. NicolasHug commented on Apr 19, 2020

    @NicolasHug
    MemberAuthor

    On master, with check_estimator(), NuSVC fails on check_class_weight_classifiers which is marked with the xfail_checks tag.

    In [1]: from sklearn.svm import NuSVC                                                                                  
    
    In [2]: from sklearn.utils.estimator_checks import check_estimator                                                     
    
    In [3]: check_estimator(NuSVC())                                                                                       
    ---------------------------------------------------------------------------
    AssertionError                            Traceback (most recent call last)
    <ipython-input-3-6747ab965a6f> in <module>
    ----> 1 check_estimator(NuSVC())
    
    ~/dev/sklearn/sklearn/utils/estimator_checks.py in check_estimator(Estimator, generate_only)
        486     for estimator, check in checks_generator:
        487         try:
    --> 488             check(estimator)
        489         except SkipTest as exception:
        490             # the only SkipTest thrown currently results from not
    
    ~/dev/sklearn/sklearn/utils/_testing.py in wrapper(*args, **kwargs)
        315             with warnings.catch_warnings():
        316                 warnings.simplefilter("ignore", self.category)
    --> 317                 return fn(*args, **kwargs)
        318 
        319         return wrapper
    
    ~/dev/sklearn/sklearn/utils/estimator_checks.py in check_class_weight_classifiers(name, classifier_orig)
       2359         # XXX: Generally can use 0.89 here. On Windows, LinearSVC gets
       2360         #      0.88 (Issue #9111)
    -> 2361         assert np.mean(y_pred == 0) > 0.87
       2362 
  5. rth commented on Apr 19, 2020

    @rth
    Member

    You are right. I probably though it would be good it if worked that way, but haven't actually implemented it lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions