Pearu Peterson wrote:
> Hi,
>
> Say, one defines
>
> class A(tuple):
>   def __repr__(self):
>     return 'A(%s)' % (tuple.__repr__(self))
>
> and I'd like to create an array of A instances.
>
> Currently I get
>
>   

The array function was designed a long time ago to inspect sequences and 
flatten them.   

Arguably, there should be more intelligence when an "object" array is 
requested, but there is ambiguity about what the "right" thing to do is. 

Thus, the current situation is that if you are creating object arrays, 
the advice is to populate it after the fact. 

So, create an empty object array and insert the entries the way you want 
them:

a = np.empty(1,dtype=object)
a[0] = A((1,2))


-Travis

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to