From c7e811cd0f9aef43a90df12bd2daf02ac2cc144f Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Tue, 3 Oct 2006 15:15:54 +0000 Subject: 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. --- numpy/core/records.py | 2 +- numpy/core/tests/test_regression.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'numpy') diff --git a/numpy/core/records.py b/numpy/core/records.py index 299a1a9f4..c9d62d2f5 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -496,7 +496,7 @@ def array(obj, dtype=None, shape=None, offset=0, strides=None, formats=None, 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) diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index cbeb5a15c..f49697bad 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -263,8 +263,8 @@ class test_regression(NumpyTestCase): 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]] -- cgit v1.2.1