Skip to content

[MRG] Fix builtin PrettyPrinter usage on estimators #12938

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 1 commit into from
Jan 14, 2019

Conversation

NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented Jan 7, 2019

Reference Issues/PRs

Fixes #12906

What does this implement/fix? Explain your changes.

This PR makes a copy of the _dispatch dict in _EstimatorPrettyPrinter to prevent the builtin PrettyPrinter class to directly call _EstimatorPrettyPrinter._print_estimator on estimator objects, which fails since _print_estimator assumes the object is an instance of _EstimatorPrettyPrinter with specific attributes.

Any other comments?

Note that even when only PrettyPrinter is used, estimators will still be rendered with _EstimatorPrettyPrinter since PrettyPrinter internally uses repr() which itself uses _EstimatorPrettyPrinter.

So using PrettyPrinter or _EstimatorPrettyPrinter on an estimator has the exact same effect.

@NicolasHug NicolasHug changed the title [WIP] Fix builtin PrettyPrinter usage on estimators [MRG] Fix builtin PrettyPrinter usage on estimators Jan 7, 2019
Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @NicolasHug !

@jnothman jnothman merged commit 07b0a42 into scikit-learn:master Jan 14, 2019
@jnothman
Copy link
Member

It is possible that we should still enhance this, making sure that estimators are pretty-printed by pprint also.

xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError: 'PrettyPrinter' object has no attribute '_indent_at_name'
3 participants