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

Function PyArray_SubclassWrap

numpy/core/src/multiarray/ctors.c:4046–4063  ·  view source on GitHub ↗

* Calls arr_of_subclass.__array_wrap__(towrap), in order to make 'towrap' * have the same ndarray subclass as 'arr_of_subclass'. */

Source from the content-addressed store, hash-verified

4044 * have the same ndarray subclass as 'arr_of_subclass'.
4045 */
4046NPY_NO_EXPORT PyArrayObject *
4047PyArray_SubclassWrap(PyArrayObject *arr_of_subclass, PyArrayObject *towrap)
4048{
4049 PyObject *wrapped = PyObject_CallMethodObjArgs((PyObject *)arr_of_subclass,
4050 npy_ma_str_array_wrap, (PyObject *)towrap, NULL);
4051 if (wrapped == NULL) {
4052 return NULL;
4053 }
4054 if (!PyArray_Check(wrapped)) {
4055 PyErr_SetString(PyExc_RuntimeError,
4056 "ndarray subclass __array_wrap__ method returned an "
4057 "object which was not an instance of an ndarray subclass");
4058 Py_DECREF(wrapped);
4059 return NULL;
4060 }
4061
4062 return (PyArrayObject *)wrapped;
4063}

Callers 3

PyArray_SqueezeFunction · 0.85
PyArray_SqueezeSelectedFunction · 0.85
array_richcompareFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected