create a list of people with randomly generated names and stats
513706
def create_random_population(num=100):
    
    people = []
    for _ in range(num):
        nme = 'blah'
        tax_min = random.randint(1,40)/100
        tax_max = tax_min + random.randint(1,40)/100
        tradition = random.randint(1,100)/100
        equity = random.randint(1,100)/100
        pers = mod_hap_env.Person(nme, {'tax_min':tax_min, 'tax_max':tax_max, 'tradition':tradition, 'equity':equity})
        people.append(pers)
        print(pers)

    return people
1242795
def make_data(n,width):
    """"""
    x = dict([(i,100*random.random()) for i in range(1,n+1)])
    y = dict([(i,100*random.random()) for i in range(1,n+1)])
    c = {}
    for i in range(1,n+1):
        for j in range(1,n+1):
            if j != i:
                c[i,j] = distance(x[i],y[i],x[j],y[j])

    e = {1:0}
    l = {1:0}
    start = 0
    delta = int(76.*math.sqrt(n)/n * width)+1
    for i in range(1,n):
        j = i+1
        start += c[i,j]
        e[j] = max(start-delta,0)
        l[j] = start + delta

    return c,x,y,e,l
696378
def make_data(n,prob):
    
    V = range(1,n+1)
    E = [(i,j) for i in V for j in V if i < j and random.random() < prob]
    return V,E
579731
def make_random_MLdataset(max_num_classes = 20,
                          min_class_size = 20,
                          max_class_size = 50,
                          max_dim = 100,
                          stratified = True):
    ""

    smallest = min(min_class_size, max_class_size)
    max_class_size = max(min_class_size, max_class_size)
    largest = max(50, max_class_size)
    largest = max(smallest+3,largest)

    if max_num_classes != 2:
        num_classes = np.random.randint(2, max_num_classes, 1)
    else:
        num_classes = 2

    if type(num_classes) == np.ndarray:
        num_classes = num_classes[0]
    if not stratified:
        class_sizes = np.random.random_integers(smallest, largest, num_classes)
    else:
        class_sizes = np.repeat(np.random.randint(smallest, largest), num_classes)

    num_features = np.random.randint(min(3, max_dim), max(3, max_dim), 1)[0]
    # feat_names = [ str(x) for x in range(num_features)]

    class_ids = list()
    labels = list()
    for cl in range(num_classes):
        class_ids.append('class-{}'.format(cl))
        labels.append(int(cl))

    ds = MLDataset()
    for cc, class_ in enumerate(class_ids):
        subids = [ 's{}-c{}'.format(ix,cc) for ix in range(class_sizes[cc]) ]
        for sid in subids:
            ds.add_sample(sid, feat_generator(num_features), int(cc), class_)

    return ds
614932
def _random_candidates(self, n=1000):
        """"""

        candidates = np.zeros((n, len(self.tunables)))
        for i, tunable in enumerate(self.tunables):
            param = tunable[1]
            lo, hi = param.range
            if param.is_integer:
                column = np.random.randint(lo, hi + 1, size=n)

            else:
                diff = hi - lo
                column = lo + diff * np.random.rand(n)

            candidates[:, i] = column

        return candidates
1337360
def marvcli_user_list():
    """"""
    app = create_app()
    for name in db.session.query(User.name).order_by(User.name):
        click.echo(name[0])
1322487
def shuffle_records(fname):
  """"""
  tf.logging.info("Shuffling records in file %s" % fname)

  # Rename file prior to shuffling
  tmp_fname = fname + ".unshuffled"
  tf.gfile.Rename(fname, tmp_fname)

  reader = tf.python_io.tf_record_iterator(tmp_fname)
  records = []
  for record in reader:
    records.append(record)
    if len(records) % 100000 == 0:
      tf.logging.info("\tRead: %d", len(records))

  random.shuffle(records)

  # Write shuffled records to original file name
  with tf.python_io.TFRecordWriter(fname) as w:
    for count, record in enumerate(records):
      w.write(record)
      if count > 0 and count % 100000 == 0:
        tf.logging.info("\tWriting record: %d" % count)

  tf.gfile.Remove(tmp_fname)
1223231
def generate_dataset_shelve(filename, number_items=1000):
    
    if os.path.exists(filename):
        os.remove(filename)
    data = shelve.open(filename)
    names = get_names()
    totalnames = len(names)
    #init random seeder
    random.seed()
    #calculate items
#    names = random.sample(names, number_items)
    for i in range(number_items):
        data[str(i+1)] = {"name":names[random.randint(0,totalnames-1)],
                     "age":random.randint(1,100),
                     "description":li_words(50, False)}
    data.close()
1100828
def generate(self, N, *, seed=None, progressbar=False):
        
        if seed is not None:
            self.reset(seed)
        items = islice(self, N)
        if progressbar:
            items = tqdm(items, total=N)

        item_list = [x for x in items]

        #logger.warning("TODO: initialise ItemList with random seed!")
        return ItemList(item_list, N)
590403
def random_name():
    

    adj = _data.adjectives[random.randint(0, len(_data.adjectives) - 1)]
    noun = _data.nouns[random.randint(0, len(_data.nouns) - 1)]
    return "%s_%s" % (adj, noun)
68806
def user_list(self, userid, cur_p=''):
        '''
        
        '''
        current_page_number = int(cur_p) if cur_p else 1
        current_page_number = 1 if current_page_number < 1 else current_page_number

        kwd = {
            'current_page': current_page_number
        }

        recs = MEntity2User.get_all_pager_by_username(userid, current_page_num=current_page_number).objects()

        self.render('misc/entity/entity_user_download.html',
                    imgs=recs,
                    cfg=config.CMS_CFG,
                    kwd=kwd,
                    userinfo=self.userinfo)
314883
def create(clients_num, clients_host, clients_port, people_num, throttle):
    
    res = []
    for number in range(clients_num):
        sc = EchoClient({
            'id': number,
            'listen_bind_ip': clients_host,
            #'multicast_bind_ip': "127.0.0.1",
            'listen_port': clients_port + number
        })
        people = []
        for person_number in range(people_num):
            people.append(Person(id=person_number))
        wrapper = WrapperEchoClient({
            'client': sc,
            'people': people,
            'throttle': throttle
        })
        res.append(wrapper)

    return res, cmd_line
251177
def _build_list(option_value, item_kind):
    '''
    
    '''
    #specify profiles if provided
    if option_value is not None:

        items = []

        #if user specified none, return an empty list
        if option_value == 'none':
            return items

        #was a list already passed in?
        if not isinstance(option_value, list):
            values = option_value.split(',')
        else:
            values = option_value

        for value in values:
            # sometimes the bigip just likes a plain ol list of items
            if item_kind is None:
                items.append(value)
            # other times it's picky and likes key value pairs...
            else:
                items.append({'kind': item_kind, 'name': value})
        return items
    return None
902492
def generate_random_table(self):
        
        table = list(range(0, self.n))
        random.shuffle(table)
        return table
564993
private void generateDN() {
        if (names.length == 1) {
            dn = names[0].toString();
            return;
        }

        StringBuilder sb = new StringBuilder(48);
        if (names != null) {
            for (int i = names.length - 1; i >= 0; i--) {
                if (i != names.length - 1) {
                    sb.append(", ");
                }
                sb.append(names[i].toString());
            }
        }
        dn = sb.toString();
    }
764062
def query_random(**kwargs):
        '''
        
        '''

        if 'limit' in kwargs:
            limit = kwargs['limit']
        elif 'num' in kwargs:
            limit = kwargs['num']
        else:
            limit = 10

        kind = kwargs.get('kind', None)

        if kind:
            rand_recs = TabPost.select().where(
                (TabPost.kind == kind) &
                (TabPost.valid == 1)
            ).order_by(
                peewee.fn.Random()
            ).limit(limit)
        else:
            rand_recs = TabPost.select().where(
                TabPost.valid == 1
            ).order_by(
                peewee.fn.Random()
            ).limit(limit)
        return rand_recs
1276020
def random_name(num_surnames=2):
    
    a = []

    # Prefix
    if random.random() < _PROB_PREF:
        a.append(_prefixes[random.randint(0, len(_prefixes) - 1)])

    # Forename
    a.append(_forenames[random.randint(0, len(_forenames) - 1)])

    # Surnames
    for i in range(num_surnames):
        a.append(_surnames[random.randint(0, len(_surnames) - 1)])

    # Suffix
    if random.random() < _PROB_SUFF:
        a.append(_suffixes[random.randint(0, len(_suffixes) - 1)])

    return " ".join(a)