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

Function array_interface_get

numpy/core/src/multiarray/getset.c:267–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267static PyObject *
268array_interface_get(PyArrayObject *self, void *NPY_UNUSED(ignored))
269{
270 PyObject *dict;
271 PyObject *obj;
272
273 dict = PyDict_New();
274 if (dict == NULL) {
275 return NULL;
276 }
277
278 int ret;
279
280 /* dataptr */
281 obj = array_dataptr_get(self, NULL);
282 ret = PyDict_SetItemString(dict, "data", obj);
283 Py_DECREF(obj);
284 if (ret < 0) {
285 Py_DECREF(dict);
286 return NULL;
287 }
288
289 obj = array_protocol_strides_get(self);
290 ret = PyDict_SetItemString(dict, "strides", obj);
291 Py_DECREF(obj);
292 if (ret < 0) {
293 Py_DECREF(dict);
294 return NULL;
295 }
296
297 obj = array_protocol_descr_get(self);
298 ret = PyDict_SetItemString(dict, "descr", obj);
299 Py_DECREF(obj);
300 if (ret < 0) {
301 Py_DECREF(dict);
302 return NULL;
303 }
304
305 obj = arraydescr_protocol_typestr_get(PyArray_DESCR(self), NULL);
306 ret = PyDict_SetItemString(dict, "typestr", obj);
307 Py_DECREF(obj);
308 if (ret < 0) {
309 Py_DECREF(dict);
310 return NULL;
311 }
312
313 obj = array_shape_get(self, NULL);
314 ret = PyDict_SetItemString(dict, "shape", obj);
315 Py_DECREF(obj);
316 if (ret < 0) {
317 Py_DECREF(dict);
318 return NULL;
319 }
320
321 obj = PyLong_FromLong(3);
322 ret = PyDict_SetItemString(dict, "version", obj);
323 Py_DECREF(obj);
324 if (ret < 0) {

Callers

nothing calls this directly

Calls 6

array_dataptr_getFunction · 0.85
array_protocol_descr_getFunction · 0.85
PyArray_DESCRFunction · 0.85
array_shape_getFunction · 0.85

Tested by

no test coverage detected