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

Function descr_subscript

numpy/core/src/multiarray/descriptor.c:3648–3675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3646}
3647
3648static PyObject *
3649descr_subscript(PyArray_Descr *self, PyObject *op)
3650{
3651 if (_check_has_fields(self) < 0) {
3652 return NULL;
3653 }
3654
3655 if (PyUnicode_Check(op)) {
3656 return _subscript_by_name(self, op);
3657 }
3658 else if (_is_list_of_strings(op)) {
3659 return (PyObject *)arraydescr_field_subset_view(self, op);
3660 }
3661 else {
3662 Py_ssize_t i = PyArray_PyIntAsIntp(op);
3663 if (error_converting(i)) {
3664 /* if converting to an int gives a type error, adjust the message */
3665 PyObject *err = PyErr_Occurred();
3666 if (PyErr_GivenExceptionMatches(err, PyExc_TypeError)) {
3667 PyErr_SetString(PyExc_TypeError,
3668 "Field key must be an integer field offset, "
3669 "single field name, or list of field names.");
3670 }
3671 return NULL;
3672 }
3673 return _subscript_by_index(self, i);
3674 }
3675}
3676
3677static PySequenceMethods descr_as_sequence = {
3678 (lenfunc) descr_length, /* sq_length */

Callers

nothing calls this directly

Calls 6

_check_has_fieldsFunction · 0.85
_subscript_by_nameFunction · 0.85
_is_list_of_stringsFunction · 0.85
PyArray_PyIntAsIntpFunction · 0.85
_subscript_by_indexFunction · 0.85

Tested by

no test coverage detected