Skip to content

Instantly share code, notes, and snippets.

@myui
Last active December 17, 2015 13:21
Show Gist options
  • Save myui/a6b305e0228b8da87963 to your computer and use it in GitHub Desktop.
Save myui/a6b305e0228b8da87963 to your computer and use it in GitHub Desktop.
>>> d.toarray()
array([[2, 1, 0, 0],
[0, 1, 1, 1]])
>>> c.toarray()
array([[2, 1, 0, 0],
[0, 1, 1, 1]])
>>> d
<2x4 sparse matrix of type '<type 'numpy.int64'>'
with 5 stored elements in Compressed Sparse Row format>
>>> c
<2x4 sparse matrix of type '<type 'numpy.int64'>'
with 6 stored elements in Compressed Sparse Row format>
>>> d.data
array([2, 1, 1, 1, 1])
>>> d.indices
array([0, 1, 1, 2, 3])
>>> d.indptr
array([0, 2, 5])
>>> c.data
array([1, 1, 1, 1, 1, 1]) !!!!!!
>>> c.indices
array([0, 1, 0, 2, 3, 1], dtype=int32)
>>> c.indptr
array([0, 3, 6], dtype=int32)
>>> c.data = np.array([2, 1, 1, 1, 1, 1])
>>> c.toarray()
array([[3, 1, 0, 0],
[0, 1, 1, 1]])
>>> c.data=np.array([2,1,2,1,1,-1])
>>> c.toarray()
array([[4, 1, 0, 0],
[0, -1, 1, 1]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment