Skip to content

Commit

Permalink
test: fix geospatial length test
Browse files Browse the repository at this point in the history
  • Loading branch information
ncclementi committed Nov 9, 2023
1 parent 596f3d9 commit 3155ed0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
18 changes: 14 additions & 4 deletions ibis/backends/duckdb/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,23 @@ def con(data_dir, tmp_path_factory, worker_id):

@pytest.fixture(scope="session")
def zones(con, data_dir):
# pending merge https://github.com/ibis-project/testing-data/pull/5
zones = con.read_geo(data_dir / "geojson" / "zones.geojson")
return zones


@pytest.fixture(scope="session")
def lines(con, data_dir):
lines = con.read_geo(data_dir / "geojson" / "lines.geojson")
return lines


@pytest.fixture(scope="session")
def zones_gdf(data_dir):
# pending merge https://github.com/ibis-project/testing-data/pull/5
gdf = gpd.read_file(data_dir / "geojson" / "zones.geojson")
return gdf
zones_gdf = gpd.read_file(data_dir / "geojson" / "zones.geojson")
return zones_gdf


@pytest.fixture(scope="session")
def lines_gdf(data_dir):
lines_gdf = gpd.read_file(data_dir / "geojson" / "lines.geojson")
return lines_gdf
14 changes: 6 additions & 8 deletions ibis/backends/duckdb/tests/test_geospatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,13 @@ def test_geospatial_is_valid(zones, zones_gdf):
tm.assert_series_equal(is_valid.to_pandas(), gp_is_valid, check_names=False)


# FIX ME: SEE https://postgis.net/docs/ST_Length.html
# ST_LENGTH returns 0 for the case of polygon or multi polygon while pandas geopandas returns the perimeter.
# https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoSeries.length.html
def test_geospatial_length(lines, lines_gdf):
# note: ST_LENGTH returns 0 for the case of polygon
# or multi polygon while pandas geopandas returns the perimeter.
length = lines.geom.length().name("length")
gp_length = lines_gdf.geometry.length

# def test_geospatial_length(zones, zones_gdf):
# length = zones.geom.length().name("length")
# gp_length = zones_gdf.geometry.length

# tm.assert_series_equal(length.to_pandas(), gp_length, check_names=False)
tm.assert_series_equal(length.to_pandas(), gp_length, check_names=False)


# not implemented in geopandas
Expand Down

0 comments on commit 3155ed0

Please sign in to comment.