[Numpy-discussion] Index array confusion...

Magnus Lie Hetland magnus at hetland.org
Sun Dec 15 14:03:03 CST 2002


Todd Miller <jmiller at stsci.edu>:
>
[snip]
> What I'm saying is that in the future it will work correctly.  :)

OK :)

> Most likely as you suggest,  but I haven't really looked at the code, 
> just the rather sickening results.

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.

BTW: I found something else that I think is rather odd:

>>> x = [0, 0, 0]
>>> y = [1, 1, 1]
>>> p = 1
>>> x[p:], y[p:] = y[p:], x[p:]
>>> x, y
([0, 1, 1], [1, 0, 0])
>>> x = array([0, 0, 0])
>>> y = array([1, 1, 1])
>>> x[p:], y[p:] = y[p:], x[p:]
>>> x, y
(array([0, 1, 1]), array([1, 1, 1]))

This seems like a bug to me. The assignment ought to swap the tails of
the sequences, as is the case with lists, but with numeric arrays,
some weird form of overwriting occurs. I guess this may be an
optimization (i.e. to avoid making copies), but it is rather
confusing. What do you think?

> Todd

-- 
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