[Numpy-discussion] what would you expect A[none] to do?

Sebastian Berg sebastian at sipsolutions.net
Thu Dec 31 11:56:04 EST 2015


On Do, 2015-12-31 at 11:36 -0500, Neal Becker wrote:
> Neal Becker wrote:
> 
> > In my case, what it does is:
> > 
> > A.shape = (5760,)
> > A[none] -> (1, 5760)
> > 
> > In my case, use of none here is just a mistake.  But why would you
> > want
> > this to be accepted at all, and how should it be interpreted?
> 
> Actually, in my particular case, if it just acted as a noop,
> returning the 
> original array, that would have been perfect.  No idea if that's a
> good 
> result in general.
> 

We have `np.newaxis` with `np.newaxis is None` for the same thing.
`None` inserts a new axes, it is documented to do so in the indexing
documentation, so I will ask you to check it if you have more
questions.
If you want a noop, you should probably use `...` or `Ellipsis`.


- Sebastian


> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20151231/7f898834/attachment.sig>


More information about the NumPy-Discussion mailing list