Skip to content

Commit

Permalink
Merge branch 'main' into fix_ui_without_geoviews
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored Oct 30, 2024
2 parents 4df0194 + 9078378 commit a9008b4
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 31 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ jobs:
run: |
echo "Deploying from ref ${GITHUB_REF#refs/*/}"
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: install dev nbsite
run: pip install --pre -U nbsite
- name: install dev
# To make sure the latest is installed.
run: pip install -e . --no-deps
- name: conda info
run: conda info
- name: conda list
Expand All @@ -62,7 +63,7 @@ jobs:
if: failure()
run: cat /tmp/sphinx-*.log | tail -n 100
- name: Deploy dev
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
if: |
(github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'dev') ||
(github.event_name == 'push' && (contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
Expand All @@ -76,7 +77,7 @@ jobs:
if: |
(github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'main') ||
(github.event_name == 'push' && !(contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./builtdocs
Expand Down Expand Up @@ -104,8 +105,6 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
- name: install
run: pip install -v --prefer-binary -e ."[doc, examples, geo]"
- name: install dev nbsite
run: pip install --pre -U nbsite
- name: pip list
run: pip list
- name: Set and echo git ref
Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

The API is based on the familiar Pandas `.plot` API and the innovative `.interactive` API.

<img src="https://github.com/MarcSkovMadsen/old-awesome-panel-assets/blob/master/images/hvPlot/hvplot-total-intro.gif?raw=true" style="max-height:600px;border-radius:2%;">
<img src="https://assets.holoviz.org/hvplot/hvplot-total-intro.gif" style="max-height:600px;border-radius:2%;">

## hvPlot works with the tools you know and love

Expand All @@ -36,7 +36,7 @@ hvPlot is **the simplest way to benefit from the [HoloViz](https://holoviz.org/)

Check out [this blog post](https://towardsdatascience.com/the-easiest-way-to-create-an-interactive-dashboard-in-python-77440f2511d1) to see how easy it is to create an interactive dashboard with hvPlot and Panel.

<a href="https://towardsdatascience.com/the-easiest-way-to-create-an-interactive-dashboard-in-python-77440f2511d1"><img src="https://miro.medium.com/max/700/1*bZjPtucT8O1esjQaGQenHw.gif" style="max-height:600px;border-radius:2%;"></a>
<a href="https://towardsdatascience.com/the-easiest-way-to-create-an-interactive-dashboard-in-python-77440f2511d1"><img src="https://assets.holoviz.org/hvplot/interactive_dashboard.gif" style="max-height:600px;border-radius:2%;"></a>

## Mini getting-started

Expand All @@ -56,12 +56,6 @@ or with ``pip``:
pip install hvplot
```

Please note that for versions of `jupyterlab<3.0`, you must install the JupyterLab extension manually with:

```bash
jupyter labextension install @pyviz/jupyterlab_pyviz
```

### Plotting data

Work with your data source:
Expand All @@ -87,7 +81,7 @@ Use the `.hvplot` API as you would use the Pandas or Xarray `.plot` API:
df.hvplot()
```

[<img src="https://github.com/MarcSkovMadsen/old-awesome-panel-assets/blob/master/images/hvPlot/hvplot-intro-plot.gif?raw=true" style="max-height:300px;border-radius:2%;">](https://hvplot.holoviz.org/user_guide/index.html)
[<img src="https://assets.holoviz.org/hvplot/hvplot-intro-plot.gif" style="max-height:300px;border-radius:2%;">](https://hvplot.holoviz.org/user_guide/index.html)


### Interactive data apps
Expand All @@ -101,7 +95,7 @@ pn.extension()
df.interactive(width=600).head(n=pn.widgets.IntSlider(start=1, end=5, value=3))
```

[<img src="https://github.com/MarcSkovMadsen/old-awesome-panel-assets/blob/master/images/hvPlot/hvplot-intro-interactive.gif?raw=true" style="max-height:300px;border-radius:2%;">](https://hvplot.holoviz.org/user_guide/Interactive.html)
[<img src="https://assets.holoviz.org/hvplot/hvplot-intro-interactive.gif" style="max-height:300px;border-radius:2%;">](https://hvplot.holoviz.org/user_guide/Interactive.html)

### How to find documentation from your notebook or editor

Expand Down
3 changes: 2 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
extensions += [ # noqa
'nbsite.gallery',
'nbsite.analytics',
'nbsite.nb_interactivity_warning',
'sphinx_copybutton',
'sphinxext.rediraffe',
]
Expand Down Expand Up @@ -114,7 +115,7 @@
'user_guide/Streaming.ipynb',
]
# cell execution timeout in seconds (-1 to ignore, 30 by default)
nb_execution_timeout = 120
nb_execution_timeout = 240

if os.getenv('HVPLOT_REFERENCE_GALLERY') not in ('False', 'false', '0'):
rediraffe_redirects.update(
Expand Down
23 changes: 23 additions & 0 deletions doc/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

See [the HoloViz blog](https://blog.holoviz.org/#category=hvplot) for a visual summary of the major features added in a selection of releases.

## Version 0.11.1 (2024-10-16)

The 0.11.1 release is a patch release that brings a few bugfixes and documentation improvements. In particular it fixes a regression introduced in version 0.11.0 leading to an error when a plot is created from a Dask object with `tiles=True`. Many thanks to @Palmr (first contribution!), @ahuang11, @Hoxbro, @maximlt, and @philippjfr for their contributions!

Bug Fixes:

- Fix regression when `tiles=True` with Dask ([#1432](https://github.com/holoviz/hvplot/pull/1432))
- Fix hover tooltips for NetworkX plots ([#1439](https://github.com/holoviz/hvplot/pull/1439))

Documentation:

- Add `nb_interactivity_warning` extension ([#1444](https://github.com/holoviz/hvplot/pull/1444))
- Document Ruff's `allowed-unused-imports` ([#1436](https://github.com/holoviz/hvplot/pull/1436))
- Update image links in README ([#1433](https://github.com/holoviz/hvplot/pull/1433))
- Minor fixes ([#1434](https://github.com/holoviz/hvplot/pull/1434))

Tests:

- Mark `test_explorer_geo_revise_kind` with geo marker ([#1426](https://github.com/holoviz/hvplot/pull/1426))

[Full Changelog](https://github.com/holoviz/hvplot/compare/v0.11.0...v0.11.1)


## Version 0.11.0 (2024-09-27)

This minor release brings a number of enhancements and bugfixes, checkout the [release blog post](https://blog.holoviz.org/posts/hvplot_release_0.11/) for a visual summary of the most important changes.
Expand Down
2 changes: 1 addition & 1 deletion doc/user_guide/Customization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
" projection (default=None):\n",
" Coordinate reference system of the plot (output projection) specified as a string or integer EPSG code, a CRS or Proj pyproj object, a Cartopy CRS object or class name, a WKT string, or a proj.4 string. Defaults to PlateCarree.\n",
" tiles (default=False):\n",
" Whether to overlay the plot on a tile source. If coordinate values fall within lat/lon bounds, auto-projects to EPSG:3857 unless `projection=False`. Tiles sources\n",
" Whether to overlay the plot on a tile source. If coordinate values fall within lat/lon bounds, auto-projects to EPSG:3857 unless `projection=False` or if the data is lazily loaded (dask / ibis). Tiles sources\n",
" can be selected by name or a tiles object or class can be passed,\n",
" the default is 'Wikipedia'.\n",
" tiles_opts (default=None): dict\n",
Expand Down
4 changes: 2 additions & 2 deletions doc/user_guide/Geographic_Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"source": [
"We'll first start by displaying the airports **without GeoViews** with tiles by setting `tiles=True`. \n",
"\n",
"Under the hood, hvPlot projects lat/lon to easting/northing ([EPSG:4326](https://epsg.io/4326) to [EPSG:3857](https://epsg.io/3857)) coordinates without additional package dependencies if it detects that the values falls within expected lat/lon ranges.\n",
"Under the hood, hvPlot projects lat/lon to easting/northing ([EPSG:4326](https://epsg.io/4326) to [EPSG:3857](https://epsg.io/3857)) coordinates without additional package dependencies if it detects that the values falls within expected lat/lon ranges, **unless the data is lazily loaded (dask / ibis).**\n",
"\n",
"Note, **this feature is only available after `hvplot>=0.11.0`**; older versions, `hvplot<0.11.0`, require manual projection (see below)."
]
Expand Down Expand Up @@ -417,7 +417,7 @@
"- `global_extent` (default=False): Whether to expand the plot extent to span the whole globe\n",
"- `project` (default=False): Whether to project the data before plotting (adds initial overhead but avoids projecting data when plot is dynamically updated)\n",
"- `projection` (default=None): Coordinate reference system of the plot (output projection) specified as a string or integer EPSG code, a CRS or Proj pyproj object, a Cartopy CRS object or class name, a WKT string, or a proj.4 string. Defaults to PlateCarree.\n",
"- `tiles` (default=False): Whether to overlay the plot on a tile source. If coordinate values fall within lat/lon bounds, auto-projects to EPSG:3857 unless `projection=False`. Accepts the following values:\n",
"- `tiles` (default=False): Whether to overlay the plot on a tile source. If coordinate values fall within lat/lon bounds, auto-projects to EPSG:3857 unless `projection=False` or if the data is lazily loaded (dask / ibis). Accepts the following values:\n",
" - `True`: OpenStreetMap layer\n",
" - `xyzservices.TileProvider` instance (requires [`xyzservices`](https://xyzservices.readthedocs.io/) to be installed)\n",
" - a map string name based on one of the default layers made available by [HoloViews](https://holoviews.org/reference/elements/bokeh/Tiles.html) ('CartoDark', 'CartoLight', 'EsriImagery', 'EsriNatGeo', 'EsriUSATopo', 'EsriTerrain', 'EsriStreet', 'EsriReference', 'OSM', 'OpenTopoMap') or [GeoViews](https://geoviews.org/user_guide/Working_with_Bokeh.html) ('CartoDark', 'CartoEco', 'CartoLight', 'CartoMidnight', 'EsriImagery', 'EsriNatGeo', 'EsriUSATopo', 'EsriTerrain', 'EsriReference', 'EsriOceanBase', 'EsriOceanReference', 'EsriWorldPhysical', 'EsriWorldShadedRelief', 'EsriWorldTopo', 'EsriWorldDarkGrayBase', 'EsriWorldDarkGrayReference', 'EsriWorldLightGrayBase', 'EsriWorldLightGrayReference', 'EsriWorldHillshadeDark', 'EsriWorldHillshade', 'EsriAntarcticImagery', 'EsriArcticImagery', 'EsriArcticOceanBase', 'EsriArcticOceanReference', 'EsriWorldBoundariesAndPlaces', 'EsriWorldBoundariesAndPlacesAlternate', 'EsriWorldTransportation', 'EsriDelormeWorldBaseMap', 'EsriWorldNavigationCharts', 'EsriWorldStreetMap', 'OSM', 'OpenTopoMap'). Note that Stamen tile sources require a Stadia account when not running locally; see [stadiamaps.com](https://stadiamaps.com/).\n",
Expand Down
16 changes: 16 additions & 0 deletions doc/user_guide/Introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,22 @@
"For more detail on the available options see the [Customization](Customization.ipynb) user guide."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Working with Ruff\n",
"\n",
"In most cases, `import hvplot.pandas` is imported and never used directly. This will make linters like Ruff flag it as an [`unused-import`](https://docs.astral.sh/ruff/rules/unused-import/). This can either be ignored with a `# noqa: F401` or global being set in the `pyproject.toml` with [`allowed-unused-imports`](https://docs.astral.sh/ruff/settings/#lint_pyflakes_allowed-unused-imports).\n",
"\n",
"```toml\n",
"[tool.ruff.lint.pyflakes]\n",
"allowed-unused-imports = [\"hvplot.pandas\"]\n",
"```\n",
"\n",
"This configuration requires Ruff version 0.6.9 or greater to be installed."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
12 changes: 10 additions & 2 deletions doc/user_guide/NetworkX.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,16 @@
"graphviz = hvnx.draw(G, pos=pos)\n",
"\n",
"layout = shell + graphviz\n",
"\n",
"hvnx.save(layout, 'graph_layout.png')"
"layout"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"hvnx.save(layout, 'graph_layout.png')\n",
"```"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions doc/user_guide/Viewing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"hvplot.save(plot, 'test.png')"
"```python\n",
"hvplot.save(plot, 'test.png')\n",
"```"
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions envs/py3.11-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
name: hvplotdocs
channels:
- nodefaults
- pyviz/label/dev
- pyviz/label/tooling_dev
- conda-forge
dependencies:
- python=3.11
Expand All @@ -34,6 +36,7 @@ dependencies:
- ipywidgets
- jinja2
- matplotlib
- nbsite>=0.8.6
- networkx>=2.6.3
- notebook>=5.4
- numba>=0.51.0
Expand Down
5 changes: 4 additions & 1 deletion hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
is_cudf,
is_streamz,
is_ibis,
is_lazy_data,
is_xarray,
is_xarray_dataarray,
process_crs,
Expand Down Expand Up @@ -2167,11 +2168,13 @@ def _process_tiles_without_geo(self, data, x, y):
if data.crs is not None:
data = data.to_crs(epsg=3857)
return data, x, y
else:
elif not is_lazy_data(data):
# To prevent eager evaluation: https://github.com/holoviz/hvplot/pull/1432
min_x = np.min(data[x])
max_x = np.max(data[x])
min_y = np.min(data[y])
max_y = np.max(data[y])

x_within_bounds = -180 <= min_x <= 360 and -180 <= max_x <= 360
y_within_bounds = -90 <= min_y <= 90 and -90 <= max_y <= 90
if x_within_bounds and y_within_bounds:
Expand Down
3 changes: 2 additions & 1 deletion hvplot/networkx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from bokeh.models import HoverTool
from holoviews import Graph, Labels, dim
from holoviews.core.util import dimension_sanitizer
from holoviews.core.options import Store
from holoviews.plotting.bokeh import GraphPlot, LabelsPlot
from holoviews.plotting.bokeh.styles import markers
Expand Down Expand Up @@ -331,7 +332,7 @@ def draw(G, pos=None, **kwargs):
(d.label, d.name + '_values' if d in g.kdims else d.name) for d in g.kdims + g.vdims
]
tooltips = [
(label, '@{{dimension_sanitizer(name)}}')
(label, f'@{{{dimension_sanitizer(name)}}}')
for label, name in tooltip_dims
if name not in node_styles + edge_styles
]
Expand Down
17 changes: 17 additions & 0 deletions hvplot/tests/testgeowithoutgv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
import pandas as pd
import pytest

try:
import dask.dataframe as dd
import hvplot.dask # noqa
except ImportError:
dd = None


bk_renderer = hv.Store.renderers['bokeh']

Expand Down Expand Up @@ -66,3 +72,14 @@ def test_plot_with_xyzservices_tileprovider(self, simple_df):
assert isinstance(plot.get(0).data, xyzservices.TileProvider)
bk_plot = bk_renderer.get_plot(plot)
assert bk_plot.projection == 'mercator'

@pytest.mark.skipif(dd is None, reason='dask not installed')
def test_plot_with_dask(self, simple_df):
ddf = dd.from_pandas(simple_df, npartitions=2)
plot = ddf.hvplot.points('x', 'y', tiles=True)
assert 'x_' not in plot.get(1).data
assert 'y_' not in plot.get(1).data
assert len(plot) == 2
assert isinstance(plot.get(0), hv.Tiles)
bk_plot = bk_renderer.get_plot(plot)
assert bk_plot.projection == 'mercator'
7 changes: 7 additions & 0 deletions hvplot/tests/testnetworkx.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ def setUp(self):
def test_nodes_are_not_sorted(self):
plot = hvnx.draw(self.g)
assert all(self.nodes == plot.nodes.dimension_values(2))

def test_default_hover_tooltip(self):
from bokeh.models import HoverTool

plot = hvnx.draw(self.g)
hover = next(t for t in plot.opts['tools'] if isinstance(t, HoverTool))
assert [('index', '@{index_hover}')] == hover.tooltips
15 changes: 15 additions & 0 deletions hvplot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,21 @@ def is_xarray(data):
return isinstance(data, (DataArray, Dataset))


def is_lazy_data(data):
"""Check if data is lazy
This checks if the datatype is Dask, Ibis, or Polars' LazyFrame.
It is useful to avoid eager evaluation of the data.
"""
if is_dask(data) or is_ibis(data):
return True
elif is_polars(data):
import polars as pl

return isinstance(data, pl.LazyFrame)
return False


def is_xarray_dataarray(data):
if not check_library(data, 'xarray'):
return False
Expand Down
12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ examples-tests = [
# Additional packages required to build the docs
doc = [
"hvplot[examples]",
"nbsite >=0.8.4",
"nbsite >=0.8.6",
"sphinxext-rediraffe",
]
# Trick to let pip know we want to install dev dependencies
Expand Down Expand Up @@ -221,7 +221,6 @@ ruff = [
geoviews = { skip = true, packages = "geoviews-core >=1.9.0" }
# It should be ibis-framework[duckdb], but it works anyway.
ibis-framework = { skip = true, packages = "ibis-duckdb" }
nbsite = { skip = true }

[tool.pyproject2conda.envs."tests"]
channels = ["nodefaults", "pyviz/label/dev", "conda-forge"]
Expand All @@ -231,7 +230,14 @@ name = "hvplottests"
# reqs = ["-e .."] # Doesn't work

[tool.pyproject2conda.envs."docs"]
channels = ["nodefaults", "conda-forge"]
channels = [
"nodefaults",
# To get dev HoloViews, not always needed.
"pyviz/label/dev",
# To get dev nbsite, not always needed.
"pyviz/label/tooling_dev",
"conda-forge"
]
python = ["3.11"]
extras = ["doc", "examples", "geo", "graphviz", "dev-extras"]
name = "hvplotdocs"

0 comments on commit a9008b4

Please sign in to comment.