Ejemplo n.º 1
0
 def testDynamicUpdateSliceInDim(self):
   rng = jtu.rand_default()
   x = rng((6, 7), onp.int32)
   y = rng((3, 7), onp.int32)
   z = x.copy()
   z[2:5] = y
   self.assertAllClose(npe.dynamic_update_slice_in_dim(x, y, 2, 0), z,
                       check_dtypes=True)
Ejemplo n.º 2
0
  def test_from_dask(self, einstr, dtype):
    r = jtu.rand_default()
    if '->' in einstr:
      input_str, _ = einstr.split('->')
    else:
      input_str = einstr
    input_names = input_str.split(',')

    dims = itertools.cycle([2, 3, 4])
    shapes = defaultdict(lambda: next(dims))
    input_shapes = [tuple(shapes[c] for c in names.replace('...', '01'))
                    for names in input_names]
    operands = [r(shape, dtype) for shape in input_shapes]

    self._check(einstr, *operands)
Ejemplo n.º 3
0
 def testDynamicSliceInDim(self):
     rng = jtu.rand_default()
     x = rng((6, 7), onp.int32)
     self.assertAllClose(npe.dynamic_slice_in_dim(x, 2, 3),
                         x[2:5],
                         check_dtypes=True)