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

Function _set_out_array

numpy/core/src/umath/ufunc_object.c:847–868  ·  view source on GitHub ↗

* Checks if 'obj' is a valid output array for a ufunc, i.e. it is * either None or a writeable array, increments its reference count * and stores a pointer to it in 'store'. Returns 0 on success, sets * an exception and returns -1 on failure. */

Source from the content-addressed store, hash-verified

845 * an exception and returns -1 on failure.
846 */
847static int
848_set_out_array(PyObject *obj, PyArrayObject **store)
849{
850 if (obj == Py_None) {
851 /* Translate None to NULL */
852 return 0;
853 }
854 if (PyArray_Check(obj)) {
855 /* If it's an array, store it */
856 if (PyArray_FailUnlessWriteable((PyArrayObject *)obj,
857 "output array") < 0) {
858 return -1;
859 }
860 Py_INCREF(obj);
861 *store = (PyArrayObject *)obj;
862
863 return 0;
864 }
865 PyErr_SetString(PyExc_TypeError, "return arrays must be of ArrayType");
866
867 return -1;
868}
869
870/********* GENERIC UFUNC USING ITERATOR *********/
871

Callers 1

convert_ufunc_argumentsFunction · 0.85

Calls 1

Tested by

no test coverage detected