[Numpy-discussion] flat indexing of object arrays

Travis Oliphant oliphant at ee.byu.edu
Thu Oct 5 17:11:34 CDT 2006


Martin Wiechert 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:
>
>  
>
>>>>import numpy
>>>>numpy.version.version
>>>>        
>>>>
>'1.0rc1.dev3171'
>  
>
>>>>from numpy import *
>>>>a = ndarray ((2,2), object)
>>>>a.flat [2] = (1, 2, 3)
>>>>a.flat [2]
>>>>        
>>>>
>1
>  
>
>>>>a
>>>>        
>>>>
>array([[None, None],
>       [1, None]], dtype=object)
>
>Is this a feature? Wouldn't a naive user like me expect
>a.flat [2] == (1, 2, 3)?
>
>  
>
You are probably right.    This should be changed.

-Travis





More information about the Numpy-discussion mailing list