content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
from typing import Mapping import subprocess import json def _conda_info(codna_env: str) -> Mapping: """ Return json response of `conda run -n $conda_env info` command :param codna_env: :return: """ process = subprocess.run( ['conda', 'run', '-n', codna_env, 'conda', 'info', '--json'],...
b643cad358843542d1c9addd5e76c8f06be1bb51
41,787
from typing import List from typing import Tuple from typing import Dict def edf_annotations(triggers: List[Tuple[str, str, float]], durations: Dict[str, float] = {} ) -> List[Tuple[float, float, str]]: """Convert bcipy triggers to the format expected by pyedflib for writin...
8c26f7e7bd874bc2a996e251f02513135e8e9e49
41,788
import math def IMGB(X): """ IMGB converts true/false imaginary numbers into real numbers B(t) = 1 + 0i B(f) = 0 + 0i """ return (-2 * (X - 1)) / complex(3, -math.sqrt(3))
642cfbe1c7d25b7329398b0b8a859e5907430166
41,789
import os def _can_write(params): """Check if file exists and if the -f flag is defined.""" if os.path.exists(params.filename): return params.force_overwrite return True
3acaaa034521c275f97d05b6881ac885cc4359a4
41,790
def norm_na(data, na_values): """ Standardize missing values Parameters ---------- data: pd.DataFrame DataFrame to make changes to na_values: list List of missing values to replace """ base_na_list = ["\\b#N/A\\b", "\\b#N/A N/A\\b", ...
604bccdee5186b9c56eb4fcea4035a72c06c4169
41,791
def get_N(longN): """ Extract coefficients fro the 32bits integer, Extract Ncoef and Nbase from 32 bit integer return (longN >> 16), longN & 0xffff :param int longN: input 32 bits integer :return: Ncoef, Nbase both 16 bits integer """ return (longN >> 16), (longN & (2 ** 16 - 1))
bb8a0c041d8821958901681d925d278fb7083ba5
41,792
import math def gaussian(x, amplitude, mu, sigma): """ # # from https://en.wikipedia.org/wiki/Gaussian_function >>> gaussian(0, 1, 0, 10) 1.0 >>> gaussian(0, 1, 1000, 10) 0.0 """ val = amplitude * math.exp(-(x - mu)**2 / sigma**2) return val
d87efb609fa1871e64516be8ed6be13903bc86e8
41,794
from typing import List def are_diagonals_safe(board: List[List[int]], y_initial: int, x_initial: int, size: int) -> bool: """ Loop over columns and check if it's valid to place a queen at (x_initial, y_initial) Notes: Board is inverted so read the below to understand: top means absol...
4ba602872cb3aa01c96cbb6b52e25c957e329939
41,795
def join_list_mixed(x, sep=', '): """ Given a mixed list with str and list element join into a single str :param x: list to be joined :param sep: str to be used as separator between elements :return: str """ return sep.join([sep.join(y) if isinstance(y, list) else y for y in x])
5faa80d7a451ceeff658938976f291337a6ee8d0
41,797
import re def trim(string: str) -> str: """Takes in a string argument and trims every extra whitespace from in between as well as the ends.""" return re.sub(" +", " ", string.strip())
5c7b428d742a7255b0036d4eeb75a5fab2817e36
41,800
def _proc_lines(in_str): """ Decode `in_string` to str, split lines, strip whitespace Remove any empty lines. Parameters ---------- in_str : bytes Input bytes for splitting, stripping Returns ------- out_lines : list List of line ``str`` where each line has been stripp...
66cd12550503ffd421bab32084a0c23897f90588
41,801
import itertools def decode_years_to_min_max(summarized_year_string): """ decode a summarized string of years into minimum & max. year values >>> decode_years_to_min_max('2000-2002, 2004') (2000, 2004) >>> decode_years_to_min_max('1992, 1994-1995') (1992, 1995) >>> decode_years_to_min_max...
078b74432fc762c4ba39accec90a72a6cec00dc9
41,802
def font_style( custom_font, font): """ Changes font family :param custom_font: font used by Message in Tkinter GUI :param font: font the user selects :return: font used by GUI """ custom_font.config(family=font) return custom_font
d2bf35924abd32b6232039c6284dbb35891a4df8
41,803
def y_in_process(coord2d: list, y_coord: int, ly: int, processes_in_y: int) -> bool: """ Checks whether a global y coordinate is in a given process or not. Args: coord2d: process coordinates given the cartesian topology x_coord: global y coordinate lx: size of the lattice grid in y ...
0d67c92426f44fff405e7f50f4219ad2d2c76361
41,804
def fast_transpose(cg, inner_block, align=32): """ Builds a fast transpose using an internal blocking scheme in an attempt to vectorize IO from/to DRAM """ sig = "void gg_fast_transpose(unsigned long n, unsigned long m, const double* PRAGMA_RESTRICT input, double* PRAGMA_RESTRICT output)" cg.start_...
0fe0884fd97c8f740da499334d665a1c6a083c1a
41,805
import os def get_scripts_path(creator_name: str, mods_dir: str, mod_name: str = "Untitled") -> str: """ This builds a path to the Scripts folder inside the Mod Folder :param creator_name: Creator Name :param mods_dir: Path to the Mods Folder :param mod_name: Name of Mod :return: Path to Scri...
8331bc3949f01efe38445c541f307d1445d8a833
41,807
def flatten_nodes(parent_node, result): """ create a list of nodes """ # The node is valid ? if not parent_node: return False # This node has children ? if not parent_node.get('children'): return False for node in sorted(parent_node['children'].keys()): c_nd = dict(paren...
10cb80a66862793aee128c0b7ecf3bd2c11868c5
41,808
import requests def fetch_coordinates(apikey, address): """ Get the coordinates of address. Returns: return: longitude and latitude of address. Args: apikey: token for Yandex service. address: name of specific place. """ base_url = "https://geocode-maps.yandex.ru/1.x"...
027a73130526522019cadf1982c22039873c732b
41,809
def fit(x,a,b,c,d): """ the fit function for accomodation against focal length """ return a*x**3 + b*x**2 + c*x + d
3dcfb363755bbc429edc03423ab3b7eb19da8137
41,810
import torch def compute_iou(pred_mask, gt_mask): """ Computes IoU between predicted instance mask and ground-truth instance mask """ pred_mask = pred_mask.byte().squeeze() gt_mask = gt_mask.byte().squeeze() # print('pred_masks', pred_mask.shape, 'gt_masks', gt_mask.shape) intersecti...
fbfbfaa92954d950dd18e5bf9e21bf303676a28d
41,812
def document_path(doc_id, options): """Return relative path to document from base output directory.""" if options.dir_prefix is None: return '' else: return doc_id[:options.dir_prefix]
91ef1244839580d9d218639676d0f6979008cf67
41,813
def constrain_cfgdict_list(cfgdict_list_, constraint_func): """constrains configurations and removes duplicates""" cfgdict_list = [] for cfg_ in cfgdict_list_: cfg = cfg_.copy() if constraint_func(cfg) is not False and len(cfg) > 0: if cfg not in cfgdict_list: cfg...
dd880b8d67847c67bdeb1e7fe4d5234f03e50bd8
41,815
import re def pip_to_requirements(s): """ Change a PIP-style requirements.txt string into one suitable for setup.py """ if s.startswith('#'): return '' m = re.match('(.*)([>=]=[.0-9]*).*', s) if m: return '%s (%s)' % (m.group(1), m.group(2)) return s.strip()
dcfceacfab4c47429bd7aff7bc6795ab7f3f7b5f
41,816
def hash3(key: str, tablesize: int) -> int: """ 因为是大端模式,所以这么写,大端模式即高有效位在低位,而上面的729*key[2]是小端模式 大端模式的好处是方便用Horner法则计算 乘法改成乘以32,这样方便移位运算加速 """ hashval = 0 for k in key: hashval += (hashval << 5) + ord(k) return hashval
6e4656dada7cd89364afaa723feda7b14c865124
41,818
def range_check(value, min_value, max_value, inc_value=0): """ :brief Determine if the input parameter is within range :param value: input value :param min_value: max value :param max_value: min value :param inc_value: step size, default=0 :return: Tru...
bf21759371706144e9d25f0692c60d3246e66159
41,819
import json def destructure(env): """Decodes Nix 2.0 __structuredAttrs.""" return json.loads(env['__json'])
93b7fbee7262358c75d8f7d9343e51fef2662f6a
41,820
import os def determineAppropriateGroupID(): """ Determine a secondary group ID which can be used for testing, or None if the executing user has no additional unix group memberships. """ currentGroups = os.getgroups() if len(currentGroups) < 2: return None else: return curr...
2f684601a1584fedc71f5b061160fed11a986241
41,821
def wns_payload(alert=None, toast=None, tile=None, badge=None): """WNS specific platform override payload. Must include exactly one of ``alert``, ``toast``, ``tile``, or ``badge``. """ if sum(1 for x in (alert, toast, tile, badge) if x) != 1: raise ValueError("WNS payload must have one notific...
50162e61a945950deb2c16bf23a87c0775f81f75
41,823
def get_event_ID(ev): """ extracts unique ID of a skipped exon event """ chrom = ev.split(";")[1][3:].split(":")[0] return chrom + ":" + ev.split("-")[1].replace(":", "-") + ":" + ev.split(":")[-1]
e7678d363d0147280f18ff26cdd4e657396aabe9
41,824
def passAuth(password): """ Returns true if the password matches with the user's password, else returns false.""" if password == 9241: return True else: return False
63f60643f999de198b237d3b4f0d2e4c9046157e
41,825
def _dict_printable_fields(dict_object, skip_fields): """Returns a list of strings for the interesting fields of a dict.""" return ['%s=%r' % (name, value) for name, value in dict_object.items() # want to output value 0 but not None nor [] if (value or value == 0) and name no...
776663a70a7f76879722e9ae55feef7ab50d5880
41,827
def _get_host(self, request, prefix_path = None): """ Retrieves the host for the current request prepended with the given prefix path. :type request: Request :param request: The request to be used. :type prefix_path: String :param prefix_path: The prefix path to be prepended to the host...
9b3c205734820ac03ba8e1e3441e7ea6540fc6c3
41,829
def divide(*, alpha=None, omega): """Define monadic reciprocal and dyadic division. Monadic case: ÷ 1 ¯2 5J10 1 ¯0.5 0.04J¯0.08 Dyadic case: 4 ÷ 3 1.33333333 """ if alpha is None: alpha = 1 return alpha/omega
09c2f5da506b2e3545c21fbb36209b677d63017f
41,830
def ascii_chr(value): """ Converts byte to ASCII char :param value: ASCII code of character :return: char """ return bytes([value])
e1c5053b0b68ea6bac561e9addb5ff9148890323
41,833
def create_labels_lookup(labels): """ Create a dictionary where the key is the row number and the value is the actual label. In this case, labels is an array where the position corresponds to the row number and the value is an integer indicating the label. """ labels_lookup = {} for idx,...
b80bab4792d4bd403a903c18907d16b2bcb79418
41,834
def _compose_args(bloom_fn: str, gfa_fn: str) -> dict: """Compose a dict of args with two variables""" return { "kmer": 30, "bloom": bloom_fn, "bloom_size": "500M", "levels": 1, "fasta": "tests/correct/transcript.fa", "max_fp_bases": 5, "max_overlap": 10, ...
0d3405bbef405cb2e03b6dec166151be85f6c6bf
41,835
from typing import Optional from typing import List def str2list(x: str) -> Optional[List]: """Convert string to list base on , delimiter.""" if x: return x.split(",")
62cd7f087f72981e22f2f8fdc1871a394e00501b
41,836
def mag2Jy(info_dict, Mag): """Converts a magnitude into flux density in Jy Parameters ----------- info_dict: dictionary Mag: array or float AB or vega magnitude Returns ------- fluxJy: array or float flux density in Jy """ fluxJy = info_dict["Flux_zero_Jy"] ...
b81d3b8abd10e30e12c33d2a91b42981d2c0d522
41,837
def buildProcessArgs(*args, **kwargs): """Build |CLI| arguments from Python-like arguments. :param prefix: Prefix for named options. :type prefix: :class:`basestring` :param args: Positional arguments. :type args: :class:`~collections.Sequence` :param kwargs: Named options. :type kwargs: :class:`dict` ...
e802e8b35a7b0e6f9bd06e62f29e4dce49580dea
41,838
def df_to_json(dataframe): """Turns a pandas dataframe into a JSON string. Works file for single rows, but is a little naive in terms of transformation for multiple row tables Parameters ---------- dataframe : pd, mandatory The pandas dataframe to turn into ...
c9ad685ebdc3befd0dbef2414318ba674cb73047
41,839
def strip_suffix(string, suffix): """Remove a suffix from a string if it exists.""" if string.endswith(suffix): return string[:-(len(suffix))] return string
0ca354328ce8579fcce4f16f4f0dfdeac4708391
41,843
import os def get_last_line(inputfile): """ :param inputfile: :return: """ filesize = os.path.getsize(inputfile) blocksize = 1024 dat_file = open(inputfile, 'r') last_line = "" lines = dat_file.readlines() count = len(lines) if count > 100: num = 100 else: ...
71682e58f3ed70e037261ef15e433ff98c49b357
41,845
def create_url(config): """Create github api url.""" return '{base_url}/repos/{repo_owner}/{repo_name}/issues'.format(**config)
3e3068f7a02ca65d8f2d5a1b987378e3b50d8dba
41,846
def list_items(conn=None, **kwargs): """ :rtype: ``list`` """ return [x for x in getattr( getattr( conn, kwargs.pop('service') ), kwargs.pop('generator'))(**kwargs)]
d60c3c8319401ad7027926417715fc6fa2c27a8e
41,847
def to_str(bytes_or_str): """ Converts supplied data into a UTF-8 encoded string if the data is of type bytes. :param bytes_or_str: Data to be converted. :return: UTF-8 encoded string if the data was of type bytes. Otherwise it returns the supplied data as is. """ if isinstance(bytes_or_str, by...
d54246d5f0b054d19accd0404e37d51fbd3e9b3c
41,848
def generate_code_str(body, argname, global_name): """ Generate python code to eval() """ body = body.replace('\n', '\n ') return f"""def f({argname}): {body} output = f({global_name})"""
4d580ed432d4f691006de2caa055efded20b51c9
41,849
def minmax_scale(array, ranges=(0., 1.)): """ normalize to [min, max], default is [0., 1.] :param array: ndarray :param ranges: tuple, (min, max) :return: """ _min = ranges[0] _max = ranges[1] return (_max - _min) * (array - array.min()) / (array.max() - array.min()) + _min
105dcecb40ac982dcf0973e15b9f2cc80e9a8469
41,850
def validate_chrom_lengths(chromDF, tvDF): """Ensure all chromosomes in chromDF are present in tvDF. Chromosome length file can contain for chromosomes than TV file, but not the other way around. Return True if all are found, False if not.""" chrom_names = chromDF['Chromosome'].unique() ...
0904297a6b507b3a05363dbe162468f63b5dfeef
41,852
import math def calculate_colour(c): """run the contrast calculation on a rgb component""" c = c / 255.0 if c <= 0.03928: c = c / 12.92 else: c = math.pow((c + 0.055) / 1.055, 2.4) return c
72d93c51d45977f983bcd1e6def2dba51c729c0e
41,853
def default_style(): """ The style sheet provided by pypfilt. """ text_colour = '#000000' axis_colour = '#000000' return { 'font.family': 'sans-serif', 'font.sans-serif': ['Noto Sans', 'Open Sans'], # http://matplotlib.org/users/mathtext.html#mathtext-tutorial # '...
1789aeae1d8dc821f9389ead8f575521ce41f4ee
41,854
def update_zones( self, zones: dict, delete_dependencies: bool, ) -> bool: """Configure zones on Orchestrator. .. list-table:: :header-rows: 1 * - Swagger Section - Method - Endpoint * - zones - POST - /zones .. warning:: ...
e4c1470411b75e23df02c3b14398b311d0ca59e1
41,855
import os def parent_dir(directory): """Return the parent directory for the given directory. Args: directory: The path to the directory. Return: The path to the parent directory. """ return os.path.normpath(os.path.join(directory, os.pardir))
9b222e93d904e3c22e683ae40324fc1d0938fddc
41,856
def IsVector(paramType): """ Check if a param type translates to a vector of values """ pType = paramType.lower() if pType == 'integer' or pType == 'float': return False elif pType == 'color' or pType.startswith('float'): return True return False
58a14693ffabc2230eea0b3f6702aa56ffc514ca
41,857
def _S_lambda(spara, z): """Return s-parameter lambdas from given impedance.""" if spara in ('11', '22'): return lambda f: z(float(f)) / ( z(float(f)) + 100.0)##Decimal(100) ) elif spara in ('21', '12'): return lambda f: 100.0 / (z(float(f)) + 100.0)##Decimal(100) / ( z(f) + 100)##Decimal(1...
67cdca86dbd82d8e5c9c531a56700697d234d241
41,858
def secondsToMinutes(times): """ Converts splits in seconds to minutes. """ return times / 60.0
04a97bbadce9ef982fab72fc7dced25aea16c3de
41,860
def clean_string(dirty): """ Cleans a string so it can be stored in PG without raising an error. Param: dirty (string or None) the string to be cleaned. """ if dirty: clean = dirty.replace("\x00", "\uFFFD") # fixes "ValueError: A string literal cannot contain NUL (0x00) characters." els...
b0801562b86d531023540dab648a7ee52abc0aae
41,861
def calc_frequencies(rolls): """ 1) Create a list of length 11 named totals with all zeros in it 2) Go through the rolls[][] list with a nested loop; add the number in rolls[row][col] to the appropriate entry in the totals list. """ # Initialize a list of length 11 na...
6735e0ab5111fcf51f86f7f9b1d1dcba569652ed
41,862
import random def random_sample(lst, limit=1): """ 从一个集合中随机抽取n个 """ if len(lst) > limit: return random.sample(lst, limit) else: return lst
a2cd8ac8a892d7d71f7fb383881f9555c9b68d75
41,864
import psutil import re def get_matching_process_ids(cmd_pattern, user_pattern): """ CommandLine: export PID=30196 export PID=$(python -c "import utool as ut; print(ut.get_matching_process_ids('jonc', 'python2.7'))") export PID=$(python -c "import utool as ut; print(ut.get_matching_pro...
720fd219b33a8597dab9ece359bb388a0f1c0ab5
41,867
def getRelativeFreePlaceIndexForCoordinate(freePlaceMap, x, y): """ Returns the Index in the FreePlaceValueArray in witch the given Coordinate is in :param freePlaceMap: The FreePlaceMap to check on :param x: The X Coordinate to Check for :param y: The Y Coordinate to Check for :return: The foun...
855b5c6e4e225bb5f25b941d84d71756822ec152
41,868
def add_engagement_metrics(impressions_data): """Accepts some daily impressions data. Tacks on a few more columns with various engagement metrics for testing""" # Impressions data arrives in the format: # [[date, impressions, clicks, ctr%, pins, blocks, js_date]] # remove the js_date impressio...
ec64870cd35e97beeff872de883d57379558a758
41,869
def rating_class(rating): """ Outputs the Bootstrap CSS class for the review rating based on the range. """ try: rating = float(rating) except ValueError: return "" if rating >= 80: return "success" if rating >= 50: return "info" if rating >= 20: ...
46bb43032a7193ffe63e91bc261a36eca84da0a6
41,870
import subprocess import os def make_prot_db(fasta_file, outname=None, combined="combined.fa"): """ Creates GenBank Databases from Protein FASTA of an organism Parameters ---------- fasta_file : str or list Path to protein FASTA file or list of paths to protein fasta files outname : s...
b62cdd3f41a39f20dba83ca0816ad91a0f566873
41,874
import platform def dump_config(config, *args): """Dump arguments""" if platform.system() == "Windows": return ['powershell', '-Command', f"echo \"{' '.join(args)}: {config}\""] return ['bash', '-c', f"echo \"{' '.join(args)}: {config}\""]
d8af4550bf01a41aa41c7887705188c9aa7a1a82
41,875
def charmask(space, char_list, caller): """Return a character mask based on a character range specification. Note: the caller's name must be specified to get correct warnings. """ def _warn(space, msg, caller): space.ec.warn(caller + "(): Invalid '..'-range" + msg) mask = [False] * 256 ...
51e02797b8639ca30b25cb0ec0e696b7177e9292
41,876
def check_tree(tree_root, visited=None): """ Perform some basic structural check on a DFS tree. :param tree_root: :param visited: :return: """ if visited is None: visited = [] for pp in tree_root.pseudo_parents: if tree_root not in pp.pseudo_children: return ...
6806897b898ea70249b05634912075b551833e02
41,877
import os import zipfile import tarfile def create_archive(archive, root, relative_file_paths): """ Create an archive with given file paths relative to given root.""" extension = os.path.basename(archive).split(os.extsep, 1)[1] if extension == "zip": with zipfile.ZipFile(archive, mode="w") as z: ...
2b5638f3337940112602396b6dd51820be8ad9cd
41,878
def create_info(type, client_public_key, server_public_key): """ Create info structure for use in encryption. The start index for each element within the buffer is: value | length | start | ----------------------------------------- 'Content-Encoding: '| 18 | 0 | ...
0e2dae46522d89c8b099721d05bac6ae0058e64a
41,879
def get_total(alist, digits=1): """ get total sum param alist: list param digits: integer [how many digits to round off result) return: float """ return round(sum(alist), digits)
27a26f21e74036a56796f1cc05fcfb88efa41a45
41,883
import re def check_is_valid_url(url): """check if the url provided is valid""" if re.match(r"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)", url): return True return False
0ca83c0d2e4baeb660ab67fe17cca640560988ee
41,884
def fatorial(numero): # função recursiva """ Funcao recursiva As três aspas duplas é a documentação """ if numero <= 1: return 1 else: return (numero * fatorial(numero - 1))
b4457f5f43ea21e986d25297e49b75f04af94b43
41,885
import json def to_json(obj): """Object to JSON.""" return json.dumps(obj)
2029d7507b029ea1d9c11c99a3a9735d0094a3c6
41,886
import argparse def get_parameters(): """ make parser to get parameters """ parser = argparse.ArgumentParser(description="take config file path") parser.add_argument("config", type=str, help="path of a config file for testing") parser.add_argument( "--checkpoint_path", type=s...
a666b0fe6fc6398b614171e79d2e6a278beb2ba2
41,887
import base64 import uuid def gen_random_string(): """Summary Returns: TYPE: Description """ return base64.urlsafe_b64encode(uuid.uuid4().bytes)[:22].decode('utf-8')
9e3d352d0ded63d4ab1e3bdb29a0510e884d10d2
41,888
def get_prev_offset(offset, limit): """ Calculates the previous offset value provided the current one and the page limit :param offset: :param limit: :param size: :return: """ pref_offset = offset - limit if pref_offset >= 0: return pref_offset
3dbe5419484a0be5c5ade42704c037ef59e18ac6
41,890
import numpy def calculate_overlap_ratio_single_det(walker, delta, trial, i): """Calculate overlap ratio for single site update with UHF trial. Parameters ---------- walker : walker object Walker to be updated. delta : :class:`numpy.ndarray` Delta updates for single spin flip. ...
1e2a6325c3ef3951ccaa3182e9a79e506428ee34
41,891
def object_name(obj): """Generates a name for an object from it's module and class Args: obj (object): any object to be named Returns: String naming the object """ try: try: return obj.__module__ + '.' + obj.__name__ except TypeError: retur...
5ffcd38ca1f0468b0c60fb87afbea46786bd21a9
41,892
import re def replaceall(replace_dict, string): """ replaceall will take the keys in replace_dict and replace string with their corresponding values. Keys can be regular expressions. """ replace_dict = dict((re.escape(k), v) for k, v in list(replace_dict.items())) pattern = re.compile("|".join(lis...
66c6ec299476986011de21a5f28a613c44435d33
41,894
import six import io def write_string(file, text, encoding='utf-8'): """Write text to given file. This method will automatically detect whether or not ``file`` is text based or byte based. """ if not isinstance(text, six.string_types): raise TypeError('Text must be string or bytes type.')...
a08a9e5722c4b700f8d0fe1ae29aaaf104fdc06f
41,895
def set_config_value_unknown(config_dict, find_key, new_value, unknown): """for a given dictionary, it will recursively search for the key. if a key is found it will assign the new value if the key is not found, it will assign the key-value pair to the unknown key in the dictionary """ def _se...
fb5a12240b1c3107ce8a52d6c419dc7b5f0b2871
41,896
def roll_rating(flight_phase, aircraft_class, roll_timecst): """ Give a rating of the Roll mode : Level1 Level2 or Level 3 according to MILF-8785C Args: flight_phase : string : 'A', 'B' or 'C' aircraft_class : int : 1, 2, 3 or 4 roll_timecst (float): Roll Mode time constante [s] R...
7e24ad1cf3c2433ed7b3e5fe7dab8a53b35a6d8d
41,898
def patch_card(card, expansion): """Temporary fixes for issues in mtgjson data. Remember to also report these upstream.""" return True
c32386a6d844567d482d54da70a7fd0c09e0d767
41,901
def sample_data_pyAISm(): """ Provides a sample of pyAISm decoded AIS data. :returns dict """ return { "type": 3, "repeat": 0, "mmsi": 366892000, "status": 0, "turn": 0, "speed": 64, "accuracy": '1', "lon": -122.51208, "lat": 37...
bac7dec787b9636608a7606dcb93621dfdd8b9b3
41,902
import math def convertBytes(bytes, lst=None): """ :param bytes: :param lst: :return: """ if lst is None: lst = ['Bytes', 'K', 'M', 'G', 'TB', 'PB', 'EB'] i = int(math.floor( # 舍弃小数点,取小 math.log(bytes, 1024) # 求对数(对数:若 a**b = N 则 b 叫做以 a 为底 N 的对数) )) if i >= len...
44fbd76f22a15df3f11096c2e44ba52c9c2f0d7e
41,903
def generate_config(context): """Generates configuration.""" deployment_name = context.env['deployment'] type_provider_name = context.properties['typeProviderName'] scheduling_function_name = context.properties['routerFunctionName'] deployment_function_name = deployment_name + '-deployment' type_provider ...
cf18a47331f3270590a1e26215ee1090b544e70c
41,904
import csv def get_symbols(): """Read symbols from a csv file. Returns: [list of strings]: symbols """ with open('symbols.csv') as f: reader = csv.reader(f) return [row[0] for row in reader]
cd4552761f0e6e4ec55ed764fb399e9442b9b1a1
41,905
def correct_invalid_value(value, args): """This cleanup function replaces null indicators with None.""" try: if value in [item for item in args["nulls"]]: return None if float(value) in [float(item) for item in args["nulls"]]: return None return value ...
e7c575d45237dce82491e53afeccb953b21e1b33
41,906
from typing import Dict def generate_wiki_template_text(name: str, parameters: Dict[str, str]) -> str: """ Generate wikitext for template call with name and parameters. Parameters should not contain unescaped '{', '}' or '|' characters, otherwsie generated text can be incorrect. """ result = ...
2c785431fed529cafa45a22a824033d284dffd44
41,907
import importlib def my_model(opts): """Creates model object according to settings in parsed options. Calls function with name opts.opts2model in module opts.model_module to create model instance. Args: opts (obj): Namespace object with options. Required attributes are opts.model...
9c31d2ba15c157cf5f7b15a7cf6fba88ce16a981
41,908
def channel_name(channel): """Get IRC channel name. :channel: channel name without # :returns: channel name with # """ return "#%s" % channel if not channel.startswith('#') else channel
07f975dc389de05263ed5c17bc8e5e33999b0571
41,909
def split(container, count): """ split the jobs for parallel run """ return [container[_i::count] for _i in range(count)]
bb665bef7e81a5ed4c9d0ba5e61e5a97b17dcc58
41,910
def initDbInfo(): """ function: create a init dbInfo dict input: NA output: NA """ tmpDbInfo = {} tmpDbInfo['dbname'] = "" tmpDbInfo['dboid'] = -1 tmpDbInfo['spclocation'] = "" tmpDbInfo['CatalogList'] = [] tmpDbInfo['CatalogNum'] = 0 return tmpDbInfo
4ddb0da18387d03a0beaaab8a280c45db2d76024
41,911
from typing import Optional from typing import Iterable from typing import Pattern def include_or_exclude( item: str, include_regex: Optional[Iterable[Pattern[str]]] = None, exclude_regex: Optional[Iterable[Pattern[str]]] = None ) -> bool: """ Returns: True if the item should be inclu...
0179244d8dc220a08c7b4a8f82edb1eac126f431
41,913
def test(self, args): """run tests""" if args.remainder and args.remainder[0] == '-': remainder = args.remainder[1:] else: remainder = args.remainder return (self.local.FG, self.local['tox'][remainder])
256ad67134269cafbbe7779d2e51b366f827e766
41,914
def group_cpu_metrics(metrics): """Group together each instances metrics per app/space""" grouped_metrics = {} for metric in metrics: grouped_metrics.setdefault(metric['space'], {}).setdefault(metric['app'], []).append(metric['value']) return [(app, space, metric_values,) for space,...
91b91601c359e2b80c31b80fcb80bd5915d5972d
41,915
def time2secs(timestr): """Converts time in format hh:mm:ss to number of seconds.""" h, m, s = timestr.split(':') return int(h) * 3600 + int(m) * 60 + int(s)
e06432cd56db691574e8400a23a57982e9177531
41,916
def convert_arabic_to_roman(arabic): """ Convert an arabic literal to a roman one. Limits to 39, which is a rough estimate for a maximum for using roman notations in daily life. ..note:: Based on https://gist.github.com/riverrun/ac91218bb1678b857c12. :param arabic: An arabic number, as str...
6f786c75250fe4da7e7c540acc82a8fc100254a7
41,917
def dont_give_me_five(start, end): """ Start number and the end number of a region and should return the count of all numbers except numbers with a 5 in it. The start and the end number are both inclusive! :param start: starting integer for range. :param end: ending integer for range. :return: t...
b87303f00100105268820324f8ad76a4fde4f89a
41,918
def compare(a, b): """Sort an array of persons with comparator. Comparator: - If scores are equal, compare names. - If a.score is higher than b.score, a should appear first. - Vice versa. """ if a.score == b.score: return a.name < b.name return b.score - a.score < 0
5f58377a5d783c88cb214230d2823ce319860652
41,921
def dummy_get_app(*dummy): """ dummy app """ return ["get"]
4d0b7a3a8f2a0eb50e155ff510847147a4afb66b
41,922