Matthew Brett wrote: >Hi, > >On 10/5/06, Martin Wiechert <[EMAIL PROTECTED]> wrote: > > >>Hi list, >> >>when I try to assign a sequence as an element of an object array via flat >>indexing only the first element of the sequence is assigned: >> >> > >I've also been having trouble with flat on object arrays. > >Is this intended? > >In [1]: from numpy import * > >In [2]: a = arange(2) > >In [3]: a[1] >Out[3]: 1 > >In [4]: a.flat[1] >Out[4]: 1 > >In [5]: b = array([a], dtype=object) > >In [6]: b[1] >--------------------------------------------------------------------------- >exceptions.IndexError Traceback (most >recent call last) > >/home/mb312/devel_trees/scipy/Lib/io/<ipython console> > >IndexError: index out of bounds > >In [7]: b.flat[1] >Out[7]: 1 > > >
This is correct behavior. Look at the shape of b. It is being indexed correctly. The problem is that it is ambiguous as to what is wanted when you write b = array([a], dtype=object). We have gone through the rounds on this one and the current behavior is our best compromise. -Travis ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion