[SciPy-User] running script error (eigen symmetric)

Aronne Merrelli aronne.merrelli at gmail.com
Tue Dec 18 11:14:50 EST 2012


On Mon, Dec 17, 2012 at 5:22 PM, Amy Anderson <amyla333 at gmail.com> wrote:

> Hi scipy users,
>
> I am trying to run this script in python and the script is now working
> with the test data (eigen problem solved) but when I input my own data to
> be called by script I got the following errors.
>
> [moriaht-5:~/Desktop/pyClusterROI] moriah% python pyClusterROI_test.py
> tcorr connectivity subject2002.nii
>
> Traceback (most recent call last):
>   File "pyClusterROI_test.py", line 89, in <module>
>     make_local_connectivity_tcorr( infiles[i], maskname, outname, 0.5 )
>   File
> "/Users/moriah/Desktop/pyClusterROI/make_local_connectivity_tcorr.py", line
> 114, in make_local_connectivity_tcorr
>     msk=csc_matrix((range(1,m+1),(iv,zeros(m))),shape=(prod(sz[1:]),1))
>   File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/sparse/compressed.py",
> line 44, in __init__
>     other = self.__class__( coo_matrix(arg1, shape=shape) )
>   File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/sparse/coo.py",
> line 188, in __init__
>     self._check()
>   File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/sparse/coo.py",
> line 220, in _check
>     raise ValueError('row index exceedes matrix dimensions')
> ValueError: row index exceedes matrix dimensions
>
>
> I was wondering if anyone might know what this error might mean or how to
> fix it? I do not know what is meant by "row index exceeds matrix
> dimensions" as this is the first time I am using scipy to run a script.
>
>
Hi,

It is difficult to debug this without seeing the actual code you are
running, but it seems likely that the inputs to the CSC matrix constructor
are in error. Can you set a breakpoint and check the inputs at this call?

msk=csc_matrix((range(1,m+1),(iv,zeros(m))),shape=(prod(sz[1:]),1))

what are the runtime values of m, iv, and sz? I can trigger the same
ValueError that you see, by giving the constructor a set of row, column
entries in the matrix, that are outside the shape of the matrix as
described by the shape keyword. For example:

In [21]: test = scipy.sparse.csc_matrix( ([5,6], ([0,5],[0,0])), shape =
(3,1) )
<snipped various traceback stuff...>
ValueError: row index exceedes matrix dimensions


That call is attempting to put a matrix element at (5,0) while the shape is
only (3,1). So, making shape (6,1) works:

In [22]: test = scipy.sparse.csc_matrix( ([5,6], ([0,5],[0,0])), shape =
(6,1) )

In [23]: test.todense()
Out[23]:
matrix([[5],
        [0],
        [0],
        [0],
        [0],
        [6]])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20121218/0752f6cb/attachment.html>


More information about the SciPy-User mailing list