Open MaxGhenis opened 5 years ago
np.argpartition
can do this: https://stackoverflow.com/a/34226816/1840471
Largely added but the distances aren't coming out in the right order:
print(nearest[nearest.dist1 > nearest.dist3].shape[0]) # 129
print(nearest[nearest.dist1 < nearest.dist3].shape[0]) # 756
One of these should be zero.
From numpy.argpartition
documentation:
Element index to partition by. The k-th element will be in its final sorted position and all smaller elements will be moved before it and all larger elements behind it. The order all elements in the partitions is undefined. If provided with a sequence of k-th it will partition all of them into their sorted position at once.
So it needs to be re-sorted either within nearest_record_single
or at the end (probably faster).
Rather than only the current minimum.
From https://www.irs.gov/pub/irs-soi/07rppsweber.pdf see