Open ssolson opened 10 months ago
I think this would be the correct implementation:
def centroid_diffs(Centroids, centroid):
# Calculate Euclidean distances
distances = np.sqrt(np.sum((Centroids[:, 1:] - centroid[1:])**2, axis=1))
# Find the index of the centroid with the minimum distance
min_arg = np.argmin(distances)
# Return the pair: index of the single centroid and the index of the closest centroid
pair = [int(centroid[0]), int(Centroids[min_arg, 0])]
return pair
While the current method works for the tutorial dataset (see image), it is not robust for different configurations. The suggested method is more robust and fixes this issue.
@tnelson-integral I believe there is a bug in
centroid_diffs
calculation.https://github.com/sandialabs/seat-qgis-plugin/blob/d04f83e5584b713f5e9ba728759a9a1dd54461b0/seat/power_module.py#L125-L147
I created the following test using the euclidean distance to calculate the distance
The expect pair differs:
AssertionError: Lists differ: [3, 0] != [3, 1]
Am I missing something about the data and the way it should be handled?