Lines Matching defs:shape

48      base object. shape, strides, suboffsets and format are read-only for
51 A memoryview's buffer is a private copy of the exporter's buffer. shape,
55 buffer copies share shape, strides and suboffsets. In this case, the
225 ((view)->shape[0] == 1 || (view)->strides[0] == (view)->itemsize)
243 with the same logical structure: format, itemsize, ndim and shape
300 if (dest->shape[i] != src->shape[i])
302 if (dest->shape[i] == 0)
327 sizeof(mem) == shape[0] * itemsize. */
329 copy_base(const Py_ssize_t *shape, Py_ssize_t itemsize,
335 Py_ssize_t size = shape[0] * itemsize;
344 for (i=0, p=mem; i < shape[0]; p+=itemsize, sptr+=sstrides[0], i++) {
348 for (i=0, p=mem; i < shape[0]; p+=itemsize, dptr+=dstrides[0], i++) {
357 have the same ndim, shape and itemsize. */
359 copy_rec(const Py_ssize_t *shape, Py_ssize_t ndim, Py_ssize_t itemsize,
369 copy_base(shape, itemsize,
376 for (i = 0; i < shape[0]; dptr+=dstrides[0], sptr+=sstrides[0], i++) {
380 copy_rec(shape+1, ndim-1, itemsize,
400 mem = PyMem_Malloc(dest->shape[0] * dest->itemsize);
407 copy_base(dest->shape, dest->itemsize,
432 mem = PyMem_Malloc(dest->shape[dest->ndim-1] * dest->itemsize);
439 copy_rec(dest->shape, dest->ndim, dest->itemsize,
460 view->strides[i] = view->strides[i+1] * view->shape[i+1];
473 view->strides[i] = view->strides[i-1] * view->shape[i-1];
487 assert(src->shape != NULL);
499 /* shape is constant and shared: the logical representation of the
538 /* Copy shape and strides. Reconstruct missing values. */
545 dest->shape = NULL;
550 dest->shape[0] = src->shape ? src->shape[0] : src->len / src->itemsize;
556 dest->shape[i] = src->shape[i];
579 /* len = product(shape) * itemsize */
587 len *= view->shape[i];
642 mv->view.shape = mv->ob_array;
655 The new memoryview has full buffer information: shape and strides
692 /* Register an incomplete view: shape, strides, suboffsets and flags still
834 of src->shape, src->strides and src->suboffsets.
850 assert(src->shape != NULL);
876 /* shape and strides */
878 dest->shape[i] = src->shape[i];
1008 fb->view.shape = fb->array;
1117 /* Casting format and shape */
1204 assert(view->shape == mv->ob_array);
1242 view->shape[0] = view->len / view->itemsize;
1257 copy_shape(Py_ssize_t *shape, const PyObject *seq, Py_ssize_t ndim,
1267 "memoryview.cast(): elements of shape must be integers");
1275 /* In general elements of shape may be 0, but not for casting. */
1277 "memoryview.cast(): elements of shape must be integers > 0");
1282 "memoryview.cast(): product(shape) > SSIZE_MAX");
1286 shape[i] = x;
1292 /* Cast a 1-D array to a new shape. The result array will be C-contiguous.
1296 cast_to_ND(PyMemoryViewObject *mv, const PyObject *shape, int ndim)
1303 assert(view->shape == mv->ob_array);
1309 view->shape = NULL;
1314 len = copy_shape(view->shape, shape, ndim, view->itemsize);
1322 "memoryview: product(shape) * itemsize != buffer size");
1338 if (view->shape[i] == 0)
1350 If 'shape' is given, the 1-D view from the previous step will
1351 be cast to a C-contiguous view with new shape and strides.
1360 shape: object = NULL
1362 Cast a memoryview to a new format or shape.
1367 PyObject *shape)
1380 if ((shape || self->view.ndim != 1) && zero_in_shape(self)) {
1382 "memoryview: cannot cast view with zeros in shape or strides");
1385 if (shape) {
1386 CHECK_LIST_OR_TUPLE(shape)
1387 ndim = PySequence_Fast_GET_SIZE(shape);
1408 if (shape && cast_to_ND(mv, shape, (int)ndim) < 0)
1463 view->itemsize is the _previous_ itemsize. If shape is present,
1464 the equality product(shape) * itemsize = len still holds at this
1509 /* product(shape) * itemsize = len and calcsize(format) = itemsize
1512 view->shape = NULL;
2068 tolist_base(PyMemoryViewObject *self, const char *ptr, const Py_ssize_t *shape,
2075 lst = PyList_New(shape[0]);
2079 for (i = 0; i < shape[0]; ptr+=strides[0], i++) {
2095 tolist_rec(PyMemoryViewObject *self, const char *ptr, Py_ssize_t ndim, const Py_ssize_t *shape,
2103 assert(shape != NULL);
2107 return tolist_base(self, ptr, shape, strides, suboffsets, fmt);
2109 lst = PyList_New(shape[0]);
2113 for (i = 0; i < shape[0]; ptr+=strides[0], i++) {
2115 item = tolist_rec(self, xptr, ndim-1, shape+1,
2152 return tolist_base(self, view->buf, view->shape,
2157 return tolist_rec(self, view->buf, view->ndim, view->shape,
2287 assert(view->shape);
2290 nitems = view->shape[dim];
2407 slicelength = PySlice_AdjustIndices(base->shape[dim], &start, &stop, step);
2422 base->shape[dim] = slicelength;
2593 dest.shape = &arrays[0]; dest.shape[0] = view->shape[0];
2601 dest.len = dest.shape[0] * dest.itemsize;
2638 return self->view.ndim == 0 ? 1 : self->view.shape[0];
2779 cmp_base(const char *p, const char *q, const Py_ssize_t *shape,
2787 for (i = 0; i < shape[0]; p+=pstrides[0], q+=qstrides[0], i++) {
2802 Py_ssize_t ndim, const Py_ssize_t *shape,
2811 assert(shape != NULL);
2816 return cmp_base(p, q, shape,
2822 for (i = 0; i < shape[0]; p+=pstrides[0], q+=qstrides[0], i++) {
2825 equal = cmp_rec(xp, xq, ndim-1, shape+1,
2906 equal = cmp_base(vv->buf, ww->buf, vv->shape,
2912 equal = cmp_rec(vv->buf, ww->buf, vv->ndim, vv->shape,
3060 return _IntTupleFromSsizet(self->view.ndim, self->view.shape);
3128 "A tuple of ndim integers giving the shape of the memory\n"
3150 {"shape", (getter)memory_shape_get, NULL, memory_shape_doc},