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

Function arrayflags_setitem

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

Source from the content-addressed store, hash-verified

564}
565
566static int
567arrayflags_setitem(PyArrayFlagsObject *self, PyObject *ind, PyObject *item)
568{
569 char *key;
570 char buf[16];
571 int n;
572 if (PyUnicode_Check(ind)) {
573 PyObject *tmp_str;
574 tmp_str = PyUnicode_AsASCIIString(ind);
575 key = PyBytes_AS_STRING(tmp_str);
576 n = PyBytes_GET_SIZE(tmp_str);
577 if (n > 16) n = 16;
578 memcpy(buf, key, n);
579 Py_DECREF(tmp_str);
580 key = buf;
581 }
582 else if (PyBytes_Check(ind)) {
583 key = PyBytes_AS_STRING(ind);
584 n = PyBytes_GET_SIZE(ind);
585 }
586 else {
587 goto fail;
588 }
589 if (((n==9) && (strncmp(key, "WRITEABLE", n) == 0)) ||
590 ((n==1) && (strncmp(key, "W", n) == 0))) {
591 return arrayflags_writeable_set(self, item, NULL);
592 }
593 else if (((n==7) && (strncmp(key, "ALIGNED", n) == 0)) ||
594 ((n==1) && (strncmp(key, "A", n) == 0))) {
595 return arrayflags_aligned_set(self, item, NULL);
596 }
597 else if (((n==15) && (strncmp(key, "WRITEBACKIFCOPY", n) == 0)) ||
598 ((n==1) && (strncmp(key, "X", n) == 0))) {
599 return arrayflags_writebackifcopy_set(self, item, NULL);
600 }
601
602 fail:
603 PyErr_SetString(PyExc_KeyError, "Unknown flag");
604 return -1;
605}
606
607static char *
608_torf_(int flags, int val)

Callers

nothing calls this directly

Calls 3

arrayflags_writeable_setFunction · 0.85
arrayflags_aligned_setFunction · 0.85

Tested by

no test coverage detected