MCPcopy Create free account
hub / github.com/numpy/numpy / arraydescr_richcompare

Function arraydescr_richcompare

numpy/core/src/multiarray/descriptor.c:3403–3443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3401}
3402
3403static PyObject *
3404arraydescr_richcompare(PyArray_Descr *self, PyObject *other, int cmp_op)
3405{
3406 PyArray_Descr *new = _convert_from_any(other, 0);
3407 if (new == NULL) {
3408 /* Cannot convert `other` to dtype */
3409 PyErr_Clear();
3410 Py_RETURN_NOTIMPLEMENTED;
3411 }
3412
3413 npy_bool ret;
3414 switch (cmp_op) {
3415 case Py_LT:
3416 ret = !PyArray_EquivTypes(self, new) && PyArray_CanCastTo(self, new);
3417 Py_DECREF(new);
3418 return PyBool_FromLong(ret);
3419 case Py_LE:
3420 ret = PyArray_CanCastTo(self, new);
3421 Py_DECREF(new);
3422 return PyBool_FromLong(ret);
3423 case Py_EQ:
3424 ret = PyArray_EquivTypes(self, new);
3425 Py_DECREF(new);
3426 return PyBool_FromLong(ret);
3427 case Py_NE:
3428 ret = !PyArray_EquivTypes(self, new);
3429 Py_DECREF(new);
3430 return PyBool_FromLong(ret);
3431 case Py_GT:
3432 ret = !PyArray_EquivTypes(self, new) && PyArray_CanCastTo(new, self);
3433 Py_DECREF(new);
3434 return PyBool_FromLong(ret);
3435 case Py_GE:
3436 ret = PyArray_CanCastTo(new, self);
3437 Py_DECREF(new);
3438 return PyBool_FromLong(ret);
3439 default:
3440 Py_DECREF(new);
3441 Py_RETURN_NOTIMPLEMENTED;
3442 }
3443}
3444
3445static int
3446descr_nonzero(PyObject *NPY_UNUSED(self))

Callers

nothing calls this directly

Calls 3

_convert_from_anyFunction · 0.85
PyArray_EquivTypesFunction · 0.85
PyArray_CanCastToFunction · 0.85

Tested by

no test coverage detected