[SciPy-user] Re: [Numpy-discussion] errors=31 in scipy.test() with latest cvs versions of scipy and Numerical

David M. Cooke cookedm at physics.mcmaster.ca
Wed Apr 6 05:44:38 EDT 2005


On Wed, Apr 06, 2005 at 10:00:06AM +0200, Nils Wagner wrote:
> Hi all,
> 
> Using Numeric 24.0
> >>> scipy.__version__
> '0.3.3_303.4599'
> 
> scipy.test() results in
> 
> ======================================================================
> ERROR: check_simple_todense (scipy.io.mmio.test_mmio.test_mmio_coordinate)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "/usr/lib/python2.3/site-packages/scipy/io/tests/test_mmio.py", 
> line 152, in check_simple_todense
>    b = mmread(fn).todense()
>  File "/usr/lib/python2.3/site-packages/scipy/sparse/Sparse.py", line 
> 254, in todense
>    csc = self.tocsc()
>  File "/usr/lib/python2.3/site-packages/scipy/sparse/Sparse.py", line 
> 1437, in tocsc
>    return csc_matrix(a, (rowa, ptra), M=self.shape[0], N=self.shape[1])
>  File "/usr/lib/python2.3/site-packages/scipy/sparse/Sparse.py", line 
> 357, in __init__
>    self._check()
>  File "/usr/lib/python2.3/site-packages/scipy/sparse/Sparse.py", line 
> 375, in _check
>    if (nnz>0) and (max(self.rowind[:nnz]) >= M):
> IndexError: invalid slice

(etc. -- note to self: use scipy for regression testing :-)

nnz is coming from
nnz = self.indptr[-1]
where self.indptr is an array of Int32.

Hmm, this corresponds to the behaviour I just responded to Sebastien de
Menten about. The problem is that nnz is *not* an Python integer; it's
an array, so the slice fails.

I think I was wrong in that email about saying this was expected
behaviour :-)

This comes from the recent fix of a[0,0] and a[0][0] returning
the same type. Either change that back, or else we need to spruce up the
slicing logic to consider 0-dimensional integer arrays as scalars.

A minimal test case:

a = Numeric.array([5,6,7,8])
b = Numeric.array([0,1,2,3], 'i')
n = b[-1]
assert a[:n] == 8

(I'm not tackling this right now)

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca




More information about the SciPy-User mailing list