summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Kathiresan <ganesh3597@gmail.com>2021-06-12 19:38:50 +0530
committerGanesh Kathiresan <ganesh3597@gmail.com>2021-06-12 19:38:50 +0530
commit1336de4caa574499bcc0d1829197381df1f9dd4b (patch)
tree2a73c677fcbc2636dea3f6e947b9a0a8fd5d3546
parent341736a4e5f0023c8352a553b84d59ba9dd3356d (diff)
downloadnumpy-1336de4caa574499bcc0d1829197381df1f9dd4b.tar.gz
BUG: Remove TypeError on invalid dtypes comparison
-rw-r--r--numpy/core/src/multiarray/descriptor.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index f0dfac55d..3f06acd58 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -3228,7 +3228,22 @@ arraydescr_richcompare(PyArray_Descr *self, PyObject *other, int cmp_op)
{
PyArray_Descr *new = _convert_from_any(other, 0);
if (new == NULL) {
- return NULL;
+ /* Cannot convert `other` to dtype */
+
+ PyErr_Clear();
+
+ switch (cmp_op) {
+ case Py_LT:
+ case Py_LE:
+ case Py_EQ:
+ case Py_GT:
+ case Py_GE:
+ Py_RETURN_FALSE;
+ case Py_NE:
+ Py_RETURN_TRUE;
+ default:
+ Py_RETURN_NOTIMPLEMENTED;
+ }
}
npy_bool ret;