content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
def node_region(patched_ast_node): """Get the region of a patched ast node""" return patched_ast_node.region
870fc43f1b635d5b5eb5e5a4ffa80ab322af168d
18,818
def source2id(vocab, text): """Convert a source to ids""" sequence_length = 7 return [vocab.get(word, vocab['<UNK>']) for word in text] \ + [vocab['<PAD>']] * (sequence_length - len(text))
682eda8d67dd3a88e7c6c61abef754b1669d3760
18,819
def get_NM_number(tags): """ Return the number of mismatches found in the NM tag Arguments: - `tags`: The tags argument """ for tpair in tags: if tpair[0] == 'NM': return tpair[1] return 10
ce192b22ee73bcb71d85a3ff22dd8cd005ca2633
18,821
def _dense_q_minus_grad(q, dense_adjacency_matrix, s, alpha): """Computes q-grad on dense arguments.""" return (1. - alpha) * dense_adjacency_matrix.T @ q - alpha * s
9ac5c097eeef66f203e06368db7ef7e0778cb847
18,822
def _extract_target(data, target_col): """Removes the target column from a data frame, returns the target col and a new data frame minus the target.""" target = data[target_col] train_df = data.copy() del train_df[target_col] return target, train_df
726a76e254c1d6dc120b590d9d7128986ddc9227
18,823
def score_compressed_state(total, trumps): """ Calculate score from compressed state """ score = 0 for num_trumps in range(trumps, -1, -1): score = total + num_trumps * 10 if score <= 31: break return score
0d6652174c2f3f409431c15f38874b8057b94921
18,824
def site(client): """Returns a Site object.""" return client.sites.post({'name': 'Foo', 'description': 'Foo site.'})
f7f23d95c151f14b8a0782b7fc16e0172a3dfe74
18,827
from typing import List def _collapse_data(table: List[List[List[str]]]) -> List[List[str]]: """combine data rows to return a simple list of lists""" result: List[List[str]] = [] for row in table: new_row: List[str] = [] for line in row: if new_row: for i, item...
117a6446c006cbd232aad2e018be3fe336faa550
18,828
def title_format(name): """" This customized title function transform names in title format while keeping prepositions like "de" and "das" in lowercase """ person_names = [k.title() if len(k)>3 else k for k in name.split(' ')] return ' '.join(person_names)
e9d0501ddfc0714f9ca4acba5b1bdf3f379b0243
18,831
from typing import List from typing import Dict import collections def merge_series(list_of_metas: List[Dict]) -> Dict: """Merge series with the same SeriesUID. """ result = collections.defaultdict(list) for metas in list_of_metas: result[metas["SeriesInstanceUID"]].append(metas) retur...
42b23b504c6e973913f93da2e86f71f8ea9baec2
18,833
def _rlimit_min(one_val, nother_val): """Returns the more stringent rlimit value. -1 means no limit.""" if one_val < 0 or nother_val < 0 : return max(one_val, nother_val) else: return min(one_val, nother_val)
ba286aa6b36a53d691a13b775bbbcfd8722c8b8e
18,834
def nspath_eval(xpath, nsmap): """Return an etree friendly xpath""" out = [] for chunks in xpath.split('/'): namespace, element = chunks.split(':') out.append('{%s}%s' % (nsmap[namespace], element)) return '/'.join(out)
1e859c10314d3381a9186f1118bc692887e35ffe
18,835
from typing import Dict from typing import Any from typing import Callable import argparse def arg_map(**mapping: Dict[Any, Any]) -> Callable[[Any], Any]: """ Create function to map arguments using given `mapping`. :param mapping: mapping between input arguments and their desired values. :ret...
d24d94be7feafc86d2842fd94a961a2257deefe9
18,836
def multi_find(s, r): """ Internal function used to decode the Formants file generated by Praat. """ s_len = len(s) r_len = len(r) _complete = [] if s_len < r_len: n = -1 else: for i in range(s_len): # search for r in s until not enough characters are left ...
c5cb9bbc8ed629b68ac1d7d6cbb2c887c8de1070
18,837
def select_sign(pathways, sign): """Selects all pathways depending on the overall sign """ selected = [] pos = False if sign > 0.0: pos = True for pway in pathways: if pos: if pway.sign > 0.0: selected.append(pway) else: i...
b936ee7c18034ab869f26036f01e7c2d1399ff2a
18,838
def _get_fields(line, delimiter=' ', remove_fields=['', '\n']): """Gets the fields from a line delimited by delimiter and without entries in remove_fields Parameters ---------- line : str Line to find the fields delimiter : str Text separating fields in string ...
adfa2e6a1be18049b7b956bef7a0f3c121120641
18,839
def dict_alert_msg(form_is_valid, alert_title, alert_msg, alert_type): """ Function to call internal alert message to the user with the required paramaters: form_is_valid[True/False all small letters for json format], alert_title='string', alert_msg='string', alert_type='success, error, warning, inf...
f9f82c9b809be2ad1d6d872d6e00610a5ebc3493
18,840
def _count_openephys_sessions(filename): """Open-ephys can have multiple sessions. We count how many files are in the format: - Continuous_Data.openephys - Continuous_Data_2.openephys - Continuous_Data_3.openephys """ sessions = [] for f in filename.glob('*.openephys'): ses...
2828c5e31cfeafbec51e6ed46994e8a6deeaac5c
18,841
def check_no_overlap(op_start_times:list, machines_ops_map:dict, processing_time:dict): """ Check if the solution violates the no overlap constraint. Returns True if the constraint is violated. Keyword arguments: op_start_times (list): Start times for the operations machines_ops_...
90736c066987466adcf641f9999542466c17fc8e
18,842
import os def my_loc() -> str: """ Since moving this to a library file... now it gives an undesired path. """ return os.path.dirname(os.path.realpath(__file__)).replace('lib', '')
0f75605aa265c7fffe87bdeb1249c41cc3709bb3
18,843
def p_stat_repeat(p): """stat : stat NEWLINE stat""" p[0] = p[1] + p[3] return p
b0a7332fee9cee28debaccc0b6ca948b019c4633
18,844
def filter_for_celltypes(x, y, celltypes): """ Filter data for cells belonging to specified celltypes :param x: :param y: :param celltypes: :return: """ cts = list(y['Celltype']) keep = [elem in celltypes for elem in cts] x = x.loc[keep, :] y = y.loc[keep, :] return (x, y...
e4cf59cad4903d128eedace71546777dce8dae46
18,846
def leap_year(year, calendar="standard"): """Determine if year is a leap year. Args: year (int): Year to assess. calendar (optional str): Calendar type. Returns: bool: True if year is a leap year. """ leap = False if (calendar in ["standard", "gregorian", "proleptic_gre...
d1c569747082e5f75660cda662daab5f4d77269b
18,848
def dosya_oku(dosyaIsmi): """ Okunacak dosyanın konumu verilince satirlari dondurur. @param string dosyaIsmi : Dosya konumu @return list : Dosyanin icindeki satirlar """ dosyaOkuyucu = open(dosyaIsmi,'r',encoding='utf8',errors="ignore") satirlar = dosyaOkuyucu.readlines() return sat...
152cc87a02dd6ed25a0cb6f3a43913506e0bdc69
18,849
def index(): """ This is the display view. """ return "gutn tag!"
a1401ffa3635d613e9b02ae04834823a9a2ecaee
18,850
import requests def shock_download(url, token): """ Download data from a Shock node. Parameters ---------- url : str URL to Shock node token : str Authentication token for Patric web services Returns ------- str Data from Shock node """ response = req...
7a2e9855ca807892cef16af370755eac3644f9f5
18,851
import time def date_filename(): """Provides an html file name based on the current date and time. Returns: str -- File name """ return time.strftime('%Y%m%d%H%M%S') + '.html'
72012a6cef29567a9fb4e1642db29ab720904aa5
18,852
def trim_patch_boundary(img, patch_boundary, h, w, pH, sH, pW, sW, sf): """ Remove both rows and columns to reduce edge effect around patch edges. """ # trim rows if pH * sH >= patch_boundary: img = img[:, patch_boundary * sf:, :, :] if (pH + 1) * sH + patch_boundary <= h: i...
8ebdad74d227098a286a16ed9678ca24b992e402
18,853
def read_all_file(all_file,components=None,verbose=False): """Read in JXP-style .all file in an appropriate manner NOTE: If program breaks in this function, check the all file to see if it is properly formatted. Fills components if inputted Parameters ---------- all_file : str Full ...
e1c1396cc1efde43b2d250bb5870af99fcd2f31c
18,854
def url_add(tag=None, **kwargs): """ Displays a box containing an "add page" entry box and its form If tag is specified, it is the slug of a tag which will be assigned to the URL when it is submitted. """ if tag: tag = tag.slug kwargs["tag"] = tag return kwargs
03e2be366d51c1b0990110fb7e41626ad1a9106c
18,856
import os def find_images_from_tree(path): """ Collect images from a tree with one folder per identity """ print("Searching for images in {}".format(path)) image_files = [] for root, dirs, files in os.walk(path): for name in files: if name.lower().endswith(("jpg", "jpeg", "pn...
f63e83d55ef599a4d52588061710af27d9ee14b0
18,857
def create_html_email_href(email: str) -> str: """ HTML version of an email address :param email: the email address :return: email address for use in an HTML document """ return f'<a href="mailto:{email}">{email}</a>' if email else ""
c72bb76f3b1fc3d30571a879d1b8172d8c4e77cd
18,858
def mock_listdir(dir_map, dir): """ mock os.listdir() """ return dir_map.get(dir, [])
e274b10dcf3ea25538dd712a3cb91ce873d83bdb
18,859
def dummyListener(source, intent): """Sample intent listener Intent listeners (see :any:`registerIntentListener`) should follow this function prototype. The function can handle `intent` and perform appropriate action if desired. If the function handled the intent, it should return True to mark the intent has hav...
c994b08f5d409debe80fb9f8a29380355a190e12
18,860
def compute_velocities(U_100): """Compute the secondary air flow rates (25-150%) based on the 100% airflow rate""" quarter_scale = 0.25 # 25 percent scale half_scale = 0.50 # half scale five_quarter_scale = 1.25 # adding 25% to U six_quarter_scale = 1.5 # adding 50% to U # Surrounding veloc...
1a5274100dbb8c316bf7506a8213bcfa66036994
18,861
import sqlite3 def isSqlite3DB(filepath): """ Returns whether file at filepath is a sqlite3 database. Args: filepath (str): The file to check. Returns: bool: Whether the database could be opened and queried. """ try: conn = sqlite3.connect(filepath) conn.execu...
54a0c42faea75ffa9d2571b78976db9116c81207
18,862
def _resolve_refs(variables: dict, ref_table: dict) -> dict: """Replaces `ref_table` refs while copying `variables` to the output.""" new_vars = {} for num, kvpair in enumerate(variables.items()): k, v = kvpair new_vars[k] = ref_table[str(v)] return new_vars
d7c3110aa50f061234e9cc9f2c4a225ff4cbba41
18,864
def get_sea_attribute_cmd(seaname): """ Get pvid, pvid_adapter, and virt_adapters from the configured SEA device. Also get the state of the SEA. :param seaname: sea device name :returns: A VIOS command to get the sea adapter's attributes. """ return ("ioscli lsdev -dev %(sea)s -attr pvid,pv...
18224e14e45b73ff716f4282aaff3e06c4584866
18,867
import numpy as np def calculateNorm(var): """ Calculate polar cap anomalies """ ### Import modules mean = np.nanmean(var,axis=0) anom = (var - mean)/np.nanstd(var,axis=0) print('Completed: Calculate normalized anomalies for polar cap!') return anom
e9e8db2286ced83aa3083722809cd6e11822486f
18,868
def input_vector(): """enter vector Returns: list: vector with args """ return list(map(int, input('Элементы вектора: ').split()))
a50e733aa180ec2877fb9219f9062b7eac7f5475
18,869
import numpy def s2dctmat(nfilt,ncep,freqstep): """Return the 'legacy' not-quite-DCT matrix used by Sphinx""" melcos = numpy.empty((ncep, nfilt), 'double') for i in range(0,ncep): freq = numpy.pi * float(i) / nfilt melcos[i] = numpy.cos(freq * numpy.arange(0.5, float(nfilt)+0.5, 1.0, 'doub...
295aef6530ed350c9ebf90f3d276551aa50f8583
18,870
import sys import pkgutil def _importable_libraries(*libraries): """ Of all traceable_libraries, separate those available and unavailable in current execution path. """ available = [] unavailable = [] for library in libraries: if library in sys.modules or pkgutil.find_loader(librar...
9152ae1ff82fdac1a199b3c8a43c46b2c9402efd
18,871
def askbookingInfoPlaces(): """ This function asks the user for the number of places required in the room. Parameters ---------- places : int Returns ------- places : int Note: You can only pick dates from 01/01/2022, 00 till 12/31/2022, 23" """ while ...
90630673d4646dfdfffd73bcb5fd1fcc359691b1
18,872
import itertools def groupby(): """Group sorted elements.""" def square(value): """Calculate the square of a number.""" return value**2 sorted_items = sorted(range(-2, 3), key=square) grouped = itertools.groupby(sorted_items, key=square) return dict((key, list(values)) for key, ...
e8e6ec4a4f34e0745a7f1b2f91cad808908a9587
18,873
import os def get_progress(out_corenlp_dir: str) -> int: """ Get the current progress of the NLP tool :param out_corenlp_dir: reads the output dir and checks how many .json files have been created already :return: length of processed documents """ hits = 0 for fn in os.listdir(out_corenlp_...
c59c08b890d33ef4ddd30a0e6c25ac225e32d64a
18,874
def remove_indent(code_block): """ makes sure first line is not indented and removes that much space from the rest of the lines as well :returns: str - the block unindented """ lines = code_block.strip('\n').split('\n') indent = len(lines[0]) - len(lines[0].lstrip()) return '\n'...
360af8f8ca15f9f73e3904402f521b67850902be
18,876
def zzx_neg(f): """Negate a polynomial in Z[x]. """ return [ -coeff for coeff in f ]
c813597dc9540c8d85221352da10db894de4aa4c
18,877
import inspect import sys def run_module(module_name_string, args_dict): """Run a module specified via CLI. Args: module_name_string (str): Module name to execute. args_dict (dict): CLI arguments dictionary. Returns: [any type returned by module]: Data returned by module. If any....
45c21cf66f560339019b6b2e224046afaa1148dc
18,878
def check_undirected(graph): """ dict -> boolean Just a sanity check that a graph is in fact undirected. """ for node in graph: for neighbor in graph[node]: if node not in graph[neighbor]: return False return True
3ea285e60ec1e18a6ff641274124d4c9e8dfd95a
18,880
def get_all_indices(n): """get all the row, col indices for an (n, n) array""" return map(list, zip(*[(i, j) for i in range(n) for j in range(n)]))
25db8d87540966afea0d2f3e6ee83397f716576b
18,884
def Initial_T_exponential(process_time, n, m, a): """[generate temperature declining process] Returns: [1D-np.array]: [temperature declining array] """ ret = [] sum = process_time.sum()/(5*n*m) ret.append(sum) # initial temperature b = 1 - 2*a/(n*(n-1)) # declining rate cur = ...
b0f2e39cf4a55ecf449ef90d73981909735af17c
18,885
def _secant(a, b, dfa, dfb): """Returns the secant interpolation for the minimum. The secant method is a technique for finding roots of nonlinear functions. When finding the minimum, one applies the secant method to the derivative of the function. For an arbitrary function and a bounding interval, the secant...
50edfa4d3dfb214e6c3f0db595afe1282cb73f10
18,886
def join_by_dash(name): """ if the name 'Room 1' is given, the output would be 'Room-1' """ return "-".join(name.split())
6819f447c4b2616007fae9f94e427b8df4c57c0b
18,888
def get_q_values(node): """ Return all triples (state, action, q) Parameters ---------- node : Node Initial node. Returns ------- Recursively transverse the tree, and return all triples (state, action, q) """ if node.children == None: return [[node.state_va...
8c3015f3b9c44ec7bfaaaf8833b39d167598f2bc
18,890
import inspect import os def get_importing_module_filename(level=2): """Run this during the initialization of a module to return the absolute pathname of the module that it is being imported from.""" module_filename = inspect.getframeinfo( inspect.getouterframes(inspect.currentframe(...
2d68e2e24af0bd6367ce95e13c496743208ad356
18,892
def change_linewidth(ax, lw=3): """change linewidth for each line plot in given axis Parameters ---------- ax : mpl.axis axis to change fontsize of lw : float, optional [description], by default 3 Returns ------- ax mpl.axis Examples -------- ...
b92294878351b6f251c99f43295a8e8e56995cd1
18,893
import torch def _category_weights(): """ Sum up the number of each category """ category_sizes = torch.Tensor( [[131., 199., 177., 157., 3446., 1689., 14838.,186.], [379., 366., 1705., 1297., 9746., 873., 1475.,4982.], [232., 257., 241., 3422., 126., 11225., 5105., 215.], ...
6a18c71bd42eff90b5ab2f8d8a2d0fe9fdbf6086
18,895
def find_upper_bound(x): """ find_upper_bound returns an integer n with n >= len(x), without using the len() function. The complexity is O(log(len(x)). """ n = 1 while True: try: v = x[n] except IndexError: return n n *= 2
4251791d0e270f29bc9f4d26bbf81c2292ffa50c
18,896
def yes_or_no(question): """Asks a yes or no question, and captures input. Blank input is interpreted as Y.""" reply = str(input(question+' (Y/n): ')).capitalize().strip() if reply == "": #pylint: disable=no-else-return return True elif reply[0] == 'Y': return True elif reply[0] ==...
f441e39b85dc7407bedce5c120aa9839f0a3064f
18,897
def get_material_nodes_by_type(material, bl_idname): """ Find material nodes with bl_idname type name """ return (node for node in material.node_tree.nodes if node.bl_idname == bl_idname)
4406bf09a0d44ecb29e917dc7ff7d78b179cfbf8
18,898
import os def getFileExtension(filename): """Return the extension part of a filename, sans period, in lowercase.""" return os.path.splitext(filename)[1][1:].strip().lower()
d2fbedfe31cc9baec378d8332d4386c3fe2e7409
18,899
import requests def _good_response(status_code): """ Determines what status codes represent a good response from an API call. """ return status_code == requests.codes.ok
dd2aef136390640bae65ce41172b15da6e8fb078
18,900
def matching(tr_synth, tr_seis): """ matching zeroes all values of the seismic trace `tr_seis` outside the limits of the synthetic trace `tr_synth` Parameters ---------- tr_synth : numpy.array The synthetic trace tr_seis : numpy.array The seismic trace Returns ----...
55527b1302fd099e88353ea7c1ee447633a5a494
18,904
import random def generate_trace_id(): """ Create a random number formatted as a hexadecimal string, suitable for use as a trace identifier. """ return f"{random.randint(0, 2 ** 128 - 1):x}"
ffab4ce96b03903f70ba831dadb069aa4ab9c312
18,905
import os import re def get_current_container_id(read_from='/proc/self/cgroup'): """ Get the ID of the container the application is currently running in, otherwise return `None` if not running in a container. This is a best-effort guess, based on cgroups. :param read_from: the cgroups file to re...
5a536fc31f7abd2a5d4e081bceaef13aebbf5561
18,908
import numpy as np def _convert_to_colorscale(cmap): """ Return a colour scale list, as converted from a colour map. PURPOSE: This is a helper function used to convert a colour map into a colour scale list, as used by the Plotly colorscale parameter. DESIGN: Returned format: [(0.00, u'#f...
3d1aeb4bc02fb9553c27708596e8bafe4cd3b084
18,910
def robot_move(row, col, k): """ :param row: row of matrix, m :param col: col of matrix, n :param k: bit sum limit :return: num of blocks can reach """ def bit_sum(num): """ calculate bit sum :param num: num :return: bit sum """ b_sum = 0 ...
edf463b050deffd9de7c42816d672c7a3edc24b4
18,911
def booleanize_if_possible(sample): """Boolean-ize truthy/falsey strings.""" if sample.lower() in ['true', 'yes', 'on', 1]: sample = True elif sample.lower() in ['false', 'no', 'off', 0]: sample = False return sample
10ffb3481f15a7548512f01266027977a61a7e13
18,912
def normalize_feature_for_target_col(in_df, str_norm_target_col, abs_max_num): """ normalize designated column e.g. normalize col with max "60" [20, 30, 70, 65, -90] -> [0.333..., 0.5, 1.0, 1.0, -1.0] :param in_df : pandas.DataFrame, :param str_norm_t...
63eaa8065d6485d6bdacb850d318ed993225204f
18,913
import collections import operator def dnsbl_hit_count(log_data): """Counts how many hosts were found in each dnsbl.""" y = collections.defaultdict(int) for v in log_data.values(): for bl in v: y[bl] += 1 return sorted(y.items(), key=operator.itemgetter(1), reverse=True)
6a03054b7f50b1cbb27e58e4edc1212bb7cc2abf
18,915
def resize_lane(lane, x_ratio, y_ratio): """Resize the coordinate of a lane accroding image resize ratio. :param lane: the lane need to be resized :type lane: a list of dicts :param x_ratio: correspond image resize ratio in x axes. :type x_ratio: float :param y_ratio: correspond image resize ra...
23dacea6ac9820b73fad124433630a991ea14d37
18,916
def clean_up_database_str(string_to_transform): """Removes unneded chars from the string, retrieved from the database Args: string_to_transform: the string that should be parsed Returns: The fixed string """ return string_to_transform[3:-3]
45bc809f9e60efad69a4df0d6937cbf542966a95
18,917
from pathlib import Path def unique_filepath(filepath): """Generate a unique filename to ensure existing files are not overwritten. :param filepath: File-name, including path, to the file location :type filepath: str :return: Unique filepath (filename and path to file location) :rtype: str ""...
7ca638b1cd0f2ac4f0a9e720e659179da3e03e6a
18,918
def check_user_mask(input,verbose=False): """ Checks user-defined soft constraints by ensuring that input is a list of strings """ output = [] if not input: ouput = [] return output if (not isinstance(input,(list,tuple))): raise ValueError("\n User mask must be in the form of a list of tuples, each of len...
d36b79d7f12dade7f56aaafbcdec642b235e03c1
18,919
def shift(df, shift_map=None): """shift the dataframe Args: df (dataframe): origin dataframe shift_map (dict, optional): mapping of shift for columns of dataframe. Defaults to None. Returns: dataframe: shiftted dataframe """ if shift_map is not None: df = df.copy() ...
41a9948fe90a00f42a02a85a0f5c308b2c03954b
18,920
def merge_spending_diff(df_spending_current, df_spending_2013, df_spending_difference): """ Merge spending by brand and adverse events """ df_spending_2013 = df_spending_2013.drop(['average_spending_per_claim', 'average_spending_per_beneficiary', ...
5924dbccd278cbf9a1f5cd0a12dcef4bb293b895
18,921
def _attrfilter(label, value, expr): """ Build an `attrfilter(<label>, <value>, <expr>)` type query expression. `expr` is a query expression of any supported type. """ return "attrfilter({label}, {value}, {expr})".format( label = label, value = value, expr = expr, )
38dfc19bf043a9c327665c324f96d7f205ea6416
18,922
def isEmbeddedInOtherArc(arc, arcs, startIndex=0, stopIndex=-1): """ Check whether an arc is embedded within another arc between two indices. """ isEmbedded = False testArcs = [] for testArc in arcs: if (testArc[0] >= startIndex and testArc[-1] <= stopIndex ...
dec7d73b98e13b5f43b2aa62897dfea62afa5154
18,923
def genererate_principal(primary: str, instance: str, realm: str) -> str: """ Generate a Kerberos principal from the three different components. """ if instance: principal = "{}/{}".format(primary, instance) else: principal = primary return "{}@{}".format(principal, realm.upper(...
a39055e2029f044ce50107cb58860465491a5333
18,926
def foo(a, b): """function docstring""" return a + b
ca70214cc351b9807d472a3e94ff6291e6a054b9
18,927
import re def check_password_complexity(email, password): """ Check that a password meets the minimum complexity requirements, returning True if the requirements are satisfied, False otherwise. The rules are: - minimum length 10 - at least one lowercase letter - at least one u...
16bd2d99777a7d0764ce3b697b1c3319c60ccf87
18,928
def autoname(index, sizes): """ Given an index and list of sizes, return a name for the layer. >>> autoname(0, sizes=4) 'input' >>> autoname(1, sizes=4) 'hidden1' >>> autoname(2, sizes=4) 'hidden2' >>> autoname(3, sizes=4) 'output' """ if index == 0: n = "inp...
c7b426f7b3865472e64b84cab4ddff003cd47576
18,933
def _standardize(dataframe): """Transform features by centering the distribution of the data on the value 0 and the standard deviation to the value 1. The transformation is given by: scaled_value = (value - mean) / standard deviation Parameters ---------- dataframe : pandas.DataFrame ...
8db61585170223056e176e8b444a33a785cec591
18,934
def deform_conv_openvino(ctx, g, input, offset, weight, stride, padding, dilation, groups, defo...
226b1af110dd621710ce7eccbc4ad8f51e79f1db
18,935
import os def from_env(env_var, default): """ Gets value from envrionment variable or uses default Args: env_var: name of envrionment variable default: the default value """ new = os.environ.get(env_var) if new: return new else: return default
b9e1b248ff690bf2d6e1e65cfedb3a05b3a09e8f
18,936
def issues_data(record): """Retrieve issues data from record.""" total = int(record["total_files"]) issues = int(record["files_with_issues"]) correct = total - issues return total, issues, correct
9ff63711f50ef7df1c274d93eec3bd5780d2337d
18,937
import typing import random def shuffle_dependent_lists(*lists: typing.Iterable): """Shuffle multiple lists, but keep the dependency between them""" tmp = list(zip(*lists)) # Seed the random generator so results are consistent between runs random.Random(123).shuffle(tmp) return zip(*tmp)
44727399539a3864b19f7271d9f6506331a24d6d
18,938
from typing import Dict from typing import List def systemd_run( cpus: int = 4, memory_gigabytes: int = 8, env: Dict[str, str] = {} ) -> List[str]: """ Since we limit memory inside our VM we also limit the number of CPUs for the benchmark """ assert memory_gigabytes >= 1 # if 0 this is an empt...
7619f0ac600b0687182633b0bcc9181e40fa432a
18,939
import inspect def _wrapped_fn_argnames(fun): """Returns list of argnames of a (possibly wrapped) function.""" return tuple(inspect.signature(fun).parameters)
d68d744051c45c5992e700f06d91121af8738486
18,940
import logging def get_log(log_id): """ Return a logging object set to the given id. """ # print('¤'*100) # print('¤'*100) # print('¤'*100) # print(logging.Logger.manager.loggerDict.keys()) # print('¤'*100) for item in logging.Logger.manager.loggerDict.keys(): # print('{} _ {}'....
9533e2d35c487331234df40e93c0e50b6b1f4960
18,942
def modify_cert(conf): """This function modifies each of the certs (ca cert, client cert and client key) as a single line string to make it compatible with Grafana. """ fpd = open(conf["trustFile"], 'r') lines = fpd.readlines() tls_ca_cert = "\\n".join([line.strip() for line in lines])...
18a8a8628371d02874cfd5146bb7191eede3de91
18,944
import os import re def get_scenarios(fixtures_path, in_ext='yaml', out_ext='xml'): """Returns a list of scenarios, each scenario being described by two parameters (yaml and xml filenames by default). - content of the fixture output file (aka expected) """ scenarios = [] files = os.listdir...
6b78bef22611bc41eeb3781e13d6f34ab196b637
18,945
def clean_sql_statement(original: str) -> str: """ Cleans up SQL statements so that they end with a semicolon and don't have any leading or trailing whitespace """ clean = original.strip() if not clean.endswith(";"): clean = clean + ";" return clean
cf8bc73da26cd4cad363b8560170a37c6d5228de
18,946
def solution(N, A): """ This problem took me a good while to solve. The problem in itself is not hard, but the description is not very clear. I had to read it several times and even then, it took me a good few tries until I realised what it was asking me to do. If I had been given this task in ...
e70e6b24d566d93cf6dd58004c7668856a9f1cc8
18,947
def sort_keypoints(kps): """ Sort a list of cv2.KeyPoint based on their response """ responses = [kp.response for kp in kps] indices = range(len(responses)) indices = sorted(indices, key=lambda i: responses[i], reverse=True) return [kps[i] for i in indices]
7b1cc49498571715b2715118fb3887384d4e386c
18,948
def render_revert_function(autogen_context, op): """ Collect the function definition currently live in the database and use its definition as the downgrade revert target """ target = op.target autogen_context.imports.add(target.render_import_statement()) context = autogen_context engine = conte...
91f36487b4871141c69737cb35960bc3b87f5f99
18,949
import base64 import os def gen_private_key(): """Generate 32 byte random private key""" return base64.urlsafe_b64encode(os.urandom(32))
08e1558897480d8aac74c115f1138816775d380e
18,950
def normalize_none(value): """ Normalize a none string value to a None. """ if isinstance(value, None.__class__): return value if isinstance(value, str): if value.lower().strip() == "none": return None raise ValueError("Cannot convert {} to None".format(value))
7ed3de84dfa0c1c0cf3b1013eab2d978084769b9
18,951
def check_result_size(result: dict, parameters: dict) -> dict: """Returns the results according to the result_size. Only edits the targeted results, e.g. for a drug-search, only the drugs will be edited. :param dict result: Dictionary of the result. :param dict parameters: Dictionary of the task p...
0a06cfb2e23ce4505291eb20e8f71d66251fae16
18,957
def aumento_salarial(salario, porcentagem): """ Recebe um salário e sua porcentagem de aumento, e retorna o novo salário""" novosalario = salario + (salario * porcentagem / 100) return round (novosalario, 2)
7578f69bf486ba58374b70be673c1453694b3a72
18,958