code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def decrase_health(self): <NEW_LINE> <INDENT> self.health -= self.individual_config['frame_health_reduce'] * self.poison
decrease own health if called the amount is increased by own poisoning
625941bad6c5a10208143ed1
def test_deploy_cert(plugin, temp_dir, domains): <NEW_LINE> <INDENT> cert = crypto_util.gen_ss_cert(util.KEY, domains) <NEW_LINE> cert_path = os.path.join(temp_dir, "cert.pem") <NEW_LINE> with open(cert_path, "w") as f: <NEW_LINE> <INDENT> f.write(OpenSSL.crypto.dump_certificate( OpenSSL.crypto.FILETYPE_PEM, cert)) <NE...
Tests deploy_cert returning True if the tests are successful
625941b97b25080760e392e4
def get_database_url(settings): <NEW_LINE> <INDENT> if not settings.database_source: <NEW_LINE> <INDENT> return settings.database <NEW_LINE> <DEDENT> global _DB_URL_CACHED, _DB_URL_REFRESH_TIME, _DB_URL_REFRESH_JITTER <NEW_LINE> if _DB_URL_REFRESH_TIME > time.time(): <NEW_LINE> <INDENT> return _DB_URL_CACHED <NEW_LINE>...
Given settings, load a database URL either from our executable source or the bare string.
625941b9d4950a0f3b08c1dd
def test_update_id(self): <NEW_LINE> <INDENT> obj = RuleObject.get(self.uuid) <NEW_LINE> serializer_data1 = json.loads(json.dumps(self.data1)) <NEW_LINE> with self.assertRaises(IDUpdateNotPermitted): <NEW_LINE> <INDENT> serializer = RuleObjectSerializer(obj, data=serializer_data1[0], partial=True, context={'pk': self.u...
test case to test update function with id update
625941ba67a9b606de4a7d46
def validatejson(data_input, mode): <NEW_LINE> <INDENT> LOGGER.info('validating JSON; Mode: {}'.format(mode)) <NEW_LINE> passed = False <NEW_LINE> if mode >= MODE.NONE: <NEW_LINE> <INDENT> passed = True <NEW_LINE> <DEDENT> if mode >= MODE.SIMPLE: <NEW_LINE> <INDENT> name = data_input.file <NEW_LINE> (mtype, encoding) =...
JSON validation function :param data_input: :class:`ComplexInput` :param pywps.validator.mode.MODE mode: This function validates JSON input based on given validation mode. Following happens, if `mode` parameter is given: `MODE.NONE` No validation, returns `True`. `MODE.SIMPLE` Returns `True` if the mime type...
625941ba796e427e537b044c
def list_randitem_norep(n,items,excluded_values=[]): <NEW_LINE> <INDENT> return _list_rand0(n,items,False,excluded_values)
Generate a list of random items selected from a list without replacements.
625941ba91af0d3eaac9b89e
@app.route('/horoscope_results') <NEW_LINE> def horoscope_results(): <NEW_LINE> <INDENT> horoscope_sign = request.args.get("horoscope_sign") <NEW_LINE> users_personality = HOROSCOPE_PERSONALITIES[horoscope_sign] <NEW_LINE> lucky_number = random.randint(1, 99) <NEW_LINE> context = { 'name': request.args.get('users_name'...
Shows the user the result for their chosen horoscope.
625941baf7d966606f6a9e92
def append_random_number_to_filename(self, local_img_file): <NEW_LINE> <INDENT> date = datetime.datetime.now() <NEW_LINE> date_string = date.strftime("%m-%d-%Y") <NEW_LINE> return "%s-%s-glitched.%s" % (local_img_file.split(".")[0], date_string, local_img_file.split(".")[1])
Prevent overwriting of original file
625941ba5fc7496912cc380f
def build(tree, control, level = 2): <NEW_LINE> <INDENT> tree = Builder.getDict(tree) <NEW_LINE> if level == 1: <NEW_LINE> <INDENT> return Builder.constructBoxLayout(tree, control) <NEW_LINE> <DEDENT> if level == 2: <NEW_LINE> <INDENT> return Builder.buildBoxes(tree, control) <NEW_LINE> <DEDENT> elif level == 3: <NEW_L...
API-call for building a QVBoxLayout from a given tree. The tree can be a path to a json file or a dictionary. The control has to implement the getCallback method that provides a callable for a given key. Level 2 returns layout containing QGroupBoxes, containing QWidgets, Level 3 returns layout conaining QTabWidgets, co...
625941ba63b5f9789fde6f6f
def work(self, burst=False): <NEW_LINE> <INDENT> setup_loghandlers() <NEW_LINE> self._install_signal_handlers() <NEW_LINE> self.pm = ProcessManager() <NEW_LINE> did_perform_work = False <NEW_LINE> self.register_birth() <NEW_LINE> self.log.info("RQ worker {0!r} started, version {1}".format(self.key, VERSION)) <NEW_LINE>...
Starts the work loop
625941baf548e778e58cd406
def torus(center=(0., 0., 0.), normal=(0., 0., 1.), radius=1., color='', cradius=.25, samples=20, csamples=20, _self=cmd): <NEW_LINE> <INDENT> from math import cos, sin, pi <NEW_LINE> if color and isinstance(color, str): <NEW_LINE> <INDENT> color = list(_self.get_color_tuple(color)) <NEW_LINE> <DEDENT> obj = [] <NEW_LI...
Generate and return a torus CGO with given center, normal and ring radius.
625941ba5166f23b2e1a4fe3
def activate(self): <NEW_LINE> <INDENT> return self
Turn on the executive
625941baa8370b771705272a
def zoom_out(self, x, y): <NEW_LINE> <INDENT> pass
Zoom out and center at the coordinates (x, y).
625941ba442bda511e8be2af
def rand_proxy(limit = ''): <NEW_LINE> <INDENT> if limit == '': <NEW_LINE> <INDENT> limit = config.Config['rand_proxy_limit'] <NEW_LINE> <DEDENT> with conn: <NEW_LINE> <INDENT> cursor = conn.cursor() <NEW_LINE> cursor.execute('SELECT protocol,ip FROM pool WHERE status = \'5\' ORDER BY random() LIMIT ' + str(limit)) <NE...
随机获取数据库中指定条数数据, 如果没有设置limit,则按照config中的默认条数进行返回
625941ba97e22403b379ce23
def save_model_loss(self, loss_li): <NEW_LINE> <INDENT> metric_file = codecs.open(self.out_dir + '/metrics.log', 'a', 'utf-8') <NEW_LINE> metric_comparison_file = codecs.open('./code/output_dir/' + self.args.domain + '/metrics.log', 'a', 'utf-8') <NEW_LINE> metric_file.write('Final loss: %s' % (loss_li[-1]) + "\n") <NE...
Creates plots of the training loss and saves them as .png and .pdf files. Args: loss_li: List that contains the model loss for every epoch Returns:
625941babe383301e01b5316
def _getAST(content): <NEW_LINE> <INDENT> content = '\n'.join(content.splitlines(0)) <NEW_LINE> errlineno = None <NEW_LINE> ast_ = None <NEW_LINE> try: <NEW_LINE> <INDENT> ast_ = _quietCompilerParse(content) <NEW_LINE> <DEDENT> except SyntaxError as ex: <NEW_LINE> <INDENT> errlineno = ex.lineno <NEW_LINE> log.debug("co...
Return an AST for the given Python content. If cannot, raise an error describing the problem.
625941ba236d856c2ad44668
def sequence_input(sequence): <NEW_LINE> <INDENT> position_feq = [] <NEW_LINE> with open(sequence) as seq: <NEW_LINE> <INDENT> lines = seq.readlines()[1:] <NEW_LINE> for i in range(len(lines)): <NEW_LINE> <INDENT> pos_prob = [] <NEW_LINE> try: <NEW_LINE> <INDENT> pos_prob.append(lines[i].strip('\n').split(',')[1]) <NEW...
takes in sequences from base_content that are in .csv format and frequencies per position to use in simulating sequences using a 1st order Markov Model. Parameters ---------- sequence : csv file with columns of sequences (A, T, G, C) Returns ------- position_frequencies : list of lists per position base fr...
625941bafbf16365ca6f6047
def to_rst(self): <NEW_LINE> <INDENT> return ".. code::\n\n" + text.indent(self.attributes['text'], 3) + "\n"
Return the rst representation of this tag and it's children.
625941ba046cf37aa974cbd4
def get_post_archive_url(self): <NEW_LINE> <INDENT> return self.get_absolute_url()
get the URL of the archive for all posts
625941bae64d504609d746ca
def mask(self, space, width, pos): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self.masks[(space, width, pos)] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> assert self.lv % space == space % width == 0 <NEW_LINE> m = self.all_mask // ((1 << space) - 1) <NEW_LINE> m *= (1 << width) - 1 <NEW_LINE> m = ...
Return a certain bit mask as a C literal In the returned bit mask we set the bits at positions ``k * space + pos * width + j, 0 <= j < width``, for all ``k >= 0`` such that the bit position is less than ``n * lv``, with ``n, lv`` as given by method ``set_matrix``. ``space`` must be divisible by ``lv`` and ``width...
625941ba9b70327d1c4e0c5e
def get_files(self, files): <NEW_LINE> <INDENT> self.logger.info("Get Files") <NEW_LINE> for pattern in files: <NEW_LINE> <INDENT> self.get_pattern(pattern)
Get files from the remote host
625941ba711fe17d825421fc
def run_proc(self, module, wlink, job_data, parameters): <NEW_LINE> <INDENT> if not self.has_plugin(module): <NEW_LINE> <INDENT> raise Exception("No plugin named {}".format(module)) <NEW_LINE> <DEDENT> plugin = self.pmanager.getPluginByName(module) <NEW_LINE> config_settings = plugin.details.items('Settings') <NEW_LINE...
Run module adapter for wasp interpreter To support the Job_data mechanism, injects wlink
625941ba656771135c3eb6fc
def login(self, mobile, code): <NEW_LINE> <INDENT> app_login_body = {"mobile": mobile, "code": code} <NEW_LINE> logging.info("app登录地址:{}".format(self.app_login_url)) <NEW_LINE> logging.info("app登录body:{}".format(app_login_body)) <NEW_LINE> return requests.post(self.app_login_url, json=app_login_body, headers=apiConfig....
app登录 :param mobile: 手机号 :param code: 验证码 :return:
625941ba8e05c05ec3eea1fc
def check_input(the_user_entry): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> for z in range(length_of_bad_input): <NEW_LINE> <INDENT> if bad_input[z] == the_user_entry: <NEW_LINE> <INDENT> messagebox.showwarning(title="Invalid input!", message="The following characters are forbidden:\n" "~`!@#$%^&*()_-+={[}]|\\:;\"\'<...
Checks the user's input, throws an error if they enter the wrong character :param the_user_entry: :return:
625941ba187af65679ca4fa7
def load_edml(dir_path): <NEW_LINE> <INDENT> with open(dir_path + '/m.obj', 'rb') as f: <NEW_LINE> <INDENT> m = pickle.load(f) <NEW_LINE> <DEDENT> m.build(outdir=dir_path) <NEW_LINE> m.load(outdir=dir_path) <NEW_LINE> return m
Convenience method for reconstructing a saved EDML object. First loads in metadata from ``m.obj``, then uses that metadata to construct the computation graph. Then, if saved weights are found, these are loaded into the graph. :param dir_path: Path to directory containing the EDML checkpoint files. :return: The loaded ...
625941ba16aa5153ce362302
def backup(self, backup_info): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.strategy.start_backup(backup_info) <NEW_LINE> backup_info.save() <NEW_LINE> if backup_info.begin_wal is not None: <NEW_LINE> <INDENT> output.info("Backup start at xlog location: %s (%s, %08X)", backup_info.begin_xlog, backup_info.begin_wal...
Perform a backup for the server - invoked by BackupManager.backup() through the generic interface of a BackupExecutor. This implementation is responsible for performing a backup through the streaming protocol. The connection must be made with a superuser or a user having REPLICATION permissions (see PostgreSQL docume...
625941ba32920d7e50b28056
def driverNameToDriverAlias(self, name: str) -> str: <NEW_LINE> <INDENT> return self._conn_manager._drivers_sql_manager.nameToAlias(name)
Return the alias from the name of a sql driver.
625941ba8e71fb1e9831d637
def unset_max_noutput_items(self): <NEW_LINE> <INDENT> return _blocks_swig1.vector_insert_i_sptr_unset_max_noutput_items(self)
unset_max_noutput_items(vector_insert_i_sptr self)
625941baad47b63b2c509e13
def breadthFirstSearch(problem): <NEW_LINE> <INDENT> closed = set([]) <NEW_LINE> fringe = util.Queue() <NEW_LINE> closed.add(problem.getStartState()) <NEW_LINE> for successors in problem.getSuccessors(problem.getStartState()): <NEW_LINE> <INDENT> fringe.push( ( successors[0] , [successors[1]] ) ) <NEW_LINE> <DEDENT> wh...
Search the shallowest nodes in the search tree first.
625941bad8ef3951e32433c7
def test_fuse_element(self): <NEW_LINE> <INDENT> pass
Checks the fusion of two demons of the same family into an element
625941ba30dc7b76659017f4
def test_credv2_lps_off_v1_aes256_decrypt(self): <NEW_LINE> <INDENT> with open(data_filename("credv2_lps_off_v1_aes256"), "rb") as fd: <NEW_LINE> <INDENT> s = fd.read() <NEW_LINE> <DEDENT> cred = SAPCredv2(s).creds[0].cred <NEW_LINE> self.validate_credv2_plain(cred)
Test decryption of a version 1 AES256 encrypted credential with LPS off
625941ba5fdd1c0f98dc00bc
def get(self, uuid): <NEW_LINE> <INDENT> with open(self.match(uuid)) as bob: <NEW_LINE> <INDENT> data = json.load(bob) <NEW_LINE> <DEDENT> return self.create(**data)
Get a single issue. uuid can be a partial uuid.
625941baa17c0f6771cbdede
def insert(info: BusInfo) -> bool: <NEW_LINE> <INDENT> mongodb = UnibrowserDAO(host=__host, port=__port) <NEW_LINE> result = mongodb.insert(collection=__collection, documents=[info.to_object()]) <NEW_LINE> return result == 1
Inserts a single BusInfo object in Unibrowser's persistent storage. :param faq: the BusInfo to insert :returns: true if the insert succeeds, false otherwise
625941ba851cf427c661a39c
def on_turn(self, game): <NEW_LINE> <INDENT> possible_moves = [ (self.x+1, self.y), (self.x-1, self.y), (self.x, self.y+1), (self.x, self.y-1), (self.x+1, self.y+1), (self.x+1, self.y-1), (self.x-1, self.y+1), (self.x-1, self.y-1), ] <NEW_LINE> target = possible_moves[randint(0, len(possible_moves)-1)] <NEW_LINE> tile ...
Executes this NPC's turn AI, and then returns the amount of time till it can act again.
625941ba45492302aab5e14b
def db_get_document(doc_name, **kwargs): <NEW_LINE> <INDENT> return rdb_conn.conn.db().table(doc_name, **kwargs)
Gets and returns the document by the given name from the database. :param doc_name: Name of the document to fetch :return: The fetched document
625941ba4527f215b584c2e5
def _keep_dist_for_north_or_south_snake(self, direction, snake, dist_from_snake): <NEW_LINE> <INDENT> if snake.rect.centerx < self.rect.centerx and dist_from_snake > self.hover_dist: <NEW_LINE> <INDENT> self._go_chase_west() <NEW_LINE> <DEDENT> elif snake.rect.centerx >= self.rect.centerx and dist_from_snake > self.hov...
Causes Boo to keep its distance from Snake while Boo is going north or south.
625941bab5575c28eb68de88
def upgma( matrix, taxa, distances=True ): <NEW_LINE> <INDENT> return cluster.upgma(matrix,taxa,distances)
Carry out a cluster analysis based on the UPGMA algorithm (:evobib:`Sokal1958`). Parameters ---------- matrix : list A two-dimensional list containing the distances. taxa : list An list containing the names of all taxa corresponding to the distances in the matrix. distances : bool (default=True) ...
625941bab7558d58953c4da5
@register(name='shrink', filter=TYPE_STATE_FILTER, unshade=True) <NEW_LINE> def _shrink(win, direction, vertical_first=True, xinerama=False): <NEW_LINE> <INDENT> if direction.is_middle: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> workarea = get_current_workarea(win, xinerama) <NEW_LINE> shrink = Shrinker(workarea=wo...
Shrink window in given direction.
625941ba287bf620b61d38f8
def create_deployment(self, stack_id, command, app_id=None, instance_ids=None, comment=None, custom_json=None): <NEW_LINE> <INDENT> params = {'StackId': stack_id, 'Command': command, } <NEW_LINE> if app_id is not None: <NEW_LINE> <INDENT> params['AppId'] = app_id <NEW_LINE> <DEDENT> if instance_ids is not None: <NEW_LI...
Deploys a stack or app. + App deployment generates a `deploy` event, which runs the associated recipes and passes them a JSON stack configuration object that includes information about the app. + Stack deployment runs the `deploy` recipes but does not raise an event. :type stack_id: string :param stack_id: The...
625941ba8a349b6b435e7fff
def aspect_aware_resizing( self, image, max_size, interpolation=Image.LANCZOS): <NEW_LINE> <INDENT> height, width = image.shape[:2] <NEW_LINE> larger_of_the_two = max(height, width) <NEW_LINE> if larger_of_the_two > max_size: <NEW_LINE> <INDENT> scaling_value = max_size / float(larger_of_the_two) <NEW_LINE> resize_heig...
Performs resizing while maintaining the aspect ratio of the image Parameters ---------- image : instance of `numpy.ndarray` Image matrix, which shoud be in the specified mode. max_size : int The maximum allowed image size, which applies to both width and height. The larger of the 2 will be used to com...
625941baaad79263cf3908c6
def names(self, search=[]): <NEW_LINE> <INDENT> dct = self.parse() <NEW_LINE> insearch = lambda x: any([word in x for word in search]) <NEW_LINE> return [dct[e] for e in dct if insearch(e.text)]
Provide a list of names to search through and return the corresponding entries
625941bad8ef3951e32433c8
def acos(x): <NEW_LINE> <INDENT> return select( ne(x, _const(x, -1.0)), mul(_const(x, 2), atan2(sqrt(sub(_const(x, 1), square(x))), add(_const(x, 1), x))), full_like(x, onp.pi))
Elementwise arc cosine: :math:`\mathrm{acos}(x)`.
625941ba4e696a04525c92d9
@pytest.fixture(scope="module") <NEW_LINE> def affiliations_service(app): <NEW_LINE> <INDENT> return getattr(current_rdm_records, "affiliations_service")
Affiliations service.
625941ba7b180e01f3dc4690
def is_date(date_string): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> datetime.strptime(date_string, '%d-%m-%Y') <NEW_LINE> return True <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return False
Verifies if a string represents a date.
625941ba26068e7796caeb64
def get_sum_to_recharge(self): <NEW_LINE> <INDENT> balance = self.balance_checker() <NEW_LINE> if balance > settings.MIN_BALANCE: <NEW_LINE> <INDENT> self.log(u"Current balance %s - no need to refill", balance) <NEW_LINE> return 0 <NEW_LINE> <DEDENT> to_recharge = 250 - balance <NEW_LINE> to_recharge = max(settings.MIN...
Return the sum we need to put into balance
625941bad268445f265b4cf9
def convertEndianess(hexString): <NEW_LINE> <INDENT> if version < '3': <NEW_LINE> <INDENT> import codecs <NEW_LINE> S = hexString <NEW_LINE> return codecs.encode(codecs.decode(S, 'hex')[::-1], 'hex').decode() <NEW_LINE> <DEDENT> elif not version < '3': <NEW_LINE> <INDENT> s = hexString <NEW_LINE> return codecs.encode(c...
Takes string of Little/Big Endian hex, converts Endianess, returns hex string.
625941ba63b5f9789fde6f70
def testJsonChangeRelationTypeRequest(self): <NEW_LINE> <INDENT> pass
Test JsonChangeRelationTypeRequest
625941baa934411ee3751525
def run(self): <NEW_LINE> <INDENT> id_list = self.get_href() <NEW_LINE> url_list = self.get_url_list(id_list) <NEW_LINE> for url in url_list: <NEW_LINE> <INDENT> html = self.parse_url(url) <NEW_LINE> content_list = self.get_content_list(html) <NEW_LINE> self.save_content(content_list)
run函数实现主逻辑
625941bad164cc6175782bd9
def add_simple_link(self, issue, object): <NEW_LINE> <INDENT> data = {"object": object} <NEW_LINE> url = self._get_url('issue/' + str(issue) + '/remotelink') <NEW_LINE> r = self._session.post( url, data=json.dumps(data)) <NEW_LINE> simple_link = RemoteLink( self._options, self._session, raw=json_loads(r)) <NEW_LINE> re...
Add a simple remote link from an issue to web resource. This avoids the admin access problems from add_remote_link by just using a simple object and presuming all fields are correct and not requiring more complex ``application`` data. ``object`` should be a dict containing at least ``url`` to the linked external URL a...
625941ba66656f66f7cbc035
def get_tier_name(self): <NEW_LINE> <INDENT> tier = self.get_tier() <NEW_LINE> if tier: <NEW_LINE> <INDENT> return tier.tier_locale()
Returns the price tier for showing prices in the reviewer tools and developer hub.
625941ba1f037a2d8b94608a
def calc_sheet_id_onchange(self, cr, uid, ids, calc_sheet_id, context=None): <NEW_LINE> <INDENT> res = {'value': {'line_ids': False}} <NEW_LINE> if calc_sheet_id: <NEW_LINE> <INDENT> product_lines = [] <NEW_LINE> calssheet = self.pool.get('sale.prequotation').browse(cr, uid, calc_sheet_id, context=context) <NEW_LINE> f...
Changes purchase requisition line if Calc Sheet changes. @param name: Name of the field @param product_id: Changed product_id @return: Dictionary of changed values
625941bafb3f5b602dac351a
def main(): <NEW_LINE> <INDENT> s = server.server('192.168.100.14', 4004) <NEW_LINE> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if s.acceptingConnections: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> conn, addr = s.accept() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> br...
Main event loop that launches a Clue-Less server and listens for incoming connections and messages from clients.
625941ba099cdd3c635f0ae7
def sumOfDistancesInTree(self, N, edges): <NEW_LINE> <INDENT> if N==1: <NEW_LINE> <INDENT> return [0] <NEW_LINE> <DEDENT> d={} <NEW_LINE> for u,v in edges: <NEW_LINE> <INDENT> if u in d: <NEW_LINE> <INDENT> d[u].append(v) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> d[u]=[v] <NEW_LINE> <DEDENT> if v in d: <NEW_LINE> <...
:type N: int :type edges: List[List[int]] :rtype: List[int]
625941ba23e79379d52ee3f2
def load_od_data(coco_dir, data_name, use_crowded): <NEW_LINE> <INDENT> import pycocotools.coco <NEW_LINE> coco_dir = pathlib.Path(coco_dir) <NEW_LINE> coco = pycocotools.coco.COCO( str(coco_dir / "annotations" / f"instances_{data_name}.json") ) <NEW_LINE> class_names = [c["name"] for c in coco.loadCats(coco.getCatIds(...
物体検出のデータの読み込み。
625941baa4f1c619b28afecc
def test_list_null_cr(self): <NEW_LINE> <INDENT> self.data_in = [None] <NEW_LINE> self.expected = '[null]' <NEW_LINE> opts.compact = True <NEW_LINE> opts.raw = True <NEW_LINE> self.assertEqual(self.json_out.create_json(self.data_in), self.expected)
Test [None] -cr
625941ba91f36d47f21ac381
def _get_splice_site_coordinates(self, t, start, end, exon_i): <NEW_LINE> <INDENT> left_diff, right_diff = TranscriptProviderUtils.determine_closest_distance_from_exon(start, end, exon_i, t) <NEW_LINE> if abs(left_diff) < abs(right_diff): <NEW_LINE> <INDENT> dist_from_exon = left_diff * -1 <NEW_LINE> if dist_from_exon...
Returns distance from exon.
625941bafbf16365ca6f6048
def nb_mots(chaine): <NEW_LINE> <INDENT> if chaine == "": <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> res = 1 <NEW_LINE> for car in chaine: <NEW_LINE> <INDENT> if car == " ": <NEW_LINE> <INDENT> res += 1 <NEW_LINE> <DEDENT> <DEDENT> return res
Suppose que chaine contient des mots séparés par un seul espace. En ce cas, compter les mots consiste à compter les espaces et à ajouter 1... Remarque : il existe les fonction count() et split(), mais c'est de la triche
625941bae8904600ed9f1db4
def get_utc_timestamp() -> Text: <NEW_LINE> <INDENT> return str(datetime.datetime.utcnow().timestamp() * 1000)
Get utc timestamp. Returns: Text: utc timestamp
625941ba925a0f43d2549cff
def get_reference_node(self, name='reference'): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> ref_node = self.get_node('reference', name) <NEW_LINE> <DEDENT> except NodeNotFoundException: <NEW_LINE> <INDENT> ref_node = self.create_node('reference', name, {'reference': 'reference'}, reference=True) <NEW_LINE> self.get_re...
Nodes returned here are very easily referenced by name and then function as an index for all attached nodes The most typical use case is to index all of the nodes of a certain type, but the functionality is not limited to this.
625941baec188e330fd5a631
def get_year(soup): <NEW_LINE> <INDENT> nav_obj_lst = soup.findAll("nav", attrs={"id": ["breadcrumbs"]}) <NEW_LINE> if nav_obj_lst: <NEW_LINE> <INDENT> if nav_obj_lst[0].text: <NEW_LINE> <INDENT> year_with_colon = "".join( [ x for x in nav_obj_lst[0].text.split(" ") if any(c.isdigit() for c in x) ] ) <NEW_LINE> if year...
function pulls the year out of a PCC Class Scehdule Course Page. Year is in breadcrumbs at the top of the page input: bs4 Soup Object, from a PCC Class Schedule Course Page output: str, string that is the course year, Example: '2018'
625941ba3d592f4c4ed1cf0a
def countArrangement(self, n: int) -> int: <NEW_LINE> <INDENT> @lru_cache(None) <NEW_LINE> def dfs(i, remains: Set[int]): <NEW_LINE> <INDENT> if i == n+1: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> cnt = 0 <NEW_LINE> for j in remains: <NEW_LINE> <INDENT> if i%j == 0 or j%i == 0: <NEW_LINE> <INDENT> cnt += dfs(i+1...
DFS using a set, especially frozenset for caching
625941bad99f1b3c44c67421
def compute_checksum(stream, algo, message_digest, chunk_size=None, progress_callback=None): <NEW_LINE> <INDENT> chunk_size = chunk_size_or_default(chunk_size) <NEW_LINE> bytes_read = 0 <NEW_LINE> while 1: <NEW_LINE> <INDENT> chunk = stream.read(chunk_size) <NEW_LINE> if not chunk: <NEW_LINE> <INDENT> if progress_callb...
Get helper method to compute checksum from a stream. :param stream: File-like object. :param algo: Identifier for checksum algorithm. :param messsage_digest: A message digest instance. :param chunk_size: Read at most size bytes from the file at a time. :param progress_callback: Function accepting one argument with num...
625941ba1d351010ab8559a9
def descend(): <NEW_LINE> <INDENT> global objects, depth, dstairs, astairs <NEW_LINE> LEVELS[depth] = objects <NEW_LINE> objects = [] <NEW_LINE> depth += 1 <NEW_LINE> try: <NEW_LINE> <INDENT> objects = LEVELS[depth] <NEW_LINE> for obj in objects: <NEW_LINE> <INDENT> if obj.name == dstairs.name: <NEW_LINE> <INDENT> dsta...
Decends down the stairs, creating a new map and saving the old one.
625941ba8e7ae83300e4ae57
def histogram_eq(image): <NEW_LINE> <INDENT> image1 = np.copy(image) <NEW_LINE> image1[:,:,0] = cv2.equalizeHist(image1[:,:,0]) <NEW_LINE> image1[:,:,1] = cv2.equalizeHist(image1[:,:,1]) <NEW_LINE> image1[:,:,2] = cv2.equalizeHist(image1[:,:,2]) <NEW_LINE> return image1
Perform histogram equalization on the input image. See https://en.wikipedia.org/wiki/Histogram_equalization.
625941baa17c0f6771cbdedf
def gather_property(self, *args, **kwargs): <NEW_LINE> <INDENT> return self.calculate_all(*args, **kwargs)
The old alias for calculate_all, retained for compatibility
625941ba23849d37ff7b2f1d
def text_process(mess): <NEW_LINE> <INDENT> nopunc = [char for char in mess if char not in string.punctuation] <NEW_LINE> nopunc = ''.join(nopunc) <NEW_LINE> return [word for word in nopunc.split() if word.lower() not in stopwords.words('english')]
Removing the punctuations Removing the common words Returning the cleaned words
625941ba21bff66bcd6847e0
def test1(self): <NEW_LINE> <INDENT> y = T.tensor4('y') <NEW_LINE> self.mode = self.mode.excluding('fusion') <NEW_LINE> f = theano.function([y], y[::-1][::-1], mode=self.mode) <NEW_LINE> graph = f.maker.fgraph.toposort() <NEW_LINE> divs = [node for node in graph if isinstance(node.op, T.elemwise.Elemwise) and isinstanc...
Tests removing the extra floor_div by 1 introduced by local_subtensor_merge optimization
625941ba10dbd63aa1bd2a3a
def main(self, args=None, prog_name=None, complete_var=None, standalone_mode=True, **extra): <NEW_LINE> <INDENT> return click.Command.main(self, args=args, prog_name=self.name, complete_var=complete_var, standalone_mode=standalone_mode, **extra)
Workaround click 4.0 bug https://github.com/mitsuhiko/click/issues/365
625941baab23a570cc25000b
@staff_member_required <NEW_LINE> def import_ldap_user(request): <NEW_LINE> <INDENT> if request.method == 'POST': <NEW_LINE> <INDENT> form = ImportLDAPForm(request.POST) <NEW_LINE> if form.is_valid(): <NEW_LINE> <INDENT> tutorial = form.cleaned_data['tutorial'] <NEW_LINE> uids = form.cleaned_data['uids'].split() <NEW_L...
View in the admin
625941ba090684286d50eb6c
def get_data_filter(self): <NEW_LINE> <INDENT> return self._data_filter
Returns the station filter :rtype: Filter. :return: the station name
625941ba3eb6a72ae02ec361
def nothing(self, x): <NEW_LINE> <INDENT> pass
Callback function for the trackbars used by the gui_choose_hsv() function.
625941baf548e778e58cd407
def _schurDecompBasicQrIteration(mat): <NEW_LINE> <INDENT> if(not ifSquareMat(mat)): <NEW_LINE> <INDENT> print('[schurDecompBasicQrIteration]: not a square matrix'); <NEW_LINE> return None; <NEW_LINE> <DEDENT> uMat = eye(sizeSquareMat(mat)); <NEW_LINE> tMat = cloneMat(mat); <NEW_LINE> oldEigDiagVec = zeroes(sizeSquareM...
[schurDecompBasicQrIteration]: compute an upper triangular matrix uMat and a unitary matrix vMat such that mat = uMat * tMat * uMat* is the Schur decomposition of mat. It requires mat has distinct real eigenvalues. If mat is Hermitian, then tMat is a diagonal matrix: mat -> (uMat, tMat): mat = uMat * tMat * uMat* ar...
625941ba0383005118ecf470
def cmd_STORED(self): <NEW_LINE> <INDENT> self._current.popleft().success(True)
Manage a success response to a set operation.
625941bac4546d3d9de728bc
def DefaultPrivateKeySize(): <NEW_LINE> <INDENT> return 2048
User can choose size of his Private Key during install. Can be 1024, 2048 or 4096.
625941ba435de62698dfdadf
def testGetPreviewDimensions_shortCanvas(self): <NEW_LINE> <INDENT> mockModel = mock.Mock(name='mockModel') <NEW_LINE> mockModel.getWidth.return_value = 100 <NEW_LINE> mockModel.getHeight.return_value = 100 <NEW_LINE> c = controller.Controller(mockModel, None) <NEW_LINE> mockPreview = mock.Mock(name='mockPreview') <NEW...
Check that if the preview canvas is too short the region is scaled down.
625941bae1aae11d1e749b40
def wrapper(*args, **kwargs): <NEW_LINE> <INDENT> result = 0 <NEW_LINE> i = 0 <NEW_LINE> for i in range(n): <NEW_LINE> <INDENT> start = timeit.default_timer() <NEW_LINE> func(*args, **kwargs) <NEW_LINE> final = timeit.default_timer() <NEW_LINE> result += final - start <NEW_LINE> i += 1 <NEW_LINE> <DEDENT> print(result ...
:param args: :param kwargs: :return: The average time out of n cycles of func
625941ba31939e2706e4ccfb
def InstancesChanged(self): <NEW_LINE> <INDENT> rv = bool(_c.env_getInstancesChanged(self.__env)) <NEW_LINE> _c.env_setInstancesChanged(self.__env, False) <NEW_LINE> return rv
test if Instances have changed since last call
625941ba82261d6c526ab32e
def to_keypoint_image(self, size=1): <NEW_LINE> <INDENT> eu.do_assert(len(self.keypoints) > 0) <NEW_LINE> height, width = self.shape[:2] <NEW_LINE> image = np.zeros((height, width, len(self.keypoints)), dtype=np.uint8) <NEW_LINE> sizeh = max(0, (size - 1) // 2) <NEW_LINE> for i, kp in enumerate(self.keypoints): <NEW_LI...
Draws a new black image of shape (H,W,N) in which all keypoint coordinates are set to 255. (H=shape height, W=shape width, N=number of keypoints) This function can be used as a helper when augmenting keypoints with a method that only supports the augmentation of images. Parameters ------- size : int Size of each ...
625941ba5fdd1c0f98dc00bd
def demo(): <NEW_LINE> <INDENT> import taurus <NEW_LINE> db = taurus.Authority() <NEW_LINE> host = db.getNormalName() <NEW_LINE> w = main_TaurusDbTableWidget(host, TaurusElementType.Device) <NEW_LINE> return w
Table panels
625941ba63d6d428bbe4437b
def forward(self, x : UFloatTensor) -> UFloatTensor: <NEW_LINE> <INDENT> x = self.conv(x) <NEW_LINE> if self.activation: <NEW_LINE> <INDENT> x = self.activation(x) <NEW_LINE> <DEDENT> if self.bn: <NEW_LINE> <INDENT> x = self.bn(x) <NEW_LINE> <DEDENT> return x
:param x: Any input tensor that can be input into nn.Conv2d. :return: Tensor with convolutional layer and optional activation and batchnorm applied.
625941ba9b70327d1c4e0c5f
def set_keybindings(self, keybindings=[], debug_event=None): <NEW_LINE> <INDENT> tbl = [] <NEW_LINE> bindings = keybindings <NEW_LINE> if debug_event is not None: <NEW_LINE> <INDENT> mod = wx.ACCEL_CMD if util.platform() == "osx" else wx.ACCEL_CTRL <NEW_LINE> bindings.append((mod, ord('`'), debug_event)) <NEW_LINE> <DE...
Method to easily set key bindings. Also sets up debug keybindings and events.
625941ba85dfad0860c3ace5
def download_weekly_pointing_file(date): <NEW_LINE> <INDENT> date = parse_time(date) <NEW_LINE> tmp_dir = tempfile.mkdtemp() <NEW_LINE> base_url = 'ftp://legacy.gsfc.nasa.gov/FTP/glast/data/lat/weekly/spacecraft/' <NEW_LINE> fbasename = 'lat_spacecraft_weekly_w' <NEW_LINE> weekly_file_start = parse_time('2008-08-07') <...
Downloads the FERMI/LAT weekly pointing file corresponding to the specified date. This file contains 1 minute cadence data on the spacecraft pointing, useful for calculating detector angles. Parameters ---------- date : `datetime.datetime` A datetime object or other date format understood by the parse_time fu...
625941ba55399d3f0558853f
def kmerFrequencies(self,samp=None): <NEW_LINE> <INDENT> res = self._kmers(samp,self.frequences,self.resultF) <NEW_LINE> normPolicy = self.normPolicy <NEW_LINE> assert normPolicy & NORM_POLICY.FREQ, normPolicy <NEW_LINE> if normPolicy & NORM_POLICY.EU_ROW: <NEW_LINE> <INDENT> res["val"] /= n.sqrt(n.dot(res["val"],res["...
Return frequencies normalized according to normalization policy supplied to ctor. @param[in] samp If not None, process() will be called first for this data, and then count returned. Otherwise it will assume that process() has been called before (maybe multiple times), and simply finalize and return counts.
625941ba4d74a7450ccd404f
def get_ResponseFile(self): <NEW_LINE> <INDENT> return super(IHttpResponse, self).get_ResponseFile()
Method IHttpResponse.get_ResponseFile OUTPUT responseFilePath : BSTR*
625941baf548e778e58cd408
def lastScenePos(self): <NEW_LINE> <INDENT> pass
QGraphicsSceneMouseEvent.lastScenePos() -> QPointF
625941ba8e05c05ec3eea1fd
def test_case(self): <NEW_LINE> <INDENT> self.assertEquals( Select( [Case((self.schema.FOO.BAR < 1), Constant(2), Constant(3))], From=self.schema.FOO, Limit=123 ).toSQL(), SQLFragment("select case when BAR < ? then ? else ? end from FOO limit ?", [1, 2, 3, 123]) ) <NEW_LINE> self.assertEqual(Case((self.schema.FOO.BAR <...
A L{Case} object will generate an appropriate SQL statement.
625941ba5166f23b2e1a4fe5
def get_exif_data(image): <NEW_LINE> <INDENT> exif_data = {} <NEW_LINE> try: <NEW_LINE> <INDENT> info = image._getexif() <NEW_LINE> if info: <NEW_LINE> <INDENT> for tag, value in info.items(): <NEW_LINE> <INDENT> decoded = TAGS.get(tag, tag) <NEW_LINE> if decoded == "GPSInfo": <NEW_LINE> <INDENT> gps_data = {} <NEW_LIN...
Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags
625941baa8370b771705272c
def _ok_to_deallocate_displist(self): <NEW_LINE> <INDENT> raise Exception("subclass must implement")
Say whether it's ok to deallocate self's OpenGL display list right now (assuming our OpenGL context is current). [subclasses must override this]
625941ba507cdc57c6306b60
def get_insert_columns(self, join=True): <NEW_LINE> <INDENT> columns = "" <NEW_LINE> for item in self.columns: <NEW_LINE> <INDENT> thistype = item[1][0] <NEW_LINE> if ((thistype != "skip") and (thistype !="combine") and (self.contains_pk == True or thistype[0:3] != "pk-")): <NEW_LINE> <INDENT> columns += item[0] + ", "...
Gets a set of column names for insert statements.
625941ba8a43f66fc4b53ef5
def run_command_verbose(self, cmd): <NEW_LINE> <INDENT> LOG.info("Running command %s", cmd) <NEW_LINE> stdout, stderr, exit_code = self.run_remote_cmd(cmd) <NEW_LINE> LOG.info("The command returned the output %s", stdout) <NEW_LINE> LOG.info("The stderr of the command was %s", stderr) <NEW_LINE> LOG.info("The exit code...
Run the given command and log anything it returns.
625941ba236d856c2ad4466a
def user_order_heartbeat(self,mission_id): <NEW_LINE> <INDENT> helper=DBHelper(1) <NEW_LINE> statement='update mission set status=2 where status=0 and end_time<'+str(time.time()) <NEW_LINE> helper.commit(statement) <NEW_LINE> now=time.time() <NEW_LINE> statement='update user_order set status=4 where %f-order_begin_time...
更新任务状态,下发任务
625941ba8a349b6b435e8000
def normalise(self, meta, val): <NEW_LINE> <INDENT> if hasattr(self, "normalise_either"): <NEW_LINE> <INDENT> result = self.normalise_either(meta, val) <NEW_LINE> if result is not NotSpecified: <NEW_LINE> <INDENT> return result <NEW_LINE> <DEDENT> <DEDENT> if val is NotSpecified: <NEW_LINE> <INDENT> if hasattr(self, "n...
Use this spec to normalise our value
625941ba63f4b57ef0000fad
def test_index(self): <NEW_LINE> <INDENT> resp = self.app.get("/") <NEW_LINE> self.assertEqual(resp.status_code, status.HTTP_200_OK) <NEW_LINE> self.assertIn(b"NYU DevOps eCommerce Promotions", resp.data)
Test index call
625941ba9b70327d1c4e0c60
def create_test_posts(instance): <NEW_LINE> <INDENT> instance.post = Post( title="My first title", description="", source="some text [...] end of abstract", author= instance.staffUser ) <NEW_LINE> instance.post.save() <NEW_LINE> instance.post2 = Post( title="My second title", description="", source="some text [...] end...
Create 4 test posts for tests. run create_test_tags and create_test_users first.
625941ba99cbb53fe6792a73
def _loop_watching_for_changes(self): <NEW_LINE> <INDENT> while not self._quit_event.is_set(): <NEW_LINE> <INDENT> if self.ready: <NEW_LINE> <INDENT> if self._automatic_restarts: <NEW_LINE> <INDENT> self._handle_changes(_CHANGE_POLLING_MS) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> time.sleep(_CHANGE_POLLING_MS/1000...
Loops until the InstancePool is done watching for file changes.
625941ba66656f66f7cbc036
def update_docker_compose(self, default_rabbit_link="rabbitmq", toggle=False): <NEW_LINE> <INDENT> dc_filepath = os.path.join(self.project_dir, 'docker-compose.yml') <NEW_LINE> with open(dc_filepath, 'r') as _: <NEW_LINE> <INDENT> docker_compose = yaml.load(_) <NEW_LINE> docker_compose.pop('version') <NEW_LINE> <DEDENT...
Generate docker-compose.yml
625941ba26238365f5f0ecf6
def endGeom(self, nodeName): <NEW_LINE> <INDENT> if self.writer is not None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> geom = Geom(self.vdata) <NEW_LINE> geom.addPrimitive(self.prim) <NEW_LINE> node = GeomNode("gui_geom") <NEW_LINE> node.addGeom(geom) <NEW_LINE> nodepath = NodePath(n...
Finishes creating the geometry and returns a node.
625941ba6fece00bbac2d5c7
def reflection_normal(outgoing_ray, incoming_ray): <NEW_LINE> <INDENT> ray1 = normalize(-incoming_ray) <NEW_LINE> ray2 = normalize(outgoing_ray) <NEW_LINE> return normalize((ray1 + ray2)/2)
Returns the normal vector between incoming and outgoing reflection rays.
625941ba3c8af77a43ae3629
def _wx_add_view_with(self, dock_control, with_obj): <NEW_LINE> <INDENT> with_item = self._wx_view_dock_window.get_control(with_obj.id) <NEW_LINE> if with_item is None: <NEW_LINE> <INDENT> raise ValueError("Cannot find item %s" % with_obj) <NEW_LINE> <DEDENT> with_item.parent.add(dock_control)
Adds a view in the same region as another item.
625941bac4546d3d9de728bd
def update(force_save=False): <NEW_LINE> <INDENT> need_save = find_changes() <NEW_LINE> need_save = need_save or force_save <NEW_LINE> global persistent_mtime <NEW_LINE> pairs = renpy.loadsave.location.load_persistent() <NEW_LINE> pairs.sort() <NEW_LINE> mtime = persistent_mtime <NEW_LINE> for mtime, other in pairs: <N...
Loads the persistent data from persistent files that are newer than persistent_mtime, and merges it into the persistent object.
625941ba16aa5153ce362304