[Numpy-discussion] Index array confusion...

Magnus Lie Hetland magnus at hetland.org
Mon Dec 16 11:23:02 EST 2002


Perry Greenfield <perry at stsci.edu>:
>
> Magnus Lie Hetland wrote:
> 
> > >Well, what I was asking about was really what you meant by "correct".
> > >My interpretation of "correct" here was that only tuples and slices
> > >would be allowed as indexes.
> > >
> To clarify, tuples should be interpreted differently than lists or 
> arrays as arguments, as you suggested earlier so that
> x[1,2,3] is not interpreted the same as x[[1,2,3]] or x[array([1,2,3])].
> Granted, that will be confusing for those that try x[(1,2,3)]
> expecting it to be equivalent ot x[[1,2,3]] but we decided that
> the benefits of array indices well outweigh that confusing case.

Exactly. I agree completely with this (intended) behaviour. I was just
a bit baffled to find that numarray (0.4), in fact, behaved
differently. Since this is indeed a bug, the issue seems resolved to
me :)

(Except that I might have to add some version control to avoid running
with 0.4 :/)

> As far as far as slices resulting in views rather than copies
> (was with lists), this is a topic that has been talked to death.

Yes -- sorry about that.

> The original Numeric has view behavior.

I know. Just a mind-bug on my part :)

> When we started on numarray
> we were intending to make it more consistent with lists, but there
> were many that argued that view semantics were more sensible and
> we were persuaded that they were right (besides, the backward
> compatibility issue was very important as well).

And performance, perhaps?

And; from Todd's comment about a hypothetical built-in for the
purpose, I assume there is no way of copying the contents of one slice
to another without going via a temporary array?

> Perry

-- 
Magnus Lie Hetland        Practical Python          The Anygui Project
http://hetland.org        http://ppython.com        http://anygui.org




More information about the NumPy-Discussion mailing list