carsonfarmer / fastpair

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

Fixed error when n of points is less than self.min_points #17

Closed Rakesh4G closed 3 years ago

Rakesh4G commented 3 years ago

Fixed error when n of points is less than self.min_points

Fixes: https://github.com/carsonfarmer/fastpair/issues/15

The problem was seen when using custom distance function, and fp was not initialized as the total number of points were less than self.min_points.

when doing brute_force it is ignoring dist function that is used to initialize FastPair.

@CMCDragonkai @vriez

Rakesh4G commented 3 years ago

There is only one change in base.py

https://github.com/carsonfarmer/fastpair/pull/17/files#diff-29376cffcc320517bbc4980bbd07118af6b3bf06b74012bb0ba0709e26115869R192

Rest changes are formatting changes as per black.

I have also added pytest to capture this bug.

Rakesh4G commented 3 years ago

Also added a couple more test cases to complete code coverage:

https://travis-ci.org/github/carsonfarmer/fastpair/jobs/771542325

---------- coverage: platform linux, python 3.5.10-final-0 -----------
Name                             Stmts   Miss  Cover   Missing
--------------------------------------------------------------
fastpair/__init__.py                 2      0   100%
fastpair/base.py                   123      0   100%
fastpair/test/test_fastpair.py     205      0   100%
--------------------------------------------------------------
TOTAL                              330      0   100%
======================= 15 passed, 294 warnings in 1.37s =======================
carsonfarmer commented 3 years ago

Thanks for the contribution @Rakesh4G. Are you interested in having this package deployed to pypi? I can probably prioritize that later this week?

Rakesh4G commented 3 years ago

Thanks for the contribution @Rakesh4G. Are you interested in having this package deployed to pypi? I can probably prioritize that later this week?

Thanks @carsonfarmer , package deployed to pypi would be really great.