content
stringlengths
39
14.9k
sha1
stringlengths
40
40
id
int64
0
710k
def format_iteration_coordinate(coord): """ Format the iteration coordinate to a human-readable string. Parameters ---------- coord : list List containing the iteration coordinate. Returns ------- str : iteration coordinate converted to a string """ separator = ...
a79827cdbb20c1784fe54e9beba8f163bd96627d
582,225
def always(msg): """For handlers that should trigger in all cases.""" return True
89b9767b6618bccc830328391a43fbda21eebb99
582,227
import itertools def group_by(iterable, iteratee): """ Splits an iterable into sets, grouped by the result of running each value through iteratee. If iteratee is a string instead of a function, groups by the property named by iteratee on each of the values. params: iterable, iteratee ite...
79371a848d3ff290765e34df45f56d65aa74170e
582,228
def compute_knot_vector2(degree, num_dpts, num_cpts, params): """ Computes a knot vector ensuring that every knot span has at least one :math:`\\overline{u}_{k}`. Please refer to the Equations 9.68 and 9.69 on The NURBS Book (2nd Edition), p.412 for details. :param degree: degree :type degree: int ...
7cc40acfea52290deb7f96103646a7ce6176388d
582,230
def ensembl_genes(request, gene_bulk): """Return a dictionary that maps ensembl ids on genes""" _ensembl_genes = {} for gene_obj in gene_bulk: _ensembl_genes[gene_obj['ensembl_id']] = gene_obj return _ensembl_genes
43f86025e5c8231156e8b060727a40213e4bc8ab
582,231
def _combine_ws(parts, whitespace): """Combine whitespace in a list with the element following it. Args: parts: A list of strings. whitespace: A string containing what's considered whitespace. Return: The modified list. """ out = [] ws = '' for part in parts: ...
501e3058a26b0ef9fa4cbfaf054866d17d9b2482
582,232
def crop_to_multiple(img, size_multiple): """ Crops the image so that its dimensions are multiples of size_multiple.""" new_width = (img.shape[1] // size_multiple) * size_multiple new_height = (img.shape[0] // size_multiple) * size_multiple offset_x = (img.shape[1] - new_width) // 2 offset_y = (img.shape[0] -...
554d44488c63e844edc797c18e85e36f7a9b9ce1
582,236
def to_bytes(string: str) -> bytes: """Encodes the string to UTF-8.""" return string.encode("utf-8")
bc28913e34a8c5b741082a99312c8777930db691
582,240
def group_events(events): """ Groups events by ID, station, instrument and channel code. """ grouped = [] grouped_ids = [] for i, e in enumerate(events): if i in grouped_ids: continue group_tag = e['id'] + e['station'] + e['instrument'] current_group = [e]...
0682692f22d9d20513fa93e26bd4071bc0b83145
582,241
def SubclassCount(G, n): """Recursive all-subclass count.""" N_sub = 0 for nn in G.successors(n): N_sub += 1 N_sub += SubclassCount(G, nn) return N_sub
127d09996944b7f362d18e91cd9169a67bea2dfb
582,243
import requests def uuid(ign): """Find the UUID of a player using Mojang's api""" data = requests.get(f'https://api.mojang.com/users/profiles/minecraft/{ign}').json() x = data["id"] return x
2ff92e3f73e6faf768e44c2b1162a946077e623f
582,248
def is_file_included(filename, model): """ Determines if a file is included by a model. Also checks for indirect inclusions (files included by included files). Args: filename: the file to be checked (filename is normalized) model: the owning model Returns: True if the file ...
f50d83a7288494408df8b540c79f2b52053ee87a
582,253
def read_file(path: str) -> str: """Method to read content of a file. Args: path (str): path to file. Returns: str: content of the file. """ with open(path, 'r', encoding='utf8') as file: content = file.read() return content
7c96bb59505ec19d31b2e0aff534c5aeb3da8ac2
582,254
import re def _transform_rpaths(orig_rpaths, orig_root, new_prefixes): """Return an updated list of RPATHs where each entry in the original list starting with the old root is relocated to another place according to the mapping passed as argument. Args: orig_rpaths (list): list of the original...
72913afdc09b1d950b39a31703b44924be2cb6f4
582,255
import math def _calculate_atom_distance(i, j): """Euclidean distance between two 3d points""" return math.sqrt((i[0] - j[0])*(i[0] - j[0]) + (i[1] - j[1])*(i[1] - j[1]) + (i[2] - j[2])*(i[2] - j[2]))
43662ab58ae1a941501c96f9cdaef6a7e4117f63
582,258
from typing import Optional def bool_from_hex(value: str) -> Optional[bool]: # either 00 or C8 """Convert a 2-char hex string into a boolean.""" if not isinstance(value, str) or len(value) != 2: raise ValueError(f"Invalid value: {value}, is not a 2-char hex string") if value == "FF": retu...
74468f2f77769fc6ddccaae01a486c1d2245d71d
582,260
import string def format_filename(filename): """ Formats filename to remove invalid characters :param filename: :return: filename without invalid characters """ valid_chars = "-_.() %s%s" % (string.ascii_letters, string.digits) formated_filename = ''.join(char for char in filename if char ...
94d9d35b6b992a4ef90fb1befeb908b971808458
582,261
def _is_jupytext_file(ntbk): """Infer whether a notebook node was created from a Jupytext Markdown file. Right now, this just tries to guess based on whether there's a particular piece of metadata in the notebook. """ jupytext_meta = ntbk.get('metadata', {}).get('jupytext') if jupytext_meta is ...
d5da033da69fcec5b6828db9629d9686b0590c47
582,262
from datetime import datetime def weekday_and_num_to_day(year: int, month: int, weekday_number: int, weekday: int): """Converts current year, month, weekday and weekday number into the day of month """ dt_first = datetime(year, month, 1) dt_first_weekday = dt_first.weekday() return 1 - dt_first_we...
c8e02d2ce027e949129aa9c21e9c19e37d5357c4
582,263
import collections def pool_permission_list_for_service(service): """Build the permission string for Ceph for a given service""" permissions = [] permission_types = collections.OrderedDict() for permission, group in sorted(service["group_names"].items()): if permission not in permission_types:...
f0bd3b8c0e48083e3142d87a3a3cc531e2286756
582,264
def qxscalar(scalar, quat): """quaternion scalar multiplication :param scalar: scalar value :param quat: quaternion value :return: scaled quaternion set; q_out = scalar * quat """ return [scalar*q for q in quat]
dc38e716e1e873ca396f01017eb39159326a5baa
582,265
from pathlib import Path import pickle def read_database(database_path: Path): """Read and return the database.""" with open(str(database_path.absolute()), "rb") as database_file: return pickle.load(database_file)
54391e8056e9d161f59a2873c3c0831b07f869fa
582,267
def upper(text): """ Uppercases given text. """ return text.upper()
95ccbdb4d005ea4f189c2e608ff070ddfad8c03b
582,269
def tel_deact(serie): """ Counts amount of cars from a serie when there is an activation. When the sensor then turns off there is a car added. :param serie: slice from sensor column in the dataframe when the traffic light turns green :return: amount of cars that went by while traffic light was green...
090c2e98b8d67a3f7ffa60bff08eec56a89eeaea
582,271
def expand_extent(extent, margin): """Make the rectangular region bigger by a given amount to all directions. Args: extent: The rectangular given as a list of [lon1, lon2, lat1, lat2]. Longitude in [0,360) °E and latitude in [-90,+90] °N. margin: The amount to extend into all four d...
64ccb131410148e403f4a83bfbc2176b265d6a83
582,276
def gen_n_dict(n): """Creates a doctionary where the keys range from 0 to the number of digits in n. The definition for each key is 0. """ n_dict = {} for i in range(0, len(str(n))): n_dict[i] = 0 return n_dict
b78153ddc6c7f5e808ce7c50c4c83a4a80d78c30
582,278
def get_line(output,string): """ Return the line number in 'output' containing the first occurence of 'string' """ for i,line in enumerate(output): if (string in line): return i
228a3f9fee3c9a98c02016f6953ca4bad79e059f
582,281
import re import typing def parse_args(str_prop: str) -> typing.List[str]: """Parses the arguments of a proposition string.""" matches = re.match("[^\(]*\(([^\)]*)", str_prop) if matches is None: raise ValueError(f"Unable to parse objects from '{str_prop}'.") str_args = matches.group(1).repla...
72c61236fb3919c471933aff415209db8377a495
582,283
def build_ssl_modified_sequence(seq, mods, ssl_mods): """ Build BiblioSpec SSL modified sequence string. Arguments: seq - peptide sequence mods - MS2PIP-formatted modifications ssl_mods - dict of name: mass shift strings create ssl_mods from MS2PIP params with: `ssl_mods = \ {ptm.split(',')[0]:\ "{:+.1f}"...
069f518af2ef9a64f176108275f32e84acd4ebd9
582,285
def max_ring_size(mol): """Get the size of the largest ring in a molecule :param mol: input_molecule :return: size of the largest ring or 0 for an acyclic molecule """ ri = mol.GetRingInfo() atom_rings = ri.AtomRings() if len(atom_rings) == 0: return 0 else: return max([...
7bc22269d97642706617c01f363b690201d7a35d
582,286
def get_task(benchmark, env_id): """Get a task by env_id. Return None if the benchmark doesn't have the env""" # A lambda function is a small anonymous function. # The filter() method constructs an iterator from elements of an iterable for which a function returns true. # The next() function returns the...
47edb506bee85b1efe0a1cfb9c9837256275f574
582,287
import torch def logsubexp(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor: """Calculate log(exp(x) - exp(y)) """ return x + torch.log1p(input=-torch.exp(y - x))
307659d58b26654871eafbd07b058f5e69d99ca5
582,294
from collections import defaultdict def makedefdict(d, default_factory=int): """Converts a normal dictionary into a :class:`defaultdict`, using the given `default_factory`""" ret = defaultdict(default_factory) ret.update(d) return ret
5f878a4792641162736d09536d65d5ee10898209
582,296
def get_source(source, provider): """ Returns `source` if given, otherwise `provider` """ if not source: source = provider return source
d84f1543ae9f31cec8709c6b2fbdc4c2e18142d0
582,297
import filelock import pickle def pickle_read(filename): """Read pickle file contents with a lock.""" lock = filelock.FileLock(filename+'.lck',timeout=20) pickle_data = None with lock: pickle_data = pickle.load(open(filename, 'rb')) return pickle_data
e6bb14a849ff0c8cb524ce7fce4311455d087a11
582,300
def gmt2dict(gmt): """ Load gmt file as dictionary """ with open(gmt) as genesets: genesets_dict = { line.strip().split("\t")[0]: line.strip().split("\t")[2:] for line in genesets.readlines()} return genesets_dict
91734839a3bfb6647e79d84a229c0cbbbc0880ed
582,301
def count_val_size_in_dict(result): """ expects a dict with keys which map to lists sums the size of all lists in the dict @param result: a dict where each key maps to a list @return: the summed size of all lists """ amount = 0 for k, values in result.items(): amount += len(value...
b90f3e65154ff2ac76fcac417b7582a9044cb8f1
582,305
import torch def _gen_pairs(input, dim=-2, reducer=lambda a, b: ((a - b) ** 2).sum(dim=-1)): """Generates all pairs of different rows and then applies the reducer Args: input: a tensor dim: a dimension to generate pairs across reducer: a function of generated pair of rows to apply (bey...
5c2e4f05f4bad12d8de81001a6d6ef720d02718a
582,307
def get_var_value(re_search, tokens, i): """Gets the list of tokens between re_search["start_tokens"] and re_search["end_tokens"]. Args: re_search: Dictionary with hash values `start_tokens` and `end_token`. tokens: list of tokens in which to look for `re_search`. i: starting index ...
69ae273c89e77a03e5275da2234590990265ff12
582,308
def extract_camera_key_from_filename(filename: str) -> str: """ Extract the camera name from the filename. :param filename: the name of the file where the samples image is stored. Ex: 'samples/CAM_BACK/n015-2018-10-02-10-50-40+0800__CAM_BACK__1538448750037525.jpg', :return: The camera na...
1bf2ce862efc384b39a9a149d4d7d5e3af7218f1
582,309
def read_readme(filename): """Return contents of README.md.""" with open(filename, 'r', encoding='utf8') as f: readme = f.read() return readme
0fba0d84a338434c5679acd3e1f31e00b11635c5
582,310
import math def length(line): """Returns the Manhattan length of the given line segment. """ (point1, point2) = list(line.boundary) return (math.fabs(point1.x - point2.x) + math.fabs(point1.y - point2.y))
4c8006df9f24971c2e836093ca50df2f37b0761c
582,312
def format_datetime(dt): """Format the datetime string""" if not dt: return "" fmt = "%Y-%m-%d %H:%M:%S" return dt.strftime(fmt)
4c3cab9db2c8b571d77d082ffdfb0d75cdd95933
582,313
def add(data: dict[str, str], key_word: str, info: str) -> dict[str, str]: """Add provided key and value to the JSON file. Parameters ---------- data : dict of str, str Internally used by `read` to pass in the current data key_word : str The key to be used info : str The...
27994f1e3437455082fc548c3d4e122cb7729158
582,318
def catwalk(text): """ Replace multiple spaces in a string with a single space. :type text: string :param text: The text to fix. >>> catwalk("this is a long sentence") 'this is a long sentence' """ # Return the fixed version return ' '.join(text.split())
49f00d6e7d584ecaa31454e8cf2d214b937f5002
582,320
def capitalizeFirst(word): """ Capitalizes the first letter of a string. """ return word[0].upper() + word[1:]
8c893137431b4f1787fa3b969ef8f1d2ece840c0
582,321
import torch def get_num_parameters(model): """ Returns the number of trainable parameters in a model of type nn.Module :param model: nn.Module containing trainable parameters :return: number of trainable parameters in model """ num_parameters = 0 for parameter in model.parameters(): ...
09e4b4e5b79d30600905984af8860413b643eeae
582,324
import time def TimestampISO8601(t): """Seconds since epoch (1970-01-01) --> ISO 8601 time string.""" return time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(t))
be3b1668328a372300ca51e9a17bddbeebd884f1
582,327
import hashlib import base64 def encode_secure_id(value: int, secret: str, realm: bytes = b"") -> str: """ Secure a (postive 32-bit) integer id from manipulation/bruteforce testing, by hashing it together with a given secret string. The id and the hash are encoded into an url-safe base64 string. :par...
1f12d77a318df5de922d2716fbff0c3bb7d893df
582,329
def get_lastfm_high_water_mark(config): """Get the marker for the latest last.fm track processed.""" if (not config.has_section('lastfm') or not config.has_option('lastfm', 'last_timestamp')): return 1 return config.getint('lastfm', 'last_timestamp')
ad5eab3b59e9b642cc3964af77bdf7d868d6914f
582,333
from typing import List def select_record_fields(record: dict, fields: List[str]) -> dict: """ Selects a subset of fields from a dictionary. If the field is not present in the dictionary it defaults to None. Parameters: record: dictionary The dictionary to select from fiel...
0aa0206399714053e8880b03364a2479b2a0c67b
582,337
import pickle def load_pickle(location, filename): """ Load pickled object from disk. Parameters ========== location : str Path to directory to store the pickled object. filename : str Name of file to be loaded. Returns ======= object : scikit-learn/custom model o...
2022ec5b875a3dff94e68331353ede8483e538c8
582,340
def parse_sk_m(line): """ Parse sk_m measurements. This is a line having this format: $ sk_m_print(0,send-1-0-1) idx= 4 tscdiff= 42 @return None, in case the lines is not an sk_m, a tuple (core, title, idx, tscdiff) otherwise """ if line.startswith('sk_m_print'): (desc, _, idx, _,...
e1125f0010fbe1ba4d7e2a253a9c1597db0b3845
582,348
def format_smashgg_url(url): """Converts bracket url to api url, if necessary.""" if "api.smash.gg" not in url: url = "http://api.smash.gg/phase_group/" + url.split("/")[-1] api_string = "?expand[0]=sets&expand[1]=entrants" if api_string not in url: url += api_string return url
36ea0ef09b850923599039085f7be3b960098d7d
582,349
def has_consequential_property(exchange): """Return list of consequential properties from an exchange""" return [prop for prop in exchange.get('properties', []) if prop['name'] == 'consequential' and prop['amount'] == 1]
a01c7000dc24c81f49eb849282a503841c8f87fe
582,351
def median(in_list): """ Finds median value of given list :param in_list: list of values :return: float or int """ n = len(in_list) in_list.sort() if n % 2 == 0: m1 = in_list[n // 2] m2 = in_list[n // 2 - 1] m = (m1 + m2) / 2 else: m = in_list[n // 2] ...
7918eca5f9660b74c2e7b04b13b67c8702d48f13
582,354
def plane(xy_array, a, b, c): """ Return z values such that z = a*x + b*y + c. :param xy_array: a (2xN) numpy array, x values being the first row and y values the second row :param a: coefficient for x values :param b: coefficient for y values :param c: constant offset :return: an arr...
0cf9441f9d76bab667935cf9b63216750ca74c23
582,362
def rev_comp(seq): """reverse complement a string""" relation = {'A':'T', 'T':'A', 'C':'G', 'G':'C', 'N':'N'} return ''.join(relation[s] for s in seq[::-1])
eee6f6256b4d8d5d803267c62d5182e7b495b278
582,363
def _abbreviateAbbreviatedName(name): """ Abbreviate the part of a name that may contain abbreviations. The input string should already have spaces and hyphens removed. :param name: Name to abbreviate :returns: Abbreviated form of the name """ res = [] parts = name.split('.') fo...
1b09aacee775798a29faf58e57f69da2d4c1372f
582,368
def remove_null_kwargs(**kwargs): """ Return a kwargs dict having items with a None value removed. """ return {k: v for k, v in kwargs.items() if v is not None}
2e0a85ae584a7d6b84aa073ce86941b15db72361
582,370
from typing import Iterable def _expand_numparse(disable_numparse, column_count): """ Return a list of bools of length `column_count` which indicates whether number parsing should be used on each column. If `disable_numparse` is a list of indices, each of those indices are False, and everything el...
6b9e33d176cbf876f10a32a11c578a8fb4da85d5
582,374
def extract_model_global_features(file_path): """ Extract number of features, number of classes and number of trees of this model :param file_path: path to model.txt :return: dict with "n_args", "n_classes", "n_trees" """ res = {} with open(file_path, "r") as f: for _ in range(3): ...
ca5934e4ee44cf03cef252067d58d30dc778fced
582,375
import re def is_correct_vector_v3(vector): """ Checks whether CVSSv3 base vector is valid. :param vector: base vector of CVSSv3 (string) :return: True if valid """ return vector is not None \ and re.match(r'(CVSS:3\.0/)?AV:[NALP]/AC:[LH]/PR:[NLH]/UI:[NR]/S:[UC]/C:[NLH]/I:[NLH]' ...
b091826c5f99ca7f41888f950086f983ddbd1f8b
582,378
def distance_helper(initial_velocity, acceleration, time): """ Calculates the distance traveled given the initial velocity, acceleration, and time, Helper function to the distance function. :param initial_velocity: Integer initial velocity :param acceleration: Integer acceleration :param ti...
e8699b2ff82cceb95ffd4e1fe4bbe865ce807b0f
582,379
import random def truncation_selection(population, children, truncation=10): """ Select the genomes with the highest fitness and sample uniformly from this list. Args: population: the parent population. children: the number of children to select. truncation: the number of top parent...
f6c1d4b2fdabfc36c63688b25e9a8906534d5c50
582,380
import uuid def protect_from_wrap(text, groups, restore_info=None): """ Protect each match in groups that appears in text from wrapping by replacing it with a UUID in hex format (which won't be wrapped). Parameters ---------- text : str The text in which groups (like markdown links o...
6b7f612754fa160158e01ef03e3c23cd414c9df8
582,381
import hashlib def _hash_token(token: str) -> str: """Get a SHA1 digest of `token`.""" as_bytes = token.encode("UTF-8") return hashlib.sha1(as_bytes).hexdigest()
fed2471fdfd889d4d6c649ef222a179c254c27fc
582,382
def get_simulation_method_args(method_props, module_method_args): """ Setup the simulation method and its keyword arguments Args: method_props (:obj:`dict`): properties of the simulation method module_method_args (:obj:`dict`): dictionary representing the desired simulation function, ...
a72950a1aca61bcf6391359ecca785df503e5768
582,385
def is_bool(target: bool) -> bool: """Check target is boolean.""" if not isinstance(target, bool): return False return True
d2549baf00d9e65a01a35154ec2923c2ee17016b
582,387
import json def read_data_shapes(path, preferred_batch_size=1): """Read the data name and data shape required by the MXNet module. Args: path (str): an MXNet NDArray that is the result of a prediction preferred_batch_size (int): the accept content type expected by the client Returns: ...
2f1ce014d3959d4f32084c23c22fc61f09b1a882
582,390
def create_query(section): """ Creates a search query based on the section of the config file. """ query = {} if 'ports' in section: query['ports'] = [section['ports']] if 'up' in section: query['up'] = bool(section['up']) if 'search' in section: query['search'] ...
39410288e69f466c6fa2faa048fcfe29aa710de7
582,396
import math def get_points(samples): """ Returns the least base-2 number that is greater than the max value in the samples array Inputs: samples - array with data Outputs: 2**power - base-2 number that is greater than the max samples """ power = int(math.log(max(samples), ...
e94f6820542a97ca5af982cddfb73dcd3fad668d
582,397
def message_info(exchange, routing_key, properties): """Return info about a message using the same conditional constructs :param str exchange: The exchange the message was published to :param str routing_key: The routing key used :param properties: The AMQP message properties :type properties: pika...
e1a74a00f353ea15a80db32355b8eb051f70c07d
582,398
def indices_to_coords(x, y, geomatrix) -> tuple: """Returns geographic coordinates of pixel Calculates coordinates at x,y based on geomatrix *** Parameters ---------- x:int Column position of pixel within image y:int Row position of pixel within image geomatrix:geomatrix As returned by gdal.GetGeoTra...
4d0decf2869e35b9e63be0d57122c0ab1fb50cfb
582,400
def cartIDs(nmax): """Given an nmax, convert to (n,m) Cartesian ID pairs """ ids=[] if type(nmax) is int: nmax=[nmax,nmax] for ny in range(nmax[0]): for nx in range(nmax[1]): ids.append([ny,nx]) return ids
8cb3ac7273aede431ca6933e4f03db77b295d398
582,402
import re def checked_type(file_path, regex_list): """Check if the file_path is from the regex list""" for regex in regex_list: if re.match(regex, file_path, re.IGNORECASE): return True return False
4e0c633716af403f1b008da4066f3b251abbf933
582,408
def trim_dropbox_link(path): """Trim a dropbox link to extract file name. e.g. https://www.dropbox.com/s/m8qlfp0cjnn4ka7/20002_1065.gwas. imputed_v3.both_sexes.tsv.bgz?dl=0 --> https://www.dropbox.com/s/m8qlfp0cjnn4ka7/20002_1065.gwas. imputed_v3.both_sexes.tsv.bgz """ path = path.r...
8bcc5ea6637e11f3ebab6c3f820c4e64156a6127
582,410
def _get_all_equipped(obj): """ Returns a list of all equipped items. """ if hasattr(obj, 'inventory'): equipped_list = [] for item in obj.inventory: if item.equipment and item.equipment.is_equipped: equipped_list.append(item.equipment) return equipped...
ddf5e006f3c1731fb385e3e9214c46607a09edec
582,411
def ellipsis(s: str, width: int) -> str: """ Shrinks the given string to width (including an ellipsis character). Parameters ---------- s The string. width The maximum width. Returns ------- str A modified string with at most `width` characters. """ ...
95e18d0b9e7e5068da73657e83bb0e1e461da22b
582,415
def numericise(value, empty2zero=False): """Returns a value that depends on the input string: - Float if input can be converted to Float - Integer if input can be converted to integer - Zero if the input string is empty and empty2zero flag is set - The same input string, empty or not...
4395f768a20a9fce748f47a3ce74c5313b02c522
582,417
def tup_list_maker(tup_list): """ Takes a list of tuples with index 0 being the text_id and index 1 being a list of sentences and broadcasts the text_id to each sentence """ final_list = [] for item in tup_list: index = item[0] sentences = item[1] for sentence in sentence...
7c00da0a1b0835b7648cf9332386f03712896b6c
582,420
def dictHas(dict, keys): """ Verify if dict has expected keys""" for i in keys: if dict.get(i) is None: return False return True
d412a52769c1465e764ddb26f2e12eda10bbc776
582,421
def params_to_string(num_params, units=None, precision=2): """Convert parameter number into a string. Args: num_params (float): Parameter number to be converted. units (str | None): Converted FLOPs units. Options are None, 'M', 'K' and ''. If set to None, it will automatically choose...
a181a142aa1886dfaaebf0665908244764d69cde
582,423
def find_job(instance, job_name=None): """locate job within instance""" for job in instance.get_jobs(): if job.applicationName.split("::")[-1] == job_name: return job else: return None
c83cb8aee4811869a093f3b0aac1791f63750631
582,424
def inH2O_mph2Pas2_m2(x): """inH2O/mph^2 -> Pa-s^2/m^2""" return 1246.*x
bbe71993ce39e8869abfa72ed72c7e5652024e0a
582,426
def create_feature_class_set(dataset): """ Gets the dataset and generates a feature set and class set. :param dataset: dataset - list[list]: The dataset which contains the attributes and classes. Example: [[0.23, 0.34, 0.33, 0.12, 0.45, 0.68, 'cp'], [0.13, 0.35, 0.01, 0.72, 0.25, 0.08, 'pp...
ed9de92cdfe030226d78109ddfba0d3f6b1d2a90
582,427
from random import randint def random_array(size = 20, max = 0): """ CREATE TEST INPUT AS ARRAY(LIST) ARG size: LENGTH OF ARRAY ARG max: MAXIMUM VALUE FOR ELEMENTS """ if max == 0: max = size * 3 return [randint(0, max) for _ in range(size)]
7701e981168c8dd7a3047165e42e8fd1db43077e
582,428
from pathlib import Path def checkIsEndpoint(folder_path: Path): """Returns True if all files within the directory are of the expected extension""" list_files = folder_path.iterdir() if all([file.is_file() for file in list_files]): return True return False
d7c5b924c47ffaf1e2cc546cbc99f62d06f0b739
582,430
def serialize_csc(matrix): """ Decompose a matrix in Compressed Sparse Column format into more basic data types (tuples and numpy arrays) which PyArrow knows how to serialize """ return ((matrix.data, matrix.indices, matrix.indptr), matrix.shape)
4f7a19974fc71eeb03028b671dd12a8002d699eb
582,431
def reverse_mapping(mapping): """ Construct a reverse dictionary mapping values to keys. :param dict mapping: the original dictionary. """ reverse = {} for key, values in mapping.items(): for value in values: reverse[value] = key return reverse
93c1d785223988572440e17f4b09fe2131b566d9
582,435
def calc_cost(cl1_len, cl2_len, num_cl1, num_cl2): """ Assign a cost to a pattern based on if the majority of its occurances are observed in regions of a time series that are annotated with the same binary label. The cost calculation takes into account a possible difference in the total lengths of the s...
7e58e78261f1a62e772da2db855162acf5de7d7f
582,436
def maybe_add_slash(path): """Add a final trailing slash if it wasn't there already""" with_trailing_slash = path if path.endswith('/') else path + '/' return with_trailing_slash
117f670b47ad6e6d1df26c54d09ed0c771c2d273
582,437
def remove_ending_whitespace(prompt: str) -> str: """Remove ending whitespace from string. Args: prompt (str): prompt to remove from Returns: str: The resulting string """ return prompt.rstrip()
47f5be8d66fb1ee46a9bebe6db494beecc702029
582,439
import re def clear_sent(sent): """Remove all non-letters symbols, except `-` Args: sent (str): Sentence Returns: str: Cleared sentence """ sent = re.sub(r'[^-\w]+', ' ', sent) sent = re.sub(r'(\s-\s*|-\s+)', ' ', sent) return sent.strip()
c3ab8addc0dc48daefe4e85e381b5cfd66955d1d
582,440
def RemoveSmallSegments(BasinHillslopeData, n_traces=50): """ Remove hilltop segments with less than a specified number of traces in a basin Args: BasinHillslopeData (pandas dataframe): The dataframe containing the hillslope data (ridgelines). You get this using the ReadHillslopeData function ...
de4dcc5835ad63650f368ceea28776360148bf24
582,442
import re def _escape_icon_filename(value): """ Escape forbidden symbols in an icon file name. """ value = re.sub(r'[<>:\/\\|?*\'"’“”„«»…–—¡¿]', '', str(value)) value = value.strip() value = value.replace(' ', '-') return value
6655370e51d3142d87f8b0bbd8ead4643acaa53a
582,445
def time_of_saccades(saccades, d_time): """ A Function to get the start and end time of the individual saccades :param saccades: a list with values which indicate if the move from the previos is a saccade. :param d_time: the delta time in seconds between each step :return: return...
968d7ef56cabdcf275c5b7dad6540fafb9e63165
582,446
def _get_tag_from_loaded_dicom(dcm, tag): """ Get tag from loaded pydicom data structure. Attributes: dcm (FileDataset): dicom slice, result from pydicom.dcmread() tag (str): key of interest in the dicom (e.g. "SOPClassUID") Returns: content (str): the contant of the dicom key ...
7104ddaf4592ed48e5027195827a617d6d62ee20
582,448
def create_detector(client): """ Creates a GuardDuty Detector :param client: GuardDuty Boto3 client :return: DetectorId """ response = client.create_detector(Enable=True) detector_id = response['DetectorId'] return detector_id
f841a953e84bf79dbc6f7e43eb51ee7085ea7007
582,454
def find_mesh_instances(vnode): """ A mesh instance at a vnode may be moved and split-up into multiple vnodes during vtree creation. Find all the places it ended up. """ if vnode.mesh: return [vnode] else: vnodes = [] for moved_to in vnode.mesh_moved_to: vnode...
c7be515dd16ba8e8b4986ba9e8b015fb4955fe80
582,456