From 5172ae3f46a2da8935e643c7ee6a2086fca3956c Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Wed, 19 Jul 2006 15:24:47 +0000 Subject: 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. --- numpy/core/src/arrayobject.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'numpy/core/src/arrayobject.c') 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