[Numpy-discussion] how to create an array of objects that are sequences?
Pearu Peterson
pearu@cens.ioc...
Fri Jan 4 11:23:50 CST 2008
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
>>> array([A((1,2))], dtype=object)
array([[1, 2]], dtype=object)
but what I'd like to get is
array([A((1, 2))], dtype=object)
I tried defining A.__array__ method but that does not have
effect when A instance is inside a sequence to array call.
Thanks for any information for how to resolve this problem,
PEaru
More information about the Numpy-discussion
mailing list