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

numpy-svn@scip... numpy-svn@scip...
Thu Sep 18 22:33:42 CDT 2008


Author: pierregm
Date: 2008-09-18 22:33:40 -0500 (Thu, 18 Sep 2008)
New Revision: 5834

Modified:
   trunk/numpy/core/records.py
Log:
* fixing view to recognize dtype and type parameters, for consistency with regular ndarrays.

Modified: trunk/numpy/core/records.py
===================================================================
--- trunk/numpy/core/records.py	2008-09-18 21:48:57 UTC (rev 5833)
+++ trunk/numpy/core/records.py	2008-09-19 03:33:40 UTC (rev 5834)
@@ -448,17 +448,23 @@
         else:
             return self.setfield(val, *res)
 
-    def view(self, obj):
-        try:
-            if issubclass(obj, ndarray):
-                return ndarray.view(self, obj)
-        except TypeError:
-            pass
-        dtype = sb.dtype(obj)
-        if dtype.fields is None:
-            return self.__array__().view(dtype)
-        return ndarray.view(self, obj)
+    def view(self, dtype=None, type=None):
+        if dtype is None:
+            return ndarray.view(self, type)
+        elif type is None:
+            try:
+                if issubclass(dtype, ndarray):
+                    return ndarray.view(self, dtype)
+            except TypeError:
+                pass
+            dtype = sb.dtype(dtype)
+            if dtype.fields is None:
+                return self.__array__().view(dtype)
+            return ndarray.view(self, dtype)
+        else:
+            return ndarray.view(self, dtype, type)
 
+
 def fromarrays(arrayList, dtype=None, shape=None, formats=None,
                names=None, titles=None, aligned=False, byteorder=None):
     """ create a record array from a (flat) list of arrays



More information about the Numpy-svn mailing list