[Numpy-svn] r3248 - in trunk/numpy/core: . tests

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Oct 3 10:15:57 CDT 2006


Author: oliphant
Date: 2006-10-03 10:15:54 -0500 (Tue, 03 Oct 2006)
New Revision: 3248

Modified:
   trunk/numpy/core/records.py
   trunk/numpy/core/tests/test_regression.py
Log:
Allow lists to work with rec.array using fromrecords.py.  But, tuples are the standard for records as the ndarray only allows tuples to be used for records.

Modified: trunk/numpy/core/records.py
===================================================================
--- trunk/numpy/core/records.py	2006-10-03 15:08:04 UTC (rev 3247)
+++ trunk/numpy/core/records.py	2006-10-03 15:15:54 UTC (rev 3248)
@@ -496,7 +496,7 @@
         return fromstring(obj, dtype, shape=shape, offset=offset, **kwds)
 
     elif isinstance(obj, (list, tuple)):
-        if isinstance(obj[0], tuple):
+        if isinstance(obj[0], (tuple, list)):
             return fromrecords(obj, dtype=dtype, shape=shape, **kwds)
         else:
             return fromarrays(obj, dtype=dtype, shape=shape, **kwds)

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2006-10-03 15:08:04 UTC (rev 3247)
+++ trunk/numpy/core/tests/test_regression.py	2006-10-03 15:15:54 UTC (rev 3248)
@@ -263,8 +263,8 @@
     def check_rec_iterate(self,level=rlevel):
         """Ticket #160"""
         descr = N.dtype([('i',int),('f',float),('s','|S3')])
-        x = N.rec.array([[1,1.1,'1.0'],
-                         [2,2.2,'2.0']],dtype=descr)
+        x = N.rec.array([(1,1.1,'1.0'),
+                         (2,2.2,'2.0')],dtype=descr)
         x[0].tolist()
         [i for i in x[0]]
 



More information about the Numpy-svn mailing list