Fixed bug in distances.py when calculating pairs from arbitrary indices lists