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

Function PyArray_View

numpy/core/src/multiarray/convert.c:503–543  ·  view source on GitHub ↗

NUMPY_API * View * steals a reference to type -- accepts NULL */

Source from the content-addressed store, hash-verified

501 * steals a reference to type -- accepts NULL
502 */
503NPY_NO_EXPORT PyObject *
504PyArray_View(PyArrayObject *self, PyArray_Descr *type, PyTypeObject *pytype)
505{
506 PyArrayObject *ret = NULL;
507 PyArray_Descr *dtype;
508 PyTypeObject *subtype;
509 int flags;
510
511 if (pytype) {
512 subtype = pytype;
513 }
514 else {
515 subtype = Py_TYPE(self);
516 }
517
518 dtype = PyArray_DESCR(self);
519 flags = PyArray_FLAGS(self);
520
521 Py_INCREF(dtype);
522 ret = (PyArrayObject *)PyArray_NewFromDescr_int(
523 subtype, dtype,
524 PyArray_NDIM(self), PyArray_DIMS(self), PyArray_STRIDES(self),
525 PyArray_DATA(self),
526 flags, (PyObject *)self, (PyObject *)self,
527 _NPY_ARRAY_ENSURE_DTYPE_IDENTITY);
528 if (ret == NULL) {
529 Py_XDECREF(type);
530 return NULL;
531 }
532
533 if (type != NULL) {
534 if (PyObject_SetAttrString((PyObject *)ret, "dtype",
535 (PyObject *)type) < 0) {
536 Py_DECREF(ret);
537 Py_DECREF(type);
538 return NULL;
539 }
540 Py_DECREF(type);
541 }
542 return (PyObject *)ret;
543}

Callers 13

array_reshapeFunction · 0.85
array_viewFunction · 0.85
array_newbyteorderFunction · 0.85
PyArray_FromArrayFunction · 0.85
PyArray_EnsureArrayFunction · 0.85
PyArray_NewshapeFunction · 0.85
PyArray_SqueezeFunction · 0.85
PyArray_SqueezeSelectedFunction · 0.85
array_subscriptFunction · 0.85
PyArray_MapIterNewFunction · 0.85

Calls 7

PyArray_DESCRFunction · 0.85
PyArray_FLAGSFunction · 0.85
PyArray_NewFromDescr_intFunction · 0.85
PyArray_NDIMFunction · 0.85
PyArray_DIMSFunction · 0.85
PyArray_STRIDESFunction · 0.85
PyArray_DATAFunction · 0.85

Tested by

no test coverage detected