[Numpy-discussion] sparse array data
Francesc Alted
francesc at continuum.io
Wed May 2 18:20:23 EDT 2012
On 5/2/12 4:07 PM, Stéfan van der Walt wrote:
> Hi Francesc
>
> On Wed, May 2, 2012 at 1:53 PM, Francesc Alted<francesc at continuum.io> wrote:
>> and add another one for the actual values of the array. For a 3-D
>> sparse array, this looks like:
>>
>> dim0 | dim1 | dim2 | value
>> ==========================
>> 0 | 0 | 0 | val0
>> 0 | 10 | 100 | val1
>> 20 | 5 | 202 | val2
> What's the distinction between this and a coo_matrix?
Well, as the OP said, coo_matrix does not support dimensions larger than
2, right?
In [4]: coo_matrix((3,4), dtype=np.int8).todense()
Out[4]:
matrix([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]], dtype=int8)
In [5]: coo_matrix((2,3,2), dtype=np.int8).todense()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Users/faltet/<ipython-input-5-46b8ae62259f> in <module>()
----> 1 coo_matrix((2,3,2), dtype=np.int8).todense()
/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/scipy/sparse/coo.py
in __init__(self, arg1, shape, dtype, copy)
127 obj, ij = arg1
128 except:
--> 129 raise TypeError('invalid input format')
130
131 try:
TypeError: invalid input format
--
Francesc Alted
More information about the NumPy-Discussion
mailing list