@@ -54,6 +54,8 @@ maintainer email: oliphant.travis@ieee.org
54
54
#include "mem_overlap.h"
55
55
#include "numpyos.h"
56
56
57
+ #include "binop_override.h"
58
+
57
59
/*NUMPY_API
58
60
Compute the size of an array (in number of items)
59
61
*/
@@ -1335,23 +1337,12 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
1335
1337
1336
1338
switch (cmp_op ) {
1337
1339
case Py_LT :
1338
- if (needs_right_binop_forward (obj_self , other , "__gt__" , 0 ) &&
1339
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1340
- /* See discussion in number.c */
1341
- Py_INCREF (Py_NotImplemented );
1342
- return Py_NotImplemented ;
1343
- }
1344
- result = PyArray_GenericBinaryFunction (self , other ,
1345
- n_ops .less );
1340
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1341
+ result = PyArray_GenericBinaryFunction (self , other , n_ops .less );
1346
1342
break ;
1347
1343
case Py_LE :
1348
- if (needs_right_binop_forward (obj_self , other , "__ge__" , 0 ) &&
1349
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1350
- Py_INCREF (Py_NotImplemented );
1351
- return Py_NotImplemented ;
1352
- }
1353
- result = PyArray_GenericBinaryFunction (self , other ,
1354
- n_ops .less_equal );
1344
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1345
+ result = PyArray_GenericBinaryFunction (self , other , n_ops .less_equal );
1355
1346
break ;
1356
1347
case Py_EQ :
1357
1348
/*
@@ -1401,11 +1392,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
1401
1392
return result ;
1402
1393
}
1403
1394
1404
- if (needs_right_binop_forward (obj_self , other , "__eq__" , 0 ) &&
1405
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1406
- Py_INCREF (Py_NotImplemented );
1407
- return Py_NotImplemented ;
1408
- }
1395
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1409
1396
result = PyArray_GenericBinaryFunction (self ,
1410
1397
(PyObject * )other ,
1411
1398
n_ops .equal );
@@ -1478,11 +1465,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
1478
1465
return result ;
1479
1466
}
1480
1467
1481
- if (needs_right_binop_forward (obj_self , other , "__ne__" , 0 ) &&
1482
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1483
- Py_INCREF (Py_NotImplemented );
1484
- return Py_NotImplemented ;
1485
- }
1468
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1486
1469
result = PyArray_GenericBinaryFunction (self , (PyObject * )other ,
1487
1470
n_ops .not_equal );
1488
1471
if (result == NULL ) {
@@ -1502,20 +1485,12 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
1502
1485
}
1503
1486
break ;
1504
1487
case Py_GT :
1505
- if (needs_right_binop_forward (obj_self , other , "__lt__" , 0 ) &&
1506
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1507
- Py_INCREF (Py_NotImplemented );
1508
- return Py_NotImplemented ;
1509
- }
1488
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1510
1489
result = PyArray_GenericBinaryFunction (self , other ,
1511
1490
n_ops .greater );
1512
1491
break ;
1513
1492
case Py_GE :
1514
- if (needs_right_binop_forward (obj_self , other , "__le__" , 0 ) &&
1515
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1516
- Py_INCREF (Py_NotImplemented );
1517
- return Py_NotImplemented ;
1518
- }
1493
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1519
1494
result = PyArray_GenericBinaryFunction (self , other ,
1520
1495
n_ops .greater_equal );
1521
1496
break ;
0 commit comments