carsonfarmer / fastpair

FastPair: Data-structure for the dynamic closest-pair problem.
MIT License
12 stars 4 forks source link

strange test pass & fail for `test_update_point_less_points()` #60

Open jGaboardi opened 3 months ago

jGaboardi commented 3 months ago

Within test_update_point_less_points(), I am not sure this final assert is testing what it's supposed to and I am concerned about it currently passing.

From what I understand, the final assert statement should be testing number of point currently in fp, and that should not be 1 because we are only adding points to fp and then updating a single point, never removing any points, where:

So I think the final line here should pass with assert len(fp) == 9, but it somehow passes with assert len(fp) == 1 in the ✅ above...


def test_update_point_less_points(self, point_set):
    ps = point_set
    fp = FastPair()
    for p in ps[:9]:
        fp += p
    assert fp.initialized is False
    old = ps[0]  # Just grab the first point...
    new = rand_tuple(len(ps[0]))
    fp._update_point(old, new)
    assert len(fp) == 1

cc @gegen07

Edit 1

I have seen failure in local serial testing, but it is not consistent.

FAILED fastpair/tests/test_fastpair.py::TestFastPairUpdatePointLessPoints::test_basic - assert 9 == 1