text
stringlengths
75
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
0.18
def density(self, x, y, n_sersic, r_eff, k_eff, center_x=0, center_y=0): """ de-projection of the Sersic profile based on Prugniel & Simien (1997) :return: """ raise ValueError("not implemented! Use a Multi-Gaussian-component decomposition.")
[ "def", "density", "(", "self", ",", "x", ",", "y", ",", "n_sersic", ",", "r_eff", ",", "k_eff", ",", "center_x", "=", "0", ",", "center_y", "=", "0", ")", ":", "raise", "ValueError", "(", "\"not implemented! Use a Multi-Gaussian-component decomposition.\"", ")...
40.571429
0.010345
def assoc2(self, assets_by_site, assoc_dist, mode, asset_refs): """ Associated a list of assets by site to the site collection used to instantiate GeographicObjects. :param assets_by_sites: a list of lists of assets :param assoc_dist: the maximum distance for association ...
[ "def", "assoc2", "(", "self", ",", "assets_by_site", ",", "assoc_dist", ",", "mode", ",", "asset_refs", ")", ":", "assert", "mode", "in", "'strict filter'", ",", "mode", "self", ".", "objects", ".", "filtered", "# self.objects must be a SiteCollection", "asset_dt"...
46.365854
0.00103
def delete_certificate_issuer_config_by_id(self, certificate_issuer_configuration_id, **kwargs): # noqa: E501 """Delete certificate issuer configuration. # noqa: E501 Delete the configured certificate issuer configuration. You can only delete the configurations of custom certificates. # noqa: E501 ...
[ "def", "delete_certificate_issuer_config_by_id", "(", "self", ",", "certificate_issuer_configuration_id", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'asynchronous'",...
61.190476
0.001533
def find_tarball(directory, name, version): """Return matching tarball filename from dist/ dir (if found). Setuptools generates a source distribution in a ``dist/`` directory and we need to find the exact filename, whether .tgz or .zip. We expect "name + '-' + version + '.tar.gz'", but we *can* get a ...
[ "def", "find_tarball", "(", "directory", ",", "name", ",", "version", ")", ":", "dir_contents", "=", "os", ".", "listdir", "(", "os", ".", "path", ".", "join", "(", "directory", ",", "'dist'", ")", ")", "candidates", "=", "[", "tarball", "for", "tarbal...
43.192308
0.000871
def _scan_constraint_match(self, minimum_version, maximum_version, jdk): """Finds a cached version matching the specified constraints :param Revision minimum_version: minimum jvm version to look for (eg, 1.7). :param Revision maximum_version: maximum jvm version to look for (eg, 1.7.9999). :param bool ...
[ "def", "_scan_constraint_match", "(", "self", ",", "minimum_version", ",", "maximum_version", ",", "jdk", ")", ":", "for", "dist", "in", "self", ".", "_cache", ".", "values", "(", ")", ":", "if", "minimum_version", "and", "dist", ".", "version", "<", "mini...
43.388889
0.010025
def _MergeTaskStorage(self, storage_writer): """Merges a task storage with the session storage. This function checks all task stores that are ready to merge and updates the scheduled tasks. Note that to prevent this function holding up the task scheduling loop only the first available task storage is m...
[ "def", "_MergeTaskStorage", "(", "self", ",", "storage_writer", ")", ":", "if", "self", ".", "_processing_profiler", ":", "self", ".", "_processing_profiler", ".", "StartTiming", "(", "'merge_check'", ")", "for", "task_identifier", "in", "storage_writer", ".", "Ge...
37.063063
0.009233
def list(self, path): """GET /<path>?list=true :param path: :type path: :return: :rtype: """ try: payload = { 'list': True } return self._adapter.get('/v1/{0}'.format(path), params=payload).json() except...
[ "def", "list", "(", "self", ",", "path", ")", ":", "try", ":", "payload", "=", "{", "'list'", ":", "True", "}", "return", "self", ".", "_adapter", ".", "get", "(", "'/v1/{0}'", ".", "format", "(", "path", ")", ",", "params", "=", "payload", ")", ...
23.6
0.008152
def push(self, *args, **kwargs): ''' Push commits to remote ''' stdout = six.b('') # Execute command cmd = self.git.push(as_process=True, *args, **kwargs) # Capture output while True: output = cmd.stdout.read(1) sys.stdout.write(outpu...
[ "def", "push", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "stdout", "=", "six", ".", "b", "(", "''", ")", "# Execute command\r", "cmd", "=", "self", ".", "git", ".", "push", "(", "as_process", "=", "True", ",", "*", "args",...
27.545455
0.002125
def calc_in_wc_v1(self): """Calculate the actual water release from the snow layer due to the exceedance of the snow layers capacity for (liquid) water. Required control parameters: |NmbZones| |ZoneType| |WHC| Required state sequence: |SP| Required flux sequence |TF|...
[ "def", "calc_in_wc_v1", "(", "self", ")", ":", "con", "=", "self", ".", "parameters", ".", "control", ".", "fastaccess", "flu", "=", "self", ".", "sequences", ".", "fluxes", ".", "fastaccess", "sta", "=", "self", ".", "sequences", ".", "states", ".", "...
29.865169
0.000364
def __update(self, sym, item, metadata=None, combine_method=None, chunk_range=None, audit=None): ''' helper method used by update and append since they very closely resemble eachother. Really differ only by the combine method. append will combine existing date with new data (within a chu...
[ "def", "__update", "(", "self", ",", "sym", ",", "item", ",", "metadata", "=", "None", ",", "combine_method", "=", "None", ",", "chunk_range", "=", "None", ",", "audit", "=", "None", ")", ":", "if", "not", "isinstance", "(", "item", ",", "(", "DataFr...
44.313953
0.002053
def GetEntries(self, parser_mediator, match=None, **unused_kwargs): """Extracts relevant Spotlight entries. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. match (Optional[dict[str: object]]): keys extracted fr...
[ "def", "GetEntries", "(", "self", ",", "parser_mediator", ",", "match", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "shortcuts", "=", "match", ".", "get", "(", "'UserShortcuts'", ",", "{", "}", ")", "for", "search_text", ",", "data", "in", "...
40
0.009946
def pore_diameter(elements, coordinates, com=None): """Return pore diameter of a molecule.""" if com is None: com = center_of_mass(elements, coordinates) atom_vdw = np.array([[atomic_vdw_radius[x.upper()]] for x in elements]) dist_matrix = euclidean_distances(coordinates, com.reshape(1, -1)) ...
[ "def", "pore_diameter", "(", "elements", ",", "coordinates", ",", "com", "=", "None", ")", ":", "if", "com", "is", "None", ":", "com", "=", "center_of_mass", "(", "elements", ",", "coordinates", ")", "atom_vdw", "=", "np", ".", "array", "(", "[", "[", ...
45.6
0.002151
def update_task_positions_obj(self, positions_obj_id, revision, values): ''' Updates the ordering of tasks in the positions object with the given ID to the ordering in the given values. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: ...
[ "def", "update_task_positions_obj", "(", "self", ",", "positions_obj_id", ",", "revision", ",", "values", ")", ":", "return", "positions_endpoints", ".", "update_task_positions_obj", "(", "self", ",", "positions_obj_id", ",", "revision", ",", "values", ")" ]
50.3
0.011719
def _waitAny(*children): """Waits on any child Future created by the calling Future. :param children: A tuple of children Future objects spawned by the calling Future. :return: A generator function that iterates on futures that are done. The generator produces results of the children in a non...
[ "def", "_waitAny", "(", "*", "children", ")", ":", "n", "=", "len", "(", "children", ")", "# check for available results and index those unavailable", "for", "index", ",", "future", "in", "enumerate", "(", "children", ")", ":", "if", "future", ".", "exceptionVal...
36.971429
0.000753
def create_open_msg(self): """Create `Open` message using current settings. Current setting include capabilities, timers and ids. """ asnum = self.local_as # If local AS number is not Two-Octet AS number, swaps with AS_TRANS. if not is_valid_old_asn(asnum): a...
[ "def", "create_open_msg", "(", "self", ")", ":", "asnum", "=", "self", ".", "local_as", "# If local AS number is not Two-Octet AS number, swaps with AS_TRANS.", "if", "not", "is_valid_old_asn", "(", "asnum", ")", ":", "asnum", "=", "bgp", ".", "AS_TRANS", "bgpid", "...
32.689655
0.002049
def format(self, obj, context, maxlevels, level): # pylint: disable=arguments-differ """ Mask obj if it looks like an URL, then pass it to the super class. """ if isinstance(obj, basestring) and "://" in fmt.to_unicode(obj): obj = mask_keys(obj) return pprint.PrettyPrinter.f...
[ "def", "format", "(", "self", ",", "obj", ",", "context", ",", "maxlevels", ",", "level", ")", ":", "# pylint: disable=arguments-differ", "if", "isinstance", "(", "obj", ",", "basestring", ")", "and", "\"://\"", "in", "fmt", ".", "to_unicode", "(", "obj", ...
59.666667
0.011019
def Group(params, name=None, type=None): """Groups together Params for adding under the 'What' section. Args: params(list of :func:`Param`): Parameter elements to go in this group. name(str): Group name. NB ``None`` is valid, since the group may be best identified by its type. ...
[ "def", "Group", "(", "params", ",", "name", "=", "None", ",", "type", "=", "None", ")", ":", "atts", "=", "{", "}", "if", "name", ":", "atts", "[", "'name'", "]", "=", "name", "if", "type", ":", "atts", "[", "'type'", "]", "=", "type", "g", "...
32.111111
0.001681
def _new_program(self, p): """New program was added to the multiprogram; update items in the shader. """ for k, v in self._set_items.items(): getattr(p, self._shader)[k] = v
[ "def", "_new_program", "(", "self", ",", "p", ")", ":", "for", "k", ",", "v", "in", "self", ".", "_set_items", ".", "items", "(", ")", ":", "getattr", "(", "p", ",", "self", ".", "_shader", ")", "[", "k", "]", "=", "v" ]
35.333333
0.009217
def allocate_disks(logical_disk, server, raid_config): """Allocate physical disks to a logical disk. This method allocated physical disks to a logical disk based on the current state of the server and criteria mentioned in the logical disk. :param logical_disk: a dictionary of a logical disk ...
[ "def", "allocate_disks", "(", "logical_disk", ",", "server", ",", "raid_config", ")", ":", "size_gb", "=", "logical_disk", "[", "'size_gb'", "]", "raid_level", "=", "logical_disk", "[", "'raid_level'", "]", "number_of_physical_disks", "=", "logical_disk", ".", "ge...
46.740741
0.000259
def analyses(self, *, family: str=None, query: str=None, status: str=None, deleted: bool=None, temp: bool=False, before: dt.datetime=None, is_visible: bool=None): """Fetch analyses form the database.""" analysis_query = self.Analysis.query if family: analysis_query =...
[ "def", "analyses", "(", "self", ",", "*", ",", "family", ":", "str", "=", "None", ",", "query", ":", "str", "=", "None", ",", "status", ":", "str", "=", "None", ",", "deleted", ":", "bool", "=", "None", ",", "temp", ":", "bool", "=", "False", "...
52.090909
0.017995
def battery2_send(self, voltage, current_battery, force_mavlink1=False): ''' 2nd Battery status voltage : voltage in millivolts (uint16_t) current_battery : Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilo...
[ "def", "battery2_send", "(", "self", ",", "voltage", ",", "current_battery", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "battery2_encode", "(", "voltage", ",", "current_battery", ")", ",", "force_mavlink1", ...
53.888889
0.008114
def discoverEventDependency(sig): """ :return: generator of tuples (event operator, signal) """ try: drivers = sig.drivers except AttributeError: return if len(drivers) == 1: d = drivers[0] if isinstance(d, Operator): if isEventDependentOp(d.operator...
[ "def", "discoverEventDependency", "(", "sig", ")", ":", "try", ":", "drivers", "=", "sig", ".", "drivers", "except", "AttributeError", ":", "return", "if", "len", "(", "drivers", ")", "==", "1", ":", "d", "=", "drivers", "[", "0", "]", "if", "isinstanc...
26.111111
0.002053
def extract_value_from_output(canary, split_offset, kal_out): """Return value parsed from output. Args: canary(str): This string must exist in the target line. split_offset(int): Split offset for target value in string. kal_out(int): Output from kal. """ retval = "" while re...
[ "def", "extract_value_from_output", "(", "canary", ",", "split_offset", ",", "kal_out", ")", ":", "retval", "=", "\"\"", "while", "retval", "==", "\"\"", ":", "for", "line", "in", "kal_out", ".", "splitlines", "(", ")", ":", "if", "canary", "in", "line", ...
32.1875
0.001887
def _discretize(a): """Discretizes array values to class labels.""" arr = np.asarray(a) index = np.argsort(arr) inverse_index = np.zeros(arr.size, dtype=np.intp) inverse_index[index] = np.arange(arr.size, dtype=np.intp) arr = arr[index] obs = np.r_[True, arr[1:] != arr[:-1]] return obs.cumsum()[inverse_...
[ "def", "_discretize", "(", "a", ")", ":", "arr", "=", "np", ".", "asarray", "(", "a", ")", "index", "=", "np", ".", "argsort", "(", "arr", ")", "inverse_index", "=", "np", ".", "zeros", "(", "arr", ".", "size", ",", "dtype", "=", "np", ".", "in...
35.777778
0.027273
def delete(self, route: str(), callback: object()): """ Binds a PUT route with the given callback :rtype: object """ self.__set_route('delete', {route: callback}) return RouteMapping
[ "def", "delete", "(", "self", ",", "route", ":", "str", "(", ")", ",", "callback", ":", "object", "(", ")", ")", ":", "self", ".", "__set_route", "(", "'delete'", ",", "{", "route", ":", "callback", "}", ")", "return", "RouteMapping" ]
32
0.008696
def ruler_line(self, widths, linetype='-'): """Generates a ruler line for separating rows from each other""" cells = [] for w in widths: cells.append(linetype * (w+2)) return '+' + '+'.join(cells) + '+'
[ "def", "ruler_line", "(", "self", ",", "widths", ",", "linetype", "=", "'-'", ")", ":", "cells", "=", "[", "]", "for", "w", "in", "widths", ":", "cells", ".", "append", "(", "linetype", "*", "(", "w", "+", "2", ")", ")", "return", "'+'", "+", "...
40.166667
0.00813
def run(self, s): """Split string ``s`` at delimiter, correctly interpreting quotes Further, interprets arrays wrapped in one level of ``[]``. No recursive brackets are interpreted (as this would make the grammar non-regular and currently this complexity is not needed). Currently, ...
[ "def", "run", "(", "self", ",", "s", ")", ":", "begins", ",", "ends", "=", "[", "0", "]", ",", "[", "]", "# transition table", "DISPATCH", "=", "{", "self", ".", "NORMAL", ":", "self", ".", "_handle_normal", ",", "self", ".", "QUOTED", ":", "self",...
40.576923
0.001852
def write_close(self, code=None): '''Write a close ``frame`` with ``code``. ''' return self.write(self.parser.close(code), opcode=0x8, encode=False)
[ "def", "write_close", "(", "self", ",", "code", "=", "None", ")", ":", "return", "self", ".", "write", "(", "self", ".", "parser", ".", "close", "(", "code", ")", ",", "opcode", "=", "0x8", ",", "encode", "=", "False", ")" ]
42.25
0.011628
def split(txt, seps): """ Splits a text in a meaningful list of words based on a list of word separators (define in pyqode.core.settings) :param txt: Text to split :param seps: List of words separators :return: A **set** of words found in the document (excluding ...
[ "def", "split", "(", "txt", ",", "seps", ")", ":", "# replace all possible separators with a default sep", "default_sep", "=", "seps", "[", "0", "]", "for", "sep", "in", "seps", "[", "1", ":", "]", ":", "if", "sep", ":", "txt", "=", "txt", ".", "replace"...
35.434783
0.002389
def read(self, size=None): """Read at most size bytes from this buffer. Bytes read from this buffer are consumed and are permanently removed. Args: size: If provided, read no more than size bytes from the buffer. Otherwise, this reads the entire buffer. Returns: ...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "self", ".", "__size", "ret_list", "=", "[", "]", "while", "size", ">", "0", "and", "self", ".", "__buf", ":", "data", "=", "self", "....
32
0.002427
def _ellipsoid_bootstrap_expand(args): """Internal method used to compute the expansion factor for a bounding ellipsoid based on bootstrapping.""" # Unzipping. points, pointvol = args rstate = np.random # Resampling. npoints, ndim = points.shape idxs = rstate.randint(npoints, size=npoi...
[ "def", "_ellipsoid_bootstrap_expand", "(", "args", ")", ":", "# Unzipping.", "points", ",", "pointvol", "=", "args", "rstate", "=", "np", ".", "random", "# Resampling.", "npoints", ",", "ndim", "=", "points", ".", "shape", "idxs", "=", "rstate", ".", "randin...
31.310345
0.001068
def _create_trustdb(cls): """Create the trustdb file in our homedir, if it doesn't exist.""" trustdb = os.path.join(cls.homedir, 'trustdb.gpg') if not os.path.isfile(trustdb): log.info("GnuPG complained that your trustdb file was missing. %s" % "This is likely due to changing to a n...
[ "def", "_create_trustdb", "(", "cls", ")", ":", "trustdb", "=", "os", ".", "path", ".", "join", "(", "cls", ".", "homedir", ",", "'trustdb.gpg'", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "trustdb", ")", ":", "log", ".", "info", "(",...
53.5
0.002299
def _get_equivids(self, limit): """ The file processed here is of the format: #NBK_id GR_shortname OMIM NBK1103 trimethylaminuria 136132 NBK1103 trimethylaminuria 602079 NBK1104 cdls 122470 Where each of the rows represents a mapping between ...
[ "def", "_get_equivids", "(", "self", ",", "limit", ")", ":", "raw", "=", "'/'", ".", "join", "(", "(", "self", ".", "rawdir", ",", "self", ".", "files", "[", "'idmap'", "]", "[", "'file'", "]", ")", ")", "model", "=", "Model", "(", "self", ".", ...
42.848921
0.001477
def get_installed_version(vcs): """Get the installed version for this project. Args: vcs (easyci.vcs.base.Vcs) Returns: str - version number Raises: VersionNotInstalledError """ version_path = _get_version_path(vcs) if not os.path.exists(version_path): rais...
[ "def", "get_installed_version", "(", "vcs", ")", ":", "version_path", "=", "_get_version_path", "(", "vcs", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "version_path", ")", ":", "raise", "VersionNotInstalledError", "with", "open", "(", "version_pa...
23.588235
0.002398
def pruneWeights(self, minWeight): """ Prune all the weights whose absolute magnitude is less than minWeight :param minWeight: min weight to prune. If zero then no pruning :type minWeight: float """ if minWeight == 0.0: return # Collect all weights weights = [v for k, v in self.na...
[ "def", "pruneWeights", "(", "self", ",", "minWeight", ")", ":", "if", "minWeight", "==", "0.0", ":", "return", "# Collect all weights", "weights", "=", "[", "v", "for", "k", ",", "v", "in", "self", ".", "named_parameters", "(", ")", "if", "'weight'", "in...
32.6875
0.011152
def get_matching_indexes(self, idx_spec): """ Parameters ---------- idx_spec : str A string in the form of a pair of brackets enclosing some index expression matching HDUs in the file Returns ------- result : list A list of HDU...
[ "def", "get_matching_indexes", "(", "self", ",", "idx_spec", ")", ":", "# if index is missing, assume to open the first HDU we know how", "# to do something with", "if", "idx_spec", "is", "None", "or", "idx_spec", "==", "''", ":", "idx", ",", "hdu", "=", "self", ".", ...
30.14
0.001285
def nvc2pl(normal, constant): """ Make a plane from a normal vector and a constant. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/nvc2pl_c.html :param normal: A normal vector defining a plane. :type normal: 3-Element Array of floats :param constant: A constant defining a plane. :...
[ "def", "nvc2pl", "(", "normal", ",", "constant", ")", ":", "plane", "=", "stypes", ".", "Plane", "(", ")", "normal", "=", "stypes", ".", "toDoubleVector", "(", "normal", ")", "constant", "=", "ctypes", ".", "c_double", "(", "constant", ")", "libspice", ...
32.555556
0.001658
def set_execution_state(self, execution_state): """ set exectuion state """ if not execution_state: self.execution_state = None self.cluster = None self.environ = None else: self.execution_state = execution_state cluster, environ = self.get_execution_state_dc_environ(execution_...
[ "def", "set_execution_state", "(", "self", ",", "execution_state", ")", ":", "if", "not", "execution_state", ":", "self", ".", "execution_state", "=", "None", "self", ".", "cluster", "=", "None", "self", ".", "environ", "=", "None", "else", ":", "self", "....
32.692308
0.020595
def list_instances( deployment_name='', cloud_name='EC2 us-east-1', view='tiny', ): """ Returns a list of instances from your account. :param str deployment_name: If provided, only lists servers in the specified deployment. :param str cloud_name: The friendly na...
[ "def", "list_instances", "(", "deployment_name", "=", "''", ",", "cloud_name", "=", "'EC2 us-east-1'", ",", "view", "=", "'tiny'", ",", ")", ":", "api", "=", "get_api", "(", ")", "cloud", "=", "find_by_name", "(", "api", ".", "clouds", ",", "cloud_name", ...
34.62963
0.001041
def delete_media_service_rg(access_token, subscription_id, rgname, msname): '''Delete a media service. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. msname (str): Media service...
[ "def", "delete_media_service_rg", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "msname", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/resourceGr...
38
0.001427
def update_endpoint_obj(client, endpoint, object_id, revision, data): ''' Helper method to ease the repetitiveness of updating an... SO VERY DRY (That's a doubly-effective pun becuase my predecessor - https://github.com/bsmt/wunderpy - found maintaing a Python Wunderlist API to be "as tedious and bor...
[ "def", "update_endpoint_obj", "(", "client", ",", "endpoint", ",", "object_id", ",", "revision", ",", "data", ")", ":", "data", "[", "'revision'", "]", "=", "int", "(", "revision", ")", "endpoint", "=", "'/'", ".", "join", "(", "[", "endpoint", ",", "s...
58.777778
0.011173
def spawn(self, command): """Spawn process.""" if self.shell: args = command else: args = shlex.split(command) return subprocess.Popen(args, shell=self.shell)
[ "def", "spawn", "(", "self", ",", "command", ")", ":", "if", "self", ".", "shell", ":", "args", "=", "command", "else", ":", "args", "=", "shlex", ".", "split", "(", "command", ")", "return", "subprocess", ".", "Popen", "(", "args", ",", "shell", "...
29.714286
0.009346
def _makeComplementTable(complementData): """ Make a sequence complement table. @param complementData: A C{dict} whose keys and values are strings of length one. A key, value pair indicates a substitution that should be performed during complementation. @return: A 256 character string t...
[ "def", "_makeComplementTable", "(", "complementData", ")", ":", "table", "=", "list", "(", "range", "(", "256", ")", ")", "for", "_from", ",", "to", "in", "complementData", ".", "items", "(", ")", ":", "table", "[", "ord", "(", "_from", "[", "0", "]"...
42.2
0.001546
def doc(self, groups=None, set_location=True, **properties): """Add flask route to autodoc for automatic documentation Any route decorated with this method will be added to the list of routes to be documented by the generate() or html() methods. By default, the route is added to the 'a...
[ "def", "doc", "(", "self", ",", "groups", "=", "None", ",", "set_location", "=", "True", ",", "*", "*", "properties", ")", ":", "def", "decorator", "(", "f", ")", ":", "# Get previous group list (if any)", "if", "f", "in", "self", ".", "func_groups", ":"...
39.791667
0.001533
def parse_requirements(filename): """Parse out a list of requirements from the given requirements requirements file. """ reqs = [] version_spec_in_play = None # Iterate over each line in the requirements file. for line in open(filename, 'r').read().strip().split('\n'): # Sanity chec...
[ "def", "parse_requirements", "(", "filename", ")", ":", "reqs", "=", "[", "]", "version_spec_in_play", "=", "None", "# Iterate over each line in the requirements file.", "for", "line", "in", "open", "(", "filename", ",", "'r'", ")", ".", "read", "(", ")", ".", ...
39.924528
0.000461
def adjust_angles(self, start_node, start_angle, end_node, end_angle): """ This function adjusts the start and end angles to correct for duplicated axes. """ start_group = self.find_node_group_membership(start_node) end_group = self.find_node_group_membership(end_node) ...
[ "def", "adjust_angles", "(", "self", ",", "start_node", ",", "start_angle", ",", "end_node", ",", "end_angle", ")", ":", "start_group", "=", "self", ".", "find_node_group_membership", "(", "start_node", ")", "end_group", "=", "self", ".", "find_node_group_membersh...
50.243902
0.000952
def solve(self, grid): """Return a solution point for a Sudoku grid.""" soln = self.S.satisfy_one(assumptions=self._parse_grid(grid)) return self.S.soln2point(soln, self.litmap)
[ "def", "solve", "(", "self", ",", "grid", ")", ":", "soln", "=", "self", ".", "S", ".", "satisfy_one", "(", "assumptions", "=", "self", ".", "_parse_grid", "(", "grid", ")", ")", "return", "self", ".", "S", ".", "soln2point", "(", "soln", ",", "sel...
49.5
0.00995
def docs_cli(ctx, recreate, gen_index, run_doctests): # type: (click.Context, bool, bool, bool) -> None """ Build project documentation. This command will run sphinx-refdoc first to generate the reference documentation for the code base. Then it will run sphinx to generate the final docs. You can c...
[ "def", "docs_cli", "(", "ctx", ",", "recreate", ",", "gen_index", ",", "run_doctests", ")", ":", "# type: (click.Context, bool, bool, bool) -> None", "if", "ctx", ".", "invoked_subcommand", ":", "return", "from", "peltak", ".", "logic", "import", "docs", "docs", "...
32.864865
0.001597
def rest_instances(self, file_path=None, sort_keys=False): """*Writes the instances as JSON to a file.* The instances are written to file as a JSON array of JSON objects, each object representing a single instance, and having three properties: - the request - the response ...
[ "def", "rest_instances", "(", "self", ",", "file_path", "=", "None", ",", "sort_keys", "=", "False", ")", ":", "if", "not", "file_path", ":", "outputdir_path", "=", "BuiltIn", "(", ")", ".", "get_variable_value", "(", "\"${OUTPUTDIR}\"", ")", "if", "self", ...
33.791667
0.001797
def create_api_pool_deploy(self): """Get an instance of Api Pool Deploy services facade.""" return ApiPoolDeploy( self.networkapi_url, self.user, self.password, self.user_ldap)
[ "def", "create_api_pool_deploy", "(", "self", ")", ":", "return", "ApiPoolDeploy", "(", "self", ".", "networkapi_url", ",", "self", ".", "user", ",", "self", ".", "password", ",", "self", ".", "user_ldap", ")" ]
33.428571
0.008333
def logstats(self): """ Print the node's current statistics to log. """ lines = [ "node {} current stats".format(self), "--------------------------------------------------------", "node inbox size : {}".format(len(self.nodeInBox)), ...
[ "def", "logstats", "(", "self", ")", ":", "lines", "=", "[", "\"node {} current stats\"", ".", "format", "(", "self", ")", ",", "\"--------------------------------------------------------\"", ",", "\"node inbox size : {}\"", ".", "format", "(", "len", "(", "se...
56.111111
0.001298
def get_small_file(context, path): """ Basic in-memory caching module fetcher. This generates one roundtrip for every previously unseen file, so it is only a temporary solution. :param context: Context we should direct FileService requests to. For now (and probably forever) this is just...
[ "def", "get_small_file", "(", "context", ",", "path", ")", ":", "pool", "=", "mitogen", ".", "service", ".", "get_or_create_pool", "(", "router", "=", "context", ".", "router", ")", "service", "=", "pool", ".", "get_service", "(", "u'mitogen.service.PushFileSe...
42.764706
0.001346
def _add_series_or_dataframe_operations(cls): """ Add the series or dataframe only operations to the cls; evaluate the doc strings again. """ from pandas.core import window as rwindow @Appender(rwindow.rolling.__doc__) def rolling(self, window, min_periods=None,...
[ "def", "_add_series_or_dataframe_operations", "(", "cls", ")", ":", "from", "pandas", ".", "core", "import", "window", "as", "rwindow", "@", "Appender", "(", "rwindow", ".", "rolling", ".", "__doc__", ")", "def", "rolling", "(", "self", ",", "window", ",", ...
40.783784
0.001294
def htmlCtxtReadFd(self, fd, URL, encoding, options): """parse an XML from a file descriptor and build a tree. This reuses the existing @ctxt parser context """ ret = libxml2mod.htmlCtxtReadFd(self._o, fd, URL, encoding, options) if ret is None:raise treeError('htmlCtxtReadFd() failed...
[ "def", "htmlCtxtReadFd", "(", "self", ",", "fd", ",", "URL", ",", "encoding", ",", "options", ")", ":", "ret", "=", "libxml2mod", ".", "htmlCtxtReadFd", "(", "self", ".", "_o", ",", "fd", ",", "URL", ",", "encoding", ",", "options", ")", "if", "ret",...
52.857143
0.010638
def get_argument_query(self): """ Helper function to get query argument. Raises exception if argument is missing. Returns the query argument. """ try: query = self.get_argument(constants.PARAM_QUERY) return query except tornado.web.MissingArgumentError as e: raise Exception...
[ "def", "get_argument_query", "(", "self", ")", ":", "try", ":", "query", "=", "self", ".", "get_argument", "(", "constants", ".", "PARAM_QUERY", ")", "return", "query", "except", "tornado", ".", "web", ".", "MissingArgumentError", "as", "e", ":", "raise", ...
29.545455
0.01194
def is_valid_geometry(self): """ It is possible to infer the geometry only if exactly one of sites, sites_csv, hazard_curves_csv, gmfs_csv, region is set. You did set more than one, or nothing. """ has_sites = (self.sites is not None or 'sites' in self.inputs ...
[ "def", "is_valid_geometry", "(", "self", ")", ":", "has_sites", "=", "(", "self", ".", "sites", "is", "not", "None", "or", "'sites'", "in", "self", ".", "inputs", "or", "'site_model'", "in", "self", ".", "inputs", ")", "if", "not", "has_sites", "and", ...
49.928571
0.001404
def map(self, mapper): """ Map categories using input correspondence (dict, Series, or function). Parameters ---------- mapper : dict, Series, callable The correspondence from old values to new. Returns ------- SparseArray The out...
[ "def", "map", "(", "self", ",", "mapper", ")", ":", "# this is used in apply.", "# We get hit since we're an \"is_extension_type\" but regular extension", "# types are not hit. This may be worth adding to the interface.", "if", "isinstance", "(", "mapper", ",", "ABCSeries", ")", ...
31.846154
0.001172
def set_window_size_callback(window, cbfun): """ Sets the size callback for the specified window. Wrapper for: GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes...
[ "def", "set_window_size_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents"...
39.809524
0.002336
def filter_query(self, query): """ Filter the given query using the filter classes specified on the view if any are specified. """ for filter_class in list(self.filter_classes): query = filter_class().filter_query(self.request, query, self) return query
[ "def", "filter_query", "(", "self", ",", "query", ")", ":", "for", "filter_class", "in", "list", "(", "self", ".", "filter_classes", ")", ":", "query", "=", "filter_class", "(", ")", ".", "filter_query", "(", "self", ".", "request", ",", "query", ",", ...
33.222222
0.009772
def _set_symlink_ownership(path, user, group, win_owner): ''' Set the ownership of a symlink and return a boolean indicating success/failure ''' if salt.utils.platform.is_windows(): try: salt.utils.win_dacl.set_owner(path, win_owner) except CommandExecutionError: ...
[ "def", "_set_symlink_ownership", "(", "path", ",", "user", ",", "group", ",", "win_owner", ")", ":", "if", "salt", ".", "utils", ".", "platform", ".", "is_windows", "(", ")", ":", "try", ":", "salt", ".", "utils", ".", "win_dacl", ".", "set_owner", "("...
31.125
0.001949
def add_child(self, child, modify=False): """ Adds an object as a child in the scene graph. With modify=True, model_matrix_transform gets change from identity and prevents the changes of the coordinates of the child""" SceneGraph.add_child(self, child) self.notify() if modify: ...
[ "def", "add_child", "(", "self", ",", "child", ",", "modify", "=", "False", ")", ":", "SceneGraph", ".", "add_child", "(", "self", ",", "child", ")", "self", ".", "notify", "(", ")", "if", "modify", ":", "child", ".", "_model_matrix_transform", "[", ":...
70.428571
0.01002
def generate_submit_scripts(templates, prefix=None, deffnm='md', jobname='MD', budget=None, mdrun_opts=None, walltime=1.0, jobarray_string=None, startdir=None, npme=None, **kwargs): """Write scripts for queuing systems. This sets up queuing system run sc...
[ "def", "generate_submit_scripts", "(", "templates", ",", "prefix", "=", "None", ",", "deffnm", "=", "'md'", ",", "jobname", "=", "'MD'", ",", "budget", "=", "None", ",", "mdrun_opts", "=", "None", ",", "walltime", "=", "1.0", ",", "jobarray_string", "=", ...
48.597938
0.009148
def to_rgb(self): ''' Return a corresponding :class:`~bokeh.colors.rgb.RGB` color for this HSL color. Returns: HSL ''' from .rgb import RGB # prevent circular import r, g, b = colorsys.hls_to_rgb(float(self.h)/360, self.l, self.s) return RGB(round(r*...
[ "def", "to_rgb", "(", "self", ")", ":", "from", ".", "rgb", "import", "RGB", "# prevent circular import", "r", ",", "g", ",", "b", "=", "colorsys", ".", "hls_to_rgb", "(", "float", "(", "self", ".", "h", ")", "/", "360", ",", "self", ".", "l", ",",...
31.909091
0.00831
def set_font(self, font, color_scheme=None): """Set font""" self.editor.set_font(font, color_scheme=color_scheme)
[ "def", "set_font", "(", "self", ",", "font", ",", "color_scheme", "=", "None", ")", ":", "self", ".", "editor", ".", "set_font", "(", "font", ",", "color_scheme", "=", "color_scheme", ")" ]
42.333333
0.015504
def list_(device, unit=None): ''' Prints partition information of given <device> CLI Examples: .. code-block:: bash salt '*' partition.list /dev/sda salt '*' partition.list /dev/sda unit=s salt '*' partition.list /dev/sda unit=kB ''' _validate_device(device) if un...
[ "def", "list_", "(", "device", ",", "unit", "=", "None", ")", ":", "_validate_device", "(", "device", ")", "if", "unit", ":", "if", "unit", "not", "in", "VALID_UNITS", ":", "raise", "CommandExecutionError", "(", "'Invalid unit passed to partition.part_list'", ")...
36.626667
0.000354
def is_false(self): """ Ensures :attr:`subject` is ``False``. """ self._run(unittest_case.assertFalse, (self._subject,)) return ChainInspector(self._subject)
[ "def", "is_false", "(", "self", ")", ":", "self", ".", "_run", "(", "unittest_case", ".", "assertFalse", ",", "(", "self", ".", "_subject", ",", ")", ")", "return", "ChainInspector", "(", "self", ".", "_subject", ")" ]
32
0.010152
def create(vm_): ''' if configuration parameter ``deploy`` is ``True``, Provision a single machine, adding its keys to the salt master else, Test ssh connections to the machine Configuration parameters: - deploy: (see above) - provider: name of entry in ``salt/cloud.provid...
[ "def", "create", "(", "vm_", ")", ":", "deploy_config", "=", "config", ".", "get_cloud_config_value", "(", "'deploy'", ",", "vm_", ",", "__opts__", ",", "default", "=", "False", ")", "# If ssh_host is not set, default to the minion name", "if", "not", "config", "....
40
0.001235
def logp_gradient_contribution(self, calculation_set=None): """ Calculates the gradient of the joint log posterior with respect to self. Calculation of the log posterior is restricted to the variables in calculation_set. """ # NEED some sort of check to see if the log p calculati...
[ "def", "logp_gradient_contribution", "(", "self", ",", "calculation_set", "=", "None", ")", ":", "# NEED some sort of check to see if the log p calculation has recently", "# failed, in which case not to continue", "return", "self", ".", "logp_partial_gradient", "(", "self", ",", ...
54.9
0.010753
def is_sparse_file(filename): """Determine if the given filename indicates a dense or a sparse matrix If pathname is xxx.coo.yyy return True otherwise False. """ dirname, basename = os.path.split(filename) name, ext = os.path.splitext(basename) matrix_name, matrix_ext = os.path.splitext(nam...
[ "def", "is_sparse_file", "(", "filename", ")", ":", "dirname", ",", "basename", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "basename", ")", "matrix_name", ",", "matrix_e...
30
0.002488
def convert_to_ip(self): """Convert the Data Collection to IP units.""" self._values, self._header._unit = self._header.data_type.to_ip( self._values, self._header.unit)
[ "def", "convert_to_ip", "(", "self", ")", ":", "self", ".", "_values", ",", "self", ".", "_header", ".", "_unit", "=", "self", ".", "_header", ".", "data_type", ".", "to_ip", "(", "self", ".", "_values", ",", "self", ".", "_header", ".", "unit", ")" ...
49.5
0.00995
def from_transitions(initial_state, accepting_states, transition_function): # type: (State, Set[State], TransitionFunction) -> DFA """ Initialize a DFA without explicitly specifying the set of states and the alphabet. :param initial_state: the initial state. :param accepting_sta...
[ "def", "from_transitions", "(", "initial_state", ",", "accepting_states", ",", "transition_function", ")", ":", "# type: (State, Set[State], TransitionFunction) -> DFA", "states", ",", "alphabet", "=", "_extract_states_from_transition_function", "(", "transition_function", ")", ...
47.153846
0.0096
def get_block_info(self): """ Get the retrieved block information. Return [(height, [txs])] on success, ordered on height Raise if not finished downloading """ if not self.finished: raise Exception("Not finished downloading") ret = [] for (blo...
[ "def", "get_block_info", "(", "self", ")", ":", "if", "not", "self", ".", "finished", ":", "raise", "Exception", "(", "\"Not finished downloading\"", ")", "ret", "=", "[", "]", "for", "(", "block_hash", ",", "block_data", ")", "in", "self", ".", "block_inf...
31.714286
0.008753
def checksum(thing): """ Get the checksum of a calculation from the calculation ID (if already done) or from the job.ini/job.zip file (if not done yet). If `thing` is a source model logic tree file, get the checksum of the model by ignoring the job.ini, the gmpe logic tree file and possibly other fi...
[ "def", "checksum", "(", "thing", ")", ":", "try", ":", "job_id", "=", "int", "(", "thing", ")", "job_file", "=", "None", "except", "ValueError", ":", "job_id", "=", "None", "job_file", "=", "thing", "if", "not", "os", ".", "path", ".", "exists", "(",...
38.84
0.001005
def recentMatches(self, **criteria): """identify all recent matches for player given optional, additional criteria""" if not self.matches: return [] # no match history try: # maxMatches is a specially handled parameter (not true criteria) maxMatches = criteria["maxMatches"] ...
[ "def", "recentMatches", "(", "self", ",", "*", "*", "criteria", ")", ":", "if", "not", "self", ".", "matches", ":", "return", "[", "]", "# no match history", "try", ":", "# maxMatches is a specially handled parameter (not true criteria)", "maxMatches", "=", "criteri...
54.076923
0.013986
def concat(source, task_limit=None): """Given an asynchronous sequence of sequences, generate the elements of the sequences in order. The sequences are awaited concurrently, although it's possible to limit the amount of running sequences using the `task_limit` argument. Errors raised in the source...
[ "def", "concat", "(", "source", ",", "task_limit", "=", "None", ")", ":", "return", "base_combine", ".", "raw", "(", "source", ",", "task_limit", "=", "task_limit", ",", "switch", "=", "False", ",", "ordered", "=", "True", ")" ]
41.181818
0.00216
def maybe_automatically_publish_drafts_on_save(sender, instance, **kwargs): """ If automatic publishing is enabled, immediately publish a draft copy after it has been saved. """ # Skip processing if auto-publishing is not enabled if not is_automatic_publishing_enabled(sender): return ...
[ "def", "maybe_automatically_publish_drafts_on_save", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "# Skip processing if auto-publishing is not enabled", "if", "not", "is_automatic_publishing_enabled", "(", "sender", ")", ":", "return", "# Skip missing ...
35.473684
0.001445
def get_asset_path(self, filename): """ Get the full system path of a given asset if it exists. Otherwise it throws an error. Args: filename (str) - File name of a file in /assets folder to fetch the path for. Returns: str - path to the target file. ...
[ "def", "get_asset_path", "(", "self", ",", "filename", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", "(", "self", ".", "_asset_path", ",", "filename", ")", ")", ":", "return", "os", ".", "path", ".", "join",...
33.833333
0.008383
def codemirror_instance(config_name, varname, element_id, assets=True): """ Return HTML to init a CodeMirror instance for an element. This will output the whole HTML needed to initialize a CodeMirror instance with needed assets loading. Assets can be omitted with the ``assets`` option. Example...
[ "def", "codemirror_instance", "(", "config_name", ",", "varname", ",", "element_id", ",", "assets", "=", "True", ")", ":", "output", "=", "io", ".", "StringIO", "(", ")", "manifesto", "=", "CodemirrorAssetTagRender", "(", ")", "manifesto", ".", "register", "...
29.295455
0.000751
def reject(self): """ Emits the accepted signal and closes the popup. """ self._result = 0 if not self.signalsBlocked(): self.rejected.emit() if self.autoCloseOnReject(): self.close()
[ "def", "reject", "(", "self", ")", ":", "self", ".", "_result", "=", "0", "if", "not", "self", ".", "signalsBlocked", "(", ")", ":", "self", ".", "rejected", ".", "emit", "(", ")", "if", "self", ".", "autoCloseOnReject", "(", ")", ":", "self", ".",...
26.4
0.010989
def translate_key_values(adict, translations, default=''): """Modify the keys in adict to the ones in translations. Be careful, this will modify your input dictionary. The keys not present in translations will be left intact. Parameters ---------- adict: a dictionary translations: iterable...
[ "def", "translate_key_values", "(", "adict", ",", "translations", ",", "default", "=", "''", ")", ":", "for", "src_key", ",", "dst_key", "in", "translations", ":", "adict", "[", "dst_key", "]", "=", "adict", ".", "pop", "(", "src_key", ",", "default", ")...
29.8
0.001626
def clear(self): "Remove all rows and reset internal structures" ## list has no clear ... remove items in reverse order for i in range(len(self)-1, -1, -1): del self[i] self._key = 0 if hasattr(self._grid_view, "wx_obj"): self._grid_view.wx_obj.Clea...
[ "def", "clear", "(", "self", ")", ":", "## list has no clear ... remove items in reverse order\r", "for", "i", "in", "range", "(", "len", "(", "self", ")", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "del", "self", "[", "i", "]", "self", ".", "...
40
0.009174
def q12d_local(vertices, lame, mu): """Local stiffness matrix for two dimensional elasticity on a square element. Parameters ---------- lame : Float Lame's first parameter mu : Float shear modulus See Also -------- linear_elasticity Notes ----- Vertices sho...
[ "def", "q12d_local", "(", "vertices", ",", "lame", ",", "mu", ")", ":", "M", "=", "lame", "+", "2", "*", "mu", "# P-wave modulus", "R_11", "=", "np", ".", "matrix", "(", "[", "[", "2", ",", "-", "2", ",", "-", "1", ",", "1", "]", ",", "[", ...
24.594203
0.001133
def print_spans(spans, max_idx: int) -> None: """Quick test to show how character spans match original BEL String Mostly for debugging purposes """ bel_spans = [" "] * (max_idx + 3) for val, span in spans: if val in ["Nested", "NSArg"]: continue for i in range(span[0], ...
[ "def", "print_spans", "(", "spans", ",", "max_idx", ":", "int", ")", "->", "None", ":", "bel_spans", "=", "[", "\" \"", "]", "*", "(", "max_idx", "+", "3", ")", "for", "val", ",", "span", "in", "spans", ":", "if", "val", "in", "[", "\"Nested\"", ...
28.909091
0.001522
def convert_pdf_to_txt(pdf, startpage=None): """Convert a pdf file to text and return the text. This method requires pdftotext to be installed. Parameters ---------- pdf : str path to pdf file startpage : int, optional the first page we try to convert Returns ------- ...
[ "def", "convert_pdf_to_txt", "(", "pdf", ",", "startpage", "=", "None", ")", ":", "if", "startpage", "is", "not", "None", ":", "startpageargs", "=", "[", "'-f'", ",", "str", "(", "startpage", ")", "]", "else", ":", "startpageargs", "=", "[", "]", "stdo...
25.25
0.001362
def set_data_value(datastore, path, data): ''' Set a data entry in a datastore :param datastore: The datastore, e.g. running, operational. One of the NETCONF store IETF types :type datastore: :class:`DatastoreType` (``str`` enum). :param path: The device path to set the value at, ...
[ "def", "set_data_value", "(", "datastore", ",", "path", ",", "data", ")", ":", "if", "isinstance", "(", "path", ",", "six", ".", "string_types", ")", ":", "path", "=", "'/'", ".", "split", "(", "path", ")", "return", "_proxy_cmd", "(", "'set_data_value'"...
32.08
0.002421
def get_identity(self, subject_id, entities=None): """ Get all the identity information that has been received and are still valid about the subject. :param subject_id: The identifier of the subject :param entities: The identifiers of the entities whoes assertions are intere...
[ "def", "get_identity", "(", "self", ",", "subject_id", ",", "entities", "=", "None", ")", ":", "if", "not", "entities", ":", "entities", "=", "self", ".", "entities", "(", "subject_id", ")", "if", "not", "entities", ":", "return", "{", "}", ",", "[", ...
39.875
0.002295
def ram_dumper(**kwargs): """Dump data to 'memory' for later usage.""" logging.debug("trying to save stuff in memory") farms = kwargs["farms"] experiments = kwargs["experiments"] engine = kwargs["engine"] try: engine_name = engine.__name__ except AttributeError: engine_name ...
[ "def", "ram_dumper", "(", "*", "*", "kwargs", ")", ":", "logging", ".", "debug", "(", "\"trying to save stuff in memory\"", ")", "farms", "=", "kwargs", "[", "\"farms\"", "]", "experiments", "=", "kwargs", "[", "\"experiments\"", "]", "engine", "=", "kwargs", ...
36.636364
0.002418
def _get_batch_name(items, skip_jointcheck=False): """Retrieve the shared batch name for a group of items. """ batch_names = collections.defaultdict(int) has_joint = any([is_joint(d) for d in items]) for data in items: if has_joint and not skip_jointcheck: batches = dd.get_sample...
[ "def", "_get_batch_name", "(", "items", ",", "skip_jointcheck", "=", "False", ")", ":", "batch_names", "=", "collections", ".", "defaultdict", "(", "int", ")", "has_joint", "=", "any", "(", "[", "is_joint", "(", "d", ")", "for", "d", "in", "items", "]", ...
41.533333
0.00157
def optional_file_like(path): """Validator that ensures that if a file exists it regular, a fifo, or a character device. The file is not required to exist. This includes character special devices like /dev/null. """ if (os.path.exists(path) and not (os.path.isfile(path) or ...
[ "def", "optional_file_like", "(", "path", ")", ":", "if", "(", "os", ".", "path", ".", "exists", "(", "path", ")", "and", "not", "(", "os", ".", "path", ".", "isfile", "(", "path", ")", "or", "stat", ".", "S_ISFIFO", "(", "os", ".", "stat", "(", ...
50
0.001786
def init(): ''' Return the list of svn remotes and their configuration information ''' bp_ = os.path.join(__opts__['cachedir'], 'svnfs') new_remote = False repos = [] per_remote_defaults = {} for param in PER_REMOTE_OVERRIDES: per_remote_defaults[param] = \ six.text_...
[ "def", "init", "(", ")", ":", "bp_", "=", "os", ".", "path", ".", "join", "(", "__opts__", "[", "'cachedir'", "]", ",", "'svnfs'", ")", "new_remote", "=", "False", "repos", "=", "[", "]", "per_remote_defaults", "=", "{", "}", "for", "param", "in", ...
36.512195
0.000434
def _ExtractPathSpecsFromDirectory(self, file_entry, depth=0): """Extracts path specification from a directory. Args: file_entry (dfvfs.FileEntry): file entry that refers to the directory. depth (Optional[int]): current depth where 0 represents the file system root. Yields: dfv...
[ "def", "_ExtractPathSpecsFromDirectory", "(", "self", ",", "file_entry", ",", "depth", "=", "0", ")", ":", "if", "depth", ">=", "self", ".", "_MAXIMUM_DEPTH", ":", "raise", "errors", ".", "MaximumRecursionDepth", "(", "'Maximum recursion depth reached.'", ")", "# ...
37.560606
0.009041
def build_graph(self): """Forms the core by building a wrapper around the inception graph. Here we add the necessary input & output tensors, to decode jpegs, serialize embeddings, restore from checkpoint etc. To use other Inception models modify this file. Note that to use other models bes...
[ "def", "build_graph", "(", "self", ")", ":", "import", "tensorflow", "as", "tf", "input_jpeg", "=", "tf", ".", "placeholder", "(", "tf", ".", "string", ",", "shape", "=", "None", ")", "image", "=", "tf", ".", "image", ".", "decode_jpeg", "(", "input_jp...
42.5
0.001643
def refresh_content(self, order=None, name=None): """ Re-download all submissions and reset the page index """ order = order or self.content.order # Preserve the query if staying on the current page if name is None: query = self.content.query else: ...
[ "def", "refresh_content", "(", "self", ",", "order", "=", "None", ",", "name", "=", "None", ")", ":", "order", "=", "order", "or", "self", ".", "content", ".", "order", "# Preserve the query if staying on the current page", "if", "name", "is", "None", ":", "...
33.958333
0.002387
def mean_size(self, p, q): ''' >>> ds = 1E-6*np.array([240, 360, 450, 562.5, 703, 878, 1097, 1371, 1713, 2141, 2676, 3345, 4181, 5226, 6532]) >>> numbers = [65, 119, 232, 410, 629, 849, 990, 981, 825, 579, 297, 111, 21, 1] >>> psd = ParticleSizeDistribution(ds=ds, fractions=numbe...
[ "def", "mean_size", "(", "self", ",", "p", ",", "q", ")", ":", "if", "p", "!=", "q", ":", "# Note: D(p, q) = D(q, p); in ISO and proven experimentally", "numerator", "=", "sum", "(", "self", ".", "di_power", "(", "i", "=", "i", ",", "power", "=", "p", ")...
61.941176
0.008419
def get_version_status( package_descriptors, targets, repos_data, strip_version=False, strip_os_code_name=False): """ For each package and target check if it is affected by a sync. This is the case when the package version in the testing repo is different from the version in the main re...
[ "def", "get_version_status", "(", "package_descriptors", ",", "targets", ",", "repos_data", ",", "strip_version", "=", "False", ",", "strip_os_code_name", "=", "False", ")", ":", "status", "=", "{", "}", "for", "package_descriptor", "in", "package_descriptors", "....
39.571429
0.000503
def command(sock, dbname, spec, slave_ok, is_mongos, read_preference, codec_options, check=True, allowable_errors=None, address=None, check_keys=False, listeners=None, max_bson_size=None, read_concern=DEFAULT_READ_CONCERN, parse_write_concern_error=False, ...
[ "def", "command", "(", "sock", ",", "dbname", ",", "spec", ",", "slave_ok", ",", "is_mongos", ",", "read_preference", ",", "codec_options", ",", "check", "=", "True", ",", "allowable_errors", "=", "None", ",", "address", "=", "None", ",", "check_keys", "="...
41.428571
0.000281
def make_processitem_handlelist_handle_name(handle_name, condition='contains', negate=False, preserve_case=False): """ Create a node for ProcessItem/HandleList/Handle/Name :return: A IndicatorItem represented as an Element node """ document = 'ProcessItem' search = 'ProcessItem/HandleList/H...
[ "def", "make_processitem_handlelist_handle_name", "(", "handle_name", ",", "condition", "=", "'contains'", ",", "negate", "=", "False", ",", "preserve_case", "=", "False", ")", ":", "document", "=", "'ProcessItem'", "search", "=", "'ProcessItem/HandleList/Handle/Name'",...
44.615385
0.008446
async def publish_event( self, stream: str, type: str, body: Optional[Any] = None, id: Optional[uuid.UUID] = None, metadata: Optional[Any] = None, expected_version: int = -2, require_master: bool = False, ) -> None: """ Publish a single...
[ "async", "def", "publish_event", "(", "self", ",", "stream", ":", "str", ",", "type", ":", "str", ",", "body", ":", "Optional", "[", "Any", "]", "=", "None", ",", "id", ":", "Optional", "[", "uuid", ".", "UUID", "]", "=", "None", ",", "metadata", ...
38.809524
0.002393
def __find_and_modify(self, filter, projection, sort, upsert=None, return_document=ReturnDocument.BEFORE, array_filters=None, session=None, **kwargs): """Internal findAndModify helper.""" common.validate_is_mapping("filter", filter) if not isi...
[ "def", "__find_and_modify", "(", "self", ",", "filter", ",", "projection", ",", "sort", ",", "upsert", "=", "None", ",", "return_document", "=", "ReturnDocument", ".", "BEFORE", ",", "array_filters", "=", "None", ",", "session", "=", "None", ",", "*", "*",...
48.634615
0.00155
def ntile(n): """ Window function: returns the ntile group id (from 1 to `n` inclusive) in an ordered window partition. For example, if `n` is 4, the first quarter of the rows will get value 1, the second quarter will get 2, the third quarter will get 3, and the last quarter will get 4. This is...
[ "def", "ntile", "(", "n", ")", ":", "sc", "=", "SparkContext", ".", "_active_spark_context", "return", "Column", "(", "sc", ".", "_jvm", ".", "functions", ".", "ntile", "(", "int", "(", "n", ")", ")", ")" ]
36.769231
0.002041