[Numpy-discussion] Re: Questions about the array interface.
mrmaple at gmail.com
Thu Apr 7 04:44:27 CDT 2005
Hi Chris, Travis, ...
Great conversation you've started. I have two questions at the
moment... I do love the idea that an abstraction can bring the
different but similar num* worlds together.
Which sourceforge CVS repository is the interface (and an
implementation) show up on first? My guess is numpy/numeric3
I see Travis has been updating it while I sleep.
> def DrawPointList(self, points, pens=None):
> # some checking code on the pens)
> if (hasattr(points,'__array_shape__') and
> hasattr(points,'__array_typestr__') and
> len(points.__array_shape__) == 2 and
> points.__array_shape__ == 2 and
> points.__array_typestr__ == 'i4' and
> ): # this means we have a compliant array
> # return the array protocol version
> return self._DrawPointArray(points.__array_data__, pens,)
> #This needs to be written now!
This means that whenever you have some complex multivalued
multidementional structure with the data you want to plot, you have to
reshape it into the above 'compliant' array before passing it on. I'm
a newbie, but is this reshape something where the data has to be
copied and take up memory twice? If not, then great, you would
painlessly reshape into something that had a different set of strides
that just accessed the data that complied in the big blob of data. If
the reshape is expensive, then maybe we need the array abstraction,
and then a second 'thing' that described which parts of the array to
use for the sequence of 2-tuples to use for plotting the x,y s of a
scatter plot. (or whatever)
I do think we can accept more than just i4 for a datatype. Especially
since a last-minute cast to i4 in inexpensive for almost every data
> #return the generic python sequence version
> return self._DrawPointList(points, pens, )
> Then we'll need a function (in C++):
> _DrawPointArray(points.__array_data__, pens,)
More information about the Numpy-discussion