content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
def GetAutoCompList(self, command): """Apply SimpleCompleter results to base results from the 'smart' completer. """ baseList = self.BaseGetAutoCompList(command) scompList = self.scomp.GetAutoCompList(command) # Wipeout duplicates by creating a set, then sort data alphabetically baseList.ex...
2dd48f62b4fd121ecda238f553d54b13bdbb45d9
34,390
def uppercase(f): """ I am uppercase """ def f_wrapper(): """ I am uppercase wrapper """ return f().upper() return f_wrapper
50ac66e3c1a1440b60466676af48c27a81ca8c5c
34,391
def interpolation_search(sample_input, lowest, highest, item): """ function to search the item in a give list of item :param sample_input: list of number :param lowest: the lowest element on our list :param highest: the highest element on our list :param item: the item element to search in our l...
027cf3657a2540a87d2d7da2b122f4c5f47e9c54
34,392
def get_last_search_position(logger_file): """ Required for resuming the previous search operation :param logger_file: Logger file name :return: Last position id """ with open(logger_file, 'r+') as f: lines = f.read().splitlines() try: last_pos = lines[-1].split(' - '...
a58de436fab3f3da32913c475e205cd3ed49de6e
34,393
def check_domain_whitelist(string, whitelist): """ Returns True if a white listed domain appears in the string, otherwise returns False. :param string: A string possibly containing a domain name. :param whitelist: A list of strings containing white listed domains. :return: Bool """ for i in wh...
e92376a001fee8365ade4b829dd5daa7079063d8
34,394
def summarize_reduced_diffs(reduced_diffs): """ Print a human-readable summary of the relevant reduced diff data """ buf = "" ### General summary if 'sum_data_units_read_gibs' not in reduced_diffs: read_gibs = reduced_diffs.get('sum_data_units_read_bytes', 0) * 2.0**(-40) write_g...
8e3be22d11a3ae9f011edfa0fb28fdb859c7a980
34,395
import html def unescape(str): """ 反转译 """ return html.unescape(str)
aa5e0a9e15b5757d7c762fae4e144ae347ce88c4
34,396
import torch def copy_model_to_gpu(model, loss=None): """ Copies a model and (optional) loss to GPU and enables cudnn benchmarking. For multiple gpus training, the model in DistributedDataParallel for distributed training. """ if not torch.backends.cudnn.deterministic: torch.backends.c...
4fa61832eacdf3ab055e931fd9f952406f4aeca4
34,397
def get_strings(filename): """ Read strings from files generated by an IDAPython script and store them in a list for further processing. """ list_strings= [] with open(filename,'rU') as f: list_strings= [line[:-1] for line in f.readlines()] return list_strings
1f01bce01bd601e9bf25c8673fdcc97443384719
34,398
def _add_algorithm_defaults(algorithm): """Central location specifying defaults for algorithm inputs. Converts allowed multiple inputs into lists if specified as a single item. """ defaults = {"archive": [], "min_allele_fraction": 10.0, "tools_off": []} convert_to_li...
1c8b2b41e86fe8a484714916999e5f3b4de08ed4
34,403
from typing import List from typing import Any from typing import Dict def locate_or_create_pip_section_target(deps: List[Any]) -> Dict[str, Any]: """ :param deps: the "dependencies" section of the Conda YAML data :return: the (first) member of deps that is a dictionary; if there is none, one is appended....
a30cdf9c665f22ed3891b47eff1a54993d5c245e
34,404
import os def path_to_yaml_helper(yaml_path): """ Replace current OS path separater with forward slashes. """ return yaml_path.replace(os.path.sep, '/')
c3afe8078f6ab3e1585da3d8a69e0ebdd644b5b4
34,405
from typing import Any import hashlib def hex(data: Any) -> str: """Get sha512.""" if isinstance(data, str): data = data.encode("utf-8") return hashlib.sha512(data).hexdigest()
aad95dbcf69245d41b23115fd022f99340de060d
34,406
import click def extract_coord(reg_str): """Given a SAM-compatible genome coordinate, extract the values.""" reg_str = reg_str.replace(",", "") try: contig, reg_str = reg_str.rsplit(":", 1) except ValueError: # No start and end specified return reg_str, None, None try: ...
158273aed268769ba15f40259465d8ef78e8d149
34,408
import os def get_zip_info_from_offset(zip_file, offset): """Get the ZipInfo object from a zip file. Returns: A ZipInfo object found at the 'offset' into the zip file. Returns None if no file can be found at the given 'offset'. """ file_size = os.stat(zip_file.filename).st_size if o...
9b82afa8888a06927d0e7edd06fb0d87a88fc084
34,409
import difflib def compare_configs(cfg1, cfg2): """ This function, using the unified diff function, will compare two config files and identify the changes. '+' or '-' will be prepended in front of the lines with changes :param cfg1: old configuration file path and filename :param cfg2: new configu...
e0ad56de3f601a4f04347036106eb4de112afa83
34,410
def started_puller(system, puller, puller_start_message): """ fixture that create and start a PullerActor and actor before launching the test and stop it after the test end """ system.ask(puller, puller_start_message) return puller
2e8673d9e6d88c347a8b6b9ce5230cbf4efa9927
34,412
def _limit_description_to_key(description): """Translate between the description of the Text widget and the corresonding key and value pos in the fitarg dictionary. Parameters ---------- description : str The string describing the widget Returns -------- key : string The ke...
2fe559dbce1c61ac0c298e3132ca188b52a4b9e2
34,413
import warnings import collections import re def read_quants_gianninas(fobj): """Read and parse custom file format of physical stellar parameters from Gianninas et al 2014, [1]_. Parameters ---------- fobj : file object An opened file object to the text file with parameters. E...
0b0750686cb127c81d80566a7d6e40d48570fd72
34,414
def addtable(table, table_name): """ Adds a table and assigns a name. """ table_name=table.copy(deep=True) # we remove external reference table_name['fromdepth'] = table_name['fromdepth'].astype(float) table_name['todepth'] = table_name['todepth'].astype(float) table_name['collarid'] ...
de5ce38d546d0688d0f4f60e71618a0fa9bb4639
34,415
def getManifestSchemaVersion(manifest): """ returns manifest schema version for manifest""" return manifest["manifest"]["schemaVersion"]
45e028fbc7e08572d24495d8a69b48c150a0722a
34,417
import math def getCosineSetSim(concepts_1: set, concepts_2: set): """ Returns Cosine Set Similarity for the given concept sets """ intersection = len(concepts_1.intersection(concepts_2)) return intersection/(math.sqrt(len(concepts_2)*len(concepts_1)))
f6c03fa83d55c19f6d5953ef84a4d9233262386d
34,420
import functools def dec_busy(func): """ Decorator to set the amp/lcd controller state to busy while executing function. """ @functools.wraps(func) def wrapper(self, *args, **kwargs): self.busy = True output = func(self, *args, **kwargs) self.busy = False return o...
730a7cbe34f8323098aca441142c1c3c5fd1788c
34,421
def is_run(part): """ >>> is_run([4]) False >>> is_run([1, 2, 3]) True >>> is_run([3, 2, 1]) False """ if len(part) != 3: return False return part[0] + 2 == part[1] + 1 == part[2]
a7719c1a02a8a8a573e2bc69052711ec551b100f
34,422
def form_tree_definition(proj, formname): """Turn the form (instrument) definition in the project xml file into a python dictionary tree. In the XML structure items are defined in different places and the are various places where 'ref' items have to be looked up to find 'def'. Turn it into a nice ...
d1a2eb638eed9443af11ec933942f2179e20c79b
34,423
def parse_one_line(line): """ Get one line of a file in this format 16:17:266:2864 3:4:194:2443 and return a couple of lists [16,17,266,2864], [3,4,194,2443] """ line_trial, line_success = line.split(' ') one_trial = [int(s) for s in line_trial.split(':')] one_success = [...
8397e9fa742f42af5348d0bab0d459e98991b95f
34,426
def get_sanitized_git_link(git_repository_slug: str) -> str: """ >>> assert get_sanitized_git_link(git_repository_slug='pypa/pip') == 'git+https://github.com/pypa/pip.git' """ sanitized_git_link = 'git+https://github.com/{git_repository_slug}.git'.format(git_repository_slug=git_repository_slug) ret...
0fc8647cd2b74ef6720b2ece7bddae851d73c467
34,427
import traceback def stop_transfer_if_fail(f): """stop transfer if unexpected exception occurs""" def wrapper(transfer, *args, **kwargs): try: return f(transfer, *args, **kwargs) except Exception as e: transfer.stop(warning='%s closed because of %s' % ...
cc013b8ff44447c555e7d5becefe9067a15ec3a2
34,428
def get_employee_sick_leave_days(employee, month): """Calls the sick leave days for the given employee and month.""" return month.get_employee_sick_leave_days(employee)
171a17828c834718e79267bd1524194c66904bf7
34,429
def unsupLossBSchedule(iteration): """ Schedule for weighting loss between forward and backward loss """ if iteration > 400000: return 0.5 elif iteration > 300000: return 0.5 elif iteration > 200000: return 0.5 elif iteration > 190000: return 0.5 elif iteration > 180000: return 0.4 elif iteration > 1...
44bf2ec144af58fd6d29187d326b2e44a03a49d8
34,430
def sufficiency(tankstellen, scenario, capacity): """Calculate ratio if charging point is sufficient for e cars that want to charge. Args: tankstellen (gdf): Df containing all charging points with respective load (Belastung) scenario (string): Name of scenario column to calculate sufficiency ...
4c9895f3250ba54aaaa3f9f1b4ca9d426f4c26cc
34,431
import requests def get_tnstats(url, cookie): """ Retrieve Tunneled Node's agregated statistics :param url: base url :param cookie: Cookie value :return: TN Statisctics JSON :Example: result = get_tnstats(base_url, sessionid) """ header = {'cookie': cookie} get_tn_stats = requ...
2b182029d5e7fabebcb8df5fdd5ce42bf83ae1cd
34,432
def check_sample_id(value: str, length: int = 15) -> bool: """ Light validation of BMH Sample ID :param value: sample_id :param length: expected length of string """ if len(value) != length: return False components = value.split("-") if len(components) != 3: return False ...
e7d9da2f86f41503db09dfe74b4f181df8a1d579
34,433
def getLimFromPoints(pointsLists): """ Bestimmt die größten- und kleinsten X- bzw. Y-Werte aller Punkte Parameter: Eine Liste von Listen von Punkten. [[(x:flaot, y:flaot), ...], ...] Rückgabewert: ((xmin:flaot, xmax:flaot), (ymin:flaot, ymax:flaot)) """ xmin = xmax = pointsLists[0][0][0] ...
161a5623bb1f75583d9bb38fca7c54034d0012af
34,434
def section_string_to_dict(sectioned_report): """Parses a string containing the sectioned report into a dictionary containing each section and its content INPUT: String containing a sectioned report OUTPUT: Dictionary containing each section with its content""" sectioned_report_to_dict = {} labels =...
96be7d9a90d68b75965fc33deaf8c904ccc36eb4
34,437
import re def normalize(text: str) -> str: """ Replace all whitespaces in the text with a single space. For example " foo bar " is converted to "foo bar". """ return re.sub(r"\s+", " ", text).strip()
b8015d6004b57ff13c9d78acac4ff479ea327a11
34,438
import os def get_dir(filename: str, mode: str = 'dir') -> str: """Get file dir's name and dir's basename. If file located at /path/to/dir/file, then the dirname is "/path/to/dir", and basename is "dir" Args: filename: str. Local filename, normally it's __file__. mode: str. `file` return...
a5d91ac39bbbac32bc0608166e08116b641d4301
34,439
def qgis_vector_dissolve( processing, context, INPUT, FIELD, OUTPUT, USING_GDAL_FUNCTION=False ): """qgis dissolve input vector based on values in FIELD list ---------- Notes ------- Returns: ------- None, """ if USING_GDAL_FUNCTION: out = processing.run( ...
c8d262902d1631bae2f322c5e7070b72f2b4a03c
34,440
from typing import List from typing import Union def numeros_al_final_comprension(lista: List[Union[float, str]]) -> List[Union[float, str]]: """Re-escribir utilizando comprensión de listas.""" letras = [elem for elem in lista if type(elem) == str] numeros = [elem for elem in lista if type(elem) in [int, ...
5b7c08f614099590e927eeed3d3f4339b244813b
34,441
import time import select import errno def NoIntrPoll(pollfun, timeout=-1): """ This wrapper is used to handle the interrupt exceptions that might occur during a poll system call. The wrapped function must be defined as poll([timeout]) where the special timeout value 0 is used to return immediatel...
aa6abde06644560f0d0bc1983c226b7342b253fe
34,442
def egfr_38(): """Create test fixture for EGFR on 38""" return { "variant": "7-55142262-G-A", "assembly": "GRCh38", "total_observations": { "allele_count": 7, "allele_number": 152192, "decimal": "0.000045995" }, "max_pop_freq": { ...
93d0275e2b8e6794e8a09ec8720fb1e23824ade4
34,443
import os def create_dirs_path_object(path): """ Check and create path """ dir_exist = os.path.exists(path) if not dir_exist: os.makedirs(path) return True else: return False
5d5609e1f38c46064a1217b68142633f9c83b84b
34,445
def check_digit13(firsttwelvedigits): """Check sum ISBN-13.""" # minimum checks if len(firsttwelvedigits) != 12: return None try: int(firsttwelvedigits) except Exception: # pragma: no cover return None # checksum val = sum( (i % 2 * 2 + 1) * int(x) for i, x i...
434cb3e71ecba49a0e5a13c73a6808c8c5e80446
34,446
def get_verbose_name( object ): """ Returns the verbose name for a model. """ return object._meta.verbose_name
5af7289fed0f7b7fec0e1140a80b56291c9764a3
34,447
def param_for_gem(): """ Identify the parameters that will generate such "gem found". Once you find these three numbers (number, num1 and num2), return them in a list. >>> output = param_for_gem() >>> len(output) == 3 True >>> all([isinstance(num, int) for num in output]) True "...
6573e9dc7b524530524a3a94712da9114ab3a924
34,448
import torch def batch_colout(X: torch.Tensor, p_row: float, p_col: float) -> torch.Tensor: """Applies ColOut augmentation to a batch of images, dropping the same random rows and columns from all images in a batch. Args: X: Batch of images of shape (N, C, H, W). p_row: Fraction of rows to...
1ff4311127749afc9eb56797b76d18c706ebf378
34,450
def filter_endswith(word, ending=None): """Filter words ending with a specified suffix. :param word (str): A word. :param ending (str, optional): The optional ending to check. :rtype bool: The resulting check. """ return word.lower().endswith(ending)
cc189ee272a2662d061ce1eb5a79103f03842eed
34,452
def paginate(query, page, count): """ Returns the items given the count and page specified :param query: :param page: :param count: """ return query.paginate(page, count)
ce6bc412de90b9333c8febbf75a35b2abfa3e0ae
34,453
def _get_s3_presigned_put_url(s3_client, bucket, filepath, md5sum, lifetime_sec): """ Creates a pre-signed URL for S3-like backends, e.g. Minio. Note that since our production object storage backend is GCS, we do not enforce or require any Content-MD5 value. :param: s3_client: an initialized S3 cl...
d020281a0ce4d71eb3492d5f8a7a693b35d03c32
34,454
import os def _json_add_reader(json, filename): """ Add LAS Reader Element and return """ json['pipeline'].insert(0, { 'type': 'readers.las', 'filename': os.path.abspath(filename) }) return json
adb4fdbadbcef88b49f6cb93665df0fa99318138
34,455
import os def normalised_path(input_path:str) -> str: """returns a normalised "real"/"full" filepath for a given directory then checks its a valid directory""" normalised_path:str = os.path.realpath(os.path.expanduser(input_path)) + "\\" if os.path.isdir(normalised_path): return normalised_path ...
917d093c7b1f181871eab43006ec1ca5cb97e8eb
34,457
def add(x, y): """ Adds to num and returns an output""" return x + y
bf1edf11bbd831594383dcc942fd75fd5bc0e398
34,458
def __find_lags_in_frame(data, target_name, max_depth): """ Finds lags in Dataframe :return: Data about found lags :param max_depth: Max possible lag depth :param data: Dataframe :param target_name: Target variable """ # для всех переменных осуществляется подбор result = list() f...
c662adbdefbbf6dddf4de6f10d17495100186359
34,459
def get_change_sign(word): """ # sign['a'] = # a à á â ã ạ ả ấ ầ ậ ắ ặ # sign['e'] = # è é ê ẹ ẻ ẽ ế ề ể ễ ệ # sign['i'] = # ì í ỉ ị # sign['o'] = # ò ó ô õ ọ ỏ ố ồ ổ ộ ớ ờ ỡ ợ # sign['u'] = # ù ú ụ ủ ứ ừ ữ ự # sign['y'] = # ý ỳ ỵ ỷ """ sign_ ...
14c4eaac88b59bacbdcdc0e016475ae0f3d80b24
34,460
def reverse_bits(n): """ Reverses the bits in an integer. :param n: an integer value. :return: finds the integer value of a reversed integer bit. """ return int(bin(n)[::-1][0:-2], 2)
e19979b487c84ab4a7925ca64aaebeddd2fb0655
34,463
import torch def UnNormalize_tensor(tensor: torch.Tensor, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)): """ Args: tensor (Tensor): Tensor image of size (C, H, W) to be normalized. Returns: Tensor: UnNormalized image. """ for t, m, s in zip(tensor, mean, std): t.mu...
49454d108e36dce96be4128ceac48a42d6f9a7b4
34,464
def read_positive_integer_custom(text, position): """Read a number starting from the given position, return it and the first position after it in a tuple. If there is no number at the given position then return None. """ if position >= len(text) or (not text[position].isdigit()): return ("",...
e63e9d8fcd4ac424836cb973f8048bc4564b4e1b
34,465
from typing import List import re def remove_obsidian_comments(content: List[str]) -> List[str]: """ Remove the obsidian comments from the content. %% comment %% """ return re.sub(r'\s*\%\%(.|\n)*?\s*\%\%', '', '\n'.join(content)).split('\n')
58d234c5fb6668310115beb4e8a9e03b98b14c04
34,466
from math import isnan def clamp(x: float, lower=0., upper=1.) -> float: """ Clamps a float to within a range (default [0, 1]). """ if x <= lower: return lower elif x >= upper: return upper elif isnan(x): raise FloatingPointError('clamp is undefined for NaN') return...
e1af0a40b4f0e9ecb0f917faa4b8ab5f4c9b2ac5
34,467
import itertools def repeat(): """Repeate a sequence a number of times.""" repeated = itertools.repeat('AB', times=2) return list(repeated)
13cd3f501080c79025971323b953eba3816d6834
34,468
import logging def get_annotator_idx(jam, feature_name, annotator_name, filename): """Gets the annotator index of the annotation annotated by annotator_name.""" annotator_idx = -1 for i, annotator in enumerate(jam[feature_name]): if annotator.annotation_metadata.annotator.name == annotator_name: annotator_id...
5b21681528e08958dc0b405b3d5d3a21d3e33851
34,470
import socket def get_free_ports(n): """Based on https://gist.github.com/dbrgn/3979133""" ports = [] sockets = [] for i in range(n): s = socket.socket() s.bind(('', 0)) port = s.getsockname()[1] ports.append(port) sockets.append(s) for s in sockets: ...
eff425d1c1c10267271bbf821de7294c58d03765
34,471
import random def rand_trial(tgt_num,min_itv,max_itv): """ Generate a list of number, which would be used to make sure that there are some filler sentence(s) between any 2 target sentences. Parameters ---------- tgt_num: Int The number of target sentences min_itv: In...
8d16b943804556c80d84a9050ce89cc2e4cf82dc
34,474
import random def random_int(s, m): """Generate an int that fits in the given fixed point format. """ # Integer bits ret = random.getrandbits((m-1) or 1) # Sign weight ret -= 2**(m-1) if s else 0 return ret
7b8022180774310c367f3509d045f4f82f44db82
34,477
def qual_class_name(cls): """ Returns the fully qualifieid class name (module + class name). """ return cls.__module__ + "." + cls.__name__
ff433a30616851fdb0951fba4295230f9fa01907
34,478
def get_bytes(t, iface='eth0') -> int: """Get raw network speed.""" with open('/sys/class/net/' + iface + '/statistics/' + t + '_bytes', 'r') as f: data = f.read() return int(data)
55a5030b53281df85736e5c9e029990d1a557348
34,481
def fit_to_display(img, fit_by_height = None): """ Returns a proportionally resized image with the largest dimensions that can fit on the display. `fit_by_height`: whether to force resizing using height """ width, height = img.size ratio = float(width) / height if fit_by_height == None:...
722c920a91deee42bd4f3af018199104e7598a5a
34,482
def WDM_suppression(m, m_c, a_wdm, b_wdm, c_wdm): """ Suppression function from Lovell et al. 2020 :return: the factor that multiplies the CDM halo mass function to give the WDM halo mass function dN/dm (WDM) = dN/dm (CDM) * WDM_suppression where WDM suppression is (1 + (a_wdm * m_c / m)^b_wdm)^c...
e9ad362bc63be58a465d0e11a0bfb45ad3f1bc2d
34,483
def remove_chars(value,char_list=''): """ Remove specific chars from a string :param value: Value to be formatted :type value: String :param char_list: String containing the characters you want to remove :type char_list: String :returns: String without punctuation symbols :rtype: St...
2090ad14efff19974af8aa7bd68cdee11536e056
34,485
def rule(index): """Convert decimal index to binary rule list.""" return [int(x) for x in list(format(index, '08b'))]
33b167503e9caac338d747240dcc07b0d40bc057
34,487
def mania_key_fix(objs_each_key, mode=0): """ Remove the 1/4 spaced adjacent notes to make the map perfectly playable. It's a lazy hack for the obvious loophole in the note pattern algorithm. Should set to inactive for low key counts. mode 0: inactive mode 1: remove latter note mode 2: remo...
e5108d853fcb05b4bc86769bacad5e3495472ad6
34,488
def getColor(index, colors): """ returns the colour at the position of an array which contains colours """ return colors[index%len(colors)]
e49f5dc983936695f5810c363d6ff86913802937
34,489
def get_sections_url(request): """ A fixture that returns URL for two different section endpoints: - /v1/hearing/<hearing id>/sections/ - /v1/section/?hearing=<hearing id> """ return { 'nested': lambda hearing: '/v1/hearing/%s/sections/' % hearing.id, 'root': lambda hearing: '/v1...
1ecae93851fe50f26e6f6bb0fc0ae6f386ddb626
34,490
def _qualify_optional_type(cpp_type): # type: (str) -> str """Qualify the type as optional.""" return 'boost::optional<%s>' % (cpp_type)
a86e1135cb6e17aae6215041356d7eda7c68f747
34,491
def suggest_removal_features(df): """ Will find features that appear to be almost index like with their feature values. Args: df: pd.Dataframe Pandas DataFrame object. Returns: Returns back a list of features to remove. """ features_to_remove = set() ...
e990c52c12fa6ba36f79daa89e25d3acb9ea5fef
34,492
def parse_file_tokens(parse_tokens): """Parses tokens from a file.""" def factory(filename: str): with open(filename, 'r', encoding='utf-8') as test_file: file_content = test_file.read() return parse_tokens(file_content) return factory
83e27a2bc08acdd28c6da88c96b2206169701293
34,493
def camelCase(List): """Returns list containing camelcase words""" camelCaseList = [] nonCamelCaseList = [] for s in List: if s != s.lower() and s != s.upper() and "_" not in s: camelCaseList.append(s) else: nonCamelCaseList.append(s) return camelCaseList, no...
f9b076d1a094cc7f6d2dbead58940574f4b535b0
34,495
import time def measure_time(func): """ A decorator to measure execution time of an arbitrary function func: a function to measure """ def wrapper(*args, **kargs): t = time.time() result = func(*args, **kargs) print(f"{func.__name__} took {t} seconds") return resu...
dfb4107d7e519a9c4ba79d830664cf73d2653e76
34,497
import numpy def estDt(gr, cfl, u): """ estimate the timestep """ # use the proported flame speed dt = cfl*gr.dx/numpy.max(numpy.abs(u)) return dt
57482f6d30adc4f05537e8f5c87d7d10db31fd8d
34,498
import subprocess def git_add(directory): """Runs the git command to add all the files for the plugin""" return subprocess.Popen(["git", "add", "*"], cwd=directory)
37f99efcf0c8aa812493c0351f60b82ca55fde50
34,499
import torch def charbonnier_loss(pred: torch.Tensor, target: torch.Tensor, q: float = 0.2, eps: float = 0.01) -> torch.Tensor: """Generalized Charbonnier loss function between output and ground truth. The loss function is .. math:: los...
481de25b3d379f0c5f6c6f79f353166bc1bc1194
34,500
import math def angulo_desejado(ll_alvo, ll_atual): """Dados latitude e longitude do alvo e atuais, calcula o angulo em que o robo deve estar para atingir o alvo""" dy = ll_alvo[0]-ll_atual[0] dx = ll_alvo[1]-ll_atual[1] angulo = math.atan2(dx, dy) / math.pi * 180 return angulo
545ff24c790940b70fac96f1aad1900a0f247a49
34,501
import subprocess def lambda_handler(event, context): """ Run the Whitespace program baudelaire.ws with the provided input and return a response containing the resulting output, in a format suitable for API Gateway integration. Input is taken from the query string parameter "input". It must be ...
3e2bdab09fff41e815a5211ea926ff859d5a682f
34,503
from typing import Optional def format_op_params(params: Optional[list]) -> str: """format operation params nicely for display""" if params is not None: return "(" + ", ".join(map(str, params)) + ")" if len(params) > 0 else "" return ""
4620011e1f12ac0b0165e591eaf50ed539142cdf
34,504
def num_filled_bits(bloom_filter): """Determines how many bits in a filter are filled. Args: bloom_filter (BloomFilter): Bloom filter object to check. Returns: int: Number of filled bits in the filter. """ return '{0:b}'.format(bloom_filter.value).count('1')
e3b61c002c88c10e5d36bbbb80cf4833b22884a1
34,505
import json def build_address_map(tilegrid_file): """ Loads the tilegrid and generates a map (baseaddr, offset) -> tile name(s). Parameters ---------- tilegrid_file: The tilegrid.json file/ Returns ------- A dict with lists of tile names. """ address_map = {} ...
c5debba6159f847267b228cefdbe3ae88015c887
34,506
def log_intensity(V, H, params): """Evaluate the log likelihood of spiking with an exponential link function. V: 2D array with voltage and θV in the first two columns H: 2D array with θ1 and θ2 in the first two columns params: list of parameters (see predict() for specification) """ return V[:, ...
1540b9cf8c174bc49d68c4cd86fa90a127fbec07
34,507
def trim_missing_at_end_data_df(df_data, neg_lim=None): """ Removes rows at end of file that have empty data :param df_data: :param neg_lim: :return: """ df_data = df_data.reset_index(drop=True) nan_rows = df_data[df_data.iloc[:, :3].isnull().T.any().T] nan_indexes = list(nan_rows.i...
3665a5b360f4b14f452a14b86764f6b5fbebd3b0
34,508
def get_word(word_type): """Get a word from a user and return that word.""" # The lower() function converts the string to lowercase before testing it if word_type.lower() == 'adjective': # Use 'an' in front of 'adjective' a_or_an = 'an' else: # Otherwise, use 'a' in front of 'no...
44447b8478e857956b5a328c514d632a8ba90bb3
34,509
import threading def isMultiThreadMode(): """ Checks if running in multi-thread(ing) mode """ return threading.activeCount() > 1
09f08fc36b23ac9e279f7aad46917751118dc856
34,510
def def_readme(): """ Check Readme Markdown """ readme = '' with open('README.md') as file_content: readme = file_content.read() return readme
904ed946ca6135b6a350b42916a7f0f64398054b
34,511
def validate_item_pickup_transaction_locations(loan, destination, **kwargs): """Validate the loan item, pickup and transaction locations.""" pickup_location_pid = loan["pickup_location_pid"] item_location_pid = kwargs["item_location_pid"] if destination == "ITEM_AT_DESK": return pickup_location_...
b5a79c35dd8ec4028ed947a95dc628a3306d6cc4
34,513
import requests def log_me_in_direct(base_url, user_data=None): """ :param user_data: :returns cookies :param base_url: :return: """ add_url = "/geo/init" response = requests.post(base_url + add_url, data=user_data) return response.history[0].cookies
3dd25d6270d59ab9f8558d4511f8875c51a72668
34,514
import io import array def part1(stdin: io.TextIOWrapper, stderr: io.TextIOWrapper) -> int: """Find two numbers that sum to 2020, then multiply them.""" numbers = array.array('i') iterations = 0 for line in stdin: iterations += 1 number = int(line.strip()) pair = 2020 - numbe...
cd0b88df8d6dbb7cd6aefff70a4fe68a43ee4c8c
34,515
from string import printable def unprintable(mystring): """return only the unprintable characters of a string""" return ''.join( character for character in mystring if character not in printable )
bb48580d525d1e829f5b4b33cd4c0e540aa3a21a
34,516
import os def get_images(image_path): """ get all images at the specified image_path (! no check for actual image files) :param image_path: the path that is searched :return: number of images, file paths """ images = os.listdir(image_path) number_images = len(images) image_file_paths =...
e4c5d4fb33f6be57437e7fa2cebc3996cba7a9a1
34,517
def sum_credit_debit(credit, debit): """ Calculates the total of the transactions :param credit: Credits :param debit: Debits :return: """ credit_sum = 0 for entry in credit: credit_sum += entry.amount debit_sum = 0 for entry in debit: debit_sum += entry.amount ...
e375afea5e108e89e0f998f1cb28fb559a806077
34,518
def can_review(user): """Checks if a user can review a translate""" return user.permissions['perm_review']
ab0dcb8cb0372c1421e6b9171e01e2be7113e3f1
34,519
def select_frames(frames, frames_per_video): """ Select a certain number of frames determined by the number (frames_per_video) :param frames: list of frames :param frames_per_video: number of frames to select :return: selection of frames """ step = len(frames)//frames_per_video if step =...
d00ca8381e919cb38858d236186c4ebbd2b8a064
34,520
def doc_freqs(docs) -> dict: """ Takes in a list of spacy Doc objects and return a dictionary of frequencies for each token over all the documents. E.g. {"Aarhus": 20, "the": 2301, ...} """ res_dict = {} for doc in docs: # create empty list to check whether token appears multiple times ...
2bdeaf2150b4c2ecb8f240984d6d5f7eb210c585
34,524