content
stringlengths
39
9.28k
sha1
stringlengths
40
40
id
int64
8
710k
def get_dparse2_supported_file_name(file_name): """ Return the file_name if this is supported or None given a `file_name` string. """ # this is kludgy but the upstream data structure and API needs this dfile_names = ( 'Pipfile.lock', 'Pipfile', 'conda.yml', 'setup...
ce4e1120f6d7ddc403d8eb351df72bb5b8d6e9c0
228,561
import re def _is_valid_frequency(value: str) -> bool: """Returns true if the frequency passed is an instance of string, is not None, and adheres to the regex patterns for frequency strings. """ pattern = r"^\d+[smhdwM]$" return isinstance(value, str) and re.match(pattern, value) is not None
b450ae2b18f06d006b3693bc6281cf793ebeae29
612,438
def filename_handler_null(fname): """A lazy filename handler that simply returns its input. Args: fname (str): A file name. Returns: str: Same file name. """ return fname
36393198ef8aa6723e175e41c3493c81f64e08f0
470,235
def parse_bm_alleles_col(_str): """ Parse 'alleles' column of biomart response """ if _str == '': return [] else: return _str.split('/')
31e562608781e14decca447073b45bae1f20c8f4
691,562
import __main__ as main def is_ipython_interpreter() -> bool: # pragma: no cover """Return if we are in an IPython interpreter or not.""" return hasattr(main, '__IPYTHON__')
a06509e767641a56fbe10e777dab174165ed9af5
350,801
def _map_relation(c, language='any'): """ Map related concept or collection, leaving out the relations. :param c: the concept or collection to map :param string language: Language to render the relation's label in :rtype: :class:`dict` """ label = c.label(language) return { 'id'...
ee8d82eaf2e1153b943d1851c85c81546c427f16
550,377
def get_counts_by_tract(mf_with_tract, output_col_name): """Return a dataframe containing the the mortgage foreclosure counts by Census Tract by year. Parameters ---------- mf_with_parcels : pandas df Mortgage foreclosure data, where each row represents a foreclosed property and its parcel ...
e4d204889ab67e28e1abf90cc0618fd23fedaef7
114,573
def get_azure_users(azure, users): """ Get list of user data from Azure Active Directory Parameters ---------- az: object flask-dance Azure object users: list email addresses Returns ------- list Azure user principal names (should match email) """ em...
6708421e6c4e93a047c597cf721a7fe225578c7b
474,633
def match_with_gaps(my_word, other_word): """ my_word: string with _ characters, current guess of secret word other_word: string, regular English word returns: boolean, True if all the actual letters of my_word match the corresponding letters of other_word, or the letter is the special s...
0e4907caed4931b9d85fa8571c476d88691ee1a0
312,993
def _get_json_schema_node_id(fully_qualified_name: str) -> str: """Returns the reference id (i.e. HTML fragment id) for a schema.""" return 'json-%s' % (fully_qualified_name,)
eafdacc1e7c4f2feabcd5b486fb264d33332266d
26,701
def calculate_rtu_inter_char(baudrate): """calculates the interchar delay from the baudrate""" if baudrate <= 19200: return 11.0 / baudrate else: return 0.0005
dcda292631a335e69ad209812aee684876081ca7
166,314
def split_part_key(key): """ Split the standard part key. Only returns port if present in key. Parameters ---------- key : str Standard part key as hpn:rev Returns ------- tuple hpn, rev, [,port] """ split_key = key.split(":") if len(split_key) == 2: ...
dfd59f64a442b98fb744d78110a8eba600500d5f
317,951
import six def utf8(string): """Convert a Unicode or utf-8 encoded string to a native Python str. This function's name is misleading: while on Python 2 it really returns a utf-8-encoded string, on Python 3 it return a native Unicode Python str. This function is robust to incorrectly-enco...
aa696782d03fc8e96046e47e8595c007ba446bfe
573,635
def get_end_linenumber(text): """Utility to get the last line's number in a Tk text widget.""" return int(float(text.index('end-1c')))
8768a6ce777087ee1730b41efd9a41180672c33b
638,889
import re def stat_check(string): """Validate input of filter string for values like atime, mtime, ctime. These shuld be integer values prefixed by a + or a - only with no spaces Eg: 1 5 -10 +20 Invalid: 1.5 abc $#@ + 5 a5 ...
2d40873d3838d817cfd0932f436fa8eeb2cdc1b8
622,302
def find_seq_rec(block, name, case_sensitive=True): """Given part of a sequence ID, find the first matching record.""" if case_sensitive: def test(name, rec): return name in rec['id'] else: def test(name, rec): return name.upper() in rec['id'].upper() for rec in ...
58d590cda5a427416ade3756edfff7b1eec6546e
522,370
import re def parse_show_core_dump(raw_result): """ Parse the show core-dump output. :param str raw_result: vtysh raw result string. :rtype: dict :return: The parsed result of the show core-dump \ in a dictionary of the form: :: { 0:{ 'instance_i...
124ed157bbb4cc8a60a4b05af94dc3b85489fcfd
553,580
def create_tokens_and_tokentypes(tokens_a, tokens_b, cls_id, sep_id): """Merge segments A and B, add [CLS] and [SEP] and build tokentypes.""" tokens = [] tokentypes = [] # [CLS]. tokens.append(cls_id) tokentypes.append(0) # Segment A. for token in tokens_a: tokens.append(token) ...
0f72f261ff1e0ee2d304321cd0bbc0af9c662b4b
688,190
def extract_files_to_lint(file_diffs): """Grab only files out of a list of FileDiffs that have a ACMRT status.""" if not file_diffs: return [] lint_files = [f.name for f in file_diffs if f.status in b'ACMRT'] return lint_files
3594bd942f132f7c815df3423eaef6c0de882588
82,123
def copy_dict_or_new(original: dict) -> dict: """Makes a copy of the original dict if not None; otherwise returns an empty dict. """ if original is None: return dict() return dict(original)
d3315b39fe26e97aca1ebf4fa320f87852348bbc
443,128
def get_message( items: list[str], sort: bool = False, oxford: bool = True, separator: str = "," ) -> str: """Get message. >>> get_message(["chips", "pie", "soda"], separator=";") 'You are bringing chips; pie; and soda.' >>> get_message(["chips", "pie", "soda"], oxford=False) 'You are bringing ...
78c81340c7cfa62497bf4554b6dc0dd66c083e06
344,320
def format_datetime(session): """Convert date or datetime object into formatted string representation. """ if session.data is not None: date_format = session.field.opts.date_format if date_format == 'iso8601': session.data = session.data.isoformat() else: sess...
53a99843e47dde6b82cb48e77fd553bbf65dd646
698,881
def conv_F2C(f): """Convert fahrenheit to Celsius""" return (f - 32.0) * 0.555556
24daec5ea411dd1eb793193b8b6c42f85236d813
393,900
import re def decodetype(type_): """ Decode Type. >>> decodetype('r') (True, None, False, False) >>> decodetype('w') (False, None, True, False) >>> decodetype('u') (False, None, False, True) """ r = re.compile(r"(r)([1-9]?)") m = r.match(type_) if m: read = m.g...
26fb491c6759cef4c38c2832afa330070229f104
415,354
def is_part_of(L1, L2): """Return True if *L2* contains all elements of *L1*, False otherwise.""" for i in L1: if i not in L2: return False return True
1518489ffab2ea2efdc8aeb04b94359f3279f08d
345,577
import pathlib def get_fixture_path(filename: str) -> pathlib.Path: """Get path of a fixture.""" return pathlib.Path(__file__).parent.joinpath("fixtures", filename)
ec058b5204778a39912bf7cb5a3022945f0f8fb5
333,464
import torch def right_shift_to_zero(x, bits): """Right shift with quantization towards zero implementation. Parameters ---------- x : torch.int32 or torch.int64 input tensor. bits : int number of bits to shift. Returns ------- torch.int32 or torch.int64 right...
c83ffdec97dfc57c7f44e14467495b7105cb969a
580,119
import hashlib def hash_file(filename, hash_type, as_hex=True): """ Hash a file using SHA1 or MD5 :param filename: :param hash_type: 'sha1' or 'md5' :param as_hex: True to return a string of hex digits :return: The hash of the requested file """ h = getattr(hashlib, hash_type)() ...
2e81d506880dd88371f4b764634cd525ee2b762d
535,072
def get_estimated_max_weight(weight, num_reps): """Returns the estimated max weight based on weight and reps.""" estimated_max = weight * (1 + num_reps / 30.0) return float("{0:.2f}".format(estimated_max))
28a608ee34173b66008f2ba2d7a761ca7b758739
620,857
def dot(a, b): """Compute the dot product between the two vectors a and b.""" return sum(i * j for i, j in zip(a, b))
93c727467a62ec3ce93a0b612624cb0eab57b120
593,135
def dataclass_param(request): """Parametrize over both implementations of the @dataclass decorator.""" return request.param
4954d0fe17b620f592d1899af885d1a221f8ad24
568,908
import math def prime_check(number: int) -> bool: """Checks to see if a number is a prime in O(sqrt(n)). A number is prime if it has exactly two factors: 1 and itself. >>> prime_check(0) False >>> prime_check(1) False >>> prime_check(2) True >>> prime_check(3) True >>> pr...
6e67b379262437f5eb04473c9259d98997566a3e
622,937
def doprefix(site_url): """ Returns protocol prefix for url if needed. """ if site_url.startswith("http://") or site_url.startswith("https://"): return "" return "http://"
fc53d4f9f113be79b68becec8b7332c96d779127
123,624
from typing import Union def num_cvt(string: str) -> Union[int, float]: """ >>> num_cvt("2007") 2007 >>> num_cvt("3.14") 3.14 >>> num_cvt("1,234") 1234 """ try: return int(string) except ValueError: pass try: return float(string) except ValueErro...
d99019a5bbd5a6490adf85758c14b815a0c8a3b3
568,690
def convert_alt_list_to_string(alt): """ The ALT field in the VCF file is represented as a list, can convert this to a comma seperated string. """ _vars = list() for _var in alt: _vars.append(str(_var)) return ','.join(_vars)
11aef24df506094d711eb6e8e644a1272d461c78
73,123
from pathlib import Path import yaml def yaml_to_dict(filepath): """Get a dictionary from a yaml file. :param str filepath: the file path to the yaml file. :return: dictionary representation of the yaml file. :rtype: dict """ with Path(filepath).open('r') as f: return yaml.safe_load...
411435694fd8bc2f107decace982a46854d5b437
75,625
def should_include(page, target_name): """Report whether a given page should be part of the given target""" if "targets" not in page: return False if target_name in page["targets"]: return True else: return False
e3b69ca957ad152a783a177e0cc59355c4e54c27
358,219
def float_to_text(value, sig): """ Convert float to text string for computing hash. Preseve up to N significant number given by sig. :param value: the float value to convert :param sig: choose how many digits after the comma should be output """ if value == 0: value = 0. # Identify...
2f43348ce9f434dc62064f84b8d61e572a02d7cc
608,798
def is_integer(variable): """Checks if a variable is an integer value""" return type(variable) == int
d8f13deab6aea7fbd3b2b546a43284ae5b787f15
416,293
def _models_save_all_function_name(model): """Returns the name of the function to save a list of models as existing records""" return '{}_save_all_existing'.format(model.get_table_name())
14cae95731dcb0e42ebd7b2be31d3a7294d9a120
583,609
def empty_dropper(item): """Used for list/dict types that may contain empty strings Recurses over the lists and dicts, replacing '' with None values""" if isinstance(item, dict): return {k: empty_dropper(v) for k, v in item.items()} elif isinstance(item, list): return [empty_dropper(v) ...
98d56a74cd5a5fe36f17371dd42c4a3eaaf5729f
148,888
def find_tri_div(n): """ Find the smallest triangle number with over `n` divisors. """ if n < 1: return 1 # Start with the 2nd triangular number tri = 3 num = 2 while True: # Start divisor count with 1 and the number itself. div_cnt = 2 i = 2 limit = tri ...
628b1e7a62a5dd438be8ebcdeb5a67800808d024
127,712
def get_tip_labels(tree_or_node): """Returns a `set` of tip labels for a node or tree.""" try: return {x.taxon.label for x in tree_or_node.leaf_node_iter()} except AttributeError: return {x.taxon.label for x in tree_or_node.leaf_iter()}
2d6edfb1e7bf9671cd3b78b73aa006339b21ee0c
82,942
def v2_subscriptions_response(subscriptions_response): """Define a fixture that returns a V2 subscriptions response.""" subscriptions_response["subscriptions"][0]["location"]["system"]["version"] = 2 return subscriptions_response
59319dd263672bb37b68a996fb9b713160bc8449
309,070
def get_min_dist_node(dist, visited): """ Gets the node with the minimum distance from the unvisited nodes Args: dist (dict): dictionary with nodes as keys and values is a liste which first element is the minimum distance and second one is the closest node visited (array): array of visited ...
b13bfd4b5c0203ae6b4629100cd8afba4be51450
158,273
def my_split(text, delimiter = ' '): """ Particiona uma string a cada ocorrência do delimitador. Considerando a string e o delimitador passados como parâmetro, cada ocorrência do delimitador gera um novo particionamento da string. As partições são armazenadas numa lista que será retornada. O espaço em ...
b0e357b2efeb828ceda5959a8f46a4b0bb03cafe
218,547
def find_cms_attribute(attrs, name): """ Find and return CMS attribute values of a given type. :param attrs: The :class:`.cms.CMSAttributes` object. :param name: The attribute type as a string (as defined in ``asn1crypto``). :return: The values associated with the requested ...
7ce3d9c12ca919b7b35539f1a85ddfe4a96cb449
489,638
def seconds_between(left, right): """ Calculates seconds between two datetime values Args: left (time): Greater time value right (time): Smaller time value Returns: time: Total difference between two datetime values in seconds """ return (left - right).total_seconds()
071a01b98ca310d008df43b5cb8c56bd76ddcb78
414,582
def count(geo): """ count the number of atoms in the geometry """ return len(geo)
73efc9a1c32a9c8abc1f4fcda38b2cf1cb23fd26
452,146
def _transpose_list(list_of_lists): """Transpose a list of lists.""" return list(map(list, zip(*list_of_lists)))
854c8cea5ef7f54bf4c41bb505980474c8daba28
486,919
def gps_to_utc(gpssec): """ Convert GPS seconds to UTC seconds. Parameters ---------- gpssec: int Time in GPS seconds. Returns ------- Time in UTC seconds. Notes ----- The code is ported from Offline. Examples -------- >>> gps_to_utc(0) # Jan 6th, 1980 ...
342c479df8d4c864592494e8d50452e9f02c04d5
18,804
import random def sample(max_index, size=40000, split=8000): """Samples indices.""" indices = random.sample(range(max_index), size) train = indices[:-split] test = indices[-split:] return train, test
aa650781c35d0b73b9edc441f0ebcd4577fa5821
587,201
def toHexString(value): """ Returns a clean hex (no hash) string for a given input """ return str(hex(value))[2:]
9d02cd3cbc469c25c0235de658cf69bb8861d260
589,555
def default_zero(input): """ Helper function that returns the input, replacing anything Falsey (such as Nones or empty strings) with 0.0. """ return round(input if input else 0.0, 2)
d5c06c9f0449277e5fc2b8083335fa7e35595305
40,256
def gpm2m3_s(gpm): """gpm -> m^3/s""" return 6.3090196e-05*gpm
84feddeca5bffe56eb17842a97b2a436c916a2db
263,941
from typing import List import random def rollDice(dice1=True) -> int: """Returns random number between 1 and 6 or 1 and 12 depending on if dice1 is Treu or False""" if dice1 is True: rolls: List[int] = [1, 2, 3, 4, 5, 6] return random.choice(rolls) rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...
24c74f727e3b620d173182c09bee38d5c29a8af6
138,874
def classname(object, modname): """Get a class name and qualify it with a module name if necessary.""" name = object.__name__ if object.__module__ != modname: name = object.__module__ + '.' + name return name
af4e05b0adaa9c90bb9946edf1dba67a40e78323
766
def divide(n, iterable): """Divide the elements from *iterable* into *n* parts, maintaining order. >>> group_1, group_2 = divide(2, [1, 2, 3, 4, 5, 6]) >>> list(group_1) [1, 2, 3] >>> list(group_2) [4, 5, 6] If the length of *iterable* is not evenly divisible by *n*...
649b057378e74bb94e5d085d1dd583db677c6616
347,662
import re def find_alignment_gaps(alignment): """ Returns location (in list form) of alignment gaps in a sequence """ return([char.start() for char in re.finditer("-", alignment)])
813d1fe587cec1094475395b9057c820e49557ab
530,699
def fillnan(series, value, **kwargs): """ fill nan values in series with value """ return series.fillna(value)
c7be865ec91f0fc5c385c6ba836697a949300e9f
308,373
import numbers def is_numeric(value): """ Test if a value is numeric. :param value: input value :return: boolean value. """ return isinstance(value, numbers.Number)
297df40e3682f7427d7bae7493d43d013d9523c1
358,522
def unique_fname(full_path: str) -> str: """Get unique file name for given full path to MELD data file. The return format is '[dialog]_[utterance]'. :param full_path: full path to MELD .mp4 data file :return: unique id of data file (only unique within dataset directory) """ fname = full_path.split(...
29bffc8a2028ac126709fe17d9e2e1d2914bf769
26,658
def pastis_matrix_measurements(nseg): """ Calculate the total number of measurements needed for a PASTIS matrix with nseg segments :param nseg: int, total number of segments :return: int, total number of measurements """ total_number = (nseg**2 + nseg) / 2 return int(total_number)
133cb69837651ac3e6d0891179b365367fe848cc
694,508
import time def convert_to_minutes(seconds): """ convert an amount of seconds to minutes and seconds """ return time.strftime("%M:%S", time.gmtime(seconds))
51fe1a52f02a60fb3440f035dbefd85410601ff9
329,564
def filter_for_sprl(c): """ Given a BIDSFile object, filter for sprl type file """ try: val = "sprlcombined" in c.entities["acquisition"] except KeyError: return False else: return val
6f05313701ecc01512fedf05709e5e13629c467d
21,920
from typing import Tuple def _unmerge_points( board_points: Tuple[int, ...] ) -> Tuple[Tuple[int, ...], Tuple[int, ...]]: """Return player and opponent board positions starting from their respective ace points.""" player: Tuple[int, ...] = tuple( map( lambda n: 0 if n < 0 else n, ...
25965e023030266cc92e6b1456483204ad2c863a
703,206
import re def remove_punctuation(string, hyphens_are_separators=True, keep_commas=False): """removes punctuation from a string (simple regex replacing everything but w and s with nothing) and returns the string Keyword arguments: string -- the string to remove punctuation from hyphens_are_separat...
0cb9184d748fba00ed0a683a2328ddab3bd61a8a
589,003
def compare(a, b): """Return -1/0/1 if a is less/equal/greater than b.""" return 0 if a == b else 1 if a > b else -1 if a < b else None
88fcfb93da232f13047bd04528f462da322fd967
283,015
def binary_count(a: int) -> int: """ ambil 1 bilangan integer dan kemudian mengambil angka yaitu jumlah bit yang berisi 1 dalam representasi biner dari nomor itu contoh bilangan biner dari 25 25 = 11001 yang berarti 3 angka 1 dari 25 >>> binary_count(25) 3 >>> binary_coun...
d8c882be9ccc0fa4d2cc0be134a7579c5df572bb
246,701
def is_success(status): """ Check if HTTP status code is successful. :param status: http status code :returns: True if status is successful, else False """ return 200 <= status <= 299
5d28acbc98ebd5b5baaadca1668a29e649c8c1d2
317,119
def _jsnp_unescape(jsn_s): """ Parse and decode given encoded JSON Pointer expression, convert ~1 to / and ~0 to ~. .. note:: JSON Pointer: http://tools.ietf.org/html/rfc6901 >>> _jsnp_unescape("/a~1b") '/a/b' >>> _jsnp_unescape("~1aaa~1~0bbb") '/aaa/~bbb' """ return jsn_s.repl...
36260a38b42119e1f78a2cdd2c3f3994fae8ae47
487,297
import bz2 def decompress(data): """ Helper function to decompress data (using bz2) """ c = bz2.BZ2Decompressor() return c.decompress(data)
18dee25febbc1e3ce9e709d19129169e60fb928a
369,071
from typing import List from typing import Dict import heapq def top_anomalies(points: List[Dict], n=10) -> List[Dict]: """Returns top n anomalies according to severity.""" return heapq.nlargest( n, points, key=lambda point: point["severity"] )
a7ed3495070e3c8b913137736b1cb841c93443db
118,093
import json def read_file(file_path, is_json=False): """ Read a file. Parameters ---------- file_path : str Path that the file should be read from. is_json : boolean Flag representing if the file should is JSON. """ if is_json: with open(file_path, 'r') as meta...
12da18361ceb98e76dcb14aefdb48f0688f7e145
379,821
def read_list_from_file(filename): """ Reads in a list from file. Assumes that every line is a different entry. Args: filename - the name of the file that contains the list Returns: list """ l = [] with open(filename, 'r') as inputfile: for username in inputfile: l.append(username.strip()...
b4fa66d5f1f7f485ba1d5295557307fa43089a83
365,724
def bdp_B(bw_Mbps, rtt_us): """ Calculates the BDP in bytes. """ return (bw_Mbps / 8. * 1e6) * (rtt_us / 1e6)
b2c5a23cab22812b3f6bd2cf184b2bc0d21ced02
274,737
def floatnan(s): """converts string to float returns NaN on conversion error""" try: return float(s) except ValueError: return float('NaN')
b618013ea76346e248b21ed0fc5f0b6a3cbbab95
622,270
def print_perf(start, end): """Print diff as ms between start and end times (floats in secs).""" diff = (end - start) * 1000 print('{:.2f} milliseconds elapsed'.format(diff)) return diff
796b38069e25d77697601fdedb9a86409d12eaca
168,804
import itertools def contains_peroxide(structure, relative_cutoff=1.2): """ Determines if a structure contains peroxide anions. Args: structure: Input structure. relative_cutoff: The peroxide bond distance is 1.49 Angstrom. Relative_cutoff * 1.49 stipul...
5db51989f823b3a6cc113267371459e8cf37d920
649,296
import requests def getSTCNItem( itemLocations: list, holdingArchive: str = "Amsterdam, Rijksmuseum Research Library", ENDPOINT: str = "http://data.bibliotheken.nl/sparql"): """ Find the STCN item for a given itemLocation and holdingArchive. Args: itemLocations (list): The...
4520d115a2fd2dc4397f0030109e400d9d8a1317
129,925
def add_iam_binding(policy, member, role): """Adds binding to given policy. Args: policy: Policy. member: Account, e.g. user:joe@doe.com, serviceAccount:..., etc. role: Role Returns: True if binding was added. False, if binding was already present in policy. """ # Check if member is already ...
90769af439ee4a054365fece170fd7887edbec6c
252,968
def tokens_to_text(token_list): """Convert a list of binja tokens to plain text Mostly useful for testing """ return ''.join([tok.text for tok in token_list])
9aae7abd351578f52b37de28ae886ffa3fee06a7
590,764
def _flatten_array_to_str(array): """ Helper function to reduce an array to a string to make it immutable. Args: array (array): Array to make to string Returns: string: String where each value from the array is appended to each other """ s = "" for i in array: s...
229bb0f3908717d87964c24cb2e13f357727c837
619,820
def skeaf_code(aiida_local_code_factory): """Get a skeaf code.""" return aiida_local_code_factory(executable="diff", entry_point="skeaf")
7aa3b904796ad6f38e1abfda96959269732c3f93
596,051
def _maybe_correct_vars(vars): """Change vars from string to singleton tuple of string, if necessary.""" if isinstance(vars, str): return (vars,) else: return vars
1aa46b03988f06a3697b703991c64899e173d0eb
40,453
import re def is_valid_remote_clone_id(remote_clone_job_id): """ Validates a remote clone job ID, also known as the remote clone job "job_name". A valid remote clone job name should look like: dstrclone-00000001 - It should end with 8 hexadecimal characters in lower case. :type remote_clone_j...
186700e080bc372679d14b7af6ed8e83dcc4f04b
620,099
def get_streamer_id(video_str): """Gets the streamer ID based on the name of the video :param video_str: String name of the video :return: String containing the streamers ID """ streamer_id = "" started = False for char in video_str: if char == '_': if not started: started = True else: return s...
f2cc61d55d401d727a753c833bd85a2916effe43
553,018
import torch def get_cyclic_scheduler(optimizer, batches_per_epoch, base_lr=10e-6, max_lr=0.1, step_size_factor=5): """ Get cyclic scheduler. Note that the resulting optimizer's step function is called after each batch! :param optimizer: optimizer :type optimizer: torch.optim.Optimizer :para...
826837231f5ec5e9db159ee2ff00a2f49e265d60
252,619
def polynomial_3_differential(x, a, b, c, d): """Polynomial order 3 where f(x) = a + b * x + c * x**2 + d * x**3 Differential(f(x) = b + 2.0 * c * x**1 + 3.0 * d * x**2 """ return b + 2.0 * c * x + 3.0 * d * x**2
40bd4df94b956cd7e7145f850446840a913b09fc
432,914
def robot_point_creator(dict_point): """Fonction qui permet de convertir les données dictionnaires de configuration de la forme du robot en une liste de point Args: dict_point (dict): dictionnaire de configuration de la forme du robot Returns: liste: liste des coordonnées dans le repère du...
33ce0607ec7c59c903c63050abeafe4f8dcd1259
68,364
import re def split_revisions(version_string): """ Returns a list of revisions pulled from the version string. Revisions are separated by -, _, or ~ """ return re.split('[-_~]', version_string)
d0d49d540ee770826fc3e615ec361203d8f0d65b
509,299
def abs_list(in_list): """ Return abs() of each element in in_list, e.g. [2, 3+4j, -6] -> [2, 5, 6] """ return [abs(x) for x in in_list]
ea3721ad8cc334d1a049756e4dcff55a936dd0fe
367,276
def guess_module_name(fct): """ Guesses the module name based on a function. @param fct function @return module name """ mod = fct.__module__ spl = mod.split('.') name = spl[0] if name == 'src': return spl[1] return spl[0]
e7153ad73178840108c60167fc155abf32edca61
574,256
def register(client, username, password, confirm_password): """ Fires a post request to the register route """ return client.post("/register", data=dict( username = username, password = password, confirm_password = confirm_password ), follow_redirects=True)
f5557a6c9aee7af58bbccb6e085bdf81d12a5d7b
405,665
def gather_types(input_step, varname): """ Given and input step, return a SPARQL fragment to gather the types for the step :param input_step: :return: SPARQL fragment as string """ if not input_step['object']['literal']: return ' ?' + input_step['object']['name'] + ' a ?' + varname + ' ....
b8e07817ee160b05b5e97db9a8e7dc334e3dcf95
312,109
import colorsys def hsv_to_rgb(h, s, v): """ Convert an HSV tuple to an RGB hex string. h -- hue (0-360) s -- saturation (0-100) v -- value (0-255) Returns a hex RGB string, i.e. #123456. """ r, g, b = tuple(int(i * 255) for i in colorsys.hsv_to_rgb(h / 360, s / 1...
48bb7e31f16b6c435094aa990bb4d02f06cc37f7
696,673
import requests def _request_limit_reached(exception): """ Checks if exception was raised because of too many executed requests. (This is a temporal solution and will be changed in later package versions.) :param exception: Exception raised during download :type exception: Exception :return: `Tru...
67280ea48cce3238d0c574ec8ad1b13719df4990
25,197
def CreateHyperspectralImageRectangular(embedding, array_size, coordinates, scale=True): """Fill a hyperspectral image from n-dimensional embedding of high-dimensional imaging data by rescaling each channel from 0-1 (optional). All coordinates in the image not listed in coordinates object will be masked ...
3760c420a512859efd60c0e34c204a4dae3f0cb6
451,680
import re def _compute_replacement(dependency_version_map, androidx_repository_url, line): """Computes output line for build.gradle from build.gradle.template line. Replaces {{android_repository_url}}, {{androidx_dependency_version}} and {{version_overrides}}. Args: ...
1c5031e3b0ab483bf8cf06661cab1170fc0bf2c9
402,524
def get_unique_ops_names(all_ops): """ Find unique op names. Params: all_ops: list, of dictionary of all operations. Return: list of unique op names. """ return set(op['name'] for op in all_ops)
c731ace82342b0dd5c1fb71be5221d7845ff1657
374,878