On 3/2/07, Christopher Barker <[EMAIL PROTECTED]> wrote: > This sounds like EXACTLY the type of object that the array interface is > supposed to support. So what you need to do is give your object an array > interface: > > http://numpy.scipy.org/array_interface.shtml
I still am not able to make my mock-up custom python class work as I would like with asarray (though it works with "list"). What am I missing? The way I read it this appears to be in support of extension code that wants to expose the array interface, but I have a python object that acts like a sequence (am I missing some important method) that wants to work properly with numpy.asarray class C: def __init__(self): self._data = (1,2,3,4,5) def __iter__(self): for i in self._data: yield i return def __getitem__(self, i): return self._data[i] def __getslice__(self, i, j): return self._data[i:j] def __len__(self): return len(self._data) def __array_interface__(self): return dict( shape=(len(self._data),), typestr='f', version=3) import numpy c = C() print numpy.asarray(c) #for i in c: # print i ------------------------------------------------------------------------- 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 _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users