diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-01-25 23:58:35 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-25 23:58:35 +0000 |
commit | 656b8ba14074b62b0560748324fd66186410e396 (patch) | |
tree | 7000ce3372fa8b818bfd91fe475f8cbd6d8c9d73 | |
parent | 2a71223ff0ca8ff7c9f7cb69c73de19ae19c1782 (diff) | |
download | numpy-656b8ba14074b62b0560748324fd66186410e396.tar.gz |
Simplify hasobject checks by setting hasobject to 1 for OBJECT_Descr data-type descriptor.
-rw-r--r-- | numpy/core/src/arrayobject.c | 6 | ||||
-rw-r--r-- | numpy/core/src/arraytypes.inc.src | 3 | ||||
-rw-r--r-- | numpy/core/src/multiarraymodule.c | 9 |
3 files changed, 8 insertions, 10 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 33a86efe5..033eef26d 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -3762,10 +3762,10 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, /* It is bad to have unitialized OBJECT pointers */ /* which could also be sub-fields of a VOID array */ - if (descr == &OBJECT_Descr || descr->hasobject) { - if (descr->hasobject) { + if (descr->hasobject) { + if (descr != &OBJECT_Descr) { PyErr_SetString(PyExc_TypeError, - "fields with object members "\ + "fields with object members " \ "not yet supported."); goto fail; } diff --git a/numpy/core/src/arraytypes.inc.src b/numpy/core/src/arraytypes.inc.src index fe4d00494..96d2386e8 100644 --- a/numpy/core/src/arraytypes.inc.src +++ b/numpy/core/src/arraytypes.inc.src @@ -1744,6 +1744,7 @@ static PyArray_Descr @from@_Descr = { #NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object# #kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT# #endian= |*3, =*14, |# +#isobject= 0*17,1# */ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = { @@ -1794,7 +1795,7 @@ static PyArray_Descr @from@_Descr = { &Py@NAME@ArrType_Type, PyArray_@kind@LTR, PyArray_@from@LTR, - '@endian@', 0, + '@endian@', @isobject@, PyArray_@from@, @num@*sizeof(@fromtyp@), _ALIGN(@fromtyp@), diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c index 966886d04..dd588d4ae 100644 --- a/numpy/core/src/multiarraymodule.c +++ b/numpy/core/src/multiarraymodule.c @@ -3459,8 +3459,7 @@ _convert_from_array_descr(PyObject *obj) "two fields with the same name"); goto fail; } - if (!hasobject && (conv->hasobject || \ - conv->type_num == PyArray_OBJECT)) + if (!hasobject && conv->hasobject) hasobject = 1; tup = PyTuple_New(2); PyTuple_SET_ITEM(tup, 0, (PyObject *)conv); @@ -3518,8 +3517,7 @@ _convert_from_list(PyObject *obj, int align, int try_descr) tup = PyTuple_New(2); key = PyString_FromFormat("f%d", i+1); ret = PyArray_DescrConverter(PyList_GET_ITEM(obj, i), &conv); - if (!hasobject && (conv->hasobject || \ - conv->type_num == PyArray_OBJECT)) + if (!hasobject && conv->hasobject) hasobject=1; PyTuple_SET_ITEM(tup, 0, (PyObject *)conv); if (align) { @@ -3688,8 +3686,7 @@ _convert_from_dict(PyObject *obj, int align) tup = PyTuple_New(len); descr = PyObject_GetItem(descrs, index); ret = PyArray_DescrConverter(descr, &newdescr); - if (!hasobject && (newdescr->hasobject || \ - newdescr->type_num == PyArray_OBJECT)) + if (!hasobject && newdescr->hasobject) hasobject = 1; Py_DECREF(descr); PyTuple_SET_ITEM(tup, 0, (PyObject *)newdescr); |