Slicing with None adds a new dimension. It's a common paradigm, though usually you'd use A[np.newaxis] or A[np.newaxis, ...] instead for readibility. (np.newaxis is None, but it's a lot more readable)
There's a good argument to be made that slicing with a single None shouldn't add a new axis, and only the more readable forms like A[None, :], A[..., None], etc should. However, that would rather seriously break backwards compatibility. There's a fair amount of existing code that assumes "A[None]" prepends a new axis. On Thu, Dec 31, 2015 at 10:36 AM, Neal Becker <ndbeck...@gmail.com> 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. > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > https://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion