@@ -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
/*
@@ -1402,11 +1393,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
1402
1393
return result ;
1403
1394
}
1404
1395
1405
- if (needs_right_binop_forward (obj_self , other , "__eq__" , 0 ) &&
1406
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1407
- Py_INCREF (Py_NotImplemented );
1408
- return Py_NotImplemented ;
1409
- }
1396
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1410
1397
result = PyArray_GenericBinaryFunction (self ,
1411
1398
(PyObject * )other ,
1412
1399
n_ops .equal );
@@ -1480,11 +1467,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
1480
1467
return result ;
1481
1468
}
1482
1469
1483
- if (needs_right_binop_forward (obj_self , other , "__ne__" , 0 ) &&
1484
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1485
- Py_INCREF (Py_NotImplemented );
1486
- return Py_NotImplemented ;
1487
- }
1470
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1488
1471
result = PyArray_GenericBinaryFunction (self , (PyObject * )other ,
1489
1472
n_ops .not_equal );
1490
1473
if (result == NULL ) {
@@ -1504,20 +1487,12 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
1504
1487
}
1505
1488
break ;
1506
1489
case Py_GT :
1507
- if (needs_right_binop_forward (obj_self , other , "__lt__" , 0 ) &&
1508
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1509
- Py_INCREF (Py_NotImplemented );
1510
- return Py_NotImplemented ;
1511
- }
1490
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1512
1491
result = PyArray_GenericBinaryFunction (self , other ,
1513
1492
n_ops .greater );
1514
1493
break ;
1515
1494
case Py_GE :
1516
- if (needs_right_binop_forward (obj_self , other , "__le__" , 0 ) &&
1517
- Py_TYPE (obj_self )-> tp_richcompare != Py_TYPE (other )-> tp_richcompare ) {
1518
- Py_INCREF (Py_NotImplemented );
1519
- return Py_NotImplemented ;
1520
- }
1495
+ RICHCMP_GIVE_UP_IF_NEEDED (obj_self , other );
1521
1496
result = PyArray_GenericBinaryFunction (self , other ,
1522
1497
n_ops .greater_equal );
1523
1498
break ;
0 commit comments