Skip to content

Commit 2cb9e37

Browse files
committed
Replaced sqrt(x**2+y**2) with hypot in Mapping/kmeans_clustering/kmeans_clustering.py
1 parent 72a28b4 commit 2cb9e37

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Mapping/kmeans_clustering/kmeans_clustering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def update_clusters(self):
6868
dx = [icx - px for icx in self.center_x]
6969
dy = [icy - py for icy in self.center_y]
7070

71-
dist_list = [math.sqrt(idx ** 2 + idy ** 2) for (idx, idy) in zip(dx, dy)]
71+
dist_list = [math.hypot(idx, idy) for (idx, idy) in zip(dx, dy)]
7272
min_dist = min(dist_list)
7373
min_id = dist_list.index(min_dist)
7474
self.labels[ip] = min_id

0 commit comments

Comments
 (0)