summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-10-03 15:15:54 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-10-03 15:15:54 +0000
commitc7e811cd0f9aef43a90df12bd2daf02ac2cc144f (patch)
tree3676b3aa6d898869c5883ea39ab6f0a5e302fa65 /numpy
parent6cef646e900565129caf116380f75136f155c516 (diff)
downloadnumpy-c7e811cd0f9aef43a90df12bd2daf02ac2cc144f.tar.gz
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.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/records.py2
-rw-r--r--numpy/core/tests/test_regression.py4
2 files changed, 3 insertions, 3 deletions
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]]