Skip to content

Conversation

@maximlt
Copy link
Member

@maximlt maximlt commented Mar 4, 2025

  • Patching only done on import when in IPython or when the env var HVPLOT_PATCH_PLOT_DOCSTRING_SIGNATURE is non falsy
  • Move the utility functions from the top-level __init__.py to the util.py module
  • Ensure the signature and docstring contain the right options, moving the backend styling options last

@maximlt maximlt marked this pull request as draft March 4, 2025 16:04
@maximlt maximlt marked this pull request as ready for review March 4, 2025 21:36
@maximlt maximlt requested a review from hoxbro March 5, 2025 15:40
Copy link
Member

@hoxbro hoxbro left a comment

Choose a reason for hiding this comment

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

I'm assuming most of the changes are "just" moved code, and no significant logic has been changed in them.

Comment on lines +73 to +74
from .util import _PatchHvplotDocstrings, _in_ipython
from .utilities import help, hvplot_extension, output, save, show # noqa
Copy link
Member

Choose a reason for hiding this comment

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

It's a little weird that there are two files with util/utilities, but this was not added to this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it's weird :/

Copy link
Member Author

Choose a reason for hiding this comment

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

That's the sort of thing we should clean up for hvPlot 1.0.

hvplot/util.py Outdated
return geoviews


def _is_installed(package: str) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe cache this result?

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def _is_installed(package: str) -> bool:
def _is_installed(module: str) -> bool:

I see a module as something you import and a package as something you install. In most cases, this is, of course, the same.

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes thanks good catch, I didn't know find_spec was looking at modules. I removed _is_installed entirely as I think it was a bit misleading and isn't used much anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe cache this result?

I thought about it before, and then thought people do special things in their environment while working directly from a notebook (install packages, autoreloading modules, etc.). The function that patches plotting signatures and docstrings doesn't only run on import but also when switching HoloViews backend. So I'd rather not cache for now, and keep that for future improvements to improve the import speed of hvPlot, which I'm sure we'll look at at some point.

@maximlt maximlt merged commit 975c7c7 into main Mar 12, 2025
11 checks passed
@maximlt maximlt deleted the refactor_docstring_signature branch March 12, 2025 16:12
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.

3 participants