[Numpy-svn] r2995 - trunk/numpy/core
numpy-svn at scipy.org
numpy-svn at scipy.org
Thu Aug 10 22:12:24 EDT 2006
Author: oliphant
Date: 2006-08-10 21:12:22 -0500 (Thu, 10 Aug 2006)
New Revision: 2995
Modified:
trunk/numpy/core/records.py
Log:
Fix record class so that it returns chararrays and record arrays as needed as well.
Modified: trunk/numpy/core/records.py
===================================================================
--- trunk/numpy/core/records.py 2006-08-11 01:58:47 UTC (rev 2994)
+++ trunk/numpy/core/records.py 2006-08-11 02:12:22 UTC (rev 2995)
@@ -122,8 +122,16 @@
pass
fielddict = nt.void.__getattribute__(self, 'dtype').fields
res = fielddict.get(attr,None)
- if res:
- return self.getfield(*res[:2])
+ if res:
+ obj = self.getfield(*res[:2])
+ # if it has fields return a recarray,
+ # if it's a string return 'SU' return a chararray
+ # otherwise return a normal array
+ if obj.dtype.fields:
+ return obj.view(recarray)
+ if obj.dtype.char in 'SU':
+ return obj.view(chararray)
+ return obj
else:
raise AttributeError, "'record' object has no "\
"attribute '%s'" % attr
More information about the Numpy-svn
mailing list