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: '>0i4'Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/haase/PrLinN/Priithon/Mrc.py", line 56, in bindFile a = Mrc(fn, mode) File "/home/haase/PrLinN/Priithon/Mrc.py", line 204, in __init__ self.doExtHdrMap() File "/home/haase/PrLinN/Priithon/Mrc.py", line 271, in doExtHdrMap self.extHdrArray.dtype = type_descr File "/home/haase/qqq/lib/python/numpy/core/records.py", line 194, in __setattr__ return object.__setattr__(self, attr, val) TypeError: invalid data-type for array >>> U.debug() > /home/haase/qqq/lib/python/numpy/core/records.py(196)__setattr__() -> pass (Pdb) l 191 192 def __setattr__(self, attr, val): 193 try: 194 return object.__setattr__(self, attr, val) 195 except AttributeError: # Must be a fieldname 196 -> pass 197 fielddict = sb.ndarray.__getattribute__(self,'dtype').fields 198 try: 199 res = fielddict[attr][:2] 200 except (TypeError,KeyError): 201 raise AttributeError, "record array has no attribute %s" % attr (Pdb) p val [('int', '>0i4'), ('float', '>2f4')] (Pdb) p attr 'dtype' Thanks, Sebastian Haase ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion