spiketools.spatial.distance.compute_distance

spiketools.spatial.distance.compute_distance(p1, p2)[source]

Compute the distance between two positions.

Parameters:
p1, p2list of float

The position values of the two positions to calculate distance between. Can be 1d (a single value per position) or 2d (x and y values per position).

Returns:
float

Distance between the two positions.

Examples

Compute distance between two 1d positions:

>>> p1, p2 = [2], [5]
>>> compute_distance(p1, p2)
3.0

Compute distance between the two 2d positions:

>>> p1 = [1, 6]
>>> p2 = [5, 9]
>>> compute_distance(p1, p2)
5.0