Generate unique seeds for each rupture with numpy.arange.
        This should be called only in event based calculators
490535
def init_serials(self, ses_seed):
        
        sources = self.get_sources()
        serial = ses_seed
        for src in sources:
            nr = src.num_ruptures
            src.serial = serial
            serial += nr
407326
def generateRandomSDR(numSDR, numDims, numActiveInputBits, seed=42):
  
  randomSDRs = np.zeros((numSDR, numDims), dtype=uintType)
  indices = np.array(range(numDims))
  np.random.seed(seed)
  for i in range(numSDR):
    randomIndices = np.random.permutation(indices)
    activeBits = randomIndices[:numActiveInputBits]
    randomSDRs[i, activeBits] = 1

  return randomSDRs
1019058
public void generateRandom( int nbPoints, float minX, float maxX, float minY, float maxY )
	{
		xs = new ArrayList<Float>();
		ys = new ArrayList<Float>();

		for( int i = 0; i < nbPoints; i++ )
		{
			float r = (float) Math.random();
			r = (float) (((int) (r * 100)) / 100.0);
			xs.add( minX + (i * (maxX - minX) / (nbPoints - 1)) );
			ys.add( minY + r * (maxY - minY) );
		}
	}
757889
def generate_matches(self, nodes):
        
        r = {}
        if nodes and self.match(nodes[0], r):
            yield 1, r
303922
def rand_indices(x, rand_attr):
    
    loop = True
    indices = range(len(x[0]))

    while loop:
        loop = False
        # randomly selected features without replacement
        rand_list = random.sample(indices, rand_attr)
        for i in rand_list:
            if len(np.unique(x[:, i])) == 1:
                loop = True
                indices.remove(i)
                if len(indices) == rand_attr - 1:
                    return -1  # all features in dataset have one distinct value
                break
    return rand_list
55443
def unique_everseen(iterable):
    """"""
    # unique_everseen('AAAABBBCCDAABBB')    --> A B C D
    seen = set()
    seen_add = seen.add

    for element in six.moves.filterfalse(seen.__contains__, iterable):
        seen_add(element)
        yield element
988904
def gen_n_random_num(n, MAX_NUM=MAX_INT, unique=True):
    
    fmt = "<%dI" % n
    t = struct.calcsize(fmt)
    D = [d % MAX_NUM for d in struct.unpack(fmt, os.urandom(t))]
    if unique:
        D = set(D)
        assert MAX_NUM > n, \
            "Cannot have {0} unique integers less than {1}".format(n, MAX_NUM)
        while len(D) < n:
            print("Number of collision: {}. Regenerating!".format(n - len(D)))
            fmt = "<%dI" % (n - len(D))
            t = struct.calcsize(fmt)
            extra = struct.unpack(fmt, os.urandom(t))
            D |= set(d % MAX_NUM for d in extra)
        D = list(D)
    return D
1155521
def get_multiplicon_seeds(self, redundant=False):
        
        for node in self._multiplicon_graph.nodes():
            if not len(self._multiplicon_graph.in_edges(node)):
                if not self.is_redundant_multiplicon(node):
                    yield node
                elif redundant:
                    yield node
                else:
                    continue
            else:
                continue
37028
def numpy_random_seed(seed=42):
    
    old_state = np.random.get_state()
    np.random.seed(seed)
    try:
        yield
    finally:
        np.random.set_state(old_state)
360800
def iter_ruptures(self):
        
        assert self.orig, '%s is not fully initialized' % self
        for ridx in range(self.start, self.stop):
            if self.orig.rate[ridx]:  # ruptures may have have zero rate
                rup = self.get_ucerf_rupture(ridx, self.src_filter)
                if rup:
                    yield rup
916768
def unique_iterator(seq):
    
    seen = set()
    for item in seq:
        if item not in seen:
            seen.add(item)
            yield item
1089284
def extract_rupture(dstore, serial):
    
    ridx = list(dstore['ruptures']['serial']).index(int(serial))
    [getter] = getters.gen_rupture_getters(dstore, slice(ridx, ridx + 1))
    yield from getter.get_rupdict().items()
928675
def generate(self):
        '''
        '''
        offsets = (0., 0.)

        n_previous = 0

        # set recursion limit with respect to
        # the max number of nodes on the trees
        old_depth = sys.getrecursionlimit()
        max_depth = old_depth if old_depth > self._max_rec_depth else self._max_rec_depth
        # TODO: This should be fixed so we don't set sys.setrecursionlimit at all
        sys.setrecursionlimit(max_depth)

        if isinstance(self._obj, Neurite):

            max_diameter = _max_diameter(self._obj.root_node)

            dummy_section = Tree()
            dummy_section.add_child(self._obj.root_node)
            self._generate_dendro(dummy_section, (max_diameter, 0.), offsets)

            self._groups.append((0, self._n))

            self._dims.append(self._max_dims)

        else:

            for neurite in self._obj.neurites:

                neurite = neurite.root_node
                max_diameter = _max_diameter(neurite)
                dummy_section = Tree()

                dummy_section.add_child(neurite)
                self._generate_dendro(dummy_section, (max_diameter, 0.), offsets)

                # store in trees the indices for the slice which corresponds
                # to the current neurite
                self._groups.append((n_previous, self._n))

                # store the max dims per neurite for view positioning
                self._dims.append(self._max_dims)

                # reset the max dimensions for the next tree in line
                self._max_dims = [0., 0.]

                # keep track of the next tree start index in list
                n_previous = self._n

        # set it back to its initial value
        sys.setrecursionlimit(old_depth)
1263752
def RandomUniform(shape, dtype, seed):
    
    if seed:
        np.random.seed(seed)
    return np.random.uniform(size=shape).astype(dtype_map[dtype]),
433259
def unique(cls, iterable, key=None):
    

    if key is None:
      key = lambda x: x
    def generator():
      seen = set()
      seen_add = seen.add
      for item in iterable:
        key_val = key(item)
        if key_val not in seen:
          seen_add(key_val)
          yield item
    return cls(generator())
594882
def random(self, shape, tf_fn, kwargs):
    
    slice_shape = self.slice_shape(shape)
    op_seed = random.random()
    def my_fn(pnum):
      # seeds are necessary to make sure that slices that should have the
      # same values actually do have the same values.
      seed = hash("%s,%s" % (op_seed, self.slice_begin(shape, pnum)))
      return tf_fn(slice_shape, seed=seed, **kwargs)
    return self.slicewise(my_fn, self.laid_out_pnum())
647082
def _set_random_seeds():
    
    try:
        import numpy as np
        np.random.seed()
    except:
        pass

    try:
        import scipy as sp
        sp.random.seed()
    except:
        pass

    import random
    random.seed()