[Numpy-discussion] how to create an array of objects that are sequences?

Pearu Peterson pearu@cens.ioc...
Fri Jan 4 12:13:27 CST 2008

On Fri, January 4, 2008 7:33 pm, Travis E. Oliphant wrote:

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

Actually this is still an option if to put the above
to a A.as_array method something like

class A(tuple):
    def as_array(self):
        import numpy
        obj = numpy.empty(1,dtype=object)
        obj[0] = self
        return obj

but it would be nice if the __array__ method also worked.
Could this be something that should be put to issues or
would it just get a WontFix flag?

Thanks again,

More information about the Numpy-discussion mailing list