[Numpy-discussion] Array interface

Scott Gilbert xscottg at yahoo.com
Mon Apr 4 19:09:34 CDT 2005


--- Magnus Lie Hetland <magnus at hetland.org> wrote:
> 
> I would almost be tempted to say that if __array_descr__ is in use,
> __array_typestr__ *has* to use the 'V' type. (Or, one could make some
> more complicated rules, perhaps, in order to allow other types.)
> 

Yup, having multiple ways to spell the same information will likely cause
problems.  Wouldn't be bad for the protocol to say "thou shalt use the
specfic typestr when possible".  Or to say that the __array_descr__ is only
for 'V' typestrs.


>
> As for not supporting the 'V' type -- would that really be considered
> a conforming implementation? According to the spec, "Objects wishing
> to support an N-dimensional array in application code should look for
> these attributes and use the information provided appropriately". The
> typestr is required, so...
>

I think the intent is that libraries like wxPython or PIL can recognize
data that they *want* to work with.  They can raise an exception when
passed anything that is more complicated than they're willing to deal with.

I think many packages will simply punt when they see a 'V' typestr and not
look at the more complicated description at all.  Nothing wrong with
that...  The packages that produce more complicated data structures have a
way to express it and pass it to the packages that are capable of consuming
it.  Easy things are easy, and hard things are possible.


> 
> Perhaps the spec should be explicit about the shoulds/musts/mays of
> the specific typecodes? What must be supported, what may be supported
> etc.? Or perhaps that doesn't make sense? It just seems almost too bad
> that one package would have to know what another package supports in
> order to formulate its own typestr... It sort of throws part of the
> interoperability out the window.
>

Being very precise in the language describing the protocol is probably a
good thing, but I don't see anything that requires packages to formulate
their typestr's differently.  The little bit of ambiguity that is in the
__array_typestr__ and __array_descr__ attributes can be easily clarified.


Cheers,
    -Scott





More information about the Numpy-discussion mailing list