On Nov 17, 2009, at 12:33 PM, Sebastian Haase wrote:

On Tue, Nov 17, 2009 at 5:40 PM,  <josef.p...@gmail.com> wrote:
On Tue, Nov 17, 2009 at 11:24 AM, Jean-Baptiste Rudant
<boogalo...@yahoo.fr> wrote:
Hello,
I think there's something strange with shape when a slice is given by an
array.
import numpy as N
my_array = N.ones((2, 3, 6))
ind = N.arange(4)
#you hope to find (3, 4)
print my_array[0, :, ind].shape
print my_array[0, :, 0:4].shape
print my_array[0][:, ind].shape
print my_array[0][:, 0:4].shape
"""
(4, 3)
(3, 4)
(3, 4)
(3, 4)
"""
Jean-Baptiste Rudant

there was a long thread on this with the explanation in March, title
"is it a bug?"

The thread is here:
http://www.mail-archive.com/numpy-discussion@scipy.org/msg16300.html

It looks to me like violating the principle of "least surprise".
My reading of that thread is, that the observed "bug" is mostly a
consequence coming from the way fancy indexing is implemented. How
about deprecating this kind of index mixing !?

I don't think this is really a case of the way fancy indexing is implemented. It could have been done in many ways. The problem is one of real ambiguity in the general case and the fact that there wasn't any code written to handle the less ambiguous special-cases like this one.

There are real applications of index mixing, so turning it off is not an option. We could perhaps add better handling of circumstances like this, however, with appropriate warnings and transitions.

-Travis





_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to