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

Function arrayflags_getitem

numpy/core/src/multiarray/flagsobject.c:446–564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444};
445
446static PyObject *
447arrayflags_getitem(PyArrayFlagsObject *self, PyObject *ind)
448{
449 char *key = NULL;
450 char buf[16];
451 int n;
452 if (PyUnicode_Check(ind)) {
453 PyObject *tmp_str;
454 tmp_str = PyUnicode_AsASCIIString(ind);
455 if (tmp_str == NULL) {
456 return NULL;
457 }
458 key = PyBytes_AS_STRING(tmp_str);
459 n = PyBytes_GET_SIZE(tmp_str);
460 if (n > 16) {
461 Py_DECREF(tmp_str);
462 goto fail;
463 }
464 memcpy(buf, key, n);
465 Py_DECREF(tmp_str);
466 key = buf;
467 }
468 else if (PyBytes_Check(ind)) {
469 key = PyBytes_AS_STRING(ind);
470 n = PyBytes_GET_SIZE(ind);
471 }
472 else {
473 goto fail;
474 }
475 switch(n) {
476 case 1:
477 switch(key[0]) {
478 case 'C':
479 return arrayflags_contiguous_get(self, NULL);
480 case 'F':
481 return arrayflags_fortran_get(self, NULL);
482 case 'W':
483 return arrayflags_writeable_get(self, NULL);
484 case 'B':
485 return arrayflags_behaved_get(self, NULL);
486 case 'O':
487 return arrayflags_owndata_get(self, NULL);
488 case 'A':
489 return arrayflags_aligned_get(self, NULL);
490 case 'X':
491 return arrayflags_writebackifcopy_get(self, NULL);
492 default:
493 goto fail;
494 }
495 break;
496 case 2:
497 if (strncmp(key, "CA", n) == 0) {
498 return arrayflags_carray_get(self, NULL);
499 }
500 if (strncmp(key, "FA", n) == 0) {
501 return arrayflags_farray_get(self, NULL);
502 }
503 break;

Callers

nothing calls this directly

Calls 3

arrayflags_farray_getFunction · 0.85
arrayflags_fnc_getFunction · 0.85
arrayflags_forc_getFunction · 0.85

Tested by

no test coverage detected