[SciPy-user] scipy sclicing

Pauli Virtanen pav@iki...
Fri Oct 10 08:58:40 CDT 2008


Fri, 10 Oct 2008 05:45:02 -0700, John [H2O] wrote:
> Could someone explain what I'm doing wrong here?
> 
>>>> i = array(range(140,149))
>>>> j = array(range(5,20))
>>>> i
> array([140, 141, 142, 143, 144, 145, 146, 147, 148])
>>>> j
> array([ 5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])
>>>> a = acc[i,j]
> Traceback (most recent call last):
>   File "<string>", line 1, in <string>
> ValueError: shape mismatch: objects cannot be broadcast to a single
> shape
[clip]
> How come I can't use arrays to index my array?

See also the reference documentation; chapter 3.4 in Guide to Numpy [1].

.. [1] http://www.tramy.us/numpybook.pdf

-- 
Pauli Virtanen



More information about the SciPy-user mailing list