content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
import copy def mutate(sequence,variants_df): """ This function takes in a Seq object and a data frame with mutations with chr, pos, ref, var columns. It applies the mutations and then returns a sequence containing all the mutations in the variant data frame. maybe I'll use lists of sequences instead of ...
aa5cbdd42e43d9e6f27721715c49f7a2b0413399
41,241
def question_result_type(response): """ Generate the answer text for question result type. :param response: Kendra query response :return: Answer text """ try: faq_answer_text = "On searching the Enterprise repository, I have found" \ " the following answer in t...
15fd06ee46d6377f1fe38243c11acf5e66d739b6
41,243
from typing import Counter def add_numbers_to_repeated_items(items_list) -> list: """Add numeric consecutive labels to repeated items in a list. :param items_list: list of strings :return: list """ updated_items_list = [] counts = Counter(items_list) current_count = {} for item in it...
5b3337d4b75521e121c8011827eafe7b49dec88f
41,244
def readItemsFile(fileName): """ itype: String, items file name rtype: String, raw data of items file """ with open(fileName, 'r', encoding='utf-8') as f: data = f.read().strip() # remove 3ds header if data and ord(data[0]) == 65279: data = data[1:] return data
291b468813102467e47b8bca1d103d69ee8efc3c
41,245
def _get_ui_metadata_data(metadata, config, result_data): """Get ui metadata data and fill to result.""" data_dict = {} for key, config_value in config.items(): if isinstance(config_value, dict) and key != 'content_data': if key in metadata.keys(): _get_ui_metadata_data(m...
35feff19e63c34e1084211982c646fb2c44bf209
41,246
import numpy def check_lats(climatology_dict, experiment): """Sometimes the latitude axes are not exactly equal after regridding.""" experiment_lats = climatology_dict[experiment].coord('latitude') control_lats = climatology_dict['piControl'].coord('latitude') if not control_lats == experiment_lats: ...
c2e5643884f1931e989223f4b8146ccde097d15a
41,247
def list_2_dict(kv_list, fld_del="."): """Function: list_2_dict Description: Change a key.value list into a dictionary list. The key_value is a list of keys and values delimited. Values for the same key will be appended to the list for that key. Arguments: (input) kv_list -> K...
25c0177a466a633cee156119ec67d5143db774c2
41,248
def sftp_prefix(config): """ Generate SFTP URL prefix """ login_str = '' port_str = '' if config['username'] and config['password']: login_str = '%s:%s@' % (config['username'], config['password']) elif config['username']: login_str = '%s@' % config['username'] if config...
225ae15212f7024590b1aa91f3ad7a32594cb9c3
41,250
import os def RelativizePaths(base, paths, template): """converts paths to relative paths""" rels = [] for p in paths: #print "---" #print "base: ", os.path.abspath(base) #print "path: ", os.path.abspath(p) relpath = os.path.relpath(os.path.abspath(p), os.path.dirname(os.path.abspath(base))).rep...
7a881c245c256f8f60c2d85f5eab1d7cd5379d7c
41,251
def minimum_swaps(arr: list) -> int: """ Time Complexity: O(n Log n) Auxiliary Space: O(n) """ length = len(arr) # Create list of pairs where each pair; the first element in the pair is the index of the element & second is # the value array_positions = [*enumerate(arr)] # Sort the...
77f0eecd25dedaf0e7938a218e94514f51ffd634
41,252
def get_prov(uid): """ return provenance string """ return uid.prov
0f92e61f946f42ddcda0ca8962e6364ef3c2cc32
41,253
import os def likelihood_files_are_close(filepaths: list, compare_path: str): """ Find all of the paths in filepaths that are in the same directory alongside compare_paths filenames = ['testthis', 'testoutthisthing', 'whataboutthisguy'] compare_file = 'testout' likelihood_file_name_match(filename...
0522d32d446c36d11c4614cedd85bf18854feb0b
41,254
def wrap_row(r:list, by:int = 1) -> list: """Wraps the list r by number of positions. Positive by will shift right. Negative shifts left. Args: r (list): list to wrap. by (int, optional): number of positions to shift by. Defaults to 1. Returns: list: wrapped list. ...
bb1302fd7f20e2a8f3356448cc6da3826b3baf4d
41,255
import re def extract_pin(module, pstr, _regex=re.compile(r"([^/]+)/([^/]+)")): """ Extract the pin from a line of the result of a Yosys select command, or None if the command result is irrelevant (e.g. does not correspond to the correct module) Inputs ------- module: Name of module to ex...
6d48dc9ccdb2dfe1dc89a8c7a56f564fccfe60a3
41,256
import os def find_locks(ldir): """Finds all files whose name begins with 'lock-' within the directory ldir, and returns their paths as a list. Returns an empty list if no locks are found. Recursively searches subdirectories of ldir.""" lock_list = [] lock_filename_start = "lock-" if(os...
b82a37da265de9cd3eab7ff73309733efa98af98
41,257
def compute_logits(theta, ob): """ theta: A matrix of size |A| * (|S|+1) ob: A vector of size |S| return: A vector of size |A| """ #ob_1 = include_bias(ob) logits = ob.dot(theta.T) return logits
1913409b9a2f95b83c199379d602d111f6e49851
41,260
def AddOrdinalSuffix(value): """Adds an ordinal suffix to a non-negative integer (e.g. 1 -> '1st'). Args: value: A non-negative integer. Returns: A string containing the integer with a two-letter ordinal suffix. """ if value < 0 or value != int(value): raise ValueError('argument must be a non-ne...
732ac382c83983d2083f22bb23ff8968bb05875d
41,261
def slim_to_keras_namescope(): """ Utility function that produces a mapping btw old names scopes of MobilenetV1 variables """ nameMapping = {} nameMapping['MobilenetV1/Conv2d_0/conv2d/kernel'] = 'MobilenetV1/Conv2d_0/weights' for i in range(1,14): newNameDepthwise = 'MobilenetV1/Conv...
3c827eba99c727ef97343cb659c59aeb5a656023
41,262
def first_player_wins(a, b): """ If tie : Returns 0 If first player wins : Returns 1 If second player wins : Returns -1 """ if a == b: return 0 elif [a, b] == ["R", "S"] or [a, b] == ["S", "P"] or [a, b] == ["P", "R"]: return 1 return -1
ebb0b92862039ed5a8227573d5e79e1a5ea7f353
41,264
def _get_right_parentheses_index_(struct_str): """get the position of the first right parenthese in string""" # assert s[0] == '(' left_paren_count = 0 for index, single_char in enumerate(struct_str): if single_char == '(': left_paren_count += 1 elif single_char == ')': ...
43c1d890fb4ba62ae6e1a7c7df603428f9b342cd
41,265
def collect_village_number_for_binoculars(): """Let the user pick the village to peek into.""" while True: print("") village_for_binoculars = input("Which village would you like to peek into? Enter the village number. >") #print(type(village_for_binoculars)) village_for_binoculars = int(villag...
f97b9121f1f7efc126e5f9410358037300a2349d
41,266
def same(obj1,obj2): """ helper function to identify empty measurement instances """ if obj1.__class__ != obj2.__class__: return False if obj1.get() != obj2.get(): return False return True
e580ebc6e29fbecf7667f04b7ae448051c75bf29
41,267
def obs_is_afternoon(obcode): """Given an observation code (eg 'ob_1a', 'ob12_b') is this an afternoon obs?""" return obcode[-1] == 'b'
8d1f87b7f526f98a831c1da3fd6ebeb429d954ef
41,268
def center_on_atom(obj_in, idx=None, copy=True): """Shift all coords in `obj` such that the atom with index `idx` is at the center of the cell: [0.5,0.5,0.5] fractional coords. """ assert idx is not None, ("provide atom index") obj = obj_in.copy() if copy else obj_in obj.coords = None # [......
690f12a7e95a8e24930096e76941c3061a080b17
41,269
import platform def format_npm_command_for_logging(command): """Convert npm command list to string for display to user.""" if platform.system().lower() == 'windows': if command[0] == 'npx.cmd' and command[1] == '-c': return "npx.cmd -c \"%s\"" % " ".join(command[2:]) return " ".joi...
d99ccb88b337e5db19550415227c49800d7323b5
41,270
def binary_search(num_list, num, not_found="none"): """Performs a binary search on a sorted list of numbers, returns index. Only works properly if the list is sorted, but does not check whether it is or not, this is up to the caller. Arguments: num_list: a sorted list of numbers. num: ...
91b77d6910698e18f0369990dee11dfab3333b6e
41,271
def _int_to_hex(x: int) -> str: """Converts an integer to a hex string representation. """ return hex(x)
2a9bdeb96339747ec33e90393a448519daa59a84
41,272
def make_header(map_table_row, sort1, sort2, sort3): """ 項目に応じたヘッダをセット """ header_data = {} header_data["name"] = map_table_row["name"] header_data["config"] = map_table_row["config"] header_data["sort1"] = sort1 header_data["sort2"] = sort2 header_data["sort3"] = sort3 return he...
f0f83e90174d676a0d9c5368e9d272c07433321b
41,273
def encode_generator(obj): """Encode generator-like objects, such as ndb.Query.""" return list(obj)
989ce609070bb8d7be545ca5d439387aa99cff52
41,274
def toggle_modal(n1, n2, is_open): """ Controls the state of the modal collapse :param n1: number of clicks on modal :param n2: number of clicks on close button :param is_open: open state :return is_open: open/close state """ if n1 or n2: return not is_open return is_open
0eb9addbcdd7d7b7eecf8f661a380bf065fb963f
41,275
def printfunccloser(): """ return the closer to a printfunc """ s = """ print__closing(); } """ return s
5d6791287327c54b417d5000323e565ab7bc5555
41,276
import os def get_git_dir(tree): """Get Git directory from tree.""" return os.path.join(tree, ".git")
d654643f0bb8c9b6de8007fad4c7f654e91defa8
41,277
import copy def get_root_source(source): """ Get the main file source from a doc's source list. Parameters: source (str/list/dict): contents of doc['source'] or the doc itself. Returns: str: "root" filename, e.g. if source = ['KP.cell', 'KP.param', 'KP_specific_structure.res'...
d5e81089ca3706aef6289fb1ec1375c7e4bde7c8
41,280
def bai_from_bam_file(bam_file): """ Simple helper function to change the file extension of a .bam file to .bai. """ if not bam_file.endswith('.bam'): raise ValueError('{0} must have a .bam extension.'.format(bam_file)) return bam_file[:-3] + 'bai'
812aee46a94a3a1d3eec15a72d820785cf531692
41,282
def get_events_summaries(events, event_name_counter, resource_name_counter, resource_type_counter): """ Summarizes CloudTrail events list by reducing into counters of occurences for each event, resource name, and resource type in list. Args: events (dict): Dictionary containing list of CloudTrail events...
b8d061f9710a3914b74da9ec56a2037dcf8320d4
41,283
def _convert_to_code(input, k): """ Converts a binary string into words of k length """ current = 0 res = [] #Need it to round downwards for i in range(int(len(input)/k)): row = [int(e) for e in list(input[current:current+k])] res.append(row) current = current + k return ...
b1e1cc9b6aafcc7afdc99689639190d54dd177bc
41,285
def note_css_class(note_type): """ Django Lesson Note Type text = blocks.TextBlock() note_type = blocks.ChoiceBlock( choices=( ('info', 'Info'), ('warning', 'Warning'), ('danger', 'Danger'), ('note', 'Note'), ), required=False, ...
241ec5698e384d1d5026b955b32bff8e8e188dd3
41,286
def ion_size(): """ Library of ion size parameters. Mapped to formulas used in ModelSEED database From lookup table in excel spreadsheet released by Brian M. Tissue http://www.tissuegroup.chem.vt.edu/a-text/index.html This is only a partial list for now, can populate more as needed """ ...
17b29d502d5e4d879b591e8755fe69bbdab48e6b
41,288
def polynomial(coeffs): """ Return a polynomial function which with coefficients `coeffs`. Coefficients are list lowest-order first, so that ``coeffs[i]`` is the coefficient in front of ``x**i``. """ if len(coeffs)==0: return lambda x:x*0 def f(x): y=(x*0)+coeffs[0] ...
4df8fa27e3dab2d7feca9b19d6e8f87a07acd100
41,289
import collections def group_train_data(training_data): """ Group training pairs by first phrase :param training_data: list of (seq1, seq2) pairs :return: list of (seq1, [seq*]) pairs 这里的defaultdict(function_factory)构建的是一个类似dictionary的对象, 其中keys的值,自行确定赋值,但是values的类型,是function_factory的类实例,而且具有...
b224d7585ab57ea872582d8ef08cc3ebb0516af7
41,290
from urllib.request import Request, urlopen import csv def available_environments(repository="http://sintefneodroid.github.io/environments/ls"): """ @param repository: @type repository: @return: @rtype: """ req = Request(repository, headers={"User-Agent": "Mozilla/5.0"}) environments_m_csv = u...
d7d2c58cc3c09d1493999b408872397dd40f32dc
41,291
import math def get_xy(lat, lng, zoom): """ Generates an X,Y tile coordinate based on the latitude, longitude and zoom level Returns: An X,Y tile coordinate """ tile_size = 256 # Use a left shift to get the power of 2 # i.e. a zoom level of 2 will have 2^2 = 4 tiles ...
eca13cf7d5ba4ba8b3799d80d6d71c7e72eb4402
41,293
import functools def traceproperty(fn): """Trace all basic torcharrow functions operating on given types.""" @functools.wraps(fn) def wrapped(*args, **kwargs): # # same code as above, except for this line... # fn._is_property = True # #find the scope:: # # at least one pos...
806cda3b5a7fdd2a89bd0b18a491c4e2029a667d
41,294
import ast def eval_condition(condition, locals): """Evaluates the condition, if a given variable used in the condition isn't present, it defaults it to None """ condition_variables = set() st = ast.parse(condition) for node in ast.walk(st): if type(node) is ast.Name: condi...
f3fb7a871c16f22b2cd5f9d5087aec364772f6bb
41,296
def echo(data): """ Just return data back to the client. """ return data
80655150d1578c12b2f196b664df8935bae569f1
41,297
from typing import Sequence from typing import List from typing import Any def generate_by_char_at(attr_ind: int, dtuple: Sequence, pos: List[Any]): """ Generate signatures by select subset of characters in original features. >>> res = generate_by_char_at(2, ('harry potter', '4 Privet Drive', 'Little Whingin...
b455b46751e8afda705dc4ff7da3a26ff1404097
41,298
def style_function_color_map(item, style_dict): """Style for geojson polygons.""" feature_key = item['id'] if feature_key not in style_dict: color = '#d7e3f4' opacity = 0.0 else: color = style_dict[feature_key]['color'] opacity = style_dict[feature_key]['opacity'] sty...
b7c5a41b96eb550087819e079397f191bdb4de1c
41,299
def _to_date(date_s): """ .. note:: Errata issue_date and update_date format: month/day/year, e.g. 12/16/10. >>> _to_date("12/16/10") (2010, 12, 16) >>> _to_date("2014-10-14 00:00:00") (2014, 10, 14) """ if '-' in date_s: return tuple(int(x) for x in date_s.split()[0].spl...
a331d54394a7d59a1ab7b9441e554ef8fe6c4c18
41,300
def uhex(num: int) -> str: """Uppercase Hex.""" return "0x{:02X}".format(num)
f6025d7aa2a3b1cbf8286a878b5bc6f9dcc87f4c
41,301
import os def is_git_repository(directory='.'): """Returns whether the current working directory is a Git repository.""" return os.path.exists('{}/.git'.format(directory.rstrip('/')))
635e9dc6a9c2a1446a1598694d3d585805787907
41,302
from operator import mul from functools import reduce def _make_member_list(n): """Takes the length of three cyclic group and constructs the member list so that the permutations can be determined. Each member has three components, corresponding to the entries for each of the three cyclic groups. ...
45245adc903478b557a443c460d9bc78376d273f
41,303
import torch def rae(target, predictions: list, total=True): """ Calculate the RAE (Relative Absolute Error) compared to a naive forecast that only assumes that the future will produce the average of the past observations Parameters ---------- target : torch.Tensor The true values of ...
6f3650873d00fcd237bb608eed58593a927d8815
41,304
import operator def count_words(s, n): """Return the n most frequently occurring words in s.""" # Count the number of occurrences of each word in s dictionary = {} s = s.split(" ") for word in s: if word in dictionary: dictionary[word] += 1 else: dictionary...
f5d2595ffadc1eebf671d3a11ee2ead45466a732
41,305
import time def timeFunction(f, k, V, S): """ (int x list[int] x int x bool -> tuple[int, _]) x int x list[int] x int -> tuple[float, int] returns the execution time of the function <f> for the given arguments, and the number of jars of the its solution """ # t0, tf: float t0 = time.process_time() # n: int ...
f2e50399f51e38b5d2e146cc343ecd6ceef3138c
41,306
def server_address(http_server): """IP address of the http server.""" return http_server.server_address[0]
ff5c9e56f7db02924913c1f9484c83d8091c9d67
41,308
def gen_bad_labels(badcase_type, frame_objs): """ 生成每帧所对应的bad_labels 检测框以及其对应的信息 """ bad_labels = [] for j in range(len(badcase_type)): if badcase_type[j] == -1: continue tlwh = frame_objs[j][0] label_name = frame_objs[j][2] loc_x1 = tlwh[0] loc_y1...
2e42e5e159ddd99adcdcb5d42c00ace50623eb7c
41,309
def three_points_solve1(li, lj, lk, a, b, eps=1e-6): """ (1) + (2) """ lkj, lji = lk - lj, lj - li w2 = (a + b) / (lkj / b - lji / a + eps) dx = -(w2 * lji / a + a) / 2 # dx = (lkj * a * a + lji * b * b) / (lji*b - lkj * a) / 2 return w2, dx
54d17e22b47de95dbd2b00606668050fccb9cbc1
41,312
def isNestedInstance(obj, cl): """ Test for sub-classes types I could not find a universal test Parameters ---------- obj: object instance object to test cl: Class top level class to test returns ------- r: bool True if obj is indeed an instance or subclass...
bca1adb3ba93605b55ed6d204e89210d6b570882
41,314
def _transform_metric(metrics): """ Remove the _NUM at the end of metric is applicable Args: metrics: a list of str Returns: a set of transformed metric """ assert isinstance(metrics, list) metrics = {"_".join(metric.split("_")[:-1]) if "_cut" in metric or "P_" in metric el...
13747864d70f7aae6aaec5c9139724ff6c8cb7fb
41,315
def ProgressBar(percent, prefix=None, notches=50, numericalpercent=True, unicode=False): """Accepting a number between 0.0 and 1.0 [percent], returns a string containing a UTF-8 representation of a progress bar of x segments [notches] to the screen, along with an optional indication of the progress as the ...
1ad220f55d9dd242778f879c75905a0484bdbd73
41,316
import re def get_inputs( filename ): """ Each line in the input file contains directions to a tile starting from the origin. This function returns a list of lists with directions to each tile. """ with open( filename, 'r' ) as input_file: raw_data = input_file.read().splitlines() ...
d4171a45d93db37959d9422a3d12c193249856a1
41,318
import torch def compute_overlaps(batch): """Compute groundtruth overlap for each point+level. Note that this is a approximation since 1) it relies on the pooling indices from the preprocessing which caps the number of points considered 2) we do a unweighted average at each level, without consi...
7fdc3492981a7c52090a887c643cb60e4445894c
41,319
def _is_ethaddr(input): """判断是否是合法 eth 地址 Args: input (str): 用户输入 """ if len(input) != 42 or not input.startswith("0x"): return False try: int(input, 16) except: return False return True
93340d93f12b73e46d632d6e2fe0cf26aa413bc3
41,320
def xor(x, y): """N.B.: not lazy like `or` ...""" return bool(x) != bool(y)
248f5aecfdc20eb331ce7bcd70192d74522e797c
41,321
import sys def get_sequence(fasta): """get the description and trimmed dna sequence""" in_file = open(fasta, 'r') content = in_file.readlines() in_file.close() content2 = [] for i in content: if i != "": content2.append(i) content = content2 while content[0] == "" or content[0] == "\n": ...
7e4b162b44fa77b4ec0672c420174024fb6812b3
41,322
import socket def hostname(): """Get the name of the host system. Returns ------- str The domain name of the current host. """ return socket.getfqdn()
23d18c81a785e74e3d632bfc7beb32d359ed9544
41,323
def is_boundary(loop): """Is a given loop on the boundary of a manifold (only connected to one face)""" return len(loop.link_loops) == 0
4d4df7e552c6a57b42fa3e9c43682368ae5091c1
41,325
import os import random import string def get_secret_key(app, filename='secret_key'): """Get, or generate if not available, secret key for cookie encryption. Key will be saved in a file located in the application directory. """ filename = os.path.join(app.root_path, filename) try: return ...
54dbb6cbcdd8fbf6a5a060fa88ba9c3ef48d908c
41,326
import itertools def main(): """Generates SQL for comparing rows in a table. Takes a list of fields to compare, generates all combinations of those fields, compares each combination and counts amount""" sql = '''DECLARE @resultants TABLE ( [Duplicate Count] NVARCHAR(64) , [Matched on]...
c1ad81ec0ffbed6611f3219e24f17c56547e3d6f
41,327
def get_semantic_feature_path(): """Add here the path to the semantic features file. This is a file that contains the stimuli and question representations.""" return 'data/MTurk_semantic_features.npz'
a738fe399c3022af3b8ed9a9fc1ef0b040ace465
41,328
def spdk_kill_instance(client, sig_name): """Send a signal to the SPDK process. Args: sig_name: signal to send ("SIGINT", "SIGTERM", "SIGQUIT", "SIGHUP", or "SIGKILL") """ params = {'sig_name': sig_name} return client.call('spdk_kill_instance', params)
16ac6264d0e26de8e6dad86b0107f0ba21d62973
41,329
def _resolve_none(inp): """ Helper function to allow 'None' as input from argparse """ if inp == "None": return return inp
452ee9b4ec24f08126b533922d21ed1cf32db3eb
41,330
import sys def is_notebook() -> bool: """Returns True if running in a notebook (Colab, Jupyter) environment.""" # Use sys.module as we do not want to trigger an import (slow) IPython = sys.modules.get('IPython') # pylint: disable=invalid-name # Check whether we're not running in a IPython terminal if IPyth...
eb2f450d89b61fb1f75967f0850f6389468e06b0
41,331
def collapse(array): """ Collapse a homogeneous array into a scalar; do nothing if the array is not homogenous """ if len(set(a for a in array)) == 1: # homogenous array return array[0] return array
1573cbcfe3691b83be4710e3d2ea1ff3791bc098
41,334
from typing import Union import time def time_ms(as_float: bool = False) -> Union[int, float]: """Convert current time to milliseconds. :param as_float: result should be float, default result is int :return: current time in milliseconds """ _time_ms = time.time() * 1000 if not as_float: ...
9e9dd47636182935d2a6f52156fc987996c75ec3
41,335
def show_user_details2(): """ 103 Adapt program 102 to display the names and ages of all the people in the list but do not show their shoe size. :return: user details without shoe size """ users, counter = {}, 4 while counter: name = input(f"{counter} to go; Enter user name: ")....
c43d87c1b5ec3bd760f9b488d5cb6d6a8f674873
41,336
import re def char_replace(output, content_data, modification_flag): """ Attempts to convert PowerShell char data types using Hex and Int values into ASCII. Args: output: What is to be returned by the profiler content_data: [char]101 modification_flag: Boolean Returns: ...
58f433f5c28d26be18853a4414be0acf9176acc6
41,337
def is_worth_living(Life): """ 未经审视的人生不值得度过。 -- 苏格拉底 """ return Life.be_examined
143cc3299b016bb3a296b427400d4420d93c3fec
41,338
def get_name(self): """ Get dataframe name :param self: :return: """ return self._name
e539c4753f0e5a73191ab3c444e3c8160d09c937
41,339
def getcode(line): """ Extract out the Geonames reference code for searching. """ split_line = line.split('\t') head = split_line[0][2:] desc = split_line[1] return (head, desc)
fd647765934571c2bf1f4d55e94f572a26bf5250
41,342
import os def get_mp3_filenames(directory="../data/fma_small"): """ Get the path of each mp3 file under the given root directory :param directory: root directory to search :return: List[String] """ filenames = [ os.path.join(root, file) for root, _, f in os.walk(directory) for file in ...
3cb099cce7a42f075f417fae9ad53d1fe27073ce
41,343
import re def verify_pattern(pattern): """Verifies if pattern for matching and finding fulfill expected structure. :param pattern: string pattern to verify :return: True if pattern has proper syntax, False otherwise """ regex = re.compile("^!?[a-zA-Z]+$|[*]{1,2}$") def __verify_pa...
75fbef4839bedce8ef70c44ff137896f3caf7a25
41,345
def turn(guti,guti2): """Set the turn in the player one.""" if guti.guti_rect.left == 147 and guti.guti_rect.bottom == 601: if guti2.guti_rect.left == 147 and guti.guti_rect.bottom == 601: return 1
62b5809e11016b8119da8bbe55081d5af7248ce3
41,346
def path_add_str(path_): """ Format path_ for console printing """ return '+ {}'.format(path_)
0f1edde223e432560482edd68f78cb2b42a6bc84
41,347
def get_time_in_min(timestamp): """ Takes a timestamp, for example 12:00 and splits it, then converts it into minutes. """ hours, minutes = timestamp.split(":") total_minutes = int(hours)*60+int(minutes) return total_minutes
ef7f8418ad50a2ac0c2814610004aec48236f5a8
41,348
def is_leaf(tree): """ :param tree: a tree node :return: True if tree is a leaf """ if tree.left is None and tree.right is None: return True return False
5db41c7c31ba9edd03d86d8463ef23b5e289e38b
41,349
def removeForwardSlash(path): """ removes forward slash from path :param path: filepath :returns: path without final forward slash """ if path.endswith('/'): path = path[:-1] return path
bbba3cd1d3c051f805bda075227ce1ba4428df8c
41,351
def keyvalue2str(k, v): """ A function to convert key - value convination to string. """ body = '' if isinstance(v, int): body = "%s = %s " % (k, v) else: body = """%s = "%s" """ % (k, v) return body
b5ac3f07a71c5fe9e223316d637a252dc0791d15
41,352
def getAgnData(hd_agn, agn_FX_soft, redshift_limit): """ Function to get the relavant data for AGNs @hd_agn :: table file with all relevant info on AGNs @AGN_FX_soft, AGN_SDSS_r_magnitude :: limits on flux, and brightness to be classified as an AGN @redshift_limit :: decides until which AGNs to cons...
b9f048e8ff2055a38f66959b8465279d0fa34609
41,353
def extract_name_and_link(a_object): """ Get the source name and url if it's present. Parameters: ---------- - a_object (bs4.element.Tag - `a`) : an a object html tag parsed by beautiful soup 4 Returns: ---------- - source_name (str) : the plain text source name as included by Ad Fonte...
aebe743e27c2150cd81b582075091386253939e5
41,354
def my_potential_energy(rij, rc): """ Calculate total potential energy. Args: rij (np.array): distance table, shape (natom, natom) Return: float: total potential energy """ vshift = 4 * rc ** (-6) * (rc ** (-6) - 1) potential = 0.0 for i in range(len(rij)): for j in rang...
6fbf172f2c9cda19edd1222f7efdf384f6d67fc1
41,355
import random import copy def make_steps(first_step, tasks): """ """ step = first_step fail_count = 0 steps = [] while True: # details = copy.deepcopy(tasks[step]) details = tasks[step] if 'yield' in details.keys(): if random.random() < details['yield...
bc4a38318c63bbfa2fd21d256cf339b61e16645d
41,359
def async_get_pin_from_uid(uid): """Get the device's 4-digit PIN from its UID.""" return uid[-4:]
7556416888dbeaabd39c368458a8b64927a7a13a
41,360
import json import re def sd_tasktype_mapping(XNAT, project): """ Method to get the Task type mapping at Project level :param XNAT: XNAT interface :param project: XNAT Project ID :return: Dictonary with scan_type/series_description and tasktype mapping """ tk_dict = {} if XNAT.select('...
5530c3fe8ffc5a9eef2c3b3c0f4304072d3c84fd
41,362
def insert_ordered(value, array): """ This will insert the value into the array, keeping it sorted, and returning the index where it was inserted """ index = 0 # search for the last array item that value is larger than for n in range(0,len(array)): if value >= array[n]: index = n+1...
9f491aab83fcd3716eb5894d675ec4ba90bbbae9
41,363
def is_normal_meter(feet): """ Checks if the meter is normal (first syllables are at the beginning of a foot) :param feet: a list of feet ["vesi", "vanhin" "voite", "hista"] :return: True or False """ for foot in feet: for i in range(len(foot)): syllable = foot[i] ...
71bf08264cc31871e696a717d4824a58632c80dc
41,364
def compute_linenumber_stats(file_name): """ Collect data on number of total lines in the current file """ x = 0 with open(file_name) as input: for line in input: x = x + 1 return(x)
39a170010e0987903c080d2ebab1c37d7099af0b
41,365
def find_following_duplicates(array): """ Find the duplicates that are following themselves. Parameters ---------- array : list or ndarray A list containing duplicates. Returns ---------- uniques : list A list containing True for each unique and False for following dup...
aafd4bb76c318ed907732549e3650df063c8c5b5
41,366
def model_train(model, X, y): """ 模型训练 """ print(model) model.fit(X, y) return model
42548120473bba13147c57b4907dcdbbc3176014
41,369
import argparse def get_input_args(): """ Inputs are introduced through command line Args: None Inputs: --pedigreeFile path to the PED file --resultsDirectory save results to this directory """ parser = argparse.ArgumentParser() parser.add_argument('--pedigreeFile',...
95c1a0e9baebadc7bbec7de5d7a11b2b091ea57f
41,370