Skip to content

Commit

Permalink
Add DataFilterExtension example (#358)
Browse files Browse the repository at this point in the history
### Changelog

- Add `DataFilterExtension` example
- Move layer extensions out of `experimental`
  • Loading branch information
kylebarron authored Feb 13, 2024
1 parent ede2590 commit 696e2c7
Show file tree
Hide file tree
Showing 21 changed files with 1,884 additions and 421 deletions.
Binary file added assets/data-filter-extension.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions docs/api/experimental/traits.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/api/layer-extensions/brushing-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

> Screen recording from [U.S. County-to-County Migration example](../../../examples/migration/).
::: lonboard.experimental.BrushingExtension
::: lonboard.layer_extension.BrushingExtension
options:
show_bases: false
inherited_members: true
2 changes: 1 addition & 1 deletion docs/api/layer-extensions/collision-filter-extension.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CollisionFilterExtension

::: lonboard.experimental.CollisionFilterExtension
::: lonboard.layer_extension.CollisionFilterExtension
options:
show_bases: false
inherited_members: true
4 changes: 3 additions & 1 deletion docs/api/layer-extensions/data-filter-extension.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# DataFilterExtension

::: lonboard.experimental.DataFilterExtension
![](../../assets/data-filter-extension.gif)

::: lonboard.layer_extension.DataFilterExtension
options:
show_bases: false
inherited_members: true
4 changes: 4 additions & 0 deletions docs/api/traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
::: lonboard.traits.ColorAccessor

::: lonboard.traits.FloatAccessor

::: lonboard.traits.PointAccessor

::: lonboard.traits.GetFilterValueAccessor
1,402 changes: 1,402 additions & 0 deletions examples/data-filter-extension.ipynb

Large diffs are not rendered by default.

253 changes: 161 additions & 92 deletions examples/internet-speeds.ipynb

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions examples/migration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"from matplotlib.colors import Normalize\n",
"\n",
"from lonboard import Map, ScatterplotLayer\n",
"from lonboard.experimental import ArcLayer, BrushingExtension"
"from lonboard.experimental import ArcLayer\n",
"from lonboard.layer_extension import BrushingExtension"
]
},
{
Expand Down Expand Up @@ -207,7 +208,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "13b8b182",
"metadata": {},
"outputs": [],
Expand All @@ -226,7 +227,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "8e0c2fd9",
"metadata": {},
"outputs": [],
Expand All @@ -253,7 +254,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"id": "86799a4c",
"metadata": {},
"outputs": [],
Expand All @@ -270,7 +271,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"id": "570868b8",
"metadata": {},
"outputs": [],
Expand All @@ -297,7 +298,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "56b9dcf2",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -329,7 +330,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "6400bd35",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -367,22 +368,22 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"id": "5ef02c61",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "528e69ea2bac4278a26f1215a74ccf75",
"model_id": "4cbbf3652a5e4fe590157620b932e821",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(layers=[ScatterplotLayer(brushing_radius=200000.0, extensions=[BrushingExtension()], get_fill_color=<pyarr…"
]
},
"execution_count": 12,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
2 changes: 1 addition & 1 deletion lonboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Python library for fast, interactive geospatial vector data visualization in Jupyter.
"""

from . import colormap, controls, traits
from . import colormap, controls, layer_extension, traits
from ._layer import (
BaseArrowLayer,
BaseLayer,
Expand Down
11 changes: 9 additions & 2 deletions lonboard/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
from anywidget import AnyWidget
from ipywidgets import Widget

msg = """
Unexpected keyword argument: '{provided_trait_name}'.
Check the spelling of your parameters. If you're trying to use layer properties added by
a layer extension, ensure you've passed the extension object into the `extensions`
parameter of the layer.
"""


class BaseWidget(Widget):
def __init__(self, **kwargs):
Expand All @@ -13,7 +20,7 @@ def __init__(self, **kwargs):
layer_trait_names = self.trait_names()
for provided_trait_name in kwargs.keys():
if provided_trait_name not in layer_trait_names:
raise TypeError(f"unexpected keyword argument '{provided_trait_name}'")
raise TypeError(msg.format(provided_trait_name=provided_trait_name))

super().__init__(**kwargs)

Expand All @@ -24,7 +31,7 @@ def __init__(self, **kwargs):
layer_trait_names = self.trait_names()
for provided_trait_name in kwargs.keys():
if provided_trait_name not in layer_trait_names:
raise TypeError(f"unexpected keyword argument '{provided_trait_name}'")
raise TypeError(msg.format(provided_trait_name=provided_trait_name))

super().__init__(**kwargs)

Expand Down
2 changes: 1 addition & 1 deletion lonboard/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MultiRangeSlider(VBox):
"""A widget for multiple ranged sliders.
This is designed to be used with the
[DataFilterExtension][lonboard.experimental.DataFilterExtension] when you want to
[DataFilterExtension][lonboard.layer_extension.DataFilterExtension] when you want to
filter on 2 to 4 columns on the same time.
If you have only a single filter, use an ipywidgets
Expand Down
5 changes: 0 additions & 5 deletions lonboard/experimental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@
"""

from ._layer import ArcLayer, TextLayer
from .layer_extension import (
BrushingExtension,
CollisionFilterExtension,
DataFilterExtension,
)
2 changes: 1 addition & 1 deletion lonboard/experimental/_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

from lonboard._constants import EXTENSION_NAME
from lonboard._layer import BaseArrowLayer
from lonboard.experimental.traits import PointAccessor
from lonboard.traits import (
ColorAccessor,
FloatAccessor,
PointAccessor,
PyarrowTableTrait,
TextAccessor,
)
Expand Down
Loading

0 comments on commit 696e2c7

Please sign in to comment.