content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
import torch def make_coordinate_grid(spatial_size, type): """ Create a meshgrid [-1,1] x [-1,1] of given spatial_size. """ h, w = spatial_size x = torch.arange(w).type(type) y = torch.arange(h).type(type) x = (2 * (x / (w - 1)) - 1) y = (2 * (y / (h - 1)) - 1) yy = y.view(-1, 1)...
0bbbd2f0e0d588b58feebce19b3f2fd9c84934d8
708,797
def add_wrong_column(data_frame): """ Adds wrong column to dataframe :params dataframe data_frame: :returns dataframe: """ new_df = data_frame.copy() new_df['Ducks'] = 0 return new_df
0f3ae838c0975e8021cfeee258576afac75072c5
708,798
def drop_duplicates(df): """Drop duplicate rows and reindex. Args: df (pd.DataFrame): Dataframe. Returns: pd.DataFrame: Dataframe with the replaced value. Examples: >>> df = pd.DataFrame({'letters':['b','b','c'], 'numbers':[2,2,3]}) >>> drop_duplicates(df) ...
517d9faf09267df72def3fa7b90b0f59d819d660
708,800
import unicodedata def is_number(input_string): """ if input_string includes number only, return corresponding number, otherwise return input_string """ try: return float(input_string) except ValueError: pass try: return unicodedata.numeric(input_string) except...
2b435b1f23c8764e0ff6bf741678db91bb4a5b23
708,801
import requests import json def get_lang_list(source_text, key=None, print_meta_data=False): """ Inputs: source_text - source text as a string key - google api key, needed or function will raise and error returns list of language identifiers """ #set up url request to google translate api...
720c3c9252535e82881411fa345734d984350537
708,802
import uuid def token(): """ Return a unique 32-char write-token """ return str(uuid.uuid4().hex)
f7dc5725cc1d11ee0ab9471d141a89178fa3d07c
708,803
import functools def decorate_func_with_plugin_arg(f): """Decorate a function that takes a plugin as an argument. A "plugin" is a pair of simulation and postprocess plugins. The decorator expands this pair. """ @functools.wraps(f) def wrapper(self, plugins_tuple): return f(self, plugi...
e90c86bfd6c3cada33c867d26ed64da3cac6f9c4
708,804
def compute_acc_bin(conf_thresh_lower, conf_thresh_upper, conf, pred, true): """ # Computes accuracy and average confidence for bin Args: conf_thresh_lower (float): Lower Threshold of confidence interval conf_thresh_upper (float): Upper Threshold of confidence interval conf (numpy.n...
eb338800751de635e6b72213254287554cd34dc0
708,805
def _is_valid_requirement(requirement: str) -> bool: """Returns True is the `requirement.txt` line is valid.""" is_invalid = ( not requirement or # Empty line requirement.startswith('#') or # Comment requirement.startswith('-r ') # Filter the `-r requirement.txt` ) return not is_invalid
73b8ad139329698ad334b230cb04976db4ec05ba
708,806
from typing import Union from typing import Sequence def wrap_singleton_string(item: Union[Sequence, str]): """ Wrap a single string as a list. """ if isinstance(item, str): # Can't check if iterable, because a string is an iterable of # characters, which is not what we want. return [i...
6e0946fee8fddd23631ff66d405dce2ae8a15fa6
708,807
def print_settings(settings): """ This function returns the harmonic approximation settings . Returns ------- text: str Pretty-printed settings for the current Quantas run. """ text = '\nCalculator: Equation of state (EoS) fitting\n' text += '\nMeasurement units\n' text +...
4e64353e0c519a26ac210de1df39ce09fbf54045
708,808
def remove_multi_whitespace(string_or_list): """ Cleans redundant whitespace from extracted data """ if type(string_or_list) == str: return ' '.join(string_or_list.split()) return [' '.join(string.split()) for string in string_or_list]
a284eb1ea685fb55afeefe78d863a716475a9182
708,809
import json def writeJSONFile(filename,JSONDocument): """ Writes a JSON document to a named file Parameters ---------- filename : str name of the file JSONDocument : str JSON document to write to the file Returns ------- True """ filename='data/'+filename ...
4f20b42a5f38554589a7bb03039ba348e3b0bb15
708,810
def get_monotask_from_macrotask(monotask_type, macrotask): """ Returns a Monotask of the specified type from the provided Macrotask. """ return next((monotask for monotask in macrotask.monotasks if isinstance(monotask, monotask_type)))
46d4516327c89755eaa3ba6f6fa3503aae0c5bd9
708,811
import os def getREADMEforDescription(readmePath=os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md')): """Use the Markdown from the file for the package's long_description. long_description_content_type should be 'text/markdown' in this case. This is why we need the README to be in the MANIFES...
2b0eff2cb2a7fe5d94a512c6f62b4ad8bf48b290
708,812
from typing import List from typing import Tuple def choose_page(btn_click_list: List[Tuple[int, str]]) -> str: """ Given a list of tuples of (num_clicks, next_page) choose the next_page that corresponds to exactly 1 num_clicks. This is to help with deciding which page to go to next when clicking on ...
e61bc1e52c6531cf71bc54faea0d03976eb137ad
708,813
def reconstruct_entity(input_examples, entitys_iter): """ the entitys_iter contains the prediction entity of the splited examples. We need to reconstruct the complete entitys for each example in input_examples. and return the results as dictionary. input_examples: each should contains (start, end) indic...
520acff8bfd0616a045ca1286c51d75ea9465f0e
708,814
def realord(s, pos=0): """ Returns the unicode of a character in a unicode string, taking surrogate pairs into account """ if s is None: return None code = ord(s[pos]) if code >= 0xD800 and code < 0xDC00: if len(s) <= pos + 1: print("realord warning: missing surro...
6683725d24a984ecf4feb2198e29a3b68c7f1d5b
708,815
def specific_kinetic_energy(particles): """ Returns the specific kinetic energy of each particle in the set. >>> from amuse.datamodel import Particles >>> particles = Particles(2) >>> particles.vx = [1.0, 1.0] | units.ms >>> particles.vy = [0.0, 0.0] | units.ms >>> particles.vz = [0.0, 0.0]...
89a126c23b291a526401a00f812b40a5283319f4
708,816
def parse_loot_percentage(text): """Use to parse loot percentage string, ie: Roubo: 50% becomes 0.5""" percentage = float(text.split(':')[1].strip("%")) / 100 return percentage
97dc4f20f02ef0e5d3e592d3084dce80549777ce
708,817
def major_minor_change(old_version, new_version): """Check if a major or minor change occurred.""" major_mismatch = old_version.major != new_version.major minor_mismatch = old_version.minor != new_version.minor if major_mismatch or minor_mismatch: return True return False
effa9f55c82a9edcacd79e07716527f314e41f39
708,818
def org_unit_type_filter(queryset, passed_in_org_types): """Get specific Organisational units based on a filter.""" for passed_in_org_type in passed_in_org_types: queryset = queryset.filter(org_unit_type_id=passed_in_org_type) return queryset
0495cabe121f8d6fdb584538f13764bd81d978c5
708,819
def jsonify(records): """ Parse asyncpg record response into JSON format """ return [dict(r.items()) for r in records]
618cb538331c4eb637aa03f0ba857da3f2fa4c1c
708,822
def parse_vad_label(line, frame_size: float = 0.032, frame_shift: float = 0.008): """Parse VAD information in each line, and convert it to frame-wise VAD label. Args: line (str): e.g. "0.2,3.11 3.48,10.51 10.52,11.02" frame_size (float): frame size (in seconds) that is used when ...
658a2a00b8b0b2cfdb83b649d2f87fcf23cbb6b4
708,823
import ntpath def path_leaf(path): """ Extracts file name from given path :param str path: Path be extracted the file name from :return str: File name """ head, tail = ntpath.split(path) return tail or ntpath.basename(head)
98ef27b218fdb5003ac988c42aff163d1067021f
708,824
def next_permutation(a): """Generate the lexicographically next permutation inplace. https://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order Return false if there is no next permutation. """ # Find the largest index i such that a[i] < a[i + 1]. If no such # index exists, the...
b6246d53b5e0ac0e28aa5afda03d7756657a40bf
708,825
from numpy.linalg import norm def normalize(v): """ Calculate normalized vector :param v: input vector :return: normalized vector """ return v/norm(v)
0ade14b6136e5f55410f6d4cc3fb5b466fa60566
708,826
import re def replace_hyphen_by_romaji(text): """ 長音「ー」などを仮名に置換する。 """ # error check if len(text) < 2: return "" while "-" in list(text) or "~" in list(text): text_ = text if (text[0] == "-" or text[0] == "~") and len(text) >= 2: text = text[2:] ...
9e2d7216bbd751f49ed54519f5eaf8d516ae8025
708,827
def _function_set_name(f): """ return the name of a function (not the module) @param f function @return name .. versionadded:: 1.1 """ name = f.__name__ return name.split(".")[-1]
e1b73fbc520c7d9745872b0cd19766d42c027d15
708,828
def add(*args): """Adding list of values""" return sum(args)
9bc68771c10b537f0727e76cc07297e7d0311a5d
708,829
import itertools import shlex def combine_arg_list_opts(opt_args): """Helper for processing arguments like impalad_args. The input is a list of strings, each of which is the string passed into one instance of the argument, e.g. for --impalad_args="-foo -bar" --impalad_args="-baz", the input to this function is ...
77cfc6fa54201083c2cb058b8a9493b7d020273e
708,830
def path_to_filename(username, path_to_file): """ Converts a path formated as path/to/file.txt to a filename, ie. path_to_file.txt """ filename = '{}_{}'.format(username, path_to_file) filename = filename.replace('/','_') print(filename) return filename
a29e98db8ac4cd7f39e0f0e7fc1f76e72f5fa398
708,831
from typing import List def _convert_artist_format(artists: List[str]) -> str: """Returns converted artist format""" formatted = "" for x in artists: formatted += x + ", " return formatted[:-2]
66f8afb0eb09e9a66eaa728c28576bb0e5a496d3
708,832
def parse_hostportstr(hostportstr): """ Parse hostportstr like 'xxx.xxx.xxx.xxx:xxx' """ host = hostportstr.split(':')[0] port = int(hostportstr.split(':')[1]) return host, port
7d67b548728d8cc159a7baa3e5f419bf7cbbc4d3
708,833
def fastaDecodeHeader(fastaHeader): """Decodes the fasta header """ return fastaHeader.split("|")
06f0af70765670dafa0b558867e2d9094c3d928b
708,834
def tau_for_x(x, beta): """Rescales tau axis to x -1 ... 1""" if x.min() < -1 or x.max() > 1: raise ValueError("domain of x") return .5 * beta * (x + 1)
1d7b868dfadb65e6f98654276763fd4bff2c20ff
708,835
import subprocess def is_word_file(file): """ Check to see if the given file is a Word file. @param file (str) The path of the file to check. @return (bool) True if the file is a Word file, False if not. """ typ = subprocess.check_output(["file", file]) return ((b"Microsoft Office Word" ...
cb297e9cf8ed709e9802f1d3d48bc7d1271eac26
708,836
def minmax(data): """Solution to exercise R-1.3. Takes a sequence of one or more numbers, and returns the smallest and largest numbers, in the form of a tuple of length two. Do not use the built-in functions min or max in implementing the solution. """ min_idx = 0 max_idx = 0 for idx, n...
9715bef69c120f6d1afb933bd9030240f556eb20
708,838
import os def file_mtime_ns(file): """Get the ``os.stat(file).st_mtime_ns`` value.""" return os.stat(file).st_mtime_ns
20b384549dae19e35d02b85b20dd62271352f08d
708,839
def check_all_particles_present(partlist, gambit_pdg_codes): """ Checks all particles exist in the particle_database.yaml. """ absent = [] for i in range(len(partlist)): if not partlist[i].pdg() in list(gambit_pdg_codes.values()): absent.append(partlist[i]) absent_...
eab49388d472934a61900d8e972c0f2ef01ae1fb
708,840
def translation_from_matrix(M): """Returns the 3 values of translation from the matrix M. Parameters ---------- M : list[list[float]] A 4-by-4 transformation matrix. Returns ------- [float, float, float] The translation vector. """ return [M[0][3], M[1][3], M[2][3]...
2b3bddd08772b2480a923a778d962f8e94f4b78a
708,841
def saving_filename_boundary(save_location, close_up, beafort, wave_roughness): """ Setting the filename of the figure """ if close_up is None: return save_location + 'Boundary_comparison_Bft={}_roughness={}.png'.format(beafort, wave_roughness) else: ymax, ymin = close_up return save...
c0357a211adc95c35873a0f3b0c900f6b5fe42d0
708,842
def childs_page_return_right_login(response_page, smarsy_login): """ Receive HTML page from login function and check we've got expected source """ if smarsy_login in response_page: return True else: raise ValueError('Invalid Smarsy Login')
e7cb9b8d9df8bd5345f308e78cec28a20919370e
708,843
import json import sys def _load_json(json_path): """Load JSON from a file with a given path.""" # Note: Binary so load can detect encoding (as in Section 3 of RFC 4627) with open(json_path, 'rb') as json_file: try: return json.load(json_file) except Exception as ex: ...
86a6ab7c509c24a50c248134e01a7d61d1499adb
708,844
def sigma_bot(sigma_lc_bot, sigma_hc_bot, x_aver_bot_mass): """ Calculates the surface tension at the bottom of column. Parameters ---------- sigma_lc_bot : float The surface tension of low-boilling component at the bottom of column, [N / m] sigma_hc_bot : float The surface tensi...
5105e5592556cab14cb62ab61b4f242499b33e1d
708,845
def _collect_package_prefixes(package_dir, packages): """ Collect the list of prefixes for all packages The list is used to match paths in the install manifest to packages specified in the setup.py script. The list is sorted in decreasing order of prefix length so that paths are matched with t...
6c497725e8a441f93f55084ef42489f97e35acf8
708,846
def vec_sum(a, b): """Compute the sum of two vector given in lists.""" return [va + vb for va, vb in zip(a, b)]
d85f55e22a60af66a85eb6c8cd180007351bf5d9
708,848
import numpy as np def bolling(asset:list, samples:int=20, alpha:float=0, width:float=2): """ According to MATLAB: BOLLING(ASSET,SAMPLES,ALPHA,WIDTH) plots Bollinger bands for given ASSET data vector. SAMPLES specifies the number of samples to use in computing the moving average. ALPHA is an op...
90c06bb45f30713a05cde865e23c0f9e317b0887
708,849
def pairwise_comparison(column1,var1,column2,var2): """ Arg: column1 --> column name 1 in df column2 --> column name 2 in df var1---> 3 cases: abbreviation in column 1 (seeking better model) abbreviation in column 1 (seeking lesser value in column1 in co...
a67ef991dcad4816e9b15c1f352079ce14d7d823
708,850
def dequote(str): """Will remove single or double quotes from the start and end of a string and return the result.""" quotechars = "'\"" while len(str) and str[0] in quotechars: str = str[1:] while len(str) and str[-1] in quotechars: str = str[0:-1] return str
e6377f9992ef8119726b788c02af9df32c722c28
708,851
import numpy def uccsd_singlet_paramsize(n_qubits, n_electrons): """Determine number of independent amplitudes for singlet UCCSD Args: n_qubits(int): Number of qubits/spin-orbitals in the system n_electrons(int): Number of electrons in the reference state Returns: Number of indep...
408c9158c76fba5d118cc6603e08260db30cc3df
708,852
def setup_i2c_sensor(sensor_class, sensor_name, i2c_bus, errors): """ Initialise one of the I2C connected sensors, returning None on error.""" if i2c_bus is None: # This sensor uses the multipler and there was an error initialising that. return None try: sensor = sensor_class(i2c_bus...
62633c09f6e78b43fca625df8fbd0d20d866735b
708,853
def argparse_textwrap_unwrap_first_paragraph(doc): """Join by single spaces all the leading lines up to the first empty line""" index = (doc + "\n\n").index("\n\n") lines = doc[:index].splitlines() chars = " ".join(_.strip() for _ in lines) alt_doc = chars + doc[index:] return alt_doc
f7068c4b463c63d100980b743f8ed2d69b149a97
708,854
import argparse def is_positive_integer(value: str) -> int: """ Helper function for argparse. Raise an exception if value is not a positive integer. """ int_value = int(value) if int_value <= 0: raise argparse.ArgumentTypeError("{} is not a positive integer".format(value)) return int_value
4f5e2fd4e95e92b69bb8073daafbf8989037657b
708,855
from typing import List from typing import Tuple def merge_overlapped_spans(spans: List[Tuple[int, int]]) -> List[Tuple[int, int]]: """ Merge overlapped spans Parameters ---------- spans: input list of spans Returns ------- merged spans """ span_sets = list() for span in...
0ea7f2a730274f7a98f25b8df22754ec79e8fce7
708,856
def _ww3_ounp_contents(run_date, run_type): """ :param str run_type: :param run_date: :py:class:`arrow.Arrow` :return: ww3_ounp.inp file contents :rtype: str """ start_date = ( run_date.format("YYYYMMDD") if run_type == "nowcast" else run_date.shift(days=+1).format("...
fda73d25c39c5bd46d791e6745fa72a0285edcdc
708,857
def _get_value(key, entry): """ :param key: :param entry: :return: """ if key in entry: if entry[key] and str(entry[key]).lower() == "true": return True elif entry[key] and str(entry[key]).lower() == "false": return False return entry[key] ret...
93820395e91323939c8fbee653b6eabb6fbfd8eb
708,858
import subprocess def run_command(cmd): """Run command, return output as string.""" output = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).communicate()[0] return output.decode("ascii")
0996d76ab1980c2fad262f8fd227ac50772849d2
708,859
import re import uuid def get_mac(): """This function returns the first MAC address of the NIC of the PC without colon""" return ':'.join(re.findall('..', '%012x' % uuid.getnode())).replace(':', '')
95ebb381c71741e26b6713638a7770e452d009f2
708,861
def get_feature_names_small(ionnumber): """ feature names for the fixed peptide length feature vectors """ names = [] names += ["pmz", "peplen"] for c in ["bas", "heli", "hydro", "pI"]: names.append("sum_" + c) for c in ["mz", "bas", "heli", "hydro", "pI"]: names.append("mean_" + c) names.append("mz_ion"...
fbffe98af0cffb05a6b11e06786c5a7076449146
708,862
def vectorproduct(a,b): """ Return vector cross product of input vectors a and b """ a1, a2, a3 = a b1, b2, b3 = b return [a2*b3 - a3*b2, a3*b1 - a1*b3, a1*b2 - a2*b1]
adb9e7c4b5150ab6231f2b852d6860cd0e5060a0
708,863
def int_to_ip(ip): """ Convert a 32-bit integer into IPv4 string format :param ip: 32-bit integer :return: IPv4 string equivalent to ip """ if type(ip) is str: return ip return '.'.join([str((ip >> i) & 0xff) for i in [24, 16, 8, 0]])
8ceb8b9912f10ba49b45510f4470b9cc34bf7a2f
708,864
import sys def getExecutable(): """ Returns the executable this session is running from. :rtype: str """ return sys.executable
87d842239f898554582900d879501b2a3457df8e
708,865
import os def get_file_with_suffix(d, suffix): """ Generate a list of all files present below a given directory. """ items = os.listdir(d) for file in items: if file.endswith(suffix): return file.split(suffix)[0] return None
1191868a4fd9b925f6f8ce713aba16d9b66f1a9a
708,866
def PolyMod(f, g): """ return f (mod g) """ return f % g
53b47e993e35c09e59e209b68a8a7656edf6b4ce
708,867
def both_block_num_missing(record): """ Returns true of both block numbers are missing :param record: dict - The record being evaluated :return: bool """ rpt_block_num = record.get("rpt_block_num", "") or "" rpt_sec_block_num = record.get("rpt_sec_block_num", "") or "" # True, if neithe...
63e2fdaef78dbc3c6560a4b015ed022583f30d05
708,868
def encode_mode(mode): """ JJ2 uses numbers instead of strings, but strings are easier for humans to work with CANNOT use spaces here, as list server scripts may not expect spaces in modes in port 10057 response :param mode: Mode number as sent by the client :return: Mode string """ if...
db83c419acb299284b7b5338331efc95051115a5
708,870
def get_domains_by_name(kw, c, adgroup=False): """Searches for domains by a text fragment that matches the domain name (not the tld)""" domains = [] existing = set() if adgroup: existing = set(c['adgroups'].find_one({'name': adgroup}, {'sites':1})['sites']) for domain in c['domains'].find({}, {'domain': 1, '...
6ecaf4ccf1ecac806fb621c02282bf46929459ce
708,872
def live_ferc_db(request): """Use the live FERC DB or make a temporary one.""" return request.config.getoption("--live_ferc_db")
f0540c8e3383572c5f686ea89011d9e1ab0bf208
708,873
import urllib.request, urllib.parse, urllib.error from bs4 import BeautifulSoup import ssl def extract_url_dataset(dataset,msg_flag=False): """ Given a dataset identifier this function extracts the URL for the page where the actual raw data resides. """ # Ignore SSL certificate errors ctx = s...
06ec2dd6bea4c264fe9590663a28c7c92eed6a49
708,874
import json def format_parameters(parameters: str) -> str: """ Receives a key:value string and retuns a dictionary string ({"key":"value"}). In the process strips trailing and leading spaces. :param parameters: The key-value-list :return: """ if not parameters: return '{}' pair...
95f115b9000d495db776798700cfdf35209cfbd4
708,875
def Format_Phone(Phone): """Function to Format a Phone Number into (999)-999 9999)""" Phone = str(Phone) return f"({Phone[0:3]}) {Phone[3:6]}-{Phone[6:10]}"
8e46c35bca9d302d86909457c84785ad5d366c15
708,876
def register_and_login_test_user(c): """ Helper function that makes an HTTP request to register a test user Parameters ---------- c : object Test client object Returns ------- str Access JWT in order to use in subsequent tests """ c.post( "/api/auth/regi...
b76f7f6afa9af453246ae304b1b0504bd68b8919
708,877
def basic_pyxll_function_22(x, y, z): """if z return x, else return y""" if z: # we're returning an integer, but the signature # says we're returning a float. # PyXLL will convert the integer to a float for us. return x return y
851b5eef683b0456a0f5bce7f3850698693b067e
708,878
def get_data_file_args(args, language): """ For a interface, return the language-specific set of data file arguments Args: args (dict): Dictionary of data file arguments for an interface language (str): Language of the testbench Returns: dict: Language-specific data file argume...
11e30b92316bad9a46b87bd9188f97d5e8860377
708,879
import re def check_string_capitalised(string): """ Check to see if a string is in all CAPITAL letters. Boolean. """ return bool(re.match('^[A-Z_]+$', string))
f496d79fafae4c89c3686856b42113c4818f7ed8
708,880
import textwrap def ped_file_parent_missing(fake_fs): """Return fake file system with PED file""" content = textwrap.dedent( """ # comment FAM II-1\tI-1\t0\t1\t2 FAM I-1 0\t0\t1\t1 """ ).strip() fake_fs.fs.create_file("/test.ped", create_missing_dirs=True, contents=conten...
9df19ab925984236aa581c9b8843591f05d3b7b4
708,881
import random import requests def GettingAyah(): """The code used to get an Ayah from the Quran every fixed time""" while True: ayah = random.randint(1, 6237) url = f'http://api.alquran.cloud/v1/ayah/{ayah}' res = requests.get(url) if len(res.json()['data']['text']) <= 280: ...
5739cbd3554b97f01eefef7f59a4087e5497e3e7
708,882
import itertools import six def partition(predicate, iterable): """Use `predicate` to partition entries into falsy and truthy ones. Recipe taken from the official documentation. https://docs.python.org/3/library/itertools.html#itertools-recipes """ t1, t2 = itertools.tee(iterable) return ( ...
5777203d9d34a9ffddc565129d8dda3ec91efc8e
708,883
def check_struc(d1, d2, errors=[], level='wf'): """Recursively check struct of dictionary 2 to that of dict 1 Arguments --------- d1 : dict Dictionary with desired structure d2 : dict Dictionary with structre to check errors : list of str, optional Missin...
aa835e7bbd6274e73d0b3d45d1ec4d617af0a167
708,884
import argparse from datetime import datetime from typing import OrderedDict def get_args_string(args: argparse.Namespace) -> str: """ Creates a string summarising the argparse arguments. :param args: parser.parse_args() :return: String of the arguments of the argparse namespace. """ string =...
f1f4de0821d04a21df046bc0dc526b2f9f1135f6
708,885
def inverseTranslateTaps(lowerTaps, pos): """Method to translate tap integer in range [-lower_taps, raise_taps] to range [0, lowerTaps + raiseTaps] """ # Hmmm... is it this simle? posOut = pos + lowerTaps return posOut
827bdfc51b3581b7b893ff8ff02dd5846ff6cd0f
708,886
def GMLstring2points(pointstring): """Convert list of points in string to a list of points. Works for 3D points.""" listPoints = [] #-- List of coordinates coords = pointstring.split() #-- Store the coordinate tuple assert(len(coords) % 3 == 0) for i in range(0, len(coords), 3): list...
e755d344d163bdcdb114d0c9d614a1bbd40be29f
708,887
def ToOrdinal(value): """ Convert a numerical value into an ordinal number. @param value: the number to be converted """ if value % 100//10 != 1: if value % 10 == 1: ordval = '{}st'.format(value) elif value % 10 == 2: ordval = '{}nd'.format(value) elif...
774bac5fd22714ba3eb4c9dd2b16f4236e2f5e8c
708,888
def recall_at(target, scores, k): """Calculation for recall at k.""" if target in scores[:k]: return 1.0 else: return 0.0
0c3f70be3fb4cfde16d5e39b256e565f180d1655
708,889
import math def dcg(r, k=None): """The Burges et al. (2005) version of DCG. This is what everyone uses (except trec_eval) :param r: results :param k: cut-off :return: sum (2^ y_i - 1) / log (i +2) """ result = sum([(pow(2, rel) - 1) / math.log(rank + 2, 2) for rank, rel in enumerate(r[:k]...
d93c500ba55411807570c8efebdeaa49ce7fe288
708,890
async def detect_objects(computervision_client, image_url): """Detect objects from a remote image""" detect_objects_results_local = \ computervision_client.detect_objects(image_url) return detect_objects_results_local.objects
9adb2a3b2c08f99187159ad6a22047bbf3d4c30a
708,891
def fcard(card): """Create format string for card display""" return f"{card[0]} {card[1]}"
ca3866011b418bf35e1b076afd7134926a9382f9
708,892
def resetChapterProgress(chapterProgressDict, chapter, initRepeatLevel): """This method resets chapter progress and sets initial level for repeat routine. Args: chapterProgressDict (dict): Chapter progress data. chapter (int): Number of the chapter. initRepeatLevel (int): Initial level ...
e02d6e97f556a2c080c2bc273255aacedf7bb086
708,893
def on_coordinator(f): """A decorator that, when applied to a function, makes a spawn of that function happen on the coordinator.""" f.on_coordinator = True return f
d9c97c47255d165c67a4eb67a18cc85c3c9b9386
708,894
def format_gro_coord(resid, resname, aname, seqno, xyz): """ Print a line in accordance with .gro file format, with six decimal points of precision Nine decimal points of precision are necessary to get forces below 1e-3 kJ/mol/nm. @param[in] resid The number of the residue that the atom belongs to @pa...
ceeeeeafe4f7484fa17ee4ebd79363209c8f7391
708,895
def fix_legacy_database_uri(uri): """ Fixes legacy Database uris, like postgres:// which is provided by Heroku but no longer supported by SqlAlchemy """ if uri.startswith('postgres://'): uri = uri.replace('postgres://', 'postgresql://', 1) return uri
aa3aa20110b7575abf77534d08a35dccb04b731d
708,896
def get_url_names(): """ Получение ссылок на контент Returns: Здесь - список файлов формата *.str """ files = ['srts/Iron Man02x26.srt', 'srts/Iron1and8.srt'] return files
4ee8fdd5ab9efc04eda4bfe1205e073064030520
708,897
from datetime import datetime def unix_utc_now() -> int: """ Return the number of seconds passed from January 1, 1970 UTC. """ delta = datetime.utcnow() - datetime(1970, 1, 1) return int(delta.total_seconds())
b9768b60cf6f49a7cccedd88482d7a2b21cf05a2
708,898
import torch def tensor_from_var_2d_list(target, padding=0.0, max_len=None, requires_grad=True): """Convert a variable 2 level nested list to a tensor. e.g. target = [[1, 2, 3], [4, 5, 6, 7, 8]] """ max_len_calc = max([len(batch) for batch in target]) if max_len == None: max_len = max_len_...
2aa5fcc5b2be683c64026126da55330937cd8242
708,899
def invert_dict(d): """ Invert dictionary by switching keys and values. Parameters ---------- d : dict python dictionary Returns ------- dict Inverted python dictionary """ return dict((v, k) for k, v in d.items())
c70bfdb5ffa96cf07b1a4627aa484e3d5d0f4fea
708,900
def segregate(str): """3.1 Basic code point segregation""" base = bytearray() extended = set() for c in str: if ord(c) < 128: base.append(ord(c)) else: extended.add(c) extended = sorted(extended) return bytes(base), extended
e274393735bf4f1d51a75c73351848cbfdd5f81f
708,901
def format_last_online(last_online): """ Return the upper limit in seconds that a profile may have been online. If last_online is an int, return that int. Otherwise if last_online is a str, convert the string into an int. Returns ---------- int """ if isinstance(last_online, str): ...
335ed9a37062964b785c75246c9f23f678b4a90e
708,902
def option_to_text(option): """Converts, for example, 'no_override' to 'no override'.""" return option.replace('_', ' ')
4b7febe0c4500aa23c368f83bbb18902057dc378
708,903
def _cons8_89(m8, L88, L89, d_gap, k, Cp, h_gap): """dz constrant for edge gap sc touching edge, corner gap sc""" term1 = 2 * h_gap * L88 / m8 / Cp # conv to inner/outer ducts term2 = k * d_gap / m8 / Cp / L88 # cond to adj bypass edge term3 = k * d_gap / m8 / Cp / L89 # cond to adj bypass corner ...
b6e8b6331be394e9a10659029143997b097fae86
708,904