Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

TypeError: unhashable type: 'numpy.ndarray' #18

Open
moinnadeem opened this issue Jul 1, 2018 · 1 comment
Open

TypeError: unhashable type: 'numpy.ndarray' #18

moinnadeem opened this issue Jul 1, 2018 · 1 comment

Comments

@moinnadeem
Copy link

Hi!

I setup the index with the following parameters:

cp = ci.MultiClusterIndex(X, df)
cp.search(X, k=100)

X is a sparse array of dimension (128405, 75897).

Here's a copy of the traceback. Any advice? Thanks!

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-18-58e590b5ec59> in <module>()
----> 1 cp.search(X, k=100)

/home/moinnadeem/.virtualenvs/quizlet/lib/python2.7/site-packages/pysparnn/cluster_index.pyc in search(self, features, k, k_clusters, return_distance, num_indexes)
    474             ret.append(
    475                 _filter_distance(
--> 476                     _k_best(_filter_unique(r), k),
    477                     return_distance
    478                 )

/home/moinnadeem/.virtualenvs/quizlet/lib/python2.7/site-packages/pysparnn/cluster_index.pyc in _filter_unique(tuple_list)
     40     ret = []
     41     for distance, value in tuple_list:
---> 42         if not value in added:
     43             ret.append((distance, value))
     44             added.add(value)

TypeError: unhashable type: 'numpy.ndarray'
@spencebeecher
Copy link
Contributor

Thanks for the question! What is the type of X? The second argument works best when the type is a list - instead of passing 'df' i would pass the index of df 'df.Index.values'. If this doesn't work - could you share a simple version of your code with me? Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants