text
stringlengths
75
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
0.18
def _check_set_values(instance, dic): """ This function checks if the dict values are correct. :instance: the object instance. Used for querying :dic: is a dictionary with the following format: {'actions': [{'act_row_idx': 0, 'action': 'repeat', 'an_result_id': ...
[ "def", "_check_set_values", "(", "instance", ",", "dic", ")", ":", "uc", "=", "getToolByName", "(", "instance", ",", "'uid_catalog'", ")", "rulenumber", "=", "dic", ".", "get", "(", "'rulenumber'", ",", "'0'", ")", "if", "rulenumber", "and", "not", "(", ...
43.28169
0.000318
def read_pl_dataset(infile): """ Description: Read from disk a Plackett-Luce dataset. Parameters: infile: open file object from which to read the dataset """ m, n = [int(i) for i in infile.readline().split(',')] gamma = np.array([float(f) for f in infile.readline().spli...
[ "def", "read_pl_dataset", "(", "infile", ")", ":", "m", ",", "n", "=", "[", "int", "(", "i", ")", "for", "i", "in", "infile", ".", "readline", "(", ")", ".", "split", "(", "','", ")", "]", "gamma", "=", "np", ".", "array", "(", "[", "float", ...
31.461538
0.001186
def _load_zip_wav(zfile, offset=0, count=None): """Load a wav file into an array from frame start to fram end :param zfile: ZipExtFile file-like object from where to load the audio :param offset: First sample to load :param count: Maximum number of samples to load :return: The audio samples in a nu...
[ "def", "_load_zip_wav", "(", "zfile", ",", "offset", "=", "0", ",", "count", "=", "None", ")", ":", "buf", "=", "StringIO", ".", "StringIO", "(", "zfile", ".", "read", "(", ")", ")", "sample_rate", ",", "audio", "=", "wavfile", ".", "read", "(", "b...
28.888889
0.001862
def cmd_block(self, is_retry=False): ''' Prepare the pre-check command to send to the subsystem 1. execute SHIM + command 2. check if SHIM returns a master request or if it completed 3. handle any master request 4. re-execute SHIM + command 5. split SHIM results ...
[ "def", "cmd_block", "(", "self", ",", "is_retry", "=", "False", ")", ":", "self", ".", "argv", "=", "_convert_args", "(", "self", ".", "argv", ")", "log", ".", "debug", "(", "'Performing shimmed, blocking command as follows:\\n%s'", ",", "' '", ".", "join", ...
50.339806
0.002081
def merge(self, other, inplace=None, overwrite_vars=frozenset(), compat='no_conflicts', join='outer'): """Merge the arrays of two datasets into a single dataset. This method generally not allow for overriding data, with the exception of attributes, which are ignored on the second ...
[ "def", "merge", "(", "self", ",", "other", ",", "inplace", "=", "None", ",", "overwrite_vars", "=", "frozenset", "(", ")", ",", "compat", "=", "'no_conflicts'", ",", "join", "=", "'outer'", ")", ":", "inplace", "=", "_check_inplace", "(", "inplace", ")",...
44.578947
0.001155
def __get_base_path(self): """Return the file's directory and file name, with the suffix stripped.""" entry = self.get() return SCons.Subst.SpecialAttrWrapper(SCons.Util.splitext(entry.get_path())[0], entry.name + "_base")
[ "def", "__get_base_path", "(", "self", ")", ":", "entry", "=", "self", ".", "get", "(", ")", "return", "SCons", ".", "Subst", ".", "SpecialAttrWrapper", "(", "SCons", ".", "Util", ".", "splitext", "(", "entry", ".", "get_path", "(", ")", ")", "[", "0...
49
0.013378
def execute(self, query, *parameters, **kwargs): """Same as query, but do not process results. Always returns `None`.""" cursor = self._cursor() try: self._execute(cursor, query, parameters, kwargs) except: raise finally: cursor.close()
[ "def", "execute", "(", "self", ",", "query", ",", "*", "parameters", ",", "*", "*", "kwargs", ")", ":", "cursor", "=", "self", ".", "_cursor", "(", ")", "try", ":", "self", ".", "_execute", "(", "cursor", ",", "query", ",", "parameters", ",", "kwar...
27.636364
0.009554
def dispatch_failed(self, context): """Print the unhandled exception and exit the application.""" traceback.print_exception( context.exc_type, context.exc_value, context.traceback) raise SystemExit(1)
[ "def", "dispatch_failed", "(", "self", ",", "context", ")", ":", "traceback", ".", "print_exception", "(", "context", ".", "exc_type", ",", "context", ".", "exc_value", ",", "context", ".", "traceback", ")", "raise", "SystemExit", "(", "1", ")" ]
46.4
0.008475
def show_xyzs(self, xs, ys, zs, imgsize:int=4, figsize:Optional[Tuple[int,int]]=None, **kwargs): "Show `xs` (inputs), `ys` (targets) and `zs` (predictions) on a figure of `figsize`." title = 'Input / Prediction / Target' axs = subplots(len(xs), 3, imgsize=imgsize, figsize=figsize, title=title, w...
[ "def", "show_xyzs", "(", "self", ",", "xs", ",", "ys", ",", "zs", ",", "imgsize", ":", "int", "=", "4", ",", "figsize", ":", "Optional", "[", "Tuple", "[", "int", ",", "int", "]", "]", "=", "None", ",", "*", "*", "kwargs", ")", ":", "title", ...
64
0.038536
def mangle(tree, toplevel=False): """Mangle names. Args: toplevel: defaults to False. Defines if global scope should be mangled or not. """ sym_table = SymbolTable() visitor = ScopeTreeVisitor(sym_table) visitor.visit(tree) fill_scope_references(tree) mangle_scope_tree(...
[ "def", "mangle", "(", "tree", ",", "toplevel", "=", "False", ")", ":", "sym_table", "=", "SymbolTable", "(", ")", "visitor", "=", "ScopeTreeVisitor", "(", "sym_table", ")", "visitor", ".", "visit", "(", "tree", ")", "fill_scope_references", "(", "tree", ")...
24.5625
0.002451
def densify(self, geometries, sr, maxSegmentLength, lengthUnit, geodesic=False, ): """ The densify operation is performed on a geometry service resource. This operation densifies geometries by plotti...
[ "def", "densify", "(", "self", ",", "geometries", ",", "sr", ",", "maxSegmentLength", ",", "lengthUnit", ",", "geodesic", "=", "False", ",", ")", ":", "url", "=", "self", ".", "_url", "+", "\"/densify\"", "params", "=", "{", "\"f\"", ":", "\"json\"", "...
45.090909
0.013814
def getCallerInfo(depth=2): """Utility function to get information about function callers The information is the tuple (function/method name, filename, class) The class will be None if the caller is just a function and not an object method. :param depth: (int) how far back in the callstack to go to extract ...
[ "def", "getCallerInfo", "(", "depth", "=", "2", ")", ":", "f", "=", "sys", ".", "_getframe", "(", "depth", ")", "method_name", "=", "f", ".", "f_code", ".", "co_name", "filename", "=", "f", ".", "f_code", ".", "co_filename", "arg_class", "=", "None", ...
31.857143
0.014514
def char_conv(out): """ Convert integer vectors to character vectors for batch. """ out_conv = list() for i in range(out.shape[0]): tmp_str = '' for j in range(out.shape[1]): if int(out[i][j]) >= 0: tmp_char = int2char(int(out[i][j])) if in...
[ "def", "char_conv", "(", "out", ")", ":", "out_conv", "=", "list", "(", ")", "for", "i", "in", "range", "(", "out", ".", "shape", "[", "0", "]", ")", ":", "tmp_str", "=", "''", "for", "j", "in", "range", "(", "out", ".", "shape", "[", "1", "]...
30.466667
0.002123
def name(dataset_uri, new_name): """ Report / update the name of the dataset. It is only possible to update the name of a proto dataset, i.e. a dataset that has not yet been frozen. """ if new_name != "": _validate_name(new_name) try: dataset = dtoolcore.ProtoDataSe...
[ "def", "name", "(", "dataset_uri", ",", "new_name", ")", ":", "if", "new_name", "!=", "\"\"", ":", "_validate_name", "(", "new_name", ")", "try", ":", "dataset", "=", "dtoolcore", ".", "ProtoDataSet", ".", "from_uri", "(", "uri", "=", "dataset_uri", ",", ...
27.607143
0.00125
def reset(resources, *args, **kwargs): """ Remove dispensers and indicators for idle resources. """ test = kwargs.pop('test', False) client = redis.Redis(decode_responses=True, **kwargs) resources = resources if resources else find_resources(client) for resource in resources: # investigate ...
[ "def", "reset", "(", "resources", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "test", "=", "kwargs", ".", "pop", "(", "'test'", ",", "False", ")", "client", "=", "redis", ".", "Redis", "(", "decode_responses", "=", "True", ",", "*", "*", ...
37.578947
0.000683
def getProductAndReleaseResourceClient(self): """ Create an API resource REST client :return: Rest client for 'Environment' API resource """ split_regex = "(.*)://(.*):(\d*)/(.*)" regex_matches = re.search(split_regex, self.endpoint_url) logger.info("Creating Pro...
[ "def", "getProductAndReleaseResourceClient", "(", "self", ")", ":", "split_regex", "=", "\"(.*)://(.*):(\\d*)/(.*)\"", "regex_matches", "=", "re", ".", "search", "(", "split_regex", ",", "self", ".", "endpoint_url", ")", "logger", ".", "info", "(", "\"Creating Produ...
49.076923
0.012308
def old_collective_correlation( self ): """ Returns the collective correlation factor, f_I Args: None Returns: (Float): The collective correlation factor, f_I. Notes: This function assumes that the jump distance between sites has ...
[ "def", "old_collective_correlation", "(", "self", ")", ":", "if", "self", ".", "has_run", ":", "return", "self", ".", "atoms", ".", "collective_dr_squared", "(", ")", "/", "float", "(", "self", ".", "number_of_jumps", ")", "else", ":", "return", "None" ]
33.1
0.010279
def merge(self, config): """ Load configuration from given configuration. :param config: config to load. If config is a string type, then it's treated as .ini filename :return: None """ if isinstance(config, ConfigParser) is True: self.update(config) elif isinstance(config, str): self.read(config)
[ "def", "merge", "(", "self", ",", "config", ")", ":", "if", "isinstance", "(", "config", ",", "ConfigParser", ")", "is", "True", ":", "self", ".", "update", "(", "config", ")", "elif", "isinstance", "(", "config", ",", "str", ")", ":", "self", ".", ...
30.8
0.0347
def api_url(string): """Ensure that `string` looks like a URL to the API. This ensures that the API version is specified explicitly (i.e. the path ends with /api/{version}). If not, version 2.0 is selected. It also ensures that the path ends with a forward-slash. This is suitable for use as an arg...
[ "def", "api_url", "(", "string", ")", ":", "url", "=", "urlparse", "(", "string", ")", "url", "=", "url", ".", "_replace", "(", "path", "=", "ensure_trailing_slash", "(", "url", ".", "path", ")", ")", "if", "re", ".", "search", "(", "\"/api/[0-9.]+/?$\...
40.142857
0.001739
def do_exists(self, params): """ \x1b[1mNAME\x1b[0m exists - Gets the znode's stat information \x1b[1mSYNOPSIS\x1b[0m exists <path> [watch] [pretty_date] \x1b[1mOPTIONS\x1b[0m * watch: set a (data) watch on the path (default: false) \x1b[1mEXAMPLES\x1b[0m exists /foo S...
[ "def", "do_exists", "(", "self", ",", "params", ")", ":", "watcher", "=", "lambda", "evt", ":", "self", ".", "show_output", "(", "str", "(", "evt", ")", ")", "kwargs", "=", "{", "\"watch\"", ":", "watcher", "}", "if", "params", ".", "watch", "else", ...
33.913793
0.00247
def request(self, url, method="GET", params=None, headers=None, is_signed=True): """ Make a request against ``url``. By default, the request is signed with an access token, but can be turned off by passing ``is_signed=False``. """ params = params or {} headers = headers o...
[ "def", "request", "(", "self", ",", "url", ",", "method", "=", "\"GET\"", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "is_signed", "=", "True", ")", ":", "params", "=", "params", "or", "{", "}", "headers", "=", "headers", "or", "{...
45
0.008708
def _compile_int(self): """Time Domain Simulation routine execution""" string = '"""\n' # evaluate the algebraic equations g string += 'system.dae.init_fg(resetz=False)\n' for gcall, call in zip(self.gcall, self.gcalls): if gcall: string += call ...
[ "def", "_compile_int", "(", "self", ")", ":", "string", "=", "'\"\"\"\\n'", "# evaluate the algebraic equations g", "string", "+=", "'system.dae.init_fg(resetz=False)\\n'", "for", "gcall", ",", "call", "in", "zip", "(", "self", ".", "gcall", ",", "self", ".", "gca...
32.26
0.001203
def instance_norm(attrs, inputs, proto_obj): """Instance Normalization.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'epsilon' : 'eps'}) new_attrs['eps'] = attrs.get('epsilon', 1e-5) return 'InstanceNorm', new_attrs, inputs
[ "def", "instance_norm", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'epsilon'", ":", "'eps'", "}", ")", "new_attrs", "[", "'eps'", "]", "=", "attrs", ...
50.4
0.011719
def busy_connections(self): """Return a list of active/busy connections :rtype: list """ return [c for c in self.connections.values() if c.busy and not c.closed]
[ "def", "busy_connections", "(", "self", ")", ":", "return", "[", "c", "for", "c", "in", "self", ".", "connections", ".", "values", "(", ")", "if", "c", ".", "busy", "and", "not", "c", ".", "closed", "]" ]
25.5
0.009479
def dataset(self, dataset): """Set dataset having displacements and optionally forces Note ---- Elements of the list accessed by 'first_atoms' corresponds to each displaced supercell. Each displaced supercell contains only one displacement. dict['first_atoms']['forces'] ...
[ "def", "dataset", "(", "self", ",", "dataset", ")", ":", "if", "'displacements'", "in", "dataset", ":", "natom", "=", "self", ".", "_supercell", ".", "get_number_of_atoms", "(", ")", "if", "type", "(", "dataset", "[", "'displacements'", "]", ")", "is", "...
45.555556
0.000955
def domain_search(self, domain=None, company=None, limit=None, offset=None, emails_type=None, raw=False): """ Return all the email addresses found for a given domain. :param domain: The domain on which to search for emails. Must be defined if company is not. ...
[ "def", "domain_search", "(", "self", ",", "domain", "=", "None", ",", "company", "=", "None", ",", "limit", "=", "None", ",", "offset", "=", "None", ",", "emails_type", "=", "None", ",", "raw", "=", "False", ")", ":", "if", "not", "domain", "and", ...
32.822222
0.001972
def detect(self, st, threshold, trig_int, moveout=0, min_trig=0, process=True, extract_detections=False, cores=1, debug=0): """ Detect within continuous data using the subspace method. :type st: obspy.core.stream.Stream :param st: Un-processed stream to detect...
[ "def", "detect", "(", "self", ",", "st", ",", "threshold", ",", "trig_int", ",", "moveout", "=", "0", ",", "min_trig", "=", "0", ",", "process", "=", "True", ",", "extract_detections", "=", "False", ",", "cores", "=", "1", ",", "debug", "=", "0", "...
46.191176
0.000935
def _collect_potential_merges(dag, barriers): """ Returns a dict of DAGNode : Barrier objects, where the barrier needs to be inserted where the corresponding DAGNode appears in the main DAG """ # if only got 1 or 0 barriers then can't merge if len(barriers) < 2: ...
[ "def", "_collect_potential_merges", "(", "dag", ",", "barriers", ")", ":", "# if only got 1 or 0 barriers then can't merge", "if", "len", "(", "barriers", ")", "<", "2", ":", "return", "None", "# mapping from the node that will be the main barrier to the", "# barrier object t...
40.720588
0.002116
def init0(self, dae): """Set initial p and q for power flow""" self.p0 = matrix(self.p, (self.n, 1), 'd') self.q0 = matrix(self.q, (self.n, 1), 'd')
[ "def", "init0", "(", "self", ",", "dae", ")", ":", "self", ".", "p0", "=", "matrix", "(", "self", ".", "p", ",", "(", "self", ".", "n", ",", "1", ")", ",", "'d'", ")", "self", ".", "q0", "=", "matrix", "(", "self", ".", "q", ",", "(", "se...
42.25
0.011628
def get_uri(self): """Get a URL representation of the service.""" uri = "%s://%s%s" % (self.scheme, self.get_canonical_host(), self.path) return uri
[ "def", "get_uri", "(", "self", ")", ":", "uri", "=", "\"%s://%s%s\"", "%", "(", "self", ".", "scheme", ",", "self", ".", "get_canonical_host", "(", ")", ",", "self", ".", "path", ")", "return", "uri" ]
42.25
0.011628
def get_radius(self): """! @brief Calculates radius of cluster that is represented by the entry. @details It's calculated once when it's requested after the last changes. @return (double) Radius of cluster that is represented by the entry. """ ...
[ "def", "get_radius", "(", "self", ")", ":", "if", "(", "self", ".", "__radius", "is", "not", "None", ")", ":", "return", "self", ".", "__radius", "centroid", "=", "self", ".", "get_centroid", "(", ")", "radius_part_1", "=", "self", ".", "square_sum", "...
38.785714
0.024259
def timeout(self, timeout): """ :param timeout: Timeout for the query (in seconds) :type timeout: float or None """ clone = copy.deepcopy(self) clone._timeout = timeout return clone
[ "def", "timeout", "(", "self", ",", "timeout", ")", ":", "clone", "=", "copy", ".", "deepcopy", "(", "self", ")", "clone", ".", "_timeout", "=", "timeout", "return", "clone" ]
28.75
0.008439
def add_object(cls, attr, title='', display=''): """Adds a ``list_display`` attribute showing an object. Supports double underscore attribute name dereferencing. :param attr: Name of the attribute to dereference from the corresponding object, i.e. what will be lined to....
[ "def", "add_object", "(", "cls", ",", "attr", ",", "title", "=", "''", ",", "display", "=", "''", ")", ":", "global", "klass_count", "klass_count", "+=", "1", "fn_name", "=", "'dyn_fn_%d'", "%", "klass_count", "cls", ".", "list_display", ".", "append", "...
37.75
0.001174
def filterOptions(self, text): """ Filters the searched actions based on the inputed text. :param text | <str> """ if not text: self._completer.hide() self._completer.setCurrentItem(None) return # block the sig...
[ "def", "filterOptions", "(", "self", ",", "text", ")", ":", "if", "not", "text", ":", "self", ".", "_completer", ".", "hide", "(", ")", "self", ".", "_completer", ".", "setCurrentItem", "(", "None", ")", "return", "# block the signals\r", "self", ".", "_...
35.333333
0.002448
def classproperty(func): """Use as a decorator on a method definition to make it a class-level attribute. This decorator can be applied to a method, a classmethod, or a staticmethod. This decorator will bind the first argument to the class object. Usage: >>> class Foo(object): ... @classproperty ... ...
[ "def", "classproperty", "(", "func", ")", ":", "doc", "=", "func", ".", "__doc__", "if", "not", "isinstance", "(", "func", ",", "(", "classmethod", ",", "staticmethod", ")", ")", ":", "func", "=", "classmethod", "(", "func", ")", "return", "ClassProperty...
27.423077
0.009485
def get_platform_settings(): """ Returns the content of `settings.PLATFORMS` with a twist. The platforms settings was created to stay compatible with the old way of declaring the FB configuration, in order not to break production bots. This function will convert the legacy configuration into the ne...
[ "def", "get_platform_settings", "(", ")", ":", "s", "=", "settings", ".", "PLATFORMS", "if", "hasattr", "(", "settings", ",", "'FACEBOOK'", ")", "and", "settings", ".", "FACEBOOK", ":", "s", ".", "append", "(", "{", "'class'", ":", "'bernard.platforms.facebo...
33.6
0.001447
def _replace_locals(tok): """Replace local variables with a syntactically valid name. Parameters ---------- tok : tuple of int, str ints correspond to the all caps constants in the tokenize module Returns ------- t : tuple of int, str Either the input or token or the replac...
[ "def", "_replace_locals", "(", "tok", ")", ":", "toknum", ",", "tokval", "=", "tok", "if", "toknum", "==", "tokenize", ".", "OP", "and", "tokval", "==", "'@'", ":", "return", "tokenize", ".", "OP", ",", "_LOCAL_TAG", "return", "toknum", ",", "tokval" ]
30.565217
0.001379
def resource_set_create(self, token, name, **kwargs): """ Create a resource set. https://docs.kantarainitiative.org/uma/rec-oauth-resource-reg-v1_0_1.html#rfc.section.2.2.1 :param str token: client access token :param str id: Identifier of the resource set :param str na...
[ "def", "resource_set_create", "(", "self", ",", "token", ",", "name", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_realm", ".", "client", ".", "post", "(", "self", ".", "well_known", "[", "'resource_registration_endpoint'", "]", ",", "data",...
36
0.002353
def get_height_rect(width: int, string: str) -> int: """Return the number of lines which would be printed from these parameters. `width` is the width of the print boundary. `string` is a Unicode string which may include color control characters. .. versionadded:: 9.2 """ string_ = string.enco...
[ "def", "get_height_rect", "(", "width", ":", "int", ",", "string", ":", "str", ")", "->", "int", ":", "string_", "=", "string", ".", "encode", "(", "\"utf-8\"", ")", "# type: bytes", "return", "int", "(", "lib", ".", "get_height_rect2", "(", "width", ","...
36.636364
0.002421
def coverageInfo(self): """ Return information about the bases found at each location in our title sequence. @return: A C{dict} whose keys are C{int} subject offsets and whose values are unsorted lists of (score, base) 2-tuples, giving all the bases from reads th...
[ "def", "coverageInfo", "(", "self", ")", ":", "result", "=", "defaultdict", "(", "list", ")", "for", "titleAlignment", "in", "self", ":", "for", "hsp", "in", "titleAlignment", ".", "hsps", ":", "score", "=", "hsp", ".", "score", ".", "score", "for", "(...
39.4
0.002478
def feature2vector(feature, ref, layername=None): """ create a Vector object from ogr features Parameters ---------- feature: list of :osgeo:class:`ogr.Feature` or :osgeo:class:`ogr.Feature` a single feature or a list of features ref: Vector a reference Vector object to retrieve...
[ "def", "feature2vector", "(", "feature", ",", "ref", ",", "layername", "=", "None", ")", ":", "features", "=", "feature", "if", "isinstance", "(", "feature", ",", "list", ")", "else", "[", "feature", "]", "layername", "=", "layername", "if", "layername", ...
33.344828
0.00201
def _version_from_git_describe(): """ Read the version from ``git describe``. It returns the latest tag with an optional suffix if the current directory is not exactly on the tag. Example:: $ git describe --always v2.3.2-346-g164a52c075c8 The tag prefix (``v``) and the git commit ...
[ "def", "_version_from_git_describe", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "_SCAPY_PKG_DIR", ")", ",", "'.git'", ")", ")", ":", "# noqa: E501", "...
34.073171
0.000696
def determine_position(position, img, mark): """ Options: TL: top-left TR: top-right BR: bottom-right BL: bottom-left C: centered R: random X%xY%: relative positioning on both the X and Y axes X%xY: relative positioning on the X axis and absolute p...
[ "def", "determine_position", "(", "position", ",", "img", ",", "mark", ")", ":", "left", "=", "top", "=", "0", "max_left", "=", "max", "(", "img", ".", "size", "[", "0", "]", "-", "mark", ".", "size", "[", "0", "]", ",", "0", ")", "max_top", "=...
27.362319
0.002045
def run_forever(self, sockopt=None, sslopt=None, ping_interval=0, ping_timeout=None, http_proxy_host=None, http_proxy_port=None, http_no_proxy=None, http_proxy_auth=None, skip_utf8_validation=False, host=None, origin=Non...
[ "def", "run_forever", "(", "self", ",", "sockopt", "=", "None", ",", "sslopt", "=", "None", ",", "ping_interval", "=", "0", ",", "ping_timeout", "=", "None", ",", "http_proxy_host", "=", "None", ",", "http_proxy_port", "=", "None", ",", "http_no_proxy", "=...
43.211679
0.002477
def insert_many(self, rows, chunk_size=1000, ensure=None, types=None): """Add many rows at a time. This is significantly faster than adding them one by one. Per default the rows are processed in chunks of 1000 per commit, unless you specify a different ``chunk_size``. See :py:m...
[ "def", "insert_many", "(", "self", ",", "rows", ",", "chunk_size", "=", "1000", ",", "ensure", "=", "None", ",", "types", "=", "None", ")", ":", "chunk", "=", "[", "]", "for", "row", "in", "rows", ":", "row", "=", "self", ".", "_sync_columns", "(",...
34.846154
0.002148
def exist(self, table: str, libref: str ="") -> bool: """ table - the name of the SAS Data Set libref - the libref for the Data Set, defaults to WORK, or USER if assigned Returns True it the Data Set exists and False if it does not """ code = "data _null_; e = exist('" if le...
[ "def", "exist", "(", "self", ",", "table", ":", "str", ",", "libref", ":", "str", "=", "\"\"", ")", "->", "bool", ":", "code", "=", "\"data _null_; e = exist('\"", "if", "len", "(", "libref", ")", ":", "code", "+=", "libref", "+", "\".\"", "code", "+...
30.25
0.026702
def remove_element_attributes(elem_to_parse, *args): """ Removes the specified keys from the element's attributes, and returns a dict containing the attributes that have been removed. """ element = get_element(elem_to_parse) if element is None: return element if len(args): ...
[ "def", "remove_element_attributes", "(", "elem_to_parse", ",", "*", "args", ")", ":", "element", "=", "get_element", "(", "elem_to_parse", ")", "if", "element", "is", "None", ":", "return", "element", "if", "len", "(", "args", ")", ":", "attribs", "=", "el...
26.125
0.002309
def parsecommonarguments(object, doc, annotationtype, required, allowed, **kwargs): """Internal function to parse common FoLiA attributes and sets up the instance accordingly. Do not invoke directly.""" object.doc = doc #The FoLiA root document if required is None: required = tuple() if allowe...
[ "def", "parsecommonarguments", "(", "object", ",", "doc", ",", "annotationtype", ",", "required", ",", "allowed", ",", "*", "*", "kwargs", ")", ":", "object", ".", "doc", "=", "doc", "#The FoLiA root document", "if", "required", "is", "None", ":", "required"...
42.189091
0.00901
def setup(self, data, view='hypergrid', schema=None, columns=None, rowpivots=None, columnpivots=None, aggregates=None, sort=None, index='', limit=-1, computedcolumns=...
[ "def", "setup", "(", "self", ",", "data", ",", "view", "=", "'hypergrid'", ",", "schema", "=", "None", ",", "columns", "=", "None", ",", "rowpivots", "=", "None", ",", "columnpivots", "=", "None", ",", "aggregates", "=", "None", ",", "sort", "=", "No...
32.671875
0.009285
def save(self): """ save current config to the file """ with open(self._filename, "w") as f: self.config.write(f)
[ "def", "save", "(", "self", ")", ":", "with", "open", "(", "self", ".", "_filename", ",", "\"w\"", ")", "as", "f", ":", "self", ".", "config", ".", "write", "(", "f", ")" ]
25.333333
0.012739
def analyze(problem, X, Y, num_resamples=10, conf_level=0.95, print_to_console=False, seed=None): """Perform Delta Moment-Independent Analysis on model outputs. Returns a dictionary with keys 'delta', 'delta_conf', 'S1', and 'S1_conf', where each entry is a list of size D (the number of pa...
[ "def", "analyze", "(", "problem", ",", "X", ",", "Y", ",", "num_resamples", "=", "10", ",", "conf_level", "=", "0.95", ",", "print_to_console", "=", "False", ",", "seed", "=", "None", ")", ":", "if", "seed", ":", "np", ".", "random", ".", "seed", "...
36.644737
0.001399
def lstlec(string, n, lenvals, array): """ Given a character string and an ordered array of character strings, find the index of the largest array element less than or equal to the given string. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lstlec_c.html :param string: Upper bound va...
[ "def", "lstlec", "(", "string", ",", "n", ",", "lenvals", ",", "array", ")", ":", "string", "=", "stypes", ".", "stringToCharP", "(", "string", ")", "array", "=", "stypes", ".", "listToCharArrayPtr", "(", "array", ",", "xLen", "=", "lenvals", ",", "yLe...
34.423077
0.001087
def apply(self, data): """ Apply the given mapping to ``data``, recursively. The return type is a tuple of a boolean and the resulting data element. The boolean indicates whether any values were mapped in the child nodes of the mapping. It is used to skip optional branches of the object ...
[ "def", "apply", "(", "self", ",", "data", ")", ":", "if", "self", ".", "visitor", ".", "is_object", ":", "obj", "=", "{", "}", "if", "self", ".", "visitor", ".", "parent", "is", "None", ":", "obj", "[", "'$schema'", "]", "=", "self", ".", "visito...
42
0.001663
def ones(dur=None): """ Ones stream generator. You may multiply your endless stream by this to enforce an end to it. Parameters ---------- dur : Duration, in number of samples; endless if not given. Returns ------- Stream that repeats "1.0" during a given time duration (if any) or endlessly. ...
[ "def", "ones", "(", "dur", "=", "None", ")", ":", "if", "dur", "is", "None", "or", "(", "isinf", "(", "dur", ")", "and", "dur", ">", "0", ")", ":", "while", "True", ":", "yield", "1.0", "for", "x", "in", "xrange", "(", "int", "(", ".5", "+", ...
20.52381
0.011086
def generate_log_between_tags(self, older_tag, newer_tag): """ Generate log between 2 specified tags. :param dict older_tag: All issues before this tag's date will be excluded. May be special value, if new tag is the first tag. (Mean...
[ "def", "generate_log_between_tags", "(", "self", ",", "older_tag", ",", "newer_tag", ")", ":", "filtered_issues", ",", "filtered_pull_requests", "=", "self", ".", "filter_issues_for_tags", "(", "newer_tag", ",", "older_tag", ")", "older_tag_name", "=", "older_tag", ...
43.423077
0.001733
def create_connection(username=None, password=None, login_url=None, auth_url=None, api_key=None, realm=None, base_uri=None, proxies=None, timeout=None, headers=None, cookies=None, accepted_return=None): """ Creates and returns a connection ...
[ "def", "create_connection", "(", "username", "=", "None", ",", "password", "=", "None", ",", "login_url", "=", "None", ",", "auth_url", "=", "None", ",", "api_key", "=", "None", ",", "realm", "=", "None", ",", "base_uri", "=", "None", ",", "proxies", "...
57.8
0.001702
def setConfigurable(self, state): """ Sets whether or not this logger widget is configurable. :param state | <bool> """ self._configurable = state self._configButton.setVisible(state)
[ "def", "setConfigurable", "(", "self", ",", "state", ")", ":", "self", ".", "_configurable", "=", "state", "self", ".", "_configButton", ".", "setVisible", "(", "state", ")" ]
30.625
0.011905
def parse_from_json(json_str): """ Given a Unified Uploader message, parse the contents and return a MarketOrderList or MarketHistoryList instance. :param str json_str: A Unified Uploader message as a JSON string. :rtype: MarketOrderList or MarketHistoryList :raises: MalformedUploadError when i...
[ "def", "parse_from_json", "(", "json_str", ")", ":", "try", ":", "message_dict", "=", "json", ".", "loads", "(", "json_str", ")", "except", "ValueError", ":", "raise", "ParseError", "(", "\"Mal-formed JSON input.\"", ")", "upload_keys", "=", "message_dict", ".",...
34.789474
0.001472
def textConcat(self, content, len): """Concat the given string at the end of the existing node content """ ret = libxml2mod.xmlTextConcat(self._o, content, len) return ret
[ "def", "textConcat", "(", "self", ",", "content", ",", "len", ")", ":", "ret", "=", "libxml2mod", ".", "xmlTextConcat", "(", "self", ".", "_o", ",", "content", ",", "len", ")", "return", "ret" ]
40.4
0.009709
def _init_valid_functions(action_dimensions): """Initialize ValidFunctions and set up the callbacks.""" sizes = { "screen": tuple(int(i) for i in action_dimensions.screen), "screen2": tuple(int(i) for i in action_dimensions.screen), "minimap": tuple(int(i) for i in action_dimensions.minimap), } ...
[ "def", "_init_valid_functions", "(", "action_dimensions", ")", ":", "sizes", "=", "{", "\"screen\"", ":", "tuple", "(", "int", "(", "i", ")", "for", "i", "in", "action_dimensions", ".", "screen", ")", ",", "\"screen2\"", ":", "tuple", "(", "int", "(", "i...
37.470588
0.009188
def loads(s, filename=None, loader=None, implicit_tuple=True, env={}, schema=None): """Load and evaluate a GCL expression from a string.""" ast = reads(s, filename=filename, loader=loader, implicit_tuple=implicit_tuple) if not isinstance(env, framework.Environment): # For backwards compatibility we accept an ...
[ "def", "loads", "(", "s", ",", "filename", "=", "None", ",", "loader", "=", "None", ",", "implicit_tuple", "=", "True", ",", "env", "=", "{", "}", ",", "schema", "=", "None", ")", ":", "ast", "=", "reads", "(", "s", ",", "filename", "=", "filenam...
62.333333
0.015817
def do_clear(self, arg, arguments): """ Usage: clear Clears the screen.""" sys.stdout.write(os.popen('clear').read())
[ "def", "do_clear", "(", "self", ",", "arg", ",", "arguments", ")", ":", "sys", ".", "stdout", ".", "write", "(", "os", ".", "popen", "(", "'clear'", ")", ".", "read", "(", ")", ")" ]
19.5
0.01227
def send(self, message_data, routing_key=None, delivery_mode=None, mandatory=False, immediate=False, priority=0, content_type=None, content_encoding=None, serializer=None, exchange=None): """Send a message. :param message_data: The message data to send. Can be a list, ...
[ "def", "send", "(", "self", ",", "message_data", ",", "routing_key", "=", "None", ",", "delivery_mode", "=", "None", ",", "mandatory", "=", "False", ",", "immediate", "=", "False", ",", "priority", "=", "0", ",", "content_type", "=", "None", ",", "conten...
46.278689
0.001387
def contracts_derived(self): """list(Contract): List of contracts that are derived and not inherited.""" inheritance = (x.inheritance for x in self.contracts) inheritance = [item for sublist in inheritance for item in sublist] return [c for c in self._contracts.values() if c not in inher...
[ "def", "contracts_derived", "(", "self", ")", ":", "inheritance", "=", "(", "x", ".", "inheritance", "for", "x", "in", "self", ".", "contracts", ")", "inheritance", "=", "[", "item", "for", "sublist", "in", "inheritance", "for", "item", "in", "sublist", ...
64.6
0.009174
def _docker(self, method, *args, **kwargs): """wrapper for calling docker methods to be passed to ThreadPoolExecutor """ m = getattr(self.client, method) return m(*args, **kwargs)
[ "def", "_docker", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "m", "=", "getattr", "(", "self", ".", "client", ",", "method", ")", "return", "m", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
30.571429
0.009091
def write_newick_ott(out, ott, ott_id2children, root_ott_id, label_style, prune_flags, create_log_dict=False): """`out` is an output stream `ott` is an OTT instance used for translating ...
[ "def", "write_newick_ott", "(", "out", ",", "ott", ",", "ott_id2children", ",", "root_ott_id", ",", "label_style", ",", "prune_flags", ",", "create_log_dict", "=", "False", ")", ":", "# create to_prune_fsi_set a set of flag set indices to prune...", "if", "prune_flags", ...
41.508621
0.001826
def environment_variables_for_task(task): """ This will build a dict with all the environment variables that should be present when running a build or deployment. :param task: A dict of the json payload with information about the build task. :return: A dict of environment variables...
[ "def", "environment_variables_for_task", "(", "task", ")", ":", "env", "=", "{", "'CI'", ":", "'frigg'", ",", "'FRIGG'", ":", "'true'", ",", "'FRIGG_CI'", ":", "'true'", ",", "'GH_TOKEN'", ":", "task", "[", "'gh_token'", "]", ",", "'FRIGG_BUILD_BRANCH'", ":"...
30.428571
0.00091
def _histogram_fixed_binsize(a, start, width, n): """histogram_even(a, start, width, n) -> histogram Return an histogram where the first bin counts the number of lower outliers and the last bin the number of upper outliers. Works only with fixed width bins. :Stochastics: a : array Ar...
[ "def", "_histogram_fixed_binsize", "(", "a", ",", "start", ",", "width", ",", "n", ")", ":", "return", "flib", ".", "fixed_binsize", "(", "a", ",", "start", ",", "width", ",", "n", ")" ]
30.76
0.001261
def _add_section(self, section): """Adds a new section to the free section list, but before that and if section merge is enabled, tries to join the rectangle with all existing sections, if successful the resulting section is again merged with the remaining sections until the operation...
[ "def", "_add_section", "(", "self", ",", "section", ")", ":", "section", ".", "rid", "=", "0", "plen", "=", "0", "while", "self", ".", "_merge", "and", "self", ".", "_sections", "and", "plen", "!=", "len", "(", "self", ".", "_sections", ")", ":", "...
42.764706
0.009421
def datetime_from_timestamp(ts): """ Convert an :term:`HMC timestamp number <timestamp>` into a :class:`~py:datetime.datetime` object. The HMC timestamp number must be non-negative. This means the special timestamp value -1 cannot be represented as datetime and will cause ``ValueError`` to be r...
[ "def", "datetime_from_timestamp", "(", "ts", ")", ":", "# Note that in Python 2, \"None < 0\" is allowed and will return True,", "# therefore we do an extra check for None.", "if", "ts", "is", "None", ":", "raise", "ValueError", "(", "\"HMC timestamp value must not be None.\"", ")"...
34.293103
0.000489
def db_dp990(self, value=None): """ Corresponds to IDD Field `db_dp990` mean coincident drybulb temperature corresponding to Dew-point temperature corresponding to 90.0% annual cumulative frequency of occurrence (cold conditions) Args: value (float): value for IDD F...
[ "def", "db_dp990", "(", "self", ",", "value", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "try", ":", "value", "=", "float", "(", "value", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "'value {} need to be of type float...
36.826087
0.002301
def detect_encoding(self, path): """ For the implementation of encoding definitions in Python, look at: - http://www.python.org/dev/peps/pep-0263/ .. note:: code taken and adapted from ```jedi.common.source_to_unicode.detect_encoding``` """ with open(path, 'r...
[ "def", "detect_encoding", "(", "self", ",", "path", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "file", ":", "source", "=", "file", ".", "read", "(", ")", "# take care of line encodings (not in jedi)", "source", "=", "source", ".", "repl...
38.52
0.002026
def make_logger(scraper): """ Create two log handlers, one to output info-level ouput to the console, the other to store all logging in a JSON file which will later be used to generate reports. """ logger = logging.getLogger('') logger.setLevel(logging.DEBUG) requests_log = logging.getLogger("...
[ "def", "make_logger", "(", "scraper", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "''", ")", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "requests_log", "=", "logging", ".", "getLogger", "(", "\"requests\"", ")", "requests_...
35.740741
0.001009
def _normalize_tz(val): """Normalizes all valid ISO8601 time zone variants to the one python will parse. :val: a timestamp string without a timezone, or with a timezone in one of the ISO8601 accepted formats. """ match = _TZ_RE.match(val) if match: ts, tz = match.groups() if len(tz) == 5: ...
[ "def", "_normalize_tz", "(", "val", ")", ":", "match", "=", "_TZ_RE", ".", "match", "(", "val", ")", "if", "match", ":", "ts", ",", "tz", "=", "match", ".", "groups", "(", ")", "if", "len", "(", "tz", ")", "==", "5", ":", "# If the length of the tz...
35.807692
0.019874
def save_feature(self, cat, img, feature, data): """Saves a new feature.""" filename = self.path(cat, img, feature) mkdir(filename) savemat(filename, {'output':data})
[ "def", "save_feature", "(", "self", ",", "cat", ",", "img", ",", "feature", ",", "data", ")", ":", "filename", "=", "self", ".", "path", "(", "cat", ",", "img", ",", "feature", ")", "mkdir", "(", "filename", ")", "savemat", "(", "filename", ",", "{...
38.8
0.015152
def delete(name, *effects, **kwargs): """ Annotate a delete action to the model being defined. Should be delete(name, *effects, label=None, desc=None) but it is not supported by python < 3. @param name: item name unique for the model being defined. @type name: str or unicode @param effects: ...
[ "def", "delete", "(", "name", ",", "*", "effects", ",", "*", "*", "kwargs", ")", ":", "label", "=", "kwargs", ".", "pop", "(", "\"label\"", ",", "None", ")", "desc", "=", "kwargs", ".", "pop", "(", "\"desc\"", ",", "None", ")", "if", "kwargs", ":...
40.15
0.001217
def fenceloader(self): '''fence loader by sysid''' if not self.target_system in self.fenceloader_by_sysid: self.fenceloader_by_sysid[self.target_system] = mavwp.MAVFenceLoader() return self.fenceloader_by_sysid[self.target_system]
[ "def", "fenceloader", "(", "self", ")", ":", "if", "not", "self", ".", "target_system", "in", "self", ".", "fenceloader_by_sysid", ":", "self", ".", "fenceloader_by_sysid", "[", "self", ".", "target_system", "]", "=", "mavwp", ".", "MAVFenceLoader", "(", ")"...
52.4
0.015038
def get_priors(self): ''' Returns ------- pd.Series ''' priors = self.priors priors[~np.isfinite(priors)] = 0 priors += self.starting_count return priors
[ "def", "get_priors", "(", "self", ")", ":", "priors", "=", "self", ".", "priors", "priors", "[", "~", "np", ".", "isfinite", "(", "priors", ")", "]", "=", "0", "priors", "+=", "self", ".", "starting_count", "return", "priors" ]
16.2
0.064327
def get_ips(self): """ Get all IPAddress objects from the API. """ res = self.get_request('/ip_address') IPs = IPAddress._create_ip_address_objs(res['ip_addresses'], cloud_manager=self) return IPs
[ "def", "get_ips", "(", "self", ")", ":", "res", "=", "self", ".", "get_request", "(", "'/ip_address'", ")", "IPs", "=", "IPAddress", ".", "_create_ip_address_objs", "(", "res", "[", "'ip_addresses'", "]", ",", "cloud_manager", "=", "self", ")", "return", "...
34
0.012295
def to_string(self, format="smi", dialect=None, with_header=False, fragment_id=None, constraints=None): r""" Produce a string representation of the molecule. This function wraps and extends the functionality of OpenBabel (which is accessible through `to_pybel`). Many c...
[ "def", "to_string", "(", "self", ",", "format", "=", "\"smi\"", ",", "dialect", "=", "None", ",", "with_header", "=", "False", ",", "fragment_id", "=", "None", ",", "constraints", "=", "None", ")", ":", "s", "=", "self", ".", "to_pybel", "(", ")", "....
40.742424
0.000484
def unescape(msg, extra_format_dict={}): """Takes a girc-escaped message and returns a raw IRC message""" new_msg = '' extra_format_dict.update(format_dict) while len(msg): char = msg[0] msg = msg[1:] if char == escape_character: escape_key = msg[0] msg ...
[ "def", "unescape", "(", "msg", ",", "extra_format_dict", "=", "{", "}", ")", ":", "new_msg", "=", "''", "extra_format_dict", ".", "update", "(", "format_dict", ")", "while", "len", "(", "msg", ")", ":", "char", "=", "msg", "[", "0", "]", "msg", "=", ...
29.906977
0.000753
def tags(self): "Iterate over all tags yielding (name, function)" for bucket in self: for k,v in self[bucket].items(): yield k,v
[ "def", "tags", "(", "self", ")", ":", "for", "bucket", "in", "self", ":", "for", "k", ",", "v", "in", "self", "[", "bucket", "]", ".", "items", "(", ")", ":", "yield", "k", ",", "v" ]
33.6
0.023256
def numpy_array_to_gst_buffer(frames, chunk_size, num_samples, sample_rate): from gst import Buffer """ gstreamer buffer to numpy array conversion """ buf = Buffer(getbuffer(frames.astype("float32"))) # Set its timestamp and duration buf.timestamp = gst.util_uint64_scale(num_samples, gst.SECOND, sam...
[ "def", "numpy_array_to_gst_buffer", "(", "frames", ",", "chunk_size", ",", "num_samples", ",", "sample_rate", ")", ":", "from", "gst", "import", "Buffer", "buf", "=", "Buffer", "(", "getbuffer", "(", "frames", ".", "astype", "(", "\"float32\"", ")", ")", ")"...
51.875
0.00237
def set_miter_limit(self, limit): """Sets the current miter limit within the cairo context. If the current line join style is set to :obj:`MITER <LINE_JOIN_MITER>` (see :meth:`set_line_join`), the miter limit is used to determine whether the lines should be joined with a bevel i...
[ "def", "set_miter_limit", "(", "self", ",", "limit", ")", ":", "cairo", ".", "cairo_set_miter_limit", "(", "self", ".", "_pointer", ",", "limit", ")", "self", ".", "_check_status", "(", ")" ]
40.8125
0.001496
def decode(packet): """Decode a navdata packet.""" offset = 0 _ = struct.unpack_from('IIII', packet, offset) s = _[1] state = dict() state['fly'] = s & 1 # FLY MASK : (0) ardrone is landed, (1) ardrone is flying state['video'] = s >> 1 & 1 # VIDEO MASK :...
[ "def", "decode", "(", "packet", ")", ":", "offset", "=", "0", "_", "=", "struct", ".", "unpack_from", "(", "'IIII'", ",", "packet", ",", "offset", ")", "s", "=", "_", "[", "1", "]", "state", "=", "dict", "(", ")", "state", "[", "'fly'", "]", "=...
51.240506
0.022298
def task(func, *args, **kwargs): '''Composition of decorator functions for inherent self-documentation on task execution. On execution, each task prints out its name and its first docstring line. ''' prefix = '\n# ' tail = '\n' return fabric.api.task( print_full_name(color=magenta, ...
[ "def", "task", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "prefix", "=", "'\\n# '", "tail", "=", "'\\n'", "return", "fabric", ".", "api", ".", "task", "(", "print_full_name", "(", "color", "=", "magenta", ",", "prefix", "=", ...
30.857143
0.002247
def predict(self, X, lengths=None): """Predict labels/tags for samples X. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Feature matrix. lengths : array-like of integer, shape (n_sequences,), optional Lengths of sequ...
[ "def", "predict", "(", "self", ",", "X", ",", "lengths", "=", "None", ")", ":", "X", "=", "atleast2d_or_csr", "(", "X", ")", "scores", "=", "safe_sparse_dot", "(", "X", ",", "self", ".", "coef_", ".", "T", ")", "if", "hasattr", "(", "self", ",", ...
35.595238
0.001302
def outputSimple(self): """ Simple output mode """ out = [] errors = [] successfulResponses = \ len([True for rsp in self.results if rsp['success']]) out.append("INFO QUERIED {0}".format( len(self.serverList))) out.append("INFO S...
[ "def", "outputSimple", "(", "self", ")", ":", "out", "=", "[", "]", "errors", "=", "[", "]", "successfulResponses", "=", "len", "(", "[", "True", "for", "rsp", "in", "self", ".", "results", "if", "rsp", "[", "'success'", "]", "]", ")", "out", ".", ...
27.735294
0.002049
def generate_full_symmops(symmops, tol): """ Recursive algorithm to permute through all possible combinations of the initially supplied symmetry operations to arrive at a complete set of operations mapping a single atom to all other equivalent atoms in the point group. This assumes that the initial...
[ "def", "generate_full_symmops", "(", "symmops", ",", "tol", ")", ":", "# Uses an algorithm described in:", "# Gregory Butler. Fundamental Algorithms for Permutation Groups.", "# Lecture Notes in Computer Science (Book 559). Springer, 1991. page 15", "UNIT", "=", "np", ".", "eye", "("...
36.756757
0.000716
def do_inspect(self, arg): """ i(nspect) object Inspect an object """ if arg in self.curframe.f_locals: obj = self.curframe.f_locals[arg] elif arg in self.curframe.f_globals: obj = self.curframe.f_globals[arg] else: obj = WebPdb...
[ "def", "do_inspect", "(", "self", ",", "arg", ")", ":", "if", "arg", "in", "self", ".", "curframe", ".", "f_locals", ":", "obj", "=", "self", ".", "curframe", ".", "f_locals", "[", "arg", "]", "elif", "arg", "in", "self", ".", "curframe", ".", "f_g...
35.92
0.002169
def Policy(self, data=None, subset=None): """{dynamic_docstring}""" return self.factory.get_object(jssobjects.Policy, data, subset)
[ "def", "Policy", "(", "self", ",", "data", "=", "None", ",", "subset", "=", "None", ")", ":", "return", "self", ".", "factory", ".", "get_object", "(", "jssobjects", ".", "Policy", ",", "data", ",", "subset", ")" ]
48.333333
0.013605
def encode_multipart_formdata(self, fields, files, baseName, verbose=False): """ Fields is a sequence of (name, value) elements for regular form fields. Files is a sequence of (name, filename, value) elements for data to be uploaded as files Returns: (content_type, body) ready f...
[ "def", "encode_multipart_formdata", "(", "self", ",", "fields", ",", "files", ",", "baseName", ",", "verbose", "=", "False", ")", ":", "BOUNDARY", "=", "'----------ThIs_Is_tHe_bouNdaRY_$'", "CRLF", "=", "'\\r\\n'", "content_type", "=", "'multipart/form-data; boundary=...
46.321429
0.002266
def generate_prepared_request(method, url, headers, data, params, handlers): """Add handlers and prepare a Request. Parameters method (str) HTTP Method. (e.g. 'POST') headers (dict) Headers to send. data (JSON-formatted str) Body to attach to the requ...
[ "def", "generate_prepared_request", "(", "method", ",", "url", ",", "headers", ",", "data", ",", "params", ",", "handlers", ")", ":", "request", "=", "Request", "(", "method", "=", "method", ",", "url", "=", "url", ",", "headers", "=", "headers", ",", ...
26.794118
0.001059
def fail(self, message, param=None, ctx=None): """Helper method to fail with an invalid value message.""" raise BadParameter(message, ctx=ctx, param=param)
[ "def", "fail", "(", "self", ",", "message", ",", "param", "=", "None", ",", "ctx", "=", "None", ")", ":", "raise", "BadParameter", "(", "message", ",", "ctx", "=", "ctx", ",", "param", "=", "param", ")" ]
56.333333
0.011696
def likelihood3(args): """ %prog likelihood3 140_20.json 140_70.json Plot the likelihood surface and marginal distributions for two settings. """ from matplotlib import gridspec p = OptionParser(likelihood3.__doc__) opts, args, iopts = p.set_image_options(args, figsize="10x10", ...
[ "def", "likelihood3", "(", "args", ")", ":", "from", "matplotlib", "import", "gridspec", "p", "=", "OptionParser", "(", "likelihood3", ".", "__doc__", ")", "opts", ",", "args", ",", "iopts", "=", "p", ".", "set_image_options", "(", "args", ",", "figsize", ...
31.828571
0.001742
def parse_cli_args(): """ Parse the command line arguments """ # get config paths home_path = os.path.expanduser("~") xdg_home_path = os.environ.get("XDG_CONFIG_HOME", "{}/.config".format(home_path)) xdg_dirs_path = os.environ.get("XDG_CONFIG_DIRS", "/etc/xdg") # get i3status path t...
[ "def", "parse_cli_args", "(", ")", ":", "# get config paths", "home_path", "=", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "xdg_home_path", "=", "os", ".", "environ", ".", "get", "(", "\"XDG_CONFIG_HOME\"", ",", "\"{}/.config\"", ".", "format", ...
29.310185
0.000458
def translate(self, instr): """Return the SMT representation of a REIL instruction. """ try: translator = self._instr_translators[instr.mnemonic] return translator(*instr.operands) except Exception: logger.error("Failed to translate instruction: %s", ...
[ "def", "translate", "(", "self", ",", "instr", ")", ":", "try", ":", "translator", "=", "self", ".", "_instr_translators", "[", "instr", ".", "mnemonic", "]", "return", "translator", "(", "*", "instr", ".", "operands", ")", "except", "Exception", ":", "l...
31.818182
0.008333
def scale_to_vol(self, vol): """Scale cube to encompass a target volume.""" f = (vol / self.vol_cube) ** (1.0 / self.n) # linear factor self.expand *= f self.hside *= f self.vol_cube = vol
[ "def", "scale_to_vol", "(", "self", ",", "vol", ")", ":", "f", "=", "(", "vol", "/", "self", ".", "vol_cube", ")", "**", "(", "1.0", "/", "self", ".", "n", ")", "# linear factor", "self", ".", "expand", "*=", "f", "self", ".", "hside", "*=", "f",...
32
0.008696
def tokenize_akkadian_words(line): """ Operates on a single line of text, returns all words in the line as a tuple in a list. input: "1. isz-pur-ram a-na" output: [("isz-pur-ram", "akkadian"), ("a-na", "akkadian")] :param: line: text string :return: list of tuples: (word, language) """...
[ "def", "tokenize_akkadian_words", "(", "line", ")", ":", "beginning_underscore", "=", "\"_[^_]+(?!_)$\"", "# only match a string if it has a beginning underscore anywhere", "ending_underscore", "=", "\"^(?<!_)[^_]+_\"", "# only match a string if it has an ending underscore anywhere", "tw...
39.644444
0.000547
def buffer(self, buffer): """ Changes both BBox dimensions (width and height) by a percentage of size of each dimension. If number is negative, the size will decrease. Returns a new instance of BBox object. :param buffer: A percentage of BBox size change :type buffer: float :ret...
[ "def", "buffer", "(", "self", ",", "buffer", ")", ":", "if", "buffer", "<", "-", "1", ":", "raise", "ValueError", "(", "'Cannot reduce the bounding box to nothing, buffer must be >= -1.0'", ")", "ratio", "=", "1", "+", "buffer", "mid_x", ",", "mid_y", "=", "se...
51.2
0.008951