content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
def unmatched_places(w, open, close): """ Given a word ``w`` and two letters ``open`` and ``close`` to be treated as opening and closing parentheses (respectively), return a pair ``(xs, ys)`` that encodes the positions of the unmatched parentheses after the standard parenthesis matching proc...
cfd2a50c50cecc6fcc08d4fd95df56ad503fa4d2
699,290
def _clip(n: float) -> float: """ Helper function to emulate numpy.clip for the specific use case of preventing math domain errors on the acos function by "clipping" values that are > abs(1). e.g. _clip(1.001) == 1 _clip(-1.5) == -1 _clip(0.80) == 0.80 """ sign = n / abs(n...
78308e70a405b3b3d94827c00705e8842b242cde
699,291
import os def skip_files(root): """Get a list of filenames to skip. :param root: Root directory of the package template :type root: str """ # We can use .gitattributes as a quick starting point gitattributes = os.path.join(root, ".gitattributes") fnames = [] with open(gitattributes, "...
22394d690040d1e70a18aea85a99b11ae8ff540d
699,292
import shutil def hpc_batch_detect() -> str | None: """ Assuming a known job batching system, we will create a template for the user to verify and then the user will run. """ batcher = None if shutil.which("qsub"): batcher = "qsub" return batcher
99c3b6d7dc9fe332b7cf027d53ca172c1776890f
699,293
import os import json def load_json(base_path): """ Load processing log Args: base_path (str): base directory Returns: """ # Get file path json_file = os.path.join(base_path, 'processing_log.json') # Read file with open(json_file, 'r') as f: df = json.load(f) ...
2821b70cfafe6fc352695eeffd63248bee350605
699,294
import math def line_intersect(pt1, pt2, ptA, ptB): """ Taken from https://www.cs.hmc.edu/ACM/lectures/intersections.html this returns the intersection of Line(pt1,pt2) and Line(ptA,ptB) returns a tuple: (xi, yi, valid, r, s), where (xi, yi) is the intersection r is the scalar multiple such ...
73ffd9674302f3be7b0edd9cdddd95df198919cb
699,295
def render_icon(icon): """ Render a Bootstrap glyphicon icon """ return '<span class="glyphicon glyphicon-{icon}"></span>'.format(icon=icon)
4fcc501cbea07d3dbe99f35f63dc39c8f629c4c4
699,296
import binascii def hex_to_bytes(hex_repn: str) -> bytes: """ Convert a hexidecimal string representation of a block of bytes into a Pyton bytes object. This function is the inverse of bytes_to_hex. hex_to_bytes('F803') -> b'\xf8\x03' """ return binascii.unhexlify(hex_repn)
2c456a353e1cce75998d1b2dd9b077af962ee41d
699,297
import re def get_text_url_base(content): """Return base URL to full text based on the content of the landing page. Parameters ---------- content : str The content of the landing page for an rxiv paper. Returns ------- str or None The base URL if available, otherwise None...
c679e9e1e8b074f7fea3aaf9eb256542e20a4d7d
699,298
def calculateMatchValue(incompleteObject, knownObject): """Calculate an integer match value, scoring +1 for each match""" matchvalue = 0 for catkey, catval in incompleteObject.items(): if knownObject[catkey] == catval: matchvalue += 1 return matchvalue
bd0efa089fa9edc2e290a46ca7e18b3d22bd1594
699,299
def LCS1(a, b, i, j): """ LCS recursion """ if i >= len(a) or j >= len(b): return 0 elif a[i] == b[j]: return 1 + LCS1(a, b, i+1, j+1) else: return max(LCS1(a, b, i+1, j), LCS1(a, b, i, j+1))
0b1819ee67dd6fc60e66b8c2b83f79c062a149db
699,300
import os def noxcptRmDir(sDir, oXcptRet = False): """ No exceptions os.rmdir wrapper. """ oRet = True; try: os.rmdir(sDir); except: oRet = oXcptRet; return oRet;
e1611ecd30927ef73d53a773d8ccc4bcb29df8cb
699,301
def get_contents_dir(node): """Return content signatures and names of all our children separated by new-lines. Ensure that the nodes are sorted.""" contents = [] for n in sorted(node.children(), key=lambda t: t.name): contents.append('%s %s\n' % (n.get_csig(), n.name)) return ''.join(content...
147d26ae5fca9540a081feef495dfa4bb0fca8eb
699,302
import os import sys def _prepend_path(env): """ Make sure the PATH contains the location where the Python binary lives. This makes sure cli tools installed in a virtualenv work. """ if env is None: env = os.environ env = dict(env) new = os.path.dirname(sys.executable) path = e...
7e5f8c59a5f24fc5b603e437db80f11464715aea
699,303
def two_way_merge(array1, array2): """ Given two sorted arrays, merge them into a single sorted array. This is a very simple operation but is a precursor to k-way merge. We compare each element at the beginning of each array and remove smaller one and add it to the merged array. If one of the array...
6d1a4779634809b7ff63159928af668596f5c00e
699,304
import torch def fake_image_tensor(H, W, C) -> torch.Tensor: """ Fake image tensor """ torch.manual_seed(0) return torch.rand(C, H, W)
3cf09924a856ff46240804c6f4ceea65ce70410c
699,305
def wavelength_to_energy(wavelength: float): """Conversion from photon wavelength (angstroms) to photon energy (eV)""" return 1.2398 / wavelength * 1e4
fc067b9fd9cae68103742e8998b6aa0117d906d0
699,306
import os def makedirs(name, exist_ok=False, **kwargs): """ Make the directories in the given path. The ``exist_ok`` argument was added in python 3.2+. """ if not (exist_ok and os.path.exists(name)): os.makedirs(name, **kwargs) return name
aabea356ed392eb26117f25b0918e80b1dd6a5eb
699,307
import threading def concurrent_map(func, data): """ Similar to the bultin function map(). But spawn a thread for each argument and apply `func` concurrently. Note: unlike map(), we cannot take an iterable argument. `data` should be an indexable sequence. """ N = len(data) result = [...
5fb482055699087ca7f7b3b95b7d8c425894882f
699,308
def pack_quotes(quotes, **kwargs): """ :param quotes: a list of BeautifulSoup tags containing quotes, and quote details :return: a dictionary of packaged quotes """ packed_quotes = {} for group in quotes: raw = group.select_one(kwargs.get('quotetag')) raw_quote = raw.string ...
011382f79572fedd0c40f10952d71c77ba25ae37
699,309
def van_vleck_weisskopf(νeval, ν, γ, δ): """Complex Van Vleck-Weisskopf line shape function. νeval GHz frequency at which line shape is evaluated ν GHz center frequency of line γ GHz width parameter of line δ - overlap parameter of line Returned value is u...
f2f221196fbe911d4582cfc74bf260bb87ce7db0
699,310
def exists_management_key_with_priority_zero( active_management_keys, new_management_keys, management_keys_to_revoke ): """ Checks if a management key of priority zero would be present if the management keys will be updated according to the given parameters. Parameters ---------- active_man...
e4bff322bf4cb9d4b6ccc002f277a5af63e993e4
699,311
import os def get_files_recursively(directory): """ Get a list of the absolute paths of all the files present in a direcory, recursively """ files = [] for base_path, _, sub_files in os.walk(directory): # make relative paths if directory.endswith("/"): files += [ os.pat...
03ff3967b8061232386910c36f6a80a806fca50a
699,312
import re def is_valid_username(field): """ Checks if it's an alphanumeric + underscore, lowercase string, at least two characters long, and starts with a letter, ends with alphanumeric """ return re.match(r"[a-z][0-9a-z_]*[a-z0-9]$", field) is not None
b4c870951715e103d58d1187703276dbb21e84cf
699,313
import os def create_path(path): """ This function receives a path and creates the directory in the case it doesn't exist Arg: csvfile (Path): path to a file Return: created_path: absolute Path to a created file """ # Split the path in # dir and csvfile pair ...
dee201e7df29779a986230d897a17402777c0dd5
699,314
def rowSum_A(X, norm = False): """ [Added 22/10/2018] Computes rowSum**2 for dense array efficiently, instead of using einsum """ n = len(X) s = 0 for i in range(n): s += X[i]**2 if norm: s **= 0.5 return s
cd6b147fb171094d3a4a2e77c1d5e63b07a6e560
699,315
import math def find_divisors(n): """ Find divisors of n """ #div = [] count = 0 sqrt_n = int(math.sqrt(n)) if sqrt_n**2==n: count += 1 #div.append(sqrt_n) for d in range(1, sqrt_n): if n%d==0: #div.append(d) #div.append(n//d) ...
8d6d0406024dae195c0f13db60e0a65bee93dd6c
699,317
import sys def map_annotations(experiment, sample, meta_dir, cv_map): """ Maps NCBI SRA annotations to controlled vocabularies. This function creates both a JSON and tab delimited metadata file that maps metadata from NCBI to known controlled vocabulary terms. The purpose of this is to help ensur...
cca25408225658cbdca30c5e738acaa6d5c2c707
699,318
import importlib def load_plugin(name): """ :param name: """ return importlib.import_module(f"plugins.{name}", ".").run
5631f51672dd8a4597a49b4336584e769577ff09
699,319
def exchange_ecYeast(s1, subystem): """ this function is used to define the exchange reaction s1=['a --> b','a <=> c', 'H+ [extracellular] + L-citrulline [extracellular] <=> H+ [cytoplasm] L-citrulline [cytoplasm]', ' a--> '] subsystem = ['a','a','b',''] """ for i, x in enumerate(s1): p...
0f8eb84b3270c910acd673491238d52b2744f68c
699,320
def readResults(file_name, _start_time, _end_time): """Read micro-data from file_name, structured on a separate line per year. In particular, read from start_year until end_year, both inclusive""" # Read list of float values, one per household data_float = [] with open(file_name, "r") as _f: ...
4ca6bb102b0605d3472430725a8349fa891dd247
699,321
import subprocess import os def run_nodejs(js_filename): """ Run given file in nodejs and capture output """ proc = subprocess.Popen( ['node', js_filename], stdout=subprocess.PIPE) outs, _ = proc.communicate(timeout=10) outs = outs.decode('ascii', errors='ignore') outs = outs.replace(os....
623c4201638272dfb40a35d7ce1ddb6949eed39a
699,322
def array_pack(img): """ img: numpy array. I primarily use this for OpenCV images """ d = img.tobytes() s = img.shape t = img.dtype return (s, t, d)
e01398caf1018000d0dabd776945a223e39b130b
699,323
def select_number(list_of_numbers): """The player select *one* number of a list of numbers""" answer = "" while ((not answer.isdecimal()) or int(answer) not in list_of_numbers): answer = input("Please type selected number and press ENTER: ") return int(answer)
af91b18508ff361b0524a551949aac7d93f9afc6
699,324
def welcome(): """最简单的接口 """ return 'Hello World'
5ae25fb699343bb48cdf113dc783a37290b3c38a
699,325
def cast(s): """ Function which clarifies the implicit type of strings, a priori coming from csv-like files. Example ------- >>> cast('1') 1 >>> cast('1.') 1.0 >>> cast('1E+0') 1.0 >>> cast('1E+1') 10.0 >>> cast('one') 'one' >>> cast('One') 'one' """ ...
5e2c9b3b913a733608cab614ae0f08421e489196
699,326
def is_macosx_sdk_path(path): """ Returns True if 'path' can be located in an OSX SDK """ return (path.startswith('/usr/') and not path.startswith('/usr/local')) or path.startswith('/System/')
59b60fa00bf6dd10cf207e6421ea3e4828de5b9c
699,327
import math def _mean_standard(dist): """Find the mean and standard deviation.""" # In the dist dictionary, the key is the value of the metric and # the value is the number of times it appears. So, the sample # value is the key and the number of samples for the value is the # value in dist for th...
3d90807a619b6fe090571a3f07db807e60c3849c
699,328
def shift2d(x,w,a,b): """Shift a 2d quadrature rule to the box defined by the tuples a and b""" xs=[[a[0]],[a[1]]]+x*[[b[0]-a[0]],[b[1]-a[1]]] ws=w*(b[0]-a[0])*(b[1]-a[1]) return xs,ws
84c2090cc0e1689a79aa2c7fa40fb399bc03f535
699,329
def weight_on_edge(data, zxing): """ This weight is independent of the cell_width. So even, when we have already a good estimation of the cell width, this weight does not need to take the width into account. """ value_before = data[zxing] value_after = data[zxing + 1] slope = value_aft...
3af14f15589dd5227a21b53598b896a8cca4c79a
699,330
import os def get_logging_config(): """ Returns logging configuration file path :return: str """ return os.path.normpath(os.path.join(os.path.dirname(__file__), '__logging__.ini'))
a2322151c261f7f89bbdc004d128acbad701645f
699,331
import dill def hashable(a) -> int: """ Hashes many kinds of objects, including some that are unhashable through the builtin `hash` function. Lists and tuples are hashed based on their elements. """ if isinstance(a, dict): # first hash the keys and values with hashable # then hash ...
29f55a4586f09156618a70e8443dc8b847260e14
699,332
def effective_kernel(kernel_shape, dilations): """ Args: kernel_shape: tuple[int] representing the kernel shape in each given dimension. dilations: tuple[int] representing the dilation of the kernel in each given dimension. Must be the same length as kernel_...
a955d185c924514bf981c2512a8e78646d523144
699,333
def int_from_32bit_array(val): """Converts an integer from a 32 bit bytearray :param val: the value to convert to an int :type val: int :rtype: int """ rval = 0 for fragment in bytearray(val): rval <<= 8 rval |= fragment return rval
ca2f32c7eac6f42aeed688510fa57e717edfacdf
699,334
def build_evaluation_from_config_item(configuration_item, compliance_type, annotation=None): """Form an evaluation as a dictionary. Usually suited to report on configuration change rules. Keyword arguments: configuration_item -- the configurationItem dictionary in the invokingEvent compliance_type -- ei...
05769fc549acdcec7ed611abeff5f0b4f695e57e
699,335
import os import json def load_json_config(app, config_filename): """ Adds support for eventador's config.json format """ filename = os.path.join(app.config.root_path, config_filename) with open(filename) as json_file: obj = json.load(json_file) keys = list(obj.keys()) for key in k...
f3156d41b075cabc04628f1ad2e8f5ca7bb8551b
699,336
import functools def requires_attr(attr_name, raiser): """ Methods wrapped in this decorator raise an error if a required attribute is not set. """ def decorator(meth): @functools.wraps(meth) def wrapper(self, *args, **kwargs): if getattr(self, attr_name, None) is None:...
e88d5ecfc39688683c7c29fbfc68db79cc760216
699,337
def _pretty_print_label(d): """Internal utility to pretty print point label info.""" s = " %s: "%repr(d[0]) entry_keys = list(d[1].keys()) ki = 0 kimax = len(entry_keys) for k in entry_keys: keys = list(d[1][k].keys()) if len(keys) == 0: s += "{%s: {}}"%k else...
4972b54d2402d87e6fe276605c59d21cfdc91533
699,338
def dict2obj(target, change_dict=True): """ 将dict转换成obj对象 change_dict 用于控制是否转换target内部dict为obj :param target: dict :param change_dict: bool :return: obj """ class Obj(object): def __init__(self, d, change_dict): for a, b in d.items(): if change_dict ...
4beec4d45528e2939a0c63333b8a401e34df3b3d
699,339
def splitbycharset(txt, charset): """Splits a string at the first occurrence of a character in a set. Args: txt: Text to split. chars: Chars to look for (specified as string). Returns: (char, before, after) where char is the character from the character set whic...
c23577eb96c9621909acaa816e8791e95dbf493d
699,340
def process_meta_review(meta_review): """ Do something with the meta-review JSON! This is where you would: 1. Translate meta_review["ty_id"] to your own hotel ID, dropping any unmapped hotels 2. Traverse the JSON structure to find the data you are interested in, documented at http://api.trustyo...
681ace9b9685f4bfd284ac6e41efde12bafbb1b9
699,341
def find_natural_number(position: int) -> tuple: """Return natural number at specified position and number its a part of.""" num_range = "" counter = 0 while len(str(num_range)) < position: counter += 1 num_range += str(counter) return int(num_range[-1]), counter
62aff0c400ac007fc67dafd25eb4cacf63262105
699,342
def camel_case(snake_case: str) -> str: """Converts snake case strings to camel case Args: snake_case (str): raw snake case string, eg `sample_text` Returns: str: camel cased string """ cpnts = snake_case.split("_") return cpnts[0] + "".join(x.title() for x in cpnts[1:])
b3080a3e3520209581cbd381ffaff24045343115
699,343
def _guess_bounds(cube, coords): """Guess bounds of a cube, or not.""" # check for bounds just in case for coord in coords: if not cube.coord(coord).has_bounds(): cube.coord(coord).guess_bounds() return cube
44cdcdc8ee0dd821d3abdef880efe11c7cf8d48e
699,344
def reduce_repeat_bb(text_list, break_token): """ convert ['<b>Local</b>', '<b>government</b>', '<b>unit</b>'] to ['<b>Local government unit</b>'] PS: maybe style <i>Local</i> is also exist, too. it can be processed like this. :param text_list: :param break_token: :return: """ count = 0 ...
1c9d88ca295ab31831773264c2ede597b707f3f6
699,345
def ferret_result_limits(efid): """ Abstract axis limits for the shapefile_writexyval PyEF """ return ( (1, 1), None, None, None, None, None, )
ba5c3d3a5760b11384b551c08464c16587e58437
699,346
import os def mkdir(path_name): """ make dirs if not exist Args: path_name: dir path Returns: path """ if not os.path.exists(path_name): os.makedirs(path_name) return path_name
1a67d78870bed50a59e49a290ff57c6d6e58e2d4
699,347
def configmap(): """ https://kubernetes.io/docs/tasks/configure-pod-container/configmap/ """ return { 'apiVersion': 'v1', 'kind': 'ConfigMap', 'metadata': { 'name': 'testcfgmap-game-config' }, 'data': { 'game.properties': "enemies=aliens\n...
aadc00e8046be12370202f82adca12b222b0696f
699,348
def identify_contentType(url): """ Given a URL for a content, it identifies the type of the content :param url(str): URL :returns: Type of the content """ extensions = ['mp3', 'wav', 'jpeg', 'zip', 'jpg', 'mp4', 'webm', 'ecar', 'wav', 'png'] if ('youtu.be' in url) or ('youtube' in url): ...
720a9ea9adaab547309f61b6858b0eb19ddebafe
699,349
def nice_frequency(frequency): """return a string of the frequency with SI unit and a reasonable number of digits""" if frequency < 1e3: return "%dHz" % frequency elif frequency < 10e3: return "%.3fkHz" % (frequency / 1e3) elif frequency < 100e3: return "%.2fkHz" % (freque...
8fefa58236c57878be9f051e9cbfff85d398f87c
699,350
def stack(x, filters, num_blocks, block_fn, use_bias, stride1=2, name=None): """A set of stacked residual blocks. Arguments: x: input tensor. filters: integer, filters of the bottleneck layer in a block. use_bias: boolean, enables or disables all biases in conv layers. num_blocks: integ...
1ed366778a5abba4e05c070da05e3c87cbd92560
699,351
def compute(x, y): """Compute sum of passed in arguments :param x: Integer (operand 1) :param y: Integer (operand 2) :rtype: Integer """ if x > 100 or x < 0 or y > 100 or y < 0: raise ValueError("Passed in value out of bounds") return x + y
beb518f7f9b23f1fa5dc7ac82386a9cbf34a5cd5
699,353
def pid_info(output_line): """ Take a line of 'ps -o pid,comm' output and return the PID number and name. The line looks something like: 9108 orterun or 10183 daos_server Need both items. Return a tuple (name, pid) Note: there could be leading spaces on the pid. """ info =...
479c51e562b7bbeb7e812fad4b2cb1f771e2e830
699,354
from typing import List from typing import Tuple def two_columns(pairs: List[Tuple]) -> str: """ Join pairs (or more) of strings to a string. :param pairs: List of tuples of strings :return: String separated by newlines """ return '\n'.join([' '.join(map(str, t)) for t in pairs])
810fdab52b4641c32f54c6adc772f8352b8f2ae6
699,357
def get_record_as_json(cur, tablename, row_id): """ Get a single record from the database, by id, as json. """ # IMPORTANT NOTE: Only use this function in trusted input. Never on data # being created by users. The table name is not escaped. q = """ SELECT row_to_json(new_with_table) F...
00521ae582a013f97b77494944e0f6e04069ed05
699,358
def stream_handler_set_stream(stream_handler_instance, stream): """ Backport of StreamHandler.setStream() for Python 2 """ if stream is stream_handler_instance.stream: result = None else: result = stream_handler_instance.stream stream_handler_instance.acquire() try: ...
0da047fc1a4e7c17e91d51769ede549551ab9813
699,359
def zip_(self, iterable): """A zip object yielding tuples until an input is exhausted. >>> [1, 2, 3].zip([1, 2, 3]) [(1, 1), (2, 2), (3, 3)] >>> [1, 2, 3].zip([3, 2]) [(1, 3), (2, 2)] """ return list(zip(self, iterable))
b71ea3414a7817959e5b58ad7cd476b7caa3c770
699,360
def segno(x): """ Input: x, a number Return: 1.0 if x>0, -1.0 if x<0, 0.0 if x==0 """ if x > 0.0: return 1.0 elif x < 0.0: return -1.0 elif x == 0.0: return 0.0
5caccfa037b2972755958f647f009660aefae59d
699,361
def swap_xyz_string(xyzs, permutation): """ Permutate the xyz string operation Args: xyzs: e.g. ['x', 'y+1/2', '-z'] permuation: list, e.g., [0, 2, 1] Returns: the new xyz string after transformation """ if permutation == [0,1,2]: return xyzs else: n...
efd0eb400be0dca26b49c3b2d3a04a385a2fc6e4
699,363
def speed_2_pace(speed): """Convert speed in km/hr to pace in s/km""" return 60*60/speed
25379049e98622ec5888461a9f6455be399d5f5a
699,364
from pathlib import Path def get_dictionaries(base: Path) -> list[tuple[str, list[Path]]]: """Make a list of available dictionaries and the interesting files. :param base: The Apple Dictionaries root directory. :return: A list of tuples of name, files for each dictionary. """ all_dicts = sorted( ...
98068ecb847aa6975cc8dc7eed59b8948316f191
699,366
def generate_recipient_from(nhais_cypher): """ Generates the recipient cypher. This value can be deduced from the nhais_cypher provided. The nhais cypher can be 2 to 3 characters is length. If it is 2 characters in length it will append "01" to generate the recipient cypher If it is 3 characters in ...
ac29a09f246fc38b43301cc1b00a4056fc49e203
699,367
def _convert_color(color): """Convert a 24-bit color to 16-bit. The input `color` is assumed to be a 3-component list [R,G,B], each with 8 bits for color level. This method will translate that list of colors into a 16-bit number, with first 5 bits indicating R component, last 5 bits indicating...
6635e30d574288146c5ff07bf3d0d1661cd33b97
699,368
def MakeFutureReservationMessage(messages, reservation_name, sku_properties, time_window, share_settings, reservation_zone): """Constructs a future reservation message object.""" future_reservation_message = messages.FutureReservation( name=reservation_name, specificSkuP...
4ca46162638df14977e7292c25926aecc6b8876e
699,369
import os def output_unconverted_csv_file(path, sheet_name): """ sheet_name(str: CSVに変換できないsheetの名前)に対し, sheet_name.csvを作成し, その中にsheet_nameを書き込んでから保存するメソッド. """ with open(os.path.join(path, "{}.csv".format(sheet_name)), 'w', newline='', encoding='cp932', errors='ignore') as unconvert...
87e8cfb56930d7aee2934d7f3154cae7c0b14e08
699,370
def list_get(lst, index, default=None): """ A safety mechanism for accessing uncharted indexes of a list. Always remember: safety first! :param lst: list :param index: int :param default: A default value :return: Value of list at index -or- default value """ assert type(lst) == list, "Re...
41ca83d6a9b0ba66858617b48dcb6c43ca5a6a54
699,371
def iterate_items(collection, *args, **kwargs): """ iterates over the items of given object. :param type collection: collection type to be used to iterate over given object's items. :rtype: iterator[tuple[object, object]] """ return iter(collection.items(*args, **k...
49fde9f9c027ff1fc64a57ee67b06c91033f8755
699,372
from pathlib import Path from typing import List def read_raw_data(folder: Path, split: str, lang: str) -> List[str]: """Makes sure we are reading each file at most once. There is 1000 sentences per file, one file per lang so the memory footprint is ok. """ file = folder / f"{lang}.{split}" asser...
451a795b8dcc8d4698f7538b7b55800f3015038d
699,373
from typing import Tuple def is_multi_class(output_shape: Tuple[int, ...]) -> bool: """Checks if output is multi-class.""" # If single value output if len(output_shape) == 1: return False return True
66726be66cce6f837b40287b75c547d28d709a74
699,374
def cradmin_instance_url(context, appname, viewname, *args, **kwargs): """ Template tag implementation of :meth:`cradmin_legacy.crinstance.BaseCrAdminInstance.reverse_url`. Examples: Reverse the view named ``"edit"`` within the app named ``"pages"``: .. code-block:: htmldjango ...
9cea000ff75b68d536796cbcc323fef1b0a7059b
699,375
def calculate_atom_symmetry_number(molecule, atom): """ Return the symmetry number centered at `atom` in the structure. The `atom` of interest must not be in a cycle. """ symmetry_number = 1 single = double = triple = benzene = num_neighbors = 0 # note that 0 is immutable for bond in atom....
d4b28f2b0cb793a5b6190c85c73bd56196ebec43
699,377
import torch def get_discretized_transformation_matrix(matrix, discrete_ratio, downsample_rate): """ Get disretized transformation matrix. Parameters ---------- matrix : torch.Tensor Shape -- (B, L, 4, 4) where B is the batch size, L is the max cav...
fd6ab95dcbb6fca9cab6b35fd5e20998fc12472b
699,378
import re def remove_surrogates(s): """ The following is a helper function, used to convert two-character surrogate sequences into single characters. This is needed because some systems create surrogates but others don't. """ pieces = re.split('(&#\d+;)', s) for i in range(3, len(pieces)-...
31426a1cc76838dec58d78c8ab8a951f84f4eda0
699,379
def basic_bn_stem(model, data, dim_in, **kwargs): """Add a basic DenseNet stem. For a pre-trained network that used BN. An AffineChannel op replaces BN during fine-tuning. """ dim = dim_in p = model.Conv(data, 'conv1', 3, dim, 7, pad=3, stride=2, no_bias=1) p = model.AffineChannel(p, 'conv1_bn'...
37469f6baccdc9ec0de5228b6398963e8a984a57
699,380
def fib_modified(a, b, n): """Computes the modified Fiboniacci-style function.""" for _ in range(2, n): a, b = b, a + b * b return b
103433c685d672019b42c1fd1a17a34bd3727764
699,381
from numpy import asarray from numpy.testing import assert_equal def nan_equal(a,b): """Are two arrays containing nan identical, assuming nan == nan?""" a,b = asarray(a),asarray(b) try: assert_equal(a,b) except: return False return True
a5f3186e202e22d79f46781fe3c9e6a1936f4a6a
699,382
def check_thermodynamic_consistency(tab, spec, *XYf): """Thermodynamic consistency: relative error"""# ε = (∂E/∂V|_S - P)/P )""" XYf_DT = XYf[:] rho = XYf_DT[0] temp = XYf_DT[1] Pt = tab.get_table('P{s}_DT', spec)(*XYf_DT) dU_rho = tab.get_table('U{s}_DT', spec).dFx(*XYf_DT) dP_T = tab.get...
7dbf10d7a8a0e0742def3c09d20d5a5768b9dab4
699,383
def message(): """ Text message. :return: """ return "That's easy to fix, but I can't be bothered."
abff6c119536ffab9a4506d64afe067131e066a2
699,384
import yaml def represent_ordered_dict(dumper, data): """ Serializes ``OrderedDict`` to YAML by its proper order. Registering this function to ``yaml.SafeDumper`` enables using ``yaml.safe_dump`` with ``OrderedDict``s. """ return dumper.represent_mapping(yaml.resolver.BaseResolver.DEFAULT_MAPPING_...
f8c83dd3b3ecf94077b7b465334ffa84df7e16a8
699,385
def raizCuadrada(n): """ estima la raiz cuadrada en 20 intervalos """ raiz = n/2 # La estimacion inicial sera 1/2 de n for k in range(20): raiz = (1/2)*(raiz + (n / raiz)) return raiz
5b3a36dc50d5fa8921dfcbe2a24f7467201c5339
699,386
def get_dot_size(val, verbose=False): """ Get the size of the marker based on val :param val: the value to test :param verbose: more output :return: the size of the marker in pixels """ markersizes = [6, 9, 12, 15, 18] # there should be one less maxmakervals than markersizes and then we...
aa84c98a3cb78822dd02a9062f9f9a325907b310
699,387
import six def _tuplify_version(version): """ Coerces the version string (if not None), to a version tuple. Ex. "1.7.0" becomes (1, 7, 0). """ if version is None: return version if isinstance(version, six.string_types): version = tuple(int(x) for x in version.split(".")) as...
97575c813ce585e7e928b129e67196dcece5db0a
699,388
import math def is_hexagon(x): """ Checks if x is a hexagon number """ n = (1 + math.sqrt(8*x + 1))/4 return(n == round(n))
854aa38984d36cd956852a091318dd6edb0a06e1
699,389
import os def intersect_files(flist1, flist2): """Return the intersection of two sets of filepaths, based on the file name (after the final '/') and ignoring the file extension. Examples -------- >>> flist1 = ['/a/b/abc.lab', '/c/d/123.lab', '/e/f/xyz.lab'] >>> flist2 = ['/g/h/xyz.npy', '/i...
fe4c6e23ea09c2e1770d3e49967f978615df5160
699,391
from typing import List import bisect def binary_search(elements: List[int], value: int) -> int: """Returns the index of the element closest to value. Args: elements (List): A sorted list. """ if not elements: return -1 closest_index = bisect.bisect_left(elements, value, 0, len(ele...
1e1cb3ebe1b897e480aa93747108365f0e8326fd
699,392
import uuid def create_record_id(): """Create record id. :return: Record id string. :rtype: str """ return str(uuid.uuid4())
a582d8e0823061621e250f257ed4877032792fdc
699,393
from typing import Type from typing import Callable from typing import Any def is_type(tipe: Type) -> Callable[[Any], bool]: """ :param tipe: A Type :return: A predicate that checks if an object is an instance of that Type """ def predicate(value: Any) -> bool: """ :param value: An...
2b4be636675216c810f9e14f70fe8a5647552e3f
699,394
import os def is_root(): """Check admin permissions.""" return os.geteuid() == 0
f4d72e1139ef7e59f4c8764e65fb0d571ab8e32b
699,395
def MSI(record): """ "Maximise Severity if Invalid": propagate an alarm state on the linked record only if the alarm severity is `INVALID_ALARM`. When propagated, the alarm status will become `LINK_ALARM`. Example (Python source) ----------------------- `my_record.INP = MSI(other_record)` ...
872b13eafe3dd76a962f24d2f3108990b5fda40e
699,396
def strip_constants(df, indices): """Remove columns from DF that are constant input factors. Parameters ---------- * df : DataFrame, of input parameters used in model run(s). * indices : list, of constant input factor index positions. Returns ---------- * copy of `df` modified to exclu...
5a68d9beaa39cb2651ccd995af20d25165ccb03e
699,397