-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_rm_z_coords.py - Added - use pytest to test rm_z_coords.py
- Loading branch information
Showing
4 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python | ||
""" Unit tests for the rm_z_coord function. """ | ||
import geopandas as gpd | ||
from shapely.geometry import Polygon | ||
from rm_z_coord import rm_z_coord | ||
|
||
|
||
def test_rm_z_coord(): | ||
# Create a GeoDataFrame for testing | ||
data = {'geometry': [Polygon([(0, 0, 1), (1, 0, 2), | ||
(1, 1, 3), (0, 1, 4)])]} | ||
gdf = gpd.GeoDataFrame(data, crs='EPSG:4326') | ||
|
||
# Apply the function | ||
result_gdf = rm_z_coord(gdf.copy()) | ||
|
||
# Check if the z-coordinate is removed from the geometry | ||
assert all(result_gdf['geometry'].apply(lambda geom: | ||
len(geom.exterior.coords[0]) == 2)) |