[Numpy-svn] r3710 - trunk/numpy/core

numpy-svn@scip... numpy-svn@scip...
Fri Apr 13 00:49:54 CDT 2007


Author: timl
Date: 2007-04-13 00:49:41 -0500 (Fri, 13 Apr 2007)
New Revision: 3710

Modified:
   trunk/numpy/core/records.py
Log:
remove unneeded semi-colon, add missing import, whitespace cleanups

Modified: trunk/numpy/core/records.py
===================================================================
--- trunk/numpy/core/records.py	2007-04-12 08:42:21 UTC (rev 3709)
+++ trunk/numpy/core/records.py	2007-04-13 05:49:41 UTC (rev 3710)
@@ -6,6 +6,7 @@
 import numerictypes as nt
 import types
 import os
+import sys
 
 ndarray = sb.ndarray
 
@@ -128,7 +129,7 @@
         except AttributeError:
             pass
         fielddict = nt.void.__getattribute__(self, 'dtype').fields
-        res = fielddict.get(attr,None)
+        res = fielddict.get(attr, None)
         if res:
             obj = self.getfield(*res[:2])
             # if it has fields return a recarray,
@@ -146,15 +147,15 @@
 
     def __setattr__(self, attr, val):
         if attr in ['setfield', 'getfield', 'dtype']:
-            raise AttributeError, "Cannot set '%s' attribute" % attr;
+            raise AttributeError, "Cannot set '%s' attribute" % attr
         try:
-            return nt.void.__setattr__(self,attr,val)
+            return nt.void.__setattr__(self, attr, val)
         except AttributeError:
             pass
-        fielddict = nt.void.__getattribute__(self,'dtype').fields
-        res = fielddict.get(attr,None)
+        fielddict = nt.void.__getattribute__(self, 'dtype').fields
+        res = fielddict.get(attr, None)
         if res:
-            return self.setfield(val,*res[:2])
+            return self.setfield(val, *res[:2])
         else:
             raise AttributeError, "'record' object has no "\
                   "attribute '%s'" % attr
@@ -187,7 +188,7 @@
 
     def __getattribute__(self, attr):
         try:
-            return object.__getattribute__(self,attr)
+            return object.__getattribute__(self, attr)
         except AttributeError: # attr must be a fieldname
             pass
         fielddict = ndarray.__getattribute__(self,'dtype').fields
@@ -232,7 +233,7 @@
             res = fielddict[attr][:2]
         except (TypeError,KeyError):
             raise AttributeError, "record array has no attribute %s" % attr
-        return self.setfield(val,*res)
+        return self.setfield(val, *res)
 
     def __getitem__(self, indx):
         obj = ndarray.__getitem__(self, indx)
@@ -240,10 +241,10 @@
             return obj.view(ndarray)
         return obj
 
-    def field(self,attr, val=None):
-        if isinstance(attr,int):
+    def field(self, attr, val=None):
+        if isinstance(attr, int):
             names = ndarray.__getattribute__(self,'dtype').names
-            attr=names[attr]
+            attr = names[attr]
 
         fielddict = ndarray.__getattribute__(self,'dtype').fields
 
@@ -304,7 +305,7 @@
             if issubclass(obj.dtype.type, nt.flexible):
                 formats += `obj.itemsize`
             formats += ','
-        formats=formats[:-1]
+        formats = formats[:-1]
 
     if dtype is not None:
         descr = sb.dtype(dtype)
@@ -370,7 +371,7 @@
 
     nfields = len(recList[0])
     if formats is None and dtype is None:  # slower
-        obj = sb.array(recList,dtype=object)
+        obj = sb.array(recList, dtype=object)
         arrlist = [sb.array(obj[...,i].tolist()) for i in xrange(nfields)]
         return fromarrays(arrlist, formats=formats, shape=shape, names=names,
                           titles=titles, aligned=aligned, byteorder=byteorder)



More information about the Numpy-svn mailing list