get a random scan
517908
def getScans(self, modifications=False, fdr=True):
        
        if fdr:
            sql = self.base_sql+"WHERE p.ConfidenceLevel >= {} and p.SearchEngineRank <= {} {}".format(self.clvl, self.srank, self.extra)
            try:
                self.cur.execute(sql)
            except sqlite3.OperationalError:
                sql = self.base_sql+"WHERE p.ConfidenceLevel >= {} {}".format(self.clvl, self.extra)
                self.cur.execute(sql)
        else:
            sql = self.base_sql
            self.cur.execute(sql)
        while True:
            # results = self.cur.fetchmany(1000)
            # if not results:
            #     break
            try:
                tup = self.cur.fetchone()
            except:
                sys.stderr.write('Error fetching scan:\n{}\n'.format(traceback.format_exc()))
            else:
                while tup is not None:
                    if tup is None:
                        break
                    if tup[1] is not None:
                        scan = self.parseFullScan(tup, modifications=modifications)
                        scan.spectrumId = tup[3]
                        yield scan
                    try:
                        tup = self.cur.fetchone()
                    except:
                        sys.stderr.write('Error fetching scan:\n{}\n'.format(traceback.format_exc()))
                if tup is None:
                    break
        yield None
506655
def choose_one(things):
    """"""
    choice = SystemRandom().randint(0, len(things) - 1)
    return things[choice].strip()
464116
def add_random_file_from_present_folder(machine_ip, port, zone):
    """"""
    # Make a list of music files, right now it is done by collection all files
    # below the current folder whose extension does not start with .py
    # This will probably need to be modded for other pusposes.
    music_files = []
    print('Looking for music files')
    for path, dirs, files in os.walk('.'):
        for file_ in files:
            if not os.path.splitext(file_)[1].startswith('.py'):
                music_files.append(os.path.relpath(os.path.join(path, file_)))
                print('Found:', music_files[-1])

    random_file = choice(music_files)
    # urlencode all the path parts (but not the /'s)
    random_file = os.path.join(
        *[quote(part) for part in os.path.split(random_file)]
    )
    print('\nPlaying random file:', random_file)
    netpath = 'http://{}:{}/{}'.format(machine_ip, port, random_file)

    number_in_queue = zone.add_uri_to_queue(netpath)
    # play_from_queue indexes are 0-based
    zone.play_from_queue(number_in_queue - 1)
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)))
878132
def random(*args):
    
    current_frame     = inspect.currentframe().f_back
    trace_string      = ""
    while current_frame.f_back:
      trace_string = trace_string + current_frame.f_back.f_code.co_name
      current_frame = current_frame.f_back
    return counter.get_from_trace(trace_string)
163997
def random(cls, engine_or_session, limit=5):
        
        ses, auto_close = ensure_session(engine_or_session)
        result = ses.query(cls).order_by(func.random()).limit(limit).all()
        if auto_close:  # pragma: no cover
            ses.close()
        return result
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)
1053364
def get_random_giphy(phrase):
    """"""
    with warnings.catch_warnings():
        warnings.simplefilter('ignore')

        giphy = giphypop.Giphy()

    results = giphy.search_list(phrase=phrase, limit=100)

    if not results:
        raise ValueError('There were no results for that phrase')

    return random.choice(results).media_url
1184479
def get_random(self, n, l=None):
        
        random_f = Fasta()
        if l:
            ids = self.ids[:]
            random.shuffle(ids)
            i = 0
            while (i < n) and (len(ids) > 0):
                seq_id = ids.pop()
                if (len(self[seq_id]) >= l):
                    start = random.randint(0, len(self[seq_id]) - l)
                    random_f["random%s" % (i + 1)] = self[seq_id][start:start+l]
                    i += 1
            if len(random_f) != n:
                sys.stderr.write("Not enough sequences of required length")
                return
            else:
                return random_f

        else:
            choice = random.sample(self.ids, n)
            for i in range(n):
                random_f[choice[i]] = self[choice[i]]
        return random_f
288193
function getRandomInt(min, max) {
    const minInt = Math.ceil(min);
    const maxInt = Math.floor(max);
    return Math.floor(Math.random() * (maxInt - minInt)) + minInt;
}
1114440
def get_random(self):
        
        from random import randint

        count = self.count()

        if count < 1:
            raise self.EmptyDatabaseException()

        random_integer = randint(0, count - 1)

        statements = self.statements.find().limit(1).skip(random_integer)

        return self.mongo_to_object(list(statements)[0])
1041463
def get_random_item(enum: Any, rnd: Optional[Random] = None) -> Any:
    
    if rnd and isinstance(rnd, Random):
        return rnd.choice(list(enum))
    return random_module.choice(list(enum))
1024286
def simulate(self):
        """"""
        # Simulates zero to 10 types
        return [t.simulate() for t in itertools.islice(self, random.choice(range(10)))]
372545
def get_random_id(length):
    """"""
    alphabet = string.ascii_uppercase + string.ascii_lowercase + string.digits
    return ''.join(random.choice(alphabet) for _ in range(length))
1091575
def _randomString():
    """"""

    return ''.join(
        random.choice(string.ascii_uppercase + string.digits)
        for x in range(10))
1311091
def get_random_value(length=10, character_sets=[string.ascii_uppercase, string.ascii_lowercase]):
        

        return "".join(random.choice("".join(character_sets)) for i in range(length))
1358927
def scan(self, ids=range(254)):
        
        return [id for id in ids if self.ping(id)]