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

Nathaniel Smith njs at pobox.com
Thu Dec 31 19:20:34 EST 2015

On Thu, Dec 31, 2015 at 12:10 PM, Benjamin Root <ben.v.root at gmail.com> wrote:
> TBH, I wouldn't have expected it to work, but now that I see it, it does
> make some sense. I would have thought that it would error out as being
> ambiguous (prepend? append?). I have always used ellipses to make it
> explicit where the new axis should go. But, thinking in terms of how regular
> indexing works, I guess it isn't all that ambiguous.

Yeah, I'm not really a fan of the rule that indexing with too-few axes
implicitly adds a "..." on the right

  A[0] -> A[0, ...]

but given that we do have that rule, then A[None] -> A[None, ...] does
make sense.


Nathaniel J. Smith -- http://vorpus.org

More information about the NumPy-Discussion mailing list