Lines Matching refs:ndim

256 def strides_from_shape(ndim, shape, itemsize, layout):  argument
259 if ndim == 0:
263 for i in range(ndim-2, -1, -1):
267 for i in range(1, ndim):
313 def getindex(ndim, ind, strides): argument
316 for i in range(ndim):
325 ndim = len(shape)
326 sstrides = strides_from_shape(ndim, shape, 1, 'C')
327 dstrides = strides_from_shape(ndim, shape[::-1], 1, 'C')
330 fr = getindex(ndim, ind, sstrides)
331 to = getindex(ndim, ind[::-1], dstrides)
427 def verify_structure(memlen, itemsize, ndim, shape, strides, offset): argument
441 if ndim <= 0:
442 return ndim == 0 and not shape and not strides
446 imin = sum(strides[j]*(shape[j]-1) for j in range(ndim)
448 imax = sum(strides[j]*(shape[j]-1) for j in range(ndim)
460 memlen, itemsize, ndim, shape, strides, offset = t
462 for i in range(ndim):
470 memlen, itemsize, ndim, shape, strides, offset = t
487 ndim = randrange(maxdim+1)
488 if (ndim == 0):
490 return itemsize, itemsize, ndim, (), (), 0
495 return memlen, itemsize, ndim, (), (), offset
503 shape = [0] * ndim
505 for i in range(ndim):
508 ndim = len(shape)
514 strides = [0] * ndim
515 strides[ndim-1] = itemsize * randrange(-maxstride, maxstride+1)
516 if not zero_stride and strides[ndim-1] == 0:
517 strides[ndim-1] = itemsize
519 for i in range(ndim-2, -1, -1):
529 imin = sum(strides[j]*(shape[j]-1) for j in range(ndim)
531 imax = sum(strides[j]*(shape[j]-1) for j in range(ndim)
541 return memlen, itemsize, ndim, shape, strides, offset
556 def randslice_from_shape(ndim, shape): argument
559 lslices = [0] * ndim
560 rslices = [0] * ndim
561 for n in range(ndim):
572 ndim = randrange(1, maxdim+1)
580 lshape = [0]*ndim; rshape = [0]*ndim
581 lslices = [0]*ndim; rslices = [0]*ndim
583 for n in range(ndim):
619 memlen, itemsize, ndim, shape, strides, offset = t
625 memlen, itemsize, ndim, shape, strides, offset = t
650 if exporter.ndim == 0 or itemsize != bytelen:
674 ndim = randrange(4, 6)
676 yield [randrange(minshape, 5) for _ in range(ndim)]
677 ndim = randrange(2, 4)
679 yield [randrange(minshape, 5) for _ in range(ndim)]
690 def genslices_ndim(ndim, shape): argument
692 iterables = [genslices(shape[n]) for n in range(ndim)]
708 def rslices_ndim(ndim, shape, iterations=5): argument
712 yield tuple(rslice(shape[n]) for n in range(ndim))
715 yield tuple(rslice(shape[n], allow_empty=True) for n in range(ndim))
717 yield tuple(slice(0,1,0) for _ in range(ndim))
766 ndim={1}, shape=-1, strides=-1, argument
782 self.assertGreater(ndim, 0)
785 for n in range(1, ndim):
791 suboffsets = [suboffset0] + [-1 for v in range(ndim-1)]
804 self.assertEqual(result.ndim, ndim)
877 if ndim == 0:
932 self.assertEqual(m.ndim, ndim)
938 n = 1 if ndim == 0 else len(lst)
977 ndim = ex.ndim
985 ndim = 1
992 ndim=ndim, shape=shape, strides=strides,
1055 if ex1.ndim == 0 or (ex1.ndim == 1 and shape and strides):
1057 if ex2 and ex2.ndim == 1 and shape and strides:
1281 ndim=0, shape=(), strides=(),
1293 ndim=1, shape=(nitems,), strides=(itemsize,),
1314 ndim=1, shape=shape, strides=strides,
1324 for ndim in range(5):
1325 shape_t = [randrange(2, 10) for _ in range(ndim)]
1333 if ndim == 0 and flags == ND_PIL:
1339 strides = strides_from_shape(ndim, shape, itemsize, 'C')
1343 ndim=ndim, shape=shape, strides=strides,
1354 ndim=ndim, shape=shape, strides=strides,
1361 strides = strides_from_shape(ndim, shape, itemsize, 'F')
1365 ndim=ndim, shape=shape, strides=strides,
1697 ndim = len(shape_t)
1708 for slices in rslices_ndim(ndim, shape):
1729 ndim = len(shape_t)
1743 for slices in rslices_ndim(ndim, shape):
1813 ndim=nd.ndim, shape=nd.shape, strides=nd.strides,
1818 ndim = len(shape_t)
1826 lslices, rslices = randslice_from_shape(ndim, shape)
1887 ndim=z.ndim, shape=z.shape, strides=z.strides,
1972 ndim=zl.ndim, shape=zl.shape,
1977 ndim=zr.ndim, shape=zr.shape,
2349 ndim = len(shape)
2350 strides = strides_from_shape(ndim, shape, 1, 'C')
2355 ndim=ndim, shape=shape, strides=strides,
2362 ndim=ndim, shape=shape, strides=strides,
2371 ndim=ndim, shape=shape, strides=strides,
2381 lst = [items] if ndim == 0 else items
2384 ndim=1, shape=[ex.nbytes], strides=(1,),
2396 ndim = len(shape)
2397 strides = strides_from_shape(ndim, shape, 1, 'F')
2402 ndim=ndim, shape=shape, strides=strides,
2409 ndim=ndim, shape=shape, strides=strides,
2419 ndim = len(shape)
2424 ndim=ndim, shape=shape, strides=ex.strides,
2431 ndim=ndim, shape=shape, strides=ex.strides,
2681 ndim=1, shape=[31*srcsize], strides=(1,),
2689 ndim=1, shape=[31], strides=(srcsize,),
2700 ndim=1, shape=destshape, strides=(1,),
2711 ndim=0, shape=(), strides=(),
2755 ndim = len(tshape)
2760 ndim=ndim, shape=tshape, strides=strides,
2766 ndim = len(shape)
2772 ndim=ndim, shape=shape, strides=strides,
2777 ndim=ndim, shape=shape, strides=strides,
2790 self.assertEqual(m2.ndim, 1)
2801 self.assertEqual(m2.ndim, 1)
4303 ndim=1, shape=[12], strides=[1],
4323 ndim=1, shape=[12], strides=[1],
4336 ndim=1, shape=[12], strides=[1],
4345 ndim=1, shape=[12], strides=[1],
4365 ndim=1, shape=[12], strides=[1],
4380 ndim=1, shape=[12], strides=[1],