from scipy.spatial import distance_matrix def calculate_distances(positions): return distance_matrix(positions, positions)