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

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Oct 5 06:45:29 CDT 2006


Author: oliphant
Date: 2006-10-05 06:45:28 -0500 (Thu, 05 Oct 2006)
New Revision: 3256

Modified:
   trunk/numpy/core/records.py
Log:
Use .view in-place of astype in rec.array when new dtype is given.

Modified: trunk/numpy/core/records.py
===================================================================
--- trunk/numpy/core/records.py	2006-10-05 11:37:56 UTC (rev 3255)
+++ trunk/numpy/core/records.py	2006-10-05 11:45:28 UTC (rev 3256)
@@ -513,13 +513,11 @@
             return fromarrays(obj, dtype=dtype, shape=shape, **kwds)
 
     elif isinstance(obj, recarray):
-        copied = 0
         if dtype is not None and (obj.dtype != dtype):
-            new = obj.astype(dtype)
-            copied = 1
+            new = obj.view(dtype)
         else:
             new = obj
-        if copy and not copied:
+        if copy:
             new = new.copy()
         return new
 
@@ -527,13 +525,11 @@
         return fromfile(obj, dtype=dtype, shape=shape, offset=offset)
 
     elif isinstance(obj, sb.ndarray):
-        copied = 0
         if dtype is not None and (obj.dtype != dtype):
-            new = obj.astype(dtype)
-            copied = 1
+            new = obj.view(dtype)
         else:
             new = obj
-        if copy and not copied:
+        if copy:
             new = new.copy()
         res = new.view(recarray)
         if issubclass(res.dtype.type, nt.void):



More information about the Numpy-svn mailing list