-
Notifications
You must be signed in to change notification settings - Fork 0
Remove CallbackContext's _depth property #15
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
Remove CallbackContext's _depth property #15
Conversation
sklearn/callback/_progressbar.py
Outdated
| depth = len(_get_task_info_path(task_info)) - 1 | ||
| indent = f"{' ' * depth}" | ||
| style = f"[{colors[(depth) % len(colors)]}]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to avoid calling _get_task_info_path because it will be called for each node while we could build the depth during the tree building.
Let's define a depth attribute at init time as self.depth = 0 if parent is None else parent.depth + 1.
| import pytest | ||
|
|
||
| from sklearn.callback._callback_context import CallbackContext | ||
| from sklearn.callback._progressbar import _get_task_info_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we need it for metric monitor as well, let's directly move it in callback_context. Importing it from progressbar in test_callback_context feels off
…d move _get_task_info_path to _callback_context.py
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
12b921f
into
jeremiedbb:base_callbacks_2
Remove the
CallbackContext's_depthproperty, as it can easily be obtained aslen(_get_task_info_path(self.task_info)).