@@ -138,7 +138,8 @@ def get_crs_unit(coords):
138138 unit = "km"
139139 else :
140140 raise ValueError (
141- f"Unknown unit: { unit } . Please provide a crs that has a unit of 'degree', 'metre' or 'kilometre'."
141+ f"Unknown unit: { unit } . Please provide a crs that has a unit "
142+ "of 'degree', 'metre' or 'kilometre'."
142143 )
143144 return unit
144145
@@ -1288,13 +1289,14 @@ def match_centroids(
12881289 raise ValueError ("Set hazard and GeoDataFrame to same CRS first!" )
12891290 if coord_gdf .crs is None or centroids .crs is None :
12901291 raise ValueError (
1291- "Please provide coordinate GeoDataFrame and Hazard object with a valid crs attribute."
1292+ "Please provide coordinate GeoDataFrame and Hazard "
1293+ "object with a valid crs attribute."
12921294 )
1293- except AttributeError :
1295+ except AttributeError as exc :
12941296 # a crs attribute is needed for unit inference
12951297 raise ValueError (
12961298 "Please provide coordinate GeoDataFrame and Hazard object with a valid crs attribute."
1297- )
1299+ ) from exc
12981300
12991301 # get unit of coordinate systems from axis of crs
13001302 unit = get_crs_unit (coord_gdf )
@@ -1447,7 +1449,8 @@ def _nearest_neighbor_haversine(centroids, coordinates, unit, threshold):
14471449 num_warn = np .sum (dist > threshold )
14481450 if num_warn :
14491451 LOGGER .warning (
1450- f"Distance to closest centroid is greater than { threshold } km for { num_warn } coordinates."
1452+ f"Distance to closest centroid is greater than { threshold } "
1453+ "km for {num_warn} coordinates."
14511454 )
14521455 assigned [dist > threshold ] = - 1
14531456
@@ -1512,7 +1515,9 @@ def _nearest_neighbor_euclidean(
15121515 num_warn = np .sum (dist > threshold )
15131516 if num_warn :
15141517 LOGGER .warning (
1515- f"Distance to closest centroid is greater than { threshold } km for { num_warn } coordinates."
1518+ "Distance to closest centroid is greater than %i " "km for %i coordinates." ,
1519+ threshold ,
1520+ num_warn ,
15161521 )
15171522 assigned [dist > threshold ] = - 1
15181523
0 commit comments