Skip to content

Speed up import and load hvplot lazily#1541

Open
Sevans711 wants to merge 4 commits into
UXARRAY:mainfrom
Sevans711:speedup-import
Open

Speed up import and load hvplot lazily#1541
Sevans711 wants to merge 4 commits into
UXARRAY:mainfrom
Sevans711:speedup-import

Conversation

@Sevans711

Copy link
Copy Markdown
Collaborator

Closes #1539

Overview

Speeds up import uxarray from ~1.7 seconds to ~0.7 seconds, by making hvplot.pandas and hvplot.xarray imports lazy, i.e. only import them when actually initializing a PlotAccessor object for the first time.

PR Checklist

General

  • An issue is linked created and linked
  • Add appropriate labels
  • Filled out Overview and Expected Usage (if applicable) sections

Testing

  • Adequate tests are created if there is new functionality
  • Tests cover all possible logical paths in your function
  • Tests are not too basic (such as simply calling a function and nothing else)

Sevans711 and others added 3 commits June 30, 2026 11:34
Small change which reduces time for "import uxarray" on my machine from 1.7 seconds to 0.7 seconds. Also avoids the strange gray bars in Jupyter until actually making a plot for the first time, instead of immediately when importing uxarray. (The bars apparently came from "import hvplot.pandas" and "import hvplot.xarray"). See also: UXARRAY#1260

This also means hvplot import is lazy, which means we should be able to move hvplot to be an optional dependency instead of a requirement. See also: UXARRAY#1224
Comment thread test/test_dependencies.py Outdated
Co-authored-by: Rajeev Jain <rajeeja@gmail.com>
@Sevans711

Copy link
Copy Markdown
Collaborator Author

We might want to delay merging; I just discovered that import hvplot.pandas and import hvplot.xarray always change the backend to bokeh. Thus, with these changes, lazily importing hvplot means the first plot you make from uxarray will be forced into having bokeh backend, regardless of the backend you tried to set originally. I am creating a bug report on hvplot repository now about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-benchmark Run ASV benchmark workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

speed up import and load hvplot lazily

3 participants