content
stringlengths
39
14.9k
sha1
stringlengths
40
40
id
int64
0
710k
def are_users_same(users): """True if all users are the same and not Nones""" x = set(u.get('seq') for u in users) return len(x) == 1 and None not in x
0e58dbcaaa9fc9b9449efbf4454ceebb4de607a2
667,293
def efit_transform(object, data): """Fit-Transform an object on data.""" return object.fit_transform(data)
589481cdd716cd454ce287cddc38b3b2404f91da
667,294
from typing import List def count_total_keywords(keywords: List[str]) -> int: """ Returns the count of total keywords of a list of keywords as a integer. Parameters: keywords (List[str]): list with all keywords as strings. """ return len(keywords)
ba4fff81fddd82487aca121f458d68d3d793af9a
667,295
def linearise(entry, peak1_value, peak2_value, range_1to2, range_2to1): """ Converts a phase entry (rotating 360 degrees with an arbitrary 0 point) into a float between 0 and 1, given the values of the two extremes, and the ranges between them Parameters ---------- entry : int or float ...
d6faa6537c5e2ccde30ce903e90a24280dba43fe
667,296
import re def search_for_perf_sections(txt): """ Returns all matches in txt for performance counter configuration sections """ perf_src_srch_str = r'\n<source>\n type oms_omi.*?object_name "(.*?)".*?instance_regex "(.*?)".*?counter_name_regex "(.*?)".*?interval ([0-9]+[a-z])(.*?)</source>\n' ...
fbeb505ffcadb3f3cf5d4985da1af8ceb5225b25
667,297
def getLocation( min_point: tuple, max_point: tuple ) -> tuple: """Gets the bottom center location from the bounding box of an occupant.""" # Unpack the tuples into min/max values xmin, ymin = min_point xmax, ymax = max_point # Take midpoint of x-coordinate and ymax for bottom middle of box x_re...
3195507038dd5ae6e746ce4163b646f5765fc334
667,300
import copy def wrap_grant(grant_details): """Utility function wrapping grant details for return from a POST.""" details_list = [copy.deepcopy(grant_details)] if grant_details else [] return {'results': details_list}
7c1803f2d749d65ed475fec21f6abc2d8ffc614f
667,301
def get_dom_np(sents, pos): """ Finds the position of the NP that immediately dominates the pronoun. Args: sents: list of trees (or tree) to search pos: the tree position of the pronoun to be resolved Returns: tree: the tree containing the pronoun dom_pos: the position ...
c8e6a06ea07ee18afe051c676acd070aef282fcb
667,303
def check_filters(filters): """Checks that the filters are valid :param filters: A string of filters :returns: Nothing, but can modify ``filters`` in place, and raises ``ValueError``s if the filters are badly formatted. This functions conducts minimal parsing, to make sure that the relationship exist...
724bfbce98c734fe253bb2e77100fb8588f6a3da
667,304
def decodeMsg(aStr): """Decode a message received from the hub such that multiple lines are restored. """ return aStr.replace("\v", "\n")
f84cb538bc86df7f24ffeb375d3ddc42b7a9b80f
667,305
def make_freq_table(stream): """ Given an input stream, will construct a frequency table (i.e. mapping of each byte to the number of times it occurs in the stream). The frequency table is actually a dictionary. """ freq_dict = {} bsize = 512 # Use variable, to make FakeStrea...
9ddb486405ef862107fd66fd3bf20a7074d100d1
667,307
def count_factors(n): """Return the number of positive factors that n has. >>> count_factors(6) # 1, 2, 3, 6 4 >>> count_factors(4) # 1, 2, 4 3 """ i, count = 1, 0 while i <= n: if n % i == 0: count += 1 i += 1 return count
6515778b9bd3be74a30ce4b32c418357dd000150
667,309
from typing import List from typing import Dict def get_author(author_list: List[Dict]) -> str: """Parse ChemRxiv dump entry to extract author list Args: author_list (list): List of dicts, one per author. Returns: str: ;-concatenated author list. """ return "; ".join( ["...
22c9c7acba7a243592d9054eb6b811847d7bfd25
667,310
def read_conll_pos_file(path): """ Takes a path to a file and returns a list of word/tag pairs (This code is adopted from the exercises) """ sents = [] with open(path, 'r') as f: curr = [] for line in f: line = line.strip() if line == "": s...
a5b27deac877d42d759b64d97837c89ff2277546
667,312
def is_keymap_dir(keymap, c=True, json=True, additional_files=None): """Return True if Path object `keymap` has a keymap file inside. Args: keymap A Path() object for the keymap directory you want to check. c When true include `keymap.c` keymaps. json ...
9cb54853ebdda2f1e77b705c35d9a2af21029827
667,313
import torch def recall(cm, mode='pos'): """ Recall: What fraction of ground truth labels was correct? Of all ground truth positive samples, what fraction was predicted positive? sensitivity = recall_pos = TP / (TP + FN) Similarly, of all ground truth negatives, what fraction was predicted ...
bcd8437b5b1c5e2dbc7291deed06c541410aa0ce
667,316
def concatenate_datasets(datasets): """/ concatenate single cell datasets Parameters ---------- datasets: list List of AnnData objects to be concatenate. Returns ------- :class:`~anndata.AnnData` adata """ adata = datasets[0].concatenate(datasets[1]) for i in range(2, len(datasets)): adata = adata.c...
379d2cca842945621c74e14bd5270f19876e509b
667,318
import math def svp_from_t(t): """ Estimate saturation vapour pressure (*es*) from air temperature. Based on equations 11 and 12 in Allen et al (1998). :param t: Temperature [deg C] :return: Saturation vapour pressure [kPa] :rtype: float """ return 0.6108 * math.exp((17.27 * t) / (t ...
50e2a2f8c5222efd9e36bfba787e9ed56da04a57
667,322
def formatColor3i(r,g,b): """3 ints to #rrggbb""" return '#%02x%02x%02x' % (r,g,b)
19791626efad2bfa7795522c3d0d37fd91c63289
667,329
def read_string(file_pth): """ read in a file as a string """ with open(file_pth, encoding='utf8', errors='ignore') as file_obj: string = file_obj.read() return string
ce1cfc8149be034acd4d3d4fdd59700c7fbff217
667,330
def _map_bins_to_labels(bins): """ Maps integers 0-99 to a label according to the distribution specified in `bins`. Example: bins = [10, 20] # implies bin sizes of 10 - 20 - 70 maps to => [0]*10 + [1]*20 + [2]*70 Note that if the integers in `bins` don't add up to 100, this function will ...
37e0327f5cdb2d42f4368f22a2966be4ac4a4729
667,331
def get_supressed_alarms( self, ) -> dict: """Get configured supressed alarms .. list-table:: :header-rows: 1 * - Swagger Section - Method - Endpoint * - alarm - GET - /alarm/suppress :return: Returns dictionary of appliances and alarm t...
bb83658d9646e75d14364a62e6f31eaf934e5960
667,332
def _clean_roles(roles): """ Clean roles. Strips whitespace from roles, and removes empty items. Args: roles (str[]): List of role names. Returns: str[] """ roles = [role.strip() for role in roles] roles = [role for role in roles if role] return roles
d52b568f8a2d756f53f0b51307578f4d4afdcd08
667,334
from datetime import datetime def datetime_str_to_obj(datetime_str): """ :param datetime_str: a string representation of a datetime as formatted in DICOM (YYYYMMDDHHMMSS) :return: a datetime object :rtype: datetime """ year = int(datetime_str[0:4]) month = int(datetime_str[4:6]) day =...
bd1596dedfa692468b65a7ea327255936c14cef0
667,335
def _int_to_indices(value, length, bits): """Converts an integer value to indices in big endian order.""" mask = (1 << bits) - 1 return ((value >> (i * bits)) & mask for i in reversed(range(length)))
b5f6f50d241744f00b9b385aef5eeef148e7f6e7
667,337
def formatdt(date, include_time=True): """Formats a date to ISO-8601 basic format, to minute accuracy with no timezone (or, if include_time is False, omit the time).""" if include_time: return date.strftime("%Y-%m-%dT%H:%M") else: return date.strftime("%Y-%m-%d")
91cb0acaf6a20a68c00557bacbd9327db624b927
667,338
import torch def calculate_wh_iou(box1, box2) -> float: """ calculate_wh_iou - Gets the Intersection over Union of the w,h values of the bboxes :param box1: :param box2: :return: IOU """ # RETURNS THE IOU OF WH1 TO WH2. WH1 IS 2, WH2 IS NX2 box2 = box2.t() # W, H = BOX...
0af45853c1e50157f587f9decea3834df862a314
667,339
import importlib def import_class(value): """Import the given class based on string. :param value: [path of the class] :type value: [str] :returns: [class object] :rtype: {[Object]} """ value, class_name = value.rsplit(".", 1) module = importlib.import_module(value) return getattr...
1da54577f5a772e3b8a230a2328c487b9ce504ed
667,340
def hardness(s: str) -> float: """Get the element hardness.""" d = { 'h': 6.4299, 'he': 12.5449, 'li': 2.3746, 'be': 3.4968, 'b': 4.619, 'c': 5.7410, 'n': 6.8624, 'o': 7.9854, 'f': 9.1065, 'ne': 10.2303, 'na': 2.4441, 'mg': 3.0146, 'al': 3.5849, 'si': 4.1551, 'p': 4.7258, 's': 5.2960, 'c...
232e341ecb341071fbdebe3059001a7cd72f0738
667,341
def database_connection_type(hostname, default_type): """ returns known DB types based on the hostname :param hostname: hostname from the URL :return: string type, or default type """ if 'rds.amazonaws' in hostname: return 'rds' if 'redshift.amazonaws' in hostname: return 're...
49b925811738bd838f754cf4e973b7d7440ac4e0
667,344
import json def update_workspace(cursor, specification, workspace_id, update_at): """workspace情報更新 Args: cursor (mysql.connector.cursor): カーソル specification (Dict)): ワークスペース情報のJson形式 Returns: int: アップデート件数 """ sql = "UPDATE workspace" \ " SET specifi...
a93224dd0e69a3567b797359a4ef252124df9e70
667,346
def two_fer(name=None): """Return a string with a message when given a name.""" if name==None: return "One for you, one for me." else: return f"One for {name.title()}, one for me."
c07a91a48e02aa46430f4543a64a5433d763a1df
667,347
def hyphenate(path): """Replaces underscores with hyphens""" return path.replace('_', '-')
35f0b7baee9fada7385a9ffac66a45b32270f41a
667,348
def compute_score(parsed): """ If a node has no child node (len == 1), the score is the sum of the metadata, else the metadata are indexes of scores of child nodes. If an index does not exists, it is 0. """ score = 0 if len(parsed) == 1: # Only metadata score += sum(parsed['m...
dc1636fccce2406ea24e0313f9dff8124ec0e491
667,351
def _read_from(file): """Read all content of the file, and return it as a string.""" with open(file, 'r') as file_h: return file_h.read()
280860a0075a9b9e8b3f9c014d031147c1bb79ed
667,352
def askyesno(question, default=True): """Ask a yes/no question and return True or False. The default answer is yes if default is True and no if default is False. """ if default: # yes by default question += ' [Y/n] ' else: # no by default question += ' [y/N] ' ...
10635ea8eb9ff735921b0aeb98a3b0083703cf07
667,353
def genomic_dup2_rel_38(genomic_dup2_seq_loc): """Create test fixture relative copy number variation""" return { "type": "RelativeCopyNumber", "_id": "ga4gh:VRC.WLuxOcKidzwkLQ4Z5AyH7bfZiSg-srFw", "subject": genomic_dup2_seq_loc, "relative_copy_class": "partial loss" }
7b4076c58900fbacee758d23798c1c0cd800c69b
667,354
import torch def compute_iou(box1, box2): """Compute the intersection over union of two set of boxes, each box is [x1,y1,x2,y2]. Args: box1: (tensor) bounding boxes, sized [N,4]. box2: (tensor) bounding boxes, sized [M,4]. Return: (tensor) iou, sized [N,M]. """ lt = torch.max( ...
57c8770d828c793c5d34e3677a2ced8f5b755a9f
667,355
from pathlib import Path def path_to_example(dataset): """ Construct a file path to an example dataset, assuming the dataset is contained in the 'example-data' directory of the abc-classroom package. Adapted from the PySAL package. Parameters ---------- dataset: string Name of a d...
879e47e6108601fb5a79128172322f3505b65806
667,357
from typing import Iterable from typing import Any from functools import reduce def product(it: Iterable[Any]) -> Any: """ Convolution product of iterable object Args: it: Iterable object Examples: >>> fpsm.product(range(6)) 120 """ return reduce(lambda x, y: x * y, i...
e4ab027e9e672ac2ef8af17b3c9fa4ea6e61b216
667,358
from typing import List def create_copy_sql(table_name: str, stage_name: str, upload_key: str, file_format_name: str, columns: List): """Generate a CSV compatible snowflake COPY INTO command""" p_columns = ', '.join([c['name'] for...
71a126c6e7274c7c3e6508ffec5502944b8f07c7
667,362
import json def jsondump(data): """Return prettified JSON dump""" return json.dumps(data, sort_keys=True, indent=4)
3d4d76bc0c2f5c7e81c9a49d9f148a63b47127ec
667,368
def get_or_else(hashmap, key, default_value=None): """ Get value or default value Args: hashmap (dict): target key (Any): key default_value (Any): default value Returns: value of key or default_value """ value = hashmap.get(key) if value is None: return de...
6713541f8075636e92c2d2c2a2c444a9cf822375
667,369
import json def equal_list_of_dicts(obj1, obj2, exclude=[]): """Check whether two lists of dictionaries are equal, independent of the order within the list. Parameters ---------- obj1 : list of dict First object to compare obj2 : list of dict Second object to compare exclu...
dad55ea63e9da0f86c613acc39243c5ff8bbca58
667,370
from typing import List import random def generate_random_fill_holes(size: int) -> List[bool]: """ Generate a list of random bools of length size. :param size: length of list of random booleans to generate. """ return [bool(random.getrandbits(1)) for i in range(size)]
24880cbfe48f3230a198698c7ec3a90bb30f8995
667,371
def KtoM(k): """ (number) -> number Returns miles from kilometers. >>> KtoM(5) 3.106855 >>> KtoM(9) 5.592339 """ return k * 0.621371
ff684d5749aed8289828b80b44103e52702a26e4
667,372
def B2s(bs): """ Switch bytes and string. """ if type(bs) == type(b''): return "".join(map(chr, bs)) else : return bytes([ord(c) for c in bs])
435f42c3d167b4c141cc021216a997bf02a6a834
667,373
def get_flights_sorted_price(flights, reverse=False): """Return a list of flights sorted by price. Args: flights (list): list of flights, each flight is represented by a dictionary. reverse (bool, optional): defines the sorting order, by default to False - ascending, if ...
2d21ff6ccee3e07b5ce4aaf7627c94be2570aeb7
667,375
from pathlib import Path def create_profile_path(input_profile_path: Path, profile_name: str, output_dir: Path) -> Path: """Create the name of the output profile by grabbing the ID of the input profile.""" profile_name = profile_name + input_profile_path.stem[len("Color LCD"):] + ".icc" return output_dir ...
22c64f238f9122c3c0d2dccc04b9422d8ebf09db
667,380
def filterit(s): """ A functoin to filter out unnecessary characters from a sentece, helper for nBOW Args: s = Sentence returns: filtered Sentence """ s=s.lower() S='' for c in s: if c in ' abcdefghijklmnopqrstuvwxyz0123456789': if c.isdigit(): ...
873e955a964470c8a795f3ca097cac2290dd5c67
667,382
def MaxPairwiseProduct_Better(array:list): """ Using 2 variables to store Top 2 Max Values in `array`. Single Pass O(n) """ if len(array) < 2: return 0 max1, max2 = array[0],array[1] for i in array[2:]: if i > max2: if i > max1: max1, max2 = i, max...
8c120f4b801a2855840f648fa61a534683b13c6c
667,383
def slash_sort(fn): """Used to sort dir names by the number of slashes in them""" return fn.count("/")
5850d4975c2107adaf356a18e5deae85fddbe9ae
667,385
import json def decode_workload_key(workload_key): """Decode the workload key from a string to the name and arguments. The wokrload key is expected to be a list of "[func_name/hash, args ...]" in a JSON string. If not, then simply return the workload key as the name without arguments. Parameters ...
4ee9e6a12673402149deda5b531d5fbeb57cd48f
667,386
def return_all_parameters_from_parameter_group(rds_client_obj, param_group): """ Returns all the parameters for a parameter group. """ parameters_to_return = [] pagination_token = None # Iterate through all parameters in parameter group and break out when appropriate. while(True): ...
7a16ac4c7aedddcb5d77a5813d2ec8a684bdfbbb
667,387
from typing import Optional from typing import Tuple def get_results(conn, query: str, values: Optional[Tuple] = None): """Returns the results from a provided query at a given connection""" cursor = conn.cursor() cursor.execute(query, values) results = list(cursor) return results
6673b5d64d82902877d0151e5e35eba5c210fb1a
667,388
def get_duplicates_from_cols(df, cols_to_use, what_to_keep='first'): """ Check duplicated rows by using the combination of multiple columns This is a workaround in the case where one doesn't have unique identifiers for a dataset :param pd.DataFrame df: :param list cols_to_use: columns to use to cre...
772c50c606a6e013b322c08be33356fd6bb70c36
667,389
def frepr(var, ffmt="%.16e"): """Similar to Python's repr(), but return floats formated with `ffmt` if `var` is a float. If `var` is a string, e.g. 'lala', it returns 'lala' not "'lala'" as Python's repr() does. Parameters ---------- var : almost anything (str, None, int, float) ffmt :...
c7f37e53cc2cdc2c184fe233b3a27e3a3fed2b1c
667,392
def HA(df, ohlc=None): """ Function to compute Heiken Ashi Candles (HA) Args : df : Pandas DataFrame which contains ['date', 'open', 'high', 'low', 'close', 'volume'] columns ohlc: List defining OHLC Column names (default ['Open', 'High', 'Low', 'Close']) Returns : df : Pandas ...
b97a6018ad2ae39351e974f240c5961129b9c437
667,393
import functools import gc def disable_gc(f): """ Decorator to disable garbage collection during the execution of the decorated function. This can speed-up code that creates a lot of objects in a short amount of time. """ @functools.wraps(f) def wrapper(*args, **kwargs): gc.di...
c49f7cce62f21bb3c32110044423741200a8c7a5
667,396
def branch_text(branch): """ Takes and lxml tree element 'branch' and returns its text, joined to its children's tails (i.e. the content that follows childrens of 'branch'). """ texts = list(filter(lambda s: s != None, [branch.text] + [child.tail for child in branch])) if len(texts) == 0: ...
4b351d292e7c612d08296d5a968b80c0ac26267f
667,399
def splitCommas(s): """Split a string s containing items separated by commas into a list of strings. Spaces before or after each string are removed.""" items = s.split(",") return [ i.strip(" ") for i in items ]
72b3bc8fbb512e139a8b1d6daa14e882b2f5b986
667,402
def divide(a, b): """ Divides two numbers. Automatically raises ZeroDivisionError. >>> divide(3.0, 2.0) 1.5 >>> divide(1.0, 0) Traceback (most recent call last): ... ZeroDivisionError: float division by zero :param a: first number :param b: second number :return: qu...
f232480b2f9cb86cda9676587fc8fad3e7c9aace
667,403
def get_imperatives(tokens): """Identify, color and count imparative forms""" imperatives = [t for t in tokens if t.full_pos.endswith('IMP')] for t in imperatives: t.mode_color.append('Imperatives') return len(imperatives)
9fd50604b631626850d43e9bcc3350e7ee4dee74
667,404
def get_target_rows(df): """Restrict data frame to rows for which a prediction needs to be made.""" df_target = df[ (df.action_type == "clickout item") & (df["reference"].isna()) ] return df_target
203f4a4dc5103b8d251e8063f4e76848efdb98b8
667,407
def row_to_dict(row, field_names): """Convert a row from bigquery into a dictionary, and convert NaN to None """ dict_row = {} for value, field_name in zip(row, field_names): if value and str(value).lower() == "nan": value = None dict_row[field_name] = value return d...
10c903dda90524e6aacfb54a17d4839c8498a769
667,410
def parse_domains_and_ips(file_loc): """Reads the file and returns a dict with every domain we want to redirect and the respective address we want to redirect it to. Parameters: file_loc (str): the location of the file. Returns: dict: a dictionary whose keys are the domain...
64a8ab2208c8189ddc21b41bc21440d709784eac
667,415
def get_chunk(total, current, list): """ :param total: Total number of wanted chunks :param current: Current chunk position wanted :param list: List of data who will be chunked :return: The chunk """ length = len(list)//total start = current*length if current == total-1: ret...
11423312c1ed71bd5b04a3b05d8326d3887f8283
667,422
def get_element(array): """ Get an element from an array of any depth. Args ---- array (Type of the element): Array we want to get an element Returns ------- Type of the element: One of the element of the array """ element = array[0] for i in...
8a3cd667b9248a0451666469ed201512dbcae350
667,424
import six import re def is_valid_mac(address): """Verify the format of a MAC address. Check if a MAC address is valid and contains six octets. Accepts colon-separated format only. :param address: MAC address to be validated. :returns: True if valid. False if not. """ m = "[0-9a-f]{2}(:...
eba258e3c29fd50d2167d1f08493f1282bb6dbac
667,427
def does_flavor_exist(nova_client, flavor_name): """ Check if flavor exists """ for flavor in nova_client.flavors.list(): if flavor.name == flavor_name: return True return False
bdd853f606bcdb94c92c4417363bf9d0b8d2c36a
667,428
def safe_value_fallback2(dict1: dict, dict2: dict, key1: str, key2: str, default_value=None): """ Search a value in dict1, return this if it's not None. Fall back to dict2 - return key2 from dict2 if it's not None. Else falls back to None. """ if key1 in dict1 and dict1[key1] is not None: ...
5a09b5dd5108957588e5eba7867dac69b7f09fc0
667,431
import math def Combinations(n, k): """Calculate the binomial coefficient, i.e., "n choose k" This calculates the number of ways that k items can be chosen from a set of size n. For example, if there are n blocks and k of them are bad, then this returns the number of ways that the bad blocks can be distrib...
b47be64681f0351eb63b910405f25c8aa8f0386d
667,434
from typing import Tuple def normalize_architecture(arch: str, variant: str) -> Tuple[str, str]: """ Normalize the passed architecture and variant. This is copying the same semantics used in https://github.com/moby/containerd/blob/ambiguous-manifest-moby-20.10/platforms/database.go """ arch, v...
fe1711fca17238fba1a840900d133013d5de7591
667,436
def force2bytes(s): """ Convert the given string to bytes by encoding it. If the given argument is not a string (already bytes?), then return it verbatim. :param s: Data to encode in bytes, or any other object. :return: Bytes-encoded variant of the string, or the given argument verbatim. """ ...
8a7fb86152d2d4086ca4dc20c2509c2e64653dc5
667,438
def _get_build_data(build): """ Returns the given build model as formatted dict. Args: build (molior.model.build.Build): The build model. Returns: dict: The data dict. """ maintainer = "-" if build.maintainer: maintainer = "{} {}".format( build.maint...
27f11a267d08ee4fe9db6ccb013efc86f26709c2
667,440
def validate_certificateauthority_type(certificateauthority_type): """ CertificateAuthority Type validation rule. Property: CertificateAuthority.Type """ VALID_CERTIFICATEAUTHORITY_TYPE = ("ROOT", "SUBORDINATE") if certificateauthority_type not in VALID_CERTIFICATEAUTHORITY_TYPE: raise...
2f9229092d02851a9bd9dd75eeeedb65d8f4e4b0
667,443
def writeweight(alloc, content_w, g_w, g_a): """Return write weighting `ww` Parameters ---------- alloc : `[batch_size, mem_size]`. content_w : `[batch_size, mem_size]`. g_w : `[batch_size, 1]`. g_a : `[batch_size, 1]`. Returns ------- ww : `[batch_size, mem_size]`. """ ...
d63849cad870644466edd2f11b1d686000ae9456
667,444
def comp_joule_losses(self, out_dict, machine): """Compute the electrical Joule losses Parameters ---------- self : EEC_PMSM an EEC_PMSM object out_dict : dict Dict containing all magnetic quantities that have been calculated in comp_parameters of EEC machine : Machine a...
1414263267cd46527a4c6acc2967976795990ccd
667,446
def get_fold_val(fold_test, fold_list): """ Get the validation fold given the test fold. Useful for cross-validation evaluation mode. Return the next fold in a circular way. e.g. if the fold_list is ['fold1', 'fold2',...,'fold10'] and the fold_test is 'fold1', then return 'fold2'. If the fold_...
352a1c372d7a559dacd9d4dc0572d1e3eb1500b9
667,448
def map_segs_xsens2ergowear(xsens_segs): """Map segments from xsens (23) to ergowear (9).""" return xsens_segs[..., [0, 4, 5, 8, 9, 10, 12, 13, 14], :]
3f98317595efeb097a21d9f31bb67887ed97b642
667,453
def todep(name): """Convert a library name to an archive path or object file name.""" if name.startswith("-l"): name = name.replace("-l","",1) if name.startswith('toaru'): return (True, "%s/lib%s.so" % ('base/lib', name)) elif name.startswith('kuroko'): return (Tr...
1294eb790ae235d84f75bbc67dcacbaf45617fd8
667,454
from pathlib import Path def create_data_dir(run_dir): """ Create initial files for HADDOCK3 run. Returns ------- pathlib.Path A path referring only to 'data'. """ data_dir = Path(run_dir, 'data') data_dir.mkdir(parents=True, exist_ok=True) return data_dir
28945efcd3e50b91375d087e12178f855d0e3056
667,459
def split_key_value(key_value_str, delimiter='='): """ splits given string into key and value based on delimiter :param key_value_str: example string `someKey=somevalue` :param delimiter: default delimiter is `=` :return: [ key, value] """ key, value = key_value_str.split(delimiter) key...
53a6c51afc01ae487bb1d9cafe9fa3f0ab544a90
667,464
def parse_labels_and_features(dataset): """Extracts labels and features. This is a good place to scale or transform the features if needed. Args: dataset: A Pandas `Dataframe`, containing the label on the first column and monochrome pixel values on the remaining columns, in row major order. Retu...
60fb74b9b309fdbb7928406fe7213d18299b69ab
667,466
def gen_file_name(rank: int, file_ext: str) -> str: """ generate filename to write a DataFrame partition """ if rank < 10: numeric_ext = "000" + str(rank) elif rank < 100: numeric_ext = "00" + str(rank) elif rank < 1000: numeric_ext = "0" + str(rank) else: num...
d04286b6af7e9a4ee7d80ab45c1f41748b1385cd
667,469
def test_items_must_be_in_array_type(open_discovery_document, name, version): """ Test that all array types in disc docs have an attribute called "items". aiogoogle.validate.validate assumes all arrays has an "items" property and it will fail if it didn't find one """ disc_doc = open_discovery_document...
20ea6ab951c09f9d67918d2117f6ca6a980acefe
667,471
def valid_year(entry, minimum, maximum): """Validate four digit year entries.""" if len(entry) > 4: return False elif int(entry) >= minimum and int(entry) <= maximum: return True else: return False
12491b406daa3c6d2eceb0929a2a72becca3cb42
667,472
def refreshAllSymbol(command, mySymbols): """ Check if command is to refresh all stock symbols. """ return (len(mySymbols) > 0 and (command.strip().lower() == "r" or command.strip().lower() == "refresh") and len(command) == 1)
e5a397e3b2c4d4aaf8dc868702ba3b812531fdac
667,474
def clamp(val, min, max): """ Clamp value between min/max values """ if val > max: return max if val < min: return min return val
1d0a80be15bcce8619d087086af3aefb4562155b
667,475
def split_line(line): """ Converts a single input line into its elements. Result is a dict containing the keys low, high, letter and passwd. """ parts = line.split() numbers = parts[0].split("-") d = dict() d["low"] = int(numbers[0]) d["high"] = int(numbers[1]) d["letter"] =...
5d7afd29e2b61747f73d00a27646a5936a22ea85
667,476
def heaps(arr: list) -> list: """ Pure python implementation of the iterative Heap's algorithm, returning all permutations of a list. >>> heaps([]) [()] >>> heaps([0]) [(0,)] >>> heaps([-1, 1]) [(-1, 1), (1, -1)] >>> heaps([1, 2, 3]) [(1, 2, 3), (2, 1, 3), (3, 1, 2), (1, 3, 2...
1bbf1b7bb70dc650852b8f02841eaf0643f59512
667,477
def get_concordance(text, keyword, idx, window): """ For a given keyword (and its position in an article), return the concordance of words (before and after) using a window. :param text: text :type text: string :param keyword: keyword...
508a989a8d59c4877fe40291bd24be406374962a
667,478
def no_op(*_, **__) -> None: """A function that does nothing, regardless of inputs""" return None
0c113e667d7f26d1f22e6a48030ae5f311e4481a
667,482
def synergy_rows_list(ws, signal_names): """ Params - ws: openpyxl worksheet object - signal_names: name given to the signal by the user, i.e., "CFP" Returns - rows: list of tuples, each containing ('signal', signal_row_position) """ rows = [(celda.value, celda.row) for...
69f117a50e0682f50a6b0d84f235910cd657e223
667,486
def write(*args, **kwargs): """ Wrapper for print function or print to ensure compatibility with python 2 The arguments are used similarly as the print_function They can also be generalized to python 2 cases """ return print(*args, **kwargs)
f6bfcc9f72bf1fcfad0dbec56f4bce185df1fa04
667,489
def sfl(L): """ (list) -> bool Precondition: len(L) >= 2 Return True if and only if first item of the list is same as last. >>> sfl([3, 4, 2, 8, 3]) True >>> sfl([a, b, c]) False """ return (L[0] == L[-1])
e89e3a6b8aa3c17ebfee553b044d536227eeabe5
667,491
def flatten_dict(input_dict, parent_key='', sep='.'): """Recursive function to convert multi-level dictionary to flat dictionary. Args: input_dict (dict): Dictionary to be flattened. parent_key (str): Key under which `input_dict` is stored in the higher-level dictionary. sep (str): Sepa...
fa3faee48455ea7e227c77b09bee2702fee5440f
667,492
def mean(vals): """Calculate the mean of a list of values.""" return sum([v for v in vals])/len(vals)
31fa90a32ca10f42511c439954ef545a386d647f
667,494
def get_raffles_for_date_expanded(db, date, user_id, conf): """Get raffles for a specific date Args: db (psycopg2.connection): The db to generate a cursor date (datetime.date): The date to search for user_id (int): User id conf (Config): Configurations Returns: psyc...
f65573674d852e90e50f36e0e65d3c79efa64f01
667,495
from typing import Tuple def footprint_transpose(x: float, y: float) -> Tuple[float, float]: """A transform function to swap the coordinates of a shapely geometry Arguments: x {float} -- The original x-coordinate y {float} -- The original y-coordinate Returns: Tuple[float, float]...
c1b5ce2239913e99a306eeae67515481235ed4f2
667,496