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

Mark Bakker markbak@gmail....
Wed Feb 1 03:25:04 CST 2012


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'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120201/c427d7d7/attachment-0001.html 


More information about the NumPy-Discussion mailing list