[Numpy-discussion] combination of list of indices and newaxis not allowed?

Olivier Delalleau shish at keba.be
Wed Feb 1 06:47:56 EST 2012


I think you just can't use newaxis in advanced indexing (doc says "The
newaxis<http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#numpy.newaxis>object
can be used in the basic slicing syntax", and does not mention
newaxis in the advanced indexing part).

-=- Olivier

Le 1 février 2012 04:25, Mark Bakker <markbak at gmail.com> a écrit :

> Hello list,
>
> I am trying to specify the indices of an array with a list and add a
> newaxis, but that combination doesn't seem to be allowed. Any reason why?
> Here's an example:
>
> a = arange(3)
>
> This works:
>
> a[[0,2]][:,newaxis]
> Out[445]:
> array([[0],
>        [2]])
>
> This is more elegant syntax (and, I thought, correct), but it doesn't work:
>
> a[[0,2],newaxis]
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
> /Users/mark/ttim/svn/trunk/<ipython-input-444-b37a4cca4311> in <module>()
> ----> 1 a[[0,2],newaxis]
>
> TypeError: long() argument must be a string or a number, not 'NoneType'
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120201/5dc1d4c7/attachment.html>


More information about the NumPy-Discussion mailing list