Skip to content

Commit

Permalink
Add test for duckdb table with no property columns (#623)
Browse files Browse the repository at this point in the history
Closes #622
  • Loading branch information
kylebarron authored Sep 3, 2024
1 parent 63d8764 commit 8688d4d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 55 deletions.
2 changes: 1 addition & 1 deletion lonboard/_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ class HeatmapLayer(BaseArrowLayer):
def __init__(
self, *, table: ArrowStreamExportable, **kwargs: Unpack[HeatmapLayerKwargs]
):
err_msg = """\
err_msg = """
The `HeatmapLayer` is not currently working.
As of Lonboard v0.10, Lonboard upgraded to version 9.0 of the underlying
Expand Down
5 changes: 2 additions & 3 deletions lonboard/_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,13 @@ def viz(
widget visualizing the provided data.
"""
global COLOR_COUNTER
color_ordering = COLORS.copy()

if isinstance(data, (list, tuple)):
layers: List[Union[ScatterplotLayer, PathLayer, PolygonLayer]] = []
for i, item in enumerate(data):
ls = create_layers_from_data_input(
item,
_viz_color=color_ordering[(COLOR_COUNTER + i) % len(color_ordering)],
_viz_color=COLORS[(COLOR_COUNTER + i) % len(COLORS)],
scatterplot_kwargs=scatterplot_kwargs,
path_kwargs=path_kwargs,
polygon_kwargs=polygon_kwargs,
Expand All @@ -211,7 +210,7 @@ def viz(
else:
layers = create_layers_from_data_input(
data,
_viz_color=color_ordering[COLOR_COUNTER % len(color_ordering)],
_viz_color=COLORS[COLOR_COUNTER % len(COLORS)],
scatterplot_kwargs=scatterplot_kwargs,
path_kwargs=path_kwargs,
polygon_kwargs=polygon_kwargs,
Expand Down
99 changes: 49 additions & 50 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cli = ["click", "pyogrio", "shapely"]
geopandas = ["geopandas", "pandas", "shapely"]

[tool.poetry.group.dev.dependencies]
duckdb = "^0.10.2"
duckdb = ">=0.10.2"
geoarrow-pyarrow = "^0.1.1"
geoarrow-rust-core = "^0.2.0"
geodatasets = "^2023.12.0"
Expand Down
17 changes: 17 additions & 0 deletions tests/test_duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,20 @@ def test_create_table_as_custom_con():
# Succeeds when passing in con object
m = viz(con.table("test"), con=con)
assert isinstance(m.layers[0], ScatterplotLayer)


def test_geometry_only_column():
# https://github.com/developmentseed/lonboard/issues/622
con = duckdb.connect()
sql = f"""
INSTALL spatial;
LOAD spatial;
CREATE TABLE data AS
SELECT CAST(geom as POINT_2D) as geom FROM ST_Read("{cities_gdal_path}");
"""
con.execute(sql)

_layer = ScatterplotLayer.from_duckdb(con.table("data"), con)

m = viz(con.table("data"), con=con)
assert isinstance(m.layers[0], ScatterplotLayer)

0 comments on commit 8688d4d

Please sign in to comment.