[SciPy-user] sparse+slice? (and hello!)
Ed Schofield
schofield at ftw.at
Wed May 17 07:19:51 EDT 2006
Bram de Jong - MTG wrote:
> Hi,
>
> Ed Schofield wrote:
>
>> On 17/05/2006, at 9:19 AM, Bram de Jong - MTG wrote:
>>
>>> * A simple question to start of with, is it correct to say that the
>>> sparse matrices do not support slicing?
>>>
>> 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.
>>
>
> Oh, that's great news... Is this Python-only, or C code? Just to know if
> I will have to recompile. (Are there daily builds somewhere?)
>
It's Python-only, but I suggest you re-compile the package, since some
bugs were also fixed in the sparsetools Fortran code. You'll need a
fairly recent NumPy version too (I think at least 0.9.6).
> Perhaps slicing along the non-native axes could be supported as well,
> even if it's really slow... A simple docstring with a message about the
> speed would solve the problem, while supplying the user with a "full
> set". For small matrices or really sparse ones it won't be much of a
> problem I guess (?).
>
If you don't mind it being slow, an easy way to get slices along
non-native axes is to convert the matrix format first. For example,
>>> csc.tocsr()[i, :]
does the trick :)
>>> * 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 ...
>>
>
> Ok, that's great as well...
>
> thanks for the rapid reply!
>
You're welcome!
-- Ed
More information about the SciPy-User
mailing list