diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-01-04 07:35:17 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-04 07:35:17 +0000 |
commit | ddaed649c23bbd0ad36cdafdfe9cd92397ce69e3 (patch) | |
tree | 3c2a0f544bf7f08be5c62299b7b1cb3d372dd0f2 /scipy/base/src/arrayobject.c | |
parent | 3b4ee4f1edad964c20bb9dc7a32cedff4113a5cb (diff) | |
download | numpy-ddaed649c23bbd0ad36cdafdfe9cd92397ce69e3.tar.gz |
Added compare to dtypedescr and typeNA dict
Diffstat (limited to 'scipy/base/src/arrayobject.c')
-rw-r--r-- | scipy/base/src/arrayobject.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/scipy/base/src/arrayobject.c b/scipy/base/src/arrayobject.c index 68b843fd6..72db76373 100644 --- a/scipy/base/src/arrayobject.c +++ b/scipy/base/src/arrayobject.c @@ -8408,6 +8408,19 @@ arraydescr_repr(PyArray_Descr *self) return s; } +static int +arraydescr_compare(PyArray_Descr *self, PyObject *other) +{ + if (!PyArray_DescrCheck(other)) { + PyErr_SetString(PyExc_TypeError, + "not a dtypedescr object."); + return -1; + } + if (PyArray_EquivTypes(self, (PyArray_Descr *)other)) return 0; + if (PyArray_CanCastTo(self, (PyArray_Descr *)other)) return -1; + return 1; +} + static PyTypeObject PyArrayDescr_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ @@ -8419,7 +8432,7 @@ static PyTypeObject PyArrayDescr_Type = { 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + (cmpfunc)arraydescr_compare, /* tp_compare */ (reprfunc)arraydescr_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ |