Skip to content

Commit 59078e3

Browse files
committed
Try asserting that Bedrock GI tables are the same with pd.testing.assert_frame_equal
1 parent 55eb67f commit 59078e3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/test_examples/test_hk_kaitak_ags3_to_brgi_geodb.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from tempfile import TemporaryDirectory
77

88
import geopandas as gpd
9+
import pandas as pd
910

1011

1112
def test_kaitak_ags3_notebook_runs_and_creates_gpkg(examples_dir):
@@ -117,12 +118,17 @@ def test_kaitak_ags3_notebook_runs_and_creates_gpkg(examples_dir):
117118
gdf_original = gpd.read_file(
118119
temp_original_gpkg_path, layer=table["table_name"]
119120
)
120-
gdf_diff = gdf_original.compare(gdf_output)
121-
assert gdf_diff.empty, (
122-
f"The original GeoPackage {temp_original_gpkg_path.name} and the output "
123-
f"GeoPackage {gpkg_output_path.name} have a different {table['table_name']} table.\n"
124-
f"{gdf_diff}"
121+
pd.testing.assert_frame_equal(
122+
gdf_original, gdf_output, check_exact=False, rtol=1e-5
125123
)
124+
# It's also possible to assert that GIS geometries are not exactly equal.
125+
# However, when testing the equality of GeoDataFrames with pandas, the GIS
126+
# geometry are compared precisely, because the geometry is converted to a
127+
# WKT string and compared as strings. Therefore, if a less precise comparison
128+
# of GIS geometries is necessary, the assertion above needs changing too.
129+
# gpd.testing.assert_geoseries_equal(
130+
# gdf_original, gdf_output, check_less_precise=False
131+
# )
126132

127133
# Remove the newly generated kaitak_gi.gpkg
128134
os.remove(gpkg_output_path)

0 commit comments

Comments
 (0)