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

AttributeError: 'matrix' object has no attribute 'toarray' #8

Closed
bhoomit opened this issue Oct 12, 2016 · 4 comments
Closed

AttributeError: 'matrix' object has no attribute 'toarray' #8

bhoomit opened this issue Oct 12, 2016 · 4 comments

Comments

@bhoomit
Copy link

bhoomit commented Oct 12, 2016

Traceback (most recent call last):
  File "/Users/Bhoomit/work/robin/pysparnn/tests/test_pysparnn.py", line 52, in test_veccosine
    return_distance=False)
  File "pysparnn/cluster_pruning.py", line 274, in search
    k_clusters=k_clusters))
  File "pysparnn/cluster_pruning.py", line 208, in _search
    max_distance=max_distance)
  File "pysparnn/matrix_distance.py", line 81, in nearest_search
    dist_matrix = self._distance(sparse_features)
  File "pysparnn/matrix_distance.py", line 182, in _distance
    return 1 - dprod.multiply(magnitude).toarray()
AttributeError: 'matrix' object has no attribute 'toarray'

I had to use
return 1 - np.asarray(dprod.multiply(magnitude))

Am I doing something wrong? I'm using python 2.7 and virtualenv.

@spencebeecher
Copy link
Contributor

Thanks for the feedback! For my own sanity, did you install with requirements.txt?

cd pysparnn
pip install -r requirements.txt
python setup.py install

I have noticed that the sparse matrix methods change a bit from version to version. If you have a patch that works on the latest versions of scipy/numpy I'd be happy to update the code!

@bhoomit
Copy link
Author

bhoomit commented Oct 13, 2016

I used requirements.txt. Will try once again. If it still doesn't work will send a PR.

@bhoomit
Copy link
Author

bhoomit commented Oct 13, 2016

@spencebeecher so I tried again and it worked, so may be I installed one of the modules without requirements.txt. Sorry my bad. I can still send PR with latest version of scipy/numpy.

@spencebeecher
Copy link
Contributor

Would love that!

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

No branches or pull requests

2 participants