diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-07-19 15:24:47 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-07-19 15:24:47 +0000 |
commit | 5172ae3f46a2da8935e643c7ee6a2086fca3956c (patch) | |
tree | 2ec874eaea07cca772965d8a72a24d7b61cc1c30 /numpy/core/src/arrayobject.c | |
parent | b884d998f468f89704dae39ef4d1e0b2bc71a9f3 (diff) | |
download | numpy-5172ae3f46a2da8935e643c7ee6a2086fca3956c.tar.gz |
Fix up rec.array when dtype and formats are both None for cases that support it. Alter dtype=object parsing so that tuples and lists are recognized as sequences.
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index c20bc4fa4..e0dab85c2 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -6913,10 +6913,13 @@ object_depth_and_dimension(PyObject *s, int max, intp *dims) { intp *newdims, *test_dims; int nd, test_nd; - int i; + int i, islist; intp size; + PyObject *obj; - if (!PyList_Check(s) || ((size=PyList_GET_SIZE(s)) == 0)) + islist = PyList_Check(s); + if (!(islist || PyTuple_Check(s)) || + ((size = PySequence_Size(s)) == 0)) return 0; if (max < 2) { if (max < 1) return 0; @@ -6925,11 +6928,13 @@ object_depth_and_dimension(PyObject *s, int max, intp *dims) } newdims = PyDimMem_NEW(2*(max-1)); test_dims = newdims + (max-1); - nd = object_depth_and_dimension(PyList_GET_ITEM(s, 0), - max-1, newdims); + if (islist) obj = PyList_GET_ITEM(s, 0); + else obj = PyTuple_GET_ITEM(s, 0); + nd = object_depth_and_dimension(obj, max-1, newdims); for (i=1; i<size; i++) { - test_nd = object_depth_and_dimension(PyList_GET_ITEM(s, i), - max-1, test_dims); + if (islist) obj = PyList_GET_ITEM(s, 0); + else obj = PyTuple_GET_ITEM(s, 0); + test_nd = object_depth_and_dimension(obj, max-1, test_dims); if ((nd != test_nd) || (!PyArray_CompareLists(newdims, test_dims, nd))) { nd = 0; |