iit-cs579 / main

CS579: Online Social Network Analysis at the Illinois Institute of Technology
147 stars 204 forks source link

data types in csr matrix #493

Closed annonch closed 5 years ago

annonch commented 5 years ago

Curiously using example code from the link in A2

The expected behavior differs from observed. Using int64 does not print the dtype information however int8 does.

Am I missing something?

>>> from scipy.sparse import *
>>> from scipy import *
>>> csr_matrix((3,4),dtype='int64').toarray()
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])                                                            # Error
>>> csr_matrix((3,4),dtype='int8').toarray()
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]], dtype=int8)                                             # no error
>>> import numpy as np
>>> csr_matrix((3,4),dtype=np.int64).toarray()
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])
aronwc commented 5 years ago

I wouldn't worry about the dtypes for this assignment. -Aron

On Wed, Oct 9, 2019 at 4:44 PM annonch notifications@github.com wrote:

Curiously using example code from the link in A2

The expected behavior differs from observed. Using int64 does not print the dtype information however int8 does.

Am I missing something?

from scipy.sparse import from scipy import csr_matrix((3,4),dtype='int64').toarray() array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) # Error csr_matrix((3,4),dtype='int8').toarray() array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], dtype=int8) # no error import numpy as np csr_matrix((3,4),dtype=np.int64).toarray() array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/iit-cs579/main/issues/493?email_source=notifications&email_token=AA575BPQS6K2QVHW7AOBS53QNZGCTA5CNFSM4I7FFJR2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HQYLEJQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA575BNTS3WSXXMWYHO7RKDQNZGCTANCNFSM4I7FFJRQ .

annonch commented 5 years ago

Okay, just that my test for 'vectorize' will fail... My guess is platform dependency or version number.. Anyone else see this for osx? I use ports to install everything and pip for python packages.