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

Function _unpack_field

numpy/core/src/multiarray/common.c:309–328  ·  view source on GitHub ↗

* unpack tuple of dtype->fields (descr, offset, title[not-needed]) * * @param "value" should be the tuple. * * @return "descr" will be set to the field's dtype * @return "offset" will be set to the field's offset * * returns -1 on failure, 0 on success. */

Source from the content-addressed store, hash-verified

307 * returns -1 on failure, 0 on success.
308 */
309NPY_NO_EXPORT int
310_unpack_field(PyObject *value, PyArray_Descr **descr, npy_intp *offset)
311{
312 PyObject * off;
313 if (PyTuple_GET_SIZE(value) < 2) {
314 return -1;
315 }
316 *descr = (PyArray_Descr *)PyTuple_GET_ITEM(value, 0);
317 off = PyTuple_GET_ITEM(value, 1);
318
319 if (PyLong_Check(off)) {
320 *offset = PyLong_AsSsize_t(off);
321 }
322 else {
323 PyErr_SetString(PyExc_IndexError, "can't convert offset");
324 return -1;
325 }
326
327 return 0;
328}
329
330/*
331 * check whether arrays with datatype dtype might have object fields. This will

Callers 1

_get_field_viewFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected