content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
import os def check_filename(originalName): """ add number to filename to make unique if not already - returns new name""" count = 1 exists = True fileName = originalName while(exists): exists = os.path.exists(fileName) if exists: if "." in originalName: fileName = originalName.split(".") fileNa...
9611d9225def48e7fb6b2b578c60f4fe5bc1dc73
695,302
def and_(predicate1, predicate2): """DBC helper for conjunction of predicates""" def and_predicates(*args, **kwargs): return predicate1(*args, **kwargs) and predicate2(*args, **kwargs) return and_predicates
a2586e3d9c9828f6af9fdf1300db601c1018b290
695,303
import unittest def expected_failure_if(expect): """ Unit test decorator to expect failure under conditions. @param expect: Flag to check if failure is expected @type expect: bool """ if expect: return unittest.expectedFailure else: return lambda orig: orig
4cf083167e44328811a8df1bb9b8fc55dd741661
695,304
def getDist(ind1,ind2,distMat): """ distMat is a distance matrix. distMat[i,j] == distance from i to j """ return distMat[ind1,ind2]
c9303fd806cd765295f437ee533952692f89702c
695,305
def sleep_onset_latency(predictions): """ Calculates sleep onset latency on an array of sleep/wake predictions in one minute epochs. This corresponds to the total number of minutes awake before the first sleep period. Parameters ---------- predictions : array-like Binary sleep/wake pred...
6595aba1d22d9555c8998c6bb940045951b2503c
695,306
def initialize_LIP_dict(LIP_feature_collection): """ Initialize the dictionary which contains the LIP fraction remaining for all LIPs. Parameters ---------- LIP_feature_collection : feature collection feature collection of LIPs Returns ------- LIP_fracs : dictionary wit...
e105b84781105599bc92a6e1eece9b4f8ef2e4e9
695,307
def version_tuple_to_str(version): """Join version tuple to string.""" return '.'.join(map(str, version))
2567dd8481fe9dc6b1fc71cb7669aed204aaec9a
695,308
def _pat_mergeable(p1, p2): """ Compare two *AbstractionPattern* instances for equality regarding an interpretation merging operation. Evidence and hypothesis comparison is assumed to be positive, so only the automata and the initial and final states are compared. """ if p1 is None or p2 is ...
f0c418fd63784e5e6ea8cf02ac17ec315eba809d
695,309
import torch def sample_pdf_2(bins, weights, num_samples, det=False): """sample_pdf function from another concurrent pytorch implementation by yenchenlin (https://github.com/yenchenlin/nerf-pytorch). """ weights = weights + 1e-5 pdf = weights / torch.sum(weights, dim=-1, keepdim=True) cdf = t...
e20ba8d000876278d28b732fd6bcd190cd649796
695,310
def Code_f(val): """ :param val: The value of this Code """ return '\\begin{lstlisting}\n' + val + '\n\\end{lstlisting}\n'
594a913361853ccd64523adb79ca0c933c07d807
695,311
import numpy as np def rms(x): """Return the root mean square of x, instead of doing matplotlib.mlab.rms_flat. """ return np.sqrt(np.mean(x*x))
e09ae59241ac41b58d6c1273a344b622ac05d092
695,312
def isAttrMirrored(attr, mirrorAxis): """ """ if mirrorAxis == [-1, 1, 1]: if attr == 'translateX' or attr == 'rotateY' or attr == 'rotateZ': return True elif mirrorAxis == [1, -1, 1]: if attr == 'translateY' or attr == 'rotateX' or attr == 'rotateZ': return ...
560f20fd5e2110ce31fb9dddbf72fc1a8f19ca65
695,313
def pytest_report_header(config): """ return a string in test report header """ return "Hey this are the tests"
e64bf912f78e8524d99126569d0423c821158498
695,314
def firmValuationPE(annual_revenue: float, p_e_ratio: float) -> float: """Valuation by price-to-earnings (P/E) ratio. Earnings are sales minus costs. Some people prefer P/E over P/S as it captures profitability. However, companies plowing extra money into growth will have poor P/E. Eg Amazon. """ ...
55ae91c6e37468de8963b0d8c5754bb21aab81e0
695,315
def reportNumber(n, options, field=None): """ Given n an integer, report back the correct format as string. """ if field is not None: return "%*g" % (field, n) else: return "%g" % n
cdaa1e78a1031a39c37b2e72f771b0667819b172
695,316
def is_pic(img_name): """判断是否是图片 参数: img_name (str): 图片路径 返回: flag (bool): 判断值。 """ valid_suffix = ['JPEG', 'jpeg', 'JPG', 'jpg', 'BMP', 'bmp', 'PNG', 'png'] suffix = img_name.split('.')[-1] flag = True if suffix not in valid_suffix: flag = False return flag
7c809234a486d9d9effe97ecdf0bb3cc561af9fc
695,317
def valid_moves(board): """Returns a list of all valid moves in the position""" moves = [] # Go through each space, if it's not X or O, append it for space in board: if space != "X" and space != "O": moves.append(space) # Return moves at the end return moves
1447314b16ab611ab796fcbb1e5582b98d6ae88e
695,318
def estimate_kpar(kpnts): """ Estimte KPAR which is the number of parallel process among k-points. """ return max(kpnts)
659dcde496f08de761986b903e6497e76f22ecfc
695,319
def reverse_round(key): """Reverses the first operations of the round (before mixcolumn)""" state = [(key[i // 2] >> (4 * (i % 2))) & 0xf for i in range(32)] # reverse shiftrows old_state = state.copy() for i in range(4): for j in range(8): # state[8 * i + j] = old_state[8 * i +...
3b9e3246ff3cbb67016b7e4eb446e0dc4a38eadc
695,320
import logging def filter_storage_size_num(size_str): """Convert human-readable size string to a string convertible to float""" # pattern: '^[1-9][\d\.]*[MGT]B?$', multiplier=1000 (not KiB) if size_str.endswith('B'): size_str = size_str[:-1] try: size_num = 1000000 for multipl...
145680ec35ce14a17721250156fcb6c368558c28
695,321
def welcome(): """List all available api routes.""" return ( f"Welcome to the Hawaii Climate 'Surfs Up' Home Page<br/>" f"Available Routes:<br/>" f"<br/>" f"List precipitation data with dates:<br/>" f"/api/v1.0/precipitation<br/>" f"<br/>" f"Li...
43c9ec89fcaaaa4d14205da694271dc4a50f7b31
695,323
import os def save_and_view_map(f_map, output_path): """Writes Folium Map to an output file and prints the path to the terminal. Saves the specified Folium Map to the specified location. File is saved as an .html file. The user can then open the path in any browser to display it. Args: f...
663f1f55d284c6049138465eff9848a47de2af7a
695,324
def _format_vendor_id(vendor_id: str) -> str: """Strips vendor name from vendor_id field. Example: >>> _format_vendor_id("0x1234 (Nice Vendor Inc.)") # "0x1234" """ return vendor_id.split(maxsplit=1)[0]
e181330ca164ea4fdbf6ea2e57e20b707351dcfc
695,325
def search_result(doc_info, index): """ The search_results function displays the results of the query performed by the user into the search engine Args: doc_info (list): A list containing document information index (int): An integeter containing the ranking Returns: ...
56378bc310343ed104a3e507e5295952b2cbc62f
695,326
import argparse def _parse_args(): """ Parses the commandline arguments for running an expirement trail/series of trials Args: Returns: args: the parsed arguments in a new namespace """ """ Add arguments below. Example format: parser.add_argument('-cp', '--continue_...
e83b1688883cad61769866ec3cf7ec161b1bcc0f
695,327
def user_mention(user_id: str) -> str: """ Return a mention of a user that can be sent over a Discord message. This is a convenience method for cases where the user_id is known but you don't have or need the full discord.User or discord.Member object. """ if not user_id.isnumeric(): rais...
bcd093e3d49db48dd32765b477f4f7438230b4fc
695,328
def read_players_positions(positions_file): """ Read players positions """ # Show info to CLI print("[Players Positions] Reading...") # Initialize dictionaries dict_timestamp = {} dict_game_frame = {} # Used to normalize data inside the same game_frame (each of 23 entry will have ...
6a729c683849935d43d77631b17952a4eea6d375
695,329
def is_array(type_ir): """Returns true if type_ir is an array type.""" return type_ir.HasField("array_type")
ac51de921484113d56923cea74324470706883b7
695,330
def parse_input(event): """Parses all input required from step function.""" input_request = event["input"] return { "batch_id": input_request["transformation_step_output"]["batch_id"], "output_sns_arn": input_request.get("destinationSnsArn"), "execution_id": event["execution_id"], ...
ed85b61e7c9e68dbbee910d7d6c1eaf342255aa0
695,331
import itertools def flatten(l): """ Function to flatten a list. """ return list(itertools.chain.from_iterable(l))
3db376d039ca5b51ac10ea4ce673bd72b04b4b2b
695,332
def compute_wap(inner, outer): """Computes the wall area percentage (WAP) from the inner and outer airway measurements.""" return (outer - inner) / outer * 100
379e0dcd1729e34e39295988c94640378d128103
695,333
from typing import Union from pathlib import Path import os def build_path(path: Union[Path, str], path_is_absolute: bool = False) -> Path: """ This function build Path instance from arguments and returns it. :param path: path :param path_is_absolute: if True, use path as absolute :return: Path in...
92aaf148411a915663d3c1b8b3183d4edae7d243
695,334
def arrival_1(): """ Packets arrive with a constant interval of 1.5 seconds. """ return 1.5
2c7a6cee521ae18ce06f07b8b694c322fadd55ea
695,335
def pkcs5_unpad(data): """Do PKCS5 unpadding to data and return """ data_bytes = bytes(data) return data_bytes[0:-data_bytes[-1]]
7058f51e456c8dbe8b4c9c4cd9e26bc7f27efaf6
695,336
from typing import Counter def mostCommon(armies): """ Returns the most common army """ common = [a for a,c in Counter(armies).most_common(2) if not a.isDefeated()] if len(common): return str(common.pop()) else: return ""
596e1b772a7fbb1e048e3c17c0e0a08a0d0f2b2d
695,337
import os def clean_path(path): """Get a file path for the FLAC file from a FLACCue path. Notes ----- Files accessed through FLACCue will still read normally. We just need to trim off the song times. """ if('.flaccuesplit.' in path): splits = path.split('.flaccuesplit.') t...
1b21cf166c4ff072050538a4bb391a0a48b5c456
695,338
import re def remove_comments(string): """ Removes /**/ and // comments from a string (used with the control script). From http://stackoverflow.com/questions/2319019/using-regex-to-remove-comments-from-source-files """ string = re.sub(re.compile("/\*.*?\*/",re.DOTALL ) ,"" ,string) # remove all oc...
3f04a554de57517951d65396e998e29dd18b22b8
695,339
def dash_case(name): """ Convert a camel case string to dash case. Example: >>> dash_case('SomeName') 'some-name' """ letters = [] for c in name: if c.isupper() and letters and letters[-1] != "-": letters.append("-" + c.lower()) else: lett...
5fbe7aa6f3e0b063a572e57b4b3000bb7835355f
695,340
import string def tamper(payload, **kwargs): """ Converts all characters in a given payload (not processing already encoded) Reference: https://www.acunetix.com/vulnerabilities/unicode-transformation-issues/ >>> tamper('SELECT FIELD FROM TABLE WHERE 2>1') 'SELECT%C0%AAFIELD%C0%AAFROM%C0%AATA...
e2215bc0e23a8deab52d211a72ca3c3efef968c8
695,341
from datetime import datetime def get_formatted_updated_date(str_date): """ converting 2015-08-21T13:11:39.335Z string date to datetime """ return datetime.strptime(str_date, "%Y-%m-%dT%H:%M:%S.%fZ")
b0d20010a1748d470d23452c959f18aa124d9ddb
695,342
import numpy def triangle_bump(t_array, t_start, t_stop, peak_value): """ Creates a symmetrical triangular bump starting at t_start and ending t_stop with peak height of peak_values. Arguments: t_array = array of time points t_start = time at which bump starts t_st...
2720f7315757c4ce032907fde02b0ae3bc8ac6f8
695,343
def is_on_filesystem(entry, filesystem): """ Check if a certain element is on a certain type of filesystem :param entry: a dfvfs PathSpec object :param filesystem: dfvfs type indicator string :return: True if the specified filesystem is somewhere in the path-chain of the element """ path = e...
d402edf7629c05be4308e04965b9b54e1c9a3272
695,344
import struct def ReadCollapsedSequences(trace, cache_filename): """ Read the collapsed sequences from file if they exist. @params cache_filename: the file that conatains the cached data. """ # get the dataset for this trace dataset = trace.dataset # first read the node mapping nnodes...
9ce5e5087d2daa40d90c8c3549b8cab7277ad1ee
695,345
def ComputeSemiMinorAxis( efit, smarange=None ): """For Bender-style ellipse-fits only! Re-computes semi-minor axis b, based on ellipticity and semi-major axis. Optionally, the range of semi-major axes for which b is recomputed can be specified via smarange (only semi-major axis values >= smarange[0] and <= smara...
1465175bd83499e1369c90cd7d2570e117abe941
695,346
def fake_join(a, *p): """ Lifted from the POSIX implementation of os.path, for testing purposes. """ path = a for b in p: if b.startswith('/'): path = b elif path == '' or path.endswith('/'): path += b else: path += '/' + b return ...
824b9cef3585f6bf9985931f9fcf3a0315acd614
695,348
def remove_return(seq): """ Remove return characters args: seq: String output: seq: String """ return seq.replace("\n", "").replace("\r", "").replace("\t", "")
6179c18d0c1719538abd9dc7f753c627db2e02fa
695,349
import re def extract_value(content, key, is_int_value=True, delimiter='=', throw_not_found=False, default_value=-1): """ Extracts a key from content, value can be an integer or string Args: content (str): the full given text content key (str): the wanted key to be searched in the given co...
29386c9995d042f7c36118ca80cb4f2f335accfc
695,350
def line_has_sep(line): """Line has a `-` before a `=` """ a = line.find('-') # not header b = line.find('=') # header if a == -1: # No `-` return False elif b == -1: # No `=`, but `-` return True else: return a < b
61b9a8fa77dda3197abf1765cf50801f90d82251
695,351
import collections def get_history_naming_package_numbers(data, commit, date): """Get number of packages for each naming policy violation. """ result = [] progress = collections.Counter( 'Misnamed Subpackage' if package['is_misnamed'] else 'Blocked' if package['blocked_requires'] else...
a50e576341100993b28e8ce7b395616ac6082196
695,353
import torch def getOptimizer(model, lr, weight_decay): """Optimizer for training""" return torch.optim.Adadelta(model.parameters(), lr=lr, weight_decay=weight_decay)
20b878320692b44aa512d47f0b4d736acb1f86ea
695,354
def find_present_and_absent_index(src_str, keyphrase_str_list, use_name_variations=False): """ :param src_str: stemmed word list of source text :param keyphrase_str_list: stemmed list of word list :return: """ num_keyphrases = len(keyphrase_str_list) #is_present = np.zeros(num_keyphrases, dt...
4d59d27da68def7af02ea9e5d658330a6e32525b
695,356
import warnings def push(root: dict, item: str) -> dict: """ Inplace 'pushing' the given item into the root dictionary into a key consisting of an index in between 0 to 1000. Args: root(dict): Root dictionary to push `item` in. item(any): Item to be put into t...
b6a24d2330020c4c7b71fb17a852f3e3e61a8a70
695,357
def deselect(elements=None): """ Deselects the given elements. If no elements are passed then all elements are deselected. :param elements: List of elements to deselect. If none are given then all elements are deselected. :type elements: list(Element, Element, ...) :return: None ""...
36f730f5cf95d976fa0b49d7be62a54789781d05
695,358
import six import json def json_decode(data): """ Decodes the given JSON as primitives """ if isinstance(data, six.binary_type): data = data.decode('utf-8') return json.loads(data)
8a1593790fefbffa016168a23a30300ba1751dcd
695,359
import os def get_sub_list(file_list, dirname: str): """ 去除父路径,获得子路径:file_list = file_list - dirname :param file_list: :param parent: :return: """ dirname = dirname[:-len(os.sep)] if dirname.endswith(os.sep) else dirname for i, f in enumerate(file_list): if dirname in f: ...
e27195807cd264852aed286f16bd5894655d9790
695,360
def _w_long(x): """Convert a 32-bit integer to little-endian.""" return (int(x) & 0xFFFFFFFF).to_bytes(4, 'little')
4cd2c9b3e57f8c4dbd100ef00af6cc51480dc683
695,361
def Split_Info(info): """Splits necessary information out from the info vcf column Parameters ---------- info : Series Info column from a vcf as a series Returns ------- dict A dict of necessary fields and their values from the vcf """ fields = ['QD=', 'MQ=', 'MQRa...
e58d2dad51d34a7644a7d5bf307449194aec9ca3
695,362
from typing import List import random def injectFaults(mat: List[List[int]], error_map: List[List[float]], b: int) -> int: """Inject faults into an MLC matrix Args: mat (list): Matrix to inject faults into error_map (dict): Error map dictionary b (int): Bits per cell Returns: ...
b7c158c6bd5fe856115af13e652b513a2aadae5f
695,363
import time def get_download_file_name(node_type, node_name, slot): """Get file name.""" timestamp_carry = 100 file_name = "{}.{}.0.0.{}.output.{}.NONE.npy".format(node_type, node_name, round(time.time() * timestamp_carry), slot) return file_nam...
73859916094de59958626cdb9e5cea00403758ab
695,364
def add_dividers(row, divider, padding): """Add dividers and padding to a row of cells and return a string.""" div = ''.join([padding * ' ', divider, padding * ' ']) return div.join(row)
7cbe235ddf8c320cadfcc4b4a3f17a28c2aaac1c
695,365
import re def name2label(name, schema=None): """ Convert a column name to a Human Readable name. borrowed from old TG fastdata code """ # Create label from the name: # 1) Convert _ to Nothing # 2) Convert CamelCase to Camel Case # 3) Upcase first character of Each Word # Note...
7d939514acaabec18790380f13bb042344986508
695,366
def is_transpose_identity(perm): """ Tells if the permutation *perm* does nothing (itentity). :param perm: permutation :return: boolean """ return list(perm) == list(range(len(perm)))
09bc1fd0577297b1f9450c7f2f215197ae8ce3ee
695,367
import math def rta3(rts): """ RTA3 -- "Computational Cost Reduction for Real-Time Schedulability Tests Algorithms" http://ieeexplore.ieee.org/document/7404899/ """ wcrt = [0] * len(rts) a = [0] * len(rts) i = [0] * len(rts) schedulable = True flag = True for idx, task in enum...
3b23678731ca4b9eeaf9076a346af724073f62de
695,368
def Get(x, start, end=None, step=None): """ iterable >> Get(start, end, step) Extract elements from iterable. Equivalent to slicing [start:end:step] but per element of the iterable. >>> from nutsflow import Collect >>> [(1, 2, 3), (4, 5, 6)] >> Get(1) >> Collect() [2, 5] >>> [(1, 2, ...
7d46a94aca43f8d2bea691df4f1c3d6498bd3339
695,369
from typing import List import difflib def compare_files(path1: str, path2: str) -> List[str]: """Returns the delta between two files using -, ?, + format excluding lines that are the same Args: path1 (str): Path to first file path2 (str): Path to second file Returns: List[st...
2f8df203f3db161313ab2427f17e5db964f27f25
695,370
def append_custom_fields(json_blob): """Append x_mitre custom fields to Description.""" for obj in json_blob: if 'x_mitre_collections' in obj['attributes']: del obj['attributes']['x_mitre_collections'] return json_blob
e62a0d7c64391052921905f25d8442f0114e91ac
695,371
import argparse def get_argparser_ctor_args(): """ This method returns a dict containing the kwargs for constructing an argparse.ArgumentParser (either directly or as a subparser). """ return { 'prog': 'CodeChecker version', 'formatter_class': argparse.ArgumentDefaultsHelpFormatte...
5b3444d7e07e645de9ea892236272df02e3c2857
695,372
def _switch(mthread, local, sync, mproc): """ A construct needed so we can parametrize the executor fixture. This isn't straightforward since each executor needs to be initialized in slightly different ways. """ execs = dict(mthread=mthread, local=local, sync=sync, mproc=mproc) return lambd...
1ee45a6faf29d46e4ecc76fd50a5f92735d66107
695,373
import torch def logaddexp(x, y): """Compute log(e^x + e^y) element-wise in a numerically stable way. The arguments have to be of equal dimension. Arguments --------- x : :class:`torch:torch.Tensor` y : :class:`torch:torch.Tensor`""" maxes = torch.max(x, y) return torch.log(torch.exp(x...
e7160562fd0d3db6d7596577d42aee5116470051
695,374
def takes_router(func): """ Decorator that marks a function or class method to automatically receive a kwarg named `router`, referencing the :class:`mitogen.core.Router` active in the context in which the function is being invoked in. The decorator is only meaningful when the function is invoked via...
113fe6b719867ccb3841eda426e8ec1cc04f89c1
695,375
def word_count(text): """ The word-count of the given text. Goes through the string exactly once and has constant memory usage. Not super sophisticated though. """ if not text: return 0 count = 0 inside_word = False for char in text: if char.isspace(): inside_w...
18aef06c928ab9db30ba5c0c062dfa068180c99a
695,376
def find_homology(long_seq, short_seq): """ :param long_seq: str, the base DNA sequence user wants to search in with all upper case characters :param short_seq: str, the DNA sequence user wants to match with all upper case characters :return: the homology in long_seq """ homology = '' simila...
11dedba1584003174d9c8f8ba51adf99dde17f8c
695,378
def convert_units(arg, unit): """Checks compatibility and converts units using simtk.units package Args: arg (Quantity): quantity to be converted unit (Unit): Unit to be converted to Returns: arg (Quantity): Quantity scaled to the new unit """ conversionFactor = (arg.unit)....
a5148d66247c41089bd01c11f7debfb955d67119
695,379
def omniscidb_to_ibis_dtype(omniscidb_dtype): """ Register OmniSciDB Data Types. Parameters ---------- omniscidb_dtype : OmniSciDBDataType Returns ------- ibis.expr.datatypes.DataType """ return omniscidb_dtype.to_ibis()
598eeb9ec7efc495f19035145054621b94b8f069
695,380
def _canonicalize_extension(ext): """Returns a transformed ext that has a uniform pattern. Specifically, if ``ext`` has a leading . then it is simply returned. If ``ext`` doesn't have a leading . then it is prepended. Exceptions to this are if ``ext`` is ``None`` or "". If ``ext`` is "" then "" is r...
935e85fd9a0f1bcfadc68c2390446ecbc814a0bc
695,381
def min_laboratories(**kwargs): """ Максимальный вес груза, прибывшего в порт. На вход поступает название судна и общий вес груза Функция выводит название судна, которое прибыло с грузом наибольшего веса """ if kwargs: max_weight = max(kwargs.values()) for vessel, weight in kwargs...
9d429dd6ebb65bd71c31644d231c2a878d71ce3a
695,382
def get_dictionary_from_list(list_to_search, key, search_value): """ Find a dictionary in a list of dictionaries based on a certain key's value Parameters ---------- list_to_search: list List of dictionaries to search in key: str The key in the dictionaries to look for the value...
9683ccaa9e0b0310aadc519f0067c921112f820c
695,383
def cname(s): """ make name s C-friendly """ for c in "-+.": s = s.replace(c, "_") return s.upper()
7ec03dd504f67a897d53280440d09454e5a0b601
695,384
import logging import sys def gen_logger(name, log_level): """Create a logger to be used between processes. :returns: Logging instance. """ logger = logging.getLogger(name) logger.setLevel(log_level) shandler: logging.StreamHandler = logging.StreamHandler(sys.stdout) fmt: str = '\033[1;32...
cc3f5bef62ea5d9cf97f3ed03bfe4f44dddbe451
695,385
import subprocess import json def read_go_deps(main_packages, build_tags): """ read_go_deps returns a list of module dependencies in JSON format. Main modules are excluded; only dependencies are returned. Unlike `go list -m all`, this function excludes modules that are only required for running t...
cb1f9ef5bf2f3d0090287521129d7e77fde0fc73
695,386
def list_stringify(inlist): """Recursively rebuilds a list - making all the members strings... Useful before writing out lists. Used by makelist.""" outlist = [] for item in inlist: if not isinstance(item, list): if not isinstance(item, str): thisitem = str(item) ...
92ae1e1e08d195b7af282d62986045d661663f90
695,387
def message_relative_index(messages, message_id): """ Searches the relative index of the given message's id in a channel's message history. The returned index is relative, because if the message with the given is not found, it should be at that specific index, if it would be inside of the respective cha...
6b7b98de79bc18a531b15bacae326b242710d121
695,388
def _string(self) -> str: """Returns string representation of Path.as_posix()""" return self.as_posix()
3897e5bd1f689f706b51653f6fd9f588d6d3bb54
695,389
import time def get_dbus_proxy_obj_helper(request, get_environment, get_bus): """ Returns dbus proxy object connected to org.scarlett @ /org/scarlett/Listener # noqa ProxyObject implementing all the Interfaces exposed by the remote object. """ time.sleep(2) print( "[get_dbus_proxy_ob...
8384efc96da9efdd6113e7156574cfedf6f5626e
695,392
def gcd(*args): """Calculate the greatest common divisor (GCD) of the arguments.""" L = len(args) if L == 0: return 0 if L == 1: return args[0] if L == 2: a, b = args while b: a, b = b, a % b return a return gcd(gcd(args[0], args[1]), *args[2:])
0d425e9fb35e824bcd946d68dbac31f9d87d020f
695,393
import os def get_shapelists(root): """ :param root: a path/folder of shape files :return: a dictionary of files' names """ catfile = os.path.join(root, 'ShapeLists.txt') filetitles = {} with open(catfile, 'r') as f: i = 0; for line in f: filetitles[line.strip(...
81837091add7a74b6911380ce8cefb76acd4fac1
695,394
import numpy def quaternion_multiply(quaternion1, quaternion0): """Return multiplication of two quaternions. >>> q = quaternion_multiply([4, 1, -2, 3], [8, -5, 6, 7]) >>> numpy.allclose(q, [28, -44, -14, 48]) True """ w0, x0, y0, z0 = quaternion0 w1, x1, y1, z1 = quaternion1 return n...
3767aec912253437e26293bacc4223aa877f406f
695,395
def testTelescopes(k, telescopes): """ k: a telescope, baseline or triplet (str) eg: 'A0', 'A0G1', 'A0G1K0' etc. telescopes: single or list of telescopes (str) eg: 'G1', ['G1', 'A0'], etc. returns True if any telescope in k assumes all telescope names have same length! """ ...
bd3d4ef02c3fa059869ced2a17b9edb3b993d6b0
695,396
import torch def _squash(input_tensor, dim=2): """ Applies norm nonlinearity (squash) to a capsule layer. Args: input_tensor: Input tensor. Shape is [batch, num_channels, num_atoms] for a fully connected capsule layer or [batch, num_channels, num_atoms, height, width] or [batch...
715b5819498d4c3a7c40c623fc9a40d2fcfb3773
695,397
def sort_key(key): """ Quick wrap of key for sorting usage: >>> list_ = [{"a": 1, "b": 3}, {"a": 2, "b": 0}] >>> sorted(list_, key=sort_key("b")) [{"a": 2, "b": 0}, {"a": 1, "b": 3}] """ return lambda i: i[key]
01657ca8b2865f061b530d58b706020f7f9825b1
695,398
def is_valid_variable_name(name: str) -> bool: """ All single-letter, uppercase variable names are reserved. """ if len(name) == 1 and name.upper() == name: return False if not name.isidentifier(): return False return True
27459ec71782ff7f0a0c9a8e4f29fc548c398f71
695,399
def crop_image(data, header, scale): """ Crop the image in the given HDUList around the centre point. If the original size is (W, H), the cropped size will be (scale * W, scale * H). """ if scale < 0 or scale > 1: raise ValueError("scale must be in [0, 1]") # idx, data = get_data_index(h...
e2145b3953565ec75437e5fb7df759bc6e15746c
695,400
import argparse def option_handler(): """Validates and parses script arguments. Returns: Namespace: Parsed arguments object. """ parser = argparse.ArgumentParser(description="Create json file of all packs dependencies.") parser.add_argument('-o', '--output_path', help="The full path to s...
94c8bd195ef4fdc0111c7fd77efa14869bb539b4
695,401
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter def get_parser(): """Return the parser object for this script.""" parser = ArgumentParser(description=__doc__, formatter_class=ArgumentDefaultsHelpFormatter) return parser
93c940b6048a4dc3e715094d683dd698a7f8c54e
695,402
import itertools def all_combinations(samples_list): """ returns all combinations in the list given """ iterable = itertools.chain.from_iterable(itertools.combinations(samples_list, r) for r in range(len(samples_list) + 1)) combinations = [] for i in iterable: combinations.append(list(...
0a1be4fb2cca86e8682acf05f51fc11ec5dcbbae
695,406
import os def symlink_copy(src, dst): """Makes an absolute symlink from src to dst. :param str src: The file to which the symlink will point. :param str dst: The symlink file to create. """ src = os.path.realpath(src) return os.symlink(src, dst)
eff73f65a27d8c34c89a5e645f24f6b2939c406c
695,407
def time_to_str(time_in_seconds): """ Takes a time in Seconds and converts it to a string displaying it in Years, Days, Hours, Minutes, Seconds. """ seconds = time_in_seconds minutes = None hours = None days = None years = None if seconds > 60: minutes = seconds // 6...
ac79955ae1745180719de7260ad1f3e4e3f7f1e3
695,408
import torch def kernelize_with_rbf(d, mu, gamma=1.0, eps=1e-6): """ Takes a distance matrix `d` of shape `[n_batch, n_particles, n_particles, 1]` and maps it onto a normalized radial basis function (RBF) kernel representation of shape `[n_batch, n_particles, n_particles, n_kernels]...
64286bad845eec3da58752f53f51a97083bee91b
695,409
import csv def readData(fileName): """ Remark Very bad implementation. Could be improved by using iter() and reading file in chunks. This method reads the data file into list of lists returns List<List<str>>, int """ a...
44b787dd69070e93a912d9def4d10e01fc9495ea
695,410
def run(df, dt): """General warpper function to claculate folds by scaffold Args: df (DataFrame): Dataframe with standardized smiles Returns: Tuple (DataFrame, DataFrame): a datframe with successfully calculated fold information, datafarem with failed molecules """ return dt.proces...
8d6f793f22511ba2ca2923de1c6dbfb1c986ba1d
695,411