Move in-line imports to top of files#542
Conversation
| import warnings | ||
| from typing import Literal | ||
|
|
||
| import ipywidgets |
There was a problem hiding this comment.
Can you abbreviate ipywidgets to ipw?
That's what we do everywhere else in the code.
src/plopp/widgets/drawing.py
Outdated
| @@ -154,12 +155,6 @@ def _get_points_info(artist, figure): | |||
|
|
|||
|
|
|||
| def _make_points(**kwargs): | |||
There was a problem hiding this comment.
Hmm, does this mean that we can do away with the entire function _make_points (and the like)?
The comment clearly states it's to avoid issues with dependency import?
| """ | ||
| Convert the underlying Matplotlib figure to an image widget from ``ipywidgets``. | ||
| """ | ||
| from ipywidgets import Image |
There was a problem hiding this comment.
This import is a little different.
We still want to be able to use the matplotlib-based canvas without ipywidgets (to make static figures).
If we request a Canvas, ipywidgets would now be a hard-dependency, even with the lazy_loader.
I'll revert this part.
| from matplotlib.figure import Figure as MplFigure | ||
|
|
||
| from ...graphics import BaseFig | ||
| from ...widgets import HBar, VBar, make_toolbar_canvas2d |
There was a problem hiding this comment.
Same as above. We should still be able to make static mpl figures without ipywidgets.
I wonder why this was not picked up by CI?
I thought we had tests running with only minimal deps?
| """ | ||
| Convert the colorbar into a widget for use with other ``ipywidgets``. | ||
| """ | ||
| import ipywidgets as ipw |
There was a problem hiding this comment.
This one should also be reverted.
Co-authored-by: Neil Vaytet <39047984+nvaytet@users.noreply.github.com>
Since lazy_loader was introduced in #405, modules are lazily loaded so deferred imports to avoid hard dependencies are no longer needed.
Closes #541
Did some rudimentary tests on import times, didn't see much affect as expected.