In calculate_distance_matrix we can either compare an X to itself or to another Y.
The code does some optimization for X in assuming that the computation is symmetric and only doing half of the pairs (e.g. (x[0], x[1]) has the same result as (x[1], x[0])).
But the same thing is done if a Y is provided, here (x[0], y[1]) can be different to (x[1], y[0]). This code triggers the bug:
import geopandas as gpd
import trackintel as ti
from shapely.geometry import Point
a = [(0, Point(0, 0)), (1, Point(1, 1))]
b = [(0, Point(10, 10)), (1, Point(20, 20))]
a = gpd.GeoDataFrame(a, columns=["id", "g"], geometry="g")
b = gpd.GeoDataFrame(b, columns=["id", "g"], geometry="g")
res = ti.geogr.calculate_distance_matrix(a, b)
assert res[0,0] != 0
Further the whole implementation is full of bugs and smaller issues, things I found at a quick glance:
Further the test suite for this function is not useful. All except one test only compare the output of the function to different output of the function or to nothing at all. The one exception does not provide a Y.
In
calculate_distance_matrix
we can either compare anX
to itself or to anotherY
. The code does some optimization forX
in assuming that the computation is symmetric and only doing half of the pairs (e.g.(x[0], x[1])
has the same result as(x[1], x[0])
). But the same thing is done if aY
is provided, here(x[0], y[1])
can be different to(x[1], y[0])
. This code triggers the bug:Further the whole implementation is full of bugs and smaller issues, things I found at a quick glance:
n_job
default value is non-valid value 0Y
to not None herekwds
Further the test suite for this function is not useful. All except one test only compare the output of the function to different output of the function or to nothing at all. The one exception does not provide a
Y
.