content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
def _method_with_pos_reference_2(fake_value, other_value, another_fake_value=2): """ :type other_value: [list, dict, str] """ return other_value.lower()
5aef2727ba62e5c6b323b7dda389ab410c8d878f
653,026
def check_subset(list_one:list, list_two:list): """ You are given two lists of integers list_one and list_two. If list_two is a subset of list_one, return true, otherwise return list of items that are in list_two but NOT in list_one. Note: subset can be empty, if so return False Example 1: Input: list_one = ...
98866ba0166f8aaf7d5283bb832868e6ce4db158
653,027
import re import itertools def get_awesomebar_suggestions(g, query): """ This generates autocomplete suggestions when user query is the string that user types If it is the prefix for a gene, return list of gene names """ regex = re.compile('^' + re.escape(query), re.IGNORECASE) results = (...
806a3745df7b415d3af41b84533682a5442c1a36
653,028
def appear_only_at_sentence_beginning(word, title, sents): """ if the token appears in the text only at the beginning of the sentences >>> title = [u"Feng", u"Chao", u"Liang", u"Blah"] >>> doc = [[u"Feng", u"Chao", u"Liang", u"is", u"in", u"Wuhan", u"."], [u"Chao", u"Liang", u"is", u"not", u"."], [u"Li...
f268c486fbe526d962f6c901429f2601fd58047b
653,029
def match(seq, pattern): """ Returns whether given sequence matches the given pattern """ if not pattern: return not seq # ours elif isinstance(pattern[0], list): if len(pattern) > 1: return match(seq, pattern[0]) and match(seq, pattern[1:]) else: ...
b799510ef798e645278ea664563e3497d9b927f6
653,030
import os import shutil def copyPath(src, dst): """ Make a copy of the given src path to the given destination path. :type src: str :type dst: str :rtype: str """ if os.path.isfile(src): shutil.copy(src, dst) else: shutil.copytree(src, dst) return dst
b150a48802248238e6d7d1f560569965cb7b3824
653,031
def bubble_sort(L): """ Implementation of the bubble sort algorithm Complexity: O(n^2) :param L: List-object :return: Sorted list-object """ swap = False while not swap: swap = True for j in range(1, len(L)): if L[j-1] > L[j]: swap = False ...
069b72a662b626f8dcc27823e1e3ab6d5d7113db
653,032
import json def bad_configuration(): """Load json wrong configuration.""" config_data = {} with open('tests/bad_config.json') as config_file: config_data = json.load(config_file) return config_data
907b7d93b8dc1dc7df4655a60e23443ae45c7e6a
653,033
def ensure_list(i): """If i is a singleton, convert it to a list of length 1""" # Not using isinstance here because an object that inherits from a list # is not considered a list here. That is, I only want to compare on the final-type. if type(i) is list: return i return [i]
d932e98a5a8cadc07246ac428addd407c59e04e5
653,035
import operator def crop_nd_arr(img, bounding): """Crop the central portion of an array so that it matches shape 'bounding'. Parameters ---------- img : array An nd array that needs to be cropped. bounding : tuple Shape tupple smaller than shape of img to crop img to. Returns...
32dd5f6d89145a2961d39ceeb8ef23d8647598a0
653,036
import torch def sanitize_coordinates(_x1, _x2, img_size:int, padding:int=0, cast:bool=True): """ Sanitizes the input coordinates so that x1 < x2, x1 != x2, x1 >= 0, and x2 <= image_size. Also converts from relative to absolute coordinates and casts the results to long tensors. If cast is false, the ...
d79fe47402a29516be87026fe4ef3af8629e3ff7
653,037
import subprocess def lsmod(): """Shows what kernel modules are currently loaded""" return subprocess.check_output(['lsmod'], universal_newlines=True)
5a5d4571c3d6b7d2509ca2d0e1fe0fda941e56f6
653,038
def parse_full_text(status): """Param status (tweepy.models.Status)""" # GET FULL TEXT (THIS SHOULD BE EASIER) # h/t: https://github.com/tweepy/tweepy/issues/974#issuecomment-383846209 # # commenting this out because we're storing the id of the retweeted_status #if hasattr(status, "retweeted_sta...
a7ba9461ed16b7b708b45141975c0b15c97d0f45
653,039
def add(a, b): """ Add two numbers. # Arguments a (int): First number b (int): Second number # Example assert add(2, 3) == 5 Simple as that. Worth checking out: https://en.wikipedia.org/wiki/Addition#Properties """ return a + b
e1c4416f0a41cb92a2ed3db8ecfc1dd661ff2819
653,040
def listify(value): """ Convert an option specified as a string to a list. Allow both comma and space as delimiters. Passes lists transparently. """ if isinstance(value, (list, tuple)): # Already a sequence. Return as a list return list(value) else: # assume `value` is a...
8b8636884ecaddf9f558ca8cb4d80583c01b59bf
653,041
import re def extract_ul(code): """ ectract <ul> tag from code and returns it. """ #'<div class="isgrP focus-visible" data-focus-visible-added=""><ul class="jSC57 _6xe7A"><div class="PZuss"><li class="wo9IH"><div class="uu6c_"><div class="t2ksc"><div class="Jv7Aj pZp3x"><div aria-disabled="true" class="RR-M- ...
8a84528b0f6a32faadaaa69b6db94a9fc95c0059
653,042
def _extend(M, sym): """Extend window by 1 sample if needed for DFT-even symmetry""" if not sym: return M + 1, True else: return M, False
f07638db5f6b4870ccfcd26b3acc286c2d64d269
653,043
def parse_by_line(input_string, prefix_string, offset): """breaks input string by lines and finds the index of the prefix_line. Returns the line that is offset past the prefix_line""" split_by_line = input_string.splitlines() prefix_line = split_by_line.index(prefix_string) return split_by_line[p...
bc3cd05c1ad1088c3d653c81131217a01ac2f8ab
653,044
import os def gather_new_nodes_from_marker_files(new_node_marker_dir_path): """Return the new node names as list as indicated by the new-node marker files. This function simply returns a list of filenames in the new-node marker directory. """ return os.listdir(new_node_marker_dir_path)
8ab3002a2ca77a46cde2e192a0d007dbbbe0a2ee
653,045
def AvailableSearchingAlgorithms(): """Returns a List of available Searching algorithms present in this module""" return ["Binary Search", "Exponential Search", "Fibonacci Search", "Interpolation Search", "Jump Search", "Linear Search"]
e073cec4602b00b6ee2eb745233eddc50e2b38f7
653,046
import re def add_css_class(component, className): """ Update the className property of a Dash component to include a CSS class name. If one or more classes already exist, the provided className will be appended to the list. If the provided className is already present, no change will be made to ...
2ca66ab2a69aa9d5b40fedb94aedc60b0a7e50d5
653,047
import os import logging def _GetUnstrippedPath(path): """If there is a binary located at |path|, returns a path to its unstripped source. Returns None if |path| isn't a binary or doesn't exist in the lib.unstripped or exe.unstripped directories.""" if path.endswith('.so'): maybe_unstripped_path = os....
8c8783fc30daa6dd725a2e6a873b5d27c5517af6
653,048
def log_get_flags(client): """Get log flags Returns: List of log flags """ return client.call('log_get_flags')
fd47c683715832f788e6f6f21097894cb24db301
653,049
def error_500(error): """Return a custom 500 error.""" return 'Sorry, internal server error.'
f45c15482d3c768ed9672a39ad14adac24d2ebfd
653,050
import torch def precision(prediction, labels, class_num): """precision for each classes""" _, predicted = torch.max(prediction, 1) precisions = [] for i in range(class_num): pred = (predicted == i).squeeze() gt = (labels == i).squeeze() tp = torch.sum((pred & gt).squeeze()).item() fp = torch....
b6ae26dbad299d3fdb865ee2985466b419155547
653,051
def get_required(node): """Get xpath-node required information. Args: node: The xpath-node's root. Returns: A bool value. rule: The xpath-node that has a "mandatory" attr or is primary-key,it is required.else not required. """ keys = [] p_stmt = node.parent key_stmt =...
b01c3aa5a6693ba90ec1ff4d14c91c183a2e0dc4
653,052
import re def isValidEmail(email): """ Test if a given string resembles an email address Parameters ---------- email : str Returns ------- result : boolean """ if len(email) > 4: if re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", email) != No...
aceb0dbecef9b94c460c3b08b3b96f7c631a7f15
653,053
def app_delete(s, base_url, app_id): """ Deletes an app """ # delete the app r = s.delete(base_url + "/qrs/app/" + app_id + "?xrfkey=abcdefg123456789") return r.status_code
06bc8821bdd95463c4d0b626f990d47adf2228a1
653,054
import string def get_skipped(url_format: str, body_name: str): """ gets skipped args :param url_format: API URL format string :param body_name: name of body parameter :return: List of skipped args """ parsed_format = string.Formatter().parse(url_format) skipped = [x[1] for x in parse...
14747d315368d271d7944ca5f8d09ffdc02d755e
653,055
import sys def is_celery_task(): """Return true if the code is being executed inside a Celery task, False otherwise""" return True if 'celery worker' in ' '.join(sys.argv).lower() else False
533875051cf08e72e0ea6e550711231f623ce44d
653,056
def get_ta_status_flag(funding_status): """Generate TA status flag for student entry. This flag is from a "teaching preference request" perspective, not a funding perspective. Arguments: funding_status (str): funding entry for current term Returns: (str) : flag ("" for non-TA, "*"...
691c19b6f9b3660715e984998817b29aaff697df
653,057
from datetime import datetime import os def get_non_existing_filename(fname_template="runs/%Y-%m-%d_%H-%M{}.csv"): """Return a string that represent a path to file that does not exists. The filename is the current timestamp.""" suffix_num = 0 while True: fname = datetime.now().strftime( ...
15749101c22bdbe2b07444196f3556fe3e0df029
653,058
import torch def safe_divide(input_tensor: torch.Tensor, other_tensor: torch.Tensor) -> torch.Tensor: """ Divide input_tensor and other_tensor safely, set the output to zero where the divisor b is zero. Parameters ---------- input_tensor : torch.Tensor other_tensor : torch.Tensor Returns...
5abc49218d5df4624215eb8802a8db52291dbbf7
653,059
import math def roundf(value: float, precision: int = 4): """Round value but returned as float, to make display nicer in Hiplot.""" if not math.isfinite(value): return value return round(value * 10 ** precision) / 10**precision
7d6c44b0352ad57e76f736cc57c2740fdfeaaf91
653,060
def decodeBytesToUnicode(value, errors="strict"): """ Accepts an input "value" of generic type. If "value" is a string of type sequence of bytes (i.e. in py2 `str` or `future.types.newbytes.newbytes`, in py3 `bytes`), then it is converted to a sequence of unicode codepoints. This function is u...
32c16b2f7565e75178a58bc99e9a6452f3550466
653,061
def scramble(key): """ Fruitful Function Scramble the global character list using your personal key ("key") as a seed key: input seed Preconditions: key is a possibly empty string containing upper and lowercase letters, and numerals """ #-----------------------------------...
7f24d01c6b785196fa580e80417c79cbc7605bb4
653,062
def handler(value, **kwargs): """Use a value from the environment or fall back to a default if the environment doesn't contain the variable. Format of value: <env_var>::<default value> For example: Groups: ${default app_security_groups::sg-12345,sg-67890} If `app_security_gro...
9056281e86f8415a65f39688a4dbac225ad0a0d1
653,063
def calc_result_myteam_first(score): """ Determines whether the team won, drew or lost based on the score Returns a 'W', 'L', 'D' """ result = ('W' if score[0] > score[1] else ('L' if score[0] < score[1] else 'D')) return result
29717c1f6b143a09bcc220e8ceca6eed04c879c2
653,064
def basicCalculator(s): """ "(1+(4+5+2)-3)+(6+8)" -> 23 """ stack, num, sign, ret = [], 0, 1, 0 for c in s: if c.isdigit(): num = 10*num + int(c) elif c in ['+', '-']: ret += sign*num num = 0 sign = [-1, 1][c == '+'] elif c == '...
3fafa56666bc5138ab75f2c4bb7085fef1c02f5d
653,065
from pathlib import Path def find_case_sensitive_path(path: Path, platform: str) -> Path: """Find the case-sensitive path. On case-insensitive file systems (mostly Windows and Mac), a path like ``text.txt`` and ``TeXt.TxT`` would point to the same file but not on case-sensitive file systems. On ...
1a75c19313062186807c4fb974bd4ae8e78bfd6b
653,066
import requests import json def get_tickers(): """makes POST request to NYSE's API to get all ETF ticker data""" url = 'https://www.nyse.com/api/quotes/filter' headers = { 'Content-Type': 'application/json' } all_tickers = [] page_number = 1 per_page = 3000 while (True): ...
332688a48ae0c14ac40a99d4f8e216524fa1c19d
653,067
from typing import IO from typing import Tuple from typing import List def tyny_check(procar: IO[str]) -> Tuple[int, int, int, List[str], bool]: """Check whether PROCAR file is good. Return numk, nbands, nion, orbital_names and True/False if collienar calculation """ if "PROCAR lm decomposed + p...
dec5174e451f4f98cfc0a77503b56d3b7205e67f
653,068
def findOwner(cursor, tableName): """ Finds the owner of a table. """ cursor.execute("""SELECT OWNER FROM ALL_OBJECTS WHERE object_name = '"""+tableName.upper()+"'") return cursor.fetchone()[0]
6376f4fe459200326581f587ad381762a028dfe3
653,069
def lag(x, y, lag_points=1): """ Example: x, y = lag(x, y, 5) Note: this will reduce the length of the sequence by the number of lag points; in the above case, 5. :param x: numpy array :param y: numpy array :param lag_points: Integer. Number of places to shift by. Defaults ...
fab10acf77caee0fa7e42677cfaa201d25a8d5ce
653,070
import csv def write_tsv(outfile, header, rows, *, _open=open, _get_writer=csv.writer, ): """Write each of the rows to the given TSV (tab-separated) file.""" if isinstance(outfile, str): with _open(outfile, 'w', newline='') as outfile: return write_ts...
f7b0fa63141048cf869d023c21dabcf2a5dedb9a
653,071
def find_redundancy(strings): """Return the length of the longest common proper suffix. Assume there's at least two strings, and all are nonempty, and not all are equal. """ min_len = min(map(len, strings)) redundancy = 0 while redundancy < min_len - 1: chars = map(lambda s: s[-(red...
8b4f043484dce010eb3deeef44663c42e785fd6a
653,072
def best_days(dragon, me): """ >>> d = {'Monday': (1, 6), 'Friday': (3, 5)} >>> m = {'Monday': (2, 4), 'Friday': (3, 6)} >>> best_days(d, m) ['Monday'] >>> d = {'Monday': (1, 6), 'Friday': (3, 5)} >>> m = {'Monday': (0, 4), 'Friday': (3, 6)} >>> best_days(d, m) [] >>> d = {'Mon...
492b4756784a7b9aebe9ca6e89028ef747e9df12
653,073
import requests import json def post(url, params, proxies, headers): """Send a request with the POST method.""" response = requests.post(url, data=json.dumps(params),proxies=proxies, headers=headers) return response
a6d57ee82021154540ea7b8c68329d2f85eaa157
653,074
def jn(pst, start, end): """ for inference :param pst: :param start: :param end: :return: """ return " ".join([str(x) for x in pst[start:end]])
854685c30c3e77e4daaf1ecde99d8d15cbcc3e33
653,075
def resource_filename(lang_code: str, resource_type: str, resource_code: str) -> str: """ Return the formatted resource_filename given lang_code, resource_type, and resource_code. """ return "{}_{}_{}".format(lang_code, resource_type, resource_code)
84b83e1c0a3bd04a2170c9e222ced10c410f6f7b
653,076
def get_epsilon_array(gamma_array): """Flip 0 and 1 for epsilon from gamma""" return list(map(lambda d: '1' if d == '0' else '0', gamma_array))
38cb467764b021f853ccdf4614007f1578e47ae1
653,077
def parse_word_finally(text): """Type converter for "finally " (followed by one/more spaces).""" return text.strip()
6497236e5f5adfb629f4eef9a985443feec6a1c4
653,079
def run_program(program, opcode_pos): """ Runs a supplide Intcode program. >>> run_program([1,0,0,0,99]) [2,0,0,0,99] """ opcode = program[opcode_pos] if opcode == 99: return program operand1 = program[program[opcode_pos + 1]] operand2 = program[program[opcode_pos + 2...
07e6b1542efafaa68021e33b6df749ced442cff5
653,080
def extract_build_cmds(commands, exe_name): """Extracts build command information from `ninja -t commands` output. Args: commands: String containing the output of `ninja -t commands` for the libcxx_test_template. exe_name: The basename of the built executable. Returns: ...
02a31267bca83cf1d2a6430db1b949141be21025
653,081
def get_dependencies(dependency_type): """Returns the function with the name of dependency_type""" return globals()[dependency_type]
d6ffe53c57ddde73b68c2f6a6c0d7cafd83c5290
653,082
import os def is_valid(fname): """Check if it is a valid format for activity files. Parameters ---------- fname : str Path to the file to be read. Returns ------- It returns True if the it is a valid format for activities handling. """ _, ext = os.path.splitext(fname) ...
b53afc8e4a53504d362404834833311c9a20de9e
653,083
def check_request_params(data, params): """ Checks that a JSON request contains the proper parameters. Parameters ---------- data : json The JSON request params: list The parameters that should appear in the JSON request Returns ------- str A message det...
bfbc4aa1bea8f7925b54598ab0f31acbef1c1e87
653,084
import hmac import hashlib def verify_signature(message, key, signature): """ This function will verify the authenticity of a digital signature. For security purposes, Nylas includes a digital signature in the headers of every webhook notification, so that clients can verify that the webhook reque...
20e3735783f24ea4953e5712406b40db9bfc2e87
653,085
def calculate_total_bags(graph): """ Given a graph, return the total bags required """ value = 0 for node in graph: value += int(node["count"]) + int(node["count"]) * calculate_total_bags( node["inside"] ) return value
03cbca239b6867ad5abc3c8312bf9e2163a9b939
653,086
from typing import Dict def sort_dict(dic: Dict[int, str]) -> Dict[int, str]: """Sorts the keys into ascending order, filling in any gaps""" values = list(dic.values()) print(values) dic.clear() for i in range(len(values)): print(i) print(values[i]) dic[i + 1] = values[i] ...
117e1c2082dcea8f3110832c561f9096d982ce50
653,087
def fib_iterativa(number): """Fibonacci iterativa.""" last = 0 curr = 1 for _ in range(0, number): last, curr = curr, curr + last return last
a7b786793585da8f1bcce79327d4306aaf05b134
653,088
def high_density_individuals(pedigree): """Return a list of high density individuals in a pedigree Note: should probably go in Pedigree()""" return [individual for individual in pedigree if individual.is_high_density]
a9421d63903f9e9145b023e9b142d277bb5bfa85
653,089
def min_ge(seq, val): """ Same as min_gt() except items equal to val are accepted as well. >>> min_ge([1, 3, 6, 7], 6) 6 >>> min_ge([2, 3, 4, 8], 8) 8 """ for v in seq: if v >= val: return v return None
f881596755eb730b4d0b4f6fa264ef7d83fdacef
653,090
def fill_in_missing_output_path(output, output_name, tool_inputs): """ Creates a path template for outputs that are missing one This is needed for the descriptor to be valid (path template is required) """ # Look for an input with the same name as the output and use its value key found = False ...
e17979d3b488d68e10fedb74ed564cbc09940628
653,091
def _has_docker_file(repo, project_path): """Checks if project has a Dockerfile.""" return any(content_file.name == 'Dockerfile' for content_file in repo.get_contents(project_path))
adb9eba9ad908811f8f5b04098ec6be44ef824f9
653,092
import subprocess def _run_test(test_spec): """Runs a test.""" p = subprocess.Popen( test_spec.command, cwd=test_spec.directory, stdin=open('/dev/null'), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8') stdout, _ = p.communicate() exit_code = p.wait() r...
16ea3b27f0fa635130b47ee18b24121c73cbb2b3
653,093
from typing import Sequence from typing import Tuple import click def print_table(rows: Sequence) -> None: """Print a formatted table.""" head, *rows = rows col_lengths = list(map(len, head)) for row in rows: col_lengths = list(map(max, zip(col_lengths, map(len, row)))) # type: ignore d...
21c38758f7607bd28204b8fc8dc0a2bbbe2c6eed
653,094
def simHeatpump(T_cold, T_hot=50.0, efficiency=0.45, T_limit=-20.0, COP_limit=7.0): """ Creates a timedepent Coefficient of Performance (COP) based on the potential carnot efficiency and a quality grade/efficiency of the system. Parameters ----------- T_cold: float, np.array or list, required ...
573d061dd01c60812a988bcbe8e8aaf34173ebf3
653,095
def fetch_vest_scores(vest_dict, ref_aa, somatic_aa, codon_pos, default_vest=0.0): """Get VEST scores from pre-computed scores in dictionary. Note: either all mutations should be missense or non-missense intended to have value equal to default. Parameters ...
1bf3b98376ed22ccd58508daf658bc2be5070dee
653,096
import numpy def sup_dist(cdf1, cdf2): """ given two cumulative distribution functions, compute the supremum of the set of absolute distances. note: this function does not check that the ecdfs are ordered or balanced. beware! """ return numpy.max(numpy.absolute(cdf2 - cdf1))
64bb3947d8475b19928710afc6fdf1351fcdbeaf
653,097
def xstr(s): """ Returns the given object as a string or if None then returns the empty string """ return str(s) if s else ""
c1796e421dcafa98a0c6cdaa0ccd4aec63a0b641
653,098
def get_coords(geojson): """.""" if geojson.get('features') is not None: return geojson.get('features')[0].get('geometry').get('coordinates') elif geojson.get('geometry') is not None: return geojson.get('geometry').get('coordinates') else: return geojson.get('coordinates')
e3655966e60947b723292973e2ed9724991a3609
653,099
def httpPut(url, *args, **kwargs): """Performs an HTTP PUT to the given URL. Encodes the given dictionary of parameters using "applications/x-www-form-urlencoded" format. Args: url (str): The URL to send the request to. *args: Variable length argument list. **kwargs: Arbitrary ...
21ea2275f7967662cd4f04c534865b2a48408643
653,100
import re def func1(a): """전부다 numberAGC으로 바꾸고 다시 num1~~""" a = re.sub('[0-9]+/[0-9]+|[0-9]*\.[0-9]+|[0-9]+', 'numberAGC', a) list_ = re.findall('numberAGC', a) for n in range(len(list_)): a = re.sub('numberAGC', f'number{n}', a, 1) # 1번씩만 바꿈 return a
79e69c209923979cbb655eb15a5fac467d6f047d
653,101
import numpy import math def range_from_zscale(input_arr, contrast = 1.0, sig_fract = 3.0, percent_fract = 0.01, max_iter=100, low_cut=True, high_cut=True): """Estimating ranges with the zscale algorithm @type input_arr: numpy array @param input_arr: image data array as sample pixels to derive z-ranges ...
264cbc031f17f3c88129e77680e7fa763f2709f7
653,102
import os def parse_ia_identifier(s): """Split off the last""" return os.path.splitext(s.split('/')[-1])[0]
abd8330a389cd27815c319dcac23af28de5a80e5
653,103
def _autobitmask(val, total_size, index, size, keymap): """ Generate a bitmask and apply it to 'val' bits given the 'total_size', 'index', and 'size' of the BitField """ _bitmask = eval( "0b{}".format("0" * (total_size - (index + size)) + (size * "1") + "0" * index) ) key = (val...
9ba2265b12b0c5de3b59c9dd904465f9fe77ad22
653,104
def ma(df, ma_ranges=[10, 21, 50]): """ Simple Moving Average Parameters ---------- df : pandas.DataFrame, must include columns ['Close'] Dataframe where the ma is extracted from ma_ranges: list, default [10, 21, 50] List of periods of Simple Moving Average to be extracted Retur...
ddd88c75f17e0dcac6a9ce5991ee263ba92c6e83
653,105
def _compute_explicit_padding(kernel_size, dilation_rate): """Compute the necessary padding based on kernel size and dilation rate.""" if isinstance(kernel_size, int): kernel_size = [kernel_size, kernel_size] if isinstance(dilation_rate, int): dilation_rate = [dilation_rate, dilation_rate] kernel_size_e...
052a7fd5a9e86ed823bae3012f3c49f662ec2459
653,106
import argparse def parse_args(): """Parses the commandline arguments with argparse""" parser = argparse.ArgumentParser(description='Parse flags to configure the json parsing') parser.add_argument("-ftr", "--featurestrain", help="path to input train features", default="./data/clean...
ce2dcfd84adba6b344d57f758d561fd70d0624bf
653,107
def elchgeraeusch(wiederholungen): """Gibt einen String mit einer bestimmten Anzahl an Mööös aus.""" elchausspuch = "" for i in range(wiederholungen): # das wird einfach wiederholungen-mal ausgeführt elchausspuch += "Mööö " # a += b bedeutet a = a + b return elchausspuch
f28861e3ff143f108dd5debd7e8635c6551eed2e
653,109
import os from pathlib import Path import tarfile def junk_tar(tmp_path): """Extract a tar file""" # set CWD os.chdir(tmp_path) filename = Path("junktar.tar.gz") tar = tarfile.open(filename, "w:gz") # add some fake files a = tmp_path / "a" a.touch() tar.add("a") b = tmp_path ...
937b1bc61bb2270292939fafc2236b23899fad0a
653,110
def get_server(oneandone_conn, instance, full_object=False): """ Validates that the server exists whether by ID or name. Returns the server if one was found. """ for server in oneandone_conn.list_servers(per_page=1000): if instance in (server['id'], server['name']): if full_objec...
ea84b68ba4ecaf1c458b5ee85e8836367b988e20
653,111
def select_rows(match_value, col_index, all_rows, header=True): """Select only rows where the value in the search column matches This allows the caller to process requests from one user or project at a time if needed, for example when processing individual helpdesk tickets. inputs: match_value...
c320a184f965f13ae361c198b8c4098e530cc25c
653,112
def _project_im_rois(im_rois, im_scale_factor): """Project image RoIs into the rescaled training image.""" rois = im_rois * im_scale_factor return rois
174e4c4bd9f45c5d888ed97173e9ab61d334aa9a
653,113
def is_no_cache_key_option(number): """Return ``True`` iff the option number identifies a NoCacheKey option. A :coapsect:`NoCacheKey option<5.4.2>` is one for which the value of the option does not contribute to the key that identifies a matching value in a cache. This is encoded in bits 1 through 5 o...
aad8173794ae13fe885316f8048d66e547addc7b
653,114
import requests def recurent_request(quiry, max_depth = 1): """ recurently repeats request in case of fail """ try: data = requests.get(quiry).content except: max_depth -= 1 if max_depth <= 0: print("request fail!!!") return None e...
4aaef2677049bef8fc684a4d13598287a7cd95d8
653,115
import subprocess def get_git_branch(): """Function that executes Git to determine the current branch""" git_command = ['git', 'rev-parse', '--abbrev-ref', 'HEAD'] return subprocess.check_output(git_command).rstrip()
b7e032c6b742b31986c9dc5ed84f680bcdf78965
653,117
def delete_export(module, export): """ Delete file system""" if not module.check_mode: export.delete() changed = True return changed
707b2b77dd5453d59bbbc9dae1d9123febca529b
653,118
import os def get_file_list(path): """Get the list of files in a specifc path""" files_list = [f for f in os.listdir(path) if ( os.path.isfile(os.path.join(path, f)) and f != '.DS_Store')] return files_list
1406b897bf39fbc2e1cb2ae8cf87876e8e085deb
653,120
def _ecmaCodeTableCoordinate(column, row): """ Return the byte in 7- or 8-bit code table identified by C{column} and C{row}. "An 8-bit code table consists of 256 positions arranged in 16 columns and 16 rows. The columns and rows are numbered 00 to 15." "A 7-bit code table consists of 128 posi...
ec010294b2cfcd1d5eb7fb317d98688c050170e4
653,121
from typing import Callable def higher_order(fn: Callable[[int], int]) -> int: """ Crosshair can find models for pure callables over atomic types. post: _ != 42 # False (when given something like lambda a: 42 if (a == 0) else 0) """ return fn(fn(100))
5dc287cc37390708d96789b16afc4b97c697a950
653,122
import torch def total_variation(x, signed_image=False): """Anisotropic TV.""" if signed_image: x = torch.abs(x) dx = torch.mean(torch.abs(x[:, :, :, :-1] - x[:, :, :, 1:])) dy = torch.mean(torch.abs(x[:, :, :-1, :] - x[:, :, 1:, :])) return dx + dy
2087c1659bc9e2f52a8bb77b36bc98d4b34f630b
653,123
def revsplit(rev): """Parse a revision string and return (uuid, path, revnum). >>> revsplit('svn:a2147622-4a9f-4db4-a8d3-13562ff547b2' ... '/proj%20B/mytrunk/mytrunk@1') ('a2147622-4a9f-4db4-a8d3-13562ff547b2', '/proj%20B/mytrunk/mytrunk', 1) >>> revsplit('svn:8af66a51-67f5-4354-b62c-98d67c...
a2109e378ee952a8e83ad3e94eb188e39f3217e6
653,125
import random def vyber_slova(): """ Vrati nahodne vybrane slovo z daneho souboru. """ soubor = open('dictionary.txt') soubor1 = soubor.read() roz_soubor = soubor1.split('\n') slovo = random.choice(roz_soubor) slovo = slovo.lower() return slovo
d680aec5c2ce356f453a3487eece2c67c0efed82
653,126
def get_pix_ratio_from_WCS(input,output): """ [Functional form of .get_pix_ratio() method of WCSMap]""" return output.pscale/input.pscale
f09fc0f52a21934e1ef47205463b459964c53764
653,127
import torch def to_sparse(tensor): """Given a one-hot encoding vector returns a list of the indexes with nonzero values""" return torch.nonzero(tensor)
52d336c060c23a139051997d97755da7babcc79f
653,128
def generate_outputs(cluster_name, cluster_dict, config): """Add the outputs to the Terraform cluster dict. Args: cluster_name (str): The name of the currently generating cluster cluster_dict (defaultdict): The dict containing all Terraform config for a given...
cb4d86b0ed081e6dc8d15952856e6ca89ee311bd
653,130
def toggle_graphs(n_clicks, value): """ show graphs after first submission """ if n_clicks: return {'display': 'block'} else: return {'display': 'none'}
6ab4b7655f8bb8250d9595697283ed3ce2ff2038
653,131
def toggle_collapse(n, is_open): """ Simple callback that will toggle the collapse :param n: The initial state of n_clicks :param is_open: The initial state of is_open :return: The result state of is_open after it is toggled """ if n: return not is_open return is_open
136bf07ec05a9fc01125f7603399dba4d1d3cdb6
653,132