[SciPy-User] "Zero"-shape sparse matrices
Christopher Mutel
cmutel@gmail....
Fri Feb 17 10:48:58 CST 2012
On Fri, Feb 17, 2012 at 4:32 PM, eat <e.antero.tammi@gmail.com> wrote:
> On Thu, Feb 16, 2012 at 5:44 PM, Jaakko Luttinen <jaakko.luttinen@aalto.fi>
> wrote:
>> To make a long story short, Scipy doesn't seem to allow sparse matrices
>> that have length zero on any of the axes. For instance:
>> C = numpy.ones((0,0))
>> K = scipy.sparse.csc_matrix(C)
>> ValueError: invalid shape
>>
>> It is possible to create a "zero"-shape dense matrix but not sparse.
>> Why? To me, this seems like a bug.. Is it so?
I am not an expert, but it is my understanding that the sparse matrix
implementations in SciPy assume precisely two dimensions. One
dimension having a size of 0 would break all the assumptions of this
code. The NumPy array class is a much more generic container, and was
designed from the beginning to allow a number of slicing and
dimensionality tricks (see the documentation on numpy striding). You
can search through the mailing list from a few years ago to find a
discussion about three dimensional sparse matrices, and the conclusion
was the same: SciPy supports 2-d (in the sense of two real dimensions)
sparse matrices only.
-Chris
More information about the SciPy-User
mailing list