Open Nahor opened 5 months ago
Whoops! Thanks for spotting this. Will fix in an upcoming release as soon as I can.
Do you have any information on the release date for the next version?
I encountered the same bug in my project and was wondering when the fix from #175 will be available.
@ezrasingh , you can always use the git repo instead of a released crate:
kiddo = { git = "https://github.com/sdd/kiddo.git", rev = "cc62c6d76accdeba75c0f55db80c28eab8a21ae7" }
Hey @Nahor,
I pinned Kiddo to that revision in my crate, but my unit tests are still failing. Initially, I thought it might be due to stale code on my machine. However, the tests also failed in CI.
Could this possibly be a regression?
I just submitted a PR (#180) to validate the consistency of the behavior when max_qty
= 0. During testing, I found that the function handles this case differently depending on whether the results are sorted or not. Specifically, the issue arises when sorted
= false, where the function does not return an empty vec as expected, unlike when sorted
= true.
This difference explains why pinning Kiddo did not work for my case. While I can work around this with a conditional branch, I don't believe this inconsistent behavior is intended. If it works with sorted results, it should also work with unsorted results, ensuring consistent handling of max_qty
= 0.
Hey all - just released v4.2.1: https://crates.io/crates/kiddo/4.2.1
Hi @sdd, so far v4.2.1 has been great however I notice this release still fails one of the edge case I added in PR #180:
Calling nearest_n_within
when max_qty
= 0:
sorted
= false
will panicsorted
= true
returns an empty Vec
as expectedAah hey Ezra, I'll take a look over this weekend and see if I can get a fix out.
In kiddo
v4.2.0
,nearest_n_within
will only limit the number of items if sorting is enabled. If it's disabled, all the items within the radius are returned.E.g. in the
cities
example, replacenearest_n
withnearest_n_within
and a radius of 10km.This outputs 13 cities (for my data set) instead of the expected 5. If the list is sorted, then it works as expected.
Also note that the example in the documentation for
nearest_n_within
creates a tree of 2 items, asks for 2 items, and then is happy because it got 2 items in return!