unravel_index for pdist?
Hello, I typically use pdist() from scipy.spatial.distance to keep some of my scripts lean wrt memory usage. However, determining which pairs of points a distance value refers to is a bit tricky. I was wondering if a "punravel_index()" function might be welcomed? Here is my algorithm I came up with to perform this action for a single result. I haven't tested it for anything more general than that. *pntCnt* is the number of points that pdist() was used for. *index* is an index from a function like "np.argmax(pdist(p))". rowcnts = np.cumsum(xrange(pntCnt - 1, 0, -1)) row = np.searchsorted(rowcnts, index) col = pntCnt - (rowcnts[row] - index) At the very least, I hope that this is helpful to anybody else using pdist. Ben Root
participants (1)
-
Benjamin Root