[SciPy-user] sparse+slice? (and hello!)
Ed Schofield
schofield at ftw.at
Wed May 17 04:29:22 EDT 2006
On 17/05/2006, at 9:19 AM, Bram de Jong - MTG wrote:
> Hello everyone,
>
> ( First post on this list... Using SciPy in various algorithms and
> extensions, all related to audio processing )
>
> * A simple question to start of with, is it correct to say that the
> sparse matrices do not support slicing?
>
>> values = [0.1, 5.8, 21.8]
>> indices = [[0,0],[1,1],[2,1]]
>> matrix = sparse.coo_matrix(values, indices, 3, 3)
>> matrix = matrix.tocsc()
>> matrix2[1,1]
> 5.7999999999999998
>> matrix2[1,:]
> Traceback (most recent call last):
> File "<input>", line 1, in ?
> File "C:\PYTHON23\lib\site-packages\scipy\sparse\Sparse.py", line
> 578, in __getitem__
> raise KeyError, "Index out of bounds."
> KeyError: 'Index out of bounds.'
>
> This using the scipy from the latest 'enthought' python installer for
> windows.
I've added some support for slicing in more recent SVN versions.
It's now possible to use csc[:, j], csr[i, :], or lil[i, :]. These
should be efficient operations. But slicing along the 'non-native'
axes, with csc[i, :], csr[:, j], or lil[:, j] would be slower (and
more complex to write), and these raise an IndexError.
> * a not-so-simple question: is there any documentation, tutorial,
> introduction, ... to the sparse matrices of scipy? It seems neither
> the
> official (feebased) docs mention them, nor are the docstrings *that*
> extensive.
There are also more docstrings in SVN HEAD. No tutorial yet,
although we've had several requests recently. I'll see what I can do
after I've submitted my thesis in a few weeks ...
-- Ed
More information about the SciPy-User
mailing list