Пример #1
0
 def init(self):
     for mode in ['valid', 'full', 'same']:
         for dtype in util.TYPES.FLOAT:
             for cmd1, shape1 in util.gen_random_arrays(
                     "R",
                     3,
                     min_ndim=1,
                     max_dim=10,
                     samples_in_each_ndim=1,
                     dtype=dtype,
                     no_views=True):
                 if util.prod(shape1) <= 0:
                     continue
                 # Notice, the second shape must have the same number of dimension as the first one
                 # and the max dimension cannot be larger than in the first shape
                 # Finally, dimensions above 5 simple take too long
                 max_dim = min(min(shape1), 5)
                 for cmd2, shape2 in util.gen_random_arrays(
                         "R",
                         len(shape1),
                         min_ndim=len(shape1),
                         max_dim=max_dim,
                         samples_in_each_ndim=1,
                         dtype=dtype,
                         no_views=True):
                     if util.prod(shape2) > 0:
                         cmd = "R = bh.random.RandomState(42); a=%s; v=%s;" % (
                             cmd1, cmd2)
                         yield (cmd, mode)
Пример #2
0
 def init(self):
     for mode in ['same', 'valid', 'full']:
         for dtype in util.TYPES.FLOAT:
             for cmd1, shape1 in util.gen_random_arrays("R", 1, min_ndim=1, samples_in_each_ndim=1, dtype=dtype):
                 for cmd2, shape2 in util.gen_random_arrays("R", 1, min_ndim=1, samples_in_each_ndim=1, dtype=dtype):
                     if shape1[0] > 0 and shape2[0] > 0:
                         cmd = "R = bh.random.RandomState(42); a=%s; v=%s;" % (cmd1, cmd2)
                         yield (cmd, mode)
 def init(self):
     for cmd, shape in util.gen_random_arrays("R",
                                              4,
                                              min_ndim=2,
                                              dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         yield cmd
Пример #4
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 4, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         for i in range(len(shape)):
             yield (cmd, i)
         for i in range(len(shape)):
             yield (cmd, -i)
Пример #5
0
 def init(self):
     for mode in ['same', 'valid', 'full']:
         for dtype in util.TYPES.FLOAT:
             for cmd1, shape1 in util.gen_random_arrays(
                     "R", 1, min_ndim=1, samples_in_each_ndim=1,
                     dtype=dtype):
                 for cmd2, shape2 in util.gen_random_arrays(
                         "R",
                         1,
                         min_ndim=1,
                         samples_in_each_ndim=1,
                         dtype=dtype):
                     if shape1[0] > 0 and shape2[0] > 0:
                         cmd = "R = bh.random.RandomState(42); a=%s; v=%s;" % (
                             cmd1, cmd2)
                         yield (cmd, mode)
Пример #6
0
 def init(self):
     for dtype in _info.numpy_types():
         dtype = "np.%s"%dtype.name
         for cmd, shape in util.gen_random_arrays("R", 1, min_ndim=1, samples_in_each_ndim=1,
                                                  dtype=dtype, no_views=True):
             cmd = "R = bh.random.RandomState(42); res=%s; " % cmd
             yield cmd
Пример #7
0
 def init(self):
     for mode in ['valid', 'full', 'same']:
         for dtype in util.TYPES.FLOAT:
             for cmd1, shape1 in util.gen_random_arrays("R", 3, min_ndim=1, max_dim=10, samples_in_each_ndim=1,
                                                        dtype=dtype, no_views=True):
                 if util.prod(shape1) <= 0:
                     continue
                 # Notice, the second shape must have the same number of dimension as the first one
                 # and the max dimension cannot be larger than in the first shape
                 # Finally, dimensions above 5 simple take too long
                 max_dim = min(min(shape1), 5)
                 for cmd2, shape2 in util.gen_random_arrays("R", len(shape1), min_ndim=len(shape1), max_dim=max_dim,
                                                            samples_in_each_ndim=1, dtype=dtype, no_views=True):
                     if util.prod(shape2) > 0:
                         cmd = "R = bh.random.RandomState(42); a=%s; v=%s;" % (cmd1, cmd2)
                         yield (cmd, mode)
Пример #8
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 3, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         nelem = functools.reduce(operator.mul, shape)
         if nelem > 0:
             for op in ['argmin', 'argmax']:
                 yield (cmd, op)
Пример #9
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 3, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         for op in ["sum", "prod", "all", "any"]:
             yield (cmd, op, None)
             for axis in range(len(shape)):
                 yield (cmd, op, axis)
Пример #10
0
 def init(self):
     for ary, shape in util.gen_random_arrays("R", 3, max_dim=50, dtype="np.float64"):
         nelem = functools.reduce(operator.mul, shape)
         if nelem == 0:
             continue
         cmd = "R = bh.random.RandomState(42); a = %s; " % ary
         yield cmd
Пример #11
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 4, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         for i in range(len(shape)):
             yield (cmd, i)
         for i in range(len(shape)):
             yield (cmd, -i)
Пример #12
0
 def init(self):
     for ary, shape in util.gen_random_arrays("R", 3, max_dim=50, dtype="np.float64"):
         nelem = functools.reduce(operator.mul, shape)
         if nelem == 0:
             continue
         cmd = "R = bh.random.RandomState(42); a=%s; " % ary
         cmd += "m = R.random_integers(0, 1, size=a.shape, dtype=np.bool, bohrium=BH); "
         yield (cmd)
 def init(self):
     for cmd, shape in util.gen_random_arrays("R",
                                              4,
                                              min_ndim=2,
                                              dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         for offset in range(-min(shape) + 1, min(shape)):
             yield (cmd, offset)
Пример #14
0
 def init(self):
     for dtype in _info.numpy_types():
         dtype = "np.%s"%dtype.name
         for cmd, shape in util.gen_random_arrays("R", 2, min_ndim=1, samples_in_each_ndim=1,
                                                  dtype=dtype, no_views=True):
             cmd = "R = bh.random.RandomState(42); res=%s; " \
                   "m = R.random_integers(0, 1, size=res.shape, dtype=np.bool, bohrium=BH); " % cmd
             yield (cmd, dtype)
 def init(self):
     for rand_cmd, shape in util.gen_random_arrays("R",
                                                   4,
                                                   min_ndim=1,
                                                   dtype="np.float32"):
         for axis in range(len(shape)):
             cmd = "R = bh.random.RandomState(42); a = %s; b = %s; " % (
                 rand_cmd, rand_cmd)
             yield (cmd, axis)
Пример #16
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 4, min_ndim=2, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         for offset in range(-min(shape) + 1, min(shape)):
             for axis1 in range(len(shape)):
                 for axis2 in range(len(shape)):
                     if axis1 == axis2:
                         continue
                     yield (cmd, offset, axis1, axis2)
Пример #17
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 3, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         nelem = functools.reduce(operator.mul, shape)
         if nelem > 0:
             for op in ["sum", "prod", "all", "any", "mean"]:
                 yield (cmd, op, None)
                 for axis in range(len(shape)):
                     yield (cmd, op, axis)
Пример #18
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 4, min_ndim=2, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         for offset in range(-min(shape) + 1, min(shape)):
             for axis1 in range(len(shape)):
                 for axis2 in range(len(shape)):
                     if axis1 == axis2:
                         continue
                     yield (cmd, offset, axis1, axis2)
Пример #19
0
 def init(self):
     for ary, shape in util.gen_random_arrays("R",
                                              3,
                                              max_dim=50,
                                              dtype="np.float64"):
         nelem = functools.reduce(operator.mul, shape)
         if nelem == 0:
             continue
         cmd = "R = bh.random.RandomState(42); a = %s; " % ary
         yield cmd
Пример #20
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R",
                                              3,
                                              max_dim=50,
                                              dtype="np.float64"):
         nelem = functools.reduce(operator.mul, shape)
         if nelem == 0:
             continue
         cmd = "R = bh.random.RandomState(42); res=%s; " \
               "m = R.random_integers(0, 1, res.shape, bohrium=BH).astype(np.bool); " % cmd
         yield (cmd)
Пример #21
0
 def init(self):
     for ary, shape in util.gen_random_arrays("R", 3, max_dim=50, dtype="np.float64"):
         nelem = functools.reduce(operator.mul, shape)
         if nelem == 0:
             continue
         cmd = "R = bh.random.RandomState(42); a = %s; " % ary
         ind = "ind = ("
         for dim in shape:
             ind += "R.random(10, np.uint64, bohrium=BH) %% %d, " % dim
         ind += "); "
         yield cmd + ind
Пример #22
0
 def init(self):
     for ary, shape in util.gen_random_arrays("R", 3, max_dim=50, dtype="np.float64"):
         nelem = functools.reduce(operator.mul, shape)
         if nelem == 0:
             continue
         cmd = "R = bh.random.RandomState(42); a = %s; " % ary
         cmd += "ind = M.arange(%d, dtype=np.int64).reshape(%s); " % (nelem, shape)
         yield cmd
         yield cmd + "ind = ind[::2]; "
         if shape[0] > 2:
             yield cmd + "ind = ind[1:]; "
         if len(shape) > 1 and shape[1] > 5:
             yield cmd + "ind = ind[3:]; "
Пример #23
0
 def init(self):
     for dtype in _info.numpy_types():
         dtype = "np.%s" % dtype.name
         for cmd, shape in util.gen_random_arrays("R", 2, min_ndim=1, samples_in_each_ndim=1,
                                                  dtype=dtype, no_views=True):
             nelem = functools.reduce(operator.mul, shape)
             # NumPy returns some f****d up shapes when working on 1-sized arrays
             # thus we will ignore them
             if nelem > 1:
                 cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
                 cmd += "b = R.random(%s, dtype=%s, bohrium=BH); " % (shape, dtype)
                 cmd += "m = R.random_integers(0, 1, size=a.shape, dtype=np.bool, bohrium=BH); "
                 yield (cmd, dtype)
Пример #24
0
 def init(self):
     for ary, shape in util.gen_random_arrays("R",
                                              3,
                                              max_dim=50,
                                              dtype="np.float64"):
         nelem = functools.reduce(operator.mul, shape)
         if nelem == 0:
             continue
         cmd = "R = bh.random.RandomState(42); res = %s; " % ary
         ind = "ind = ("
         for dim in shape:
             ind += "R.random(shape=(10,), bohrium=BH).astype(np.uint64) %% %d, " % dim
         ind += "); "
         yield cmd + ind
Пример #25
0
 def init(self):
     for ary, shape in util.gen_random_arrays("R",
                                              3,
                                              max_dim=50,
                                              dtype="np.float64"):
         nelem = functools.reduce(operator.mul, shape)
         if nelem == 0:
             continue
         cmd = "R = bh.random.RandomState(42); a = %s; " % ary
         cmd += "ind = M.arange(%d, dtype=np.int64).reshape(%s); " % (nelem,
                                                                      shape)
         yield cmd
         yield cmd + "ind = ind[::2]; "
         if shape[0] > 2:
             yield cmd + "ind = ind[1:]; "
         if len(shape) > 1 and shape[1] > 5:
             yield cmd + "ind = ind[3:]; "
Пример #26
0
 def init(self):
     for dtype in util.TYPES.COMPLEX:
         for cmd, shape in util.gen_random_arrays("R", 2, dtype=dtype):
             cmd = "R = bh.random.RandomState(42); z = %s; " % cmd
             yield cmd
Пример #27
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 4, min_ndim=2, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         yield cmd
Пример #28
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 3, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         for op in ["cumsum", "cumprod"]:
             for axis in range(len(shape)):
                 yield (cmd, op, axis)
Пример #29
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 4, min_ndim=2, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         for offset in range(-min(shape)+1, min(shape)):
             yield (cmd, offset)
Пример #30
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 4, min_ndim=2, dtype="np.uint32"):
         cmd = "R = bh.random.RandomState(42); a = %s" % cmd
         for offset in range(shape[0], shape[0]+1):
             yield "%s; offset=%d; " % (cmd, offset)
Пример #31
0
 def init(self):
     for dtype in util.TYPES.COMPLEX:
         for cmd, shape in util.gen_random_arrays("R", 2, dtype=dtype):
             cmd = "R = bh.random.RandomState(42); z = %s; " % cmd
             yield cmd
Пример #32
0
 def init(self):
     for cmd, shape in util.gen_random_arrays("R", 3, dtype="np.float32"):
         cmd = "R = bh.random.RandomState(42); a = %s; " % cmd
         for op in ["sum", "prod"]:
             yield (cmd, op)
Пример #33
0
 def init(self):
     for rand_cmd, shape in util.gen_random_arrays("R", 4, min_ndim=1, dtype="np.float32"):
         for axis in range(len(shape)):
             cmd = "R = bh.random.RandomState(42); a = %s; b = %s; " % (rand_cmd, rand_cmd)
             yield (cmd, axis)