[Numpy-discussion] bug !? dtype type_descriptor does not accept zero length tuple

Sebastian Haase haase at msg.ucsf.edu
Wed Aug 9 18:41:00 EDT 2006


On Wednesday 09 August 2006 15:18, Travis Oliphant wrote:
> Sebastian Haase wrote:
> > Hi!
> > I have a problem with record array type descriptor.
> > With numarray this used to work.
> > My records made of  n integers and m floats.  So I used to be able
> > specify formats="%di4,%df4"%(self.numInts,self.numFloats) in numarray
> > which would translate to
> > byteorder = self.isByteSwapped and '>' or '<'
> > type_descr = [("int",   "%s%di4" %(byteorder,self.numInts)),
> >                       ("float", "%s%df4" %(byteorder,self.numFloats))]
> >
> > The problem occurs when numInts or numFloats is zero !?
> > Could it numpy be changed to silectly accept this case
> > Here is the complete traceback + some debug info:
>
> If numarray supported it, then we should get NumPy to support it as well
> unless there is a compelling reason not to.  I can't think of any except
> that it might be hard to make it work.  What is '0i4' supposed to mean
> exactly?  Do you get a zero-sized field or is the field not included?
> I think the former will be much easier than the latter.   Would that be
> O.K.?

That's exactly what numarray did. The rest of my code is assuming that all 
fields exist (even if they are empty). Otherwise I get a name error  which is 
worse than getting an empty array.

Thanks,
Sebastian Haase




More information about the NumPy-Discussion mailing list