-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
On this line, a data point is assigned to the centroids array by reference:
Line 60 in 17aaa1b
| ks[z++] = data[idx]; |
This means that as the centroids change later in the algorithm, the underlying data array is also changed. This is undesirable for two reasons: mutating the data array which is passed in could have downstream effects, and even if the data array isn't used subsequently, it makes the algorithm incorrect.
Assuming I'm not missing something here (very possible, as I am not a JS developer), data[idx].slice() would be the fix I would suggest.
Metadata
Metadata
Assignees
Labels
No labels