Skip to content

Commit 43a744f

Browse files
add comment about filtering geometry columns
1 parent a1f0fcb commit 43a744f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

climada/hazard/centroids/centr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,10 @@ def write_hdf5(self, file_name, mode="w"):
915915
store = pd.HDFStore(file_name, mode=mode, complevel=9)
916916
try:
917917
pandas_df = pd.DataFrame(self.gdf)
918+
# we replace all columns of type geometry
919+
# - with according x and y columns if they are strictly `Point`s
920+
# - with wkb values if they have other shapes
921+
# this saves a lot of time and disk space
918922
for col in pandas_df.columns:
919923
if str(pandas_df[col].dtype) == "geometry":
920924
if (self.gdf[col].geom_type == "Point").all():

climada/hazard/centroids/test/test_centr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ def test_read_write_hdf5_with_additional_columns(self):
767767
)
768768
centroids_w.write_hdf5(tmpfile)
769769
centroids_r = Centroids.from_hdf5(tmpfile)
770-
self.assertTrue(centroids_w == centroids_r)
770+
self.assertEqual(centroids_w, centroids_r)
771771
tmpfile.unlink()
772772

773773
def test_from_hdf5_nonexistent_file(self):

0 commit comments

Comments
 (0)