Skip to content

Commit 8688d4d

Browse files
authored
Add test for duckdb table with no property columns (#623)
Closes #622
1 parent 63d8764 commit 8688d4d

File tree

5 files changed

+70
-55
lines changed

5 files changed

+70
-55
lines changed

lonboard/_layer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ class HeatmapLayer(BaseArrowLayer):
19711971
def __init__(
19721972
self, *, table: ArrowStreamExportable, **kwargs: Unpack[HeatmapLayerKwargs]
19731973
):
1974-
err_msg = """\
1974+
err_msg = """
19751975
The `HeatmapLayer` is not currently working.
19761976
19771977
As of Lonboard v0.10, Lonboard upgraded to version 9.0 of the underlying

lonboard/_viz.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,13 @@ def viz(
192192
widget visualizing the provided data.
193193
"""
194194
global COLOR_COUNTER
195-
color_ordering = COLORS.copy()
196195

197196
if isinstance(data, (list, tuple)):
198197
layers: List[Union[ScatterplotLayer, PathLayer, PolygonLayer]] = []
199198
for i, item in enumerate(data):
200199
ls = create_layers_from_data_input(
201200
item,
202-
_viz_color=color_ordering[(COLOR_COUNTER + i) % len(color_ordering)],
201+
_viz_color=COLORS[(COLOR_COUNTER + i) % len(COLORS)],
203202
scatterplot_kwargs=scatterplot_kwargs,
204203
path_kwargs=path_kwargs,
205204
polygon_kwargs=polygon_kwargs,
@@ -211,7 +210,7 @@ def viz(
211210
else:
212211
layers = create_layers_from_data_input(
213212
data,
214-
_viz_color=color_ordering[COLOR_COUNTER % len(color_ordering)],
213+
_viz_color=COLORS[COLOR_COUNTER % len(COLORS)],
215214
scatterplot_kwargs=scatterplot_kwargs,
216215
path_kwargs=path_kwargs,
217216
polygon_kwargs=polygon_kwargs,

poetry.lock

Lines changed: 49 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cli = ["click", "pyogrio", "shapely"]
5454
geopandas = ["geopandas", "pandas", "shapely"]
5555

5656
[tool.poetry.group.dev.dependencies]
57-
duckdb = "^0.10.2"
57+
duckdb = ">=0.10.2"
5858
geoarrow-pyarrow = "^0.1.1"
5959
geoarrow-rust-core = "^0.2.0"
6060
geodatasets = "^2023.12.0"

tests/test_duckdb.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,20 @@ def test_create_table_as_custom_con():
205205
# Succeeds when passing in con object
206206
m = viz(con.table("test"), con=con)
207207
assert isinstance(m.layers[0], ScatterplotLayer)
208+
209+
210+
def test_geometry_only_column():
211+
# https://github.com/developmentseed/lonboard/issues/622
212+
con = duckdb.connect()
213+
sql = f"""
214+
INSTALL spatial;
215+
LOAD spatial;
216+
CREATE TABLE data AS
217+
SELECT CAST(geom as POINT_2D) as geom FROM ST_Read("{cities_gdal_path}");
218+
"""
219+
con.execute(sql)
220+
221+
_layer = ScatterplotLayer.from_duckdb(con.table("data"), con)
222+
223+
m = viz(con.table("data"), con=con)
224+
assert isinstance(m.layers[0], ScatterplotLayer)

0 commit comments

Comments
 (0)