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

Function PyArray_Converter

numpy/core/src/multiarray/conversion_utils.c:41–56  ·  view source on GitHub ↗

NUMPY_API * * Useful to pass as converter function for O& processing in PyArgs_ParseTuple. * * This conversion function can be used with the "O&" argument for * PyArg_ParseTuple. It will immediately return an object of array type * or will convert to a NPY_ARRAY_CARRAY any other object. * * If you use PyArray_Converter, you must DECREF the array when finished * as you get a new reference

Source from the content-addressed store, hash-verified

39 * as you get a new reference to it.
40 */
41NPY_NO_EXPORT int
42PyArray_Converter(PyObject *object, PyObject **address)
43{
44 if (PyArray_Check(object)) {
45 *address = object;
46 Py_INCREF(object);
47 return NPY_SUCCEED;
48 }
49 else {
50 *address = PyArray_FROM_OF(object, NPY_ARRAY_CARRAY);
51 if (*address == NULL) {
52 return NPY_FAIL;
53 }
54 return NPY_SUCCEED;
55 }
56}
57
58/*NUMPY_API
59 * Useful to pass as converter function for O& processing in

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected