text
stringlengths
75
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
0.18
texts
list
scores
list
num_lines
int64
3
2.77k
avg_score
float64
0
0.37
def from_fortran_file(cls, fortran_file: str, tmpdir: str = "."): """Builds GrFN object from a Fortran program.""" stem = Path(fortran_file).stem if tmpdir == "." and "/" in fortran_file: tmpdir = Path(fortran_file).parent preprocessed_fortran_file = f"{tmpdir}/{stem}_preproc...
[ "def", "from_fortran_file", "(", "cls", ",", "fortran_file", ":", "str", ",", "tmpdir", ":", "str", "=", "\".\"", ")", ":", "stem", "=", "Path", "(", "fortran_file", ")", ".", "stem", "if", "tmpdir", "==", "\".\"", "and", "\"/\"", "in", "fortran_file", ...
38.055556
0.001423
[ "def from_fortran_file(cls, fortran_file: str, tmpdir: str = \".\"):\n", " \"\"\"Builds GrFN object from a Fortran program.\"\"\"\n", " stem = Path(fortran_file).stem\n", " if tmpdir == \".\" and \"/\" in fortran_file:\n", " tmpdir = Path(fortran_file).parent\n", " p...
[ 0, 0.017543859649122806, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0625 ]
36
0.002223
def get_serializer(context): """Returns a serializer for a given context""" cluster_config = context.get_cluster_config() serializer_clsname = cluster_config.get(constants.TOPOLOGY_SERIALIZER_CLASSNAME, None) if serializer_clsname is None: return PythonSerializer() else: try: top...
[ "def", "get_serializer", "(", "context", ")", ":", "cluster_config", "=", "context", ".", "get_cluster_config", "(", ")", "serializer_clsname", "=", "cluster_config", ".", "get", "(", "constants", ".", "TOPOLOGY_SERIALIZER_CLASSNAME", ",", "None", ")", "if", "seri...
46
0.009321
[ "def get_serializer(context):\n", " \"\"\"Returns a serializer for a given context\"\"\"\n", " cluster_config = context.get_cluster_config()\n", " serializer_clsname = cluster_config.get(constants.TOPOLOGY_SERIALIZER_CLASSNAME, None)\n", " if serializer_clsname is None:\n", " return Pytho...
[ 0, 0, 0, 0.01098901098901099, 0, 0.03125, 0, 0.09090909090909091, 0, 0, 0.010869565217391304, 0, 0, 0.034482758620689655, 0.01, 0.017241379310344827 ]
16
0.012859
def reset_parameter(**kwargs): """Create a callback that resets the parameter after the first iteration. Note ---- The initial parameter will still take in-effect on first iteration. Parameters ---------- **kwargs : value should be list or function List of parameters for each boost...
[ "def", "reset_parameter", "(", "*", "*", "kwargs", ")", ":", "def", "_callback", "(", "env", ")", ":", "new_parameters", "=", "{", "}", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "if", "key", "in", "[", "'num_class'", ...
41.023256
0.001661
[ "def reset_parameter(**kwargs):\n", " \"\"\"Create a callback that resets the parameter after the first iteration.\n", "\n", " Note\n", " ----\n", " The initial parameter will still take in-effect on first iteration.\n", "\n", " Parameters\n", " ----------\n", " **kwargs : val...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.011363636363636364, 0, 0, 0.010869565217391304, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05 ]
43
0.00168
def _filter(self, filename): """ return 'true' if filename doesn't match name_filter regex and should be filtered out of the list. @param filename: @return: """ return self.name_filter is not None and re.search(self.name_filter, filename) is None
[ "def", "_filter", "(", "self", ",", "filename", ")", ":", "return", "self", ".", "name_filter", "is", "not", "None", "and", "re", ".", "search", "(", "self", ".", "name_filter", ",", "filename", ")", "is", "None" ]
41.142857
0.013605
[ "def _filter(self, filename):\n", " \"\"\"\n", " return 'true' if filename doesn't match name_filter regex and should be filtered out of the list.\n", " @param filename:\n", " @return:\n", " \"\"\"\n", " return self.name_filter is not None and re.search(self.nam...
[ 0, 0.08333333333333333, 0.009433962264150943, 0, 0, 0, 0.021505376344086023 ]
7
0.016325
def load_source(source): """ Common entry point for loading some form of raw swagger schema. Supports: - python object (dictionary-like) - path to yaml file - path to json file - file object (json or yaml). - json string. - yaml string. """ if isinsta...
[ "def", "load_source", "(", "source", ")", ":", "if", "isinstance", "(", "source", ",", "collections", ".", "Mapping", ")", ":", "return", "deepcopy", "(", "source", ")", "elif", "hasattr", "(", "source", ",", "'read'", ")", "and", "callable", "(", "sourc...
30.978261
0.00068
[ "def load_source(source):\n", " \"\"\"\n", " Common entry point for loading some form of raw swagger schema.\n", "\n", " Supports:\n", " - python object (dictionary-like)\n", " - path to yaml file\n", " - path to json file\n", " - file object (json or yaml).\n", ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2 ]
46
0.004348
def metric(self, slug, num=1, category=None, expire=None, date=None): """Records a metric, creating it if it doesn't exist or incrementing it if it does. All metrics are prefixed with 'm', and automatically aggregate for Seconds, Minutes, Hours, Day, Week, Month, and Year. Parameters: ...
[ "def", "metric", "(", "self", ",", "slug", ",", "num", "=", "1", ",", "category", "=", "None", ",", "expire", "=", "None", ",", "date", "=", "None", ")", ":", "# Add the slug to the set of metric slugs", "self", ".", "r", ".", "sadd", "(", "self", ".",...
42.886364
0.001036
[ "def metric(self, slug, num=1, category=None, expire=None, date=None):\n", " \"\"\"Records a metric, creating it if it doesn't exist or incrementing it\n", " if it does. All metrics are prefixed with 'm', and automatically\n", " aggregate for Seconds, Minutes, Hours, Day, Week, Month, and...
[ 0, 0.0125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.045454545454545456 ]
44
0.001317
def weather_from_dictionary(d): """ Builds a *Weather* object out of a data dictionary. Only certain properties of the dictionary are used: if these properties are not found or cannot be read, an error is issued. :param d: a data dictionary :type d: dict :returns: a *Weather* instance :...
[ "def", "weather_from_dictionary", "(", "d", ")", ":", "# -- times", "if", "'dt'", "in", "d", ":", "reference_time", "=", "d", "[", "'dt'", "]", "elif", "'dt'", "in", "d", "[", "'last'", "]", ":", "reference_time", "=", "d", "[", "'last'", "]", "[", "...
31.874346
0.000796
[ "def weather_from_dictionary(d):\n", " \"\"\"\n", " Builds a *Weather* object out of a data dictionary. Only certain\n", " properties of the dictionary are used: if these properties are not\n", " found or cannot be read, an error is issued.\n", "\n", " :param d: a data dictionary\n", " ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
191
0.000369
def run(self, agent_host): """run the agent on the world""" total_reward = 0 current_r = 0 tol = 0.01 self.prev_s = None self.prev_a = None # wait for a valid observation world_state = agent_host.peekWorldState() while world_stat...
[ "def", "run", "(", "self", ",", "agent_host", ")", ":", "total_reward", "=", "0", "current_r", "=", "0", "tol", "=", "0.01", "self", ".", "prev_s", "=", "None", "self", ".", "prev_a", "=", "None", "# wait for a valid observation", "world_state", "=", "agen...
47.090909
0.014337
[ "def run(self, agent_host):\n", " \"\"\"run the agent on the world\"\"\"\n", "\n", " total_reward = 0\n", " current_r = 0\n", " tol = 0.01\n", " \n", " self.prev_s = None\n", " self.prev_a = None\n", " \n", " # wait for a valid obser...
[ 0, 0.024390243902439025, 0, 0, 0, 0, 0.1111111111111111, 0, 0, 0.1111111111111111, 0, 0, 0.0196078431372549, 0, 0, 0, 0.008264462809917356, 0, 0, 0, 0, 0, 0, 0.022222222222222223, 0.07692307692307693, 0, 0.1111111111111111, 0.03225806451612903, 0, 0, 0.056...
132
0.017681
def autodiscover(module_name=None): """ Autodiscover INSTALLED_APPS perms.py modules and fail silently when not present. This forces an import on them to register any permissions bits they may want. """ from django.utils.module_loading import module_has_submodule from permission.compat impor...
[ "def", "autodiscover", "(", "module_name", "=", "None", ")", ":", "from", "django", ".", "utils", ".", "module_loading", "import", "module_has_submodule", "from", "permission", ".", "compat", "import", "import_module", "from", "permission", ".", "conf", "import", ...
41
0.001907
[ "def autodiscover(module_name=None):\n", " \"\"\"\n", " Autodiscover INSTALLED_APPS perms.py modules and fail silently when not\n", " present. This forces an import on them to register any permissions bits\n", " they may want.\n", " \"\"\"\n", " from django.utils.module_loading import ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0625, 0, 0, 0, 0, 0.047619047619047616 ]
25
0.004405
def json2py(json_obj): """ Converts the inputted JSON object to a python value. :param json_obj | <variant> """ for key, value in json_obj.items(): if type(value) not in (str, unicode): continue # restore a datetime if re.match('^\d{4}-\d{2}-\d{2} \d{2}...
[ "def", "json2py", "(", "json_obj", ")", ":", "for", "key", ",", "value", "in", "json_obj", ".", "items", "(", ")", ":", "if", "type", "(", "value", ")", "not", "in", "(", "str", ",", "unicode", ")", ":", "continue", "# restore a datetime", "if", "re"...
33.424242
0.014097
[ "def json2py(json_obj):\n", " \"\"\"\n", " Converts the inputted JSON object to a python value.\n", " \n", " :param json_obj | <variant>\n", " \"\"\"\n", " for key, value in json_obj.items():\n", " if type(value) not in (str, unicode):\n", " continue\n", "\...
[ 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.0958904109589041, 0, 0.05660377358490566, 0, 0, 0.07017543859649122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05263157894736842 ]
33
0.014403
def join_multiline_pairs(source, pair="()"): """ Finds and removes newlines in multiline matching pairs of characters in *source*. By default it joins parens () but it will join any two characters given via the *pair* variable. .. note:: Doesn't remove extraneous whitespace that ends ...
[ "def", "join_multiline_pairs", "(", "source", ",", "pair", "=", "\"()\"", ")", ":", "opener", "=", "pair", "[", "0", "]", "closer", "=", "pair", "[", "1", "]", "io_obj", "=", "io", ".", "StringIO", "(", "source", ")", "out_tokens", "=", "[", "]", "...
28.613636
0.001536
[ "def join_multiline_pairs(source, pair=\"()\"):\n", " \"\"\"\n", " Finds and removes newlines in multiline matching pairs of characters in\n", " *source*.\n", "\n", " By default it joins parens () but it will join any two characters given via\n", " the *pair* variable.\n", "\n", " ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.011494252873563218, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.022222222222222223 ]
44
0.000766
def do_watch(self, params): """ \x1b[1mNAME\x1b[0m watch - Recursively watch for all changes under a path. \x1b[1mSYNOPSIS\x1b[0m watch <start|stop|stats> <path> [options] \x1b[1mDESCRIPTION\x1b[0m watch start <path> [debug] [depth] with debug=true, print watches as they fire....
[ "def", "do_watch", "(", "self", ",", "params", ")", ":", "wm", "=", "get_watch_manager", "(", "self", ".", "_zk", ")", "if", "params", ".", "command", "==", "\"start\"", ":", "debug", "=", "to_bool", "(", "params", ".", "debug", ")", "children", "=", ...
31.254902
0.001217
[ "def do_watch(self, params):\n", " \"\"\"\n", "\\x1b[1mNAME\\x1b[0m\n", " watch - Recursively watch for all changes under a path.\n", "\n", "\\x1b[1mSYNOPSIS\\x1b[0m\n", " watch <start|stop|stats> <path> [options]\n", "\n", "\\x1b[1mDESCRIPTION\\x1b[0m\n", " watch start...
[ 0, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0136986301369863 ]
51
0.001903
def from_archive(cls, archive: Archive, predictor_name: str = None) -> 'Predictor': """ Instantiate a :class:`Predictor` from an :class:`~allennlp.models.archival.Archive`; that is, from the result of training a model. Optionally specify which `Predictor` subclass; otherwise, the default...
[ "def", "from_archive", "(", "cls", ",", "archive", ":", "Archive", ",", "predictor_name", ":", "str", "=", "None", ")", "->", "'Predictor'", ":", "# Duplicate the config so that the config inside the archive doesn't get consumed", "config", "=", "archive", ".", "config"...
48.521739
0.008787
[ "def from_archive(cls, archive: Archive, predictor_name: str = None) -> 'Predictor':\n", " \"\"\"\n", " Instantiate a :class:`Predictor` from an :class:`~allennlp.models.archival.Archive`;\n", " that is, from the result of training a model. Optionally specify which `Predictor`\n", " ...
[ 0.011904761904761904, 0.08333333333333333, 0.010752688172043012, 0.01098901098901099, 0, 0, 0.011111111111111112, 0, 0, 0, 0, 0.018867924528301886, 0.020618556701030927, 0.011904761904761904, 0, 0, 0, 0, 0, 0, 0, 0, 0.014084507042253521 ]
23
0.008416
def block(context_name, parent_block_func, view_func=None): """A decorator that is used for inserting the decorated block function in the block template hierarchy. The :func:`block` decorator accepts the following arguments: :param context_name: key in the `g.blocks` dictionary in which the result ...
[ "def", "block", "(", "context_name", ",", "parent_block_func", ",", "view_func", "=", "None", ")", ":", "def", "decorator", "(", "block_func", ")", ":", "block", "=", "Block", "(", "block_func", ",", "view_func", ")", "parent_block", "=", "Block", ".", "bl...
53.307692
0.000709
[ "def block(context_name, parent_block_func, view_func=None):\n", " \"\"\"A decorator that is used for inserting the decorated block function in\n", " the block template hierarchy.\n", "\n", " The :func:`block` decorator accepts the following arguments:\n", "\n", " :param context_name: key in...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05 ]
26
0.001923
def keys(self): """Create an ordered dict of the names and values of key fields.""" keys = OrderedDict() def order_key(_): (k, v) = _ cache_key = getattr(type(self), k) return cache_key.order items = [(k, getattr(type(self), k)) for k in...
[ "def", "keys", "(", "self", ")", ":", "keys", "=", "OrderedDict", "(", ")", "def", "order_key", "(", "_", ")", ":", "(", "k", ",", "v", ")", "=", "_", "cache_key", "=", "getattr", "(", "type", "(", "self", ")", ",", "k", ")", "return", "cache_k...
25.52381
0.01259
[ "def keys(self):\n", " \"\"\"Create an ordered dict of the names and values of key fields.\"\"\"\n", "\n", " keys = OrderedDict()\n", "\n", " def order_key(_):\n", " (k, v) = _\n", " cache_key = getattr(type(self), k)\n", " return cache_key.order...
[ 0, 0.013157894736842105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03225806451612903, 0.1, 0, 0.047619047619047616, 0.029411764705882353, 0.1, 0, 0, 0, 0.05263157894736842 ]
21
0.017861
def update(self, points, pointvol=0., vol_dec=0.5, vol_check=2., rstate=None, bootstrap=0, pool=None, mc_integrate=False): """ Update the set of ellipsoids to bound the collection of points. Parameters ---------- points : `~numpy.ndarray` with shape (npoints, ndim...
[ "def", "update", "(", "self", ",", "points", ",", "pointvol", "=", "0.", ",", "vol_dec", "=", "0.5", ",", "vol_check", "=", "2.", ",", "rstate", "=", "None", ",", "bootstrap", "=", "0", ",", "pool", "=", "None", ",", "mc_integrate", "=", "False", "...
39.07619
0.000713
[ "def update(self, points, pointvol=0., vol_dec=0.5, vol_check=2.,\n", " rstate=None, bootstrap=0, pool=None, mc_integrate=False):\n", " \"\"\"\n", " Update the set of ellipsoids to bound the collection of points.\n", "\n", " Parameters\n", " ----------\n", " ...
[ 0, 0.0136986301369863, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
105
0.001049
def get(self, name, return_json=False, quiet=False): '''get is a list for a single instance. It is assumed to be running, and we need to look up the PID, etc. ''' from spython.utils import check_install check_install() # Ensure compatible for singularity prior to 3.0, and after 3.0 subgr...
[ "def", "get", "(", "self", ",", "name", ",", "return_json", "=", "False", ",", "quiet", "=", "False", ")", ":", "from", "spython", ".", "utils", "import", "check_install", "check_install", "(", ")", "# Ensure compatible for singularity prior to 3.0, and after 3.0", ...
28.473684
0.002382
[ "def get(self, name, return_json=False, quiet=False):\n", " '''get is a list for a single instance. It is assumed to be running,\n", " and we need to look up the PID, etc.\n", " '''\n", " from spython.utils import check_install\n", " check_install()\n", "\n", " # Ensure compatible...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03508771929824561, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1111111111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0...
57
0.003442
def removed(name, updates=None): ''' Ensure Microsoft Updates are uninstalled. Args: name (str): The identifier of a single update to uninstall. updates (list): A list of identifiers for updates to be removed. Overrides ``name``. Default is None. ....
[ "def", "removed", "(", "name", ",", "updates", "=", "None", ")", ":", "if", "isinstance", "(", "updates", ",", "six", ".", "string_types", ")", ":", "updates", "=", "[", "updates", "]", "if", "not", "updates", ":", "updates", "=", "name", "ret", "=",...
28.52459
0.000833
[ "def removed(name, updates=None):\n", " '''\n", " Ensure Microsoft Updates are uninstalled.\n", "\n", " Args:\n", "\n", " name (str):\n", " The identifier of a single update to uninstall.\n", "\n", " updates (list):\n", " A list of identifiers for upd...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.012345679012345678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.008130081300813009, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
122
0.000753
def alter_edge(self, from_index, to_index, to_jimage=None, new_weight=None, new_edge_properties=None): """ Alters either the weight or the edge_properties of an edge in the StructureGraph. :param from_index: int :param to_index: int :param to_jimage: t...
[ "def", "alter_edge", "(", "self", ",", "from_index", ",", "to_index", ",", "to_jimage", "=", "None", ",", "new_weight", "=", "None", ",", "new_edge_properties", "=", "None", ")", ":", "existing_edges", "=", "self", ".", "graph", ".", "get_edge_data", "(", ...
40.5
0.002296
[ "def alter_edge(self, from_index, to_index, to_jimage=None,\n", " new_weight=None, new_edge_properties=None):\n", " \"\"\"\n", " Alters either the weight or the edge_properties of\n", " an edge in the StructureGraph.\n", "\n", " :param from_index: int\n", ...
[ 0, 0.015873015873015872, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02127659574468085 ]
42
0.002869
def render_registration(self): ''' Render pinned points on video frame as red rectangle. ''' surface = self.get_surface() if self.canvas is None or self.df_canvas_corners.shape[0] == 0: return surface corners = self.df_canvas_corners.copy() corners['w...
[ "def", "render_registration", "(", "self", ")", ":", "surface", "=", "self", ".", "get_surface", "(", ")", "if", "self", ".", "canvas", "is", "None", "or", "self", ".", "df_canvas_corners", ".", "shape", "[", "0", "]", "==", "0", ":", "return", "surfac...
34.24
0.002273
[ "def render_registration(self):\n", " '''\n", " Render pinned points on video frame as red rectangle.\n", " '''\n", " surface = self.get_surface()\n", " if self.canvas is None or self.df_canvas_corners.shape[0] == 0:\n", " return surface\n", "\n", " ...
[ 0, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.045454545454545456 ]
25
0.005152
def completed_number(prefix, length): """ 'prefix' is the start of the CC number as a string, any number of digits. 'length' is the length of the CC number to generate. Typically 13 or 16 """ ccnumber = prefix # generate digits while len(ccnumber) < (length - 1): digit = random.choic...
[ "def", "completed_number", "(", "prefix", ",", "length", ")", ":", "ccnumber", "=", "prefix", "# generate digits", "while", "len", "(", "ccnumber", ")", "<", "(", "length", "-", "1", ")", ":", "digit", "=", "random", ".", "choice", "(", "[", "'0'", ","...
32.25
0.009677
[ "def completed_number(prefix, length):\n", " \"\"\"\n", " 'prefix' is the start of the CC number as a string, any number of digits.\n", " 'length' is the length of the CC number to generate. Typically 13 or 16\n", " \"\"\"\n", " ccnumber = prefix\n", " # generate digits\n", " whil...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0.012048192771084338, 0, 0.047619047619047616, 0, 0, 0, 0, 0, 0, 0.0425531914893617, 0, 0, 0, 0, 0.04, 0, 0, 0, 0.045454545454545456, 0.03571428571428571 ]
28
0.007978
def get_field_info(wrapper,entity_type): 'type: wrapper :atws.Wrapper' fields = wrapper.new('GetFieldInfo') fields.psObjectType = entity_type return wrapper.GetFieldInfo(fields)
[ "def", "get_field_info", "(", "wrapper", ",", "entity_type", ")", ":", "fields", "=", "wrapper", ".", "new", "(", "'GetFieldInfo'", ")", "fields", ".", "psObjectType", "=", "entity_type", "return", "wrapper", ".", "GetFieldInfo", "(", "fields", ")" ]
37.8
0.010363
[ "def get_field_info(wrapper,entity_type):\n", " 'type: wrapper :atws.Wrapper'\n", " fields = wrapper.new('GetFieldInfo')\n", " fields.psObjectType = entity_type\n", " return wrapper.GetFieldInfo(fields)" ]
[ 0.024390243902439025, 0, 0, 0, 0.02564102564102564 ]
5
0.010006
def graph_from_seeds(seeds, cell_source): """ This creates/updates a networkx graph from a list of cells. The graph is created when the cell_source is an instance of ExcelCompiler The graph is updated when the cell_source is an instance of Spreadsheet """ # when called from Spreadsheet instanc...
[ "def", "graph_from_seeds", "(", "seeds", ",", "cell_source", ")", ":", "# when called from Spreadsheet instance, use the Spreadsheet cellmap and graph", "if", "hasattr", "(", "cell_source", ",", "'G'", ")", ":", "# ~ cell_source is a Spreadsheet", "cellmap", "=", "cell_source...
43.918552
0.008966
[ "def graph_from_seeds(seeds, cell_source):\n", " \"\"\"\n", " This creates/updates a networkx graph from a list of cells.\n", "\n", " The graph is created when the cell_source is an instance of ExcelCompiler\n", " The graph is updated when the cell_source is an instance of Spreadsheet\n", " ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0.012048192771084338, 0.014925373134328358, 0, 0, 0, 0, 0, 0, 0.011627906976744186, 0.022222222222222223, 0.017543859649122806, 0, 0, 0, 0, 0.02040816326530612, 0, 0, 0, 0.023255813953488372, 0, 0, 0, 0, 0, 0, 0, 0.0138888...
221
0.004621
def port(alias_name, default=None, allow_none=False): """Get the port from the docker link alias or return the default. Args: alias_name: The docker link alias default: The default value if the link isn't available allow_none: If the return value can be `None` (i.e. optional) Examp...
[ "def", "port", "(", "alias_name", ",", "default", "=", "None", ",", "allow_none", "=", "False", ")", ":", "warnings", ".", "warn", "(", "'Will be removed in v1.0'", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", "try", ":", "return", "int", "...
34.478261
0.002454
[ "def port(alias_name, default=None, allow_none=False):\n", " \"\"\"Get the port from the docker link alias or return the default.\n", "\n", " Args:\n", " alias_name: The docker link alias\n", " default: The default value if the link isn't available\n", " allow_none: If the ret...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.011627906976744186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.047619047619047616 ]
23
0.002576
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ assert isinstance(value, six.integer_types) return str(value).encode("utf_8")
[ "def", "value_to_db", "(", "self", ",", "value", ")", ":", "assert", "isinstance", "(", "value", ",", "six", ".", "integer_types", ")", "return", "str", "(", "value", ")", ".", "encode", "(", "\"utf_8\"", ")" ]
50.5
0.014634
[ "def value_to_db(self, value):\n", " \"\"\" Returns field's single value prepared for saving into a database. \"\"\"\n", " assert isinstance(value, six.integer_types)\n", " return str(value).encode(\"utf_8\")" ]
[ 0, 0.024390243902439025, 0, 0.024390243902439025 ]
4
0.012195
def get(self, sid): """ Constructs a OriginationUrlContext :param sid: The unique string that identifies the resource :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext ...
[ "def", "get", "(", "self", ",", "sid", ")", ":", "return", "OriginationUrlContext", "(", "self", ".", "_version", ",", "trunk_sid", "=", "self", ".", "_solution", "[", "'trunk_sid'", "]", ",", "sid", "=", "sid", ",", ")" ]
41.8
0.01171
[ "def get(self, sid):\n", " \"\"\"\n", " Constructs a OriginationUrlContext\n", "\n", " :param sid: The unique string that identifies the resource\n", "\n", " :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext\n", " :rtype: twilio.rest.trunk...
[ 0, 0.08333333333333333, 0, 0, 0, 0, 0.011627906976744186, 0.011904761904761904, 0, 0.019801980198019802 ]
10
0.012667
def from_header(self, header): """Generate a SpanContext object using the trace context header. The value of enabled parsed from header is int. Need to convert to bool. :type header: str :param header: Trace context header which was extracted from the HTTP ...
[ "def", "from_header", "(", "self", ",", "header", ")", ":", "if", "header", "is", "None", ":", "return", "SpanContext", "(", ")", "try", ":", "match", "=", "re", ".", "search", "(", "_TRACE_CONTEXT_HEADER_RE", ",", "header", ")", "except", "TypeError", "...
33.690476
0.001374
[ "def from_header(self, header):\n", " \"\"\"Generate a SpanContext object using the trace context header.\n", " The value of enabled parsed from header is int. Need to convert to\n", " bool.\n", "\n", " :type header: str\n", " :param header: Trace context header which ...
[ 0, 0.0136986301369863, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03125 ]
42
0.00107
def apply_multicolor_transit(self,band,depth): """ Applies constraint corresponding to measuring transit in different band This is not implemented yet. """ if '{} band transit'.format(band) not in self.constraints: self.constraints.append('{} band transit'.format(ban...
[ "def", "apply_multicolor_transit", "(", "self", ",", "band", ",", "depth", ")", ":", "if", "'{} band transit'", ".", "format", "(", "band", ")", "not", "in", "self", ".", "constraints", ":", "self", ".", "constraints", ".", "append", "(", "'{} band transit'"...
40
0.012225
[ "def apply_multicolor_transit(self,band,depth):\n", " \"\"\"\n", " Applies constraint corresponding to measuring transit in different band\n", "\n", " This is not implemented yet.\n", " \"\"\"\n", " if '{} band transit'.format(band) not in self.constraints:\n", " ...
[ 0.0425531914893617, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0.038461538461538464 ]
10
0.016435
def add_view( self, baseview, name, href="", icon="", label="", category="", category_icon="", category_label="", ): """ Add your views associated with menus using this method. :param baseview: A BaseView ty...
[ "def", "add_view", "(", "self", ",", "baseview", ",", "name", ",", "href", "=", "\"\"", ",", "icon", "=", "\"\"", ",", "label", "=", "\"\"", ",", "category", "=", "\"\"", ",", "category_icon", "=", "\"\"", ",", "category_label", "=", "\"\"", ",", ")"...
34.858824
0.001969
[ "def add_view(\n", " self,\n", " baseview,\n", " name,\n", " href=\"\",\n", " icon=\"\",\n", " label=\"\",\n", " category=\"\",\n", " category_icon=\"\",\n", " category_label=\"\",\n", " ):\n", " \"\"\"\n", " Add...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.14285714285714285, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.011627906976744186, 0, 0, 0, 0, 0, 0, 0, 0...
85
0.00358
def do_some_work( self, work_dict): """do_some_work :param work_dict: dictionary for key/values """ label = "do_some_work" log.info(("task - {} - start " "work_dict={}") .format(label, work_dict)) ret_data = { "job_resul...
[ "def", "do_some_work", "(", "self", ",", "work_dict", ")", ":", "label", "=", "\"do_some_work\"", "log", ".", "info", "(", "(", "\"task - {} - start \"", "\"work_dict={}\"", ")", ".", "format", "(", "label", ",", "work_dict", ")", ")", "ret_data", "=", "{", ...
20.192308
0.001818
[ "def do_some_work(\n", " self,\n", " work_dict):\n", " \"\"\"do_some_work\n", "\n", " :param work_dict: dictionary for key/values\n", " \"\"\"\n", "\n", " label = \"do_some_work\"\n", "\n", " log.info((\"task - {} - start \"\n", " \"work_dict={}\")\n",...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05263157894736842 ]
26
0.002024
def active_vectors_info(self): """Return the active scalar's field and name: [field, name]""" if not hasattr(self, '_active_vectors_info'): self._active_vectors_info = [POINT_DATA_FIELD, None] # field and name _, name = self._active_vectors_info # rare error where scalar nam...
[ "def", "active_vectors_info", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_active_vectors_info'", ")", ":", "self", ".", "_active_vectors_info", "=", "[", "POINT_DATA_FIELD", ",", "None", "]", "# field and name", "_", ",", "name", "=", ...
40.666667
0.008016
[ "def active_vectors_info(self):\n", " \"\"\"Return the active scalar's field and name: [field, name]\"\"\"\n", " if not hasattr(self, '_active_vectors_info'):\n", " self._active_vectors_info = [POINT_DATA_FIELD, None] # field and name\n", " _, name = self._active_vectors_info...
[ 0, 0.014084507042253521, 0, 0.024390243902439025, 0, 0, 0, 0, 0, 0, 0, 0.025 ]
12
0.00529
def prepare_lineage(func): """ Prepares the lineage inlets and outlets. Inlets can be: * "auto" -> picks up any outlets from direct upstream tasks that have outlets defined, as such that if A -> B -> C and B does not have outlets but A does, these are provided as inlets. * "list of task_ids" -> p...
[ "def", "prepare_lineage", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "context", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Preparing lineage inlets and ...
39.75
0.002192
[ "def prepare_lineage(func):\n", " \"\"\"\n", " Prepares the lineage inlets and outlets. Inlets can be:\n", "\n", " * \"auto\" -> picks up any outlets from direct upstream tasks that have outlets defined, as such that\n", " if A -> B -> C and B does not have outlets but A does, these are prov...
[ 0, 0, 0, 0, 0.009615384615384616, 0.01098901098901099, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.012345679012345678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.012345679012345678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
56
0.001801
def pixel_scale_angle_at_skycoord(skycoord, wcs, offset=1. * u.arcsec): """ Calculate the pixel scale and WCS rotation angle at the position of a SkyCoord coordinate. Parameters ---------- skycoord : `~astropy.coordinates.SkyCoord` The SkyCoord coordinate. wcs : `~astropy.wcs.WCS` ...
[ "def", "pixel_scale_angle_at_skycoord", "(", "skycoord", ",", "wcs", ",", "offset", "=", "1.", "*", "u", ".", "arcsec", ")", ":", "# We take a point directly \"above\" (in latitude) the input position", "# and convert it to pixel coordinates, then we use the pixel deltas", "# bet...
35.981481
0.000501
[ "def pixel_scale_angle_at_skycoord(skycoord, wcs, offset=1. * u.arcsec):\n", " \"\"\"\n", " Calculate the pixel scale and WCS rotation angle at the position of\n", " a SkyCoord coordinate.\n", "\n", " Parameters\n", " ----------\n", " skycoord : `~astropy.coordinates.SkyCoord`\n", ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.043478260869565216 ]
54
0.000805
def som_simulate(som_pointer, pattern): """! @brief Processes input pattern (no learining) and returns index of neuron-winner. @details Using index of neuron winner catched object can be obtained using property capture_objects. @param[in] som_pointer (c_pointer): pointer to object of self-orga...
[ "def", "som_simulate", "(", "som_pointer", ",", "pattern", ")", ":", "pointer_data", "=", "package_builder", "(", "pattern", ",", "c_double", ")", ".", "create", "(", ")", "ccore", "=", "ccore_library", ".", "get", "(", ")", "ccore", ".", "som_simulate", "...
37.470588
0.013783
[ "def som_simulate(som_pointer, pattern):\r\n", " \"\"\"!\r\n", " @brief Processes input pattern (no learining) and returns index of neuron-winner.\r\n", " @details Using index of neuron winner catched object can be obtained using property capture_objects.\r\n", " \r\n", " @param[in] som_poi...
[ 0, 0, 0.011494252873563218, 0.009433962264150943, 0.16666666666666666, 0.012195121951219513, 0, 0.16666666666666666, 0, 0.16666666666666666, 0, 0.16666666666666666, 0, 0.16666666666666666, 0, 0, 0.017857142857142856 ]
17
0.052018
def bb_pad_collate(samples:BatchSamples, pad_idx:int=0) -> Tuple[FloatTensor, Tuple[LongTensor, LongTensor]]: "Function that collect `samples` of labelled bboxes and adds padding with `pad_idx`." if isinstance(samples[0][1], int): return data_collate(samples) max_len = max([len(s[1].data[1]) for s in sample...
[ "def", "bb_pad_collate", "(", "samples", ":", "BatchSamples", ",", "pad_idx", ":", "int", "=", "0", ")", "->", "Tuple", "[", "FloatTensor", ",", "Tuple", "[", "LongTensor", ",", "LongTensor", "]", "]", ":", "if", "isinstance", "(", "samples", "[", "0", ...
51.071429
0.017857
[ "def bb_pad_collate(samples:BatchSamples, pad_idx:int=0) -> Tuple[FloatTensor, Tuple[LongTensor, LongTensor]]:\n", " \"Function that collect `samples` of labelled bboxes and adds padding with `pad_idx`.\"\n", " if isinstance(samples[0][1], int): return data_collate(samples)\n", " max_len = max([len(s...
[ 0.045454545454545456, 0.011111111111111112, 0.014705882352941176, 0, 0, 0, 0, 0.02857142857142857, 0, 0, 0, 0.025, 0.02040816326530612, 0.06666666666666667 ]
14
0.015137
def gen_search_article_url(keyword, page=1, timesn=WechatSogouConst.search_article_time.anytime, article_type=WechatSogouConst.search_article_type.all, ft=None, et=None): """拼接搜索 文章 URL Parameters ---------- keyword : str or unicode 搜索文字 ...
[ "def", "gen_search_article_url", "(", "keyword", ",", "page", "=", "1", ",", "timesn", "=", "WechatSogouConst", ".", "search_article_time", ".", "anytime", ",", "article_type", "=", "WechatSogouConst", ".", "search_article_type", ".", "all", ",", "ft", "=", "Non...
39.128571
0.002493
[ "def gen_search_article_url(keyword, page=1, timesn=WechatSogouConst.search_article_time.anytime,\n", " article_type=WechatSogouConst.search_article_type.all, ft=None, et=None):\n", " \"\"\"拼接搜索 文章 URL\n", "\n", " Parameters\n", " ----------\n", " ...
[ 0.010309278350515464, 0.01904761904761905, 0.043478260869565216, 0, 0, 0, 0, 0, 0, 0, 0, 0.012195121951219513, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
70
0.001521
def querypath(self, block, path): """An XPath-like interface to `query`.""" class BadPath(Exception): """Bad path exception thrown when path cannot be found.""" pass results = self.query(block) ROOT, SEP, WORD, FINAL = six.moves.range(4) # pylint: di...
[ "def", "querypath", "(", "self", ",", "block", ",", "path", ")", ":", "class", "BadPath", "(", "Exception", ")", ":", "\"\"\"Bad path exception thrown when path cannot be found.\"\"\"", "pass", "results", "=", "self", ".", "query", "(", "block", ")", "ROOT", ","...
35.612903
0.001322
[ "def querypath(self, block, path):\n", " \"\"\"An XPath-like interface to `query`.\"\"\"\n", " class BadPath(Exception):\n", " \"\"\"Bad path exception thrown when path cannot be found.\"\"\"\n", " pass\n", " results = self.query(block)\n", " ROOT, SEP, ...
[ 0, 0.02, 0, 0, 0, 0, 0.011111111111111112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
62
0.001235
def to_string(self, style=None, utcoffset=None): """Return a |str| object representing the actual date in accordance with the given style and the eventually given UTC offset (in minutes). Without any input arguments, the actual |Date.style| is used to return a date string in you...
[ "def", "to_string", "(", "self", ",", "style", "=", "None", ",", "utcoffset", "=", "None", ")", ":", "if", "not", "style", ":", "style", "=", "self", ".", "style", "if", "utcoffset", "is", "None", ":", "string", "=", "''", "date", "=", "self", ".",...
34.44898
0.001152
[ "def to_string(self, style=None, utcoffset=None):\n", " \"\"\"Return a |str| object representing the actual date in\n", " accordance with the given style and the eventually given\n", " UTC offset (in minutes).\n", "\n", " Without any input arguments, the actual |Date.style| is ...
[ 0, 0.015384615384615385, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.015384615384615385 ]
49
0.000628
def convert_double_to_two_registers(doubleValue): """ Convert 32 Bit Value to two 16 Bit Value to send as Modbus Registers doubleValue: Value to be converted return: 16 Bit Register values int[] """ myList = list() myList.append(int(doubleValue & 0x0000FFFF)) #Append Least Signific...
[ "def", "convert_double_to_two_registers", "(", "doubleValue", ")", ":", "myList", "=", "list", "(", ")", "myList", ".", "append", "(", "int", "(", "doubleValue", "&", "0x0000FFFF", ")", ")", "#Append Least Significant Word ", "myList", ".", "append", "(", "...
43.6
0.020225
[ "def convert_double_to_two_registers(doubleValue):\n", " \"\"\"\n", " Convert 32 Bit Value to two 16 Bit Value to send as Modbus Registers\n", " doubleValue: Value to be converted\n", " return: 16 Bit Register values int[]\n", " \"\"\" \n", " myList = list()\n", " myList.append(i...
[ 0, 0, 0, 0, 0, 0.1, 0, 0.031914893617021274, 0.043010752688172046, 0.058823529411764705 ]
10
0.023375
def delete_group_dampening(self, group_id, dampening_id): """ Delete an existing group dampening :param group_id: Group Trigger id to be retrieved :param dampening_id: id of the Dampening to be deleted """ self._delete(self._service_url(['triggers', 'groups', group_id, '...
[ "def", "delete_group_dampening", "(", "self", ",", "group_id", ",", "dampening_id", ")", ":", "self", ".", "_delete", "(", "self", ".", "_service_url", "(", "[", "'triggers'", ",", "'groups'", ",", "group_id", ",", "'dampenings'", ",", "dampening_id", "]", "...
42.625
0.008621
[ "def delete_group_dampening(self, group_id, dampening_id):\n", " \"\"\"\n", " Delete an existing group dampening\n", "\n", " :param group_id: Group Trigger id to be retrieved\n", " :param dampening_id: id of the Dampening to be deleted\n", " \"\"\"\n", " self....
[ 0, 0.08333333333333333, 0, 0, 0, 0, 0, 0.019801980198019802 ]
8
0.012892
def find_matching(cls, message, channel): """ Yield ``cls`` subclasses that match message and channel """ return ( handler for handler in cls._registry if isinstance(handler, cls) and handler.match(message, channel) )
[ "def", "find_matching", "(", "cls", ",", "message", ",", "channel", ")", ":", "return", "(", "handler", "for", "handler", "in", "cls", ".", "_registry", "if", "isinstance", "(", "handler", ",", "cls", ")", "and", "handler", ".", "match", "(", "message", ...
23
0.046025
[ "def find_matching(cls, message, channel):\n", "\t\t\"\"\"\n", "\t\tYield ``cls`` subclasses that match message and channel\n", "\t\t\"\"\"\n", "\t\treturn (\n", "\t\t\thandler\n", "\t\t\tfor handler in cls._registry\n", "\t\t\tif isinstance(handler, cls)\n", "\t\t\tand handler.match(message, channe...
[ 0, 0.3333333333333333, 0.017241379310344827, 0.16666666666666666, 0.09090909090909091, 0.09090909090909091, 0.03125, 0.03225806451612903, 0.02564102564102564, 0.6666666666666666 ]
10
0.145488
def create_event_hub(self, hub_name, hub=None, fail_on_exist=False): ''' Creates a new Event Hub. hub_name: Name of event hub. hub: Optional. Event hub properties. Instance of EventHub class. hub.message_retention_in_days: Number of days to re...
[ "def", "create_event_hub", "(", "self", ",", "hub_name", ",", "hub", "=", "None", ",", "fail_on_exist", "=", "False", ")", ":", "_validate_not_none", "(", "'hub_name'", ",", "hub_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", ...
38.918919
0.002033
[ "def create_event_hub(self, hub_name, hub=None, fail_on_exist=False):\n", " '''\n", " Creates a new Event Hub.\n", "\n", " hub_name:\n", " Name of event hub.\n", " hub:\n", " Optional. Event hub properties. Instance of EventHub class.\n", " hu...
[ 0, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.007936507936507936, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.043478260869565216 ]
37
0.003642
def get_url_file_name(url): """Get the file name from an url Parameters ---------- url : str Returns ------- str The file name """ assert isinstance(url, (str, _oldstr)) return urlparse.urlparse(url).path.split('/')[-1]
[ "def", "get_url_file_name", "(", "url", ")", ":", "assert", "isinstance", "(", "url", ",", "(", "str", ",", "_oldstr", ")", ")", "return", "urlparse", ".", "urlparse", "(", "url", ")", ".", "path", ".", "split", "(", "'/'", ")", "[", "-", "1", "]" ...
17.4
0.010909
[ "def get_url_file_name(url):\n", " \"\"\"Get the file name from an url\n", " \n", " Parameters\n", " ----------\n", " url : str\n", "\n", " Returns\n", " -------\n", " str\n", " The file name \n", " \"\"\"\n", "\n", " assert isinstance(url, (str, _oldst...
[ 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.043478260869565216, 0, 0, 0, 0.018867924528301886 ]
15
0.01749
async def api_call(self, verb, action, params=None, add_authorization_token=True, retry=False): """Send api call.""" if add_authorization_token and not self.token: await self.refresh_token() try: return await self._api_call_impl(verb, action, params, add_authorization_to...
[ "async", "def", "api_call", "(", "self", ",", "verb", ",", "action", ",", "params", "=", "None", ",", "add_authorization_token", "=", "True", ",", "retry", "=", "False", ")", ":", "if", "add_authorization_token", "and", "not", "self", ".", "token", ":", ...
45.923077
0.00821
[ "async def api_call(self, verb, action, params=None, add_authorization_token=True, retry=False):\n", " \"\"\"Send api call.\"\"\"\n", " if add_authorization_token and not self.token:\n", " await self.refresh_token()\n", "\n", " try:\n", " return await self._api...
[ 0.010416666666666666, 0.034482758620689655, 0, 0, 0, 0, 0.010869565217391304, 0, 0, 0, 0, 0.010416666666666666, 0.058823529411764705 ]
13
0.009616
def georadius(self, key, longitude, latitude, radius, unit='m', *, with_dist=False, with_hash=False, with_coord=False, count=None, sort=None, encoding=_NOTSET): """Query a sorted set representing a geospatial index to fetch members matching a given maximum distance fr...
[ "def", "georadius", "(", "self", ",", "key", ",", "longitude", ",", "latitude", ",", "radius", ",", "unit", "=", "'m'", ",", "*", ",", "with_dist", "=", "False", ",", "with_hash", "=", "False", ",", "with_coord", "=", "False", ",", "count", "=", "Non...
41.97561
0.002271
[ "def georadius(self, key, longitude, latitude, radius, unit='m', *,\n", " with_dist=False, with_hash=False, with_coord=False,\n", " count=None, sort=None, encoding=_NOTSET):\n", " \"\"\"Query a sorted set representing a geospatial index to fetch members\n", " ...
[ 0, 0.014285714285714285, 0.016666666666666666, 0.012658227848101266, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05555555555555555 ]
41
0.002419
def bz2_compress_stream(src, level=9): """Compress data from `src`. Args: src (iterable): iterable that yields blocks of data to compress level (int): compression level (1-9) default is 9 Yields: blocks of compressed data """ compressor = bz2.BZ2Compressor(level) for b...
[ "def", "bz2_compress_stream", "(", "src", ",", "level", "=", "9", ")", ":", "compressor", "=", "bz2", ".", "BZ2Compressor", "(", "level", ")", "for", "block", "in", "src", ":", "encoded", "=", "compressor", ".", "compress", "(", "block", ")", "if", "en...
25.647059
0.002212
[ "def bz2_compress_stream(src, level=9):\n", " \"\"\"Compress data from `src`.\n", "\n", " Args:\n", " src (iterable): iterable that yields blocks of data to compress\n", " level (int): compression level (1-9) default is 9\n", "\n", " Yields:\n", " blocks of compressed d...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03571428571428571 ]
17
0.002101
def on(self, *args): """ If no arguments are specified, turn all the LEDs on. If arguments are specified, they must be the indexes of the LEDs you wish to turn on. For example:: from gpiozero import LEDBoard leds = LEDBoard(2, 3, 4, 5) leds.on(0) ...
[ "def", "on", "(", "self", ",", "*", "args", ")", ":", "self", ".", "_stop_blink", "(", ")", "if", "args", ":", "for", "index", "in", "args", ":", "self", "[", "index", "]", ".", "on", "(", ")", "else", ":", "super", "(", "LEDBoard", ",", "self"...
34.148148
0.00211
[ "def on(self, *args):\n", " \"\"\"\n", " If no arguments are specified, turn all the LEDs on. If arguments are\n", " specified, they must be the indexes of the LEDs you wish to turn on.\n", " For example::\n", "\n", " from gpiozero import LEDBoard\n", "\n", " ...
[ 0, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02631578947368421 ]
27
0.004061
def get_querydict(self): """ 这个函数跟 self.method有关 self.method 暂时没用, querydict都是POST的 """ if self.method: querydict = getattr(self.request, self.method.upper()) else: querydict = getattr(self.request, 'POST'.upper()) # copy make querydict ...
[ "def", "get_querydict", "(", "self", ")", ":", "if", "self", ".", "method", ":", "querydict", "=", "getattr", "(", "self", ".", "request", ",", "self", ".", "method", ".", "upper", "(", ")", ")", "else", ":", "querydict", "=", "getattr", "(", "self",...
29.846154
0.015
[ "def get_querydict(self):\n", " \"\"\"\n", " 这个函数跟 self.method有关\n", " self.method 暂时没用, querydict都是POST的 \n", " \"\"\"\n", " if self.method:\n", " querydict = getattr(self.request, self.method.upper())\n", " else:\n", " querydict = g...
[ 0, 0.08333333333333333, 0, 0.022727272727272728, 0, 0, 0.014705882352941176, 0, 0.015873015873015872, 0, 0, 0.021739130434782608, 0.04 ]
13
0.01526
def makevFunc(self,solution): ''' Creates the value function for this period, defined over market resources m and persistent income p. self must have the attribute EndOfPrdvFunc in order to execute. Parameters ---------- solution : ConsumerSolution T...
[ "def", "makevFunc", "(", "self", ",", "solution", ")", ":", "mSize", "=", "self", ".", "aXtraGrid", ".", "size", "pSize", "=", "self", ".", "pLvlGrid", ".", "size", "# Compute expected value and marginal value on a grid of market resources", "pLvl_temp", "=", "np", ...
49.946429
0.028401
[ "def makevFunc(self,solution):\n", " '''\n", " Creates the value function for this period, defined over market resources\n", " m and persistent income p. self must have the attribute EndOfPrdvFunc in\n", " order to execute.\n", "\n", " Parameters\n", " ------...
[ 0.03333333333333333, 0.08333333333333333, 0.012195121951219513, 0.012195121951219513, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.012345679012345678, 0, 0, 0, 0, 0, 0.012195121951219513, 0.060240963855421686, 0.05714285714285714, 0.034482758620689655, 0.023809523809523808, ...
56
0.019249
def get_deploy_data(self): ''' Gets any default data attached to the current deploy, if any. ''' if self.state and self.state.deploy_data: return self.state.deploy_data return {}
[ "def", "get_deploy_data", "(", "self", ")", ":", "if", "self", ".", "state", "and", "self", ".", "state", ".", "deploy_data", ":", "return", "self", ".", "state", ".", "deploy_data", "return", "{", "}" ]
24.888889
0.008621
[ "def get_deploy_data(self):\n", " '''\n", " Gets any default data attached to the current deploy, if any.\n", " '''\n", "\n", " if self.state and self.state.deploy_data:\n", " return self.state.deploy_data\n", "\n", " return {}" ]
[ 0, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0.058823529411764705 ]
9
0.015795
def _seconds_as_string(seconds): """ Returns seconds as a human-friendly string, e.g. '1d 4h 47m 41s' """ TIME_UNITS = [('s', 60), ('m', 60), ('h', 24), ('d', None)] unit_strings = [] cur = max(int(seconds), 1) for suffix, size in TIME_UNITS: if size is not None: cur, res...
[ "def", "_seconds_as_string", "(", "seconds", ")", ":", "TIME_UNITS", "=", "[", "(", "'s'", ",", "60", ")", ",", "(", "'m'", ",", "60", ")", ",", "(", "'h'", ",", "24", ")", ",", "(", "'d'", ",", "None", ")", "]", "unit_strings", "=", "[", "]", ...
31.933333
0.002028
[ "def _seconds_as_string(seconds):\n", " \"\"\"\n", " Returns seconds as a human-friendly string, e.g. '1d 4h 47m 41s'\n", " \"\"\"\n", " TIME_UNITS = [('s', 60), ('m', 60), ('h', 24), ('d', None)]\n", " unit_strings = []\n", " cur = max(int(seconds), 1)\n", " for suffix, size in T...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.030303030303030304 ]
15
0.00202
def _get_branches(self): """Get branches from org/repo.""" if self.offline: local_path = Path(LOCAL_PATH).expanduser() / self.org / self.repo get_refs = f"git -C {shlex.quote(str(local_path))} show-ref --heads" else: get_refs = f"git ls-remote --heads https://...
[ "def", "_get_branches", "(", "self", ")", ":", "if", "self", ".", "offline", ":", "local_path", "=", "Path", "(", "LOCAL_PATH", ")", ".", "expanduser", "(", ")", "/", "self", ".", "org", "/", "self", ".", "repo", "get_refs", "=", "f\"git -C {shlex.quote(...
48.166667
0.008489
[ "def _get_branches(self):\n", " \"\"\"Get branches from org/repo.\"\"\"\n", " if self.offline:\n", " local_path = Path(LOCAL_PATH).expanduser() / self.org / self.repo\n", " get_refs = f\"git -C {shlex.quote(str(local_path))} show-ref --heads\"\n", " else:\n", "...
[ 0, 0.023809523809523808, 0, 0, 0.012345679012345678, 0, 0.011111111111111112, 0, 0, 0.008771929824561403, 0, 0.047619047619047616 ]
12
0.008638
def partitions(collection): """Generate all set partitions of a collection. Example: >>> list(partitions(range(3))) # doctest: +NORMALIZE_WHITESPACE [[[0, 1, 2]], [[0], [1, 2]], [[0, 1], [2]], [[1], [0, 2]], [[0], [1], [2]]] """ collection = list(col...
[ "def", "partitions", "(", "collection", ")", ":", "collection", "=", "list", "(", "collection", ")", "# Special cases", "if", "not", "collection", ":", "return", "if", "len", "(", "collection", ")", "==", "1", ":", "yield", "[", "collection", "]", "return"...
25.153846
0.001473
[ "def partitions(collection):\n", " \"\"\"Generate all set partitions of a collection.\n", "\n", " Example:\n", " >>> list(partitions(range(3))) # doctest: +NORMALIZE_WHITESPACE\n", " [[[0, 1, 2]],\n", " [[0], [1, 2]],\n", " [[0, 1], [2]],\n", " [[1], [0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.030303030303030304 ]
26
0.001166
def write(self, filehandle, file_format): """Write :class:`~ctfile.ctfile.CTfile` data into file. :param filehandle: File-like object. :param str file_format: Format to use to write data: ``ctfile`` or ``json``. :return: None. :rtype: :py:obj:`None`. """ try: ...
[ "def", "write", "(", "self", ",", "filehandle", ",", "file_format", ")", ":", "try", ":", "filehandle", ".", "write", "(", "self", ".", "writestr", "(", "file_format", "=", "file_format", ")", ")", "except", "IOError", ":", "raise", "IOError", "(", "'\"f...
39.083333
0.008333
[ "def write(self, filehandle, file_format):\n", " \"\"\"Write :class:`~ctfile.ctfile.CTfile` data into file. \n", "\n", " :param filehandle: File-like object.\n", " :param str file_format: Format to use to write data: ``ctfile`` or ``json``.\n", " :return: None.\n", " :...
[ 0, 0.03076923076923077, 0, 0, 0.011764705882352941, 0, 0, 0, 0, 0, 0, 0.014492753623188406 ]
12
0.004752
def find_vlans( self, number, name, iexact, environment, net_type, network, ip_version, subnet, acl, pagination): """ Find vlans by all search parameters :param nu...
[ "def", "find_vlans", "(", "self", ",", "number", ",", "name", ",", "iexact", ",", "environment", ",", "net_type", ",", "network", ",", "ip_version", ",", "subnet", ",", "acl", ",", "pagination", ")", ":", "if", "not", "isinstance", "(", "pagination", ","...
34.765432
0.001036
[ "def find_vlans(\n", " self,\n", " number,\n", " name,\n", " iexact,\n", " environment,\n", " net_type,\n", " network,\n", " ip_version,\n", " subnet,\n", " acl,\n", " pagin...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.011363636363636364, 0, 0, 0, ...
81
0.001343
def _finite_well_energy(P, n=1, atol=1e-6): ''' Returns the nth bound-state energy for a finite-potential quantum well with the given well-strength parameter, `P`. ''' assert n > 0 and n <= _finite_well_states(P) pi_2 = pi / 2. r = (1 / (P + pi_2)) * (n * pi_2) eta = n * pi_2 - arcsin(r)...
[ "def", "_finite_well_energy", "(", "P", ",", "n", "=", "1", ",", "atol", "=", "1e-6", ")", ":", "assert", "n", ">", "0", "and", "n", "<=", "_finite_well_states", "(", "P", ")", "pi_2", "=", "pi", "/", "2.", "r", "=", "(", "1", "/", "(", "P", ...
32.882353
0.000869
[ "def _finite_well_energy(P, n=1, atol=1e-6):\n", " '''\n", " Returns the nth bound-state energy for a finite-potential quantum well\n", " with the given well-strength parameter, `P`.\n", " '''\n", " assert n > 0 and n <= _finite_well_states(P)\n", " pi_2 = pi / 2.\n", " r = (1 / (...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.08333333333333333 ]
34
0.002451
def sample(problem, N, seed=None): """Generate model inputs using Latin hypercube sampling (LHS). Returns a NumPy matrix containing the model inputs generated by Latin hypercube sampling. The resulting matrix contains N rows and D columns, where D is the number of parameters. Parameters ...
[ "def", "sample", "(", "problem", ",", "N", ",", "seed", "=", "None", ")", ":", "if", "seed", ":", "np", ".", "random", ".", "seed", "(", "seed", ")", "D", "=", "problem", "[", "'num_vars'", "]", "result", "=", "np", ".", "zeros", "(", "[", "N",...
25.371429
0.001085
[ "def sample(problem, N, seed=None):\r\n", " \"\"\"Generate model inputs using Latin hypercube sampling (LHS).\r\n", "\r\n", " Returns a NumPy matrix containing the model inputs generated by Latin\r\n", " hypercube sampling. The resulting matrix contains N rows and D columns,\r\n", " where D i...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.058823529411764705 ]
35
0.001681
def sumMerge(dict1, dict2): """ Adds two dictionaries together, and merges into the first, dict1. Returns first dict. """ for key in dict2: dict1[key] = list(map(lambda a,b: a + b, dict1.get(key, [0,0,0,0]), dict2[key])) return dict1
[ "def", "sumMerge", "(", "dict1", ",", "dict2", ")", ":", "for", "key", "in", "dict2", ":", "dict1", "[", "key", "]", "=", "list", "(", "map", "(", "lambda", "a", ",", "b", ":", "a", "+", "b", ",", "dict1", ".", "get", "(", "key", ",", "[", ...
32.25
0.022642
[ "def sumMerge(dict1, dict2):\n", " \"\"\"\n", " Adds two dictionaries together, and merges into the first, dict1.\n", " Returns first dict.\n", " \"\"\"\n", " for key in dict2:\n", " dict1[key] = list(map(lambda a,b: a + b, dict1.get(key, [0,0,0,0]), dict2[key]))\n", " return ...
[ 0, 0, 0, 0, 0, 0, 0.056179775280898875, 0.0625 ]
8
0.014835
def get_kapur_threshold(image, mask=None): """The Kapur, Sahoo, & Wong method of thresholding, adapted to log-space.""" cropped_image = np.array(image.flat) if mask is None else image[mask] if np.product(cropped_image.shape)<3: return 0 if np.min(cropped_image) == np.max(cropped_image): ...
[ "def", "get_kapur_threshold", "(", "image", ",", "mask", "=", "None", ")", ":", "cropped_image", "=", "np", ".", "array", "(", "image", ".", "flat", ")", "if", "mask", "is", "None", "else", "image", "[", "mask", "]", "if", "np", ".", "product", "(", ...
42.923077
0.008762
[ "def get_kapur_threshold(image, mask=None):\n", " \"\"\"The Kapur, Sahoo, & Wong method of thresholding, adapted to log-space.\"\"\"\n", " cropped_image = np.array(image.flat) if mask is None else image[mask]\n", " if np.product(cropped_image.shape)<3:\n", " return 0\n", " if np.min(cro...
[ 0, 0.012345679012345678, 0, 0.023809523809523808, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0136986301369863, 0, 0, 0, 0, 0, 0, 0.025, 0.02564102564102564, 0, 0, 0, 0.037037037037037035, 0.029411764705882353, 0.02631578947368421, 0.03571428571428571, 0, 0, 0.02,...
39
0.008786
def describe(self, pid, vendorSpecific=None): """Note: If the server returns a status code other than 200 OK, a ServiceFailure will be raised, as this method is based on a HEAD request, which cannot carry exception information.""" response = self.describeResponse(pid, vendorSpecific=vend...
[ "def", "describe", "(", "self", ",", "pid", ",", "vendorSpecific", "=", "None", ")", ":", "response", "=", "self", ".", "describeResponse", "(", "pid", ",", "vendorSpecific", "=", "vendorSpecific", ")", "return", "self", ".", "_read_header_response", "(", "r...
63
0.010444
[ "def describe(self, pid, vendorSpecific=None):\n", " \"\"\"Note: If the server returns a status code other than 200 OK, a ServiceFailure\n", " will be raised, as this method is based on a HEAD request, which cannot carry\n", " exception information.\"\"\"\n", " response = self.de...
[ 0, 0.02247191011235955, 0.011627906976744186, 0, 0, 0.0196078431372549 ]
6
0.008951
def is_valid_program(self,p): """checks whether program p makes a syntactically valid tree. checks that the accumulated program length is always greater than the accumulated arities, indicating that the appropriate number of arguments is alway present for functions. It then checks that ...
[ "def", "is_valid_program", "(", "self", ",", "p", ")", ":", "# print(\"p:\",p)", "arities", "=", "list", "(", "a", ".", "arity", "[", "a", ".", "in_type", "]", "for", "a", "in", "p", ")", "accu_arities", "=", "list", "(", "accumulate", "(", "arities", ...
51
0.009626
[ "def is_valid_program(self,p):\n", " \"\"\"checks whether program p makes a syntactically valid tree.\n", "\n", " checks that the accumulated program length is always greater than the\n", " accumulated arities, indicating that the appropriate number of arguments is\n", " alway ...
[ 0.03333333333333333, 0.014285714285714285, 0, 0, 0.011904761904761904, 0, 0, 0, 0, 0, 0, 0, 0, 0.030303030303030304, 0, 0, 0, 0.044444444444444446 ]
18
0.00746
def send(self, command): """send function sends the command to the oxd server and recieves the response. Parameters: * **command (dict):** Dict representation of the JSON command string Returns: **response (dict):** The JSON response from the oxd Server as a dic...
[ "def", "send", "(", "self", ",", "command", ")", ":", "cmd", "=", "json", ".", "dumps", "(", "command", ")", "cmd", "=", "\"{:04d}\"", ".", "format", "(", "len", "(", "cmd", ")", ")", "+", "cmd", "msg_length", "=", "len", "(", "cmd", ")", "# make...
32.762712
0.002009
[ "def send(self, command):\n", " \"\"\"send function sends the command to the oxd server and recieves the\n", " response.\n", "\n", " Parameters:\n", " * **command (dict):** Dict representation of the JSON command string\n", "\n", " Returns:\n", " **r...
[ 0, 0.01282051282051282, 0, 0, 0, 0.012345679012345678, 0, 0, 0.012345679012345678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
59
0.00112
def is_active(self): """Determines whether this plugin is active. This plugin is active if any health pills information is present for any run. Returns: A boolean. Whether this plugin is active. """ return bool( self._grpc_port is not None and self._event_multiplexer and ...
[ "def", "is_active", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "_grpc_port", "is", "not", "None", "and", "self", ".", "_event_multiplexer", "and", "self", ".", "_event_multiplexer", ".", "PluginRunToTagToContent", "(", "constants", ".", "DEBUGG...
29.142857
0.002375
[ "def is_active(self):\n", " \"\"\"Determines whether this plugin is active.\n", "\n", " This plugin is active if any health pills information is present for any\n", " run.\n", "\n", " Returns:\n", " A boolean. Whether this plugin is active.\n", " \"\"\"\n", " return bool(\n"...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.022727272727272728 ]
14
0.001623
def present(name, ip, clean=False): # pylint: disable=C0103 ''' Ensures that the named host is present with the given ip name The host to assign an ip to ip The ip addr(s) to apply to the host. Can be a single IP or a list of IP addresses. clean : False Remove any...
[ "def", "present", "(", "name", ",", "ip", ",", "clean", "=", "False", ")", ":", "# pylint: disable=C0103", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "None", "if", "__opts__", "[", "'test'", "]", "e...
36.135417
0.001403
[ "def present(name, ip, clean=False): # pylint: disable=C0103\n", " '''\n", " Ensures that the named host is present with the given ip\n", "\n", " name\n", " The host to assign an ip to\n", "\n", " ip\n", " The ip addr(s) to apply to the host. Can be a single IP or a list o...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
96
0.001245
def set_training(model, mode): """ A context manager to temporarily set the training mode of 'model' to 'mode', resetting it when we exit the with-block. A no-op if mode is None. """ if mode is None: yield return old_mode = model.training if old_mode != mode: mod...
[ "def", "set_training", "(", "model", ",", "mode", ")", ":", "if", "mode", "is", "None", ":", "yield", "return", "old_mode", "=", "model", ".", "training", "if", "old_mode", "!=", "mode", ":", "model", ".", "train", "(", "mode", ")", "try", ":", "yiel...
24.529412
0.002309
[ "def set_training(model, mode):\n", " \"\"\"\n", " A context manager to temporarily set the training mode of 'model'\n", " to 'mode', resetting it when we exit the with-block. A no-op if\n", " mode is None.\n", " \"\"\"\n", " if mode is None:\n", " yield\n", " return...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.030303030303030304 ]
17
0.001783
def find_path(target, from_path=None, direction='both', depth_first=False): """ Finds a file or subdirectory from the given path, defaulting to a breadth-first search. :param target: str of file or subdirectory to be found :param from_path: str of path from which to search (defaults to relati...
[ "def", "find_path", "(", "target", ",", "from_path", "=", "None", ",", "direction", "=", "'both'", ",", "depth_first", "=", "False", ")", ":", "from_path", "=", "from_path", "if", "from_path", "else", "relative_path", "(", "''", ",", "2", ")", "if", "dir...
39.673913
0.000535
[ "def find_path(target, from_path=None, direction='both', depth_first=False):\n", " \"\"\"\n", " Finds a file or subdirectory from the given\n", " path, defaulting to a breadth-first search.\n", " :param target: str of file or subdirectory to be found\n", " :param from_path: str of pa...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.012658227848101266 ]
46
0.000275
def run(self): """Run command.""" command = ['npm', 'install'] self.announce( 'Running command: %s' % str(command), level=INFO) subprocess.check_call(command)
[ "def", "run", "(", "self", ")", ":", "command", "=", "[", "'npm'", ",", "'install'", "]", "self", ".", "announce", "(", "'Running command: %s'", "%", "str", "(", "command", ")", ",", "level", "=", "INFO", ")", "subprocess", ".", "check_call", "(", "com...
29.714286
0.009346
[ "def run(self):\n", " \"\"\"Run command.\"\"\"\n", " command = ['npm', 'install']\n", " self.announce(\n", " 'Running command: %s' % str(command),\n", " level=INFO)\n", " subprocess.check_call(command)" ]
[ 0, 0.037037037037037035, 0, 0, 0, 0, 0.02631578947368421 ]
7
0.00905
def count(expr): """ Value counts :param expr: :return: """ if isinstance(expr, SequenceExpr): unique_input = _extract_unique_input(expr) if unique_input: return nunique(unique_input).rename('count') else: return Count(_value_type=types.int64, _i...
[ "def", "count", "(", "expr", ")", ":", "if", "isinstance", "(", "expr", ",", "SequenceExpr", ")", ":", "unique_input", "=", "_extract_unique_input", "(", "expr", ")", "if", "unique_input", ":", "return", "nunique", "(", "unique_input", ")", ".", "rename", ...
34.681818
0.001276
[ "def count(expr):\n", " \"\"\"\n", " Value counts\n", "\n", " :param expr:\n", " :return:\n", " \"\"\"\n", "\n", " if isinstance(expr, SequenceExpr):\n", " unique_input = _extract_unique_input(expr)\n", " if unique_input:\n", " return nunique(unique_i...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.017241379310344827 ]
22
0.000784
def singular_subresource(raml_resource, route_name): """ Determine if :raml_resource: is a singular subresource. :param raml_resource: Instance of ramlfications.raml.ResourceNode. :param route_name: Name of the :raml_resource:. """ static_parent = get_static_parent(raml_resource, method='POST') ...
[ "def", "singular_subresource", "(", "raml_resource", ",", "route_name", ")", ":", "static_parent", "=", "get_static_parent", "(", "raml_resource", ",", "method", "=", "'POST'", ")", "if", "static_parent", "is", "None", ":", "return", "False", "schema", "=", "res...
39.555556
0.001372
[ "def singular_subresource(raml_resource, route_name):\n", " \"\"\" Determine if :raml_resource: is a singular subresource.\n", "\n", " :param raml_resource: Instance of ramlfications.raml.ResourceNode.\n", " :param route_name: Name of the :raml_resource:.\n", " \"\"\"\n", " static_parent ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03125 ]
18
0.001736
def before_start(self, when=None): """ Returns True if the task/course is not yet accessible """ if when is None: when = datetime.now() return self._val[0] > when
[ "def", "before_start", "(", "self", ",", "when", "=", "None", ")", ":", "if", "when", "is", "None", ":", "when", "=", "datetime", ".", "now", "(", ")", "return", "self", ".", "_val", "[", "0", "]", ">", "when" ]
32.333333
0.01005
[ "def before_start(self, when=None):\n", " \"\"\" Returns True if the task/course is not yet accessible \"\"\"\n", " if when is None:\n", " when = datetime.now()\n", "\n", " return self._val[0] > when" ]
[ 0, 0.014285714285714285, 0, 0, 0, 0.029411764705882353 ]
6
0.007283
def plot_groups_all(self, fout_dir=".", **kws_pltargs): # GrouperUserGos """Plot GO DAGs for all groups of user GOs.""" hdrgos = self.grprobj.get_hdrgos() pltargs = PltGroupedGosArgs(self.grprobj, fout_dir=fout_dir, **kws_pltargs) return self._plot_groups_hdrgos(hdrgos, pltargs)
[ "def", "plot_groups_all", "(", "self", ",", "fout_dir", "=", "\".\"", ",", "*", "*", "kws_pltargs", ")", ":", "# GrouperUserGos", "hdrgos", "=", "self", ".", "grprobj", ".", "get_hdrgos", "(", ")", "pltargs", "=", "PltGroupedGosArgs", "(", "self", ".", "gr...
61.4
0.012862
[ "def plot_groups_all(self, fout_dir=\".\", **kws_pltargs): # GrouperUserGos\n", " \"\"\"Plot GO DAGs for all groups of user GOs.\"\"\"\n", " hdrgos = self.grprobj.get_hdrgos()\n", " pltargs = PltGroupedGosArgs(self.grprobj, fout_dir=fout_dir, **kws_pltargs)\n", " return self._plo...
[ 0.0136986301369863, 0.01818181818181818, 0, 0.011904761904761904, 0.017857142857142856 ]
5
0.012328
def _check_non_simple(coeffs): r"""Checks that a polynomial has no non-simple roots. Does so by computing the companion matrix :math:`A` of :math:`f'` and then evaluating the rank of :math:`B = f(A)`. If :math:`B` is not full rank, then :math:`f` and :math:`f'` have a shared factor. See: https://d...
[ "def", "_check_non_simple", "(", "coeffs", ")", ":", "coeffs", "=", "_strip_leading_zeros", "(", "coeffs", ")", "num_coeffs", ",", "=", "coeffs", ".", "shape", "if", "num_coeffs", "<", "3", ":", "return", "deriv_poly", "=", "polynomial", ".", "polyder", "(",...
33.270833
0.000608
[ "def _check_non_simple(coeffs):\n", " r\"\"\"Checks that a polynomial has no non-simple roots.\n", "\n", " Does so by computing the companion matrix :math:`A` of :math:`f'`\n", " and then evaluating the rank of :math:`B = f(A)`. If :math:`B` is not\n", " full rank, then :math:`f` and :math:`f'...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.017241379310344827 ]
48
0.000359
def sharing_agreement_create(self, data, **kwargs): "https://developer.zendesk.com/rest_api/docs/core/sharing_agreements#create-sharing-agreement" api_path = "/api/v2/sharing_agreements.json" return self.call(api_path, method="POST", data=data, **kwargs)
[ "def", "sharing_agreement_create", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/sharing_agreements.json\"", "return", "self", ".", "call", "(", "api_path", ",", "method", "=", "\"POST\"", ",", "data", "=", "data", ...
68.75
0.010791
[ "def sharing_agreement_create(self, data, **kwargs):\n", " \"https://developer.zendesk.com/rest_api/docs/core/sharing_agreements#create-sharing-agreement\"\n", " api_path = \"/api/v2/sharing_agreements.json\"\n", " return self.call(api_path, method=\"POST\", data=data, **kwargs)" ]
[ 0, 0.019417475728155338, 0, 0.014285714285714285 ]
4
0.008426
def apply_fixes(args, tmpdir): """Calls clang-apply-fixes on a given directory.""" invocation = [args.clang_apply_replacements_binary] if args.format: invocation.append('-format') if args.style: invocation.append('-style=' + args.style) invocation.append(tmpdir) subprocess.call(invocation)
[ "def", "apply_fixes", "(", "args", ",", "tmpdir", ")", ":", "invocation", "=", "[", "args", ".", "clang_apply_replacements_binary", "]", "if", "args", ".", "format", ":", "invocation", ".", "append", "(", "'-format'", ")", "if", "args", ".", "style", ":", ...
33.555556
0.022581
[ "def apply_fixes(args, tmpdir):\n", " \"\"\"Calls clang-apply-fixes on a given directory.\"\"\"\n", " invocation = [args.clang_apply_replacements_binary]\n", " if args.format:\n", " invocation.append('-format')\n", " if args.style:\n", " invocation.append('-style=' + args.style)\n", " invoc...
[ 0, 0.018518518518518517, 0.018518518518518517, 0.05555555555555555, 0, 0.058823529411764705, 0, 0.03571428571428571, 0.06896551724137931 ]
9
0.028455
def in_single_path_and_inner(self): """ Test if a node is not linking to any fan in or out node. """ return len(self.successor) == 1 and self.successor[0] is not None and not self.successor[0].in_or_out and \ len(self.precedence) == 1 and self.precedence[0] is not None and...
[ "def", "in_single_path_and_inner", "(", "self", ")", ":", "return", "len", "(", "self", ".", "successor", ")", "==", "1", "and", "self", ".", "successor", "[", "0", "]", "is", "not", "None", "and", "not", "self", ".", "successor", "[", "0", "]", ".",...
57.833333
0.014205
[ "def in_single_path_and_inner(self):\n", " \"\"\"\n", " Test if a node is not linking to any fan in or out node.\n", " \"\"\"\n", " return len(self.successor) == 1 and self.successor[0] is not None and not self.successor[0].in_or_out and \\\n", " len(self.preceden...
[ 0, 0.08333333333333333, 0, 0, 0.008620689655172414, 0.02702702702702703 ]
6
0.01983
def list_directors(self, service_id, version_number): """List the directors for a particular service and version.""" content = self._fetch("/service/%s/version/%d/director" % (service_id, version_number)) return map(lambda x: FastlyDirector(self, x), content)
[ "def", "list_directors", "(", "self", ",", "service_id", ",", "version_number", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/director\"", "%", "(", "service_id", ",", "version_number", ")", ")", "return", "map", "(", "lambda", ...
65.5
0.022642
[ "def list_directors(self, service_id, version_number):\n", "\t\t\"\"\"List the directors for a particular service and version.\"\"\"\n", "\t\tcontent = self._fetch(\"/service/%s/version/%d/director\" % (service_id, version_number))\n", "\t\treturn map(lambda x: FastlyDirector(self, x), content)" ]
[ 0, 0.03076923076923077, 0.022222222222222223, 0.03571428571428571 ]
4
0.022176
def load(fnames, tag=None, sat_id=None): """Load CHAMP STAR files Parameters ------------ fnames : (pandas.Series) Series of filenames tag : (str or NoneType) tag or None (default=None) sat_id : (str or NoneType) satellite id or None (default=None) Returns -----...
[ "def", "load", "(", "fnames", ",", "tag", "=", "None", ",", "sat_id", "=", "None", ")", ":", "import", "re", "if", "len", "(", "fnames", ")", "<=", "0", ":", "return", "pysat", ".", "DataFrame", "(", "None", ")", ",", "pysat", ".", "Meta", "(", ...
42.344828
0.014919
[ "def load(fnames, tag=None, sat_id=None):\n", " \"\"\"Load CHAMP STAR files\n", "\n", " Parameters\n", " ------------\n", " fnames : (pandas.Series)\n", " Series of filenames\n", " tag : (str or NoneType)\n", " tag or None (default=None)\n", " sat_id : (str or NoneT...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03571428571428571, 0.01818181818181818, 0.015384615384615385, 0.013513513513513514, 0.014084507042253521, 0.016129032258064516, 0.017857142857142856, 0.015625, 0.0...
116
0.010601
def isprintable(string): """Return if all characters in string are printable. >>> isprintable('abc') True >>> isprintable(b'\01') False """ string = string.strip() if not string: return True if sys.version_info[0] == 3: try: return string.isprintable() ...
[ "def", "isprintable", "(", "string", ")", ":", "string", "=", "string", ".", "strip", "(", ")", "if", "not", "string", ":", "return", "True", "if", "sys", ".", "version_info", "[", "0", "]", "==", "3", ":", "try", ":", "return", "string", ".", "isp...
26.703704
0.001339
[ "def isprintable(string):\n", " \"\"\"Return if all characters in string are printable.\n", "\n", " >>> isprintable('abc')\n", " True\n", " >>> isprintable(b'\\01')\n", " False\n", "\n", " \"\"\"\n", " string = string.strip()\n", " if not string:\n", " return Tru...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02 ]
27
0.000741
def expired(self): """Called when an expired session is atime""" self._data["_killed"] = True self.save() raise SessionExpired(self._config.expired_message)
[ "def", "expired", "(", "self", ")", ":", "self", ".", "_data", "[", "\"_killed\"", "]", "=", "True", "self", ".", "save", "(", ")", "raise", "SessionExpired", "(", "self", ".", "_config", ".", "expired_message", ")" ]
36.8
0.010638
[ "def expired(self):\n", " \"\"\"Called when an expired session is atime\"\"\"\n", " self._data[\"_killed\"] = True\n", " self.save()\n", " raise SessionExpired(self._config.expired_message)" ]
[ 0, 0.018518518518518517, 0, 0, 0.017241379310344827 ]
5
0.007152
def get_text(docgraph, node_id=None): """ returns the text (joined token strings) that the given node dominates or spans. If no node ID is given, returns the complete text of the document """ if node_id: tokens = (docgraph.node[node_id][docgraph.ns+':token'] for node_id...
[ "def", "get_text", "(", "docgraph", ",", "node_id", "=", "None", ")", ":", "if", "node_id", ":", "tokens", "=", "(", "docgraph", ".", "node", "[", "node_id", "]", "[", "docgraph", ".", "ns", "+", "':token'", "]", "for", "node_id", "in", "get_span", "...
37.923077
0.00198
[ "def get_text(docgraph, node_id=None):\n", " \"\"\"\n", " returns the text (joined token strings) that the given node dominates\n", " or spans. If no node ID is given, returns the complete text of the\n", " document\n", " \"\"\"\n", " if node_id:\n", " tokens = (docgraph.node[...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.037037037037037035 ]
13
0.002849
def set(self, paths: Union[str, Iterable[str]], metadata: Union[IrodsMetadata, List[IrodsMetadata]]): """ Sets the given metadata on the iRODS entities at the given path or paths. Similar to `add` excpet pre-existing metadata with matching keys will be overwritten. If a single metadata ...
[ "def", "set", "(", "self", ",", "paths", ":", "Union", "[", "str", ",", "Iterable", "[", "str", "]", "]", ",", "metadata", ":", "Union", "[", "IrodsMetadata", ",", "List", "[", "IrodsMetadata", "]", "]", ")", ":" ]
58.5
0.009818
[ "def set(self, paths: Union[str, Iterable[str]], metadata: Union[IrodsMetadata, List[IrodsMetadata]]):\n", " \"\"\"\n", " Sets the given metadata on the iRODS entities at the given path or paths. Similar to `add` excpet pre-existing\n", " metadata with matching keys will be overwritten.\n...
[ 0.00980392156862745, 0.08333333333333333, 0.008403361344537815, 0, 0, 0.008403361344537815, 0, 0, 0.009615384615384616, 0, 0, 0.18181818181818182 ]
12
0.025115
def groupby_apply(df, cols, func, *args, **kwargs): """ Groupby cols and call the function fn on each grouped dataframe. Parameters ---------- cols : str | list of str columns to groupby func : function function to call on the grouped data *args : tuple positional pa...
[ "def", "groupby_apply", "(", "df", ",", "cols", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "axis", "=", "kwargs", ".", "pop", "(", "'axis'", ")", "except", "KeyError", ":", "axis", "=", "0", "lst", "=", "[", "...
31.666667
0.001021
[ "def groupby_apply(df, cols, func, *args, **kwargs):\n", " \"\"\"\n", " Groupby cols and call the function fn on each grouped dataframe.\n", "\n", " Parameters\n", " ----------\n", " cols : str | list of str\n", " columns to groupby\n", " func : function\n", " funct...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01818181818181818 ]
30
0.000606
def check_fast(self, r, k=None): '''Fast check if there's any error in a message+ecc. Can be used before decoding, in addition to hashes to detect if the message was tampered, or after decoding to check that the message was fully recovered. returns True/False ''' n = self.n if no...
[ "def", "check_fast", "(", "self", ",", "r", ",", "k", "=", "None", ")", ":", "n", "=", "self", ".", "n", "if", "not", "k", ":", "k", "=", "self", ".", "k", "#h = self.h[k]", "g", "=", "self", ".", "g", "[", "k", "]", "# If we were given a string,...
41.181818
0.00863
[ "def check_fast(self, r, k=None):\n", " '''Fast check if there's any error in a message+ecc. Can be used before decoding, in addition to hashes to detect if the message was tampered, or after decoding to check that the message was fully recovered.\n", " returns True/False\n", " '''\n", ...
[ 0, 0.009259259259259259, 0, 0, 0, 0.034482758620689655, 0.043478260869565216, 0, 0, 0.010526315789473684, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.008064516129032258, 0.022222222222222223, 0.017241379310344827 ]
22
0.006603
def next_event(self): """Simulates the queue forward one event. This method behaves identically to a :class:`.LossQueue` if the arriving/departing agent is anything other than a :class:`.ResourceAgent`. The differences are; Arriving: * If the :class:`.ResourceAgent` ha...
[ "def", "next_event", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_arrivals", "[", "0", "]", ",", "ResourceAgent", ")", ":", "if", "self", ".", "_departures", "[", "0", "]", ".", "_time", "<", "self", ".", "_arrivals", "[", "0", "]...
43.69697
0.002035
[ "def next_event(self):\n", " \"\"\"Simulates the queue forward one event.\n", "\n", " This method behaves identically to a :class:`.LossQueue` if the\n", " arriving/departing agent is anything other than a\n", " :class:`.ResourceAgent`. The differences are;\n", "\n", " ...
[ 0, 0.02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.009615384615384616, 0, 0.009259259259259259, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
66
0.001107
def postfix_to_optree(nodes): """Convert a list of nodes in postfix order to an Optree.""" while len(nodes) > 1: nodes = _reduce(nodes) if len(nodes) == 0: raise OperatorError("Empty node list") node = nodes[0] if isinstance(node, OperatorNode): raise OperatorError("Operator without operands") ...
[ "def", "postfix_to_optree", "(", "nodes", ")", ":", "while", "len", "(", "nodes", ")", ">", "1", ":", "nodes", "=", "_reduce", "(", "nodes", ")", "if", "len", "(", "nodes", ")", "==", "0", ":", "raise", "OperatorError", "(", "\"Empty node list\"", ")",...
23.058824
0.019608
[ "def postfix_to_optree(nodes):\n", " \"\"\"Convert a list of nodes in postfix order to an Optree.\"\"\"\n", " while len(nodes) > 1:\n", " nodes = _reduce(nodes)\n", "\n", " if len(nodes) == 0:\n", " raise OperatorError(\"Empty node list\")\n", "\n", " node = nodes[0]\n", "\n", " if is...
[ 0, 0.015873015873015872, 0.041666666666666664, 0, 0, 0.045454545454545456, 0, 0, 0.05555555555555555, 0, 0.02702702702702703, 0, 0, 0.02857142857142857, 0, 0, 0.05714285714285714 ]
17
0.015958
def _pack_fn(self): """For packed datasets, returns a function to pack examples. Returns: None or a function from list of TFRecords to list of TFRecords """ if not self.packed_length: return None def my_fn(records): """Function from list of TFRecords to list of TFRecords.""" ...
[ "def", "_pack_fn", "(", "self", ")", ":", "if", "not", "self", ".", "packed_length", ":", "return", "None", "def", "my_fn", "(", "records", ")", ":", "\"\"\"Function from list of TFRecords to list of TFRecords.\"\"\"", "examples", "=", "[", "]", "for", "record", ...
35.68
0.009825
[ "def _pack_fn(self):\n", " \"\"\"For packed datasets, returns a function to pack examples.\n", "\n", " Returns:\n", " None or a function from list of TFRecords to list of TFRecords\n", " \"\"\"\n", " if not self.packed_length:\n", " return None\n", " def my_fn(records):\n", ...
[ 0, 0, 0, 0, 0, 0, 0, 0.05555555555555555, 0.041666666666666664, 0.015151515151515152, 0.05, 0.034482758620689655, 0, 0, 0, 0, 0.02702702702702703, 0, 0, 0, 0, 0.01694915254237288, 0.06666666666666667, 0, 0.0625 ]
25
0.0148
def evaluate(self, node, filename=None): """ Evaluate a source string or node, using ``filename`` when displaying errors. """ if isinstance(node, string_types): self.source = node kwargs = {'mode': 'eval'} if filename: kwargs['f...
[ "def", "evaluate", "(", "self", ",", "node", ",", "filename", "=", "None", ")", ":", "if", "isinstance", "(", "node", ",", "string_types", ")", ":", "self", ".", "source", "=", "node", "kwargs", "=", "{", "'mode'", ":", "'eval'", "}", "if", "filename...
37.32
0.00209
[ "def evaluate(self, node, filename=None):\n", " \"\"\"\n", " Evaluate a source string or node, using ``filename`` when\n", " displaying errors.\n", " \"\"\"\n", " if isinstance(node, string_types):\n", " self.source = node\n", " kwargs = {'mode'...
[ 0, 0.08333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03571428571428571 ]
25
0.004762
def metadata(func): """Add metadata to an item. Decorator that adds metadata to a given item such as the gelk revision used. """ @functools.wraps(func) def decorator(self, *args, **kwargs): eitem = func(self, *args, **kwargs) metadata = { 'metadata__gelk_version': s...
[ "def", "metadata", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "decorator", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "eitem", "=", "func", "(", "self", ",", "*", "args", ",", "*", "*"...
29.888889
0.001802
[ "def metadata(func):\n", " \"\"\"Add metadata to an item.\n", "\n", " Decorator that adds metadata to a given item such as\n", " the gelk revision used.\n", "\n", " \"\"\"\n", " @functools.wraps(func)\n", " def decorator(self, *args, **kwargs):\n", " eitem = func(self, *ar...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05 ]
18
0.002778
def list_pkgs(versions_as_list=False, **kwargs): ''' List the filesets/rpm packages currently installed as a dict: .. code-block:: python {'<package_name>': '<version>'} CLI Example: .. code-block:: bash salt '*' pkg.list_pkgs ''' ret = {} versions_as_list = salt.uti...
[ "def", "list_pkgs", "(", "versions_as_list", "=", "False", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "}", "versions_as_list", "=", "salt", ".", "utils", ".", "data", ".", "is_true", "(", "versions_as_list", ")", "# not yet implemented or not applicab...
30.208333
0.00089
[ "def list_pkgs(versions_as_list=False, **kwargs):\n", " '''\n", " List the filesets/rpm packages currently installed as a dict:\n", "\n", " .. code-block:: python\n", "\n", " {'<package_name>': '<version>'}\n", "\n", " CLI Example:\n", "\n", " .. code-block:: bash\n", "\n...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.011904761904761904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
72
0.001157
def list_nodes_full(**kwargs): ''' Return all data on nodes ''' nodes = _query('server/list') ret = {} for node in nodes: name = nodes[node]['label'] ret[name] = nodes[node].copy() ret[name]['id'] = node ret[name]['image'] = nodes[node]['os'] ret[name]['s...
[ "def", "list_nodes_full", "(", "*", "*", "kwargs", ")", ":", "nodes", "=", "_query", "(", "'server/list'", ")", "ret", "=", "{", "}", "for", "node", "in", "nodes", ":", "name", "=", "nodes", "[", "node", "]", "[", "'label'", "]", "ret", "[", "name"...
28.944444
0.001859
[ "def list_nodes_full(**kwargs):\n", " '''\n", " Return all data on nodes\n", " '''\n", " nodes = _query('server/list')\n", " ret = {}\n", "\n", " for node in nodes:\n", " name = nodes[node]['label']\n", " ret[name] = nodes[node].copy()\n", " ret[name]['id']...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.07142857142857142 ]
18
0.003968
def task(self, total: int, name=None, message=None): """Wrap code into a begin and end call on this monitor""" self.begin(total, name, message) try: yield self finally: self.done()
[ "def", "task", "(", "self", ",", "total", ":", "int", ",", "name", "=", "None", ",", "message", "=", "None", ")", ":", "self", ".", "begin", "(", "total", ",", "name", ",", "message", ")", "try", ":", "yield", "self", "finally", ":", "self", ".",...
32.857143
0.008475
[ "def task(self, total: int, name=None, message=None):\n", " \"\"\"Wrap code into a begin and end call on this monitor\"\"\"\n", " self.begin(total, name, message)\n", " try:\n", " yield self\n", " finally:\n", " self.done()" ]
[ 0, 0.015151515151515152, 0, 0, 0, 0, 0.043478260869565216 ]
7
0.008376
def symmetric_strength_of_connection(A, theta=0): """Symmetric Strength Measure. Compute strength of connection matrix using the standard symmetric measure An off-diagonal connection A[i,j] is strong iff:: abs(A[i,j]) >= theta * sqrt( abs(A[i,i]) * abs(A[j,j]) ) Parameters ---------- ...
[ "def", "symmetric_strength_of_connection", "(", "A", ",", "theta", "=", "0", ")", ":", "if", "theta", "<", "0", ":", "raise", "ValueError", "(", "'expected a positive theta'", ")", "if", "sparse", ".", "isspmatrix_csr", "(", "A", ")", ":", "# if theta == 0:", ...
33.296296
0.00027
[ "def symmetric_strength_of_connection(A, theta=0):\n", " \"\"\"Symmetric Strength Measure.\n", "\n", " Compute strength of connection matrix using the standard symmetric measure\n", "\n", " An off-diagonal connection A[i,j] is strong iff::\n", "\n", " abs(A[i,j]) >= theta * sqrt( abs(A...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
108
0.000772
def find_good_temp_dir(candidate_temp_dirs): """ Given a list of candidate temp directories extracted from ``ansible.cfg``, combine it with the Python-builtin list of candidate directories used by :mod:`tempfile`, then iteratively try each until one is found that is both writeable and executable. ...
[ "def", "find_good_temp_dir", "(", "candidate_temp_dirs", ")", ":", "paths", "=", "[", "os", ".", "path", ".", "expandvars", "(", "os", ".", "path", ".", "expanduser", "(", "p", ")", ")", "for", "p", "in", "candidate_temp_dirs", "]", "paths", ".", "extend...
38
0.001116
[ "def find_good_temp_dir(candidate_temp_dirs):\n", " \"\"\"\n", " Given a list of candidate temp directories extracted from ``ansible.cfg``,\n", " combine it with the Python-builtin list of candidate directories used by\n", " :mod:`tempfile`, then iteratively try each until one is found that is b...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.16666666666666666 ]
23
0.007246
def _get_options(**kwargs): ''' Returns a list of options to be used in the yum/dnf command, based on the kwargs passed. ''' # Get repo options from the kwargs fromrepo = kwargs.pop('fromrepo', '') repo = kwargs.pop('repo', '') disablerepo = kwargs.pop('disablerepo', '') enablerepo =...
[ "def", "_get_options", "(", "*", "*", "kwargs", ")", ":", "# Get repo options from the kwargs", "fromrepo", "=", "kwargs", ".", "pop", "(", "'fromrepo'", ",", "''", ")", "repo", "=", "kwargs", ".", "pop", "(", "'repo'", ",", "''", ")", "disablerepo", "=", ...
34.352113
0.000399
[ "def _get_options(**kwargs):\n", " '''\n", " Returns a list of options to be used in the yum/dnf command, based on the\n", " kwargs passed.\n", " '''\n", " # Get repo options from the kwargs\n", " fromrepo = kwargs.pop('fromrepo', '')\n", " repo = kwargs.pop('repo', '')\n", " ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
71
0.001006
def _get_exchange_key_ntlm_v1(negotiate_flags, session_base_key, server_challenge, lm_challenge_response, lm_hash): """ [MS-NLMP] v28.0 2016-07-14 3.4.5.1 KXKEY Calculates the Key Exchange Key for NTLMv1 authentication. Used for signing an...
[ "def", "_get_exchange_key_ntlm_v1", "(", "negotiate_flags", ",", "session_base_key", ",", "server_challenge", ",", "lm_challenge_response", ",", "lm_hash", ")", ":", "if", "negotiate_flags", "&", "NegotiateFlags", ".", "NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY", ":", "key...
41.928571
0.000555
[ "def _get_exchange_key_ntlm_v1(negotiate_flags, session_base_key,\n", " server_challenge, lm_challenge_response,\n", " lm_hash):\n", " \"\"\"\n", " [MS-NLMP] v28.0 2016-07-14\n", "\n", " 3.4.5.1 KXKEY\n", " Calculates the Key Exchan...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.037037037037037035 ]
42
0.000882
def cli(env, sortby): """List SSH keys.""" mgr = SoftLayer.SshKeyManager(env.client) keys = mgr.list_keys() table = formatting.Table(['id', 'label', 'fingerprint', 'notes']) table.sortby = sortby for key in keys: table.add_row([key['id'], key.get('label'), ...
[ "def", "cli", "(", "env", ",", "sortby", ")", ":", "mgr", "=", "SoftLayer", ".", "SshKeyManager", "(", "env", ".", "client", ")", "keys", "=", "mgr", ".", "list_keys", "(", ")", "table", "=", "formatting", ".", "Table", "(", "[", "'id'", ",", "'lab...
25.875
0.002331
[ "def cli(env, sortby):\n", " \"\"\"List SSH keys.\"\"\"\n", "\n", " mgr = SoftLayer.SshKeyManager(env.client)\n", " keys = mgr.list_keys()\n", "\n", " table = formatting.Table(['id', 'label', 'fingerprint', 'notes'])\n", " table.sortby = sortby\n", "\n", " for key in keys:\n", ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05263157894736842 ]
16
0.003289
def to_text(path, language='fra'): """Wraps Tesseract 4 OCR with custom language model. Parameters ---------- path : str path of electronic invoice in JPG or PNG format Returns ------- extracted_str : str returns extracted text from image in JPG or PNG format """ i...
[ "def", "to_text", "(", "path", ",", "language", "=", "'fra'", ")", ":", "import", "subprocess", "from", "distutils", "import", "spawn", "import", "tempfile", "import", "time", "# Check for dependencies. Needs Tesseract and Imagemagick installed.", "if", "not", "spawn", ...
26.102941
0.001629
[ "def to_text(path, language='fra'):\n", " \"\"\"Wraps Tesseract 4 OCR with custom language model.\n", "\n", " Parameters\n", " ----------\n", " path : str\n", " path of electronic invoice in JPG or PNG format\n", "\n", " Returns\n", " -------\n", " extracted_str : str...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01041666666666...
68
0.00086
def register_controller(self, module, required=True, min_number=1): """Loads a controller module and returns its loaded devices. This is to be used in a mobly test class. Args: module: A module that follows the controller module interface. required: A bool. If True, fai...
[ "def", "register_controller", "(", "self", ",", "module", ",", "required", "=", "True", ",", "min_number", "=", "1", ")", ":", "verify_controller_module", "(", "module", ")", "# Use the module's name as the ref name", "module_ref_name", "=", "module", ".", "__name__...
48.306667
0.001082
[ "def register_controller(self, module, required=True, min_number=1):\n", " \"\"\"Loads a controller module and returns its loaded devices.\n", "\n", " This is to be used in a mobly test class.\n", "\n", " Args:\n", " module: A module that follows the controller module int...
[ 0, 0.014492753623188406, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.012345679012345678, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0625, 0, 0, ...
75
0.001797
def _get_frame_info(stacklevel, context=1): """Get a Traceback for the given `stacklevel`. For example: `stacklevel=0` means this function's frame (_get_frame_info()). `stacklevel=1` means the calling function's frame. See https://docs.python.org/2/library/inspect.html#inspect.getouterframes for more info. ...
[ "def", "_get_frame_info", "(", "stacklevel", ",", "context", "=", "1", ")", ":", "frame_list", "=", "inspect", ".", "getouterframes", "(", "inspect", ".", "currentframe", "(", ")", ",", "context", "=", "context", ")", "frame_stack_index", "=", "stacklevel", ...
44.714286
0.01252
[ "def _get_frame_info(stacklevel, context=1):\n", " \"\"\"Get a Traceback for the given `stacklevel`.\n", "\n", " For example:\n", " `stacklevel=0` means this function's frame (_get_frame_info()).\n", " `stacklevel=1` means the calling function's frame.\n", " See https://docs.python.org/2/library/in...
[ 0, 0.02040816326530612, 0, 0, 0, 0, 0.01098901098901099, 0, 0.010526315789473684, 0, 0, 0.012658227848101266, 0.022222222222222223, 0.05263157894736842 ]
14
0.009245
def publish(func_or_workspace_id, workspace_id_or_token = None, workspace_token_or_none = None, files=(), endpoint=None): '''publishes a callable function or decorates a function to be published. Returns a callable, iterable object. Calling the object will invoke the published service. Iterating the object will...
[ "def", "publish", "(", "func_or_workspace_id", ",", "workspace_id_or_token", "=", "None", ",", "workspace_token_or_none", "=", "None", ",", "files", "=", "(", ")", ",", "endpoint", "=", "None", ")", ":", "if", "not", "callable", "(", "func_or_workspace_id", ")...
42.2
0.009727
[ "def publish(func_or_workspace_id, workspace_id_or_token = None, workspace_token_or_none = None, files=(), endpoint=None):\n", " '''publishes a callable function or decorates a function to be published. \n", "\n", "Returns a callable, iterable object. Calling the object will invoke the published service....
[ 0.040983606557377046, 0.0125, 0, 0.010869565217391304, 0, 0.2, 0.011627906976744186, 0.011764705882352941, 0.012048192771084338, 0, 0, 0.047619047619047616, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.012048192771084338, 0....
50
0.016337