Skip to content

Commit 16bcc84

Browse files
committed
Make clearer error message for _nearest_neighbor with non-allowed units
1 parent a5d5c20 commit 16bcc84

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

climada/util/coordinates.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,8 +1317,10 @@ def _nearest_neighbor_approx(
13171317
# first check that unit is in degree
13181318
if unit != "degree":
13191319
raise ValueError(
1320-
"Only degree unit is supported for nearest neighbor approximation."
1321-
"Please use euclidean distance for non-degree units."
1320+
"Only degree unit is supported for nearest neighbor matching using"
1321+
"'approx' distance. Please use euclidean distance by setting "
1322+
"'distance=euclidean' in the match_coordinates or match_centroids "
1323+
"function when using units that are not degrees."
13221324
)
13231325
# Compute only for the unique coordinates. Copy the results for the
13241326
# not unique coordinates
@@ -1385,8 +1387,10 @@ def _nearest_neighbor_haversine(centroids, coordinates, unit, threshold):
13851387
# first check that unit is in degree
13861388
if unit != "degree":
13871389
raise ValueError(
1388-
"Only degree unit is supported for nearest neighbor approximation."
1389-
"Please use euclidean distance for non-degree units."
1390+
"Only degree unit is supported for nearest neighbor matching using"
1391+
"'haversine' distance. Please use euclidean distance by setting "
1392+
"'distance=euclidean' in the match_coordinates or match_centroids "
1393+
"function when using units that are not degrees."
13901394
)
13911395
# Construct tree from centroids
13921396
tree = BallTree(np.radians(centroids), metric="haversine")

0 commit comments

Comments
 (0)