[NumPy-Tickets] [NumPy] #1994: Empty indices in empty arrays raise IndexError
NumPy Trac
numpy-tickets@scipy....
Tue Dec 13 14:00:43 CST 2011
#1994: Empty indices in empty arrays raise IndexError
---------------------+------------------------------------------------------
Reporter: jordigh | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: Other | Version: 1.6.0
Keywords: |
---------------------+------------------------------------------------------
Let x be an array and consider the following expression:
{{{
x[:, idx]
}}}
This should be valid as long as all elements of idx are nonnegative
integers less than x.shape[1], right?
However, this is not true if, say, x.shape == (5, 0) and idx = []. The
statement "all elements of idx are nonnegative integers less than 0" is
still true, however this causes an error.
Note that the following does not error out, however:
{{{
x = np.array([])
x[ [] ]
}}}
So this looks like a bug to me. I have had independent confirmation in IRC
of this behaviour in 1.6.1 and 1.5.0.
The reason why I would like this fixed is that I don't want to have to
special-case my indexing code for indexing arrays with empty dimensions
with an empty index array. I could work around this, but I would rather
not.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1994>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list