Inconsistent indexing of arrays with no elements, depending on shape (Trac #1171) #1769

Closed
thouis opened this Issue Oct 19, 2012 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

thouis commented Oct 19, 2012

Original ticket http://projects.scipy.org/numpy/ticket/1171 on 2009-07-14 by trac user jguyer, assigned to unknown.

An empty, rank-0 array can be indexed with an empty list:

#!python
>>> import numpy as np
>>> np.__version__
'1.3.0.dev6304'
>>> a = np.zeros((0,))
>>> a[..., []]
array([], dtype=float64)

but an empty array of higher rank throws an index error

#!python
>>> b = np.zeros((1, 0))
>>> b[..., []]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: invalid index

We have a not-completely-insane reason for wanting the second case to return array([], shape=(1, 0), dtype=float64). At a minimum, it seems the two cases should be consistent.

I wonder if this is related to ticket:1169?

I see this on a 10.5.7 Mac, with Python 2.6.2 and NumPy 1.3.0dev and on a Debian etch machine running Python 2.4.4 and NumPy 1.2.1.

Contributor

thouis commented Oct 19, 2012

@teoliphant wrote on 2009-07-15

I agree with this reasoning. Does someone have a patch?

Contributor

thouis commented Oct 19, 2012

Milestone changed to Unscheduled by @cournape on 2009-11-25

Contributor

nouiz commented May 15, 2013

Fix issue have been fixed by gh-2701 from its description. Can someone close it?

seberg closed this May 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment