[SciPy-user] TypeError: an integer is required

Antoine Cailliau antoinecailliau@gmail....
Sun Apr 15 13:10:24 CDT 2007


Hi,

For a university project, I need to compute some big matrix (rouglhy
2000*85000). But when I try to create my matrix I've a error I don't
understand.

Here is the code fragment
> movies_seen_by_user = sparse.csc_matrix((max_movie_id+1,
> cursor.rowcount),cursor.rowcount,None)

cursor.rowcount = 2000 and is an integer.

And here's is the error : 
>   File "/var/www/project/project/algorithm.py", line 103, in suggest_films
>     movies_seen_by_user = sparse.csc_matrix((max_movie_id+1, cursor.rowcount),cursor.rowcount,None)
>   File "/usr/lib/python2.4/site-packages/scipy/sparse/sparse.py", line 530, in __init__
>     self.data = zeros((nzmax,), self.dtype)
> TypeError: an integer is required

The problem is time that the loop take. With a sparse.zero it's quicker
than with a sparse matrix (csc) but I've a lot of zero in my matrix and
I want to have a sparse matrix for the operations I made after.

I tried 
> movies_seen_by_user = sparse.csc_matrix((max_movie_id+1, cursor.rowcount))
> movies_seen_by_user.nzmax = cursor.rowcount
> movies_seen_by_user.allocsize = cursor.rowcount + 1
But my script still very very very slow.

Thanks to everyone,

Antoine C.

-- 
Antoine Cailliau
Rue de l'Angélique, 2
1348 Louvain-La-Neuve
Mobile : 00 32 496 67 82 52
a.cailliau@ac-graphic.net
http://www.ac-graphic.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20070415/7e8f8b70/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3869 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20070415/7e8f8b70/attachment-0001.bin 


More information about the SciPy-user mailing list