pixelogik / NearPy

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

stored vector cannot be list #83

Open mkoralew opened 5 years ago

mkoralew commented 5 years ago

Hi, due to unitvec function there is no possibility to store 'list' vector - it has to be np.array /ndarray, otherwise None is returned.

Due to fact there is no imput check maybe it will be nice to edit unitvec function so it will change list object to np.array, e.g:

def unitvec(vec):
    """
    Scale a vector to unit length. The only exception is the zero vector, which
    is returned back unchanged.
    """
    if isinstance(vec, list):
        vec = numpy.array(vec)

    ....

BR, Marcin

pixelogik commented 5 years ago

@mkoralew I think the whole framework expects vectors to be of type np.array / ndarray?

I never tried it with list vectors. Are you saying that this is the only place where this conversion would be needed in order to make list vectors work?

If you want to use list vectors and they are not supported by the framework feel free to add the support including tests in a pull request.