content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
import math def distance(x1: float, y1: float, x2: float, y2: float): """ Return distance between two 2D points. """ dx = x2 - x1 dy = y2 - y1 return math.sqrt(dx * dx + dy * dy)
a956929ed37b224bc178d4755129f4b6d469a167
628,641
def get_last(s): """Get the last item in a Pandas Series""" return s.iloc[-1]
00088046fead8fac52156f5a97b432f1ef5c6e03
628,642
import argparse def parse_args(): """ Parse user inputs.""" parser = argparse.ArgumentParser() parser.add_argument('-u', help="add a username (requires -p)", required=False) parser.add_argument('-p', help="the username password", required=True) parse...
9ce341d2df201b2390ab1740282532446b67ff94
628,644
def excel_column_number(name): """Excel-style column name to number, e.g., A = 1, Z = 26, AA = 27, AAA = 703.""" n = 0 for c in name: n = n * 26 + 1 + ord(c) - ord('A') return n
ddd8b803cef027f7c04953247ce63a535662ae60
628,645
def set_val_or_default(in_dict, key, val): """Helper functions to either get and item from or add an item to a dictionary and return that item Parameters ---------- in_dict : `dict` input dictionary key : `str` key to search for val : `dict` or `function` item to add to ...
4368d5a34a26f67c220adebe634f59ad5467a2c6
628,646
from warnings import warn def read_and_check(file_handle, byte_sizes): """ Return data read from input file stream in segments of specified byte sizes and check for complete reads. Inputs: file_handle - Handle to file to read from. byte_sizes - List of byte sizes to read. Outputs: ...
d585859d305b33c49abea94725e9bbaa65e67966
628,647
import textwrap def mutations( seqID='A' ): # pragma: no cover """RosettaScript to execute a `RESFILE <https://www.rosettacommons.org/docs/latest/rosetta_basics/file_types/resfiles>`_. :param str seqID: |seqID_param| :return: :class:`str` .. seealso:: :func:`.DesignFrame.apply_resfile`...
5b7a7feecd435abaf36e101eda9ce21e5efc52ca
628,648
from typing import Dict from typing import List import re def get_typos_in_string(s: str, known_typos: Dict[str, str]) -> List: """ >>> get_typos_in_string('foo buzz', {'foo': 'bar', 'bazz': 'buzz'}) ['foo'] >>> get_typos_in_string('foo bazz', {'foo': 'bar', 'bazz': 'buzz'}) ['bazz', 'foo'] "...
fbd96e8897fbcf403a9da8db04f5a2bf0916270b
628,650
def valid_chunk_size(chunk_size): # type: (int) -> bool """Checks whether chunk size is multiple of 256 KiB. Args: chunk_size (int): Input chunk_size to be validated. Returns: bool: True if chunk_size is multiple of 256 KiB, False otherwise. """ return not bool(chunk_size % 262...
0ae4fe953186f970b80e7e28baeeb23b2a8e903a
628,651
import numpy def binarize_target_images(target_matrix, binarization_threshold): """Binarizes target images. Specifically, this method turns each target image into a binary label, depending on whether or not (max value in image) >= binarization_threshold. E = number of examples (storm objects) in fil...
5c20c2ac8404c37106a471145726ceddf4192c89
628,652
def set_name_ds(name_ds): """Set the dataset name in regression; return generic name if user provides no explicit name." Parameters ---------- name_ds : string User provided dataset name. Returns ------- name_ds : string """ if not name_ds: ...
b5bd02b2301eb828708a112f575b1b66abd90d6f
628,653
def calculate_range(histogram, words, index): """Return the difference between the high and low ends of a range for a value in the modified histogram. Param: histogram(dict): modified so each value is a tuple words(list): a list of the keys in histogram index(int): a way fo...
456078de0bf526cb7620ab38f4a8fa7ecc0db0ec
628,655
from typing import Any import gzip import pickle def load_object(path: str, compressed: bool = True) -> Any: """Reads a python object into memory that's been saved to disk. Args: path: the file path of the object to load compressed: flag to specify whether the file was compressed prior to sav...
cd3324e484b58d275ebef95f083c8aa8c576e78a
628,656
from datetime import datetime def datetime_to_epoch(datetime: datetime, ms: bool = True) -> int: """ Convert a python datetime to number of (milli-) seconds since epoch. """ if ms: return int(datetime.timestamp() * 1000) return int(datetime.timestamp())
73c5e41a8d24e0542c87db5910e9a6354e1f2f5c
628,657
def get_unity_consistencygroup_parameters(): """This method provide parameters required for the ansible consistency group module on Unity""" return dict( cg_name=dict(required=False, type='str'), cg_id=dict(required=False, type='str'), description=dict(required=False, type='str')...
d2cd897660769c199c941254b813a660a4746bc6
628,659
import re def get_line_padding(line): """ Returns padding of current editor's line @return str """ m = re.match(r'^(\s+)', line) return m and m.group(0) or ''
cb77492c5603035ee919ace43887bcd2beed3b00
628,660
def v8_add(*matrices): """Add corresponding numbers in given 2-D matrices. Solving the first bonus - accepting any number of matrices """ combined = [] for rows in zip(*matrices): row = [] for values in zip(*rows): total = 0 for n in values: t...
d33ef86c5e18abf0f4b68a75cc0f08f4e4a4284e
628,661
def allFirmsReturnGlobal(date, pdatabase, printWarnings=True): """ Return on value-weighted index of all firms in U.S. markets Uses decimal representation Relies on naming of pdatabase (crsp) Returns -1 if no data available Returns FLOAT """ aRetQuery = pdatabase.data.query('date == "' +...
3b6efd024c50f6d173c9a5ef3229987c3635d794
628,662
def leafnumber(deltaTT=23.5895677277, phyllochron=0.0, hasFlagLeafLiguleAppeared=0, switchMaize=0, atip=10.0, leaf_tip_emerg=10.0, k_bl=1.412, nlim=6.617, leafNumber=0.0, cumulTTPhenoMa...
1386b7fa7f070b2bf4d507e5d363e5d685cad330
628,663
import numpy as np def detect_highly_expr_genes(one_cluster, other_clusters): """ Args: one_cluster: (n_genes, n_samples) pd DataFrame- A single cluster with its samples other_clusters: (n_genes, n_samples) pd DataFrame - Other clusters! Returns: list of strings - returns the first...
efa57926f5f8269718370914a6d6061552605a79
628,664
import json from functools import reduce import operator def analysis_json(file_name): """ @param file_name: json文件名 @return:一个list存有json处理完后每个句子分成前半段 mention 后半段的格式 """ with open(file_name, encoding="utf-8") as load_f: load_dict = json.load(load_f) file_text = [] for text_index ...
f53dea743f9bf49f29e64d18f9e8a3c95280364d
628,665
def colorize(text, color): """ Wrap `text` with ANSI `color` code. See https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences """ code = f"\033[{color}m" restore = "\033[0m" return "".join([code, text, restore])
e1995a7973197c4a31ad655db92a88e47917e89a
628,667
def return_lines(path, linepos, nstart, nstop): """return nsamp lines from path where line offsets are in linepos""" offsets = linepos[nstart:nstop] lines = [] with open(path) as inf: for offset in offsets: inf.seek(offset) lines.append(inf.readline()) return lines
8222658d0af8f08cfc38127f4aa07c9f78487099
628,669
def number_of_edges(G): """Return the size of a graph = number of edges. """ return G.number_of_edges()
3c46add55f9b8cef27d20183c80681a4e0cb6a9b
628,670
from typing import List def ligands_from_conformers(conformers: List[str]) -> List[str]: """ Extract the ligands from a list of conformers. """ return [conformer.split('_')[0] for conformer in conformers]
f218a27b3a91d7852c6896dc8f15e08ff4885503
628,672
import logging def parse_border_options(values: dict) -> dict: """ Extract the world border options from the values dictionary. :param values: The values generated from the PySimpleGUI window event. :return: The border options. """ logging.info("Extracting world border options") border_opts =...
4b6b7b328225d191fb94c7e688db8dac6782b30d
628,673
def gps_format_datetime(datetime_str): """convert CGNS GGA date time into format for REST post""" year = datetime_str[:4] month = datetime_str[4:6] day = datetime_str[6:8] hours = datetime_str[8:10] minutes = datetime_str[10:12] seconds = datetime_str[12:14] return '{}%2F{}%2F{}+{}%3A{}%...
e8264e0598cb76b62fcc9c9a7915ff7e7b525c71
628,674
import argparse def parse_args(): """Parses arguments.""" parser = argparse.ArgumentParser() parser.add_argument('model_path', type=str, help='Path to the pre-trained model.') parser.add_argument('target_list', type=str, help='List of target images to diffuse from.'...
2814e7cad753d1f2938eefb2d2721c056d0c07d6
628,675
def bit_on(num, bit): """Return the value of a number's bit position. >>> [bit_on(42, i) for i in range(clog2(42))] [0, 1, 0, 1, 0, 1] """ return (num >> bit) & 1
ecfa4486cb076207bf4b9e7ec7d97f0c58c1eb2d
628,676
import re def ipv6(address): """ :param address: MAC Address :return: Bool if valid format """ if re.fullmatch( r'(([0-9aA-fF]{1,4}:){7}[0-9aA-fF]{1,4}|' r'([0-9aA-fF]{1,4}:){7}:|' r'([0-9aA-fF]{1,4}:){1,6}:[0-9aA-fF]{1,4}|' r'([0-9aA-fF]{1,4}:){1,5}...
183ff09097b9129a2baa662d7ab1a1d5a7509e91
628,677
def load_filepaths(filename): """Read in a list of file paths. Args: filename: A text file containing a list of file paths. Assume that each line has one file path. Returns: filepaths: A list of strings where each is a file path. """ with open(filename) as f: filepa...
2475a28b2afaf8380502270d79bc2f756dd5a25e
628,679
import requests def _http_get(url, session=None, stream=True, **kwargs): """Make a GET request with the URL. Any errors from the HTTP request (non 200 codes) will raise an HTTPError. :param url: The URL to GET. :type url: str :param session: Optional :class:`~requests.Session` object to use to m...
5ac2be88284ab53a465d33f8900e4590cb0c190a
628,680
def setup_units(): """Set up the single unit data.""" # The number of tetrodes, probes, etc - any kind of grouping num_groups = 8 # The region that each group belongs to regions = ["CA1"] * num_groups # A group number for each group, for example the tetrode number groups = [1, 2, 3, 4, 9, ...
340a90b1669fe3c7b5571b03d04e1e85c5bf00ca
628,681
def nombre_adaptateur(listcutseq, adaptateur): """ args : La fonction prend en argument la liste des reads et la liste des adaptateurs return: La fonction retourne le nombre d'adaptateur present dans le readset """ count_adaptateur = 0 for icountlistseq in range(len(listcutseq)): ...
fc8c24c35d67231700004d976f9a963291fd88e3
628,682
def SignToBool(inp): """Converts signed bits into boolean bits -1 -> 0 1 -> 1""" return (inp + 1) / 2
e50c669670df2538a6bb98ebcafa25043e328538
628,683
import re def trim_after(string, regex, include_pattern=False): """Trim a string after the first match of regex. If fail to match any pattern, the original string is returned The matched pattern is trimed as well. Args: string (str): the string to trim regex (regex): the regex to ma...
e4c9dfdb2f688c984a0bb0c34ca389fdd26a5c9f
628,684
def crowdsale(uncapped_flatprice, uncapped_flatprice_finalizer, team_multisig): """Set up a crowdsale with customer id require policy.""" uncapped_flatprice.transact({"from": team_multisig}).setRequireCustomerId(True) return uncapped_flatprice
77c430cacb13f7b0e1b132952760e1fd7c4980b2
628,686
import torch def rebase(x, max_entry, fl_mode="ceil"): """ left shift tensor """ if fl_mode == "ceil": return x * (2.0 ** torch.ceil(torch.log2(max_entry))) else: return x * (2.0 ** torch.round(torch.log2(max_entry)))
2b3bb4e64f6fee20118660fe36d3c88db707daaf
628,688
def _return_arg(__arg: ..., /) -> ...: """Return the singular positional argument unchanged.""" return __arg
b4f8b9b8a7b7d344f15c99fdeaf71f938dca5892
628,689
def invert_mapping(mapping): """document to hierarchy labels. [modules, lessons, items] """ inverted_mapping = {} for coursera_item_type, value_dict in mapping.items(): # coursera_item_type one of [modules, lessons, items] for item_name, doc_ids in value_dict.items(): for...
2547dfffb6243908d54c7080666e3b33f8a23d06
628,690
def display_iscsi_device(iqn, sess): """ Print the data for iscsi device identified by iqn. Parameters ---------- iqn: str The iSCSI qualified name. sess: OCISession An oci sdk session. Returns ------- bool: True on success, False otherwise. """ this_compa...
efc77ddd813fb0ece6fe5cae24b4719dcff948d2
628,691
def get_fitness(traceIsFit, traceFitnessValue): """ Gets a dictionary expressing fitness in a synthetic way from the list of boolean values saying if a trace in the log is fit, and the float values of fitness associated to each trace Parameters ------------ traceIsFit Boolean value that...
4a160126c7b0574919b9d98e7eae0bf5cf705df5
628,692
def get_items_rated_by(user_id, ratings_matrix): """ param user_id: id de l'utilisateur recherché param ratings_matrix: matrice d'interactions return: items notés par l'utilisateur user_id """ user_ratings = ratings_matrix.loc[[user_id]] items = user_ratings[user_ratings.columns[~user_rating...
0e0d9de50961c68ef34fb358100ebf8f085dfba2
628,693
import os def join_path(*paths) -> str: """os.path.join() to return only linux path string, that means replace backslash with slash""" return os.path.join(*paths).replace('\\', '/')
076beb5a7e36f9c8eabd7aaec3de83b73a39d599
628,694
import os def file_name(filename): """ Gets file name without extension. :param filename: :return: file name. """ return os.path.splitext(filename)[0]
8789e35d6b54e2ece4861008430f9fef93b38afb
628,695
import re def make_key(word: str, sense: str) -> str: """Create a key from a word and sense, e.g. "usage_example|NOUN". word (unicode): The word. sense (unicode): The sense. RETURNS (unicode): The key. """ text = re.sub(r"\s", "_", word) return text + "|" + sense
a417c00c8a11961d4e33b9df59665cc50b02efbe
628,696
import re def cleanup_tlg_txt(tlg_str): """"Remove all non–Greek characters from a TLG corpus.""" # fix beta code transliteration problems tlg_str = re.sub(r'ι|\+', 'ϊ', tlg_str) tlg_str = re.sub(r'ί\+', 'ΐ', tlg_str) tlg_str = re.sub(r'\\.', '.', tlg_str) # fix tlg markup tlg_str = re.sub...
563f70fb2e701f3c50816a15dddd716f3bd6aa4e
628,697
def pagination(item_count, page_start, page_limit, cb): """ Pagination for Inline Keyboard :type item_count: int :type page_start: int :type page_limit: int :type cb: str :param item_count: total number of items :param page_start: page_start page from this item number :param page_li...
fec98e5a268664f6faaea040c12150e352927480
628,698
from typing import OrderedDict def _sort_resources(resources): """ Sorts a resource dictionary of the type validated by 'sync_services.is_valid_resource_schema' by using an OrderedDict. :return: None """ for values in resources.values(): values["children"] = OrderedDict(sorted(values[...
550ea92e5939a4817973e39532218f1aa910e9c9
628,699
def discard_unknown_labels(labels): """Function for discarding medial wall (unknown) labels from a list of labels. Input arguments: ================ labels : list List of labels. Each label must be an instance of the MNE-Python Label class. Output arguments: ===============...
55dfd39591c4979979eb2f06515b57c6236ca407
628,700
from collections import defaultdict def tree(): """ Tree structure """ return defaultdict(tree)
89362149c544e0331736ff8106a0335bc7ae8f0d
628,701
def org_default_payload(login: str, uid: int): """Provide the basic structure for an organization payload.""" return { 'action': 'member_added', 'membership': { 'url': '', 'state': 'pending', 'role': 'member', 'organization_url': '', 'u...
af542f5a9da78ff3b08e80cd49e84f828e9a8cbb
628,702
def construct(*args, datatype, typename=None, **kwds): """ Construct an object from a type constructor. A type constructor is a dictionary which has a field "datatype" which has a callable method to construct a class, and a field "typename" which is the Python path of the function or class in "data...
c32bdc0d48a69aa9c1e263d30e46fe5297dc21b7
628,703
def dynamic_import(fqn): """ Import a module use a FQN and return the last module in the chain. See python.org/doc/2.5/lib/built-in-funcs.html. """ #print "utilfqn",fqn mod = __import__(fqn) #print "mod",mod components = fqn.split('.') for comp in components[1:]: mod = getatt...
55be700c46f11d93bdb2f1fc440d2e5a40ae9bb5
628,704
def graph_links(links): """ Decorates a link dataframe so it can be used as a basis for building a graph; It is meant to be used on a LineDraft export link DataFrame; :param links: LineDraft link DataFrame; :return: Basically the same as links but with different names and trivial columns; """ ...
760f517e5be5fb1bf747bfa20f061c14fb15dadb
628,705
def generate_brightness_string_from_brightness_barcode(brightness_barcode, num_interval=15): """ Helper function Generate the string where each character represents the brightness interval of the brightness in the input brightness barcode. :param brightness_barcode: Input 1 dimensional brightness b...
07c059778409ea349df2a5f2ad5f26754f1a3f31
628,706
def rfcspace(string): """ If the string is an RFC designation, and doesn't have a space between 'RFC' and the rfc-number, a space is added """ string = str(string) if string[:3].lower() == "rfc" and string[3] != " ": return string[:3].upper() + " " + string[3:] else: retu...
667f159f5c2a3103db89729ec986735c4849fc02
628,707
def sorted_point_set(): """Returns simple, unsorted point set""" return [(1,1), (1,3), (2,1), (2,2), (2,3), (3,2)]
580df7cc80f41acc89ab0a16b045beb0601f3112
628,708
def _flatten_marshmallow_errors(errors): """Flatten marshmallow errors.""" res = [] for field, error in errors.items(): if isinstance(error, list): res.append( dict(field=field, message=' '.join([str(x) for x in error]))) elif isinstance(error, dict): ...
702837c2d580af0ec790c434662ba1036f759b6a
628,709
def extract_feature(model, frame, return_h_w=False): """Extract one frame feature everytime.""" out = model.get_intermediate_layers(frame.unsqueeze(0).cuda(), n=1)[0] out = out[:, 1:, :] # we discard the [CLS] token h, w = int(frame.shape[1] / model.patch_embed.patch_size), int(frame.shape[2] / model.patch_embed.p...
393a15f2213e45ad8b22b9310332173a7295c4d1
628,710
def _args_to_recodings(*args, _force_index=False, **kwargs): """Convert arguments to replaceable""" values = {} for i, arg in enumerate(args): if isinstance(arg, dict): values.update(arg) else: values[i] = arg values.update(kwargs) if _force_index: fo...
24b798c52f7502d8f1085f27cc13deb4454040a1
628,711
def validate_schema(assert_, data, schema, error_on_extra_cols=False): """Check if a data frame complies with a schema """ cols = set(data.columns) expected = set(schema) missing = expected - cols unexpected = cols - expected msg = 'validate_schema: missing columns {missing}.'.format(missin...
819bf7ef34df6bd44961051de89638164e334fc0
628,712
def extract_header(filename: str): """ Extract the header of a Deltamed .eeg file. Args: filename: path to the .eeg file. Returns: A list of bytes """ header = [] with open(filename, 'rb') as file_: header = [ char if isinstance(char, bytes) else bytes([char...
7c9fe634ccf4474054c1b58c467da6a87f28eab8
628,713
import random import torch def seq_data_iter_random(corpus, batch_size, num_steps): """使用随机抽样生成一个小批量子序列""" # 从随机偏移量开始对序列进行分区,随机范围包括num_steps-1 corpus = corpus[random.randint(0, num_steps - 1):] # 减去1,是因为我们需要考虑标签 num_subseqs = (len(corpus) - 1) // num_steps # 长度为num_steps的子序列的起始索引 initial_i...
db9a7433ee49013c463f683a6287a942df03c9f6
628,714
def single_chain_filter(df): """ Remove anything beyond first model/chain in structure. :param df: dataframe to filter against. :type df: atoms dataframe. :return: same dataframe if structure has only one chain, otherwise empty dataframe. :rtype: atoms dataframe. """ chains = df[['str...
b7b9d656a7bfe30353d13fa57b1d26b548050509
628,715
import argparse def get_command_line_arguments(): """Get arguments from command line""" parser = argparse.ArgumentParser(prog="Pygit. Initialize working directories for python-git") parser.add_argument("-v", "--verbosity", type=int, help="turn verbosity ON/OFF", choices=[0,1]) parser.add_argument("-r...
c04aa795247952071189e99784f86268a520c416
628,717
def named(values, names): """Creates a dict with `names` as fields, and `values` as values.""" return dict(zip(names.split(), values))
67f7eb9c22cd74594137aaed390006ca73d48736
628,719
def attributes(): """Output file attributes.""" lexical = [ 'count_dot_url', 'count_hifen_url', 'count_underline_url', 'count_bar_url', 'count_question_url', 'count_equal_url', 'count_arroba_url', 'count_ampersand_url', 'count_exclamation_url', 'count_blank_url', 'count_til_url',...
384b9d893133c817d80feda93406172183501894
628,720
def get_majority_vote(a): """ Returns the majority vote element of a list """ return max(map(lambda val: (a.count(val), val), set(a)))[1]
95bab122350813aaafc6965a6dcf14c87483701e
628,721
def hasQueryMatch(qList, tweetJSON): """Returns true if a tweet containing any keyword in QUERY_KEYWORDS is found""" return any(keyword in tweetJSON['text'] for keyword in qList)
b0ff979b8c54f09450749ef134c7b9deabe7a231
628,722
import torch def sub(input, other, *args, **kwargs): """ Subtracts ``other``, scaled by ``alpha``, from ``input``. Examples:: >>> import torch >>> import treetensor.torch as ttorch >>> ttorch.sub( ... ttorch.tensor([1, 2, 3]), ... ttorch.tensor([3, 5, 11])...
bf1d9ed3e23500e28beccfff29c325ed8289330b
628,723
import torch def get_window(name, window_length, squared=False): """ Returns a windowing function. Arguments: window (str): name of the window, currently only 'hann' is available window_length (int): length of the window squared (bool): if true, square the window Returns: ...
f5cca82ae8983f0297fac601bc563d6f89d6af6e
628,724
def get_p_significance(p_value): """ Get the statistical significance indicator :param p_value: :return: statistical significance indicator """ if 0 < p_value < 0.001: return ' ***' elif 0.001 < p_value < 0.01: return ' **' elif 0.01 < p_value < 0.05: return ' *' ...
566255eef5ab8c8d76d503f2538cb56aa3f8462d
628,725
def triangle_area(p1, p2, p3): """ Calculate the triangle area given from 3 points :param p1: :param p2: :param p3: :return: """ x1, y1 = p1[0], p1[1] x2, y2 = p2[0], p2[1] x3, y3 = p3[0], p3[1] return abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2...
e2578627993221518eb2d72a4b553cbbdffaf897
628,726
import math def binom(n, k): """ Compute a binomial coefficient (n choose k). Parameters ---------- n, k : int Positive integers. Returns ------- int """ # could be replace by math.comb(n, k) in Python >= 3.8 try: return math.factorial(n) // ma...
3a5af73134a2cc1b746d48e5a210af07b66f4a5c
628,727
def get_kinds_section(structure, protocol_settings): """ Write the &KIND sections given the structure and the settings_dict""" kinds = [] all_atoms = set(structure.get_ase().get_chemical_symbols()) for atom in all_atoms: kinds.append({ '_': atom, 'BASIS_SET': protocol_set...
eec6280712b01bdeb09006b5e914acfa11256795
628,728
def sanitizeContents(contents:str) -> str: """ Sanitizes the input `contents` string to be a well-behaved config file. """ out = [] for line in contents.splitlines(): tmp=(" ".join(line.split())).strip() #squeezes spaces and trims leading and trailing spaces tmp=tmp.replace("&amp;", '&') #decodes HTML-encoded ...
9f407af1f1d46fb9f50a79c84a4040a7a1305646
628,729
def is_trivial_dir(dname): """input a string return 1 if dname is empty or '.' else return 0 """ if dname == None: return 1 if dname == '' or dname == '.' or dname == './' : return 1 return 0
f072d4e31ead2f90a1598e1778b78778977344b8
628,730
def add_metadata_defaults(md): """Central location for defaults for algorithm inputs. """ defaults = {"batch": None, "phenotype": ""} for k, v in defaults.items(): if k not in md: md[k] = v return md
ef612ae8a2d4bccfbb6955a9191aaed1239665f5
628,731
def dummy_room(create_room): """Give you a dummy room.""" return create_room()
0caea041d5f39bcbd2080cf7ebf633d8b3c0d017
628,732
import os import sys def _cd(name, **kws): """change directory to specified directory""" name = name.strip() if name: os.chdir(name) ret = os.getcwd() if sys.platform == 'win32': ret = ret.replace('\\','/') return ret
4bb15a076a003c09520589a6358d599b1032c11c
628,733
from typing import List def parse_reqs(requirements_file: str) -> List[str]: """Get requirements as a list of strings from the file.""" with open(requirements_file) as reqs: return [r for r in reqs if r]
bd9f8decddef9dc6c61ad9d837f18ea7bb45e1e3
628,734
def _mean_int(*args): """Return the mean of the supplied values.""" return int(sum(args) / len(args))
e3809221fb93d0424f540113adffa4942de63cfe
628,735
def echo(**kwds): """ Retorna um eco para a chamada na API """ return kwds
f1872212f16de2a802ec72133f325508433dcfac
628,736
def payload_2(kernels, time_2, output_time_format, output_time_custom_format): """Payload from WGC API example 2.""" return { "kernels": [{ "type": "KERNEL_SET", "id": kernels, }], "times": [ time_2, ], "calculationType": "TIME_CONVERSI...
94df462a9c31347101eec66f12a4e84e25f10d28
628,737
def nodeKey(search, node, goal, heuristicFunc): """ Give sort key that prioritizes node based on search, where min key is higher priority. This prioritization is essentially the difference between the various search algorithms. """ if search == 'A*': g = node.cost; h = heu...
258b20beabf7ccf2fc89d44e8411187c2957034b
628,738
def wspolczynniki(liczba_wezlow, numer_wezla): """ :param liczba_wezlow: liczba węzłów (int) :param numer_wezla: numer węzła (int) :return: para liczb: (wartość w węźle, waga) """ dane = ( ((- 0.577350, 1), (0.577350, 1)), ((- 0.774597, 5 / 9), (0, 8 / 9), (0.774597, 5 / 9)), ...
777c05afa0f74028e12c48f8dcd2a17955c3ceec
628,739
def _has_surrogates(s): """Return True if s contains surrogate-escaped binary data.""" try: s.encode() return False except UnicodeEncodeError: return True
19e6ef5bb3e71d37a3f9afa199f8b01aba96e3ef
628,740
import os def get_file_ext(filename): """ Gets the extension (or compound extension) from a filename Keyword arguments: filename -- the file to get the extension from """ root,ext = os.path.splitext(filename) if ext.lower() in ['.gz', '.bz2', '.xz']: other = os.path.splitext(r...
200c451d064617d1ff25827c7d2d146d0953daad
628,741
def get_alias_year(work, alias): """Get year from alias Default: return first element of tuple/list that represents the alias """ return alias[0]
8a89a55e73b29eab6f20d01a027ac974dd3aca10
628,742
def Binary(value): """Construct an object holding binary data. This function is part of the `DBAPI 2.0 specification <http://www.python.org/dev/peps/pep-0249/>`_. """ return value
3b79a0fbaa6ffc07a8730c46113ecd770dbfb2e9
628,743
def get_empty_env_directory_map(organisms_dir, samples_dir, data_dir): """ Get dictionary from environment variables (:py:const:`riboviz.params.ENV_DIRS`) to directories. Returns an empty dictionary. All parameters are unused. :param organisms_dir: Organisms directory :type organisms_dir: str o...
03ffabf910c0b9e704e105149b55c4e22f779da3
628,744
def hamming_dist(hash1, hash2): """ calculate hamming distance :param hash1: hash with value {-1, 1}, with shape (hash number, hash bit) :param hash2: hash with value {-1, 1} and same length of hash bit with hash1 :return: """ q = hash1.shape[-1] distH = 0.5 * (q - hash1.mm(hash2.transpo...
8edabdf4ae6cdc046aa0159caf647899398eff08
628,745
def format_indent_line(items, spaces, indent, backslash, is_last): """Returns elements separated by commas. The line can be indented. This function is for internal use and is not available in templates. :param list items: a list of items. :param int spaces: indentation spaces :param bool indent: in...
f8c2ff98286456a51982557471359826c300678c
628,746
def tower_of_hanoi( n: int = 1, from_rod: str = 'A', to_rod: str = 'B', through_road: str = 'C' ) -> str: """ Solving the Hanoi Towers puzzle. Returns a string with the sequence of disc changes from rod to rod in the format 'disk_number from_rod->to_rod' If n < 0 it raise...
7a97c01c775e0200a7d1e44bcd106e66276a5120
628,747
def weeks_el(day1, day2): """ (int, int) -> int Return number of weeks between two days in the same year. >>> weeks_el(3, 20) 2 >>> weeks_el(9, 61) """ one = (abs(day1 - day2)) // 7 return (one)
2f1e69676b79625b28991ed84a533326ffa6a0e9
628,748
import argparse def get_argument_parser(): """Get argument parser.""" parser = argparse.ArgumentParser( description='Deploy application.') parser.add_argument('environment', type=str, choices=['dev', 'tst', 'qa', 'prd'], help='The name of the environ...
12a80b6d87e19884ee8d048dd5308c0a5760f135
628,749
def one_sentence(): """A one sentence text without newlines""" return "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
0d921900c6c8c8f7281c86bc9d13762ebe3ee0d0
628,750
def cos(x): """Return the cosine of *x* radians.""" return 1.0
88a84b17734602ba1c92189df893a700524d1c1a
628,751
from typing import Optional import tempfile import os import subprocess def bash(script: str, environment: Optional[dict] = None): """Runs command-line programs using the bash's shell.""" handle, script_path = tempfile.mkstemp(suffix=".sh") try: with os.fdopen(handle, "w") as f: f.writ...
b8405e2f8e20b462eaf8fe50dbec55cbcf8560bc
628,752