[Numpy-discussion] Introduction

Scott Gilbert xscottg at yahoo.com
Tue Apr 16 16:38:02 EDT 2002

--- Perry Greenfield <perry at stsci.edu> wrote:
> If one had an NDArray that happened to contain a type that numarray 
> supported, yes it is possible (in fact RecArray does that sort of thing).
> If your point is that in doing so one must use the private attributes
> such as _strides, yes that is true.

My point was simply:

  = One *can* convert from (NDArray + typecode) to a full NumArray
  = You *do* already convert lists, tuples, ... to NumArrays in ufuncs
  = So you *could* convert *(NDArrays + typecode) to NumArrays in ufuncs
    in the same place that checks to see if it is a list, tuple, ...


  = You possibly *could* standardize the attributes in an NDArray
      (buffer, typecode, shape, stride, offset, ...)
  = If you *did* standardize the attributes, then others *could*
    build UserDefinedNDArrays however they see fit and they would
    work with NumArrays

However I get the sense that the numarray module is your baby, and you
don't want to change him too much.  That's very understandable, you're a
proud parent.  Truth be told, he's a good looking kid, and I look forward
to hanging out with him when he's all grown up.  We just have a little
different view on parenting, and I was hoping my kid would have an easier
time playing with yours.

Now that I've beaten that silly metaphor to death...  :-)


ps: It occurs to me, with the strong sense of encapsulation you desire,
that I could have presented this better as requesting that you specify a
set of standard *methods* instead of attributes.  Something like:

     def __array_getbuffer__(self):
     def __array_getoffset__(self):
     def __array_getshape__(self):
     def __array_getstrides__(self):
     def __array_getitemsize__(self):
     def __array_gettypecode__(self):
     def __array_getendian__(self):
     # Who knows what the real list would consist of...
     # We never got to discuss what a really general
     # purpose description of an NDArray would require...

Then anything which implemented those standard *methods* would be a viable
NDArray.  From my point of view it amounts to about the same thing, but I
think it's a better design and that you might like this idea more.

However I'm getting out of breath on this topic, and I have other things
I need to do (I'm sure this is true for you too), so if you don't see any
merit in this idea, I won't push for it any further.

Cheers again.

Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

More information about the NumPy-Discussion mailing list