On 3/2/07, Alan Isaac <[EMAIL PROTECTED]> wrote:
> John asked:
> > What is the minimum interface for an object to be
> > converted to a numpy sequence via as array?
>
> The class must inherit from object.
> That will probably do it.
> If all else fails, try fromiter.
>
I know it works with fromiter, but I am trying to find a way mpl users
can create objects that will work directly in mpl, which uses asarray.
Thanks for the object suggestion; here is the minimal interface that
appears to work
class C(object):
def __init__(self):
self._data = (1,2,3,4,5)
def __getitem__(self, i):
return self._data[i]
def __len__(self):
return len(self._data)
import numpy
c = C()
print numpy.asarray(c)
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users