Return a random board with given max x and y coords.
341679
def random_board(max_x, max_y, load_factor):
    """"""
    return dict(((randint(0, max_x), randint(0, max_y)), 0) for _ in
                xrange(int(max_x * max_y / load_factor)))
9370
def flip_coords(X,loop):
    
    if(loop[0]==1):
        return np.array(map(lambda i: np.array([i[2],i[1],i[0],i[5],i[4],i[3]]),X))
    else:
        return X
480663
def random_start_board(cls):
        """"""
        board = cls()
        board._random_fill()
        destructions = True  # prime the loop
        while destructions:
            board, destructions = board.execute_once()
            board._random_fill()
        return board
1092119
def _randomSO3():
    """"""
    u1 = np.random.random()
    u2 = np.random.random()
    u3 = np.random.random()
    R = np.array(
        [
            [np.cos(2 * np.pi * u1), np.sin(2 * np.pi * u1), 0],
            [-np.sin(2 * np.pi * u1), np.cos(2 * np.pi * u1), 0],
            [0, 0, 1],
        ]
    )
    v = np.array([np.cos(2 * np.pi * u2) * np.sqrt(u3), np.sin(2 * np.pi * u2) * np.sqrt(u3), np.sqrt(1 - u3)])
    H = np.identity(3) - 2 * v * np.transpose([v])
    return -np.dot(H, R)
128118
def make_data(n):
    """"""
    V = range(1,n+1)
    x = dict([(i, random.random()) for i in V])
    y = dict([(i, random.random()) for i in V])
    c, q = {}, {}
    Q = 100
    for i in V:
        q[i] = random.randint(10, 20)
        for j in V:
            if j > i:
                c[i, j] = distance(x[i], y[i], x[j], y[j])
    return V, c, q, Q
1109872
def random(cls):
        """"""
        axis = random_unit()
        angle = np.random.uniform(0,2*np.pi)
        invert = bool(np.random.randint(0,2))
        return Rotation.from_properties(angle, axis, invert)
103458
def from_rectangle(box):
        
        x = box.left + box.width * random.uniform(0, 1)
        y = box.bottom + box.height * random.uniform(0, 1)
        return Vector(x, y)
97053
def generateRandomSDRVaryingSparsity(numSDR, numDims, minSparsity, maxSparsity,
                                     seed=42):
  
  randomSDRs = np.zeros((numSDR, numDims), dtype=uintType)
  indices = np.array(range(numDims))
  np.random.seed(seed)
  for i in range(numSDR):
    sparsity = np.random.random() * (maxSparsity - minSparsity) + minSparsity
    numActiveInputBits = int(sparsity * numDims)
    randomIndices = np.random.permutation(indices)
    activeBits = randomIndices[:numActiveInputBits]
    randomSDRs[i, activeBits] = 1
  return randomSDRs
651653
def in_SCAT_box(x, y, low_bound, high_bound, x_max, y_max):
    """"""
    passing = True
    upper_limit = high_bound(x)
    lower_limit = low_bound(x)
    if x > x_max or y > y_max:
        passing = False
    if x < 0 or y < 0:
        passing = False
    if y > upper_limit:
        passing = False
    if y < lower_limit:
        passing = False
    return passing
700057
def get_bbox(self):
        """"""

        x_min = self.x
        x_max = x_min + self.width
        y_min = self.y
        y_max = self.y + self.height

        return x_min, x_max, y_min, y_max
314720
public Quaternion randomize (Random rand) {
        // pick angles according to the surface area distribution
        return fromAngles(MathUtil.lerp(-FloatMath.PI, +FloatMath.PI, rand.nextFloat()),
                          FloatMath.asin(MathUtil.lerp(-1f, +1f, rand.nextFloat())),
                          MathUtil.lerp(-FloatMath.PI, +FloatMath.PI, rand.nextFloat()));
    }
537855
def generator(self, random, args):
        """"""
        if self.duplicates:
            max_count = [self.capacity // item[0] for item in self.items]
            return [random.randint(0, m) for m in max_count]
        else:
            return [random.choice([0, 1]) for _ in range(len(self.items))]
160313
def random_real_solution(solution_size, lower_bounds, upper_bounds):
    """"""
    return [
        random.uniform(lower_bounds[i], upper_bounds[i])
        for i in range(solution_size)
    ]
915767
def uniform(low, high, random_state):
    '''
    
    '''
    assert high > low, 'Upper bound must be larger than lower bound'
    return random_state.uniform(low, high)
125275
def random_mini_batches(X, Y, minibatch_size, seed=None):
  
  d    = X.shape[1]
  size = minibatch_size
  minibatches = []

  if Y is None:
      Y = np.zeros((1, d))

  np.random.seed(seed)
  perm = np.random.permutation(d)

  for t in range(0, d, size):
      subset = perm[t: t+size]
      minibatches.append((X[:, subset], Y[:, subset]))

  return minibatches
1268529
def maxpos
      v, opts = max x: true, y: true
      x = opts['x']
      y = opts['y']
      return v, x, y
    end
1223617
def _sampleFromVertices(self):
    
    coordinates = [
      self.dimensions[0] / 2. * random.choice([-1, 1]),
      self.dimensions[1] / 2. * random.choice([-1, 1]),
      self.dimensions[2] / 2. * random.choice([-1, 1]),
    ]
    return coordinates