Skip to content
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

[ENH] Implements sklearn style pretty printing directly in skbase #150

Closed
wants to merge 18 commits into from

Conversation

RNKuhns
Copy link
Contributor

@RNKuhns RNKuhns commented Mar 13, 2023

Reference Issues/PRs

Fixes #17

What does this implement/fix? Explain your changes.

This implements sklearn pretty printing directly in skbase with some minor tweaks.

Does your contribution introduce a new dependency? If yes, which one?

No new dependencies. In theory this will let us remove the dependency on sklearn, but we'll save that for a separate PR.

What should a reviewer concentrate their feedback on?

This depends on the global config PR -- specifically, the ability for local config interface to retrieve (and update) global config. Two global (or local) configuration parameters (print_changed_only and display) control pretty printing output.

Any other comments?

PR checklist

For all contributions
  • I've reviewed the project documentation on contributing
  • I've added myself to the list of contributors.
  • The PR title starts with either [ENH], [CI/CD], [MNT], [DOC], or [BUG] indicating whether
    the PR topic is related to enhancement, CI/CD, maintenance, documentation, or a bug.
For code contributions
  • Unit tests have been added covering code functionality
  • Appropriate docstrings have been added (see documentation standards)
  • New public functionality has been added to the API Reference

@RNKuhns RNKuhns marked this pull request as draft March 13, 2023 05:09
@RNKuhns RNKuhns requested a review from fkiraly March 13, 2023 05:09
with suppress(AttributeError):
return base_object._sk_visual_block_()

if isinstance(base_object, str):

Check warning

Code scanning / CodeQL

Unreachable code

This statement is unreachable.
super().__init__(indent, width, depth, stream, compact=compact)
self._indent_at_name = indent_at_name
if self._indent_at_name:
self._indent_per_level = 1 # ignore indent param

Check warning

Code scanning / CodeQL

Overwriting attribute in super-class or sub-class

Assignment overwrites attribute _indent_per_level, which was previously defined in superclass [PrettyPrinter](1).
skbase/config/__init__.py Fixed Show fixed Hide fixed
skbase/tests/test_base.py Fixed Show fixed Hide fixed
skbase/tests/test_base.py Fixed Show fixed Hide fixed
@codecov-commenter
Copy link

codecov-commenter commented Mar 13, 2023

Codecov Report

Merging #150 (3c49f7d) into main (b662e28) will increase coverage by 1.39%.
The diff coverage is 89.75%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main     #150      +/-   ##
==========================================
+ Coverage   82.68%   84.07%   +1.39%     
==========================================
  Files          32       41       +9     
  Lines        2327     2902     +575     
==========================================
+ Hits         1924     2440     +516     
- Misses        403      462      +59     
Impacted Files Coverage Δ
skbase/base/_pretty_printing/_object_html_repr.py 67.05% <67.05%> (ø)
skbase/base/_pretty_printing/_pprint.py 90.12% <90.12%> (ø)
skbase/base/_base.py 84.00% <92.85%> (+1.77%) ⬆️
skbase/config/_config.py 97.61% <97.61%> (ø)
skbase/config/tests/test_config.py 98.73% <98.73%> (ø)
skbase/base/_pretty_printing/__init__.py 100.00% <100.00%> (ø)
skbase/config/__init__.py 100.00% <100.00%> (ø)
skbase/config/tests/__init__.py 100.00% <100.00%> (ø)
skbase/utils/_check.py 100.00% <100.00%> (ø)
skbase/utils/tests/test_check.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@RNKuhns RNKuhns marked this pull request as ready for review March 13, 2023 06:54
@RNKuhns
Copy link
Contributor Author

RNKuhns commented Mar 13, 2023

@fkiraly I want to do a bit more testing and I need to clean up the 2 code scanning items that were found, but this should be ready for you to take a look at.

@RNKuhns RNKuhns mentioned this pull request Mar 13, 2023
13 tasks
Copy link
Contributor

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Quick question: why is this dependent on the global config?

This could also be implemented with, and tested with, a purely local config mechanism?

@RNKuhns
Copy link
Contributor Author

RNKuhns commented Mar 15, 2023

@fkiraly this could in theory be implemented as a local configuration. But in practice, how the objects are printed or represented in html is really something you want to set and have apply to all the objects.

@fkiraly
Copy link
Contributor

fkiraly commented Mar 16, 2023

no, I meant architecturally.

Why does this PR need to depend on the global config?
Should the global config not be such that it can optionally set a global default for any local config?

In my (perhaps too naive) understanding of the global config, it should not be coupled with the pretty printing config option, so it should not be necessary to have this PR depend on the global config.

Conversely, if there is a strict dependency here, I think there's something wrong architecturally (perhaps subtly)

@RNKuhns
Copy link
Contributor Author

RNKuhns commented Mar 17, 2023

@fkiraly i think you are suggesting the local config is the main/prevailing config and the global config can optionally override it.

That would imply returning local config and then updating with global config.

However, I think the global config should be the higher precedent config and the local config should be to optionally override it.

The global configuration should only contain config params and values that provide broad context to a BaseObject.

Local config can override that context for an object.

So for something like pretty printing options. The most typical use case is that they are not changed from global config settings. So in a limited number of cases a user calls the object's set_config to override global setting.

@fkiraly
Copy link
Contributor

fkiraly commented Mar 18, 2023

@RNKuhns, I am not suggesting anything about precendence of configs here (and I agree with you that local should override global).

All I'm saying that the existene of a global config mechanism should not be architecturally required for the pretty printing. If it is, something is architecturally wrong.

Why: config precedence and "getting the values for the applicable config" are logically separate, hence should be architecturally separate to translating the applicable config values into behaviour.

fkiraly added a commit that referenced this pull request Apr 18, 2023
Fixes #17.

This implements ``sklearn`` pretty printing directly in ``skbase`` with
some minor tweaks.

Based on #150 by @RNKuhns, but
removes the strong coupling to the new global config interface, as well
as the global config interface that imo has nothing to do (or should
have nothing to do) with that PR.

I think the global config interface still needs some work, and according
to my comments in #150, it should be entirely uncoupled, or more
precisely, coupled only via `get_config`.

(the alternative would be coupling it to every place where a config -
local or global - is used, which is bad design)

---------

Co-authored-by: rnkuhns <rnkuhns@gmail.com>
@fkiraly
Copy link
Contributor

fkiraly commented Apr 18, 2023

supserseded by #156. Config interface is here: #149

@fkiraly fkiraly closed this Apr 18, 2023
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.

[ENH] Separate Pretty Printing from sklearn dependency
3 participants