Skip to content

MNT simplify xfail check marking logic #16949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 17, 2020

Conversation

NicolasHug
Copy link
Member

  • renamed xfail_test tag into xfail_checks because that's the variable name
  • simplified and added comments to the marking logic

@NicolasHug
Copy link
Member Author

ping @rth @thomasjpfan

@NicolasHug NicolasHug changed the title [MRG] simplify xfail check marking logic [MRG] MNT simplify xfail check marking logic Apr 17, 2020
@NicolasHug NicolasHug added this to the 0.23 milestone Apr 17, 2020
@NicolasHug
Copy link
Member Author

NicolasHug commented Apr 17, 2020

I also removed the description of check_estimator and parametrize_with_checks out of the UG and put these back in the docstrings. The UG didn't read really well because the section is about "rolling your own estimator" and sklearn conventions, and the section about these tools was going into unnecessary details (also the bash command wasn't properly rendered).

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @NicolasHug ! Two minor comments otherwise LGTM.

Just to make sure I understand correctly, this is pure refactoring? It does not address issues for #16890 right?

sklearn/base.py Outdated
@@ -33,7 +33,7 @@
'stateless': False,
'multilabel': False,
'_skip_test': False,
'_xfail_test': False,
'_xfail_checks': {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm weary of having mutable object in this default dict. You never know what downstream object can do with it. I think it should not be mutable, hence the False. We also say somewhere in the doc that all estimator tags with a few exceptions default to False.

Unless this is solving some issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes the code cleaner and easier to understand because we can just do if check_name not in xfail_checks: instead of checking if it's a bool first.

I share the concern about not using mutable globals, but right above there is the 'X_types': ['2darray'] tag so I thought we could just do it here as well

Alternatively I can update _safe_tags() to return {} when the tag is False?

Copy link
Member

@rth rth Apr 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I share the concern about not using mutable globals, but right above there is the 'X_types': ['2darray'] tag so I thought we could just do it here as well

Indeed, but it one puts wrong value there either all tests are going to be skipped or some would fail. Here it would potentially skip one test which is harder to notice.

Alternatively I can update _safe_tags() to return {} when the tag is False?

+1 for this particular tag.

@NicolasHug
Copy link
Member Author

Thanks for the quick review

Just to make sure I understand correctly, this is pure refactoring? It does not address issues for #16890 right?

I'm trying to work towards #16890 ultimately, but indeed this isn't directly related and it's just a small refactoring


xfail_checks = _safe_tags(estimator, '_xfail_checks') or {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally went for this @rth
I didn't udpate _safe_tags because I actually think we don't need it anymore #16950

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @NicolasHug !

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thomasjpfan thomasjpfan changed the title [MRG] MNT simplify xfail check marking logic MNT simplify xfail check marking logic Apr 17, 2020
@thomasjpfan thomasjpfan merged commit 2d03d78 into scikit-learn:master Apr 17, 2020
gio8tisu pushed a commit to gio8tisu/scikit-learn that referenced this pull request May 15, 2020
Co-Authored-By: Roman Yurchak <rth.yurchak@gmail.com>
viclafargue pushed a commit to viclafargue/scikit-learn that referenced this pull request Jun 26, 2020
Co-Authored-By: Roman Yurchak <rth.yurchak@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants