pixelogik / NearPy

Python framework for fast (approximated) nearest neighbour search in large, high-dimensional data sets using different locality-sensitive hashes.
MIT License
759 stars 152 forks source link

Mismatch between docstring and functionality #62

Open braingineer opened 7 years ago

braingineer commented 7 years ago

There is at least one mismatch that I'm noticing right now. Specifically, the functionality specified in the docstring of Engine doesn't match what happens.

For example, in engine.py, you say:

There are four different modes of the engine:

. . .

2) No distance - The distance argument is None.
                In this case only the vector filters are applied to
                the bucket contents and the result is a list of
                filtered (vector, data) tuples.

But you're specifically replacing all incoming None arguments with default values:

def __init__(self, ...):
    #. . .
    if distance is None: distance = CosineDistance()
    self.distance = distance

Then, in Engine.neighbors, you check for self.distance being None and execute based on that:

def neighbors(self, v):
    #. . .
    # Apply distance implementation if specified
    if self.distance:
        candidates = self._append_distances(v, self.distance, candidates)
pixelogik commented 6 years ago

@braingineer Yeah that's weird. Will check where that line with CosineDistance() is coming from