content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
def make_dict(typ, *values): """Implement `make_dict`.""" return dict(zip(typ.entries.keys(), values))
e4a9a488f77a4ec0f5305c4ea67a25656f19a820
50,753
from yaml import full_load as yload import json def load_in_file(in_file): """Here goes the routine to compute the descriptors according to the state file(s)""" with open(in_file, 'r') as stream: try: state_str = yload(stream) except: state_str = json.load(stream) ...
f8bb97e07cff43da871f6e785edf10f9a77aa0a0
50,754
def create_grid_string(dots, xsize, ysize): """ Creates a grid of size (xx, yy) with the given positions of dots. """ grid = "" for y in range(ysize): for x in range(xsize): grid += "." if (x, y) in dots else "#" grid += "\n" return grid
b1653b8e710edfe49b3d54e113b6709e51fb92b7
50,755
def dni_to_value(scale_value): """ This method will transform a string value from the DNI scale to its confidence integer representation. The scale for this confidence representation is the following: .. list-table:: DNI Scale to STIX Confidence :header-rows: 1 * - DNI Scale ...
13b80d6b0c12fbc36d59db9d6626cf747beca627
50,756
import argparse def get_arguments(): """Parse all the arguments provided from the CLI. Returns: A list of parsed arguments. """ parser = argparse.ArgumentParser(description="PSPnet Network") # optimatization configuration parser.add_argument("--is-training", action="store_true", ...
e3fb21857b44a37fef7b930bcb5345c42005a780
50,757
from typing import Sequence from typing import Generator def dictionize(fields: Sequence, records: Sequence) -> Generator: """Create dictionaries mapping fields to record data.""" return (dict(zip(fields, rec)) for rec in records)
ca179ef5d03e8d5860c36872a61405b6a33ad463
50,758
import yaml import getpass import platform def get_root_dir(config_file, dir_tag="root_dir", default_dir = None): """ Read db_root entries for current user and current machine Args: config_file (): dir_tag (): default_dir (): Returns: """ if default_dir : retu...
972b61e3e30f5b685d0a03219bb3b69753aa834b
50,759
import warnings def ratio(class_label, data): """Compute ratio of all data that is `class_label`.""" try: return float(data.count(class_label)) / len(data) except ZeroDivisionError: warnings.warn("data {} is empty".format(id(data))) return 0.
7742804261d3aca98dd9ba19e083fd5c158310b9
50,760
def calc_force(force, new_closes, new_volumes): """ INPUTS: force (Series) - A copy of last record's force value. new_closes (Series) - New values, prepended with last closing price new_volumes (Series) - New values, prepended with last volume OUTPUT: Force index as a pandas ...
30034d0a142962094f8b8eb02d71eee7d4088622
50,761
def import_devices(client): """ Imports all devices from the Rayleigh Connect API :param client: An instance of the RayleighClient class :return: A JSON object containing devices and their parameters, retrieved from the Rayleigh Connect API """ return client.retrieve_devices()
83ca27b0c25015b706f787aa44c20785a6bbeee1
50,762
def lat_to_ibz(lat): """Returns the Bravais lattice ibz code based on the input string code. e.g. lat='bcc' or lat='fco' :param lat: lattice string code :type lat: str :returns: ibz code corresponding to the Bravais lattice given by the 'lat' key :rtype: int """ # One shou...
2c434b69b3ec21ad93d60ee8e48f40f087e6a369
50,763
def update_number_of_orientations(integration_density, integration_volume): """ Update the number of orientation for powder averaging. Option for advance modal. """ ori = int((integration_density + 1) * (integration_density + 2) / 2) if integration_volume == 0: return f"Averaging over {o...
bd54b18578eafdc59bf55284438b7d81d79c5509
50,764
def _cast_to_int(integer_string): """Cast a string to a integer.""" ret = int(integer_string) if ret < -1: raise ValueError() return ret
3eb4796f19467f95030ffdc8eb18eb7489329e98
50,765
import os def _find_setup_script_for_extension(top_path, source_dir='src', setup_py='setup.py'): """ Parameters ---------- top_path : str An entry for `os.walk`. source_dir : str Name of directory where sour...
cf2955864da8b0a02b68be4dc87eff5c67b90637
50,767
def getFreePlaceValues(freePlaceMap): """ Returns the Amount of Free Places for every Area Marked on the FreePlaceMap by iterating over the Map and counting each Cell of each Area together The Returned list starts with Area 1 on Index 0 :param freePlaceMap: The generated FreePlaceMap :return: Th...
a370310d26233b6dd93865b08528c505585fe9a4
50,768
def _add_system(query, data): """Add data from successful system MIB query to original data provided. Args: query: MIB query object data: Three keyed dict of data Returns: data: Aggregated data """ # Process query result = query.system() # Add tag for primary ...
cb37d05ac484f9a8f57b7a61afd9a40a971a23d0
50,770
def stat_limits(stats_dict, prof, stat, up_buff=None, low_buff=None): """Returns the highest and lowest values found in the s_c_dict provided. parameter: - stats_dict: The s_c_dict the min max values are wanted from - prof: The profile name the values are to be taken from as a string - ...
634f0588e2de0d7fa884dbedc28e388a822cf6d3
50,771
import re def unflat(data, separator="_", lseparator=('[', ']')): """ Unflat the dict Args: data (dict): the dict to unflat. Must be a key/value dict. separator (:obj:`str`, optional): key separator. Returns: dict: Unflatted dict """ unflat_dict = {} for k in sort...
dd39961dca2ad7052c72e46cbd313ca6b45ac7f4
50,773
import socket def get_hostname(): """ Retrieves the hostname of the machine Returns: hostname (str): the hostname or "Unknown otherwise" """ hostname = "" try: hostname = socket.gethostname() if "." in hostname: hostname = hostname[: hostname.find(".")] exc...
9c44ef69bbf1df5cd0a5ae7c80038def468072b3
50,774
def _InitLookUp(alpha=0.05): """ Initialize the dictionary of the look up table based on the confidence level. The tabulated data are from Rorabacher, D.B.(1991) Analytical Chemistry 63(2), 139–46. :param alpha: confidence interval (double), accepted values: 0.1, 0.05, 0.01 :return: """ if alph...
18ccc897f4f0333e285957878a441e7e21a47877
50,775
def resolve_reset(tokens): """Resolve the reset to an location, but dont resolve the location to an address yet.""" tree = tokens[0] if tree.data != "symbol": raise Exception("Unknown reset type", tree.data) return tree
756642dde822d993f47a49a1e90958ff050fd1e1
50,776
def integral(x,y): """ ROUTINE: INTEGRAL USEAGE: RESULT = INTEGRAL( X, Y ) PURPOSE: Integrate tabulated data using Simpson's rule with 3-point Lagragian interpolation. Data may be regularly sampled in X, or irregularly sampled. INPUT: X Vector of ...
1854833006bc1bdb0c2352f08a059de145ab9ba2
50,777
def unminify(soup, encoding='utf-8'): """ """ return soup.prettify().encode(encoding)
11b956f2fa61f237afb5931441f8add4320024d4
50,779
import torch def sparsity(M, tol=1.0e-3, device="cpu"): """ ========================================================================== \n Return the spacity for the input matrix M \n ----- INPUT \n ...
60ab6d9578d4f3285b5ca8ec7287ab1e68cb7618
50,781
def load_org2_gateway(network_config): """ Loads the `org2_gw` Gateway """ return network_config.get_gateway('org2_gw')
55f1770759f71a1ab730689920e17eec549cd95f
50,782
def int_addr(addr): """Gets the integer representation of an address""" return int(addr[1:])
3f00ae151bff20516fbaddda73feb147aa1c8424
50,783
def val_default(val, default=True): """Value or default (for attributes) """ if val is None: return default return val
6a7bb5a475428d36ad046b4e7a7099f2573eae76
50,784
def speak_next(most_recent: int, turn_num: int, nums_spoken: dict): """ If you want to optimize something in Python, it probably involves dictionaries or tuples. ~ My friend Miles """ if most_recent not in nums_spoken: saying = 0 else: saying = turn_num - nu...
d7ab59dd70ae80168f3170e4a79944dc86a63256
50,785
import os def load_user_pass(): """ Loads the username and password from the environment :return: tuple - [username, password] """ # try to get the username from environment variable LBXD_USERNAME = os.environ.get("LBXD_USERNAME", None) class UsernameMissingError(Exception): pass ...
4c29353b214c42a66831e2284e0ce1eaa21bbbf4
50,786
def frame_text(lines: list, style='╔═╗╚╝║'): """ Styles cheat-sheet: ╔═╗╚╝║ /–\\/| ┏━┓┗┛┃ """ max_width = max(len(line) for line in lines) top = style[0] + style[1]*max_width + style[2] + '\n' bottom = '\n' + style[3] + style[1]*max_width + style[4] return top + '\n'.join(styl...
e2328d4bc5583aeb6fdcaf492391fddca3a5a98c
50,787
def res_server_error(): """ Default response for an unhandled exception (base internal server error). """ return { "type": "server_error", "code": "error", "detail": "A server error occurred.", "attr": None, }
093f57abc12b48a2c788b86f860ae4addca9d475
50,788
import sqlite3 import gzip def sqlite_from_file(filename, fmt=None): """Instantiate an sqlite3.Connection and return it, with the data copied in from the specified file. The sqlite3 connection is mapped in memory, not to the source file. Args: filename (str): path to the file. fmt (str):...
5cd9152d903d2a2c98fae676230c0a2fc3d4cfbb
50,791
def getspecificnodes(): """ Returns 20 specific nodes """ nodelist = [310, 510, 810, 1210, 9, 10, 61, 37, 38, 43, 23, 204, 1208] print("Got specific nodes") return nodelist
427baabdf5aaaaaacc20745bca992e198d80b017
50,792
def cs_water_Tp(T=298, p=1): """ Calculates chemical shift of water based on Temparature and pressure (according to Maciej). """ # according to Maciej cs = 5.945e-7*p*T -1.612e-4*p -1.025e-2*T + 7.866 return(cs)
de450a97255cd245ae02f2219bddc0b5f201bfec
50,793
from collections import Counter def test_byte_pair_encode(): """ BPE: A technique to encode a string with replacing most two frequent symbols with a single alpha, and keep repeating until the remaining symbols are singular """ def bpe(s): freq = [] for a,b in zip(s,s[1:]): freq.append(a+b)...
bb292404f03731da9ddfa7085907510b14bdd179
50,794
from typing import Set import re def get_filenames_from_git_log(git_log: str) -> Set[str]: """ :param git_log: :return: """ pattern = re.compile(r'--- a\/(.+)\n\+\+\+ b\/(.+)') match_tuples = re.findall(pattern, git_log) unique_matches = {file for match_tup in match_tuples for file in mat...
cb6e8d03c38a41452508e00373f05db9e89a9d29
50,797
from typing import Tuple from typing import List def read_network(file: str) -> Tuple[int, int, List[int]]: """ Read a Boolean network from a text file: Line 1: number of state variables Line 2: number of control inputs Line 3: transition matrix of the network (linear representation of...
16ef7751cbd4af000ed33de7b065273225e35d76
50,798
import pickle def save_model(model, model_filepath): """ save the model at a desired location """ pickle.dump(model, open(model_filepath, 'wb')) return None
998eb9ff50dd383265ec636d82d3c05d781dfaa3
50,799
def filter_events_by_messages(events, ignore_github=False): """ Filter events so that only "m.room.message" events are kept. events should be a dict of room events as returned by ``get_all_events``. """ messages = {k: v[v['type'] == "m.room.message"] for k, v in events.items()} if ignore_github...
ed41183a8fbef71d2a9ec016c6cca3b96d346edc
50,800
import threading def 线程_取线程标识符(): """ 返回当前线程的“线程标识符”。这是一个非零整数。它的值没有直接的意义。它旨在用作魔术Cookie,例如用于索引线程特定数据的字典。当一个线程退出并创建另一个线程时,线程标识符可以被回收。 """ return threading.get_ident()
21976541af161d5e5605ba308cd4342cc5de7151
50,803
import subprocess import json def execute_cmd_str(cmd: str, convert_to_json: bool): """ executes shell command and return string result :param convert_to_json: :param cmd: shell command :return: returns string result or None """ try: result: str = subprocess.check_output(cmd, shell...
216d6f8083b4fd71afb1efe546569812e2fb3039
50,804
def remove_common_molecules(reactants, products): """ Removes common species between two lists leaving only reacting species. Parameters ---------- reactants, products : list of str List containing strings all molecular species. Returns ------- tuple of str Reduced list...
333b29afdd251bc6ad80910902fa7cb1433e493c
50,805
import random def random_string(length=6, password_safe=False): """Returns a random string with `length` characters of a-z, A-Z and the digits 0-9. :param length: number of characters to randomize (default 6 characters). :password_safe: set to `True` to exclude o, O and 0. """ if password_saf...
7d38429fdf0dd11290077558f7eb598d4a43d01e
50,806
def distance_between_points_meters(x1, x2, y1, y2): """Distance between two points. Example of coordinate reference system in meters: SWEREF99TM """ return (((x2 - x1) ** 2) + ((y2 - y1) ** 2)) ** 0.5
cbdcdb3f47d68a3340ae2fbcb6a93d3564352398
50,808
def as_vcf(line): """ Returns a VCF-formatted line representation of the CONF file :param line: :return: """ line = line.split('\t') var_identifier = 'cov_{}|editID_{}:{}'.format(line[2], line[0], line[1]) return '{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}'.format( line[0], line[1], ...
c4329bdac0833e814e2a44bcbf41cf742285697f
50,809
import os import json def basket_ball_wiki_es(wiki_client, init_indices): """ fill the elasticsearch WIKI_ES with a POI of basket ball """ filepath = os.path.join(os.path.dirname(__file__), "fixtures", "basket_ball_wiki_es.json") with open(filepath, "r") as f: poi = json.load(f) po...
072b528a1b6174954579660318f4893a9eef9873
50,810
def extend(rows, times=5): """Extend rows. Return the result.""" extended = rows length = len(rows) for row in extended: # Lengthen rows. for i in range((times - 1) * length): row.append(row[i] % 9 + 1) for i in range((times - 1) * length): # Add rows. extended.append([...
867fdd9afdd92afc29e0921863f8207fe5d0f9f4
50,811
def _rummy(): """ Draw Him. """ return ['------------------------------------------------------------------------------------------------------------', 'MB###BHHHBBMBBBB#####MBBHHHHBBBBHHAAA&GG&AAAHB###MHAAAAAAAAAHHAGh&&&AAAAH#@As;;shM@@@@@@@@@@@@@@@@@@@@@@@@@@', 'MGBMHAGG&&AAA&&AAM#...
f9ffea9f874b71d0efa43528442cac1b805e08a8
50,812
def _FindAndRemoveArgWithValue(command_line, argname): """Given a command line as a list, remove and return the value of an option that takes a value as a separate entry. Modifies |command_line| in place. """ if argname not in command_line: return '' location = command_line.index(argname) value = com...
07dc13e9ebfadd37ca0ff24de1407869b8667508
50,813
def wait_for_vanish(self, timeout=None): """ DEPRECATED! Use wait_until_vanished command instead. """ self.logger.warning('"wait_for_vanish" command is deprecated, use "wait_until_vanished" instead!') self.wait_until_vanished(timeout=timeout) return self
f8534f9651182ca4d77c90025035a276c8f5bacd
50,814
def get_taxonomy_collapser(level, md_key='taxonomy', unassignable_label='unassigned'): """ Returns fn to pass to table.collapse level: the level to collapse on in the "taxonomy" observation metdata category """ def f(id_, md): try: levels = [...
59dd2496cfca03d41379469eee7769ba5e08ec63
50,815
def get_start_and_end(): """ asks the user to enter a starting number (integer), ending number (integer) :return: start: int, end: int """ while True: try: start = int(input("start int: ")) end = int(input("end int: ")) break except ValueError: ...
12dc53ebfa9b62e14c8f5ed741f5aa85684b673a
50,817
def rank(p1, p2): """ Ranks two paths :param p1: First path object :param p2: Second path object :return: if p1 is ranked more than p2, then 1; if equal, then 0; else -1 """ if len(p1.relationships) > len(p2.relationships): return 1 elif len(p1.relationships) == len(p2.relationsh...
666a08834243c87458f28fca4936dcde67165935
50,818
import hashlib def generate_hashed_ports_num(pod_uid, port_name, port_count, port_start, port_end): """ Random generate the port number The algorithm is: (int(md5(podUid + portName + portIndex)[0:12] ,16) + int(md5(podUid + portName + portIndex)[12:24] ,16) + int(m...
66ad221cd4aec8e33a1ee79a23c27bb6af239392
50,819
import os def ensure_expandusr(path): """ Ensure paths contain ~[user]/ expanded. """ return os.path.expanduser(path) if '~' in path else path
302a202b6bed446cd9358e3010b526f0168d594b
50,822
import math def atms(RT, TT, DNT, GAMAL, R): """ Internal routine used by REFRO Refractive index and derivative with respect to height for the stratosphere. Given: RT d height of tropopause from centre of the Earth (metre) TT d temperature at the tropopause (de...
f370c7b7b030867049b457ece062d7435c15c30b
50,824
def check_statement(): """Create a test fixture to compare statements.""" def check_statement(actual, test): """Check that statements are match.""" assert actual.keys() == test.keys() assert actual['id'] == test['id'] assert actual['description'] == test['description'] if...
85116ce0b18a56b4b95bed9d1223dea393afff72
50,827
import platform def get_os_name() -> str: """Get operating system name that Node.js repos know about.""" return platform.system().lower()
b70c031670b27ddf2444d76c7495311a6f9e7eee
50,828
import numpy def get_values(loss_type, assets, time_event=None): """ :returns: a numpy array with the values for the given assets, depending on the loss_type. """ return numpy.array([a.value(loss_type, time_event) for a in assets])
10bfb36673143db21ef57872eb70ddfc32d056f4
50,830
def get_options(options): """ Get options for dcc.Dropdown from a list of options """ opts = [] for opt in options: opts.append({'label': opt.title(), 'value': opt}) return opts
61df747bf10a08aff481c509fbc736ef406d006f
50,832
def get_columns_from_data(data, columns): """ This function is a wrapper around the indexing of pandas data frames. This function gets all of the rows from the data frame. :param data: Pandas data frame :param columns: The columns which are to be selected. :return: Pandas data frame """ ...
5638efbf632c80b81eb53c98376a12599d6810a5
50,833
def CutDirectory(Path, CutPath): """This allows me to keep trove's file structure""" return Path.replace(CutPath+"\\", "")
315f3fef039e61d321387c000c4c9d26de10beba
50,834
def get_celery_worker_module_name(app_id): """ Returns the python module name of the queue worker script. Args: app_id: The application ID. Returns: A string of the module name. """ return 'app___' + app_id
52b79ec69da4c064062fcfb5dcd7edb94a095809
50,835
def solution(l): """ Solution 4 again passes all but the last test case. Try to speed things up some using a dynamic programming-like approach. This solution wound up passing all of the test cases -- the key here is to uses a memorization/dynamic programming approach. A core component of this ...
0387a39e6d087f381aece01db2718a9e90ba642c
50,836
def update_statutory_deduction(employee, local_service_tax): """Update statutory deductions of an employee""" deduction = employee.statutorydeduction deduction.local_service_tax = local_service_tax deduction.save() return deduction
29fdfb85721d8d70acc711299e44ced52e4f057a
50,837
import torch def fista_momentum(cur_Z, prev_Z, momentum): """ Calculates a linear combination of the last two sparse codings with a momentum term :param cur_Z: Sparse code found in current step :param prev_Z: Sparse code found in previous step :param momentum: float. Momentum term. :return: U...
0b8435cae2b006eb18604d71933d46a4c8e3c5d6
50,838
def blazar_find_old_host_alloc(db): """Find computehost allocations tied to expired leases""" sql = '''\ SELECT ca.id, l.id AS lid, ch.hypervisor_hostname FROM blazar.computehost_allocations ca JOIN blazar.reservations r ON ca.reservation_id=r.id JOIN blazar.leases l ON r.lease_id=l.id ...
717bcb2d788be24d8c1b96bab62d60c54e196a25
50,839
import collections def separate(xs, blocks): """Partition ``xs`` into ``n`` different list based on the corresponding labels in ``blocks``. """ sorter = collections.defaultdict(list) for x, b in zip(xs, blocks): sorter[b].append(x) x_b = list(sorter.items()) x_b.sort() return [...
967451fd3b4505b91e354e5714a7e62c44b62231
50,840
def connect_streets(st1, st2): """ Tells if streets `st1`, `st2` are connected. @param st1 street 1 @param st2 street 2 @return tuple or tuple (0 or 1, 0 or 1) Each tuple means: * 0 or 1 mean first or last extremity or the first street * 0 or 1 mean first...
77ee8f4c344277b09340cc3a38e16ee5ae11f702
50,842
def sum_of_n(n): """Sum all numbers from 0 to N, recursively.""" if n == 0: return 0 return n + sum_of_n(n - 1)
cc804ad0fb745ebdc6badfb7d50c1d0fac2e7c5b
50,843
def stiff_v(nodes): """nodes: (B, 1, N, 2)""" Pf = nodes.roll(-1, dims=2) Pff = Pf.roll(-1, dims=2) Pb = nodes.roll(1, dims=2) Pbb = Pb.roll(1, dims=2) K = - Pff + Pf * 4 - 6 * nodes - Pb * 4 - Pbb * 2 return K
e83bdac33ace21cf4932e18995ab5682aea28991
50,844
import torch def unit_test(input_vector): """ This is to verify the diverse loss class using the normal for-loop method. """ input_vector = [tensor.numpy() for tensor in input_vector] input_vector = torch.as_tensor(input_vector).transpose(0, 1) b, k, d = input_vector.shape los...
fec37d86b41d0b1a11a8e54a297b42c6e552d04e
50,845
def get_nested_serializer(instance, key): """Returns the instance's nested serializer under the 'key' field with its data filled out """ serializer_class = instance._declared_fields.get(key).__class__ serializer = serializer_class(data=instance.validated_data[key]) serializer.is_valid(raise_exceptio...
2423289a4455783880f83d0804f74d0ceded03ce
50,846
def word2features(sent, i): """返回特征列表""" word = sent[i][0] postag = sent[i][1] features = [ 'bias', 'word=' + word, 'word_tag=' + postag, ] if i > 0: features.append('word[-1]=' + sent[i-1][0]) features.append('word[-1]_tag=' + sent[i-1][1]) if i >...
781a7bf8e8d39e05a09befae254b306ba6d2eb7a
50,847
def _highlight(timing: float) -> str: """Highlights a timing based on whether it is under 60 fps.""" if timing < 1 / 60: return f"[#57A773] {timing}" return f"[red] {timing}"
e4481d0631394850d00900edec3acd5c7f5b0cd6
50,848
import itertools def repeat(value, times=-1): """:yaql:repeat Returns collection with value repeated. :signature: value.repeat(times => -1) :receiverArg value: value to be repeated :argType value: any :arg times: how many times repeat value. -1 by default, which means that returned v...
1554022dbc709ff40e1a600cd892c8a07782c6e1
50,849
def solution(pence: int) -> int: """Returns the number of different ways to make X pence using any number of coins. The solution is based on dynamic programming paradigm in a bottom-up fashion. >>> solution(500) 6295434 >>> solution(200) 73682 >>> solution(50) 451 >>> solution(10) ...
d7670650fe734b432bbfb55f13c545905fee3bce
50,850
def remove_nans(frame): """ Remove rows with nan values Args: frame (pandas Series or Dataframe): column(s) Returns: frame: the same data structure without nans """ frame = frame.dropna() return frame
b6829f06c5fa130f1c42590359e0dc8e15da4e7b
50,851
from typing import List def sortListAlphabetical(arr: List[str]) -> List[str]: """ >>> sortListAlphabetical(["welcome","to","open","source"]) ['open', 'source', 'to', 'welcome'] """ return ['open', 'source', 'to', 'welcome']
20bd7c190a6bb366d501f5a210e7058a43d2af1e
50,852
def getMainDFsavedInStep(path_to_results, path_to_directory, file_name, ending): """ Takes in Returns """ dir_path = path_to_results + "/" + path_to_directory full_path_to_results_file = dir_path + "/" + file_name + ending return full_path_to_results_file
7590e5a75da06743d016331d5824984602f9aec0
50,855
def filtered_dict(dictionary: dict, threshold, invert: bool = False): """ Removes all keys from a dictionary whose value is less than a given threshold :param dictionary: The dictionary to filter :param threshold: The threshold below which to remove elements :param invert: Whether to invert the thr...
de5687a625fd1d5dfa86e9fe06a8cd85b8a899d9
50,857
import os def canonicalize_path(cwd, path): """ Canonicalizes a path relative to a given working directory. :param cwd: The working directory to interpret ``path`` relative to. :param path: The path to canonicalize. If relative, it will be interpreted relative to ``c...
0342d2a5f6e5780bdcfd51a0da237999a12c906f
50,858
def input_moves(msg=''): """This function ensures execution of code even if player chooses invalid number of moves""" while(True): try: moves=int(input(msg)) if moves > 0: break # was able to convert to integers larger than 0 else: pri...
129bfc1b5ea0fecdb9e42110ff7def91644abbca
50,861
def dict_with_keys(dictionary, keys): """ Returns a new dictionary including only the specified keys Args: dictionary(dict): dictionary to filter keys keys(iterable): iterable of keys to filter to Returns: dict: copy of original dictionary inclusive only of specified keys "...
e93d547b515269c9e2320e41d15ab39ae363c209
50,862
def codegen_reload_data(): """Parameters to codegen used to generate the fn_datatable_utils package""" reload_params = {"package": u"fn_datatable_utils", "incident_fields": [], "action_fields": [], "function_params": [u"dt_utils_cells_to_update", u"d...
9ddd053cc30724dbdecde9105135187fbf2a951e
50,863
def iscc_clean(i): """Remove leading scheme and dashes""" return i.split(":")[-1].strip().replace("-", "")
66a6705d48528b7c182fc051c9793bae3506f0dc
50,864
def reverse_range(object): """Yields reverse range of object: list(reverse_range([1, 2, 3])) -> [2, 1, 0].""" return range(len(object) - 1, -1, -1)
9bacca7d17e3ae5678b45c37eec1ea8d0fc78cf6
50,865
import threading def start_agent_thread(cls, **kwargs): """Instantiate an agent class and run it in a new daemon thread. Returns the thread object. """ agent = cls(**kwargs) thread = threading.Thread(target=agent.run) thread.daemon = True thread.start() return thread
2f7adfe81df347ee83932293b3026ab285c0b516
50,866
def combine_quality( dqarr1, dqarr2 ): """ Combines two data quality arrays to make a third. The bitwise nature of the data quality flags means that two arrays can be combined without needing to know the meaning of the underlying flags. :Parameters: dqarr1: numpy arra...
0d24c74309b761d054455b5d77061330d48e20e2
50,867
import argparse def _parse_args(): """Parse command line arguments and share the right ones with uwsgi.""" parser = argparse.ArgumentParser('Entrypoint for starting up uwsgi.') return parser.parse_known_args()
25c1af629b09864c0a0c29fa06b5ca8259b9c7a2
50,869
def gamma(configuration): """ Fonction gamma de Sprague-Grundy pour le jeu de Nim. """ resultat = 0 for nb in configuration: resultat = (resultat ^ nb) return resultat
bccd37b1122873e7f4b6a3aa5fdeff96f272df5b
50,870
def list_to_string(a_list, quote=False): """ Converts a list to a set of strings separated by a comma. :param a_list: The list to convert. :type a_list: list :param quote: If true, then surround each item with quotes. :type quote: bool :return: The string version of the list. """ if ...
d7a517225e1a5a70320f05b0c7c69e3b5c558f4c
50,872
import os def getSubpackages(name): """获取该模块下所有的子模块名称""" splist = [] for dirpath, _dirnames, _filenames in os.walk(name): if os.path.isfile(os.path.join(dirpath, '__init__.py')): splist.append(".".join(dirpath.split(os.sep))) return splist
a876a18694e5124d345a0f7b1db5e8b9291983b9
50,873
def _tc_minmax_ ( tree , var , cuts = '' , delta = 0.0 ) : """Get min/max for the certain variable in chain/tree >>> chain = ... >>> mn,mx = chain.vminmax('pt') >>> mn,mx = chain.vminmax('pt','y>3') """ if hasattr ( tree , 'pstatVar' ) : if cuts : s = tree.pstatVar ( var , cuts ) ...
4bd4389e34bacae622162792181aa72007fc0f25
50,874
def unwind_block_transactions(block): """Yield a block for each transaction in given block""" return block['block']['transactions'].map(lambda tx: block.merge({'tx': tx}))
79ec770ba28450575cbbd063c27afcae57029abf
50,875
def argtopk_preprocess(a, idx): """ Preparatory step for argtopk Put data together with its original indices in a tuple. """ return a, idx
55e7566a5a88bf45a0eda76513a10528180dc8a9
50,876
def bone_siblings(obj, bone): """ Returns a list of the siblings of the given bone. This requires that the bones has a parent. """ parent = obj.data.bones[bone].parent if parent is None: return [] bones = [] for b in parent.children: if b.name != bone: bon...
f63d16eee87a315cbf9213fd8a86ad248370ceb7
50,877
import hashlib def sha1_hasher(s): """ A simple utility function for producing a sha1 digest of a string. """ return hashlib.sha1(s).digest()
a214bc5cc78e7398373f7dd7c50d1e3ef59d1f8f
50,879
def pathto(*args): """Mock of sphinx' pathto() just for the homepage. Otherwise we cannot re-use our sphinx templates. """ return ""
978471934469cb0c74cc476f2aae9c800953c48b
50,880
def generate_stack_id(stack_name: str) -> str: """Generate a stack ID from the stack name""" return ( f"arn:aws:cloudformation:ap-southeast-2:123456789012:stack/{stack_name}/" "bd6129c0-de8c-11e9-9c70-0ac26335768c" )
130749de4bf983b22a26aaac5412c55c5baf5e37
50,883