content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
def hello(): """ Defines the route ('/') and what needs to be returned. """ return "<h1 style='color:blue'>Hello World!</h1>"
4527001c85889c0dcfebdcc81490a8204139ab8b
645,388
def directory_in_zip(zip_f, directory_name): """Determine if a directory exists in a ZIP""" return any(x.startswith("%s/" % directory_name.rstrip("/")) for x in zip_f.namelist())
94cb8f94661a4734c00a0227b104c738db1e2c48
645,389
def get_names_flat(adtype): """ Returns the field names of the input datatype as a tuple. Nested structure are flattened beforehand. Parameters ---------- adtype : dtype Input datatype Examples -------- >>> from numpy_demo.lib import recfunctions as rfn >>> rfn.get_name...
6c0ae63e7d998abdc54d5a9567067d059c794db1
645,390
import os import hashlib def _generate_unique_identifier(path: str) -> str: """ Generate a unique identifier based on the shell script and the save_input file from KSHELL. Parameters ---------- path : str The path to a summary file or a directory with a summary file. """ shell...
02d9ff01ec736f3345aaac11b1e0d6ae29b789b1
645,392
def reorder_leaderboard_data(data): """ @param data (List of List): Each item represent a row in global leaderboard @return (List of List): Re-order rows according to rating and assigned ranks """ result = [] rank = 1 data = sorted(data, key=lambda x: x[3], reverse=True) for ro...
8c5725f09b782011da110467e8119a5b333fc828
645,393
def defaultObjectSerializer(self): """reduce function that uses the default implementation""" return self.__reduce__()
90e42e79ebc2d073eb99269c4d7b4920911bf1de
645,394
import ast from typing import Tuple from typing import Type def is_contained(node: ast.AST, to_check: Tuple[Type[ast.AST], ...]) -> bool: """Checks whether node does contain given subnode types.""" for child in ast.walk(node): if isinstance(child, to_check): return True return False
e2d9ce47280a19180d7c2d10a1bf92f2c5227914
645,395
def parse_tools(df): """ :param df: Pandas Dataframe :return: List of dictionaries """ return df.to_dict('records')
a44ce69f08ddbd59608ecb54c9f8b8da34e40374
645,397
def TF_family(motifs_df): """function to add a TF family column in the motifs.bed file (for DAP-seq cistrome motifs only)""" motifs_df["TF_family"] = motifs_df.TF_name def capitalise(x): return x.upper() # capitalise = lambda x: x.upper() motifs_df.TF_family = motifs_df.TF_family.apply(cap...
da8ef2d7f03049703599d5927aebbb0f3f6f8c52
645,398
from datetime import datetime def timestamp() -> str: """Timestamp that can be used in a file name.""" return datetime.now().isoformat().replace(":", "-")
18f36c6f08333ff54b0eec19c205123a15875a22
645,399
import subprocess def popen_call(sub_cmd, input, is_last_process): """ Execute a command specified as function arguments using the given input """ if not input: process = subprocess.Popen(sub_cmd, stdout=subprocess.PIPE, std...
58d53826a72eac22c5cd19d566673e01135e08b2
645,400
import re def split_string_on_punctuation(text): """Split on ?!.,; - e.g. "hi, how are you doing? blabla" -> ['hi', 'how are you doing', 'blabla'] (make sure you strip trailing spaces)""" pattern = r'[?!.,;][\s]*' return [i for i in re.sub(pattern, "|", text).split("|") if i != ""] pass
c0334332d79c7dee9e98c7c215b0be657b7292c1
645,401
import json def getResponseUrl(response): """ Get the return url from a hosted payment API call :param response: Response object in JSON :return: Transaction ID """ resp_dict = json.loads(response.text) try: url = resp_dict["url"] except KeyError: print('Retrieval uns...
9abec3c44284e112d877efac02aa20d102254d54
645,402
def prefix_max(array: list, i: int) -> int: """Return index of maximum item in array[:i+1]""" if i >= 1: j = prefix_max(array, i-1) if array[i] < array[j]: return j return i
42d3b77e83e9783e30c6618b63e3cb060113f7e0
645,403
def not_noquote(p_tag): """ Helper function to detect the <p quote="noquote"><bf>Praise for the previous edition...</bf></p> tags in listcomp in the `Reviews` class __init__ method. Returns whether it is not, so the value can be used directly to omit these tags. """ is_nq = "quote" in p_tag.attr...
9d0308d08a157c9106f394a526ccbf1f7a940206
645,404
def formatDollars(d,noneValue='',zeroValue='$0'): """Formats a number as a whole dollar value with alternatives for None and 0.""" if d is None: return noneValue elif d==0: return zeroValue return '${:.0f}'.format(d)
88972887ed4c8a894d74e4cbabb0a74e44d2c815
645,405
from typing import List from typing import Any def pad(sents: List[List[Any]], pad_token: Any): """ Pad list of sentences according to the longest sentence in the batch. @param sents: list of sentences, where each sentence is represented as a list of words @param pad_to...
4e6d368701f7d9cee7498ab88cb7684487ffc2fd
645,406
def parse_optionalString(value): """parse an optional string""" if not value: return None return value
b3f45005b0cbffe7214f8d3240ecf79705fa9743
645,407
from typing import List def missingNumber1(nums: List[int]) -> int: """ 思路:排序,哈希,求和(等差数列-高斯求和公式),位运算(异或) """ n = len(nums) expectedSum = n * (n + 1) // 2 actualSum = 0 for val in nums: actualSum += val return expectedSum - actualSum
0c0d6bcc5d3696e8004cbe49c7f9fd7d8e20002b
645,409
def get_base_req(req): """Get the name of the required package for the given requirement.""" if isinstance(req, tuple): req = req[0] return req.split(":", 1)[0]
03642dedb41cda6841e6a63e3c9c50e2e8676234
645,411
import argparse def get_shared_desi_proc_parser(): """ Create an argparser object for use with desi_proc AND desi_proc_joint_fit based on arguments from sys.argv """ parser = argparse.ArgumentParser(usage="{prog} [options]") parser.add_argument("-n", "--night", type=int, help="YEARMMDD night") ...
c9be570890cb0d92737ec9d13d1471891ffb4764
645,412
def _add_property_function(function_name): """ Adds regular function that is applied directly on the underlying `_tensor` attribute, and returns the result of that function. """ def property_func(self, *args, **kwargs): return getattr(self._tensor, function_name)(*args, **kwargs) if fu...
f80d6ff08ceb6ab254ff385170c6a297a1536e2f
645,413
def read_response_from_server(): """ Wait for one response from the remote server. :return: The response received from the server, None on error. The newline character is stripped away (not included in the returned value). """ # The "global" keyword is needed so that this function refers to the...
d4de33cd291a54f61027bd670cb77e29e8deb230
645,414
def optimize(f, g, c, x0, n, count, prob): """ Args: f (function): Function to be optimized g (function): Gradient function for `f` c (function): Function evaluating constraints x0 (np.array): Initial position to start from n (int): Number of evaluations allowed. Remember...
fad95de8d225fb158dff375b2a11059b229ea056
645,415
import re def natural_sort_key(s, _nsre=re.compile("([0-9]+)")): """ Taken from: https://stackoverflow.com/a/16090640 """ return [ int(text) if text.isdigit() else text.lower() for text in _nsre.split(s) ]
b37b0e7e11969427f3b16f578bb8fa65f80922eb
645,417
def addition(num1, num2=0): """ Adds two numbers Args: num1: The first number num2: The second number, default 0 Returns: The result of the addition process """ return (num1+num2)
2a573575cbfbcf3b6165f8076a80c008c0b50b79
645,418
def t_area(t_str: str) -> float: """Calculate area of a triangle (basic). Args: t_str: <str> triangle shape as a string. Returns: <float> triangle area. """ rows = t_str.split('\n')[2:-1] base = rows[-1].count(' ') height = sum(map(lambda string: ' ' in string, rows)) return (b...
ed3e26ee76cd8a3b808c8b03e0bc028c32dec2e6
645,421
def quantize_key_values(key): """ Used in the Django trace operation method, it ensures that if a dict with values is used, we removes the values from the span meta attributes. For example:: >>> quantize_key_values({'key', 'value'}) # returns ['key'] """ if isinstance(key, dict)...
3420bbaf8b5b22fbc6cf170369094c31b9e79efe
645,422
def upar(unit_st): """Parse unit_st into num (float), unit (string) pair""" unit_st = str(unit_st) try: #Python 3 mod ind = list(map(str.isalpha, unit_st)).index(True) num, unit = float(unit_st[:ind]), unit_st[ind:] except ValueError: num = float(unit_st) unit = ...
8e907389880d3da283cb05512e21abf640fbb4e7
645,423
import hashlib def password_encryption(password): """ 將密碼用sha256加密 :param password: 密碼明碼 :return: 雜湊後的密碼 """ return hashlib.sha256(password.encode('ascii')).hexdigest()
e3114931efa60a510b35914a4478babacf43ccc2
645,424
def load_words() -> set: """370099 words in the set""" with open("words_alpha.txt") as file: valid_words = set(file.read().split()) return valid_words
479e2525ad2bacdc35844ad78e2cf9484c06e370
645,425
def build_n_sequence_dictionary(n : int, txt : str) -> dict: """ Returns a dict counting appearances of n-long progressions Parameters ---------- n : int The length of progressions to count txt : str A comma-separated string of roman numerals Returns ------- dict ...
1b229dad484bef6d20b5bcc6c908a7b4240ca8ce
645,426
from typing import Dict def rb2coco_bbox( rb_label: Dict, label_id: int, image_id: int, category_id: int, width: int, height: int, ) -> Dict: """Convert rb bbox to coco bbox.""" assert rb_label["bbox2d"] xnorm = rb_label["bbox2d"]["xnorm"] ynorm = rb_label["bbox2d"]["ynorm"] ...
4aa6d3b2c4c21d07e5b60df272f27de290169035
645,427
def get_keydown(handle): """ Read all the USB HID events from a device. Return when a key down event happens. Ignore any key up events. """ while True: try: d = handle.read(64) if d[3] != 0: return d[3] except: print("error ...
a3bda52bb36aacbf7a64960d135c00d5db2ec05c
645,428
def find_key(value, dictionary, default=None): """ Find the given value in the given dictionary and returns its key. If value is not found - return default value (None or given). If many elements can be found - return one of them arbitrarily (the first one found):: >>> find_key('d', {'a': 'b', ...
5acef8b8cb35e0e3420ff4f9264b37d6ef8cec0f
645,429
import json def extract(): """ #### Extract task A simple Extract task to get data ready for the rest of the data pipeline. In this case, getting data is simulated by reading from a hardcoded JSON string. """ data_string = '{"1001": 301.27, "1002": 433.21, "1003": 502.22}' order_data_...
d7d08ee0557446420b2fb6523b613be5a2e2e612
645,431
def count_resolve(siblings): """collapse sibling steps into one""" first = siblings.pop() for s in siblings: if s is not None: # ? # all siblings ought to have the same 'last' # assert first['last'] == s['last'] first['step'] += s['step'] return first
bb8a3e93553320522ed32c219df9d4109fd8e11f
645,432
def caloria_function(is_male: bool, weight: float, height: float, age: float, sport_a_week: int) -> float: """ Calculates 24hour calory need. Returns -1 in any error case. :param is_male: True/False. Does human have MALE sex? :param weight: float, kilograms :param height: float, santimeters ...
20ea77f846ad4455a119675b36f09a6995bfc23d
645,434
def start_from(year, starting_year): """[Returns the years from the first publication of the book] Args: year ([str]): [Year of the book] starting_year ([str]): [Year of pulication of the first book of the serie] Returns: [int]: [Years since the publication of the first book of the...
07f2a4a33e438ef1d46b551ac3c1d0d21065dcce
645,436
from datetime import datetime def get_datetime(date, time, *, microseconds=True): """ Combine date and time from dicom to isoformat. Parameters ---------- date : str Date in YYYYMMDD format. time : str Time in either HHMMSS.ffffff format or HHMMSS format. microseconds: boo...
641f91292da33de6d516bfa06749c98bee1dc028
645,437
def remove_dup(df_tweet): """ Remove dupicated tweets (based on the 'tweet' text column) For duplicated tweets, it will keep the first tweeet Args: df_tweet (pandas df): dataframe containing covid tweet Returns: df_tweet (pandas df): dataframe with duplicated tweets removed """ ...
ced960eae68e0882ba0739cdb2734bfdc01192a5
645,438
import ipaddress def ip_subtract(ip, val): """Subtract an integer to an IP address. Args: ip (str): An IP address in string format that is able to be converted by `ipaddress` library. val (int): An integer of which the IP address should be subtracted by. Returns: str: IP address ...
0372ba4f14f6a3722ea7843a8c36c5470890004d
645,439
def within(min=None, max=None): """ Create a validation function to check whether an argument value is within a specified range (inclusive). `min` and `max` cannot both be None. :param min: A lower bound for the value. Optional. :param max: An upper bound for the value. Optional. :return: A...
03a6d4d7ac14f7c7845c9cdb5d9aa662af352ce6
645,440
def _call_connected(conn, *args, **kwargs): """Helper function to return connection status""" return conn.isalive(), False
18d7a3a07aa855be7779ddcd088c70c853b690c8
645,441
def get_stack_status(conn, stack_name): """Check stack status""" stacks = [] resp = conn.list_stacks() stacks.extend(resp) while resp.next_token: resp = conn.list_stacks(next_token=resp.next_token) stacks.extend(resp) for s in stacks: if s.stack_name == stack_name and s.s...
f669153230830fff5b59d58c06594a76d46a8a7a
645,442
import math def _adamic_adar(set_one: list, set_two: list, graph) -> float: """ Calculate Adamic Adar score for input lists :param set_one: A list of graph nodes -> part one :param set_two: A list of graph nodes -> part two :param graph: NetworkX bipartite graph :return: Adamic Adar score ...
65cf8c85c7fe888ad8f339622a6fb0b0b4949b35
645,443
def eliminar_repetidas(cadena: str) -> str: """Elimina las palabras que se repiten más de tres veces. :param cadena: cadena de caracteres. :cadena type: str :return: cadena sin las palabras repetidas más de tres veces. :rtype: str """ return " ".join([i for i in cadena.split() if cadena.cou...
ce59a3a062d15b538416214a49f63de6fbdab9a3
645,444
def reverse_slice_order(slc: slice) -> slice: """Reverse a slice order. NOT MAINTAINED. ie the order in which indices are taken. The indices themselves do not change. We assume the slice is valid (size > 0). """ start, stop, step = slc.start, slc.stop, slc.step if step is None: ...
a32fdc1b7e2f8f001af859d0fea421366a0afc9c
645,445
def pad_array(matrix, value): """ Pads the left side of the rows of a matrix with the given value Args: matrix: matrix to be padded value: the value to use to pad the array """ for row in matrix: row.append(value) return matrix
949f6929df985096a5938de636ce97a9e97e3ffb
645,447
def standardize(variables, constraints): """Converts the constraints and objective to standard form. Args: variables: The variables of the LP. constraints: The constraints to be converted. Returns: The new constraints and objective. """ standard_constraints = [] for c i...
275b3e31013fbf82d11f14c2ed500923468388b7
645,449
def parse_slack_output(slack_client, slack_rtm_output, config, bot_id): """ The Slack Real Time Messaging API is an events firehose. this parsing function returns None unless a message is directed at the Bot, based on its ID. """ at_bot = "<@{0}>".format(bot_id) output_list = sl...
355ab5b9525e6a52b283fbd11fb81b26eef33257
645,451
def x_update(crd, v, a, dt): """Currently we only support velocity verlet""" crd += v*dt + 0.5*a*dt*dt return crd
b0261603b4fb792addbb440fafda608ea936b050
645,452
import os def list_sorted_filenames(directory): """ Get filenames in a directory, and return a sorted list of them. :param directory: The path to a directory :returns: A list of sorted filenames """ with os.scandir(directory) as entries: filenames = [entry.name for entry in entries if...
facaca7dedfa69cef7acb4477cd9e5f9ddc0f33b
645,453
def accuracy(y_true, y_predict): """ 准确度 """ return sum(y_true == y_predict) / len(y_true)
83ab3d12f690ddfcd9cc447091ef5d692af1b972
645,454
def default(): """Hello saying method""" return "Hello master"
55ac462b52a1c24fdd4fc4eee942ca26f6ba7b58
645,456
def get_input_string(): """""Reads string of words separated by space from user input :return string of words separated by space :rtype str """ print('Insert sentences in new lines. To stop insertion, enter empty line') text = '' while True: sentence = input() if sentence == ...
f702872d6dd3037907528ab8cfdeaa6c216b01d4
645,457
def delete(name,list_notif): """this deletes the notification dictionary from the notifications list""" i = 0 for item in list_notif: for notification_name in item.values(): if notification_name == name: list_notif.pop(i) i += 1 return list_notif
c54e31a2ddfc48a2d700b4d95de9dd9e8181f0ad
645,458
def convert_hex_ascii_to_int(int_val): """ Use to convert from hex-ascii to int when encoding data particle values """ return int(int_val, 16)
50774d5a2e9c2cfaed5e25f4031585cb496a7a1b
645,459
def delta4(a, b, c, d): """Delta function (4 variables) """ if (a == b) & (b == c) & (c == d): return 1 else: return 0
060dd5491957e8d343f0a3a7ceae70ae2955e9b8
645,460
def _TestTypesMatch(types_to_run, this_tests_types): """types_to_run should be a set of test types to run. this_test_types should be an iterable. Returns true if any type in the latter is also in the former, i.e., if the two are not disjoint.""" return not types_to_run.isdisjoint(this_tests_types)
ebaa99b02039cd774f469414dd5a29844a27536e
645,461
def _get_index_and_key(nodes, position): """ Returns the amount of commas and the keyword argument string. """ nodes_before = [c for c in nodes if c.start_pos < position] if nodes_before[-1].type == 'arglist': nodes_before = [c for c in nodes_before[-1].children if c.start_pos < position] ...
709ce3059c66462eac55958e2849d4828e80aac7
645,462
import os def bypass(path): """This method changes the rights of a file to 777 Args: path (string): The path of the file you want to change chmod Return: """ if os.access(path, os.R_OK) and os.access(path, os.W_OK) and os.access(path, os.X_OK): return False else: os.c...
18a7d588f6b4ba07c48c2965f0c39525f3f93d4d
645,463
def switch_to_true_only_select_key(key2bool, select_key): """ 選択したkeyのvalueをTrueに,それ以外のkeyのvalueをFalseにする. Args: key2bool: 全てのvalueがbool値になっている辞書 select_key: valueをTrueにしたいkey2bool内の1つのkey Return: key2bool: key=select_keyのvalueをTrue、その他のkeyのvalueをFalseにした辞書 """ for k in k...
db69221cd498e1db180fe014edf1260950a8db99
645,464
import optparse def build_arg_parser2(): """ Build an argument parser using optparse. Use it when python version is 2.5 or 2.6. """ usage_str = "Longest Common Substring calculator -- arguments" parser = optparse.OptionParser(usage=usage_str) parser.add_option("-s", "--sentences", nargs=2, de...
faf966b951c221a445d487d717d51930b22692ba
645,465
import psutil import os import subprocess def processRunning(path): """Cheek is process runing, no""" processName = os.path.basename(path).lower() try: for proc in psutil.process_iter(): if proc.name().lower() == processName: return True return False except ...
4cae51874b43baa561954cf2d81f28fc2d3cdfc7
645,466
import logging def convert_time(input_date: str, input_time: str): """ Input is 04/01/2007 (MM/DD/YYYY) and 12/30/1899 13:35:00 (WRONG DATE HH:MM) Output shall be 10.02.2016 13:00 (DD.MM.YYYY HH:MM) """ date_part = input_date.split('/') if not len(date_part) == 3: logging.error("Date ...
2cb161d87fcb8b3c7774efeeeb34d64cf7a62ccc
645,467
import os from pathlib import Path def get_subsubdirs(path): """ Get the second-level subdirectories of the given path. If given path 'a/b', a sample return would be ['a/b/c/d', 'a/b/c/d2', 'a/b/c/etc'] :param str path: :return list: list containing Path instances for all paths found two levels ...
2276f5b7aaae540e99a4e395475a8504a972460a
645,468
import itertools def sorted_groupby(iterator, key, reverse=False): """ Similar to `itertools.groupby`, but sorts the iterator with the same key first. """ return itertools.groupby(sorted(iterator, key=key, reverse=reverse), key)
e6f018f5828d070492a78d482b763ba864db0f10
645,469
def _load_test_data(har_data, num_test_files=3): """ Loads the test files we need and returns them in the proper format. :param num_test_files: Maximum number of test files to return. :type num_test_files: integer """ results = [] for i in range(1, num_test_files + 1): results.appen...
60666dee507c69ea4689d3080b0493d80a1dbdc1
645,470
def has_decorator(source_lines: list) -> bool: """ Checks if the source code for a function has a decorator or not :param source_lines: Source code lines of a function :return: True if there is a decorator else False """ return '@' in source_lines[0]
84399e3eda2063f6f9bdbe474470c2cce362c5fc
645,471
def get_phenotype_curie(phenotype_uri): """Extract Phenotypes CURIE from the URI """ if '/MEDDRA/' in phenotype_uri: phenotype_id = phenotype_uri.split("/MEDDRA/", 1)[1] return 'MEDDRA:' + phenotype_id if '/HP:' in phenotype_uri: phenotype_id = phenotype_uri.split("/HP:", 1)[1] ...
708ee8da8a544f57189fb252452c4bf8c856dab7
645,472
def quick_stats(x, digits=3): """Quick wrapper to get mean and standard deviation of a tensor. Parameters ---------- x: torch.Tensor digits: int Number of digits to round mean and standard deviation to. Returns ------- tuple[float] """ return round(x.mean().item(), digi...
90a72d9499acb3cdd92515974f9f96f2aed123e8
645,473
def get_output_sdf_path(gold_conf_path): """ This function extracts the output sdf path for docking results from a gold conf-file. Parameters ---------- gold_conf_path : str Full path to gold conf-file. Returns ------- sdf_path : str Full path to sdf-file. """ w...
7d1cf606f62eae64ec91134b1e2520e2a0f1976f
645,474
def getRequestsFileName(request): """Get the filename from a Requests context""" content_disposition = request.headers.get("Content-Disposition") if content_disposition is not None: attributes = (x.strip() for x in content_disposition.split(";") if x.startswith("filename=")) ...
4da0ef43d8fde804ee93f9de99208055a600a6fc
645,475
def config_contains_tar(pipeline_config: dict, tags=None) -> bool: """ Check if the input file list contains a `.tar` archive. """ if tags is None: tags = ["archive", "inside_archive"] params = pipeline_config.get("params", {}) ffiles = params.get("fetch_files", []) for ff in ffile...
65c38a5f953f8236b2886abd6c46aeb8b6f14d65
645,476
import os import shutil def validate_arff(filename): """Description of validate_arff Check if filename exists on path and is a file If file corresponds to valid arff file return absolute path Otherwise move file to invalid directory and return False """ # Check if file exists if os.path.i...
4f6ca58917a9ad05d2dea6531a384f612f4a0649
645,477
def stats_variable_names(res): """Return the variable names for a stats object""" def varname(s): pos = s.find(':') return s if pos==-1 else s[0:pos] return set( [ varname(key) for key in res.keys()] )
bcc97d16d3bf2bb2eb1e374e49a9268ac1ebeedf
645,478
def Binary(data): """Builds and returns the Binary JSON""" return { "request": { "method": "PUT", "url" : "Binary/" + data["id"] }, "resource": { "id" : data["id"], "resourceType": "Binary", "contentType" : data["mim...
adc193c7b4430fd1ed70ea2f4befb1df0ac158f6
645,479
import socket def _validate_as_ipv6(text: str) -> bool: """ A helper function for verifying that a string represents an IPv6 address. :param text: the string to verify. :return: `True` if the string looks like an IPv6 address or `False` if not. """ try: socket.inet_pton(socket.AF_INET...
b6983533bddcf111ffcbce1a8b53f96d8c9f95d0
645,481
def fahrenheit(T_in_celsius): """ returns the temperature in degrees Fahrenheit """ print ("FLAG --> my function call is here, accepting temp deg C and returning temp deg Fahrenheit ") return (T_in_celsius * 9 / 5) + 32
c4fa739923c5200267ab5eba6090143f5c479bc4
645,482
def _count_lines(file_path): """Count lines in a file. A line counter. Counts the lines in given file with counter count counts. Args: file_path: `str` path to file where to count the lines. """ count = 0 with open(file_path, "r") as fobj: for line in fobj: count += 1 ...
221898268ef750ee552d27c04780b382aadbbfa1
645,483
def _compare_blocks(symblock, crossblock): """ :param symblock: :param crossblock: :return: """ v = symblock.qry_chrom == crossblock.chrom v &= symblock.qry_start == crossblock.start v &= symblock.qry_end == crossblock.end return v
096d34f9b68d8c78eb67fc361f422ae4865ab68a
645,484
def pc_to_m(pc): """ Converts the input distance (or velocity) of the input from parsec to meters. """ return pc * 3.085677581 * 10**18
47b035a1e26f7e305f674687f5bfba2da791db3f
645,485
import torch def shiftdim(x, n=None): """Shift the dimensions of x by n. Parameters ---------- x : torch.Tensor Input tensor. n : int, default=None Shift. * When N is positive, `shiftdim` shifts the dimensions to the left and wraps the N l...
972508bcd6d72fff37dcc690597884b8ee29d44f
645,486
import json def get_json(raw): """ Returns the given text expressed as JSON, or None if any error occurred. """ try: return json.loads(raw) except: return None
477b8d13c49188f62ebafc872201365a04a77853
645,487
def klass(obj) -> str: """ returns class name of the object. Might be useful when rendering widget class names Args: obj: any python class object Returns: str: name of the class >>> from tests.test_app.models import Author >>> klass(Author) 'ModelBase' """ retur...
39eb3913e33b895889ec5a7f29fb37b9a634eb5b
645,488
def small_vote_power(karma): """See https://github.com/LessWrong2/Lesswrong2/blob/devel/packages/lesswrong/lib/voting/new_vote_types.ts for the vote power implementation. See also the blog post at https://lw2.issarice.com/posts/7Sx3CJXA7JHxY2yDG/strong-votes-update-deployed#Vote_Power_by_Karma""" if...
435ac6c970e94f0a1db6fcad865577d65c07e1a9
645,489
def hasannotation(string_list): """ Judge whether the string type parameter string_list contains annotation """ for c in string_list: if c == "#": return True return False
fda92b66675c3333c9bf7ff99dbcefd12b7fb349
645,491
def _add_extension_asset( client, customer_id, phone_number, phone_country, conversion_action_id ): """Creates a new asset for the call. Args: client: an initialized GoogleAdsClient instance. customer_id: a client customer ID. phone_number: a phone number for your business, e.g. '(1...
0065de950c3a8909489dbeea4dfbf02d5b76a820
645,492
def find_value(key, headers): """ Search *headers* for *key* and return the common value shared across each element of *headers* and raise an exception if multiple values are encountered. """ values = set([x[key] for x in headers]) if len(values) == 0: raise KeyError('{} not found'.f...
e7632abdb07ce5630bd98bdde3e1af7154b392b6
645,494
def remove_even_integers(_array: list) -> list: """ Remove Even Integers from Array """ new_arrays = [number for number in _array if number % 2] return new_arrays
a65d876d363a5f1c4eb18175870b67a3a8333c60
645,495
def exibeTokens(tokens): """ Apresenta sentença toquenizada no formato canônico, como string. """ tokens=[t.encode("utf-8") for t in tokens] return " ".join(tokens)
94f55e20a9671d3ee4af09dec966c32995ba5d61
645,496
def get_rp_health_summary(isamAppliance, check_mode=False, force=False): """ Retrieving a summary of Reverse Proxy health """ return isamAppliance.invoke_get("Retrieving a summary of Reverse Proxy health", "/wga/widgets/health.json")
9e4d7c5b5c29e20e178ee754c8496ede1149ce11
645,497
def get_generic_constraint_index(data) -> list: """Get generic constraint index""" return [i['@ConstraintID'] for i in (data.get('NEMSPDCaseFile') .get('NemSpdInputs') .get('PeriodCollection') ...
0fb6d0e7cad395263fcd4bb553419c8f8a493cfe
645,498
def nthroot(n, nth) -> float: """ n: O número que vai ser obtido a enésima raiz nth: A énesima raiz de n return: Retorna a enésima raiz de n """ return pow(n, (1/nth))
ec254e407fb65ffa230a96ba08b3862708c93a8d
645,499
def baraja_letra(a,palos,figuras): """lista,tupla,tupla-->lista[str] OBJ: Mostrar la baraja en letra PRE: Baraja de 40 cartas""" mezclada=[] for cartas in a: palo=palos[(cartas-1)//10] figura=figuras[(cartas-1)%10] mezclada=mezclada+[figura+' de '+palo] return mezclada
649e8080fa7e6565ef68604fee2f42550f91bb7d
645,501
def first_n_loads(request_data, prior_fingerprint=[], n=1): """ Heuristic: Use the first n page load(s) as an indicator of all future loads inputs: url_data : dict of page info for page to generate fingerprint from prior_fingerprint : a previously generated fingerprint (optional) n :...
a31e656f5c8ccf12db963ed58b4cf17dd005eb72
645,502
def get_transpose(df): """ get the transpose of your matrix (index by case) """ df_transpose = df.transpose() df_transpose = df_transpose.rename(index = {'gene':'case'}) # IMPORTANT! the header here will depend on the data type return df_transpose
1e39e3a67fd13b352fb18c2cf257d23edd21832d
645,503
import os def get_ids(dir): """Returns a list of the ids in the directory""" return (f[:-4] for f in os.listdir(dir) if "mask" not in f)
fd2d765c7af02bded78fc6a60d21206bc0b43f51
645,504
def ppver(*args): """ Returns PYPOWER version info for current installation. @author: Ray Zimmerman (PSERC Cornell) """ ver = {'Name': 'PYPOWER', 'Version': '5.1.4', 'Release': '', 'Date': '27-June-2018'} return ver
d0e06abb2a4bd8291c15efd9923e98ebedded9d6
645,505