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

Function get_handler_name

numpy/core/src/multiarray/alloc.c:569–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569NPY_NO_EXPORT PyObject *
570get_handler_name(PyObject *NPY_UNUSED(self), PyObject *args)
571{
572 PyObject *arr=NULL;
573 if (!PyArg_ParseTuple(args, "|O:get_handler_name", &arr)) {
574 return NULL;
575 }
576 if (arr != NULL && !PyArray_Check(arr)) {
577 PyErr_SetString(PyExc_ValueError, "if supplied, argument must be an ndarray");
578 return NULL;
579 }
580 PyObject *mem_handler;
581 PyDataMem_Handler *handler;
582 PyObject *name;
583 if (arr != NULL) {
584 mem_handler = PyArray_HANDLER((PyArrayObject *) arr);
585 if (mem_handler == NULL) {
586 Py_RETURN_NONE;
587 }
588 Py_INCREF(mem_handler);
589 }
590 else {
591 mem_handler = PyDataMem_GetHandler();
592 if (mem_handler == NULL) {
593 return NULL;
594 }
595 }
596 handler = (PyDataMem_Handler *) PyCapsule_GetPointer(mem_handler, "mem_handler");
597 if (handler == NULL) {
598 Py_DECREF(mem_handler);
599 return NULL;
600 }
601 name = PyUnicode_FromString(handler->name);
602 Py_DECREF(mem_handler);
603 return name;
604}
605
606NPY_NO_EXPORT PyObject *
607get_handler_version(PyObject *NPY_UNUSED(self), PyObject *args)

Callers 3

test_set_policyFunction · 0.85
test_policy_propagationFunction · 0.85

Calls 2

PyArray_HANDLERFunction · 0.85
PyDataMem_GetHandlerFunction · 0.85

Tested by 3

test_set_policyFunction · 0.68
test_policy_propagationFunction · 0.68