repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
google/grr | grr/client/grr_response_client/client_actions/file_finder_utils/globbing.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/file_finder_utils/globbing.py#L380-L408 | def _ListDir(dirpath, pathtype):
"""Returns children of a given directory.
This function is intended to be used by the `PathComponent` subclasses to get
initial list of potential children that then need to be filtered according to
the rules of a specific component.
Args:
dirpath: A path to the directory... | [
"def",
"_ListDir",
"(",
"dirpath",
",",
"pathtype",
")",
":",
"pathspec",
"=",
"rdf_paths",
".",
"PathSpec",
"(",
"path",
"=",
"dirpath",
",",
"pathtype",
"=",
"pathtype",
")",
"childpaths",
"=",
"[",
"]",
"try",
":",
"file_obj",
"=",
"vfs",
".",
"VFSO... | Returns children of a given directory.
This function is intended to be used by the `PathComponent` subclasses to get
initial list of potential children that then need to be filtered according to
the rules of a specific component.
Args:
dirpath: A path to the directory.
pathtype: The pathtype to use.
... | [
"Returns",
"children",
"of",
"a",
"given",
"directory",
"."
] | python | train |
gabstopper/smc-python | smc/elements/other.py | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/other.py#L409-L474 | def prepare_blacklist(src, dst, duration=3600, src_port1=None,
src_port2=None, src_proto='predefined_tcp',
dst_port1=None, dst_port2=None,
dst_proto='predefined_tcp'):
"""
Create a blacklist entry.
A blacklist can be added directly from... | [
"def",
"prepare_blacklist",
"(",
"src",
",",
"dst",
",",
"duration",
"=",
"3600",
",",
"src_port1",
"=",
"None",
",",
"src_port2",
"=",
"None",
",",
"src_proto",
"=",
"'predefined_tcp'",
",",
"dst_port1",
"=",
"None",
",",
"dst_port2",
"=",
"None",
",",
... | Create a blacklist entry.
A blacklist can be added directly from the engine node, or from
the system context. If submitting from the system context, it becomes
a global blacklist. This will return the properly formatted json
to submit.
:param src: source address, with cidr, i.e. 10.10.10.1... | [
"Create",
"a",
"blacklist",
"entry",
".",
"A",
"blacklist",
"can",
"be",
"added",
"directly",
"from",
"the",
"engine",
"node",
"or",
"from",
"the",
"system",
"context",
".",
"If",
"submitting",
"from",
"the",
"system",
"context",
"it",
"becomes",
"a",
"glo... | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/core/page.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/page.py#L51-L71 | def page_dumb(strng, start=0, screen_lines=25):
"""Very dumb 'pager' in Python, for when nothing else works.
Only moves forward, same interface as page(), except for pager_cmd and
mode."""
out_ln = strng.splitlines()[start:]
screens = chop(out_ln,screen_lines-1)
if len(screens) == 1:
... | [
"def",
"page_dumb",
"(",
"strng",
",",
"start",
"=",
"0",
",",
"screen_lines",
"=",
"25",
")",
":",
"out_ln",
"=",
"strng",
".",
"splitlines",
"(",
")",
"[",
"start",
":",
"]",
"screens",
"=",
"chop",
"(",
"out_ln",
",",
"screen_lines",
"-",
"1",
"... | Very dumb 'pager' in Python, for when nothing else works.
Only moves forward, same interface as page(), except for pager_cmd and
mode. | [
"Very",
"dumb",
"pager",
"in",
"Python",
"for",
"when",
"nothing",
"else",
"works",
"."
] | python | test |
pre-commit/pre-commit | pre_commit/make_archives.py | https://github.com/pre-commit/pre-commit/blob/72f98d26e690da11dc2e41861d14c58eb21930cb/pre_commit/make_archives.py#L30-L53 | def make_archive(name, repo, ref, destdir):
"""Makes an archive of a repository in the given destdir.
:param text name: Name to give the archive. For instance foo. The file
that is created will be called foo.tar.gz.
:param text repo: Repository to clone.
:param text ref: Tag/SHA/branch to check o... | [
"def",
"make_archive",
"(",
"name",
",",
"repo",
",",
"ref",
",",
"destdir",
")",
":",
"output_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"destdir",
",",
"name",
"+",
"'.tar.gz'",
")",
"with",
"tmpdir",
"(",
")",
"as",
"tempdir",
":",
"# Clone ... | Makes an archive of a repository in the given destdir.
:param text name: Name to give the archive. For instance foo. The file
that is created will be called foo.tar.gz.
:param text repo: Repository to clone.
:param text ref: Tag/SHA/branch to check out.
:param text destdir: Directory to place arc... | [
"Makes",
"an",
"archive",
"of",
"a",
"repository",
"in",
"the",
"given",
"destdir",
"."
] | python | train |
SiLab-Bonn/pyBAR | pybar/fei4_run_base.py | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L1445-L1457 | def interval_timer(interval, func, *args, **kwargs):
'''Interval timer function.
Taken from: http://stackoverflow.com/questions/22498038/improvement-on-interval-python/22498708
'''
stopped = Event()
def loop():
while not stopped.wait(interval): # the first call is after interval
... | [
"def",
"interval_timer",
"(",
"interval",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"stopped",
"=",
"Event",
"(",
")",
"def",
"loop",
"(",
")",
":",
"while",
"not",
"stopped",
".",
"wait",
"(",
"interval",
")",
":",
"# the f... | Interval timer function.
Taken from: http://stackoverflow.com/questions/22498038/improvement-on-interval-python/22498708 | [
"Interval",
"timer",
"function",
"."
] | python | train |
androguard/androguard | androguard/core/bytecodes/apk.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/apk.py#L1127-L1159 | def get_intent_filters(self, itemtype, name):
"""
Find intent filters for a given item and name.
Intent filter are attached to activities, services or receivers.
You can search for the intent filters of such items and get a dictionary of all
attached actions and intent categorie... | [
"def",
"get_intent_filters",
"(",
"self",
",",
"itemtype",
",",
"name",
")",
":",
"d",
"=",
"{",
"\"action\"",
":",
"[",
"]",
",",
"\"category\"",
":",
"[",
"]",
"}",
"for",
"i",
"in",
"self",
".",
"xml",
":",
"# TODO: this can probably be solved using a s... | Find intent filters for a given item and name.
Intent filter are attached to activities, services or receivers.
You can search for the intent filters of such items and get a dictionary of all
attached actions and intent categories.
:param itemtype: the type of parent item to look for, ... | [
"Find",
"intent",
"filters",
"for",
"a",
"given",
"item",
"and",
"name",
"."
] | python | train |
jmbhughes/suvi-trainer | suvitrainer/fileio.py | https://github.com/jmbhughes/suvi-trainer/blob/3d89894a4a037286221974c7eb5634d229b4f5d4/suvitrainer/fileio.py#L609-L638 | def make_three_color(self, upper_percentile=100, lower_percentile=0):
"""
Load the configured input channel images and create a three color image
:param upper_percentile: pixels above this percentile are suppressed
:param lower_percentile: pixels below this percentile are suppressed
... | [
"def",
"make_three_color",
"(",
"self",
",",
"upper_percentile",
"=",
"100",
",",
"lower_percentile",
"=",
"0",
")",
":",
"order",
"=",
"{",
"'red'",
":",
"0",
",",
"'green'",
":",
"1",
",",
"'blue'",
":",
"2",
"}",
"shape",
"=",
"self",
".",
"thmap"... | Load the configured input channel images and create a three color image
:param upper_percentile: pixels above this percentile are suppressed
:param lower_percentile: pixels below this percentile are suppressed
:return: a numpy array (m,n,3) representing a three-color image | [
"Load",
"the",
"configured",
"input",
"channel",
"images",
"and",
"create",
"a",
"three",
"color",
"image",
":",
"param",
"upper_percentile",
":",
"pixels",
"above",
"this",
"percentile",
"are",
"suppressed",
":",
"param",
"lower_percentile",
":",
"pixels",
"bel... | python | train |
pypa/pipenv | pipenv/vendor/pipdeptree.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pipdeptree.py#L75-L87 | def find_tree_root(tree, key):
"""Find a root in a tree by it's key
:param dict tree: the pkg dependency tree obtained by calling
`construct_tree` function
:param str key: key of the root node to find
:returns: a root node if found else None
:rtype: mixed
"""
result = ... | [
"def",
"find_tree_root",
"(",
"tree",
",",
"key",
")",
":",
"result",
"=",
"[",
"p",
"for",
"p",
"in",
"tree",
".",
"keys",
"(",
")",
"if",
"p",
".",
"key",
"==",
"key",
"]",
"assert",
"len",
"(",
"result",
")",
"in",
"[",
"0",
",",
"1",
"]",... | Find a root in a tree by it's key
:param dict tree: the pkg dependency tree obtained by calling
`construct_tree` function
:param str key: key of the root node to find
:returns: a root node if found else None
:rtype: mixed | [
"Find",
"a",
"root",
"in",
"a",
"tree",
"by",
"it",
"s",
"key"
] | python | train |
idmillington/layout | layout/datatypes/output.py | https://github.com/idmillington/layout/blob/c452d1d7a74c9a74f7639c1b49e2a41c4e354bb5/layout/datatypes/output.py#L79-L83 | def draw_image(
self, img_filename:str, x:float, y:float, w:float, h:float
) -> None:
"""Draws the given image."""
pass | [
"def",
"draw_image",
"(",
"self",
",",
"img_filename",
":",
"str",
",",
"x",
":",
"float",
",",
"y",
":",
"float",
",",
"w",
":",
"float",
",",
"h",
":",
"float",
")",
"->",
"None",
":",
"pass"
] | Draws the given image. | [
"Draws",
"the",
"given",
"image",
"."
] | python | train |
acutesoftware/AIKIF | aikif/cls_log.py | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L148-L153 | def record_command(self, cmd, prg=''):
"""
record the command passed - this is usually the name of the program
being run or task being run
"""
self._log(self.logFileCommand , force_to_string(cmd), prg) | [
"def",
"record_command",
"(",
"self",
",",
"cmd",
",",
"prg",
"=",
"''",
")",
":",
"self",
".",
"_log",
"(",
"self",
".",
"logFileCommand",
",",
"force_to_string",
"(",
"cmd",
")",
",",
"prg",
")"
] | record the command passed - this is usually the name of the program
being run or task being run | [
"record",
"the",
"command",
"passed",
"-",
"this",
"is",
"usually",
"the",
"name",
"of",
"the",
"program",
"being",
"run",
"or",
"task",
"being",
"run"
] | python | train |
arcticfoxnv/slackminion | slackminion/plugin/base.py | https://github.com/arcticfoxnv/slackminion/blob/62ea77aba5ac5ba582793e578a379a76f7d26cdb/slackminion/plugin/base.py#L65-L76 | def start_timer(self, duration, func, *args):
"""
Schedules a function to be called after some period of time.
* duration - time in seconds to wait before firing
* func - function to be called
* args - arguments to pass to the function
"""
t = threading.Timer(dur... | [
"def",
"start_timer",
"(",
"self",
",",
"duration",
",",
"func",
",",
"*",
"args",
")",
":",
"t",
"=",
"threading",
".",
"Timer",
"(",
"duration",
",",
"self",
".",
"_timer_callback",
",",
"(",
"func",
",",
"args",
")",
")",
"self",
".",
"_timer_call... | Schedules a function to be called after some period of time.
* duration - time in seconds to wait before firing
* func - function to be called
* args - arguments to pass to the function | [
"Schedules",
"a",
"function",
"to",
"be",
"called",
"after",
"some",
"period",
"of",
"time",
"."
] | python | valid |
ambitioninc/rabbitmq-admin | rabbitmq_admin/api.py | https://github.com/ambitioninc/rabbitmq-admin/blob/ff65054115f19991da153f0e4f4e45e526545fea/rabbitmq_admin/api.py#L468-L474 | def list_policies_for_vhost(self, vhost):
"""
A list of all policies for a vhost.
"""
return self._api_get('/api/policies/{0}'.format(
urllib.parse.quote_plus(vhost)
)) | [
"def",
"list_policies_for_vhost",
"(",
"self",
",",
"vhost",
")",
":",
"return",
"self",
".",
"_api_get",
"(",
"'/api/policies/{0}'",
".",
"format",
"(",
"urllib",
".",
"parse",
".",
"quote_plus",
"(",
"vhost",
")",
")",
")"
] | A list of all policies for a vhost. | [
"A",
"list",
"of",
"all",
"policies",
"for",
"a",
"vhost",
"."
] | python | train |
idlesign/django-admirarchy | admirarchy/utils.py | https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L169-L180 | def init_hierarchy(cls, model_admin):
"""Initializes model admin with hierarchy data."""
hierarchy = getattr(model_admin, 'hierarchy')
if hierarchy:
if not isinstance(hierarchy, Hierarchy):
hierarchy = AdjacencyList() # For `True` and etc. TODO heuristics maybe.
... | [
"def",
"init_hierarchy",
"(",
"cls",
",",
"model_admin",
")",
":",
"hierarchy",
"=",
"getattr",
"(",
"model_admin",
",",
"'hierarchy'",
")",
"if",
"hierarchy",
":",
"if",
"not",
"isinstance",
"(",
"hierarchy",
",",
"Hierarchy",
")",
":",
"hierarchy",
"=",
... | Initializes model admin with hierarchy data. | [
"Initializes",
"model",
"admin",
"with",
"hierarchy",
"data",
"."
] | python | train |
UDST/orca | orca/orca.py | https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1649-L1658 | def _all_reachable_tables(t):
"""
A generator that provides all the names of tables that can be
reached via merges starting at the given target table.
"""
for k, v in t.items():
for tname in _all_reachable_tables(v):
yield tname
yield k | [
"def",
"_all_reachable_tables",
"(",
"t",
")",
":",
"for",
"k",
",",
"v",
"in",
"t",
".",
"items",
"(",
")",
":",
"for",
"tname",
"in",
"_all_reachable_tables",
"(",
"v",
")",
":",
"yield",
"tname",
"yield",
"k"
] | A generator that provides all the names of tables that can be
reached via merges starting at the given target table. | [
"A",
"generator",
"that",
"provides",
"all",
"the",
"names",
"of",
"tables",
"that",
"can",
"be",
"reached",
"via",
"merges",
"starting",
"at",
"the",
"given",
"target",
"table",
"."
] | python | train |
MichaelAquilina/S4 | s4/clients/__init__.py | https://github.com/MichaelAquilina/S4/blob/05d74697e6ec683f0329c983f7c3f05ab75fd57e/s4/clients/__init__.py#L191-L201 | def get_action(self, key):
"""
returns the action to perform on this key based on its
state before the last sync.
"""
index_local_timestamp = self.get_index_local_timestamp(key)
real_local_timestamp = self.get_real_local_timestamp(key)
remote_timestamp = self.get_... | [
"def",
"get_action",
"(",
"self",
",",
"key",
")",
":",
"index_local_timestamp",
"=",
"self",
".",
"get_index_local_timestamp",
"(",
"key",
")",
"real_local_timestamp",
"=",
"self",
".",
"get_real_local_timestamp",
"(",
"key",
")",
"remote_timestamp",
"=",
"self",... | returns the action to perform on this key based on its
state before the last sync. | [
"returns",
"the",
"action",
"to",
"perform",
"on",
"this",
"key",
"based",
"on",
"its",
"state",
"before",
"the",
"last",
"sync",
"."
] | python | train |
uogbuji/amara3-xml | pylib/uxml/uxpath/ast.py | https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/ast.py#L135-L157 | def to_boolean(obj):
'''
Cast an arbitrary sequence to a boolean type
'''
#if hasattr(obj, '__iter__'):
if isinstance(obj, LiteralWrapper):
val = obj.obj
elif isinstance(obj, Iterable) and not isinstance(obj, str):
val = next(obj, None)
else:
val = obj
if val is N... | [
"def",
"to_boolean",
"(",
"obj",
")",
":",
"#if hasattr(obj, '__iter__'):",
"if",
"isinstance",
"(",
"obj",
",",
"LiteralWrapper",
")",
":",
"val",
"=",
"obj",
".",
"obj",
"elif",
"isinstance",
"(",
"obj",
",",
"Iterable",
")",
"and",
"not",
"isinstance",
... | Cast an arbitrary sequence to a boolean type | [
"Cast",
"an",
"arbitrary",
"sequence",
"to",
"a",
"boolean",
"type"
] | python | test |
LaoLiulaoliu/pgwrapper | pgwrapper/pgwrapper.py | https://github.com/LaoLiulaoliu/pgwrapper/blob/063a164713b79bfadb56a01c4ae19911f508d01e/pgwrapper/pgwrapper.py#L173-L200 | def joint(self, table, fields,
join_table, join_fields,
condition_field, condition_join_field,
join_method='left_join'):
""".. :py:method::
Usage::
>>> joint('user', 'name, id_number', 'medical_card', 'number', 'id', 'user_id', 'i... | [
"def",
"joint",
"(",
"self",
",",
"table",
",",
"fields",
",",
"join_table",
",",
"join_fields",
",",
"condition_field",
",",
"condition_join_field",
",",
"join_method",
"=",
"'left_join'",
")",
":",
"import",
"string",
"fields",
"=",
"map",
"(",
"string",
"... | .. :py:method::
Usage::
>>> joint('user', 'name, id_number', 'medical_card', 'number', 'id', 'user_id', 'inner_join')
select u.name, u.id_number, v.number from user as u inner join medical_card as v on u.id=v.user_id; | [
"..",
":",
"py",
":",
"method",
"::"
] | python | train |
josuebrunel/yahoo-oauth | yahoo_oauth/utils.py | https://github.com/josuebrunel/yahoo-oauth/blob/40eff7809366850c46e1a3340469044f33cd1713/yahoo_oauth/utils.py#L29-L34 | def get_data(filename):
"""Calls right function according to file extension
"""
name, ext = get_file_extension(filename)
func = json_get_data if ext == '.json' else yaml_get_data
return func(filename) | [
"def",
"get_data",
"(",
"filename",
")",
":",
"name",
",",
"ext",
"=",
"get_file_extension",
"(",
"filename",
")",
"func",
"=",
"json_get_data",
"if",
"ext",
"==",
"'.json'",
"else",
"yaml_get_data",
"return",
"func",
"(",
"filename",
")"
] | Calls right function according to file extension | [
"Calls",
"right",
"function",
"according",
"to",
"file",
"extension"
] | python | valid |
cuihantao/andes | andes/models/wind.py | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/wind.py#L82-L101 | def windspeed(self, t):
"""Return the wind speed list at time `t`"""
ws = [0] * self.n
for i in range(self.n):
q = ceil(t / self.dt[i])
q_prev = 0 if q == 0 else q - 1
r = t % self.dt[i]
r = 0 if abs(r) < 1e-6 else r
if r == 0:
... | [
"def",
"windspeed",
"(",
"self",
",",
"t",
")",
":",
"ws",
"=",
"[",
"0",
"]",
"*",
"self",
".",
"n",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n",
")",
":",
"q",
"=",
"ceil",
"(",
"t",
"/",
"self",
".",
"dt",
"[",
"i",
"]",
")",
"q... | Return the wind speed list at time `t` | [
"Return",
"the",
"wind",
"speed",
"list",
"at",
"time",
"t"
] | python | train |
dossier/dossier.models | dossier/models/web/routes.py | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L345-L393 | def v1_highlights_get(response, kvlclient, file_id_str, max_elapsed = 300):
'''Obtain highlights for a document POSTed previously to this end
point. See documentation for v1_highlights_post for further
details. If the `state` is still `pending` for more than
`max_elapsed` after the start of the `WorkU... | [
"def",
"v1_highlights_get",
"(",
"response",
",",
"kvlclient",
",",
"file_id_str",
",",
"max_elapsed",
"=",
"300",
")",
":",
"file_id",
"=",
"make_file_id",
"(",
"file_id_str",
")",
"kvlclient",
".",
"setup_namespace",
"(",
"highlights_kvlayer_tables",
")",
"paylo... | Obtain highlights for a document POSTed previously to this end
point. See documentation for v1_highlights_post for further
details. If the `state` is still `pending` for more than
`max_elapsed` after the start of the `WorkUnit`, then this reports
an error, although the `WorkUnit` may continue in the b... | [
"Obtain",
"highlights",
"for",
"a",
"document",
"POSTed",
"previously",
"to",
"this",
"end",
"point",
".",
"See",
"documentation",
"for",
"v1_highlights_post",
"for",
"further",
"details",
".",
"If",
"the",
"state",
"is",
"still",
"pending",
"for",
"more",
"th... | python | train |
limodou/uliweb | uliweb/utils/xltools.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/xltools.py#L945-L952 | def read(self):
"""
:param find: 是否使用find模式.True为递归查找.缺省为False
:param begin: 开始行号. 缺省为 None, 表示使用模板计算的位置
"""
for sheet in self.get_sheet():
for row in self.template.read_data(sheet, begin=self.begin):
yield row | [
"def",
"read",
"(",
"self",
")",
":",
"for",
"sheet",
"in",
"self",
".",
"get_sheet",
"(",
")",
":",
"for",
"row",
"in",
"self",
".",
"template",
".",
"read_data",
"(",
"sheet",
",",
"begin",
"=",
"self",
".",
"begin",
")",
":",
"yield",
"row"
] | :param find: 是否使用find模式.True为递归查找.缺省为False
:param begin: 开始行号. 缺省为 None, 表示使用模板计算的位置 | [
":",
"param",
"find",
":",
"是否使用find模式",
".",
"True为递归查找",
".",
"缺省为False",
":",
"param",
"begin",
":",
"开始行号",
".",
"缺省为",
"None",
"表示使用模板计算的位置"
] | python | train |
david-caro/python-autosemver | autosemver/api.py | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/api.py#L223-L267 | def tag_versions(repo_path):
"""
Given a repo will add a tag for each major version.
Args:
repo_path(str): path to the git repository to tag.
"""
repo = dulwich.repo.Repo(repo_path)
tags = get_tags(repo)
maj_version = 0
feat_version = 0
fix_version = 0
last_maj_version =... | [
"def",
"tag_versions",
"(",
"repo_path",
")",
":",
"repo",
"=",
"dulwich",
".",
"repo",
".",
"Repo",
"(",
"repo_path",
")",
"tags",
"=",
"get_tags",
"(",
"repo",
")",
"maj_version",
"=",
"0",
"feat_version",
"=",
"0",
"fix_version",
"=",
"0",
"last_maj_v... | Given a repo will add a tag for each major version.
Args:
repo_path(str): path to the git repository to tag. | [
"Given",
"a",
"repo",
"will",
"add",
"a",
"tag",
"for",
"each",
"major",
"version",
"."
] | python | train |
gem/oq-engine | openquake/calculators/getters.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/getters.py#L189-L212 | def get_mean(self, grp=None):
"""
Compute the mean curve as a ProbabilityMap
:param grp:
if not None must be a string of the form "grp-XX"; in that case
returns the mean considering only the contribution for group XX
"""
self.init()
if len(self.we... | [
"def",
"get_mean",
"(",
"self",
",",
"grp",
"=",
"None",
")",
":",
"self",
".",
"init",
"(",
")",
"if",
"len",
"(",
"self",
".",
"weights",
")",
"==",
"1",
":",
"# one realization",
"# the standard deviation is zero",
"pmap",
"=",
"self",
".",
"get",
"... | Compute the mean curve as a ProbabilityMap
:param grp:
if not None must be a string of the form "grp-XX"; in that case
returns the mean considering only the contribution for group XX | [
"Compute",
"the",
"mean",
"curve",
"as",
"a",
"ProbabilityMap"
] | python | train |
stevelittlefish/littlefish | littlefish/colourutil.py | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/colourutil.py#L13-L49 | def rgb_to_hsl(r, g, b):
"""
Converts an RGB color value to HSL.
:param r: The red color value
:param g: The green color value
:param b: The blue color value
:return: The HSL representation
"""
r = float(r) / 255.0
g = float(g) / 255.0
b = float(b) / 255.0
max_value = max(r,... | [
"def",
"rgb_to_hsl",
"(",
"r",
",",
"g",
",",
"b",
")",
":",
"r",
"=",
"float",
"(",
"r",
")",
"/",
"255.0",
"g",
"=",
"float",
"(",
"g",
")",
"/",
"255.0",
"b",
"=",
"float",
"(",
"b",
")",
"/",
"255.0",
"max_value",
"=",
"max",
"(",
"r",
... | Converts an RGB color value to HSL.
:param r: The red color value
:param g: The green color value
:param b: The blue color value
:return: The HSL representation | [
"Converts",
"an",
"RGB",
"color",
"value",
"to",
"HSL",
".",
":",
"param",
"r",
":",
"The",
"red",
"color",
"value",
":",
"param",
"g",
":",
"The",
"green",
"color",
"value",
":",
"param",
"b",
":",
"The",
"blue",
"color",
"value",
":",
"return",
"... | python | test |
Chilipp/model-organization | model_organization/__init__.py | https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L418-L471 | def init(self, projectname=None, description=None, **kwargs):
"""
Initialize a new experiment
Parameters
----------
projectname: str
The name of the project that shall be used. If None, the last one
created will be used
description: str
... | [
"def",
"init",
"(",
"self",
",",
"projectname",
"=",
"None",
",",
"description",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"app_main",
"(",
"*",
"*",
"kwargs",
")",
"experiments",
"=",
"self",
".",
"config",
".",
"experiments",
"ex... | Initialize a new experiment
Parameters
----------
projectname: str
The name of the project that shall be used. If None, the last one
created will be used
description: str
A short summary of the experiment
``**kwargs``
Keyword argum... | [
"Initialize",
"a",
"new",
"experiment"
] | python | train |
soravux/scoop | scoop/futures.py | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/futures.py#L47-L69 | def _startup(rootFuture, *args, **kargs):
"""Initializes the SCOOP environment.
:param rootFuture: Any callable object (function or class object with *__call__*
method); this object will be called once and allows the use of parallel
calls inside this object.
:param args: A tuple of position... | [
"def",
"_startup",
"(",
"rootFuture",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"import",
"greenlet",
"global",
"_controller",
"_controller",
"=",
"greenlet",
".",
"greenlet",
"(",
"control",
".",
"runController",
")",
"try",
":",
"result",
"=",
... | Initializes the SCOOP environment.
:param rootFuture: Any callable object (function or class object with *__call__*
method); this object will be called once and allows the use of parallel
calls inside this object.
:param args: A tuple of positional arguments that will be passed to the
c... | [
"Initializes",
"the",
"SCOOP",
"environment",
"."
] | python | train |
saltstack/salt | salt/modules/netbox.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L1070-L1113 | def create_circuit(name, provider_id, circuit_type, description=None):
'''
.. versionadded:: 2019.2.0
Create a new Netbox circuit
name
Name of the circuit
provider_id
The netbox id of the circuit provider
circuit_type
The name of the circuit type
asn
The ASN... | [
"def",
"create_circuit",
"(",
"name",
",",
"provider_id",
",",
"circuit_type",
",",
"description",
"=",
"None",
")",
":",
"nb_circuit_provider",
"=",
"get_",
"(",
"'circuits'",
",",
"'providers'",
",",
"provider_id",
")",
"nb_circuit_type",
"=",
"get_",
"(",
"... | .. versionadded:: 2019.2.0
Create a new Netbox circuit
name
Name of the circuit
provider_id
The netbox id of the circuit provider
circuit_type
The name of the circuit type
asn
The ASN of the circuit provider
description
The description of the circuit
... | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train |
lago-project/lago | lago/providers/libvirt/utils.py | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/providers/libvirt/utils.py#L145-L158 | def dict_to_xml(spec, full_document=False):
"""
Convert dict to XML
Args:
spec(dict): dict to convert
full_document(bool): whether to add XML headers
Returns:
lxml.etree.Element: XML tree
"""
middle = xmltodict.unparse(spec, full_document=full_document, pretty=True)
... | [
"def",
"dict_to_xml",
"(",
"spec",
",",
"full_document",
"=",
"False",
")",
":",
"middle",
"=",
"xmltodict",
".",
"unparse",
"(",
"spec",
",",
"full_document",
"=",
"full_document",
",",
"pretty",
"=",
"True",
")",
"return",
"lxml",
".",
"etree",
".",
"f... | Convert dict to XML
Args:
spec(dict): dict to convert
full_document(bool): whether to add XML headers
Returns:
lxml.etree.Element: XML tree | [
"Convert",
"dict",
"to",
"XML"
] | python | train |
MonashBI/arcana | arcana/study/base.py | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L669-L697 | def save_workflow_graph_for(self, spec_name, fname, full=False,
style='flat', **kwargs):
"""
Saves a graph of the workflow to generate the requested spec_name
Parameters
----------
spec_name : str
Name of the spec to generate the graph... | [
"def",
"save_workflow_graph_for",
"(",
"self",
",",
"spec_name",
",",
"fname",
",",
"full",
"=",
"False",
",",
"style",
"=",
"'flat'",
",",
"*",
"*",
"kwargs",
")",
":",
"pipeline",
"=",
"self",
".",
"spec",
"(",
"spec_name",
")",
".",
"pipeline",
"if"... | Saves a graph of the workflow to generate the requested spec_name
Parameters
----------
spec_name : str
Name of the spec to generate the graph for
fname : str
The filename for the saved graph
style : str
The style of the graph, can be one of c... | [
"Saves",
"a",
"graph",
"of",
"the",
"workflow",
"to",
"generate",
"the",
"requested",
"spec_name"
] | python | train |
pypa/pipenv | pipenv/vendor/cerberus/validator.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/cerberus/validator.py#L769-L773 | def _normalize_rename(self, mapping, schema, field):
""" {'type': 'hashable'} """
if 'rename' in schema[field]:
mapping[schema[field]['rename']] = mapping[field]
del mapping[field] | [
"def",
"_normalize_rename",
"(",
"self",
",",
"mapping",
",",
"schema",
",",
"field",
")",
":",
"if",
"'rename'",
"in",
"schema",
"[",
"field",
"]",
":",
"mapping",
"[",
"schema",
"[",
"field",
"]",
"[",
"'rename'",
"]",
"]",
"=",
"mapping",
"[",
"fi... | {'type': 'hashable'} | [
"{",
"type",
":",
"hashable",
"}"
] | python | train |
matthewdeanmartin/jiggle_version | jiggle_version/jiggle_class.py | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/jiggle_class.py#L356-L389 | def jiggle_config_file(self): # type: () ->int
"""
Update ini, cfg, conf
"""
changed = 0
# setup.py related. setup.py itself should read __init__.py or __version__.py
other_files = ["setup.cfg"]
for file_name in other_files:
filepath = os.path.join(... | [
"def",
"jiggle_config_file",
"(",
"self",
")",
":",
"# type: () ->int",
"changed",
"=",
"0",
"# setup.py related. setup.py itself should read __init__.py or __version__.py",
"other_files",
"=",
"[",
"\"setup.cfg\"",
"]",
"for",
"file_name",
"in",
"other_files",
":",
"filepa... | Update ini, cfg, conf | [
"Update",
"ini",
"cfg",
"conf"
] | python | train |
KrzyHonk/bpmn-python | bpmn_python/bpmn_diagram_rep.py | https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_rep.py#L404-L414 | def add_event_definition_element(event_type, event_definitions):
"""
Helper function, that creates event definition element (special type of event) from given parameters.
:param event_type: string object. Short name of required event definition,
:param event_definitions: dictionary of e... | [
"def",
"add_event_definition_element",
"(",
"event_type",
",",
"event_definitions",
")",
":",
"event_def_id",
"=",
"BpmnDiagramGraph",
".",
"id_prefix",
"+",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"event_def",
"=",
"{",
"consts",
".",
"Consts",
".",
... | Helper function, that creates event definition element (special type of event) from given parameters.
:param event_type: string object. Short name of required event definition,
:param event_definitions: dictionary of event definitions. Key is a short name of event definition,
value is a full... | [
"Helper",
"function",
"that",
"creates",
"event",
"definition",
"element",
"(",
"special",
"type",
"of",
"event",
")",
"from",
"given",
"parameters",
"."
] | python | train |
buildbot/buildbot | master/buildbot/process/builder.py | https://github.com/buildbot/buildbot/blob/5df3cfae6d760557d99156633c32b1822a1e130c/master/buildbot/process/builder.py#L144-L156 | def getOldestRequestTime(self):
"""Returns the submitted_at of the oldest unclaimed build request for
this builder, or None if there are no build requests.
@returns: datetime instance or None, via Deferred
"""
bldrid = yield self.getBuilderId()
unclaimed = yield self.mas... | [
"def",
"getOldestRequestTime",
"(",
"self",
")",
":",
"bldrid",
"=",
"yield",
"self",
".",
"getBuilderId",
"(",
")",
"unclaimed",
"=",
"yield",
"self",
".",
"master",
".",
"data",
".",
"get",
"(",
"(",
"'builders'",
",",
"bldrid",
",",
"'buildrequests'",
... | Returns the submitted_at of the oldest unclaimed build request for
this builder, or None if there are no build requests.
@returns: datetime instance or None, via Deferred | [
"Returns",
"the",
"submitted_at",
"of",
"the",
"oldest",
"unclaimed",
"build",
"request",
"for",
"this",
"builder",
"or",
"None",
"if",
"there",
"are",
"no",
"build",
"requests",
"."
] | python | train |
econ-ark/HARK | HARK/ConsumptionSaving/ConsIndShockModel.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsIndShockModel.py#L977-L994 | def solve(self):
'''
Solves a one period consumption saving problem with risky income.
Parameters
----------
None
Returns
-------
solution : ConsumerSolution
The solution to the one period problem.
'''
aNrm = self.prepar... | [
"def",
"solve",
"(",
"self",
")",
":",
"aNrm",
"=",
"self",
".",
"prepareToCalcEndOfPrdvP",
"(",
")",
"EndOfPrdvP",
"=",
"self",
".",
"calcEndOfPrdvP",
"(",
")",
"solution",
"=",
"self",
".",
"makeBasicSolution",
"(",
"EndOfPrdvP",
",",
"aNrm",
",",
"self"... | Solves a one period consumption saving problem with risky income.
Parameters
----------
None
Returns
-------
solution : ConsumerSolution
The solution to the one period problem. | [
"Solves",
"a",
"one",
"period",
"consumption",
"saving",
"problem",
"with",
"risky",
"income",
"."
] | python | train |
aquatix/python-utilkit | utilkit/printutil.py | https://github.com/aquatix/python-utilkit/blob/1b4a4175381d2175592208619315f399610f915c/utilkit/printutil.py#L87-L110 | def merge_x_y(collection_x, collection_y, filter_none=False):
"""
Merge two lists, creating a dictionary with key `label` and a set x and y
"""
data = {}
for item in collection_x:
#print item[0:-1]
#print item[-1]
label = datetimeutil.tuple_to_string(item[0:-1])
if fi... | [
"def",
"merge_x_y",
"(",
"collection_x",
",",
"collection_y",
",",
"filter_none",
"=",
"False",
")",
":",
"data",
"=",
"{",
"}",
"for",
"item",
"in",
"collection_x",
":",
"#print item[0:-1]",
"#print item[-1]",
"label",
"=",
"datetimeutil",
".",
"tuple_to_string... | Merge two lists, creating a dictionary with key `label` and a set x and y | [
"Merge",
"two",
"lists",
"creating",
"a",
"dictionary",
"with",
"key",
"label",
"and",
"a",
"set",
"x",
"and",
"y"
] | python | train |
ungarj/mapchete | mapchete/config.py | https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/config.py#L248-L263 | def effective_bounds(self):
"""
Effective process bounds required to initialize inputs.
Process bounds sometimes have to be larger, because all intersecting process
tiles have to be covered as well.
"""
return snap_bounds(
bounds=clip_bounds(bounds=self.init_... | [
"def",
"effective_bounds",
"(",
"self",
")",
":",
"return",
"snap_bounds",
"(",
"bounds",
"=",
"clip_bounds",
"(",
"bounds",
"=",
"self",
".",
"init_bounds",
",",
"clip",
"=",
"self",
".",
"process_pyramid",
".",
"bounds",
")",
",",
"pyramid",
"=",
"self",... | Effective process bounds required to initialize inputs.
Process bounds sometimes have to be larger, because all intersecting process
tiles have to be covered as well. | [
"Effective",
"process",
"bounds",
"required",
"to",
"initialize",
"inputs",
"."
] | python | valid |
saltstack/salt | salt/cloud/clouds/joyent.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/joyent.py#L917-L960 | def import_key(kwargs=None, call=None):
'''
List the keys available
CLI Example:
.. code-block:: bash
salt-cloud -f import_key joyent keyname=mykey keyfile=/tmp/mykey.pub
'''
if call != 'function':
log.error(
'The import_key function must be called with -f or --fun... | [
"def",
"import_key",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"log",
".",
"error",
"(",
"'The import_key function must be called with -f or --function.'",
")",
"return",
"False",
"if",
"not",
"kwargs"... | List the keys available
CLI Example:
.. code-block:: bash
salt-cloud -f import_key joyent keyname=mykey keyfile=/tmp/mykey.pub | [
"List",
"the",
"keys",
"available"
] | python | train |
RockFeng0/rtsf | rtsf/p_executer.py | https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_executer.py#L227-L243 | def init_runner(self, parser, tracers, projinfo):
''' initial some instances for preparing to run test case
@note: should not override
@param parser: instance of TestCaseParser
@param tracers: dict type for the instance of Tracer. Such as {"":tracer_obj} or {"192.168.0.1:5555":trace... | [
"def",
"init_runner",
"(",
"self",
",",
"parser",
",",
"tracers",
",",
"projinfo",
")",
":",
"self",
".",
"parser",
"=",
"parser",
"self",
".",
"tracers",
"=",
"tracers",
"self",
".",
"proj_info",
"=",
"projinfo"
] | initial some instances for preparing to run test case
@note: should not override
@param parser: instance of TestCaseParser
@param tracers: dict type for the instance of Tracer. Such as {"":tracer_obj} or {"192.168.0.1:5555":tracer_obj1, "192.168.0.2:5555":tracer_obj2}
@param proj_i... | [
"initial",
"some",
"instances",
"for",
"preparing",
"to",
"run",
"test",
"case"
] | python | train |
spyder-ide/spyder | spyder/widgets/arraybuilder.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/arraybuilder.py#L297-L369 | def process_text(self, array=True):
"""
Construct the text based on the entered content in the widget.
"""
if array:
prefix = 'np.array([['
else:
prefix = 'np.matrix([['
suffix = ']])'
values = self._widget.text().strip()
... | [
"def",
"process_text",
"(",
"self",
",",
"array",
"=",
"True",
")",
":",
"if",
"array",
":",
"prefix",
"=",
"'np.array([['",
"else",
":",
"prefix",
"=",
"'np.matrix([['",
"suffix",
"=",
"']])'",
"values",
"=",
"self",
".",
"_widget",
".",
"text",
"(",
... | Construct the text based on the entered content in the widget. | [
"Construct",
"the",
"text",
"based",
"on",
"the",
"entered",
"content",
"in",
"the",
"widget",
"."
] | python | train |
fr33jc/bang | bang/providers/openstack/__init__.py | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L189-L262 | def create_server(self, basename, disk_image_id, instance_type,
ssh_key_name, tags=None, availability_zone=None,
timeout_s=DEFAULT_TIMEOUT_S, floating_ip=True,
**kwargs):
"""
Creates a new server instance. This call blocks until the server is
created and avai... | [
"def",
"create_server",
"(",
"self",
",",
"basename",
",",
"disk_image_id",
",",
"instance_type",
",",
"ssh_key_name",
",",
"tags",
"=",
"None",
",",
"availability_zone",
"=",
"None",
",",
"timeout_s",
"=",
"DEFAULT_TIMEOUT_S",
",",
"floating_ip",
"=",
"True",
... | Creates a new server instance. This call blocks until the server is
created and available for normal use, or :attr:`timeout_s` has elapsed.
:param str basename: An identifier for the server. A random postfix
will be appended to this basename to work around OpenStack Nova
REST... | [
"Creates",
"a",
"new",
"server",
"instance",
".",
"This",
"call",
"blocks",
"until",
"the",
"server",
"is",
"created",
"and",
"available",
"for",
"normal",
"use",
"or",
":",
"attr",
":",
"timeout_s",
"has",
"elapsed",
"."
] | python | train |
AshleySetter/optoanalysis | optoanalysis/optoanalysis/optoanalysis.py | https://github.com/AshleySetter/optoanalysis/blob/9d390acc834d70024d47b574aea14189a5a5714e/optoanalysis/optoanalysis/optoanalysis.py#L2787-L2812 | def butterworth_filter(Signal, SampleFreq, lowerFreq, upperFreq):
"""
Filters data using by constructing a 5th order butterworth
IIR filter and using scipy.signal.filtfilt, which does
phase correction after implementing the filter (as IIR
filter apply a phase change)
Parameters
----------
... | [
"def",
"butterworth_filter",
"(",
"Signal",
",",
"SampleFreq",
",",
"lowerFreq",
",",
"upperFreq",
")",
":",
"b",
",",
"a",
"=",
"make_butterworth_b_a",
"(",
"lowerFreq",
",",
"upperFreq",
",",
"SampleFreq",
")",
"FilteredSignal",
"=",
"scipy",
".",
"signal",
... | Filters data using by constructing a 5th order butterworth
IIR filter and using scipy.signal.filtfilt, which does
phase correction after implementing the filter (as IIR
filter apply a phase change)
Parameters
----------
Signal : ndarray
Signal to be filtered
SampleFreq : float
... | [
"Filters",
"data",
"using",
"by",
"constructing",
"a",
"5th",
"order",
"butterworth",
"IIR",
"filter",
"and",
"using",
"scipy",
".",
"signal",
".",
"filtfilt",
"which",
"does",
"phase",
"correction",
"after",
"implementing",
"the",
"filter",
"(",
"as",
"IIR",
... | python | train |
openstack/proliantutils | proliantutils/ilo/snmp/snmp_cpqdisk_sizes.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/snmp/snmp_cpqdisk_sizes.py#L55-L100 | def _create_usm_user_obj(snmp_cred):
"""Creates the UsmUserData obj for the given credentials.
This method creates an instance for the method hlapi.UsmUserData.
The UsmUserData() allows the 'auth_protocol' and 'priv_protocol'
to be undefined by user if their pass phrases are provided.
:param snmp_... | [
"def",
"_create_usm_user_obj",
"(",
"snmp_cred",
")",
":",
"auth_protocol",
"=",
"snmp_cred",
".",
"get",
"(",
"'auth_protocol'",
")",
"priv_protocol",
"=",
"snmp_cred",
".",
"get",
"(",
"'priv_protocol'",
")",
"auth_user",
"=",
"snmp_cred",
".",
"get",
"(",
"... | Creates the UsmUserData obj for the given credentials.
This method creates an instance for the method hlapi.UsmUserData.
The UsmUserData() allows the 'auth_protocol' and 'priv_protocol'
to be undefined by user if their pass phrases are provided.
:param snmp_cred: Dictionary of SNMP credentials.
... | [
"Creates",
"the",
"UsmUserData",
"obj",
"for",
"the",
"given",
"credentials",
"."
] | python | train |
carsongee/flask-htpasswd | flask_htpasswd.py | https://github.com/carsongee/flask-htpasswd/blob/db6fe596dd167f33aeb3d77e975c861d0534cecf/flask_htpasswd.py#L194-L208 | def required(self, func):
"""
Decorator function with basic and token authentication handler
"""
@wraps(func)
def decorated(*args, **kwargs):
"""
Actual wrapper to run the auth checks.
"""
is_valid, user = self.authenticate()
... | [
"def",
"required",
"(",
"self",
",",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"\n Actual wrapper to run the auth checks.\n \"\"\"",
"is_valid",
",",
"us... | Decorator function with basic and token authentication handler | [
"Decorator",
"function",
"with",
"basic",
"and",
"token",
"authentication",
"handler"
] | python | train |
pysal/spglm | spglm/links.py | https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L623-L632 | def deriv2(self, p):
"""
Second derivative of the link function g''(p)
implemented through numerical differentiation
"""
from statsmodels.tools.numdiff import approx_fprime
p = np.atleast_1d(p)
# Note: special function for norm.ppf does not support complex
... | [
"def",
"deriv2",
"(",
"self",
",",
"p",
")",
":",
"from",
"statsmodels",
".",
"tools",
".",
"numdiff",
"import",
"approx_fprime",
"p",
"=",
"np",
".",
"atleast_1d",
"(",
"p",
")",
"# Note: special function for norm.ppf does not support complex",
"return",
"np",
... | Second derivative of the link function g''(p)
implemented through numerical differentiation | [
"Second",
"derivative",
"of",
"the",
"link",
"function",
"g",
"(",
"p",
")"
] | python | train |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2029-L2033 | def help_center_vote_delete(self, id, **kwargs):
"https://developer.zendesk.com/rest_api/docs/help_center/votes#delete-vote"
api_path = "/api/v2/help_center/votes/{id}.json"
api_path = api_path.format(id=id)
return self.call(api_path, method="DELETE", **kwargs) | [
"def",
"help_center_vote_delete",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/help_center/votes/{id}.json\"",
"api_path",
"=",
"api_path",
".",
"format",
"(",
"id",
"=",
"id",
")",
"return",
"self",
".",
"call",
"("... | https://developer.zendesk.com/rest_api/docs/help_center/votes#delete-vote | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"help_center",
"/",
"votes#delete",
"-",
"vote"
] | python | train |
seung-lab/cloud-volume | cloudvolume/storage.py | https://github.com/seung-lab/cloud-volume/blob/d2fd4500333f1bc3cd3e3919a8b649cec5d8e214/cloudvolume/storage.py#L626-L641 | def list_files(self, prefix, flat=False):
"""
List the files in the layer with the given prefix.
flat means only generate one level of a directory,
while non-flat means generate all file paths with that
prefix.
"""
layer_path = self.get_path_to_file("")
path = os.path.join(lay... | [
"def",
"list_files",
"(",
"self",
",",
"prefix",
",",
"flat",
"=",
"False",
")",
":",
"layer_path",
"=",
"self",
".",
"get_path_to_file",
"(",
"\"\"",
")",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"layer_path",
",",
"prefix",
")",
"for",
"bl... | List the files in the layer with the given prefix.
flat means only generate one level of a directory,
while non-flat means generate all file paths with that
prefix. | [
"List",
"the",
"files",
"in",
"the",
"layer",
"with",
"the",
"given",
"prefix",
"."
] | python | train |
caseyjlaw/rtpipe | rtpipe/parsecands.py | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L199-L208 | def cleanup(workdir, fileroot, scans=[]):
""" Cleanup up noise and cands files.
Finds all segments in each scan and merges them into single cand/noise file per scan.
"""
os.chdir(workdir)
# merge cands/noise files per scan
for scan in scans:
merge_segments(fileroot, scan, cleanup=True,... | [
"def",
"cleanup",
"(",
"workdir",
",",
"fileroot",
",",
"scans",
"=",
"[",
"]",
")",
":",
"os",
".",
"chdir",
"(",
"workdir",
")",
"# merge cands/noise files per scan",
"for",
"scan",
"in",
"scans",
":",
"merge_segments",
"(",
"fileroot",
",",
"scan",
",",... | Cleanup up noise and cands files.
Finds all segments in each scan and merges them into single cand/noise file per scan. | [
"Cleanup",
"up",
"noise",
"and",
"cands",
"files",
".",
"Finds",
"all",
"segments",
"in",
"each",
"scan",
"and",
"merges",
"them",
"into",
"single",
"cand",
"/",
"noise",
"file",
"per",
"scan",
"."
] | python | train |
Parsl/parsl | parsl/monitoring/db_manager.py | https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/monitoring/db_manager.py#L374-L402 | def start_file_logger(filename, name='database_manager', level=logging.DEBUG, format_string=None):
"""Add a stream log handler.
Parameters
---------
filename: string
Name of the file to write logs to. Required.
name: string
Logger name. Default="parsl.executors.interchange"
level... | [
"def",
"start_file_logger",
"(",
"filename",
",",
"name",
"=",
"'database_manager'",
",",
"level",
"=",
"logging",
".",
"DEBUG",
",",
"format_string",
"=",
"None",
")",
":",
"if",
"format_string",
"is",
"None",
":",
"format_string",
"=",
"\"%(asctime)s %(name)s:... | Add a stream log handler.
Parameters
---------
filename: string
Name of the file to write logs to. Required.
name: string
Logger name. Default="parsl.executors.interchange"
level: logging.LEVEL
Set the logging level. Default=logging.DEBUG
- format_string (string): Set... | [
"Add",
"a",
"stream",
"log",
"handler",
".",
"Parameters",
"---------",
"filename",
":",
"string",
"Name",
"of",
"the",
"file",
"to",
"write",
"logs",
"to",
".",
"Required",
".",
"name",
":",
"string",
"Logger",
"name",
".",
"Default",
"=",
"parsl",
".",... | python | valid |
jantman/awslimitchecker | awslimitchecker/services/route53.py | https://github.com/jantman/awslimitchecker/blob/e50197f70f3d0abcc5cfc7fde6336f548b790e34/awslimitchecker/services/route53.py#L127-L139 | def _get_hosted_zone_limit(self, limit_type, hosted_zone_id):
"""
Return a hosted zone limit [recordsets|vpc_associations]
:rtype: dict
"""
result = self.conn.get_hosted_zone_limit(
Type=limit_type,
HostedZoneId=hosted_zone_id
)
return r... | [
"def",
"_get_hosted_zone_limit",
"(",
"self",
",",
"limit_type",
",",
"hosted_zone_id",
")",
":",
"result",
"=",
"self",
".",
"conn",
".",
"get_hosted_zone_limit",
"(",
"Type",
"=",
"limit_type",
",",
"HostedZoneId",
"=",
"hosted_zone_id",
")",
"return",
"result... | Return a hosted zone limit [recordsets|vpc_associations]
:rtype: dict | [
"Return",
"a",
"hosted",
"zone",
"limit",
"[",
"recordsets|vpc_associations",
"]"
] | python | train |
baguette-io/baguette-messaging | farine/execute/method.py | https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/execute/method.py#L46-L54 | def start(self, *args, **kwargs):#pylint:disable=unused-argument
"""
Launch the method.
:param restart: Restart the method if it ends.
:type restart: bool
:rtype: None
"""
restart = kwargs.get('restart', True)
return self.run(restart) | [
"def",
"start",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint:disable=unused-argument",
"restart",
"=",
"kwargs",
".",
"get",
"(",
"'restart'",
",",
"True",
")",
"return",
"self",
".",
"run",
"(",
"restart",
")"
] | Launch the method.
:param restart: Restart the method if it ends.
:type restart: bool
:rtype: None | [
"Launch",
"the",
"method",
".",
":",
"param",
"restart",
":",
"Restart",
"the",
"method",
"if",
"it",
"ends",
".",
":",
"type",
"restart",
":",
"bool",
":",
"rtype",
":",
"None"
] | python | train |
pandas-dev/pandas | pandas/core/arrays/categorical.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2635-L2670 | def _factorize_from_iterable(values):
"""
Factorize an input `values` into `categories` and `codes`. Preserves
categorical dtype in `categories`.
*This is an internal function*
Parameters
----------
values : list-like
Returns
-------
codes : ndarray
categories : Index
... | [
"def",
"_factorize_from_iterable",
"(",
"values",
")",
":",
"from",
"pandas",
".",
"core",
".",
"indexes",
".",
"category",
"import",
"CategoricalIndex",
"if",
"not",
"is_list_like",
"(",
"values",
")",
":",
"raise",
"TypeError",
"(",
"\"Input must be list-like\""... | Factorize an input `values` into `categories` and `codes`. Preserves
categorical dtype in `categories`.
*This is an internal function*
Parameters
----------
values : list-like
Returns
-------
codes : ndarray
categories : Index
If `values` has a categorical dtype, then `cat... | [
"Factorize",
"an",
"input",
"values",
"into",
"categories",
"and",
"codes",
".",
"Preserves",
"categorical",
"dtype",
"in",
"categories",
"."
] | python | train |
persephone-tools/persephone | persephone/model.py | https://github.com/persephone-tools/persephone/blob/f94c63e4d5fe719fb1deba449b177bb299d225fb/persephone/model.py#L258-L299 | def eval(self, restore_model_path: Optional[str]=None) -> None:
""" Evaluates the model on a test set."""
saver = tf.train.Saver()
with tf.Session(config=allow_growth_config) as sess:
if restore_model_path:
logger.info("restoring model from %s", restore_model_path)
... | [
"def",
"eval",
"(",
"self",
",",
"restore_model_path",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"saver",
"=",
"tf",
".",
"train",
".",
"Saver",
"(",
")",
"with",
"tf",
".",
"Session",
"(",
"config",
"=",
"allow_growth_co... | Evaluates the model on a test set. | [
"Evaluates",
"the",
"model",
"on",
"a",
"test",
"set",
"."
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L15664-L15685 | def wnvald(insize, n, window):
"""
Form a valid double precision window from the contents
of a window array.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnvald_c.html
:param insize: Size of window.
:type insize: int
:param n: Original number of endpoints.
:type n: int
... | [
"def",
"wnvald",
"(",
"insize",
",",
"n",
",",
"window",
")",
":",
"assert",
"isinstance",
"(",
"window",
",",
"stypes",
".",
"SpiceCell",
")",
"assert",
"window",
".",
"dtype",
"==",
"1",
"insize",
"=",
"ctypes",
".",
"c_int",
"(",
"insize",
")",
"n... | Form a valid double precision window from the contents
of a window array.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnvald_c.html
:param insize: Size of window.
:type insize: int
:param n: Original number of endpoints.
:type n: int
:param window: Input window.
:type wi... | [
"Form",
"a",
"valid",
"double",
"precision",
"window",
"from",
"the",
"contents",
"of",
"a",
"window",
"array",
"."
] | python | train |
apache/spark | python/pyspark/cloudpickle.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/cloudpickle.py#L926-L936 | def dump(obj, file, protocol=None):
"""Serialize obj as bytes streamed into file
protocol defaults to cloudpickle.DEFAULT_PROTOCOL which is an alias to
pickle.HIGHEST_PROTOCOL. This setting favors maximum communication speed
between processes running the same Python version.
Set protocol=pickle.DE... | [
"def",
"dump",
"(",
"obj",
",",
"file",
",",
"protocol",
"=",
"None",
")",
":",
"CloudPickler",
"(",
"file",
",",
"protocol",
"=",
"protocol",
")",
".",
"dump",
"(",
"obj",
")"
] | Serialize obj as bytes streamed into file
protocol defaults to cloudpickle.DEFAULT_PROTOCOL which is an alias to
pickle.HIGHEST_PROTOCOL. This setting favors maximum communication speed
between processes running the same Python version.
Set protocol=pickle.DEFAULT_PROTOCOL instead if you need to ensur... | [
"Serialize",
"obj",
"as",
"bytes",
"streamed",
"into",
"file"
] | python | train |
PmagPy/PmagPy | programs/plot_cdf.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/plot_cdf.py#L12-L63 | def main():
"""
NAME
plot_cdf.py
DESCRIPTION
makes plots of cdfs of data in input file
SYNTAX
plot_cdf.py [-h][command line options]
OPTIONS
-h prints help message and quits
-f FILE
-t TITLE
-fmt [svg,eps,png,pdf,jpg..] specify format of ou... | [
"def",
"main",
"(",
")",
":",
"fmt",
",",
"plot",
"=",
"'svg'",
",",
"0",
"title",
"=",
"\"\"",
"if",
"'-h'",
"in",
"sys",
".",
"argv",
":",
"print",
"(",
"main",
".",
"__doc__",
")",
"sys",
".",
"exit",
"(",
")",
"if",
"'-sav'",
"in",
"sys",
... | NAME
plot_cdf.py
DESCRIPTION
makes plots of cdfs of data in input file
SYNTAX
plot_cdf.py [-h][command line options]
OPTIONS
-h prints help message and quits
-f FILE
-t TITLE
-fmt [svg,eps,png,pdf,jpg..] specify format of output figure, default is ... | [
"NAME",
"plot_cdf",
".",
"py"
] | python | train |
iotile/coretools | iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L164-L185 | def inspect_virtual(self, stream_id):
"""Inspect the last value written into a virtual stream.
Args:
stream_id (int): The virtual stream was want to inspect.
Returns:
(int, int): An error code and the stream value.
"""
stream = DataStream.FromEncoded(st... | [
"def",
"inspect_virtual",
"(",
"self",
",",
"stream_id",
")",
":",
"stream",
"=",
"DataStream",
".",
"FromEncoded",
"(",
"stream_id",
")",
"if",
"stream",
".",
"buffered",
":",
"return",
"[",
"pack_error",
"(",
"ControllerSubsystem",
".",
"SENSOR_LOG",
",",
... | Inspect the last value written into a virtual stream.
Args:
stream_id (int): The virtual stream was want to inspect.
Returns:
(int, int): An error code and the stream value. | [
"Inspect",
"the",
"last",
"value",
"written",
"into",
"a",
"virtual",
"stream",
"."
] | python | train |
NarrativeScience/lsi | src/lsi/utils/table.py | https://github.com/NarrativeScience/lsi/blob/7d901b03fdb1a34ef795e5412bfe9685d948e32d/src/lsi/utils/table.py#L146-L153 | def get_table_width(table):
"""
Gets the width of the table that would be printed.
:rtype: ``int``
"""
columns = transpose_table(prepare_rows(table))
widths = [max(len(cell) for cell in column) for column in columns]
return len('+' + '|'.join('-' * (w + 2) for w in widths) + '+') | [
"def",
"get_table_width",
"(",
"table",
")",
":",
"columns",
"=",
"transpose_table",
"(",
"prepare_rows",
"(",
"table",
")",
")",
"widths",
"=",
"[",
"max",
"(",
"len",
"(",
"cell",
")",
"for",
"cell",
"in",
"column",
")",
"for",
"column",
"in",
"colum... | Gets the width of the table that would be printed.
:rtype: ``int`` | [
"Gets",
"the",
"width",
"of",
"the",
"table",
"that",
"would",
"be",
"printed",
".",
":",
"rtype",
":",
"int"
] | python | test |
GPflow/GPflow | gpflow/likelihoods.py | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/likelihoods.py#L639-L665 | def predict_mean_and_var(self, Fmu, Fvar, epsilon=None):
r"""
Given a Normal distribution for the latent function,
return the mean of Y
if
q(f) = N(Fmu, Fvar)
and this object represents
p(y|f)
then this method computes the predictive mean
... | [
"def",
"predict_mean_and_var",
"(",
"self",
",",
"Fmu",
",",
"Fvar",
",",
"epsilon",
"=",
"None",
")",
":",
"integrand2",
"=",
"lambda",
"*",
"X",
":",
"self",
".",
"conditional_variance",
"(",
"*",
"X",
")",
"+",
"tf",
".",
"square",
"(",
"self",
".... | r"""
Given a Normal distribution for the latent function,
return the mean of Y
if
q(f) = N(Fmu, Fvar)
and this object represents
p(y|f)
then this method computes the predictive mean
\int\int y p(y|f)q(f) df dy
and the predictive va... | [
"r",
"Given",
"a",
"Normal",
"distribution",
"for",
"the",
"latent",
"function",
"return",
"the",
"mean",
"of",
"Y"
] | python | train |
saltstack/salt | salt/returners/cassandra_cql_return.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/cassandra_cql_return.py#L410-L437 | def get_jids():
'''
Return a list of all job ids
'''
query = '''SELECT jid, load FROM {keyspace}.jids;'''.format(keyspace=_get_keyspace())
ret = {}
# cassandra_cql.cql_query may raise a CommandExecutionError
try:
data = __salt__['cassandra_cql.cql_query'](query)
if data:
... | [
"def",
"get_jids",
"(",
")",
":",
"query",
"=",
"'''SELECT jid, load FROM {keyspace}.jids;'''",
".",
"format",
"(",
"keyspace",
"=",
"_get_keyspace",
"(",
")",
")",
"ret",
"=",
"{",
"}",
"# cassandra_cql.cql_query may raise a CommandExecutionError",
"try",
":",
"data"... | Return a list of all job ids | [
"Return",
"a",
"list",
"of",
"all",
"job",
"ids"
] | python | train |
pyGrowler/Growler | growler/core/router.py | https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/router.py#L137-L153 | def sinatra_path_to_regex(cls, path):
"""
Converts a sinatra-style path to a regex with named
parameters.
"""
# Return the path if already a (compiled) regex
if type(path) is cls.regex_type:
return path
# Build a regular expression string which is spl... | [
"def",
"sinatra_path_to_regex",
"(",
"cls",
",",
"path",
")",
":",
"# Return the path if already a (compiled) regex",
"if",
"type",
"(",
"path",
")",
"is",
"cls",
".",
"regex_type",
":",
"return",
"path",
"# Build a regular expression string which is split on the '/' charac... | Converts a sinatra-style path to a regex with named
parameters. | [
"Converts",
"a",
"sinatra",
"-",
"style",
"path",
"to",
"a",
"regex",
"with",
"named",
"parameters",
"."
] | python | train |
h2oai/typesentry | typesentry/signature.py | https://github.com/h2oai/typesentry/blob/0ca8ed0e62d15ffe430545e7648c9a9b2547b49c/typesentry/signature.py#L172-L186 | def _make_retval_checker(self):
"""Create a function that checks the return value of the function."""
rvchk = self.retval.checker
if rvchk:
def _checker(value):
if not rvchk.check(value):
raise self._type_error(
"Incorrect r... | [
"def",
"_make_retval_checker",
"(",
"self",
")",
":",
"rvchk",
"=",
"self",
".",
"retval",
".",
"checker",
"if",
"rvchk",
":",
"def",
"_checker",
"(",
"value",
")",
":",
"if",
"not",
"rvchk",
".",
"check",
"(",
"value",
")",
":",
"raise",
"self",
"."... | Create a function that checks the return value of the function. | [
"Create",
"a",
"function",
"that",
"checks",
"the",
"return",
"value",
"of",
"the",
"function",
"."
] | python | train |
kxgames/vecrec | vecrec/shapes.py | https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/shapes.py#L433-L438 | def get_components(self, other):
""" Break this vector into one vector that is perpendicular to the
given vector and another that is parallel to it. """
tangent = self.get_projection(other)
normal = self - tangent
return normal, tangent | [
"def",
"get_components",
"(",
"self",
",",
"other",
")",
":",
"tangent",
"=",
"self",
".",
"get_projection",
"(",
"other",
")",
"normal",
"=",
"self",
"-",
"tangent",
"return",
"normal",
",",
"tangent"
] | Break this vector into one vector that is perpendicular to the
given vector and another that is parallel to it. | [
"Break",
"this",
"vector",
"into",
"one",
"vector",
"that",
"is",
"perpendicular",
"to",
"the",
"given",
"vector",
"and",
"another",
"that",
"is",
"parallel",
"to",
"it",
"."
] | python | train |
gunthercox/ChatterBot | examples/tkinter_gui.py | https://github.com/gunthercox/ChatterBot/blob/1a03dcb45cba7bdc24d3db5e750582e0cb1518e2/examples/tkinter_gui.py#L51-L66 | def get_response(self):
"""
Get a response from the chatbot and display it.
"""
user_input = self.usr_input.get()
self.usr_input.delete(0, tk.END)
response = self.chatbot.get_response(user_input)
self.conversation['state'] = 'normal'
self.conversation.in... | [
"def",
"get_response",
"(",
"self",
")",
":",
"user_input",
"=",
"self",
".",
"usr_input",
".",
"get",
"(",
")",
"self",
".",
"usr_input",
".",
"delete",
"(",
"0",
",",
"tk",
".",
"END",
")",
"response",
"=",
"self",
".",
"chatbot",
".",
"get_respons... | Get a response from the chatbot and display it. | [
"Get",
"a",
"response",
"from",
"the",
"chatbot",
"and",
"display",
"it",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/core/states/container_state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/states/container_state.py#L2002-L2025 | def _check_transition_origin(self, transition):
"""Checks the validity of a transition origin
Checks whether the transition origin is valid.
:param rafcon.core.transition.Transition transition: The transition to be checked
:return bool validity, str message: validity is True, when the ... | [
"def",
"_check_transition_origin",
"(",
"self",
",",
"transition",
")",
":",
"from_state_id",
"=",
"transition",
".",
"from_state",
"from_outcome_id",
"=",
"transition",
".",
"from_outcome",
"if",
"from_state_id",
"==",
"self",
".",
"state_id",
":",
"return",
"Fal... | Checks the validity of a transition origin
Checks whether the transition origin is valid.
:param rafcon.core.transition.Transition transition: The transition to be checked
:return bool validity, str message: validity is True, when the transition is valid, False else. message gives
... | [
"Checks",
"the",
"validity",
"of",
"a",
"transition",
"origin"
] | python | train |
blockstack/zone-file-py | blockstack_zones/record_processors.py | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/record_processors.py#L15-L23 | def process_ttl(data, template):
"""
Replace {$ttl} in template with a serialized $TTL record
"""
record = ""
if data is not None:
record += "$TTL %s" % data
return template.replace("{$ttl}", record) | [
"def",
"process_ttl",
"(",
"data",
",",
"template",
")",
":",
"record",
"=",
"\"\"",
"if",
"data",
"is",
"not",
"None",
":",
"record",
"+=",
"\"$TTL %s\"",
"%",
"data",
"return",
"template",
".",
"replace",
"(",
"\"{$ttl}\"",
",",
"record",
")"
] | Replace {$ttl} in template with a serialized $TTL record | [
"Replace",
"{",
"$ttl",
"}",
"in",
"template",
"with",
"a",
"serialized",
"$TTL",
"record"
] | python | test |
PGower/PyCanvas | pycanvas/apis/courses.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/courses.py#L798-L868 | def update_course_settings(self, course_id, allow_student_discussion_editing=None, allow_student_discussion_topics=None, allow_student_forum_attachments=None, allow_student_organized_groups=None, hide_distribution_graphs=None, hide_final_grades=None, home_page_announcement_limit=None, lock_all_announcements=None, restr... | [
"def",
"update_course_settings",
"(",
"self",
",",
"course_id",
",",
"allow_student_discussion_editing",
"=",
"None",
",",
"allow_student_discussion_topics",
"=",
"None",
",",
"allow_student_forum_attachments",
"=",
"None",
",",
"allow_student_organized_groups",
"=",
"None"... | Update course settings.
Can update the following course settings: | [
"Update",
"course",
"settings",
".",
"Can",
"update",
"the",
"following",
"course",
"settings",
":"
] | python | train |
noirbizarre/bumpr | tasks.py | https://github.com/noirbizarre/bumpr/blob/221dbb3deaf1cae7922f6a477f3d29d6bf0c0035/tasks.py#L38-L41 | def header(text):
'''Display an header'''
print(' '.join((blue('>>'), cyan(text))))
sys.stdout.flush() | [
"def",
"header",
"(",
"text",
")",
":",
"print",
"(",
"' '",
".",
"join",
"(",
"(",
"blue",
"(",
"'>>'",
")",
",",
"cyan",
"(",
"text",
")",
")",
")",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
")"
] | Display an header | [
"Display",
"an",
"header"
] | python | train |
zyga/guacamole | guacamole/recipes/cmd.py | https://github.com/zyga/guacamole/blob/105c10a798144e3b89659b500d7c2b84b0c76546/guacamole/recipes/cmd.py#L387-L393 | def main(self, argv=None, exit=True):
"""
Shortcut for running a command.
See :meth:`guacamole.recipes.Recipe.main()` for details.
"""
return CommandRecipe(self).main(argv, exit) | [
"def",
"main",
"(",
"self",
",",
"argv",
"=",
"None",
",",
"exit",
"=",
"True",
")",
":",
"return",
"CommandRecipe",
"(",
"self",
")",
".",
"main",
"(",
"argv",
",",
"exit",
")"
] | Shortcut for running a command.
See :meth:`guacamole.recipes.Recipe.main()` for details. | [
"Shortcut",
"for",
"running",
"a",
"command",
"."
] | python | train |
GoogleCloudPlatform/datastore-ndb-python | ndb/eventloop.py | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L138-L148 | def queue_call(self, delay, callback, *args, **kwds):
"""Schedule a function call at a specific time in the future."""
if delay is None:
self.current.append((callback, args, kwds))
return
if delay < 1e9:
when = delay + self.clock.now()
else:
# Times over a billion seconds are ass... | [
"def",
"queue_call",
"(",
"self",
",",
"delay",
",",
"callback",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"if",
"delay",
"is",
"None",
":",
"self",
".",
"current",
".",
"append",
"(",
"(",
"callback",
",",
"args",
",",
"kwds",
")",
")",... | Schedule a function call at a specific time in the future. | [
"Schedule",
"a",
"function",
"call",
"at",
"a",
"specific",
"time",
"in",
"the",
"future",
"."
] | python | train |
quintusdias/glymur | glymur/config.py | https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L24-L45 | def glymurrc_fname():
"""Return the path to the configuration file.
Search order:
1) current working directory
2) environ var XDG_CONFIG_HOME
3) $HOME/.config/glymur/glymurrc
"""
# Current directory.
fname = os.path.join(os.getcwd(), 'glymurrc')
if os.path.exists(fname)... | [
"def",
"glymurrc_fname",
"(",
")",
":",
"# Current directory.",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"'glymurrc'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"fname",
")",
":",
"return",
"fname... | Return the path to the configuration file.
Search order:
1) current working directory
2) environ var XDG_CONFIG_HOME
3) $HOME/.config/glymur/glymurrc | [
"Return",
"the",
"path",
"to",
"the",
"configuration",
"file",
"."
] | python | train |
jbasko/configmanager | configmanager/sections.py | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L603-L616 | def create_section(self, *args, **kwargs):
"""
Internal factory method used to create an instance of configuration section.
Should only be used when extending or modifying configmanager's functionality.
Under normal circumstances you should let configmanager create sections
and ... | [
"def",
"create_section",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'section'",
",",
"self",
")",
"return",
"self",
".",
"settings",
".",
"section_factory",
"(",
"*",
"args",
",",
"*",
"*",
"k... | Internal factory method used to create an instance of configuration section.
Should only be used when extending or modifying configmanager's functionality.
Under normal circumstances you should let configmanager create sections
and items when parsing configuration schemas.
Do not overr... | [
"Internal",
"factory",
"method",
"used",
"to",
"create",
"an",
"instance",
"of",
"configuration",
"section",
"."
] | python | train |
maas/python-libmaas | maas/client/utils/__init__.py | https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/utils/__init__.py#L342-L350 | def print(self, *args, **kwargs):
"""Print inside of the spinner context.
This must be used when inside of a spinner context to ensure that
the line printed doesn't overwrite an already existing spinner line.
"""
clear_len = max(len(self._prev_msg), len(self.msg)) + 4
se... | [
"def",
"print",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"clear_len",
"=",
"max",
"(",
"len",
"(",
"self",
".",
"_prev_msg",
")",
",",
"len",
"(",
"self",
".",
"msg",
")",
")",
"+",
"4",
"self",
".",
"spinner",
".",
"... | Print inside of the spinner context.
This must be used when inside of a spinner context to ensure that
the line printed doesn't overwrite an already existing spinner line. | [
"Print",
"inside",
"of",
"the",
"spinner",
"context",
"."
] | python | train |
etcher-be/epab | epab/utils/_ensure_exe.py | https://github.com/etcher-be/epab/blob/024cde74d058281aa66e6e4b7b71dccbe803b1c1/epab/utils/_ensure_exe.py#L14-L26 | def ensure_exe(exe_name: str, *paths: str): # pragma: no cover
"""
Makes sure that an executable can be found on the system path.
Will exit the program if the executable cannot be found
Args:
exe_name: name of the executable
paths: optional path(s) to be searched; if not specified, sea... | [
"def",
"ensure_exe",
"(",
"exe_name",
":",
"str",
",",
"*",
"paths",
":",
"str",
")",
":",
"# pragma: no cover",
"if",
"not",
"elib_run",
".",
"find_executable",
"(",
"exe_name",
",",
"*",
"paths",
")",
":",
"LOGGER",
".",
"error",
"(",
"'could not find \"... | Makes sure that an executable can be found on the system path.
Will exit the program if the executable cannot be found
Args:
exe_name: name of the executable
paths: optional path(s) to be searched; if not specified, search the whole system | [
"Makes",
"sure",
"that",
"an",
"executable",
"can",
"be",
"found",
"on",
"the",
"system",
"path",
".",
"Will",
"exit",
"the",
"program",
"if",
"the",
"executable",
"cannot",
"be",
"found"
] | python | train |
blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/keys.py | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L137-L158 | def btc_script_to_hex(script):
""" Parse the string representation of a script and return the hex version.
Example: "OP_DUP OP_HASH160 c629...a6db OP_EQUALVERIFY OP_CHECKSIG"
"""
hex_script = ''
parts = script.split(' ')
for part in parts:
if part[0:3] == 'OP_':
value = ... | [
"def",
"btc_script_to_hex",
"(",
"script",
")",
":",
"hex_script",
"=",
"''",
"parts",
"=",
"script",
".",
"split",
"(",
"' '",
")",
"for",
"part",
"in",
"parts",
":",
"if",
"part",
"[",
"0",
":",
"3",
"]",
"==",
"'OP_'",
":",
"value",
"=",
"OPCODE... | Parse the string representation of a script and return the hex version.
Example: "OP_DUP OP_HASH160 c629...a6db OP_EQUALVERIFY OP_CHECKSIG" | [
"Parse",
"the",
"string",
"representation",
"of",
"a",
"script",
"and",
"return",
"the",
"hex",
"version",
".",
"Example",
":",
"OP_DUP",
"OP_HASH160",
"c629",
"...",
"a6db",
"OP_EQUALVERIFY",
"OP_CHECKSIG"
] | python | train |
datastore/datastore | datastore/core/query.py | https://github.com/datastore/datastore/blob/7ccf0cd4748001d3dbf5e6dda369b0f63e0269d3/datastore/core/query.py#L543-L549 | def apply_offset(self):
'''Naively apply query offset.'''
self._ensure_modification_is_safe()
if self.query.offset != 0:
self._iterable = \
offset_gen(self.query.offset, self._iterable, self._skipped_inc) | [
"def",
"apply_offset",
"(",
"self",
")",
":",
"self",
".",
"_ensure_modification_is_safe",
"(",
")",
"if",
"self",
".",
"query",
".",
"offset",
"!=",
"0",
":",
"self",
".",
"_iterable",
"=",
"offset_gen",
"(",
"self",
".",
"query",
".",
"offset",
",",
... | Naively apply query offset. | [
"Naively",
"apply",
"query",
"offset",
"."
] | python | train |
Yubico/python-u2flib-server | release.py | https://github.com/Yubico/python-u2flib-server/blob/4b9d353a3ba82be40c6cf9bab39d34ea7e07cb5a/release.py#L45-L58 | def get_version(module_name_or_file=None):
"""Return the current version as defined by the given module/file."""
if module_name_or_file is None:
parts = base_module.split('.')
module_name_or_file = parts[0] if len(parts) > 1 else \
find_packages(exclude=['test', 'test.*'])[0]
i... | [
"def",
"get_version",
"(",
"module_name_or_file",
"=",
"None",
")",
":",
"if",
"module_name_or_file",
"is",
"None",
":",
"parts",
"=",
"base_module",
".",
"split",
"(",
"'.'",
")",
"module_name_or_file",
"=",
"parts",
"[",
"0",
"]",
"if",
"len",
"(",
"part... | Return the current version as defined by the given module/file. | [
"Return",
"the",
"current",
"version",
"as",
"defined",
"by",
"the",
"given",
"module",
"/",
"file",
"."
] | python | train |
sdispater/orator | orator/query/builder.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L763-L785 | def having_raw(self, sql, bindings=None, boolean="and"):
"""
Add a raw having clause to the query
:param sql: The raw query
:type sql: str
:param bindings: The query bindings
:type bindings: list
:param boolean: Boolean joiner type
:type boolean: str
... | [
"def",
"having_raw",
"(",
"self",
",",
"sql",
",",
"bindings",
"=",
"None",
",",
"boolean",
"=",
"\"and\"",
")",
":",
"type",
"=",
"\"raw\"",
"self",
".",
"havings",
".",
"append",
"(",
"{",
"\"type\"",
":",
"type",
",",
"\"sql\"",
":",
"sql",
",",
... | Add a raw having clause to the query
:param sql: The raw query
:type sql: str
:param bindings: The query bindings
:type bindings: list
:param boolean: Boolean joiner type
:type boolean: str
:return: The current QueryBuilder instance
:rtype: QueryBuilde... | [
"Add",
"a",
"raw",
"having",
"clause",
"to",
"the",
"query"
] | python | train |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/drivers.py | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/drivers.py#L253-L338 | def _get_response(self, timeout=1.0, eor=('\n', '\n- ')):
""" Reads a response from the drive.
Reads the response returned by the drive with an optional
timeout. All carriage returns and linefeeds are kept.
Parameters
----------
timeout : number, optional
Op... | [
"def",
"_get_response",
"(",
"self",
",",
"timeout",
"=",
"1.0",
",",
"eor",
"=",
"(",
"'\\n'",
",",
"'\\n- '",
")",
")",
":",
"# If no timeout is given or it is invalid and we are using '\\n'",
"# as the eor, use the wrapper to read a line with an infinite",
"# timeout. Othe... | Reads a response from the drive.
Reads the response returned by the drive with an optional
timeout. All carriage returns and linefeeds are kept.
Parameters
----------
timeout : number, optional
Optional timeout in seconds to use when reading the
response... | [
"Reads",
"a",
"response",
"from",
"the",
"drive",
"."
] | python | train |
barrust/pyspellchecker | spellchecker/spellchecker.py | https://github.com/barrust/pyspellchecker/blob/fa96024c0cdeba99e10e11060d5fd7aba796b271/spellchecker/spellchecker.py#L157-L172 | def known(self, words):
""" The subset of `words` that appear in the dictionary of words
Args:
words (list): List of words to determine which are in the \
corpus
Returns:
set: The set of those words from the input that are in the \
... | [
"def",
"known",
"(",
"self",
",",
"words",
")",
":",
"tmp",
"=",
"[",
"w",
".",
"lower",
"(",
")",
"for",
"w",
"in",
"words",
"]",
"return",
"set",
"(",
"w",
"for",
"w",
"in",
"tmp",
"if",
"w",
"in",
"self",
".",
"_word_frequency",
".",
"dictio... | The subset of `words` that appear in the dictionary of words
Args:
words (list): List of words to determine which are in the \
corpus
Returns:
set: The set of those words from the input that are in the \
corpus | [
"The",
"subset",
"of",
"words",
"that",
"appear",
"in",
"the",
"dictionary",
"of",
"words"
] | python | train |
radjkarl/appBase | appbase/Session.py | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L456-L459 | def _saveState(self, path):
"""save current state and add a new state"""
self.addSession() # next session
self._save(str(self.n_sessions), path) | [
"def",
"_saveState",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"addSession",
"(",
")",
"# next session\r",
"self",
".",
"_save",
"(",
"str",
"(",
"self",
".",
"n_sessions",
")",
",",
"path",
")"
] | save current state and add a new state | [
"save",
"current",
"state",
"and",
"add",
"a",
"new",
"state"
] | python | train |
joshspeagle/dynesty | dynesty/bounding.py | https://github.com/joshspeagle/dynesty/blob/9e482aafeb5cf84bedb896fa6f07a761d917983e/dynesty/bounding.py#L530-L634 | 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",
"... | Update the set of ellipsoids to bound the collection of points.
Parameters
----------
points : `~numpy.ndarray` with shape (npoints, ndim)
The set of points to bound.
pointvol : float, optional
The minimum volume associated with each point. Default is `0.`.
... | [
"Update",
"the",
"set",
"of",
"ellipsoids",
"to",
"bound",
"the",
"collection",
"of",
"points",
"."
] | python | train |
MultipedRobotics/pyxl320 | pyxl320/Packet.py | https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L230-L236 | def makeServoMinLimitPacket(ID, angle):
"""
Sets the minimum servo angle (in the CW direction)
"""
angle = int(angle/300.0*1023)
pkt = makeWritePacket(ID, xl320.XL320_CW_ANGLE_LIMIT, le(angle))
return pkt | [
"def",
"makeServoMinLimitPacket",
"(",
"ID",
",",
"angle",
")",
":",
"angle",
"=",
"int",
"(",
"angle",
"/",
"300.0",
"*",
"1023",
")",
"pkt",
"=",
"makeWritePacket",
"(",
"ID",
",",
"xl320",
".",
"XL320_CW_ANGLE_LIMIT",
",",
"le",
"(",
"angle",
")",
"... | Sets the minimum servo angle (in the CW direction) | [
"Sets",
"the",
"minimum",
"servo",
"angle",
"(",
"in",
"the",
"CW",
"direction",
")"
] | python | train |
gofed/gofedlib | gofedlib/providers/upstreamprovider.py | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/providers/upstreamprovider.py#L102-L115 | def parseGithubImportPath(self, path):
"""
Definition: github.com/<project>/<repo>
"""
parts = path.split("/")
if len(parts) < 3:
raise ValueError("Import path %s not in github.com/<project>/<repo> form" % path)
repo = {}
repo["prefix"] = "/".join(parts[:3])
repo["signature"] = {"provider": "github... | [
"def",
"parseGithubImportPath",
"(",
"self",
",",
"path",
")",
":",
"parts",
"=",
"path",
".",
"split",
"(",
"\"/\"",
")",
"if",
"len",
"(",
"parts",
")",
"<",
"3",
":",
"raise",
"ValueError",
"(",
"\"Import path %s not in github.com/<project>/<repo> form\"",
... | Definition: github.com/<project>/<repo> | [
"Definition",
":",
"github",
".",
"com",
"/",
"<project",
">",
"/",
"<repo",
">"
] | python | train |
Miserlou/Zappa | zappa/core.py | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L3010-L3049 | def fetch_logs(self, lambda_name, filter_pattern='', limit=10000, start_time=0):
"""
Fetch the CloudWatch logs for a given Lambda name.
"""
log_name = '/aws/lambda/' + lambda_name
streams = self.logs_client.describe_log_streams(
logGroupName=log_name,
desc... | [
"def",
"fetch_logs",
"(",
"self",
",",
"lambda_name",
",",
"filter_pattern",
"=",
"''",
",",
"limit",
"=",
"10000",
",",
"start_time",
"=",
"0",
")",
":",
"log_name",
"=",
"'/aws/lambda/'",
"+",
"lambda_name",
"streams",
"=",
"self",
".",
"logs_client",
".... | Fetch the CloudWatch logs for a given Lambda name. | [
"Fetch",
"the",
"CloudWatch",
"logs",
"for",
"a",
"given",
"Lambda",
"name",
"."
] | python | train |
gwastro/pycbc | pycbc/workflow/core.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/core.py#L1170-L1186 | def _filename(self, ifo, description, extension, segment):
"""
Construct the standard output filename. Should only be used internally
of the File class.
"""
if extension.startswith('.'):
extension = extension[1:]
# Follow the frame convention of using integer... | [
"def",
"_filename",
"(",
"self",
",",
"ifo",
",",
"description",
",",
"extension",
",",
"segment",
")",
":",
"if",
"extension",
".",
"startswith",
"(",
"'.'",
")",
":",
"extension",
"=",
"extension",
"[",
"1",
":",
"]",
"# Follow the frame convention of usin... | Construct the standard output filename. Should only be used internally
of the File class. | [
"Construct",
"the",
"standard",
"output",
"filename",
".",
"Should",
"only",
"be",
"used",
"internally",
"of",
"the",
"File",
"class",
"."
] | python | train |
LEMS/pylems | lems/model/structure.py | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L263-L273 | def add(self, child):
"""
Adds a typed child object to the structure object.
@param child: Child object to be added.
"""
if isinstance(child, Assign):
self.add_assign(child)
else:
raise ModelError('Unsupported child element') | [
"def",
"add",
"(",
"self",
",",
"child",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"Assign",
")",
":",
"self",
".",
"add_assign",
"(",
"child",
")",
"else",
":",
"raise",
"ModelError",
"(",
"'Unsupported child element'",
")"
] | Adds a typed child object to the structure object.
@param child: Child object to be added. | [
"Adds",
"a",
"typed",
"child",
"object",
"to",
"the",
"structure",
"object",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/glow_ops.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L429-L461 | def time_pad(x, filter_size, dilations):
"""Pad left across time and pad valid across the spatial components.
Also concats a binary feature that indicates if a feature is padded or not.
Args:
x: 5-D Tensor, (NTHWC)
filter_size: list of ints
dilations: list of ints, dilations - 1 specifies the number... | [
"def",
"time_pad",
"(",
"x",
",",
"filter_size",
",",
"dilations",
")",
":",
"x_shape",
"=",
"common_layers",
".",
"shape_list",
"(",
"x",
")",
"if",
"filter_size",
"==",
"[",
"1",
",",
"1",
",",
"1",
"]",
":",
"return",
"x",
"_",
",",
"h",
",",
... | Pad left across time and pad valid across the spatial components.
Also concats a binary feature that indicates if a feature is padded or not.
Args:
x: 5-D Tensor, (NTHWC)
filter_size: list of ints
dilations: list of ints, dilations - 1 specifies the number of holes
between two filter el... | [
"Pad",
"left",
"across",
"time",
"and",
"pad",
"valid",
"across",
"the",
"spatial",
"components",
"."
] | python | train |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L383-L390 | def _alpha2rho0(self, theta_Rs, Rs):
"""
convert angle at Rs into rho0
"""
rho0 = theta_Rs / (4. * Rs ** 2 * (1. + np.log(1. / 2.)))
return rho0 | [
"def",
"_alpha2rho0",
"(",
"self",
",",
"theta_Rs",
",",
"Rs",
")",
":",
"rho0",
"=",
"theta_Rs",
"/",
"(",
"4.",
"*",
"Rs",
"**",
"2",
"*",
"(",
"1.",
"+",
"np",
".",
"log",
"(",
"1.",
"/",
"2.",
")",
")",
")",
"return",
"rho0"
] | convert angle at Rs into rho0 | [
"convert",
"angle",
"at",
"Rs",
"into",
"rho0"
] | python | train |
praekelt/django-analytics | analytics/views.py | https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/views.py#L22-L31 | def get_active_stats(self):
"""
Returns all of the active statistics for the gadgets currently registered.
"""
stats = []
for gadget in self._registry.values():
for s in gadget.stats:
if s not in stats:
stats.append(s)
retur... | [
"def",
"get_active_stats",
"(",
"self",
")",
":",
"stats",
"=",
"[",
"]",
"for",
"gadget",
"in",
"self",
".",
"_registry",
".",
"values",
"(",
")",
":",
"for",
"s",
"in",
"gadget",
".",
"stats",
":",
"if",
"s",
"not",
"in",
"stats",
":",
"stats",
... | Returns all of the active statistics for the gadgets currently registered. | [
"Returns",
"all",
"of",
"the",
"active",
"statistics",
"for",
"the",
"gadgets",
"currently",
"registered",
"."
] | python | test |
iotile/typedargs | typedargs/annotate.py | https://github.com/iotile/typedargs/blob/0a5091a664b9b4d836e091e9ba583e944f438fd8/typedargs/annotate.py#L192-L209 | def context(name=None):
"""Declare that a class defines a context.
Contexts are for use with HierarchicalShell for discovering
and using functionality from the command line.
Args:
name (str): Optional name for this context if you don't want
to just use the class name.
"""
... | [
"def",
"context",
"(",
"name",
"=",
"None",
")",
":",
"def",
"_context",
"(",
"cls",
")",
":",
"annotated",
"(",
"cls",
",",
"name",
")",
"cls",
".",
"context",
"=",
"True",
"return",
"cls",
"return",
"_context"
] | Declare that a class defines a context.
Contexts are for use with HierarchicalShell for discovering
and using functionality from the command line.
Args:
name (str): Optional name for this context if you don't want
to just use the class name. | [
"Declare",
"that",
"a",
"class",
"defines",
"a",
"context",
"."
] | python | test |
jbloomlab/phydms | phydmslib/models.py | https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/models.py#L507-L543 | def updateParams(self, newvalues, update_all=False):
"""See docs for `Model` abstract base class."""
assert all(map(lambda x: x in self.freeparams, newvalues.keys())),\
"Invalid entry in newvalues: {0}\nfreeparams: {1}".format(
', '.join(newvalues.keys()), ', '.join(self.... | [
"def",
"updateParams",
"(",
"self",
",",
"newvalues",
",",
"update_all",
"=",
"False",
")",
":",
"assert",
"all",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
"in",
"self",
".",
"freeparams",
",",
"newvalues",
".",
"keys",
"(",
")",
")",
")",
",",
"\"... | See docs for `Model` abstract base class. | [
"See",
"docs",
"for",
"Model",
"abstract",
"base",
"class",
"."
] | python | train |
wglass/lighthouse | lighthouse/zookeeper.py | https://github.com/wglass/lighthouse/blob/f4ce6550895acc31e433ede0c05d366718a3ffe5/lighthouse/zookeeper.py#L128-L189 | def start_watching(self, cluster, callback):
"""
Initiates the "watching" of a cluster's associated znode.
This is done via kazoo's ChildrenWatch object. When a cluster's
znode's child nodes are updated, a callback is fired and we update
the cluster's `nodes` attribute based on... | [
"def",
"start_watching",
"(",
"self",
",",
"cluster",
",",
"callback",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting to watch cluster %s\"",
",",
"cluster",
".",
"name",
")",
"wait_on_any",
"(",
"self",
".",
"connected",
",",
"self",
".",
"shutdown",
")... | Initiates the "watching" of a cluster's associated znode.
This is done via kazoo's ChildrenWatch object. When a cluster's
znode's child nodes are updated, a callback is fired and we update
the cluster's `nodes` attribute based on the existing child znodes
and fire a passed-in callback ... | [
"Initiates",
"the",
"watching",
"of",
"a",
"cluster",
"s",
"associated",
"znode",
"."
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/zmq/kernelmanager.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/zmq/kernelmanager.py#L760-L774 | def write_connection_file(self):
"""write connection info to JSON dict in self.connection_file"""
if self._connection_file_written:
return
self.connection_file,cfg = write_connection_file(self.connection_file,
ip=self.ip, key=self.session.key,
stdin_port=self.... | [
"def",
"write_connection_file",
"(",
"self",
")",
":",
"if",
"self",
".",
"_connection_file_written",
":",
"return",
"self",
".",
"connection_file",
",",
"cfg",
"=",
"write_connection_file",
"(",
"self",
".",
"connection_file",
",",
"ip",
"=",
"self",
".",
"ip... | write connection info to JSON dict in self.connection_file | [
"write",
"connection",
"info",
"to",
"JSON",
"dict",
"in",
"self",
".",
"connection_file"
] | python | test |
HazyResearch/metal | metal/analysis.py | https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L271-L277 | def add(self, gold, pred):
"""
Args:
gold: a np.ndarray of gold labels (ints)
pred: a np.ndarray of predictions (ints)
"""
self.counter.update(zip(gold, pred)) | [
"def",
"add",
"(",
"self",
",",
"gold",
",",
"pred",
")",
":",
"self",
".",
"counter",
".",
"update",
"(",
"zip",
"(",
"gold",
",",
"pred",
")",
")"
] | Args:
gold: a np.ndarray of gold labels (ints)
pred: a np.ndarray of predictions (ints) | [
"Args",
":",
"gold",
":",
"a",
"np",
".",
"ndarray",
"of",
"gold",
"labels",
"(",
"ints",
")",
"pred",
":",
"a",
"np",
".",
"ndarray",
"of",
"predictions",
"(",
"ints",
")"
] | python | train |
scivision/gridaurora | gridaurora/calcemissions.py | https://github.com/scivision/gridaurora/blob/c3957b93c2201afff62bd104e0acead52c0d9e90/gridaurora/calcemissions.py#L62-L76 | def getMetastable(rates, ver: np.ndarray, lamb, br, reactfn: Path):
with h5py.File(reactfn, 'r') as f:
A = f['/metastable/A'][:]
lambnew = f['/metastable/lambda'].value.ravel(order='F') # some are not 1-D!
"""
concatenate along the reaction dimension, axis=-1
"""
vnew = np.concaten... | [
"def",
"getMetastable",
"(",
"rates",
",",
"ver",
":",
"np",
".",
"ndarray",
",",
"lamb",
",",
"br",
",",
"reactfn",
":",
"Path",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"reactfn",
",",
"'r'",
")",
"as",
"f",
":",
"A",
"=",
"f",
"[",
"'/met... | concatenate along the reaction dimension, axis=-1 | [
"concatenate",
"along",
"the",
"reaction",
"dimension",
"axis",
"=",
"-",
"1"
] | python | train |
saltstack/salt | salt/modules/boto_asg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_asg.py#L895-L918 | def exit_standby(name, instance_ids, should_decrement_desired_capacity=False,
region=None, key=None, keyid=None, profile=None):
'''
Exit desired instances from StandBy mode
.. versionadded:: 2016.11.0
CLI example::
salt-call boto_asg.exit_standby my_autoscale_group_name '["i... | [
"def",
"exit_standby",
"(",
"name",
",",
"instance_ids",
",",
"should_decrement_desired_capacity",
"=",
"False",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn_... | Exit desired instances from StandBy mode
.. versionadded:: 2016.11.0
CLI example::
salt-call boto_asg.exit_standby my_autoscale_group_name '["i-xxxxxx"]' | [
"Exit",
"desired",
"instances",
"from",
"StandBy",
"mode"
] | python | train |
wheeler-microfluidics/dmf-control-board-firmware | dmf_control_board_firmware/__init__.py | https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L50-L72 | def savgol_filter(x, window_length, polyorder, deriv=0, delta=1.0, axis=-1, mode='interp', cval=0.0):
'''
Wrapper for the scipy.signal.savgol_filter function that handles Nan values.
See: https://github.com/wheeler-microfluidics/dmf-control-board-firmware/issues/3
Returns
-------
y : ndarray, ... | [
"def",
"savgol_filter",
"(",
"x",
",",
"window_length",
",",
"polyorder",
",",
"deriv",
"=",
"0",
",",
"delta",
"=",
"1.0",
",",
"axis",
"=",
"-",
"1",
",",
"mode",
"=",
"'interp'",
",",
"cval",
"=",
"0.0",
")",
":",
"# linearly interpolate missing value... | Wrapper for the scipy.signal.savgol_filter function that handles Nan values.
See: https://github.com/wheeler-microfluidics/dmf-control-board-firmware/issues/3
Returns
-------
y : ndarray, same shape as `x`
The filtered data. | [
"Wrapper",
"for",
"the",
"scipy",
".",
"signal",
".",
"savgol_filter",
"function",
"that",
"handles",
"Nan",
"values",
"."
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/ext/fontconfig.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/fontconfig.py#L85-L111 | def find_font(face, bold, italic):
"""Find font"""
bold = FC_WEIGHT_BOLD if bold else FC_WEIGHT_REGULAR
italic = FC_SLANT_ITALIC if italic else FC_SLANT_ROMAN
face = face.encode('utf8')
fontconfig.FcInit()
pattern = fontconfig.FcPatternCreate()
fontconfig.FcPatternAddInteger(pattern, FC_WEIG... | [
"def",
"find_font",
"(",
"face",
",",
"bold",
",",
"italic",
")",
":",
"bold",
"=",
"FC_WEIGHT_BOLD",
"if",
"bold",
"else",
"FC_WEIGHT_REGULAR",
"italic",
"=",
"FC_SLANT_ITALIC",
"if",
"italic",
"else",
"FC_SLANT_ROMAN",
"face",
"=",
"face",
".",
"encode",
"... | Find font | [
"Find",
"font"
] | python | train |
MartinThoma/hwrt | hwrt/segmentation/segmentation.py | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/segmentation/segmentation.py#L784-L832 | def break_mst(mst, i):
"""
Break mst into multiple MSTs by removing one node i.
Parameters
----------
mst : symmetrical square matrix
i : index of the mst where to break
Returns
-------
list of dictionarys ('mst' and 'strokes' are the keys)
"""
for j in range(len(mst['mst']... | [
"def",
"break_mst",
"(",
"mst",
",",
"i",
")",
":",
"for",
"j",
"in",
"range",
"(",
"len",
"(",
"mst",
"[",
"'mst'",
"]",
")",
")",
":",
"mst",
"[",
"'mst'",
"]",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"0",
"mst",
"[",
"'mst'",
"]",
"[",
"j",... | Break mst into multiple MSTs by removing one node i.
Parameters
----------
mst : symmetrical square matrix
i : index of the mst where to break
Returns
-------
list of dictionarys ('mst' and 'strokes' are the keys) | [
"Break",
"mst",
"into",
"multiple",
"MSTs",
"by",
"removing",
"one",
"node",
"i",
"."
] | python | train |
ultrabug/py3status | py3status/modules/dpms.py | https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/modules/dpms.py#L62-L79 | def dpms(self):
"""
Display a colorful state of DPMS.
"""
if "DPMS is Enabled" in self.py3.command_output("xset -q"):
_format = self.icon_on
color = self.color_on
else:
_format = self.icon_off
color = self.color_off
icon = ... | [
"def",
"dpms",
"(",
"self",
")",
":",
"if",
"\"DPMS is Enabled\"",
"in",
"self",
".",
"py3",
".",
"command_output",
"(",
"\"xset -q\"",
")",
":",
"_format",
"=",
"self",
".",
"icon_on",
"color",
"=",
"self",
".",
"color_on",
"else",
":",
"_format",
"=",
... | Display a colorful state of DPMS. | [
"Display",
"a",
"colorful",
"state",
"of",
"DPMS",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.