[SciPy-dev] sparse matrix support status

Ed Schofield schofield at ftw.at
Wed Nov 23 19:26:29 CST 2005


On 23/11/2005, at 7:26 PM, Jonathan Guyer wrote:

>
> Well, I guess I find the result of:
>
>>>> B = scipy.sparse.dok_matrix((3,3))
>>>> a = scipy.ones((3,))
>>>> B.setdiag(a,0)
>>>> print B.todense()
>      [[ 1.  0.  0.]
>       [ 0.  1.  0.]
>       [ 0.  0.  1.]]
>>>> B.setdiag(a,1)
>>>> print B.todense()
>      [[ 1.  1.  0.  0.]
>       [ 0.  1.  1.  0.]
>       [ 0.  0.  1.  1.]]
>
> to be surprising.
>
> I was expecting
>
>      [[ 1.  1.  0.]
>       [ 0.  1.  1.]
>       [ 0.  0.  1.]]
>

I agree this is more useful behaviour.  I've changed this in SVN and  
added an explicit resize() method for dok_matrices.

Thanks again for the feedback.

-- Ed




More information about the Scipy-dev mailing list