content
stringlengths
35
416k
sha1
stringlengths
40
40
id
int64
0
710k
def get_post_from_row(post_row): """ extracts the post body from a post row """ return post_row.find("td").find("div", class_="content")
e2e75320d4b801cd76da3027b958ccced28f34ba
687,749
def get_status(query_type, command, execution_status, status_dict): """ Get the status code of a command according to a query Args: query_type (str): Type of status query, chunk in this case command (str): Command name execution_status: State of the last given command execution ...
78c28790a2824696e54f1556c9fb32e6ee972e47
687,751
def _trim_non_alpha(string): """ Used to prune non-alpha numeric characters from the elements of bader-charged structures""" return ''.join([x for x in string if x.isalpha()])
1b7ed10396b088ced722c95393b246bbb0d9ac66
687,752
def get_all_individuals_to_be_vaccinated_by_area( vaccinated_compartments, non_vaccination_state, virus_states, area ): """Get sum of all names of species that have to be vaccinated. Parameters ---------- vaccinated_compartments : list of strings List of compartments from which individuals ...
45ba235d14df08455304ce20d7b39e590b93e872
687,753
def get_lt(hdr): """Obtain the LTV and LTM keyword values. Note that this returns the values just as read from the header, which means in particular that the LTV values are for one-indexed pixel coordinates. LTM keywords are the diagonal elements of MWCS linear transformation matrix, while LTV...
8bbe18f09c82c0273ac177b5b1090bd8b490dd8e
687,754
import pathlib def data_file(module, *comps): """Return Path object of file in the data directory of an app.""" return pathlib.Path(module.__file__).parent.joinpath('..', 'data', *comps)
1ee38b920eacb1ac90ee260c73242fdf5d7db98f
687,755
def depend_on_proj_props(target, source, env): """ Emitter which adds a dependency for the project properties file """ #sys.stderr.write("depend_on_proj_props called\n") #sys.stderr.flush() return (target, source + [env['XISE_PY_PROPFILE']])
f0ea4c5aa0a6958e71dd051a6aff08cf9318d136
687,756
def get_block(ul_row_num, ul_col_num, grid): """ ul_ params are the upper left row and column numbers """ output = [] for col_modifier in range(0,3): for row_modifier in range(0,3): output.append(grid[ul_row_num + row_modifier][ul_col_num + col_modifier]) return output
cf2e8f86ecdf26630de8abba8bcd9cad9eaa424c
687,757
from bs4 import BeautifulSoup from typing import List from typing import Dict import re def parse_row(row: BeautifulSoup, columns: List[str], table_id: str) -> Dict[str, str]: """Takes a BeautifulSoup tag corresponding to a single row in an HTML table as input, along with an ordered list of normalized column ...
06dd895243f614f2a0d6fb3b40fc857ae50274ae
687,758
def _parse_line(line): """ Parse a string to find the series data point. This implementation is specific to the .dat file as created by pcap_stats.py """ values = line.split() # Delimiter is whitespace # column "total" is values[1] try: data_point = int(values[1]) except Value...
715670a47014f78cbfa7ddb3ce4d774d8c5810d9
687,759
import json def get_response_time_data(path: str = "") -> dict: """ :param path: :return: """ with open(path) as json_file: data = json.load(json_file) return data
73eca664ce27bba79723a3e5002ede41353b10cf
687,760
def ses(count, plural='s', singular=''): """ ses is pronounced "esses". Return a string suffix that indicates a singular sense if the count is 1, and a plural sense otherwise. So, for example: log.info("%d item%s found", items, utils.ses(items)) would log: ...
f0fe352df642ba442e620bbc5aefee613747588b
687,761
import math def std_variance_real(x): """ Return the standard variance Parameter --------- x : UncertainReal Returns ------- float """ # The independent components of uncertainty # ( Faster this way than with reduce()! ) var = 0.0 if len(x._u_components) != 0...
626c78c0d8e580215c02128d4504103168fb60e4
687,762
import os def title_from_path(path): """ Extract the title from the path, peels off the order number. """ filename = os.path.split(path)[1] try: return os.path.splitext(filename.split("-")[1])[0] except IndexError: return None
fc37a635c6fb557b13dc90419f4b57735f19ada0
687,763
def function(): """Docstring""" return ''
dd694f689069f169d64f53bc20868149b072955e
687,766
def get_total_flight_time(ulog): """ get the total flight time from an ulog in seconds :return: integer or None if not set """ if ('LND_FLIGHT_T_HI' in ulog.initial_parameters and 'LND_FLIGHT_T_LO' in ulog.initial_parameters): high = ulog.initial_parameters['LND_FLIGHT_T_HI'] ...
51498c1bd819c92b34f291e5937d26146247bb53
687,768
import math def fpart(x): """Returns the fractional part of x.""" return x - math.floor(x)
022ef9a11356e24a9cfb218640b67ff2b11fe58a
687,769
def host_dict(host): """Convert a host model object to a result dict""" if host: return host.state else: return {}
5cbc0471f87deb2214f1649fba23b093641f84d9
687,770
def get_total_results(results): """Return the totalResults object from a Google Analytics API request. :param results: Google Analytics API results set :return: Number of results """ if results['totalResults']: return results['totalResults']
3cc5604017ebb9eab98f2f99f1045c13cd1402f1
687,771
from typing import List def _format_results(results: list) -> List[dict]: """ Args: results: a list of results with the following format: ['"<hash>","<anchor_hash>",<score>'] Returns: a list of dictionaries containing the hash and score """ formatted_res = [] # Remove last e...
2ce02ae0a5181c94a89b209735c1bba80deeae76
687,772
def token(application, rhsso_service_info, username): """Access token for 3scale application that is connected with RHSSO""" app_key = application.keys.list()["keys"][0]["key"]["value"] return rhsso_service_info.password_authorize(application["client_id"], app_key, username)["access_token"]
0521a2f0d52ed06a00a07c82d7ec96720c0e018f
687,773
def textarea( rows="", span=2, placeholder="", htmlId=False, inlineHelpText=False, blockHelpText=False, focusedInputText=False, required=False, disabled=False, prepopulate=False): """ *Generate a textarea - TBS style* **Key Arg...
50956f0296e275385acc2e12ea063074c32887f9
687,774
def _construct_target_subscription(_target_id, _target_type='board'): """This function constructs a dictionary for an individual subscription target to be used in a payload. .. versionadded:: 3.5.0 :param _target_id: The unique identifier for the target (e.g. Node ID) :type _target_id: str :param ...
df66023aedc3306c8ffaa9f9dbccdb3811fc660b
687,775
import re import numpy def parse_scip(variables, optimization, stdout): """Parse output from the SCIP solver(s).""" answer_match = re.search(r"^SCIP Status *: *problem is solved \[([a-zA-Z ]+)\] *\r?$", stdout, re.M) if answer_match: (status,) = answer_match.groups() if status == "optim...
44efb3300cb0486fda4465157f650b0029f3d414
687,776
def monkey_patch(cls): """ Return a method decorator to monkey-patch the given class. """ def decorate(func): name = func.__name__ func.super = getattr(cls, name, None) setattr(cls, name, func) return func return decorate
a9fa473ab70e609740750e9347d61d1184689159
687,777
def pil_to_flatten_data(img): """ Convert data from [(R1, G1, B1, A1), (R2, G2, B2, A2)] to [R1, G1, B1, A1, R2, G2, B2, A2] """ return [x for p in img.convert('RGBA').getdata() for x in p]
3c6dbd84a5f664e2301c72f85fd19ecd0824ecaa
687,778
def is_list_sorted(list): """ Check if sorted in ascending order. input is a list of values. output: sorted =1 or 0 """ sorted = 1; for index in range(0, len(list)-1): if list[index] > list[index+1]: sorted = 0; retu...
10b0207a8a0aee7302c87eaa67b549ad9bab51bf
687,780
import json def get_temp(key): """[summary] Args: key ([type]): [description] Returns: [type]: [description] """ f = open('Backend/data/dataTemp.json', errors='ignore',) data = json.load(f) for p in data['station']: if (key == int(p['key'])): f.close()...
62ebad22890d5978614dcfc0977b7a4bd84dad6e
687,781
def count_numeric(df): """ Returns the number of numeric variables in the dataset. Parameters: df (pandas DataFrame): Dataset to perform calculation on Returns: counter_numeric (int): Number of numeric variables in df """ counter_numeric = 0 for i in range(len...
eb31507163a3193ae1c67ed282f344aad50b2b22
687,782
def bahai_major(date): """Return 'major' element of a Bahai date, date.""" return date[0]
248c0d317db55f2ad1148b91a2058cac66da664f
687,783
def build_current_state(sway_outputs): """Constructs an internal representation of the screens info.""" state = dict() for out_spec in sway_outputs: state[out_spec['name']] = { 'x': out_spec['rect']['x'], 'y': out_spec['rect']['y'], 'w': out_spec['modes'][-1]['width'], 'h': out...
5e509711eb5303e847a10471a6d927bf2324ecd1
687,784
import re def underscore2camel(name): """Convert name from underscore_name to CamelCase. >>> underscore2camel('assert_text_present') 'assertTextPresent' >>> underscore2camel('click') 'click' >>> underscore2camel('goBack') 'goBack' """ def upper(match): return match.group(1...
8ff72198dad042396f6a262a9eb7c8656d6f94df
687,785
def check_alpha_signs(svm): """Returns the set of training points that violate either condition: * all non-support-vector training points have alpha = 0 * all support vectors have alpha > 0 Assumes that the SVM has support vectors assigned, and that all training points have alpha values assi...
ab3868cc5b4f954d6c6158e804d19c95834704a9
687,786
import sys def checkWigFile(filin): """Check WIG coverage file given by user""" try: i = 0 for line in open(filin, 'rU'): i += 1 if line[0:5] == 'track': return 0 elif i == 100000: return 1 except IOError: sys.exit...
1b8d0dd6872151471b8022780dea890f0fdbd3b3
687,787
import random def luck(n=2): """ gives 1 chance out of n (default: 2) to return True """ assert n > 1 return bool(random.randint(0, n-1))
1d0990ca1586d865e8da57ec4fff8715738c8b90
687,788
def convert_dict(my_dict): """Convert dictionaries from Netmiko format to NAPALM format.""" new_dict = {} for k, v in my_dict.items(): new_dict[k] = v hostname = new_dict.pop('host') new_dict['hostname'] = hostname device_type = new_dict.pop('device_type') new_device_type = device_...
13431c74534199ee73ed7a75ae34885872495f91
687,789
def bspline(p, j, x): """ Return the value at x in [0,1[ of the B-spline with integer nodes of degree p with support starting at j. Implemented recursively using the [De Boor's Algorithm](https://en.wikipedia.org/wiki/De_Boor%27s_algorithm) .. math:: B_{i,0}(x) := \left\{ \begin{matrix...
b634c3e09936074e50c919aa9bfad0b5c6b00411
687,790
def dict_partial_from_keys(keys): """Return a function that constructs a dict with predetermined keys.""" def dict_partial(values): return dict(zip(keys, values)) return dict_partial
b738face4fa1874ab8ad1072c84afcde6f63b239
687,792
def create_accounttax_sample(account_id, **overwrites): """Creates a sample accounttax resource object for the accounttax samples. Args: account_id: int, Merchant Center ID these tax settings are for. **overwrites: dictionary, a set of accounttax attributes to overwrite Returns: A new accountt...
e3a105b2ee2c798d80746104ef242f5c4b3e53c0
687,793
import shlex def split_args(line): """Version of shlex.split that silently accept incomplete strings. Parameters ---------- line : str The string to split Returns ------- [str] The line split in separated arguments """ lex = shlex.shlex(line, posix=True) lex.w...
19837bf875d108f96349f848f6f3605795469a40
687,794
def get_public_members(obj): """ Retrieves a list of member-like objects (members or properties) that are publically exposed. :param obj: The object to probe. :return: A list of strings. """ return {attr: getattr(obj, attr) for attr in dir(obj) if not attr.startswith("_") ...
ede951ccabf71fb0e6e82777f8f91167b72d0613
687,795
def CLASS(objects): """Return generator on types (or classes) of objects""" return (type(o) for o in objects)
e36831e92873490c96688b9fcf70d7eb005b90ef
687,796
def delete_cluster(dataproc, project, region, cluster): """Delete the cluster.""" print('Tearing down cluster.') result = dataproc.delete_cluster( project_id=project, region=region, cluster_name=cluster) return result
e5a1a2b97b36e2860de508aa8daedb7928f044e6
687,797
def ReshapeShortFat(original): """ ReshapeShortFat(original) Reshapes the image numpy array from original shape to the ShortFat single row shape and captures shape info in the output: channel_0, channel_1, channel_2 functionally performs original.reshape(1, x*y*z) to create single...
a1f02dfb3e675011bf08bf8261355217df25006d
687,799
def get_class_prob(predictions_dict): """Get true and predicted targets from predictions_dict. Parameters ---------- predictions_dict : dict Dict of model predictions. Must contain "target_true" and "target_pred" keys with corresponding dict values of the form class_label : probability....
d5876043d1bb2fcea25bf1892fd0b35f07e98db9
687,800
def generate_video_url(video_id:str)->str: """Takes video Id and generates the video url example https://www.youtube.com/watch?v=e3LqeN0e0as """ return f'https://www.youtube.com/watch?v={video_id}'
f48759a223ac831c46d51e4c56ce098de54425b5
687,801
def get_highest_single_digit_integer_from_string(in_string): """Get the highest single digit integer from a string """ items = set(in_string) ints = set("1234567890") items &= ints max_i = -1 if len(items) == 0: return None else: for i in items: if int(i) > max_i:...
c75ae03180d1e36ef6fd096f7762e75efc5a7076
687,802
import base64 def base64url_encode(msg): """ Encode a message to base64 based on JWT spec, Appendix B. "Notes on implementing base64url encoding without padding" """ normalb64 = base64.urlsafe_b64encode(msg) return normalb64.rstrip(b'=')
315b0b0e5041da30c3bfd97de1759f8de8cd4ea3
687,803
def check_won(state, turn): """Check if state is won on this turn.""" streak = (turn,) * 3 rows = [state[3*i:3*(i+1)] for i in range(3)] cols = [state[i::3] for i in range(3)] for i in range(3): if (rows[i] == streak) or (cols[i] == streak): return True if rows[0][0] == rows[...
3a43ac4ccb2b22fc456b380a2470633e9bc14688
687,804
def num_parameters(model): """ Returns the number of parameters in the given model Parameters ---------- model : torch.nn.Module the model to count the parameters of Returns ------- int the number of parameters in the given model """ n = 0 for p in model.pa...
cb4a2fe4f383c0765f560a1fbc8e7cc404b1eca0
687,805
def simplex_dimension(simplex): """ Get the dimension of a simplex. :param simplex: Simplex defined by a list of vertex indices. :type simplex: List[int] :return: Dimension of the simplex. """ return len(simplex) - 1
4aef0e6d1af41cc6e1d4e1977625ec1f0476c2b9
687,807
import time def fromIntGetTimePeriod(): """ 获取本月时间段 """ return [ time.strftime("%Y-%m-01 00:00:00", time.localtime(int(time.time()))), time.strftime("%Y-%m-%d 23:59:59", time.localtime(int(time.time()))) ]
d7487a0563623b0ca42e921aa4488281a1034b65
687,808
import numpy def get_SSE(a,b,r,x,y): """ input: a, b, r, x, y. circle center, radius, xpts, ypts output: SSE """ SSE = 0 X = numpy.array(x) Y = numpy.array(y) for i in range(len(X)): x = X[i] y = Y[i] v = (numpy.sqrt( (x -a)**2 + (y - b)**2 ) - r )**2 S...
6d5f1f3034fd62142558cc4360fc5b081df1afc2
687,809
def ssXXsuffix( i ): """Turns an integer into an ssXX ending between .ss01 and .ss20, e.g. 5 -> '.ss05'.""" i = i%21 # max 20 if not i: # if 0 i = 1 return ".calt.ss%.2d" % ( i )
3c2961e8e085c86dcc0cb7b950d1a4fe94de9ba8
687,810
def decode_rgb565(val): """Decode a RGB565 uint16 into a RGB888 tuple.""" r5 = (val & 0xf800) >> 11 g6 = (val & 0x7e0) >> 5 b5 = val & 0x1f return ( int((r5 * 255 + 15) / 31), int((g6 * 255 + 31) / 63), int((b5 * 255 + 15) / 31) )
0c9a67016df686eb23282de74f663493caa305a9
687,811
from typing import OrderedDict def quant_params_vec2dict(keys, vals, search_clipping=False): """ Convert the vector(s) created by quant_params_dict2vec to a dictionary of quantization parameters that the post-training quantizer API can digest """ res = OrderedDict() for idx, k in enumerate(key...
facdcaea5ae0504017d51a7d61c682322f70d23f
687,812
import secrets def generateID(): """ ## Generates an unique ID for an user when is creating a profile. """ duckobotID = secrets.token_urlsafe(32) return duckobotID
31a30e452c571172c3fd9b5fd8463c5a5c3e2b85
687,813
from typing import List import subprocess def _posix_run_cmd(args: List[str]) -> subprocess.CompletedProcess: """ Call subprocess.run with given args. Call subprocess.run with stdout/stderr PIPE redirect. Args: args (List[str]): The command to run. Returns: subprocess.CompletedP...
441d3f9d157705168ccf8b0848b8fd9212204070
687,814
from bs4 import BeautifulSoup def clean_data(data): """ Strip HTML and clean spaces """ data = BeautifulSoup(data, "lxml").text.strip() data = ' '.join(data.split()).encode("utf-8") return data
78034485428aaf8e2d70f02fa3d3011332bea407
687,815
def get_filediffs(): """ Get regular expressions for recipy "filediffs"-related log information recorded in database. :returns: regular expressions :rtype: list of str or unicode """ return [r"before this run", r"after this run"]
8b56bf5e59646ed16d37c180cca87c14e46378c2
687,816
import requests def get_aws_session_token(): """ Get the AWS credential from EC2 instance metadata """ r = requests.get("http://169.254.169.254/latest/meta-data/iam/security-credentials/") instance_profile_name = r.text r = requests.get("http://169.254.169.254/latest/meta-data/iam/security-cr...
3046dc4bc4e4ca3d74f1554d9989942d24edad56
687,817
import pkg_resources def get_template(name): """ Look for 'name' in the vr.runners.templates folder. Return its contents. >>> import six >>> tmpl = get_template('base_image.lxc') >>> isinstance(tmpl, six.string_types) True """ path = 'templates/' + name b_stream = pkg_resources.r...
75d95692b9f9e386c219650165256462ec736762
687,818
def service_exists(keystone, service_name): """ Return True if service already exists""" return service_name in [x.name for x in keystone.services.list()]
f885e8a3df9b9f20f39a97ae1a481eed26694bc4
687,819
def month_classes(request): """ Fixture for month based datetime offsets available for a time series. """ return request.param
1a5b97fca6ed716737b3373cdb9fd42fe27dff43
687,820
import os def find_files_by_ext(directory, *exts): """ Finds all the files in the given directory with the provided extensions """ if not exts: raise AttributeError('No extensions provided') if not os.path.isdir(directory): raise AttributeError('{} is not a valid directory'.forma...
579f9b211f4b6aa63664b2fea31167c48b5209be
687,821
from pandas import Series def expand_affiliation(df): """Auxiliary function to expand the information about the affiliation in publications from ScopusSearch. """ res = df[["source_id", "author_ids", "afid"]].copy() res['afid'] = res["afid"].str.split(';') res = (res["afid"].apply(Series) ...
5520c3a61b03f72e433462c4d6c46ae83835b25a
687,822
def apply_args_and_kwargs(fn, args, kwargs): """ https://stackoverflow.com/a/53173433/13747259 """ return fn(*args, **kwargs)
0a1fce401db79906ad1d9cf1ad7478fa94ed0275
687,824
import inspect def midpointRuleAdaptive(a: float, b: float, y, epsilon: float = 0.01): """Midpoint Rule implementation. It demands [a,b] of interval for integration; y - function or method returning \ single float number and accepting single float number; epsilon - difference of two subsequent calculated ...
c05d7e0e70ace0c5e6a5c0046f3db64485127ae3
687,825
def _conditional_probability(col_a_counts_map, col_b_counts_map, both_counts_map): """ For values that a might take, maps to p(a=v|b=v). = the number f times both columns a and b have a value divided by the number of times column b has that value. returns: value->prob for given maps. NB: n...
6460decae177b7fdaa8bf2f867b6fb27cae28936
687,826
import sys def hilite(string, status=False, bold=False): """If tty highligth the output.""" if not sys.stdout.isatty(): return string attr = [] if status: attr.append('32') # Green else: attr.append('31') # Red if bold: attr.append('1') return '\x1b[%sm%s...
01b1b15eda4a02fb1bb969b7d8ca7a4a7bffd7da
687,827
def _depgrep_exprs_action(_s, _l, tokens): """ This is the top-lebel node in a depgrep2 search string; the predicate function it returns binds together all the state of a depgrep2 search string. Builds a lambda function representing a predicate on a tree node from the disjunction of several dep...
f56476c6ba753c20878770ca80d855c6ee549393
687,828
import itertools def LTL_world_JTLV(W, var_prefix="obs", center_loc=None, restrict_radius=1): """Convert world matrix W into an LTL formula describing transitions. Use JTLV syntax in the returned formula. The variables are named according to var_prefix_R_C, where var_prefix is...
8b8eb45783ebe7a438d062f354ac9fa7ee70b68a
687,829
def get_changed_files(path = '.'): """ Retrieves the list of changed files. """ # not implemented return []
a229490fddf25d8efb0dbc44fbd0ea1de3965c2d
687,830
def material_type(rec): """Determine material type for record (arg1). Returns: A string, one of BK (books), CF (computer files), MP (maps), MU (music), CR (continuing resource), VM (visual materials), MX (mixed materials) """ l = rec[0] # Book: Leader/06 (Type of record) co...
21f6ae1ca85c7db62f4d6d868ffc32a1adce3197
687,831
import math def log_(value): """ Wrapper around math.log """ if value <= 0: return 0 else: return math.log(value)
3ad5dd1cb9b7d2801469c547f08402c6a176219d
687,833
def cookies_string_to_dict(cookies_string): """ Transform cookies which is type of string to the type of dict """ if not cookies_string or cookies_string == '': raise ValueError("Invalid blank param of cookies_string !") if not isinstance(cookies_string, str): raise TypeError("Inval...
300fdd5adb189ac025727bfe2d08947aac87dac4
687,834
def need_fake_wells(tsclass, well_model): """ Return boolean to see if fake wells are needed """ if well_model == 'fake': abst_rxn = bool('abstraction' in tsclass) # addn_rxn = bool('addition' in tsclass) subs_rxn = bool('substitution' in tsclass) need = bool(abst_rxn or subs...
5adc592e23e7fc5a842c2e3f9d9a2458d9d787fd
687,835
import subprocess def run_command(command: str, capture: bool = False) -> subprocess.CompletedProcess: """Run shell commands given the provided command""" # NOTE: shell=True is highly discouraged due to potential shell-injection attacks. Use with care. return subprocess.run([command], shell=True, capture_...
6e4d98d06685f47a13f737f91cdec0d3a72ddf2c
687,836
def address_check(request, reply, ipformat): """Compare request packet source address with reply destination address and vice versa. If exception occurs return False. :param request: Sent packet containing request. :param reply: Received packet containing reply. :param ipformat: Dictionary of names...
fbc2a01cc354083cdf76ac70696f85979594c703
687,838
def classname(cls): """Return the name of a class""" return cls.__name__
d907d4c78e4300dbc0ba0a185fd9b5ca85f11511
687,839
def normalize_lang(lang): """Normalize input languages string >>> from pyams_utils.i18n import normalize_lang >>> lang = 'fr,en_US ; q=0.9, en-GB ; q=0.8, en ; q=0.7' >>> normalize_lang(lang) 'fr,en-us;q=0.9,en-gb;q=0.8,en;q=0.7' """ return lang.strip() \ .lower() \ ...
d3ce6b111bdf5cad98f643955631dd9389a6d849
687,840
import os def forwardsNeedsRebuild(module_path, forwards_filename): """Determine whether the given forwards header needs rebuild. Args: module_path String, path to the module. forwards_filename String, path to the forwards header. """ forwards_mtime = os.path.getmtime(forwards_fil...
107eb461eb81066cd7573410eed112d02d607dfa
687,841
def _get_locales_header(self, request): """ Retrieves the locales list value using an (HTTP) header strategy. :type request: Request :param request: The request to be used. :rtype: List :return: The retrieved locales list. """ # retrieves the accepted language accept_language =...
6237846cd517ec0e841a56199ca300d9e394bfa6
687,842
from typing import Union def _bytes_to_str(string: Union[bytes, str]) -> str: """Helper to convert a bytes literal to a utf-8 string.""" if isinstance(string, str): return string if isinstance(string, bytes): return str(string, "utf-8") raise TypeError(f"Argument 'string' is not of t...
b8b17cdb83a615123643f5e81c8608f7ac33901b
687,843
def GetHour(acq_time): """ gets simply the hour from the given military time """ aqtime = str(acq_time) size = len(aqtime) hr = aqtime[:size - 2] #get the hours #add the 0 if we need it to match the fire db if len(hr) == 1: hr = '0' + hr elif len(hr) == 0: hr = '00' ...
d9c1f7a529d3a5eda77a287f3e92962bef379a32
687,844
def doi_to_directory(doi): """Converts a doi string to a more directory-friendly name Parameters ---------- doi : string doi Returns ------- doi : string doi with "/" and ":" replaced by "-" and "-" respectively """ return doi.replace("/", "-").replace(":", "-")
3bc20f48fbc1048da0324a5053561c685ae66b98
687,845
def drop_nan_cols(metdat): """ Use columns with 'qc' suffix as a mask to filter data """ temp = metdat.dropna(axis=1,how='all') return temp
ce4d372a1ca1bc104db6fdc32ecfb4275aa6ddb5
687,846
import numpy as np def arrayFromMarkupsControlPoints(markupsNode, world = False): """Return control point positions of a markups node as rows in a numpy array (of size Nx3). :param world: if set to True then the control points coordinates are returned in world coordinate system (effect of parent transform to...
90fbc53bd3f73888509ea2b49cf982196b21f774
687,847
def get_soil_texture_superclass_id(superclass: str): """Get soil texture superclass ID. Parameters ---------- superclass : str Superclass from {L, S, T, U}. Returns ------- int ID of superclass """ superclass_dict = {"L": 0, "S": 1, "T": 2, "U": 3} return super...
0fa642ed21ae0d46374fbb408e0640e34ff823f5
687,848
import os def determine_path(parsed_args): """ Function determines the path to the file or directory Parameters ---------- parsed_args : ArgumentParser(obj) ArgumentParser object containing parsed arguments. Returns ------- path_obj : Dictionary Python dictionary contai...
2f02a7f4f6c4a4ca261aaae0cef957ca599d1eee
687,849
import numpy def F2(x): """Cigar or Bent Cigar function""" s = x[0]**2 + (10**6) * numpy.sum(x[1 :]**2) return s
5e0a3c9e5ae72e5990eaa0e726c988c23553649e
687,850
import os def writeToSysfs(fsFile, fsValue): """ Write to a sysfs file. Parameters: fsFile -- Path to the sysfs file to modify fsValue -- Value to write to the sysfs file """ global RETCODE if not os.path.isfile(fsFile): print('Cannot write to sysfs file ' + fsFile + '. File does ...
59dd7e3816a2583199ea8d79d95f2386da7fa213
687,852
from datetime import datetime def write_fn(period: datetime = datetime.now(), prefix: str = 'xbrlrss', ext: str = '.xml') -> str: """Write the filename with pattern prefix-YYYY-MM-.xml Args: period (datetime, optional): Date from which year and month come. Defaults to datetime.now(). prefix (...
02df0ac8300fb6adf06c0b6b10daa993f8cc57bc
687,855
def parse_int(input): """ parse the integer in the input string @param input: inputs that can be converted to strings @return: """ sign, result = 1, 0 input_string = str(input).strip().lstrip('+') if input_string != '' and input_string[0] == '-': input_string, sign = input_string...
d9c21bc50bc8baa16f3cc6461cf2c4b572b43581
687,856
def fullName(first: str, middle: str, last: str) -> str: """ Compose parts of a name into a full name. """ if middle: return f"{first} {middle}. {last}" else: return f"{first} {last}"
1cd1fb8fedbbe090794cb1571fc47c62923d1f56
687,857
import os def download_ftp_cloudsat(ftp_url, usr, pwd, dest_path): """Downloads the specified files via FTP. PARAMETERS: ----------- ftp_url: FTP address for directory that contains all the CloudSat files usr: Username for FTP login pwd: Password for FTP lo...
20f7aed6e9926f56a740a10d06d2fd10688b1c3b
687,858
def valid_title_icon(arch): """An icon with fa- class or in a button must have title in its tag, parents, descendants or have text.""" valid_title_attrs = {'title', 't-att-title', 't-attf-title'} valid_t_attrs = {'t-value', 't-raw', 't-field', 't-esc'} valid_attrs = valid_title_attrs | valid_t_attrs ...
0a679834e0a67c9110400b66130755967fec82e1
687,860
from typing import List from typing import Tuple def write_inertia(inertia: List[Tuple[int, int]]): """ Given an inertia decomposition as returned by `compute_inertia`, create the string version that is latex displayable. Example: >>> write_inertia([(2, 1), (2, 3), (1, 2), (1, 1)]) '(...
ceb62482209ce7a68cade8f7c673c52594f68dcc
687,862
def xyz_to_zyx(data, x=0, y=0, z=0): """ Reverses dimensions of matrix. Assumes data is not flattened. If it is flattened, pass in y, x, z parameters :param data: :param y: :param x: :param z: """ x = data.shape[0] if x == 0 else x y = data.shape[1] if y == 0 else y z...
508000b8a76917170269e98392b3a88b0ba9ecd9
687,863
def lowercase(raw_text: str) -> str: """ >>> lowercase("This is NeW YoRk wIth upPer letters") 'this is new york with upper letters' """ return raw_text.lower()
d486c8c6d1f15cc80038bd67994067464cdbbda5
687,864