content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
import os def get_key(audio_file): """ Given an audio file path, return its ID. """ return os.path.basename(audio_file)[:-4]
ca85360f2da8a02068a90e8cdbe4605aa89e1997
693,050
def convert_back_to_year(val): """ get something between 0 and 1, return a year between 1922 and 2011 """ assert val >= 0 and val <= 1 return 1922. + val * ( 2011. - 1922. )
3e378b53063503a5c4ffb13e4bdecc235bf10042
693,051
import random from uuid import uuid4 def reproduce_agents(params, substep, state_history, prev_state): """ Generates an new agent through an nearby agent pair, subject to rules. Not done. """ # 3rd Party # 1st Party get_free_location = prev_state['utils']['get_free_location'] nearby_a...
4f7b8844e3ee017e53864ae62179dcc91b412b40
693,052
import time def datetime_to_ms(dt): """ Convert an unaware datetime object to milliseconds. This will be a UTC time. The SMC stores all times in UTC and will do the time conversions based on the local timezone. Example of converting a datetime to milliseconds:: utc_time = datetime.str...
4fe473d0a563c54846e1f0be8d9fc879883c0122
693,053
def unexcused_marker(events_unexcused): """ if the brother has 3 or more unexcused absences the first column of the row is marked for the secretary's ease of viewing/use. Puts 3+, 5+, and 7+ as depending on the number of unexcused absences. :param list[Event] events_unexcused: a list of events that...
cfebc80b735a60577ff509592daa0bf9b3d10867
693,055
def _to_list(val): """Return the variable converted to list type.""" if isinstance(val, list): return val else: return [val]
4fddae97a267fd879182cec75b1fdb553a892857
693,056
import os def setup_base_cache(): """Set up the base cache directory. Returns: str: The path to the base cache directory. """ if os.environ.get('POPPER_CACHE_DIR', None): base_cache = os.environ['POPPER_CACHE_DIR'] else: base_cache = os.path.join( os.environ.ge...
7993193af481e97c58f955292979ecbe94c33888
693,057
def get_networks(vcenter, the_vm, username): """Obtain a list of all networks a VM is connected to. :Returns: List :param vcenter: An established connection to vCenter :type vcenter: vlab_inf_common.vmware.vcenter.vCenter :param the_vm: The virtual machine that owns the specific NIC :type the...
a2c6d691fe0ebe1bc77a1a17f05de4ed4e7c342c
693,058
def L6_summary_createseriesdict(cf,ds): """ Purpose: Create a dictionary containing lists of variables, operators and formats for use by the daily, annual and cumulative routines. Usage: series_dict = L6_summary_createseriesdict(cf,ds) where cf is a control file object ds is an...
7355292aa0c3829ecfbecb1acc1af28d4152b2d7
693,059
def get_dotted(data, path): """access nested dict by dotted helper""" parts = path.split('.') if len(parts) == 1: return data.get(parts[0]) if (parts[0] in data) and isinstance(data[parts[0]], dict): return get_dotted(data[parts[0]], '.'.join(parts[1:])) return None
4b33c9ea1a87c2de75c5f3b3e7b375d5ac6049ba
693,060
def dscp_to_tos(dscp): """Convert dscp value to tos.""" tos = int(bin(dscp * 4), 2) return tos
02e644bbb04beb7f588e1cdf3f8661957325b588
693,061
def should_inject_custom(code_info): """Returns True if the code looks like suitable to inject our custom stuff into it. """ return code_info.command == 'custom'
518525112e2e5c7dfe5dcb85c9e2496b44822900
693,062
import re def build_match_and_apply_functions(pattern, replace): """Assemble regex patterns.""" def matches_rule(word): return re.search(pattern, word) def apply_rule(word): return re.sub(pattern, replace, word) return matches_rule, apply_rule
8ca7d1626f519e19e086eb60260b8d968229b4cf
693,063
import re def repl(lookup, string): """Replaces keywords within a string. Args: lookup: dict in which to look up keywords. string: string with embedded keywords. Ex. %key%. Return: String containing the replacements.""" return re.sub("%([\w_]+)%", #If it is not in the lookup, leave it alone ...
6d74a90e05f83240b5e02f3f076124d8e9061c2d
693,064
def sort_files(files): """Returns a sorted version of the given list of File's (or other structures that define an 'id' data member). The files will be sorted according to their id, and duplicate entries will be removed. Parameters ---------- files : list of :py:class:`bob.db.base.File` The list of f...
3ada6e925da246ff31ef63fdb863e9318ac17792
693,065
from typing import Union from pathlib import Path import re def _alter_spark_sql(sql: str, hadoop_local: Union[str, Path]) -> str: """Handle special paths in SQL code so that it can be used locally. :param sql: A SQL query. :param hadoop_local: The local path of Hadoop. :return: The altered SQL code ...
83389ac58f0e976119274654f2078ed2e5c3ae47
693,066
from datetime import datetime def from_timestamp(timestamp: str) -> datetime: """Parses the raw timestamp given by the API into a :class:`datetime.datetime` object.""" return datetime.strptime(timestamp, "%Y%m%dT%H%M%S.000Z")
81d3c0a5297fa0053ae9a951147fac6f46907956
693,067
def format_action(a): """ Convert Action object into string representation for pompdp file e.g scan machine (0, 0) 0.0scan e.g. exploit service 1 on machine (1, 0) 1.0exp1 """ address = "a{0}{1}".format(a.target[0], a.target[1]) if a.is_scan(): return address + "sca...
b701538922db069ba550bfa6abeeb2fed02ce30a
693,068
import re def get_win_valid_filename(filename: str, sub: str = '') -> str: """ 获取windows合法文件名 """ patn = r'[\\/:*?"<>|\r\n]+' if sub and re.match(patn, sub): sub = '' return re.sub(patn, sub, filename)
39b87113ed391e90d52a4e17d319fb6e7f2f62a2
693,069
def pos_next_to(pos_a, pos_b): """ Test if two positions are next to each other. The positions have to line up either horizontally or vertically, but positions that are diagonally adjacent are not counted. """ xa, ya = pos_a xb, yb = pos_b d = abs(xa - xb) + abs(ya - yb) return d ==...
eae09addf8a119c5ce9f401af8703068ea98c8c9
693,070
def wemo_entity_suffix_fixture(): """Fixture to select a specific entity for wemo_entity.""" return ""
525db1d0c74ce5bc09991cd11c31275069622687
693,071
import random import string def gen_dummy_object(class_, doc): """Create a dummy object based on the definitions in the API Doc.""" object_ = { "@type": class_ } if class_ in doc.parsed_classes: for prop in doc.parsed_classes[class_]["class"].supportedProperty: if "vocab:" ...
86e981c7f62ccddda0463145c825d43dc1c3c476
693,072
def getStringsFromFile(list_file): """"Return list from file ignoring blanks and comments""" l = [] with open(list_file) as f: for line in f: line = line.strip() if len(line) > 0 and not line.startswith("#"): l.append(line) return l
456604f0a431e67a6c9806de421d9032893fbcaf
693,073
def remove_pruning(module, name='weight'): """Embed mask to the pruned weight and remove the pruning method""" module.get_pruning_parameters('method', name=name).remove() return module
57ac4f6a5fe63e560323bd4b47864472203dd936
693,074
import torch def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1, padding=0): """3x3 convolution with padding""" return torch.nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=padding, groups=groups, bias=False, dilation=dilation)
9df1275c4b671e8f97c9831323fd32a3916a6652
693,075
def remove_moves_occupied(state, moves): """ Prende una lista di mosse e rimuove le posizioni già occupate guardando la board (state.board) :param state: :param moves: :return: """ for index, value in enumerate(state.board): if value != 'O': if index in moves: ...
48ab5fadf06152c99d0c4d05eb6ef615abf55e28
693,076
def scale01(arr): """ Linearly scale the values of an array in the range [0,1] :param arr: input ndarray :return: scaled ndarray """ return arr / arr.max()
335f6fdb96fc47facab63827322816382280bfbe
693,077
def get_value(): """ Function that just returns a number. :return: 4 """ return 4
8dd3282bd48551abb1e38420d7eceffcb5a0f059
693,078
def find(haystack, needle): """ >>> find("ll", "hello") -1 >>> find("", "") 0 >>> find("hello", "ll") 2 >>> find("aaaaabba", "bba") 5 >>> find("bbaaaaaa", "bba") 0 >>> find("aaaaa", "bba") -1 """ m = len(haystack) n = len(needle) if m < n: retu...
a3ac03b1cd80368112f47f0333e4513641c0c820
693,079
import os def _get_lines_from_file(filepath): """ Reads dependency:tree command output file """ if os.path.isfile(filepath) is not True: return None rstripped_lines = [] with open(filepath, 'r') as f: lines = f.readlines() for line in lines: rstripped_lines.app...
b1e3acd13e6b7a6a9f0552e27af3e3216847d740
693,080
def _args_to_str_func(handler, v, scope, context, path): """Used to display extra information when recursion limit is reached. This is the message-creating function used with an _EvaluationHandler, so it takes the same arguments as that. """ return "Limit was reached with the following path - {0}".f...
db386853e1cf419d63ec1670f6e077c1d4f90094
693,081
import base64 def _encode_key_id_from_hashed(hashed: bytes) -> str: """Encode the 30 bytes hash of the public key data. First encode the hash with base32, then divide into 12 groups like so: ABCD:EFGH:IJKL:MNOP:QRST:UVWX:YZ23:4567:ABCD:EFGH:IJKL:MNOP :param hashed: :return: """ s = ba...
532a34c56311a3fc5a43f45e4b9df8d65b0bae48
693,082
import argparse def get_args(): """ Get arguments from command line with argparse. """ parser = argparse.ArgumentParser( prog='aligned_bam_to_cpg_scores.py', description="""Calculate CpG positions and scores from an aligned bam file. Outputs raw and coverage-filtered results i...
2be055082af4ad3ff6cd9b37d31bdb87650943ef
693,083
from datetime import datetime def return_published_date(entry): """ブログ記事の公開日を返す ドラフトの場合も返される仕様だった """ publish_date_str = entry.find( "{http://www.w3.org/2005/Atom}published" ).text return datetime.fromisoformat(publish_date_str)
08ef7ab2d7c2d63cb20c5e6bc29504fd8050705b
693,084
def to_plotly_rgb(r, g, b): """Convert seaborn-style colour tuple to plotly RGB string. Args: r (float): between 0 to 1 g (float): between 0 to 1 b (float): between 0 to 1 Returns: a string for plotly """ return f"rgb({r * 255:.0f}, {g * 255:.0f}, {b * 255:.0f})"
a08723dda4be60609bc60498fb1879b876eea71f
693,085
def manage_keywords(d): """ split and iterate over keywords :param d: dictionary that contains the keywords extracted from the configuration file :return: a dictionary with mutually combined keywords """ keylist = d.keys() for key in keylist: if " " in key: kv = key...
f74309dc9d54b374dc058be190bb84b386962dce
693,086
import pickle def load_annotation_file(filename): """ Load the annotation file. """ return pickle.load(open(filename, 'rb'))
d418eb6ac5f2842d7cef505a48e553aeed366796
693,088
def echo(): """test double for asserting on the lines that would get send to click.echo""" class _echo: lines = [] def __call__(self, line): self.lines.append(line) return _echo()
c514422a3cb7b7c9d034070c8739e4698223b79f
693,089
import numpy def scatpratt(x,y,errx,erry,a,b): """ This is an alternative way of computing the "raw" scatter about the best-fit linear relation in the presence of measurement errors, proposed by Pratt et al. 2009, A&A, 498, 361. In the words of Cavagnolo et al. (2010): *We have quantified the total scatter abou...
f603e303bb4f044445c47ad365fe63a3c700c9b6
693,090
import os import re def find_amiga_os_39_iso_file(os39_dir): """Find Amiga OS 3.9 iso file""" # return none, if os39 dir doesn't exist if not os.path.exists(os39_dir): return None # get amiga os 3.9 iso files from os39 directory amiga_os_39_iso_files = [os.path.join(os39_dir, _f) for _f ...
8b1ed1f73072c60efd6b6de4f907740ec725a64f
693,091
import torch def linspace(start: torch.Tensor, stop: torch.Tensor, num_samples: int) -> torch.Tensor: """Generalization of linspace to arbitrary tensors. Args: start (torch.Tensor): Minimum 1D tensor. Same length as stop. stop (torch.Tensor): Maximum 1D tensor. Same length as sta...
44155176573f276937b10292cc11f45de1d0d277
693,092
def contains_all_value(page): """ Validate if both title and text are set Returns -------- bool True if all values are set False if not all values are set """ if len(page.getElementsByTagName('title')) == 0: return False if len(page.getElementsByTagName('text...
d2098f9db6cf98cdaf29e0c57438814c8339b095
693,093
import math def calculate_trigonometric_function(radian_x: float) -> float: """This function refer to Taylor's theorm. A remainder for cos or sin at radian_x follows Cauchy's remainder. The function has 2 steps. Step1 get a degree of Taylor polynomial function at radian_x. Step 2 calculates sin and co...
0fb5e85cf218613671a1246523dab7883a6d0d0e
693,094
import os def read_version(): """Read the library version""" path = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'code_advent', '_version.py' ) with open(path) as f: exec(f.read()) return locals()['__version__']
064d176daf91f32280104815ddd4dab9666c3863
693,095
import torch def sparsity_ch(tensor): """Channel-wise sparsity for 4D tensors""" if tensor.dim() != 4: return 0 num_filters = tensor.size(0) num_kernels_per_filter = tensor.size(1) # First, reshape the weights tensor such that each channel (kernel) in the original # tensor, is now a ...
59094a3a2b6d80f5393b56f5eaaf70d3d261ab79
693,096
def getPersonURL(person): """ Return the address the view for this Person is available at. """ return person.organizer.linkToPerson(person)
a7836e80ba92c16011742a49b5d8ce1cc91d8996
693,097
import re def parse_paren_list(row): """Parses the nested list of attributes at the start of a LIST response""" # eat starting paren assert(row[0] == '(') row = row[1:] result = [] # NOTE: RFC3501 doesn't fully define the format of name attributes name_attrib_re = re.compile("^\s*(\\\\[a...
c3f264a1bdc4f5e1df5c03cb6469ff6c920832da
693,098
import numpy def absdeg(deg): """Change from signed degrees to 0-180 or 0-360 ranges deg: ndarray Movement data in pitch, roll, yaw (degrees) Returns ------- deg_abs: ndarray Movement translated from -180:180/-90:90 degrees to 0:360/0:180 degrees Example ------- deg ...
b0c51509c427596db88ad0af465db098075ef88e
693,099
def calc_sse(mod, meas): """ """ return ((mod-meas)**2).sum()
2563eed56d6b31cbba778960bc4682c3dd53d47c
693,100
def minus(*, alpha=None, omega): """Define monadic symmetric numbers and dyadic subtraction. Monadic case: - 1 2 ¯3 4J1 ¯1 ¯2 3 ¯4J¯1 Dyadic case: 1 - 3J0.5 ¯2J¯0.5 """ if alpha is None: alpha = 0 return alpha - omega
3e614ce62cfacded565a09865568cac8bfaa396f
693,101
def get_syslog_facility(facility): """ get_syslog_facility() -- Get human-readable syslog facility name. Args (required): facility (int) - Facility number. Returns: Name of facility upon success. "UNKNOWN" on failure. """ facilities = ( (0, "KERNEL"), (1, "U...
1508eba6b68d7e8c499effba6b678e29ded9f9ae
693,102
import re def _strip_product_code(api_version): """Strips the product code from the api version string.""" match = re.match(r"^([A-Z]+-)?([0-9]+)((\.[0-9]+)*)", api_version) if match is None: raise ValueError("Invalid build number: " + api_version) return match.group(2) + match.group(3)
3d978e7d280b4f88dc3e8daa2b256f840e8c4404
693,103
import os import json def load_multiple_pdf_ignore_list(): """ When a publication/revision has more than one pdf, use this result to get the pdfs that are duplicates, or they can be ignored. The pdfs that aren't main articles, and neither are in this list can be considered valious supplemental data. ...
64a26ee9e950137ffa639e653a8e04393b32ed08
693,104
def eurosat_norm(b, index): """ :param b: band to be normalized (2D array) :param index: index of the given band (int between 0 and 11) :return: normalized band """ mean_EuroSAT = [0.44929576, 0.4386203, 0.45689246, 0.45665017, 0.47687784, 0.44870496, 0.44587377, 0.44572416,...
245b4fcea80007226fb6d8784da107a7e8ab72db
693,105
def _define_binary_experiment_parameters(model_search_cv): """Define th binary experiment parameters.""" scoring = model_search_cv.scoring if isinstance(scoring, list): scoring_cols = ['mean_test_%s' % scorer for scorer in scoring] else: scoring_cols = ['mean_test_score'] group_keys ...
1d583fad1b6882841c6ceb7275138794662e0372
693,106
def find_by_key(target: str, data: dict) -> str: """ Returns the value of the target key from a nested Python dictionary. """ for key, value in data.items(): if isinstance(value, dict): return find_by_key(target, value) elif key == target: return value return ...
ce37416b4e5e36ccbe2a89938a74ada0a951d55e
693,107
from typing import List from typing import Any def reverse_list(L: List[Any], N: int) -> List[Any]: """Cuts the list after the N-th element and reverses its order. Parameters ---------- L : list List to be reversed. N : int Index at which the list will be cut if it is smaller than...
591f9e9cc5966a6a30d9ca0c7240575cfb488d5c
693,108
def add(path: str, content: str, encoding: str = "utf-8") -> int: """ add(path: str, content: str, encoding = "utf-8") -> int ---- Add content into file. Return amount of written symbols. If file doesn't exist, create it. """ with open(path, "a", encoding = encoding) as file: size = file.wri...
c225d5ec2c224250514ac3fc4fe358e70627eea5
693,109
def binary_to_int(x_bin: str) -> int: """ Inverse of `int_to_binary`. :Example: >>> binary_to_int('1010') 10 """ return int(x_bin,2)
f07c7cbb009d6a13e684801c217edd5cdaf98265
693,110
def convert_list_for_sql(my_list): """ Convert a python list to a SQL list. The function is primarly used when trying to format SQL queries by passing an argument. Arguments: my_list: list of elements to be used in a SQL query Example: 1. convert_list_for_sql([1, 2, 3]) returns '1, 2,...
a2c3d5f43b5a0ba6f52b7c0a086b5e68c74ba13f
693,112
def _runtime_maybe(ctx, variants): """Check predicates at runtime and return matched value or None.""" for value, predicate in variants: if callable(predicate): if predicate(ctx): return value elif predicate: return value
461480e21943d3c9cbd4b8afc45fc794fdb12850
693,113
def get_rows_greater_than_avg(df, column): """ Return all the rows(with all columns) where the value in a certain 'column' is greater than the average value of that column. row where row.column > mean(data.column) Args: df: A pandas DataFrame object representing the data. column: N...
02e414411c2e54cea1258af92436318d3a27500e
693,114
def read_line_in_str(line, number_of_loci): """ read str data in each line and check the format and data type (float); return information and STR-data separately. """ col = line.strip().split("\t") # check the column number if len(col) != (number_of_loci + 6): print("\tTermination!...
0ddfb60e57c034318e676bb1faa30ce724c9275e
693,116
def read_description(): """Read README.md and CHANGELOG.md.""" try: with open("README.md") as r: description = "\n" description += r.read() with open("CHANGELOG.md") as c: description += "\n" description += c.read() return description e...
877ef1be944827ca7d45a7b67e6edbe44d4c6dfb
693,117
def get_attrs(obj, config_attrs): """ Given an object obtains the attributes different to None. :param obj: object containing the attributes. :param config_attrs: a list of all the configurable attributes within the object. :return attr_data_dict: A dictionary containing all the attributes o...
18348e05d799406961169dcb195531b25fe03946
693,119
def asm_label(address): """ Return a local label name for asm at <address>. """ return '.asm_%x' % address
81a9f6a722b22bb0ccaaec9909e0e840baa7ab54
693,120
def get_danmaku(danmaku_queue): """Get a danmaku from a danamku queue. :param danmaku_queue: the queue to recieve danmaku. """ return danmaku_queue.dequeue()
f730d57ce2649174801a2365b5ea16001744ce41
693,121
def recipRank(cls, ranking): """ This function takes a class and returns its reciprocal rank score in the sorted association list of scores [(cls1,score), ..., (clsN,score)] 'ranking' (sorted in descending order by score). Note that the reciprocal rank for classes not in the ranked list of scores is...
1fe59a39b2076d7a3780f10601d07d3f815d6cae
693,122
from pathlib import Path def is_python(path: Path) -> bool: """Returns True if |path| ends in .py.""" return path.suffix == '.py'
dbedd33fad8ff4c1da84aef24b0cb7f4ef24f0cd
693,123
def get_integrated_intensity(ave_azav, peak_bin, delta_bin=3): """ Get the average integrated intensity. Sum the bin values from the peak bin to delta bin on each side. Parameters ---------- ave_azav: ndarray radially binned average azimuthal intensity from used curves peak_bin: i...
2367ef173591d3b887406d4f18ac3b0a788b0baf
693,124
def remove_restricted(list): """ Remove restricted (system) Amazon tags from list of tags """ clean_list = [] try: for dict in list: if 'aws' not in dict['Key']: clean_list.append(dict) except Exception: return -1 return clean_list
7168747c3a3dacc54a6ee70e64569708068d0091
693,126
def check_mirc_exploit(proto) -> bool: """Verifies that the nickname portions of the protocol does not contain any binary data. Vars: :proto: The text before the second : hopefully a nickname. :returns: True if there is binary data and False if it is clean. """ for let i...
065e646d4566190a9a3961be9cc4294976b8472e
693,127
def time_major(data): """ Return the data in time-major form (Most often used to turn a single batch into this form) *(Assumes the traces are already padded)* @param data is an array of sequences @return batch contains the batch in **time-major** form [max_time, batch_size] padded with the PAD symb...
dcd47e3eef8fd16f74494b816a6418db3536d4af
693,128
def program_representation(functionInfos): """Find program representation.""" keys = ['ft01_BBInMethod', 'ft02_BBWithOneSuccessor', 'ft03_BBWithTwoSuccessors', 'ft04_BBWithMoreThanTwoSuccessors', 'ft05_BBWithOnePredecessor', 'ft06_BBWithTwoPredecessors...
702cbc73d057f5c3554d8bbf037f067631d8bf01
693,129
import re def parse_params(path): """Parse a path fragment and convert to a list of tuples. Slashes separate alternating keys and values. For example /a/3/b/5 -> [ ['a', '3'], ['b', '5'] ].""" parts = re.split('/',path) keys = parts[:-1:2] values= parts[1::2] return zip(keys,values)
c79bc783374f314c00c559fb61879e7671eb8f5a
693,130
def circ_supply(height: int, nano: bool = False) -> int: """ Circulating supply at given height, in ERG (or nanoERG). """ # Emission settings initial_rate = 75 fixed_rate_blocks = 525600 - 1 epoch_length = 64800 step = 3 # At current height completed_epochs = max(0, height - fix...
3a0c1889ab5a0869ec4033d263489bbb08dd0864
693,131
import argparse def parse_args(): """ parse input args """ parser = argparse.ArgumentParser() # for local excel analysis parser.add_argument( "--log_path", type=str, default="./log", help="benchmark log path") parser.add_argument( "--device_name", type=str, ...
43333df986830dba63d252ebfc503304b80c43ae
693,132
import torch def pad_tensor(tensor, seq_len): """Pad tensor with last element along 0 dimension.""" sz = list(tensor.size()) sz[0] = seq_len - tensor.size()[0] % seq_len tail = tensor[-1].clone().expand(sz).to(tensor.device) tensor = torch.cat((tensor, tail)) return tensor
213593e4152dde391132b247a8f729fcbb284fec
693,133
def badtoken(t): """check if t is punctuation, space, or newline char""" return t.is_punct or t.text in [' ', '\n']
92432504e6d0f0fc0720747c7bf2e97b1fc59c90
693,135
def _get_labeled_order(logger): """Get the order in which papers were labeled.""" label_order = [] n_initial = 0 n_queries = logger.n_queries() for query_i in range(n_queries): try: label_methods = logger.get("label_methods", query_i) except KeyError: continue...
cac8124a486db63db66f2592d6675f47b35d5471
693,136
def segment_string_into_two(input_string, dictionary): """ Simple solution Assumes that a string can only be broken into 2 words """ n = len(input_string) for i in range(1, n): prefix = input_string[:i] if prefix in dictionary: suffix = input_string[i:] if suffix in dictionary: return prefi...
fe7b06a3305351739de8b6c28536293579d334a8
693,138
def _GetLoadBalancingScheme(args, messages, is_psc): """Get load balancing scheme.""" if not args.load_balancing_scheme: # The default is EXTERNAL for non-PSC forwarding rules. return None if is_psc else messages.ForwardingRule.LoadBalancingSchemeValueValuesEnum.EXTERNAL if args.load_balancing_scheme == '...
9704929ad28188e76bc066361af86c36bc3cede7
693,140
def _parse_search_results(json_result): """Search results are divided into 'statuses' and 'search_metadata'. The former contains the tweets themselves, and the latter contains the max_id to use to retrieve the next batch of tweets""" statuses = json_result.get('statuses') metadata = json_result.get(...
63fb0a04297e65f0e2cdb723b0c03c8d46abfdaa
693,141
def contains_unusual_content(result: dict) -> bool: """ returns True if the response indicates the PDF contains unusual content (Launch, Sound, Movie, ResetForm, ImportData and JavaScript actions) by checking if ISO 19005.1 clause 6.6.1 is among the failure reasons. :param result: The parsed JSON r...
98d5fcacaf0c69dbe3c17e037d6b78232bfea9da
693,142
def get_channels( public, stable, server, intranet, group, add_dependent_channels=False ): """Returns the relevant conda channels to consider if building project. The subset of channels to be returned depends on the visibility and stability of the package being built. Here are the rules: * public...
b3378686aa6bf549c71393e43ac22966f8228f50
693,143
import numpy def _jet_wrapped(siz): """ Provides a jet-like colormap array for sub-aperture processing Parameters ---------- siz : int the size of the colormap Returns ------- numpy.ndarray the `siz x 3` colormap array """ siz = int(siz) red_siz = max(1, ...
64b3f334fb990157a669199515da848cc20ff084
693,145
from typing import List def divide_into_tweet(text: str) -> List[str]: """Takes a textstring and divides it unto a list of strings that are less than or equal to 276 characters long. Args: text (str): text to be divided into tweets Returns: List[str]: list of tweets less than 276 ...
72351d6a691eda1ac5244f7709f0a2ac9ab68881
693,146
def rescale_and_format(x: float, divider: float) -> str: """Текстовое представление данных. Умножает на множитель и форматирует с округлением до тысяч, разделением разрядов и выравниванием вправо.""" return f"{round(x / divider, -3):,.0f}".replace(",", " ").rjust(9)
20d2777f578e74110c54895f5e6c38a8c60411f6
693,147
def validate_text(text): """ Returns True if text exists and is more than white spaces, False otherwise.""" return bool(text) and not text.isspace()
838dbf793c918d76def644256d0d15f4ef1e62bb
693,148
import re def normalize_whitespace(text): """ Replace non-breaking spaces with regular spaces, collapse runs of whitespace, and strip whitespace from the ends of the string. """ s = text.replace(u"\xa0", u" ").replace(u"&nbsp;", " ").replace(r"\S+", " ") return re.sub(r"\s+", " ", s).strip()
c9c06c959be9455b39e5579d1bec4e3d4948e0c8
693,149
def flip_date_format(date: str) -> str: """Goes from YYYY/MM/DD to DD/MM/YYYY and vice-versa""" a, m, b = date.replace("-", "/").split("/") return f"{b}/{m}/{a}"
c63cbc0b89663b9969461474bf8e4cfc91303feb
693,150
import os def basename(path): """ Get basename. @param (str) path @return (str) """ return os.path.basename(path)
69fff2ed0deaacb4e262addd464ee8aafad7d422
693,152
def load_doc(filename): """ Function to load doc into memory. """ file = open(filename, mode='rt', encoding='utf-8') text = file.read() file.close() return text
08d0d72bbfab73708d9d9e3cd6344e667a27f4b7
693,153
import re def read_urls(filename): """Returns a list of the puzzle URLs from the given log file, extracting the hostname from the filename itself, sorting alphabetically in increasing order, and screening out duplicates. """ puzzle_urls = [] # create empty list for puzzle URLS to go into ser...
541fe96c08e4a700d58d5400bf966599fb7dc55a
693,154
def clean_hotel_name(string): """ """ r = string.strip() return r
191980c83cc4837400b59fdfec78b99d9cd95943
693,155
import pathlib def name_from_path(path: str) -> str: """Generate a model name from the H5 path.""" name = pathlib.Path(path) return name.name[: -len(name.suffix)]
2cc77fb1d5694213ff5e28a70790e4e6540c9f56
693,156
def parse_color(key, string) -> str: """ parses the color html of form 'rgb(0,0,0)' Args: key: string that is a color string: associated string value in the html Returns: str """ assert key == "color" string = string.replace("rgb(", "").replace(")", "").split(", ") ...
9205af775b1624b06064d2905ffb7d62b117676a
693,157
import os def _read_names(path): """ Read line-separated time series names from ascii file Parameters ---------- path : str Key file path Returns ------- list Time series names Notes ----- Keys are stored on ASCII file as one key per line. The file is ter...
bdf6f1d29427be32683061ab9d4187da72621e5c
693,158
def get_title(cube, nexp): """Get the plot title.""" if nexp == 1: model = cube.attributes['model_id'] experiment = cube.attributes['experiment_id'] physics = cube.attributes['physics_version'] run = cube.attributes['realization'] mip = 'r%si1p%s' %(run, physics) ...
b375077c8f8bb63d4f0e6c0aa890e68d8941c799
693,159
def check_reference_allele(reference_base, bpm_record_group): """ Check whether the given reference base (on the plus strand) is queried by any record in a group of BPMRecords Args: reference_base (string): The reference base bpm_record_group (iter(BPMRecord)): Iterable of BPMRecords ...
476c70e9e1ef3703b8b33b2c310808c6d713dbe2
693,160