| 882 | |
| 883 | |
| 884 | NPY_NO_EXPORT PyObject * |
| 885 | array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) |
| 886 | { |
| 887 | PyArrayObject *array_other; |
| 888 | PyObject *obj_self = (PyObject *)self; |
| 889 | PyObject *result = NULL; |
| 890 | |
| 891 | switch (cmp_op) { |
| 892 | case Py_LT: |
| 893 | RICHCMP_GIVE_UP_IF_NEEDED(obj_self, other); |
| 894 | result = PyArray_GenericBinaryFunction( |
| 895 | (PyObject *)self, other, n_ops.less); |
| 896 | break; |
| 897 | case Py_LE: |
| 898 | RICHCMP_GIVE_UP_IF_NEEDED(obj_self, other); |
| 899 | result = PyArray_GenericBinaryFunction( |
| 900 | (PyObject *)self, other, n_ops.less_equal); |
| 901 | break; |
| 902 | case Py_EQ: |
| 903 | RICHCMP_GIVE_UP_IF_NEEDED(obj_self, other); |
| 904 | /* |
| 905 | * The ufunc does not support void/structured types, so these |
| 906 | * need to be handled specifically. Only a few cases are supported. |
| 907 | */ |
| 908 | |
| 909 | if (PyArray_TYPE(self) == NPY_VOID) { |
| 910 | array_other = (PyArrayObject *)PyArray_FROM_O(other); |
| 911 | /* |
| 912 | * If not successful, indicate that the items cannot be compared |
| 913 | * this way. |
| 914 | */ |
| 915 | if (array_other == NULL) { |
| 916 | /* 2015-05-07, 1.10 */ |
| 917 | if (DEPRECATE_silence_error( |
| 918 | "elementwise == comparison failed and returning scalar " |
| 919 | "instead; this will raise an error in the future.") < 0) { |
| 920 | return NULL; |
| 921 | } |
| 922 | Py_INCREF(Py_NotImplemented); |
| 923 | return Py_NotImplemented; |
| 924 | } |
| 925 | |
| 926 | result = _void_compare(self, array_other, cmp_op); |
| 927 | Py_DECREF(array_other); |
| 928 | return result; |
| 929 | } |
| 930 | |
| 931 | result = PyArray_GenericBinaryFunction( |
| 932 | (PyObject *)self, (PyObject *)other, n_ops.equal); |
| 933 | break; |
| 934 | case Py_NE: |
| 935 | RICHCMP_GIVE_UP_IF_NEEDED(obj_self, other); |
| 936 | /* |
| 937 | * The ufunc does not support void/structured types, so these |
| 938 | * need to be handled specifically. Only a few cases are supported. |
| 939 | */ |
| 940 | |
| 941 | if (PyArray_TYPE(self) == NPY_VOID) { |
no test coverage detected