content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
def apply(userdata, application, normfunc, limit, derate_value=0.9): """Filter project using a norm function that takes ability, need and project prestige as parameters. Will also generate a term that decreases the value a skill adds for everytime it is included in the resume to promote a larger variety...
4a779fcff0be4d3e6b0a32f01b7a0850820f4ecd
654,518
def int_from_le_bytes(bytes, signed: bool): """Converts a little endian byte array to an integer. """ return int.from_bytes(bytes, 'little', signed=signed)
7b80e5915ebd916b3abad369df85e8580b4d708b
654,519
def read_file(filename): """ opens and read a file from file system returns file content as data if ok returns None is error while reading file """ try: fhnd = open(filename) data = fhnd.read() fhnd.close() return data except: return None
7a43af8c0bdb073de8498c4cac8872f3594b1307
654,520
def get_class_details_broden(classname, labels, short_labels): """grabs cat number for a unit classname is the word name of the class labels is our list""" class_name = [x for x in labels if x.split(' ')[1] == classname][0] class_name = class_name.split(' ')[0] class_pos = short_labels.index(cla...
4b14a3359edd11f62cd9f1b89c85a931b594eda0
654,521
import numpy def surfker(dispersion, period, mode, wave, parameter, dp): """Compute sensitivity kernel.""" # Reference velocity c1 = dispersion(period, mode, wave) # Initialize kernel nl = len(dispersion._thickness) kernel = numpy.zeros(nl) # Love-waves are not sensitive to compressional...
287bd4b0c9f7d3aa2752b838e1f3873118dd099f
654,522
def bayesdb_table_populations(bdb, table): """Return list of populations for `table`. `bdb` must have a table named `table`. If you're not sure, call :func:`bayesdb_has_table` first. """ cursor = bdb.sql_execute(''' SELECT id FROM bayesdb_population WHERE tabname = ? ''', (table,)) ...
6ee56964fef0edd0f993213f60512582dff474d8
654,523
def remove_from(message, keyword): """ Strip the message from the keyword """ message = message.replace(keyword, '').strip() return message
7a173915cf0a17b5cf0d7a143012203b0b9a1835
654,524
import math def poisson_distribution(gamma): """Computes the probability of events for a Poisson distribution. Args: gamma: The average number of events to occur in an interval. Returns: The probability distribution of k events occuring. This is a function taking one parameter (k...
287d5b9c1289d170c013652dc981749403a21707
654,525
def indice(lst, n): """ Fonction indice qui, a partir d’une liste d’entiers lst et d’un entier n retourne None si aucun element de lst ne vaut n. Dans le cas contraire, l’entier retourne est l’indice du premier element de lst qui vaut n. """ indx = None # si n n'est pas dans la liste on ret...
75c7357ff9574abd78034533e7ab4b137b0626f7
654,526
def _preprocess(arr, target): """ Initializes a table which will store subset sums obtainable by the elements that have been previous considered. """ result = [[False] * (target + 1) for _ in range(len(arr) + 1)] result[0][0] = True # Go through each element in the array, and update the tabl...
4f10026a8523dbf177774d76c093d6fff2227d61
654,527
def repo(request) -> str: """Return ECR repository to use in tests.""" return request.config.getoption("--repo")
52eaf96e03368d9bc2e4bf4a2b0346e164465a64
654,528
def _merge_closest_intervals(intervals): """ Get the closest interval and merge those two """ diff = [y[0]-x[1] for x, y in zip(intervals, intervals[1:])] argmin = diff.index(min(diff)) new_interval = [intervals[argmin][0], intervals[argmin+1][1]] return intervals[:argmin] + [new_interval] + interv...
c7c0a5005a29b289181a698a30d23f11f28858cc
654,529
def load_priority_info(path): """Loads a dictionary containing error name as a key and its priority as its value from configuration file on given path. Args: path(str): Path to configuration file. """ with open(path) as priority_file: content = priority_file.readlines() configur...
fd0c4f47e166911bead56dd031765b7ce26c95e5
654,530
def list_unique_values(dictionary): """ Return all the unique values from `dictionary`'s values lists except `None` and `dictionary`'s keys where these values appeared Args: dictionary: dictionary which values are lists or None Returns: dict where keys are unique values from `dicti...
7e6a18c6130b830c343a9594342c3daaf1696843
654,531
def transposeAndMap(listoflists, fn=lambda x: x,nothing=""): """ takes a list of lists and returns its transpose after doing a point-wise mapping: listoflists = [[1,2],[3,4]] fn = str yields [["1","3"],["2","4"]] """ innerdim = max((map(len,listoflists))) outp...
14f19c2f29870cec650a135a3765901da18dcf4e
654,533
def get_libpaths(ldd_export): """ takes the ldd output file and decomposes it into meaningful lists """ lib_paths = [] ignored_cases = [] unknown_cases = [] with open(ldd_export, 'r') as fin: for line in fin.readlines(): splits = line.split() if len(splits) ==...
f6e08f1afdbd2ebd4d491b7646ad83255b298970
654,534
def get_picture_and_author(info): """ :type info: string """ characters = ['"', '}', '{'] for char in characters: info = info.replace(char, '') info = info.split(',') return info[1].split(':')[1], info[5].split('url:')[1]
04413d03bfa0180ee38fae926856da68cdaead61
654,535
def invert_dictionary(dictionary): """Swaps all pairs of key:value into value:key Does not check for uniqueness.""" return {v:k for k,v in dictionary.items()}
3361c24f47ca5f1f407048feaba4e394ea6710ed
654,536
def parse_shape_from_metadata(run_metadata): """Parse shape from metadata.""" dev_stats = run_metadata.step_stats.dev_stats name2shape = {} for dev_stat in dev_stats: node_stats = dev_stat.node_stats for ns in node_stats: if not ns.output: continue for i, output in enumerate(ns.output): ...
55b2c6c01af7cbf0fd75f1b3edab9902e6f8a02a
654,537
def timeseries_feature_builder(df, lag): """ feature builder - This section creates feature set with lag number of predictors--Creating features using lagged data Args: dataframe, and lag days return: the dataframe with the new data """ df_copy = df.copy() for i in range(1,lag): df_c...
75d92ba2dbba1356ec215e2be183d37633485a5c
654,538
import math import torch def wing_loss(landmarks, labels, w=0.06, epsilon=0.01): """ Arguments: landmarks, labels: float tensors with shape [batch_size, landmarks]. landmarks means x1,x2,x3,x4...y1,y2,y3,y4 1-D w, epsilon: a float numbers. Returns: a floa...
dcd9144ee369d6cec56202ba36f0cf2c33b8f90b
654,541
def py2(h, kr, rho, cp, r): """ Calculate the pyrolysis number. Parameters ---------- h = heat transfer coefficient, W/m^2K kr = rate constant, 1/s rho = density, kg/m^3 cp = heat capacity, J/kgK r = radius, m Returns ------- py = pyrolysis number, - """ py = h ...
5a9868feeeaa5a99cf06e2c47671beeab7d45156
654,542
def add_indicies(steps): """update the index of each""" return (step._replace(step_index=idx) for idx, step in enumerate(steps))
7f56869cd076ef5cc5cd1c0f35fcc3e5fb1bc87c
654,543
def create_shortened_link(): """ create a shortened link from the user """ return {"shortened_link": "http://pat.ly:8080/1"}
ac7116a89c973dd38527c2813da876fbfe23225e
654,544
def keys(dic, prefix=''): """ :return: All potentially-nested keys """ def _full(k_): return k_ if prefix == '' else f'{prefix}.{k_}' for k, v in dic.items(): if isinstance(v, dict): for k__ in keys(v, prefix=_full(k)): yield k__ else: ...
58d3d7ee0b41c36fb290a3dfd4e9be4f76a7b63f
654,546
def format_for_IN(l): """ Converts input to string that can be used for IN database query """ if type(l) is tuple: l = list(l) if type(l) is str: l = [l] return "(" + ','.join(['"' + str(x) + '"' for x in l]) + ")"
a2a755041c49af612e13e11da8148344b64a7926
654,547
def _sortByModified(a, b): """Sort function for object by modified date""" if a.modified < b.modified: return 1 elif a.modified > b.modified: return -1 else: return 0
03b3b0b97774b67ca04d2ebd97ca7d05307ff08d
654,548
import os def required(requirements_file): """Read requirements file and remove comments and empty lines.""" base_dir = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(base_dir, requirements_file), 'r') as f: requirements = f.read().splitlines() return [pkg for pkg in req...
af206a13988b688e8a2b2c12dafb6a1284572779
654,549
def stations_highest_rel_level(stations, N): """Creates list of the N station objects (Type MonitoringStation) with the greatest relative water levels, sorted in order. Args: stations (list of objects), N (number of stations to return) Returns: output (list of top N relative water level stations)...
0faeec14793822e0a9fdb51b3bfc8dd5062b08cd
654,550
def impedance(vp, rho): """ Given Vp and rho, compute impedance. Convert units if necessary. Test this module with: python -m doctest -v impedance.py Args: vp (float): P-wave velocity. rho (float): bulk density. Returns: float. The impedance. Examples: >>>...
3031eb86087c17e5e72723b38b7fe9a87d610ca5
654,551
def expand_url(url): """Add http:// if not already there. Use before browsing.""" if url.startswith('http'): return url else: return('http://' + url)
658912ce2293d78762dd953f1ac3c658b29ccb15
654,552
import sys import platform def get_info_system(): """Get info about user system""" return { "python_executable": sys.executable, "python_version": platform.python_version(), "machine": platform.machine(), "system": platform.system(), }
539250be76324a823d4f918d4ae39b8f253a26ab
654,553
import os def expand_path(path: str, relative_dir: str) -> str: """ Returns an absolute path by performing '~' and '..' substitution target path path: the user-provided path relative_dir: the absolute directory to which `path` should be seen as relative """ path = os.path.expanduser(path)...
3016c29672d3fb61777602f4f19075e33113611a
654,554
def qc_read_counts(document, file): """ Read in the file of read counts compiled from kneaddata logs with the utility script """ columns, samples, data = document.read_table(file, format_data=int) # shorten known database names columns=[name.replace("SILVA_128_LSUParc_SSUParc_ribosomal_RNA","r...
ae77de152b34b2801a240a6e27517ab664821dc4
654,557
def zaid2za(zaid): """ Convert ZZAAA to (Z,A) tuple. """ # Ignores decimal and stuff after decimal. zaid = str(int(zaid)) Z = int(zaid[:-3]) A = int(zaid[-3:]) return (Z, A)
58643b9d7adb3c0756e4de5d51c5a7d68a7a65e0
654,558
def expand_contractions(myString): """Expand contractions in input string english_contractions source: https://stackoverflow.com/questions/19790188/expanding-english-language-contractions-in-python Arguments - myString: a string of text Returns: - newString: a string of text with cont...
739b9d156684155b2d02c471c169f08259dc454d
654,559
import subprocess def exec_shell(cmd_line, raise_on_err=False): """ Execute a shell statement in a subprocess Parameters ---------- cmd_line: string, the command line to execute (verbatim) raise_on_err: boolean, optional, default: False, whether to raise ValueErro...
6bcda43bc444246a1a0b199c965057a8e374a1a7
654,560
def fast_adopt(g, ego, edge): """ Fast adoption function for triangle closing rule""" try: from_neighbors = set(g.node[ego]['M'][edge[0]]) # if concept 0 not in network, false if edge[1] in from_neighbors: # edge already exists return False to_neighbors = set(g.node[ego]['M...
851d65be40683072225fbfbb8caa5d1bc2076407
654,561
def filter_active_particles(particles): """Filter active particles from particles dict.""" return {particle_number: particle for particle_number, particle in particles.items() if particle['active']}
68e7d028e4f8cc94fc003af0eff5bfaa90f451a4
654,562
def extract_keys(feature_dict, feature_cls): """Extracts keys from features dict based on feature type. Args: feature_dict: `tfds.features.FeaturesDict` from which extract keys feature_cls: `tfds.features.FeatureConnector` class to search. Returns: List of extracted keys matching the class. """ ...
a1f514304ea0ca08b7350991303d8b7576ea9eee
654,563
import torch def split_last_dimension(x, n): """Reshape x so that the last dimension becomes two dimensions. The first of these two dimensions is n. Args: x: a Tensor with shape [..., m] n: an integer. Returns: a Tensor with shape [..., n, m/n] """ x_shape = x.size() m = x_shap...
bf8fcf41315b11221d7a931c152f5ffc9ac83b5b
654,564
import numpy def latlon_to_utm_zone_number(latitude, longitude): """ Find the UTM zone number for a give latitude and longitude. UTM zone will be returned for all the lat/longs within the input arrays, which must be of the same length. Function will also work with a single value, at which point a sing...
90c06714c76b543136b2e4a6a5e96d3eb3a3e253
654,565
def contains(collection, target): """Determine whether collecitons contains target """ return target in collection
2973fe1ad055bffd837f1db39cf34a18ce42314a
654,566
import argparse def parse_args(): """set and check parameters.""" parser = argparse.ArgumentParser(description='calc metric') parser.add_argument('--data_dir', type=str, default='../output') parser.add_argument('--income_preds', type=str, default='income_preds_{}.npy') parser.add_argument('--marri...
bd63df958cc9a718b2b96234ce863f060d4b6eec
654,567
import random def codingVectors(): """Create coding vetors.""" car1 = random.randint(63, 126) vetCod_1 = (car1 + 1) % 32 vetCod_2 = random.randint(1, 10) vetCod_3 = random.randint(1, 10) vetCod_4 = vetCod_1 + vetCod_2 + vetCod_3 vetCod_4 = vetCod_4 & 7 vetCod_4 = vetCod_4 + 1 l...
33f81adf3d89786b4bf190ff9f3764d35d16ff63
654,568
def _GetDownloadZipFileName(file_name): """Returns the file name for a temporarily compressed downloaded file.""" return '%s_.gztmp' % file_name
6fa71745fc97847d5e8ae21f22d73b0dd9663e7a
654,569
def simple_sanitize(s: str): """ Sanitize SQL string inputs simply by dropping ';' and ''' """ if s is not None: return s.replace(';', '').replace('\'', '') return None
02a89693ded22ce63ed45a7d50caf88697e11b39
654,570
def is_route_bfs(graph, node1, node2): """Determine if there is a route between two nodes.""" queue = [node1] visited_nodes = set() while queue: current_node = queue.pop(0) for child_node in graph[current_node]: if child_node not in visited_nodes: if child_nod...
9ad55c8ee1f2848c23fc36ae9942d41ebddae602
654,571
def _transform_activation(phi, params): """Transform an activation function phi using the given parameters.""" params = params.copy() input_scale = params.pop("input_scale", None) input_shift = params.pop("input_shift", None) output_shift = params.pop("output_shift", None) output_scale = params.pop("outpu...
6d8cd5ba9d3fc4284d6f6e02746c18fab6df3f78
654,572
def get_path_list(path): """ Expand the path to a sequence of nodes and costs. @param path: Path to return in text form. @type path: L{Path} @return: Sequence of nodes and steps from start to finish. @rtype: C{list} of (L{BaseState}, max+ cost-vector, evt-to-next) """ # Build the pat...
d7902c4e725bcc12e1edc7a30fb31994cc5d6410
654,573
import typing import pickle def deserialize(tar: str) -> typing.Any: """ 字节字符串反序列化为对象:b'\x80\x04N.' -> None """ b = eval('bytes({})'.format(tar)) return pickle.loads(b)
700c80699b3cc740c51d1a6fc0ed347a8cee7070
654,575
def pofiles_to_unique_translations_dicts(pofiles): """Extracts unique translations from a set of PO files. Given multiple pofiles, extracts translations (those messages with non empty msgstrs) into two dictionaries, a dictionary for translations with contexts and other without them. Args: ...
e88053759f78a7a5d210ce84819e290f33708396
654,576
import math def crop_mvs_input( images, cams, view_num, depths=None, max_w=0, max_h=0, base_image_size=8 ): """ resize images and cameras to fit the network (can be divided by base image size) """ # crop images and cameras for view in range(view_num): h, w = images[view].shape[0:2...
6b565e28b3809981dd63e93c579500c038612c33
654,577
import inspect def _isFunction(fn): """ Python class is also callable, so we need to deal with such pattern. class A: def b(self): return False a = A() callable(A) # True callable(a) # False callable(a.b) # True inspect.isclass(A) # True inspect.isclass(a) # False inspect.isclass(a.b) # ...
f8775e15c8a6f7c30f3dd0a7aa6a27c340f09b38
654,578
def ctz(x): """Return the number of times 2 factors into X.""" assert x != 0 r = 0 while ((x >> r) & 1) == 0: r += 1 return r
914e4075c7db38fcd0db3816e440a23aa86dfd19
654,579
import re def tt2nav(toctree, klass=None, appendix=None, divider=False): """ Injects ``has-dropdown`` and ``dropdown`` classes to HTML generated by the :func:`toctree` function. :param str toctree: HTML generated by the :func:`toctree` function. """ tt = toctree divider = '<li cl...
3f7537a6c7e7dd47ad5e5d3b4f0f7b6a453f8584
654,580
def is_label_ranker(estimator): """Return ``True`` if the given estimator is a :term:`label ranker`. Parameters ---------- estimator : object The estimator object to test. Returns ------- out : bool ``True`` if ``estimator`` is a label ranker and ``False`` otherwise. ""...
10c4ad8b45218a708245995522476f32596e4d8e
654,582
def read_device_map(path): """ A helper method to read the device path to address mapping from file:: 0x0001,/dev/device1 0x0002,/dev/device2 :param path: The path to the input file :returns: The input mapping file """ devices = {} with open(path, 'r') as stream: fo...
9f42334702830874216f4ffce7d66b4d8c05812c
654,583
def setup_backend_pars( request, cutoff, pure, batch_size ): # pylint: disable=redefined-outer-name """Parameterized fixture, a container for the backend parameters. Every test that uses this fixture, or a fixture that depends on it will be run three times, one for each backend. To explicitly mar...
135e5e723933498f03d5725c92f69a50309ddd05
654,584
import os def get_cache_path(filename): """ get crypto cache path """ homedir = os.environ['HOME'] return os.path.join(homedir, '.cache/polybar/crypto', filename)
d17b39edcddea136390324508215170665e073ef
654,585
import json def save_parameters(gamma, factor, sigmaV, sigmaW, max_iter_steps, method, use_template, filename, path2save, Kv = 'Default', comments = ''): """ """ dic = {} if Kv == 'Default' : print("Using default Kv as parameter : GaussKernel") Kv = 'GaussKernel' dic["gamma"] ...
66f4cc458083b27d9161621e4f69fba750528e4a
654,587
import os def path_to_outputs(request, base_temp): """ PyTest fixture that creates a temporary folder to save tests outputs. You can set the base directory by passing the ``--basetemp=mydir/`` argument to the PyTest call (See [Pytest - Temporary Directories and Files][1]). [1]: https://docs.pytes...
e320551488c8d606ec4cf863999d508b9bf48052
654,588
def get_all_tips_and_taxa_names(tree): """ get all taxa and tip names in a phylogeny return lists with information from each """ taxa = [] all_tips = [] # loop through the tree and collect terminal names for term in tree.get_terminals(): taxa_name = term.name[:term.name.index("...
b50ab6e6766b44d2173994836358e6f6282a8c45
654,589
def generate_html(content): """ Generates Shoutbox-HTML-Frame... Args: content: String containing preformatted data """ htmlstring = "<html><head><meta http-equiv='cache-control' content=" \ "'no-cache'><meta name='GENERATOR' content='PyShoutOut'>" \ "<titl...
f9fcd3d9ae9830ed1ffed1b2dcb8c0b6078e5528
654,590
def generateInd(size_nodal_mu, corner13theta, corner24theta, corner12mu, corner34mu, num_nodes): """Generates the ind list based on nearest nodal points and the size of the nodal mu array args: size_nodal_mu (int): Size of nodal mu array corner13theta - corner34mu (ints): Indices of nearest nodal points num_n...
e3f9d05bf99ae574252d1d2cc28ccc2eb22d3359
654,591
def _join_translated(translated_parts, os_sep_class): """Join translated glob pattern parts. This is different from a simple join, as care need to be taken to allow ** to match ZERO or more directories. """ res = '' for part in translated_parts[:-1]: if part == '.*': # drop ...
0b4d864dd0fe970671fbf574cdf4701b6241e847
654,592
def get_par_dict(e3d_par): """ return e3d.par as a dict :param e3d_par: path to e3d.par :return: dict """ d = {} with open(e3d_par, "r") as e1: t1 = e1.readlines() for line in t1: k, v = line.strip().split("=") d[k] = v return d
6216133d901accec2bac668f628e59700a57b7e6
654,593
from typing import Sequence def get_total_width(col_widths: Sequence[int], col_spacing: int) -> int: """Returns the total width of a definition list (or, more generally, a table). Useful when implementing a RowSepStrategy.""" return sum(col_widths) + col_spacing * (len(col_widths) - 1)
65117ef980e9ad8e98bcd3e3877bc07787ad2b21
654,594
from datetime import datetime import pytz def now_aware(): """Get the current datetime object, aware of the timezone (in UTC).""" return datetime.utcnow().replace(tzinfo=pytz.utc)
950c6f9825cb206995bf0d87bf66f7d2630a304b
654,595
def convert_string_tf_to_boolean(invalue): """Converts string 'True' or 'False' value to Boolean True or Boolean False. :param invalue: string input true/false value :return: Boolean converted True/False value """ outvalue = False if invalue == 'True': outvalue = True ...
29c59a95f7f308dadb9ac151b1325069cdfd3cdc
654,596
def mygcd(a, b): """ Method to determine the greatest common denominator of two numbers. Parameters: a (int): first number, must be greater than 0 b (int): second number, must be greater than 0 Returns: a (int): greatest common denominator of parameters a ...
2b6b3324ef5154d36c21f4c1cb9f34bf42f7a2df
654,597
def lines(string, keepends=False): """ Split a string into a list of strings at newline characters. Unless *keepends* is given and true, the resulting strings do not have newlines included. """ return string.splitlines(keepends)
cde9be4207dba6897de274be304c55f4b28ed916
654,598
def allot_list(src_list: list, n: int) -> list: """ 根据给定的组数,分配list给每一组-顺序分组 :param src_list: 源list :param n: 每n个分一组 :return: """ return [src_list[i:i + n] for i in range(0, len(src_list), n)]
c9f51efa5b4619dccec69fae7b20f9a8599374fb
654,599
def BuildCampaignOperations(batch_job_helper, budget_operations, number_of_campaigns, campaign_names): """Builds the operations needed to create a new Campaign. Note: When the Campaigns are created, they will have a different Id than those generated here as a temporary Id. This is jus...
faca10dd14c2902f4bb8cc4eb782c97f76829f72
654,600
import base64 def encode_group_id(group_id): """Encode group_id as returned by the websocket for use with other endpoints.""" return "group." + base64.b64encode(group_id.encode("ascii")).decode("ascii")
9779f344864b0ec1325a9d8628c86c4177fe9c94
654,601
def frame2trans(f): """ Get the xy(z) position from the 4x4 (3x3) frames / jacobi. Assume that the homogeneous matrices are in the last 2 dimensions of the array. Attention this is just a view of the Measurements! """ return f[..., :-1, -1]
f6c165364e47cbf61f8b3a7a798e9c13d9a735c2
654,602
import os def file_size(fname: str) -> int: # {{{ """Check file size fname - str - file name return - int - file size in bytes """ return os.stat(fname).st_size # }}}
6ed182472abc3e61b98e2600006d2830050985f9
654,604
def _get_service_status_code(instance): """Checking the status code of the cfy_manager_install_<type> service.""" result = instance.run_command( 'systemctl status {}'.format(instance.unit_name), use_sudo=True, hide_stdout=True, ignore_failure=True) return result.return_code
faf52f1fed4840d3a08ba4c352d46d5b61692b5a
654,605
def get_effective_power(unit): """Get effective power of unit.""" return unit['count'] * unit['damage']
3dc131cc0c4223644307ef75b3d913b35e1f5bb5
654,606
import re import os import subprocess def get_devenv_path() -> str: """ If a Nix development environment is on the PATH, return it. Otherwise invoke Nix to build the development environment, and return its path. """ match = re.search(r'/nix/store/[0-9a-z]{32}-noblit-devenv', os.environ['PATH']) ...
fe13ed129749305abd8f767c74d6c200ed4bcf41
654,607
import six from contextlib import suppress def is_valid_aesthetic(value, ae): """ Return True if `value` looks valid. Parameters ---------- value : object Value to check ae : str Aesthetic name Returns ------- out : bool Whether the value is of a valid loo...
c15e8dde3ffdde428016559555bb08c677f9003f
654,608
def lag(series, i=1): """ Returns a series shifted backwards by a value. `NaN` values will be filled in the beginning. Same as a call to `series.shift(-i)` Args: series: column to shift backward. i (int): number of positions to shift backward. """ shifted = series.shift(i)...
c026a54b1288301c1ae757a146f36dfdf5a87c2b
654,609
from typing import List import json def get_extensions() -> List[str]: """Carica le estensioni dal file extensions.json. Si aspetta di trovare una lista con i nomi delle estensioni da aggiungere al bot. Se non trova il file o ci sono errori ritorna una lista vuota. :returns: la lista coi nomi delle e...
808d638b15e56ab1e7a58ac2c955ace07efdd061
654,610
def unittest_parser(stdout, stderr, previous_reports=None): """ Example total_line: u'Ran 2 tests in 0.396s' Example fail status line: u'FAILED (failures=17)' """ lines = stderr.split('\n') # unittest pushes output to stderr total_line, status_line = lines[-4:-1:2] total_tests = int(total_...
2b34ad7bbd134424a016279fde483a9d3d356f2b
654,611
def aero_force(rho, V, C, A): """ Aerodynamic lift/drag equation Input variables: rho : Fluid density V : Fluid velocity C : Lift/drag coefficient A : Reference area """ F = 0.5 * rho * (V**2) * C * A return F
b8f13f945e8a55acde35cac0cabb97475b8adc59
654,612
import math def calcScalingCircle(PADDING_MAP, tilesize, mapheight, mapwidth, width, height): """Description. More... """ coord_x = math.floor(0.5 * (width - mapwidth * tilesize)) + math.floor(tilesize / 2) coord_y = math.floor(0.5 * (-mapheight * tilesize + height - PADDING_MAP)) + math.floor(ti...
4ced821952789d68f1d66df1210cbbe890296a0d
654,614
def is_anagram(word1, word2): """Checks whether two words are anagrams word1: string or list word2: string or list returns: boolean """ return sorted(word1) == sorted(word2)
dd1417f0ced25149e029ec87c0064fbaed7156c9
654,615
def read_packing(pack): """ in: pack -- pytables node containing a packing (e.g. `/N1024/P3.1620e-03/0090` in N1024~P3162e-3_tables.h5, or `/N1024/P3.1620e-03/0090/SR/0000` in N1024~P3.162e-3_shear.h5) >>> import tables >>> f = tables.File(r"N256~P1e-3_tables.h5") >>> node = f.root.__...
8bf5fcc61a25a432beb36abb3a7e268d5498f356
654,616
import string def name_make_safe(name, safe_chars = None): """ Given a filename, return the same filename will all characters not in the set [-_.0-9a-zA-Z] replaced with _. :param str name: name to make *safe* :param set safe_chars: (potional) set of characters that are considered safe. Def...
b93e5d8ca5cb992a389b4ad44ed0db9c0e6abf7f
654,617
def get_kick_drum2_note(instrument=11, start=0.0, duration=0.25, amplitude=30000, hi_frequency=200, lo_frequency=80, pan=0.5, decay=0.03, tension=0.2, hit=0.5, pbendq=4, od=0.02, oc=0.1, of=1, sustain=0.01, rezfmf=20, lpampf=8): """ ; Bass Kick...
37aff6c77d002c40cc84f77bf686df141bdc0467
654,618
import sys def profile(args): """This shouldn't be called.""" print(args) sys.stdout.write('Subcommands required, for help run fyrd prof -h\n') return 1
8a8151931c357f2903960b1c06e873905c2fc36d
654,619
import re def clean_docstring(docstring): """ Convert a docstring into ReStructuredText format. """ # Find backquoted identifiers, and double the backquotes to match RST. docstring = re.sub( pattern=r"`(?P<identifier>[A-Za-z_]+)`", # Backquoted identifiers repl=r"``\g<identifier>``", # ...
5d5d1ca3eefeb1dcd8290a311b47b9b03e3b62ea
654,620
def get_most_complete_version(versions): """ Return the most complete version. i.e. `versions=['1.4', '1.4.4']` it returns '1.4.4' since it's more complete. """ if not versions: return return max(versions)
2cf0b4d94388699b59eacad75d3c10464f659ad7
654,621
def rename_columns(df, columns_dictionary): """Renames provided columns. """ return df.rename(columns=columns_dictionary)
b30b095a95edfb634af474a4542d1cd8253e6b45
654,622
def shorten(thelist, maxlen, shorten): """ If thelist has more elements than maxlen, remove elements to make it of size maxlen. The parameter shorten is a string which can be one of left, right, both or middle and specifies where to remove elements. :param thelist: the list to shorten :param max...
72aa428b04b34737225717396946bce009be6bc1
654,623
def ByteToHex( byteStr ): """ Convert a byte string to it's hex string representation e.g. for output. """ return ''.join( [ "%02X " % ord( x ) for x in byteStr ] ).strip()
bb2c5898d99d39463fa8fe71293a6154d4339b0e
654,624
def find_largest(n: int, L: list) -> list: """Return the n largest values in L in order from smallest to largest. >>> L = [3, 4, 7, -1, 2, 5] >>> find_largest(3, L) [4, 5, 7] """ copy = sorted(L) return copy[-n:]
f509d1afd824e11f6996a64ad4a40c2b55288a01
654,625
import numpy def _compute_iou(machine_mask_matrix, human_mask_matrix): """Computes IoU (intersection over union) between human and machine masks. :param machine_mask_matrix: Boolean numpy array, representing areas of extreme positive or negative interpretation values. :param human_mask_matrix: Sa...
c90b4b854a25b436cc94a89282ea480027aa664a
654,626
def update_parameters(parameters, grads, learning_rate = 1.2): """ Updates parameters using the gradient descent update rule given above Arguments: parameters -- python dictionary containing your parameters grads -- python dictionary containing your gradients Returns: parameters ...
8dc071f7d10b61ccdfd33e00404f805ad5b7ce1c
654,627
from typing import Sequence import fnmatch def _should_ignore(fd_name: str, patterns: Sequence[str]) -> bool: """Return whether `fd_name` should be ignored according to `patterns`.""" return any(fnmatch.fnmatchcase(fd_name, pattern) for pattern in patterns)
e41d8b8f8c80331f24210bd6e79c10b3e77f727b
654,628