Skip to content

Commit

Permalink
Fix a TypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
mherrmann committed Jul 11, 2024
1 parent 849f99a commit 31aa128
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion helium/_impl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,10 @@ def _find_closest(self, to_pivot, among_elts):
else:
distances.append((distance, elt))
if distances:
return sorted(distances)[0][1]
# Provide `key=` to prevent a TypeError that happens when Python
# attempts to sort on the second items of the tuples when the first
# items are equal.
return sorted(distances, key=lambda tpl: tpl[0])[0][1]
def _compute_distance(self, elt_1, elt_2):
loc_1 = elt_1.location
loc_2 = elt_2.location
Expand Down

0 comments on commit 31aa128

Please sign in to comment.