|
7 | 7 | warnings.filterwarnings("ignore", category=DeprecationWarning)
|
8 | 8 | from geopandas import GeoDataFrame
|
9 | 9 |
|
| 10 | +import pandas as pd |
10 | 11 | from pandas.testing import assert_frame_equal
|
11 | 12 | from pytest import fixture, mark
|
12 | 13 | from shapely.geometry import Point, LineString, MultiPoint, MultiLineString
|
@@ -406,6 +407,24 @@ def test_passing_slice():
|
406 | 407 | assert_frame_equal(actual, expected)
|
407 | 408 |
|
408 | 409 |
|
| 410 | +def test_drop_duplicate_geometries(): |
| 411 | + a = Point((0, 0)) |
| 412 | + b = Point((0, 2)) |
| 413 | + c = Point((0, 1)) |
| 414 | + ac = LineString([a, c]) |
| 415 | + cb = LineString([c, b]) |
| 416 | + # use an index that doesn't start from 0 to check our indexing hygiene |
| 417 | + index = pd.Index([2, 3, 5, 7, 11, 13]) |
| 418 | + gdf_with_dupes = GeoDataFrame( |
| 419 | + index=index, |
| 420 | + data=[a, a, b, ac, ac, cb], |
| 421 | + columns=["geometry"] |
| 422 | + ) |
| 423 | + deduped = snkit.network.drop_duplicate_geometries(gdf_with_dupes) |
| 424 | + # we should have just the first of each duplicate item |
| 425 | + assert (deduped.index == pd.Index([2, 5, 7, 13])).all() |
| 426 | + |
| 427 | + |
409 | 428 | @mark.skipif(not USE_NX, reason="networkx not available")
|
410 | 429 | def test_to_networkx(connected):
|
411 | 430 | """Test conversion to networkx"""
|
|
0 commit comments