sadit / SimilaritySearch.jl

A nearest neighbor search library with exact and approximate algorithms
https://sadit.github.io/SimilaritySearch.jl/
MIT License
42 stars 7 forks source link

Reassigning `minbatch` does not deactivate Polyester #32

Open nlw0 opened 1 year ago

nlw0 commented 1 year ago

I'm trying to avoid Polyester. I set minbatch=-1, and at first it looked like I got what I wanted. But actually Polyester is still being used, only with a single thread. It appears the logic is broken in this code snippet

https://github.com/sadit/SimilaritySearch.jl/blob/61485978cbcaaa645dc7940bfe2bc0be060bae0f/src/SimilaritySearch.jl#L167-L170

By contradicting the principles of functional programming and mutating the variable minbatch, the value provided by the user is forced into something else. The positive branch of the if can never be reached.

Furthermore, if the query array happens to be empty, this now results not in an empty output, as I suspect would be the case if the non-parallel code was running. What we get instead is a division-by-zero error thrown by Polyester.