nwo stringlengths 5 106 | sha stringlengths 40 40 | path stringlengths 4 174 | language stringclasses 1
value | identifier stringlengths 1 140 | parameters stringlengths 0 87.7k | argument_list stringclasses 1
value | return_statement stringlengths 0 426k | docstring stringlengths 0 64.3k | docstring_summary stringlengths 0 26.3k | docstring_tokens list | function stringlengths 18 4.83M | function_tokens list | url stringlengths 83 304 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/sympy/sympy/liealgebras/type_e.py | python | TypeE.dynkin_diagram | (self) | return diag | [] | def dynkin_diagram(self):
n = self.n
diag = " "*8 + str(2) + "\n"
diag += " "*8 + "0\n"
diag += " "*8 + "|\n"
diag += " "*8 + "|\n"
diag += "---".join("0" for i in range(1, n)) + "\n"
diag += "1 " + " ".join(str(i) for i in range(3, n+1))
return diag | [
"def",
"dynkin_diagram",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"n",
"diag",
"=",
"\" \"",
"*",
"8",
"+",
"str",
"(",
"2",
")",
"+",
"\"\\n\"",
"diag",
"+=",
"\" \"",
"*",
"8",
"+",
"\"0\\n\"",
"diag",
"+=",
"\" \"",
"*",
"8",
"+",
"\"|\... | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/liealgebras/type_e.py#L279-L287 | |||
hexway/apple_bleee | 1f8022959be660b561e6004b808dd93fa252bc90 | npyscreen/wgwidget.py | python | Widget.display | (self) | Do an update of the object AND refresh the screen | Do an update of the object AND refresh the screen | [
"Do",
"an",
"update",
"of",
"the",
"object",
"AND",
"refresh",
"the",
"screen"
] | def display(self):
"""Do an update of the object AND refresh the screen"""
if self.hidden:
self.clear()
self.parent.refresh()
else:
self.update()
self.parent.refresh() | [
"def",
"display",
"(",
"self",
")",
":",
"if",
"self",
".",
"hidden",
":",
"self",
".",
"clear",
"(",
")",
"self",
".",
"parent",
".",
"refresh",
"(",
")",
"else",
":",
"self",
".",
"update",
"(",
")",
"self",
".",
"parent",
".",
"refresh",
"(",
... | https://github.com/hexway/apple_bleee/blob/1f8022959be660b561e6004b808dd93fa252bc90/npyscreen/wgwidget.py#L423-L430 | ||
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/samsungtv/__init__.py | python | async_setup | (hass: HomeAssistant, config: ConfigType) | return True | Set up the Samsung TV integration. | Set up the Samsung TV integration. | [
"Set",
"up",
"the",
"Samsung",
"TV",
"integration",
"."
] | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Samsung TV integration."""
hass.data[DOMAIN] = {}
if DOMAIN not in config:
return True
for entry_config in config[DOMAIN]:
ip_address = await hass.async_add_executor_job(
socket.gethostbyna... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"for",
"... | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/samsungtv/__init__.py#L78-L98 | |
brightmart/slot_filling_intent_joint_model | 06ee6932bca2e07b3667e7edbef878a79cdcf2d1 | joint_model_knowl_v4_cnn_with_symbol_alime/joint_intent_slots_knowledge_model.py | python | joint_knowledge_model.cos_similiarity_vectorized | (self,v,V) | return cos | cosine similiarity vectorized
v:[1,embed_sz],
V:[None,embed_sz] | cosine similiarity vectorized
v:[1,embed_sz],
V:[None,embed_sz] | [
"cosine",
"similiarity",
"vectorized",
"v",
":",
"[",
"1",
"embed_sz",
"]",
"V",
":",
"[",
"None",
"embed_sz",
"]"
] | def cos_similiarity_vectorized(self,v,V):
"""
cosine similiarity vectorized
v:[1,embed_sz],
V:[None,embed_sz]
"""
print("cos_similiarity_vectorized.started.v:",v,";V:",V)
dot_product=tf.reduce_sum(tf.multiply(v, V),axis=1) #[1,None]
v1_norm=tf.sqrt(tf.redu... | [
"def",
"cos_similiarity_vectorized",
"(",
"self",
",",
"v",
",",
"V",
")",
":",
"print",
"(",
"\"cos_similiarity_vectorized.started.v:\"",
",",
"v",
",",
"\";V:\"",
",",
"V",
")",
"dot_product",
"=",
"tf",
".",
"reduce_sum",
"(",
"tf",
".",
"multiply",
"(",
... | https://github.com/brightmart/slot_filling_intent_joint_model/blob/06ee6932bca2e07b3667e7edbef878a79cdcf2d1/joint_model_knowl_v4_cnn_with_symbol_alime/joint_intent_slots_knowledge_model.py#L167-L180 | |
exaile/exaile | a7b58996c5c15b3aa7b9975ac13ee8f784ef4689 | plugins/audioscrobbler/_scrobbler.py | python | handle_hard_error | () | Handles hard errors. | Handles hard errors. | [
"Handles",
"hard",
"errors",
"."
] | def handle_hard_error():
"Handles hard errors."
global SESSION_ID, HARD_FAILS, HS_DELAY
if HS_DELAY == 0:
HS_DELAY = 60
elif HS_DELAY < 120 * 60:
HS_DELAY *= 2
if HS_DELAY > 120 * 60:
HS_DELAY = 120 * 60
HARD_FAILS += 1
if HARD_FAILS == 3:
SESSION_ID = None | [
"def",
"handle_hard_error",
"(",
")",
":",
"global",
"SESSION_ID",
",",
"HARD_FAILS",
",",
"HS_DELAY",
"if",
"HS_DELAY",
"==",
"0",
":",
"HS_DELAY",
"=",
"60",
"elif",
"HS_DELAY",
"<",
"120",
"*",
"60",
":",
"HS_DELAY",
"*=",
"2",
"if",
"HS_DELAY",
">",
... | https://github.com/exaile/exaile/blob/a7b58996c5c15b3aa7b9975ac13ee8f784ef4689/plugins/audioscrobbler/_scrobbler.py#L149-L162 | ||
edisonlz/fastor | 342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3 | base/site-packages/rosetta/polib.py | python | quote | (st) | return st | Quote and return the given string *st*.
**Examples**:
>>> quote('\\t and \\n and \\r and " and \\\\')
'\\\\t and \\\\n and \\\\r and \\\\" and \\\\\\\\' | Quote and return the given string *st*. | [
"Quote",
"and",
"return",
"the",
"given",
"string",
"*",
"st",
"*",
"."
] | def quote(st):
"""
Quote and return the given string *st*.
**Examples**:
>>> quote('\\t and \\n and \\r and " and \\\\')
'\\\\t and \\\\n and \\\\r and \\\\" and \\\\\\\\'
"""
# quote {{{
st = _strreplace(st, '\\', r'\\')
st = _strreplace(st, '\t', r'\t')
st = _strreplace(st, '... | [
"def",
"quote",
"(",
"st",
")",
":",
"# quote {{{",
"st",
"=",
"_strreplace",
"(",
"st",
",",
"'\\\\'",
",",
"r'\\\\'",
")",
"st",
"=",
"_strreplace",
"(",
"st",
",",
"'\\t'",
",",
"r'\\t'",
")",
"st",
"=",
"_strreplace",
"(",
"st",
",",
"'\\r'",
"... | https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/rosetta/polib.py#L202-L217 | |
Instagram/LibCST | 13370227703fe3171e94c57bdd7977f3af696b73 | libcst/matchers/_matcher_base.py | python | _construct_metadata_fetcher_dependent | (
dependent_class: libcst.MetadataDependent,
) | return _fetch | [] | def _construct_metadata_fetcher_dependent(
dependent_class: libcst.MetadataDependent,
) -> Callable[[meta.ProviderT, libcst.CSTNode], object]:
def _fetch(provider: meta.ProviderT, node: libcst.CSTNode) -> object:
return dependent_class.get_metadata(provider, node, _METADATA_MISSING_SENTINEL)
return... | [
"def",
"_construct_metadata_fetcher_dependent",
"(",
"dependent_class",
":",
"libcst",
".",
"MetadataDependent",
",",
")",
"->",
"Callable",
"[",
"[",
"meta",
".",
"ProviderT",
",",
"libcst",
".",
"CSTNode",
"]",
",",
"object",
"]",
":",
"def",
"_fetch",
"(",
... | https://github.com/Instagram/LibCST/blob/13370227703fe3171e94c57bdd7977f3af696b73/libcst/matchers/_matcher_base.py#L1529-L1535 | |||
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/lib/python2.7/site-packages/sqlalchemy/sql/selectable.py | python | CompoundSelect._refresh_for_new_column | (self, column) | [] | def _refresh_for_new_column(self, column):
for s in self.selects:
s._refresh_for_new_column(column)
if not self._cols_populated:
return None
raise NotImplementedError("CompoundSelect constructs don't support "
"addition of columns to un... | [
"def",
"_refresh_for_new_column",
"(",
"self",
",",
"column",
")",
":",
"for",
"s",
"in",
"self",
".",
"selects",
":",
"s",
".",
"_refresh_for_new_column",
"(",
"column",
")",
"if",
"not",
"self",
".",
"_cols_populated",
":",
"return",
"None",
"raise",
"No... | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/sqlalchemy/sql/selectable.py#L2443-L2452 | ||||
CMA-ES/pycma | f6eed1ef7e747cec1ab2e5c835d6f2fd1ebc097f | cma/bbobbenchmarks.py | python | AbstractTestFunction.evaluate | (self, x) | return self._evalfull(x)[0] | Returns the objective function value (in case noisy). | Returns the objective function value (in case noisy). | [
"Returns",
"the",
"objective",
"function",
"value",
"(",
"in",
"case",
"noisy",
")",
"."
] | def evaluate(self, x):
"""Returns the objective function value (in case noisy).
"""
return self._evalfull(x)[0] | [
"def",
"evaluate",
"(",
"self",
",",
"x",
")",
":",
"return",
"self",
".",
"_evalfull",
"(",
"x",
")",
"[",
"0",
"]"
] | https://github.com/CMA-ES/pycma/blob/f6eed1ef7e747cec1ab2e5c835d6f2fd1ebc097f/cma/bbobbenchmarks.py#L404-L408 | |
hakril/PythonForWindows | 61e027a678d5b87aa64fcf8a37a6661a86236589 | samples/process/dump_apisetmap.py | python | read_apisetmap | () | return data | [] | def read_apisetmap():
cp = windows.current_process
apisetmap_addr = cp.peb.ApiSetMap
print("ApiSetMap address <{0:#x}>".format(apisetmap_addr))
apisetmap_version = cp.read_dword(apisetmap_addr)
print("ApiSetMap version <{0}>".format(apisetmap_version))
meminfo = cp.query_memory(apisetmap_addr)
... | [
"def",
"read_apisetmap",
"(",
")",
":",
"cp",
"=",
"windows",
".",
"current_process",
"apisetmap_addr",
"=",
"cp",
".",
"peb",
".",
"ApiSetMap",
"print",
"(",
"\"ApiSetMap address <{0:#x}>\"",
".",
"format",
"(",
"apisetmap_addr",
")",
")",
"apisetmap_version",
... | https://github.com/hakril/PythonForWindows/blob/61e027a678d5b87aa64fcf8a37a6661a86236589/samples/process/dump_apisetmap.py#L4-L13 | |||
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/lib/python2.7/site-packages/sqlalchemy/ext/orderinglist.py | python | count_from_1 | (index, collection) | return index + 1 | Numbering function: consecutive integers starting at 1. | Numbering function: consecutive integers starting at 1. | [
"Numbering",
"function",
":",
"consecutive",
"integers",
"starting",
"at",
"1",
"."
] | def count_from_1(index, collection):
"""Numbering function: consecutive integers starting at 1."""
return index + 1 | [
"def",
"count_from_1",
"(",
"index",
",",
"collection",
")",
":",
"return",
"index",
"+",
"1"
] | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/sqlalchemy/ext/orderinglist.py#L172-L175 | |
riffnshred/nhl-led-scoreboard | 14baa7f0691ca507e4c6f7f2ec02e50ccd1ed9e1 | src/renderer/matrix.py | python | Matrix.update_indicator | (self) | [] | def update_indicator(self):
green = self.graphics.Color(0, 255, 0)
self.graphics.DrawLine(self.matrix, 0, 0, self.matrix.width,0, green) | [
"def",
"update_indicator",
"(",
"self",
")",
":",
"green",
"=",
"self",
".",
"graphics",
".",
"Color",
"(",
"0",
",",
"255",
",",
"0",
")",
"self",
".",
"graphics",
".",
"DrawLine",
"(",
"self",
".",
"matrix",
",",
"0",
",",
"0",
",",
"self",
"."... | https://github.com/riffnshred/nhl-led-scoreboard/blob/14baa7f0691ca507e4c6f7f2ec02e50ccd1ed9e1/src/renderer/matrix.py#L297-L299 | ||||
myarik/django-rest-elasticsearch | e64438edf5e5728ba7cf761b55b1c9dd48dc693f | rest_framework_elasticsearch/es_views.py | python | ElasticAPIView.get_es_range_filter_fields | (self) | return getattr(self, 'es_range_filter_fields', tuple()) | Return field or fields used for search filtering by range.
The return value must be an iterable. | Return field or fields used for search filtering by range.
The return value must be an iterable. | [
"Return",
"field",
"or",
"fields",
"used",
"for",
"search",
"filtering",
"by",
"range",
".",
"The",
"return",
"value",
"must",
"be",
"an",
"iterable",
"."
] | def get_es_range_filter_fields(self):
"""
Return field or fields used for search filtering by range.
The return value must be an iterable.
"""
return getattr(self, 'es_range_filter_fields', tuple()) | [
"def",
"get_es_range_filter_fields",
"(",
"self",
")",
":",
"return",
"getattr",
"(",
"self",
",",
"'es_range_filter_fields'",
",",
"tuple",
"(",
")",
")"
] | https://github.com/myarik/django-rest-elasticsearch/blob/e64438edf5e5728ba7cf761b55b1c9dd48dc693f/rest_framework_elasticsearch/es_views.py#L37-L42 | |
llSourcell/AI_Artist | 3038c06c2e389b9c919c881c9a169efe2fd7810e | lib/python2.7/site-packages/pip/_vendor/pyparsing.py | python | OnlyOnce.__init__ | (self, methodCall) | [] | def __init__(self, methodCall):
self.callable = _trim_arity(methodCall)
self.called = False | [
"def",
"__init__",
"(",
"self",
",",
"methodCall",
")",
":",
"self",
".",
"callable",
"=",
"_trim_arity",
"(",
"methodCall",
")",
"self",
".",
"called",
"=",
"False"
] | https://github.com/llSourcell/AI_Artist/blob/3038c06c2e389b9c919c881c9a169efe2fd7810e/lib/python2.7/site-packages/pip/_vendor/pyparsing.py#L3191-L3193 | ||||
menpo/menpo | a61500656c4fc2eea82497684f13cc31a605550b | menpo/shape/graph.py | python | Graph.get_adjacency_list | (self) | return adjacency_list | r"""
Returns the adjacency list of the graph, i.e. a `list` of length
``n_vertices`` that for each vertex has a `list` of the vertex
neighbours. If the graph is directed, the neighbours are children.
Returns
-------
adjacency_list : `list` of `list` of length ``n_vertice... | r"""
Returns the adjacency list of the graph, i.e. a `list` of length
``n_vertices`` that for each vertex has a `list` of the vertex
neighbours. If the graph is directed, the neighbours are children. | [
"r",
"Returns",
"the",
"adjacency",
"list",
"of",
"the",
"graph",
"i",
".",
"e",
".",
"a",
"list",
"of",
"length",
"n_vertices",
"that",
"for",
"each",
"vertex",
"has",
"a",
"list",
"of",
"the",
"vertex",
"neighbours",
".",
"If",
"the",
"graph",
"is",
... | def get_adjacency_list(self):
r"""
Returns the adjacency list of the graph, i.e. a `list` of length
``n_vertices`` that for each vertex has a `list` of the vertex
neighbours. If the graph is directed, the neighbours are children.
Returns
-------
adjacency_list : ... | [
"def",
"get_adjacency_list",
"(",
"self",
")",
":",
"# initialize list with empty lists",
"adjacency_list",
"=",
"[",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"n_vertices",
")",
"]",
"# get rows/columns of edges",
"rows",
",",
"cols",
"=",
"self",
... | https://github.com/menpo/menpo/blob/a61500656c4fc2eea82497684f13cc31a605550b/menpo/shape/graph.py#L323-L345 | |
thinkle/gourmet | 8af29c8ded24528030e5ae2ea3461f61c1e5a575 | gourmet/reccard.py | python | IngredientEditorModule.save | (self, recdic) | return recdic | [] | def save (self, recdic):
# Save ingredients...
self.ingtree_ui.ingController.commit_ingredients()
self.emit('saved')
return recdic | [
"def",
"save",
"(",
"self",
",",
"recdic",
")",
":",
"# Save ingredients...",
"self",
".",
"ingtree_ui",
".",
"ingController",
".",
"commit_ingredients",
"(",
")",
"self",
".",
"emit",
"(",
"'saved'",
")",
"return",
"recdic"
] | https://github.com/thinkle/gourmet/blob/8af29c8ded24528030e5ae2ea3461f61c1e5a575/gourmet/reccard.py#L1235-L1239 | |||
rembo10/headphones | b3199605be1ebc83a7a8feab6b1e99b64014187c | lib/requests/packages/urllib3/_collections.py | python | HTTPHeaderDict._copy_from | (self, other) | [] | def _copy_from(self, other):
for key in other:
val = other.getlist(key)
if isinstance(val, list):
# Don't need to convert tuples
val = list(val)
self._container[key.lower()] = [key] + val | [
"def",
"_copy_from",
"(",
"self",
",",
"other",
")",
":",
"for",
"key",
"in",
"other",
":",
"val",
"=",
"other",
".",
"getlist",
"(",
"key",
")",
"if",
"isinstance",
"(",
"val",
",",
"list",
")",
":",
"# Don't need to convert tuples",
"val",
"=",
"list... | https://github.com/rembo10/headphones/blob/b3199605be1ebc83a7a8feab6b1e99b64014187c/lib/requests/packages/urllib3/_collections.py#L277-L283 | ||||
PokemonGoF/PokemonGo-Bot-Desktop | 4bfa94f0183406c6a86f93645eff7abd3ad4ced8 | build/pywin/Lib/sets.py | python | BaseSet.__iter__ | (self) | return self._data.iterkeys() | Return an iterator over the elements or a set.
This is the keys iterator for the underlying dict. | Return an iterator over the elements or a set. | [
"Return",
"an",
"iterator",
"over",
"the",
"elements",
"or",
"a",
"set",
"."
] | def __iter__(self):
"""Return an iterator over the elements or a set.
This is the keys iterator for the underlying dict.
"""
return self._data.iterkeys() | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"iterkeys",
"(",
")"
] | https://github.com/PokemonGoF/PokemonGo-Bot-Desktop/blob/4bfa94f0183406c6a86f93645eff7abd3ad4ced8/build/pywin/Lib/sets.py#L101-L106 | |
selfteaching/selfteaching-python-camp | 9982ee964b984595e7d664b07c389cddaf158f1e | exercises/1901060005/day12/mymodule/d11_stats_word.py | python | stats_text | (text, count=20) | 合并英汉词频统计 ''' # whole text w | 合并英汉词频统计 ''' # whole text w | [
"合并英汉词频统计",
"#",
"whole",
"text",
"w"
] | def stats_text(text, count=20):
''' 合并英汉词频统计 ''' # whole text words frequence stats (en + cn) """?inside qualified comments?"""
if type(text) == str and isinstance(count, int):
return (stats_text_en(text, count)+stats_text_cn(text, count))
else:
print("Inappropriate argument value (of corre... | [
"def",
"stats_text",
"(",
"text",
",",
"count",
"=",
"20",
")",
":",
"ds frequence stats (en + cn) \"\"\"?inside qualified comments?\"\"\"",
"if",
"type",
"(",
"text",
")",
"==",
"str",
"and",
"isinstance",
"(",
"count",
",",
"int",
")",
":",
"return",
"(",
"s... | https://github.com/selfteaching/selfteaching-python-camp/blob/9982ee964b984595e7d664b07c389cddaf158f1e/exercises/1901060005/day12/mymodule/d11_stats_word.py#L77-L82 | ||
fangpenlin/bugbuzz-python | f1ba1ba8b6c22a60f3baac57ebfc2683bb2ec117 | bugbuzz/client.py | python | BugBuzzClient.upload_source | (self, filename, content) | return resp.json()['file'] | Uplaod source code to server | Uplaod source code to server | [
"Uplaod",
"source",
"code",
"to",
"server"
] | def upload_source(self, filename, content):
"""Uplaod source code to server
"""
url = self._api_url('sessions/{}/files'.format(self.session_id))
iv, encrpyted = self.encrypt(content)
resp = self.req_session.post(
url,
files=dict(
file=(fil... | [
"def",
"upload_source",
"(",
"self",
",",
"filename",
",",
"content",
")",
":",
"url",
"=",
"self",
".",
"_api_url",
"(",
"'sessions/{}/files'",
".",
"format",
"(",
"self",
".",
"session_id",
")",
")",
"iv",
",",
"encrpyted",
"=",
"self",
".",
"encrypt",... | https://github.com/fangpenlin/bugbuzz-python/blob/f1ba1ba8b6c22a60f3baac57ebfc2683bb2ec117/bugbuzz/client.py#L123-L137 | |
aws-samples/aws-kube-codesuite | ab4e5ce45416b83bffb947ab8d234df5437f4fca | src/kubernetes/client/models/v1alpha1_role.py | python | V1alpha1Role.__ne__ | (self, other) | return not self == other | Returns true if both objects are not equal | Returns true if both objects are not equal | [
"Returns",
"true",
"if",
"both",
"objects",
"are",
"not",
"equal"
] | def __ne__(self, other):
"""
Returns true if both objects are not equal
"""
return not self == other | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"return",
"not",
"self",
"==",
"other"
] | https://github.com/aws-samples/aws-kube-codesuite/blob/ab4e5ce45416b83bffb947ab8d234df5437f4fca/src/kubernetes/client/models/v1alpha1_role.py#L193-L197 | |
tomplus/kubernetes_asyncio | f028cc793e3a2c519be6a52a49fb77ff0b014c9b | kubernetes_asyncio/client/models/v1_owner_reference.py | python | V1OwnerReference.api_version | (self) | return self._api_version | Gets the api_version of this V1OwnerReference. # noqa: E501
API version of the referent. # noqa: E501
:return: The api_version of this V1OwnerReference. # noqa: E501
:rtype: str | Gets the api_version of this V1OwnerReference. # noqa: E501 | [
"Gets",
"the",
"api_version",
"of",
"this",
"V1OwnerReference",
".",
"#",
"noqa",
":",
"E501"
] | def api_version(self):
"""Gets the api_version of this V1OwnerReference. # noqa: E501
API version of the referent. # noqa: E501
:return: The api_version of this V1OwnerReference. # noqa: E501
:rtype: str
"""
return self._api_version | [
"def",
"api_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api_version"
] | https://github.com/tomplus/kubernetes_asyncio/blob/f028cc793e3a2c519be6a52a49fb77ff0b014c9b/kubernetes_asyncio/client/models/v1_owner_reference.py#L77-L85 | |
elastic/detection-rules | fd824d1fd5404c00eadb0251c8eb4f71af52a6d5 | detection_rules/eswrap.py | python | normalize_data | (events_file) | Normalize Elasticsearch data timestamps and sort. | Normalize Elasticsearch data timestamps and sort. | [
"Normalize",
"Elasticsearch",
"data",
"timestamps",
"and",
"sort",
"."
] | def normalize_data(events_file):
"""Normalize Elasticsearch data timestamps and sort."""
file_name = os.path.splitext(os.path.basename(events_file.name))[0]
events = RtaEvents({file_name: [json.loads(e) for e in events_file.readlines()]})
events.save(dump_dir=os.path.dirname(events_file.name)) | [
"def",
"normalize_data",
"(",
"events_file",
")",
":",
"file_name",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"events_file",
".",
"name",
")",
")",
"[",
"0",
"]",
"events",
"=",
"RtaEvents",
"(",
"{",
"fil... | https://github.com/elastic/detection-rules/blob/fd824d1fd5404c00eadb0251c8eb4f71af52a6d5/detection_rules/eswrap.py#L315-L319 | ||
pyg-team/pytorch_geometric | b920e9a3a64e22c8356be55301c88444ff051cae | examples/argva_node_clustering.py | python | Encoder.__init__ | (self, in_channels, hidden_channels, out_channels) | [] | def __init__(self, in_channels, hidden_channels, out_channels):
super().__init__()
self.conv1 = GCNConv(in_channels, hidden_channels)
self.conv_mu = GCNConv(hidden_channels, out_channels)
self.conv_logstd = GCNConv(hidden_channels, out_channels) | [
"def",
"__init__",
"(",
"self",
",",
"in_channels",
",",
"hidden_channels",
",",
"out_channels",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"conv1",
"=",
"GCNConv",
"(",
"in_channels",
",",
"hidden_channels",
")",
"self",
".",
"... | https://github.com/pyg-team/pytorch_geometric/blob/b920e9a3a64e22c8356be55301c88444ff051cae/examples/argva_node_clustering.py#L27-L31 | ||||
aws-samples/aws-kube-codesuite | ab4e5ce45416b83bffb947ab8d234df5437f4fca | src/kubernetes/client/models/v1beta1_self_subject_access_review.py | python | V1beta1SelfSubjectAccessReview.__ne__ | (self, other) | return not self == other | Returns true if both objects are not equal | Returns true if both objects are not equal | [
"Returns",
"true",
"if",
"both",
"objects",
"are",
"not",
"equal"
] | def __ne__(self, other):
"""
Returns true if both objects are not equal
"""
return not self == other | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"return",
"not",
"self",
"==",
"other"
] | https://github.com/aws-samples/aws-kube-codesuite/blob/ab4e5ce45416b83bffb947ab8d234df5437f4fca/src/kubernetes/client/models/v1beta1_self_subject_access_review.py#L217-L221 | |
ClusterLabs/pcs | 1f225199e02c8d20456bb386f4c913c3ff21ac78 | pcs/resource.py | python | resource_relocate_run | (cib_dom, resources=None, dry=True) | Commandline options:
* -f - CIB file, explicitly forbids -f if dry is False
* --force - allow constraint on any resource, may not have any effective
as an invalid copnstraint is ignored anyway | Commandline options:
* -f - CIB file, explicitly forbids -f if dry is False
* --force - allow constraint on any resource, may not have any effective
as an invalid copnstraint is ignored anyway | [
"Commandline",
"options",
":",
"*",
"-",
"f",
"-",
"CIB",
"file",
"explicitly",
"forbids",
"-",
"f",
"if",
"dry",
"is",
"False",
"*",
"--",
"force",
"-",
"allow",
"constraint",
"on",
"any",
"resource",
"may",
"not",
"have",
"any",
"effective",
"as",
"a... | def resource_relocate_run(cib_dom, resources=None, dry=True):
"""
Commandline options:
* -f - CIB file, explicitly forbids -f if dry is False
* --force - allow constraint on any resource, may not have any effective
as an invalid copnstraint is ignored anyway
"""
resources = [] if res... | [
"def",
"resource_relocate_run",
"(",
"cib_dom",
",",
"resources",
"=",
"None",
",",
"dry",
"=",
"True",
")",
":",
"resources",
"=",
"[",
"]",
"if",
"resources",
"is",
"None",
"else",
"resources",
"was_error",
"=",
"False",
"anything_changed",
"=",
"False",
... | https://github.com/ClusterLabs/pcs/blob/1f225199e02c8d20456bb386f4c913c3ff21ac78/pcs/resource.py#L3268-L3332 | ||
clips/pattern | d25511f9ca7ed9356b801d8663b8b5168464e68f | pattern/metrics.py | python | F | (classify=lambda document: False, documents=[], beta=1, average=None) | return (beta ** 2 + 1) * P * R / ((beta ** 2 * P + R) or 1) | Returns the weighted harmonic mean of precision and recall,
where recall is beta times more important than precision. | Returns the weighted harmonic mean of precision and recall,
where recall is beta times more important than precision. | [
"Returns",
"the",
"weighted",
"harmonic",
"mean",
"of",
"precision",
"and",
"recall",
"where",
"recall",
"is",
"beta",
"times",
"more",
"important",
"than",
"precision",
"."
] | def F(classify=lambda document: False, documents=[], beta=1, average=None):
""" Returns the weighted harmonic mean of precision and recall,
where recall is beta times more important than precision.
"""
A, P, R, F1 = test(classify, documents, average)
return (beta ** 2 + 1) * P * R / ((beta ** 2 ... | [
"def",
"F",
"(",
"classify",
"=",
"lambda",
"document",
":",
"False",
",",
"documents",
"=",
"[",
"]",
",",
"beta",
"=",
"1",
",",
"average",
"=",
"None",
")",
":",
"A",
",",
"P",
",",
"R",
",",
"F1",
"=",
"test",
"(",
"classify",
",",
"documen... | https://github.com/clips/pattern/blob/d25511f9ca7ed9356b801d8663b8b5168464e68f/pattern/metrics.py#L200-L205 | |
FSecureLABS/Jandroid | e31d0dab58a2bfd6ed8e0a387172b8bd7c893436 | libs/platform-tools/platform-tools_windows/systrace/catapult/third_party/pyserial/serial/sermsdos.py | python | Serial.setDTR | (self,level=1) | Set terminal status line | Set terminal status line | [
"Set",
"terminal",
"status",
"line"
] | def setDTR(self,level=1):
"""Set terminal status line"""
raise NotImplementedError | [
"def",
"setDTR",
"(",
"self",
",",
"level",
"=",
"1",
")",
":",
"raise",
"NotImplementedError"
] | https://github.com/FSecureLABS/Jandroid/blob/e31d0dab58a2bfd6ed8e0a387172b8bd7c893436/libs/platform-tools/platform-tools_windows/systrace/catapult/third_party/pyserial/serial/sermsdos.py#L173-L175 | ||
certbot/certbot | 30b066f08260b73fc26256b5484a180468b9d0a6 | certbot/certbot/_internal/cli/helpful.py | python | HelpfulArgumentParser.determine_help_topics | (self, chosen_topic: Union[str, bool]
) | return {t: t == chosen_topic for t in self.help_topics} | The user may have requested help on a topic, return a dict of which
topics to display. @chosen_topic has prescan_for_flag's return type
:returns: dict | [] | def determine_help_topics(self, chosen_topic: Union[str, bool]
) -> Dict[Optional[str], bool]:
"""
The user may have requested help on a topic, return a dict of which
topics to display. @chosen_topic has prescan_for_flag's return type
:returns: dict
... | [
"def",
"determine_help_topics",
"(",
"self",
",",
"chosen_topic",
":",
"Union",
"[",
"str",
",",
"bool",
"]",
")",
"->",
"Dict",
"[",
"Optional",
"[",
"str",
"]",
",",
"bool",
"]",
":",
"# topics maps each topic to whether it should be documented by",
"# argparse ... | https://github.com/certbot/certbot/blob/30b066f08260b73fc26256b5484a180468b9d0a6/certbot/certbot/_internal/cli/helpful.py#L476-L497 | ||
rowliny/DiffHelper | ab3a96f58f9579d0023aed9ebd785f4edf26f8af | Tool/SitePackages/click/globals.py | python | pop_context | () | Removes the top level from the stack. | Removes the top level from the stack. | [
"Removes",
"the",
"top",
"level",
"from",
"the",
"stack",
"."
] | def pop_context() -> None:
"""Removes the top level from the stack."""
_local.stack.pop() | [
"def",
"pop_context",
"(",
")",
"->",
"None",
":",
"_local",
".",
"stack",
".",
"pop",
"(",
")"
] | https://github.com/rowliny/DiffHelper/blob/ab3a96f58f9579d0023aed9ebd785f4edf26f8af/Tool/SitePackages/click/globals.py#L51-L53 | ||
line/promgen | 1e20263ca20460e1817f6557b9233e07aef17c77 | promgen/views.py | python | RuleUpdate.form_invalid | (self, **kwargs) | return self.render_to_response(self.get_context_data(**kwargs)) | If the form is invalid, render the invalid form. | If the form is invalid, render the invalid form. | [
"If",
"the",
"form",
"is",
"invalid",
"render",
"the",
"invalid",
"form",
"."
] | def form_invalid(self, **kwargs):
"""If the form is invalid, render the invalid form."""
return self.render_to_response(self.get_context_data(**kwargs)) | [
"def",
"form_invalid",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"render_to_response",
"(",
"self",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
")"
] | https://github.com/line/promgen/blob/1e20263ca20460e1817f6557b9233e07aef17c77/promgen/views.py#L779-L781 | |
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/coding/hamming_code.py | python | HammingCode.__hash__ | (self) | return hash((self.length(), self.dimension())) | Return the hash of ``self``.
EXAMPLES::
sage: C1 = codes.HammingCode(GF(7), 3)
sage: C2 = codes.HammingCode(GF(7), 3)
sage: hash(C1) == hash(C2)
True | Return the hash of ``self``. | [
"Return",
"the",
"hash",
"of",
"self",
"."
] | def __hash__(self):
"""
Return the hash of ``self``.
EXAMPLES::
sage: C1 = codes.HammingCode(GF(7), 3)
sage: C2 = codes.HammingCode(GF(7), 3)
sage: hash(C1) == hash(C2)
True
"""
return hash((self.length(), self.dimension())) | [
"def",
"__hash__",
"(",
"self",
")",
":",
"return",
"hash",
"(",
"(",
"self",
".",
"length",
"(",
")",
",",
"self",
".",
"dimension",
"(",
")",
")",
")"
] | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/coding/hamming_code.py#L91-L102 | |
pythonzm/Ops | e6fdddad2cd6bc697805a2bdba521a26bacada50 | task/utils/ansible_api_v2.py | python | ANSRunner.run_playbook | (self, playbook_path, extra_vars=None) | run ansible playbook | run ansible playbook | [
"run",
"ansible",
"playbook"
] | def run_playbook(self, playbook_path, extra_vars=None):
"""
run ansible playbook
"""
try:
self.callback = PlayBookResultsCollector(sock=self.sock)
if extra_vars:
self.variable_manager.extra_vars = extra_vars
executor = PlaybookExecutor(... | [
"def",
"run_playbook",
"(",
"self",
",",
"playbook_path",
",",
"extra_vars",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"callback",
"=",
"PlayBookResultsCollector",
"(",
"sock",
"=",
"self",
".",
"sock",
")",
"if",
"extra_vars",
":",
"self",
".",
"v... | https://github.com/pythonzm/Ops/blob/e6fdddad2cd6bc697805a2bdba521a26bacada50/task/utils/ansible_api_v2.py#L300-L317 | ||
earthgecko/skyline | 12754424de72593e29eb21009fb1ae3f07f3abff | skyline/functions/metrics/get_base_names_and_metric_ids.py | python | get_base_names_and_metric_ids | (current_skyline_app) | return base_names_with_ids | Returns a dict of base_names with their metric id from the
aet.metrics_manager.ids_with_metric_names Redis hash.
:param current_skyline_app: the app calling the function
:param metric_id: the metric id to lookup the base_name for.
:type current_skyline_app: str
:type metric_id: int
:return: bas... | Returns a dict of base_names with their metric id from the
aet.metrics_manager.ids_with_metric_names Redis hash. | [
"Returns",
"a",
"dict",
"of",
"base_names",
"with",
"their",
"metric",
"id",
"from",
"the",
"aet",
".",
"metrics_manager",
".",
"ids_with_metric_names",
"Redis",
"hash",
"."
] | def get_base_names_and_metric_ids(current_skyline_app):
"""
Returns a dict of base_names with their metric id from the
aet.metrics_manager.ids_with_metric_names Redis hash.
:param current_skyline_app: the app calling the function
:param metric_id: the metric id to lookup the base_name for.
:typ... | [
"def",
"get_base_names_and_metric_ids",
"(",
"current_skyline_app",
")",
":",
"base_names_with_ids",
"=",
"{",
"}",
"redis_key",
"=",
"'aet.metrics_manager.metric_names_with_ids'",
"function_str",
"=",
"'functions.metrics.get_base_name_from_metric_id'",
"try",
":",
"redis_conn_de... | https://github.com/earthgecko/skyline/blob/12754424de72593e29eb21009fb1ae3f07f3abff/skyline/functions/metrics/get_base_names_and_metric_ids.py#L7-L50 | |
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/combinat/designs/incidence_structures.py | python | IncidenceStructure.intersection_graph | (self, sizes=None) | return Graph([V, lambda x,y: len(x & y) in sizes], loops=False) | r"""
Return the intersection graph of the incidence structure.
The vertices of this graph are the :meth:`blocks` of the incidence
structure. Two of them are adjacent if the size of their intersection
belongs to the set ``sizes``.
INPUT:
- ``sizes`` -- a list/set of int... | r"""
Return the intersection graph of the incidence structure. | [
"r",
"Return",
"the",
"intersection",
"graph",
"of",
"the",
"incidence",
"structure",
"."
] | def intersection_graph(self, sizes=None):
r"""
Return the intersection graph of the incidence structure.
The vertices of this graph are the :meth:`blocks` of the incidence
structure. Two of them are adjacent if the size of their intersection
belongs to the set ``sizes``.
... | [
"def",
"intersection_graph",
"(",
"self",
",",
"sizes",
"=",
"None",
")",
":",
"from",
"sage",
".",
"sets",
".",
"positive_integers",
"import",
"PositiveIntegers",
"from",
"sage",
".",
"graphs",
".",
"graph",
"import",
"Graph",
"from",
"sage",
".",
"sets",
... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/combinat/designs/incidence_structures.py#L1076-L1110 | |
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/pandas-0.24.2-py3.7-macosx-10.9-x86_64.egg/pandas/core/frame.py | python | DataFrame.join | (self, other, on=None, how='left', lsuffix='', rsuffix='',
sort=False) | return self._join_compat(other, on=on, how=how, lsuffix=lsuffix,
rsuffix=rsuffix, sort=sort) | Join columns of another DataFrame.
Join columns with `other` DataFrame either on index or on a key
column. Efficiently join multiple DataFrame objects by index at once by
passing a list.
Parameters
----------
other : DataFrame, Series, or list of DataFrame
I... | Join columns of another DataFrame. | [
"Join",
"columns",
"of",
"another",
"DataFrame",
"."
] | def join(self, other, on=None, how='left', lsuffix='', rsuffix='',
sort=False):
"""
Join columns of another DataFrame.
Join columns with `other` DataFrame either on index or on a key
column. Efficiently join multiple DataFrame objects by index at once by
passing a l... | [
"def",
"join",
"(",
"self",
",",
"other",
",",
"on",
"=",
"None",
",",
"how",
"=",
"'left'",
",",
"lsuffix",
"=",
"''",
",",
"rsuffix",
"=",
"''",
",",
"sort",
"=",
"False",
")",
":",
"# For SparseDataFrame's benefit",
"return",
"self",
".",
"_join_com... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/pandas-0.24.2-py3.7-macosx-10.9-x86_64.egg/pandas/core/frame.py#L6694-L6815 | |
TRI-ML/packnet-sfm | f59b1d615777a9987285a10e45b5d87b0369fa7d | packnet_sfm/geometry/pose.py | python | Pose.identity | (cls, N=1, device=None, dtype=torch.float) | return cls(torch.eye(4, device=device, dtype=dtype).repeat([N,1,1])) | Initializes as a [4,4] identity matrix | Initializes as a [4,4] identity matrix | [
"Initializes",
"as",
"a",
"[",
"4",
"4",
"]",
"identity",
"matrix"
] | def identity(cls, N=1, device=None, dtype=torch.float):
"""Initializes as a [4,4] identity matrix"""
return cls(torch.eye(4, device=device, dtype=dtype).repeat([N,1,1])) | [
"def",
"identity",
"(",
"cls",
",",
"N",
"=",
"1",
",",
"device",
"=",
"None",
",",
"dtype",
"=",
"torch",
".",
"float",
")",
":",
"return",
"cls",
"(",
"torch",
".",
"eye",
"(",
"4",
",",
"device",
"=",
"device",
",",
"dtype",
"=",
"dtype",
")... | https://github.com/TRI-ML/packnet-sfm/blob/f59b1d615777a9987285a10e45b5d87b0369fa7d/packnet_sfm/geometry/pose.py#L35-L37 | |
wistbean/learn_python3_spider | 73c873f4845f4385f097e5057407d03dd37a117b | stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/task.py | python | Cooperator._addTask | (self, task) | Add a L{CooperativeTask} object to this L{Cooperator}. | Add a L{CooperativeTask} object to this L{Cooperator}. | [
"Add",
"a",
"L",
"{",
"CooperativeTask",
"}",
"object",
"to",
"this",
"L",
"{",
"Cooperator",
"}",
"."
] | def _addTask(self, task):
"""
Add a L{CooperativeTask} object to this L{Cooperator}.
"""
if self._stopped:
self._tasks.append(task) # XXX silly, I know, but _completeWith
# does the inverse
task._completeWith(SchedulerStopped()... | [
"def",
"_addTask",
"(",
"self",
",",
"task",
")",
":",
"if",
"self",
".",
"_stopped",
":",
"self",
".",
"_tasks",
".",
"append",
"(",
"task",
")",
"# XXX silly, I know, but _completeWith",
"# does the inverse",
"task",
".",
"_completeWith",
"(",
"SchedulerStoppe... | https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/task.py#L627-L637 | ||
mjq11302010044/RRPN_pytorch | a966f6f238c03498514742cde5cd98e51efb440c | maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py | python | MaskRCNNLossComputation.__init__ | (self, proposal_matcher, discretization_size) | Arguments:
proposal_matcher (Matcher)
discretization_size (int) | Arguments:
proposal_matcher (Matcher)
discretization_size (int) | [
"Arguments",
":",
"proposal_matcher",
"(",
"Matcher",
")",
"discretization_size",
"(",
"int",
")"
] | def __init__(self, proposal_matcher, discretization_size):
"""
Arguments:
proposal_matcher (Matcher)
discretization_size (int)
"""
self.proposal_matcher = proposal_matcher
self.discretization_size = discretization_size | [
"def",
"__init__",
"(",
"self",
",",
"proposal_matcher",
",",
"discretization_size",
")",
":",
"self",
".",
"proposal_matcher",
"=",
"proposal_matcher",
"self",
".",
"discretization_size",
"=",
"discretization_size"
] | https://github.com/mjq11302010044/RRPN_pytorch/blob/a966f6f238c03498514742cde5cd98e51efb440c/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py#L48-L55 | ||
tensorflow/ranking | 94cccec8b4e71d2cc4489c61e2623522738c2924 | tensorflow_ranking/python/head.py | python | _RankingHead.create_estimator_spec | (self,
features,
mode,
logits,
labels=None,
regularization_losses=None) | See `_AbstractRankingHead`. | See `_AbstractRankingHead`. | [
"See",
"_AbstractRankingHead",
"."
] | def create_estimator_spec(self,
features,
mode,
logits,
labels=None,
regularization_losses=None):
"""See `_AbstractRankingHead`."""
logits = tf.convert_to_tensor(value=logi... | [
"def",
"create_estimator_spec",
"(",
"self",
",",
"features",
",",
"mode",
",",
"logits",
",",
"labels",
"=",
"None",
",",
"regularization_losses",
"=",
"None",
")",
":",
"logits",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"value",
"=",
"logits",
")",
"# P... | https://github.com/tensorflow/ranking/blob/94cccec8b4e71d2cc4489c61e2623522738c2924/tensorflow_ranking/python/head.py#L217-L270 | ||
oilshell/oil | 94388e7d44a9ad879b12615f6203b38596b5a2d3 | demo/old/encode.py | python | EncodeError.__init__ | (self, *args, **kwargs) | [] | def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
self.details_printed = False | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"Exception",
".",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"details_printed",
"=",
"False"
] | https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/demo/old/encode.py#L13-L15 | ||||
biopython/biopython | 2dd97e71762af7b046d7f7f8a4f1e38db6b06c86 | Bio/File.py | python | as_handle | (handleish, mode="r", **kwargs) | r"""Context manager to ensure we are using a handle.
Context manager for arguments that can be passed to SeqIO and AlignIO read, write,
and parse methods: either file objects or path-like objects (strings, pathlib.Path
instances, or more generally, anything that can be handled by the builtin 'open'
fun... | r"""Context manager to ensure we are using a handle. | [
"r",
"Context",
"manager",
"to",
"ensure",
"we",
"are",
"using",
"a",
"handle",
"."
] | def as_handle(handleish, mode="r", **kwargs):
r"""Context manager to ensure we are using a handle.
Context manager for arguments that can be passed to SeqIO and AlignIO read, write,
and parse methods: either file objects or path-like objects (strings, pathlib.Path
instances, or more generally, anything... | [
"def",
"as_handle",
"(",
"handleish",
",",
"mode",
"=",
"\"r\"",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"with",
"open",
"(",
"handleish",
",",
"mode",
",",
"*",
"*",
"kwargs",
")",
"as",
"fp",
":",
"yield",
"fp",
"except",
"TypeError",
":",... | https://github.com/biopython/biopython/blob/2dd97e71762af7b046d7f7f8a4f1e38db6b06c86/Bio/File.py#L29-L75 | ||
google/aiyprojects-raspbian | 964f07f5b4bd2ec785cfda6f318e50e1b67d4758 | src/aiy/assistant/auth_helpers.py | python | get_assistant_credentials | (credentials_file=None) | return _try_to_get_credentials(credentials_file) | Retreives the OAuth credentials required to access the Google Assistant API.
If you're using :mod:`aiy.assistant.library`, you must call this function and pass the result
to the :class:`~aiy.assistant.library.Assistant` constructor.
If you're using :mod:`aiy.assistant.grpc`, you do not need this function ... | Retreives the OAuth credentials required to access the Google Assistant API. | [
"Retreives",
"the",
"OAuth",
"credentials",
"required",
"to",
"access",
"the",
"Google",
"Assistant",
"API",
"."
] | def get_assistant_credentials(credentials_file=None):
"""
Retreives the OAuth credentials required to access the Google Assistant API.
If you're using :mod:`aiy.assistant.library`, you must call this function and pass the result
to the :class:`~aiy.assistant.library.Assistant` constructor.
If you'... | [
"def",
"get_assistant_credentials",
"(",
"credentials_file",
"=",
"None",
")",
":",
"if",
"not",
"credentials_file",
":",
"credentials_file",
"=",
"_ASSISTANT_CREDENTIALS_FILE",
"return",
"_try_to_get_credentials",
"(",
"credentials_file",
")"
] | https://github.com/google/aiyprojects-raspbian/blob/964f07f5b4bd2ec785cfda6f318e50e1b67d4758/src/aiy/assistant/auth_helpers.py#L129-L151 | |
CLUEbenchmark/CLUE | 5bd39732734afecb490cf18a5212e692dbf2c007 | baselines/models/albert/create_pretraining_data.py | python | create_int_feature | (values) | return feature | [] | def create_int_feature(values):
feature = tf.train.Feature(int64_list=tf.train.Int64List(value=list(values)))
return feature | [
"def",
"create_int_feature",
"(",
"values",
")",
":",
"feature",
"=",
"tf",
".",
"train",
".",
"Feature",
"(",
"int64_list",
"=",
"tf",
".",
"train",
".",
"Int64List",
"(",
"value",
"=",
"list",
"(",
"values",
")",
")",
")",
"return",
"feature"
] | https://github.com/CLUEbenchmark/CLUE/blob/5bd39732734afecb490cf18a5212e692dbf2c007/baselines/models/albert/create_pretraining_data.py#L172-L174 | |||
ctxis/CAPE | dae9fa6a254ecdbabeb7eb0d2389fa63722c1e82 | lib/cuckoo/core/database.py | python | Database.__init__ | (self, dsn=None, schema_check=True) | @param dsn: database connection string.
@param schema_check: disable or enable the db schema version check | [] | def __init__(self, dsn=None, schema_check=True):
"""@param dsn: database connection string.
@param schema_check: disable or enable the db schema version check
"""
self._lock = SuperLock()
self.cfg = Config()
if dsn:
self._connect_database(dsn)
elif se... | [
"def",
"__init__",
"(",
"self",
",",
"dsn",
"=",
"None",
",",
"schema_check",
"=",
"True",
")",
":",
"self",
".",
"_lock",
"=",
"SuperLock",
"(",
")",
"self",
".",
"cfg",
"=",
"Config",
"(",
")",
"if",
"dsn",
":",
"self",
".",
"_connect_database",
... | https://github.com/ctxis/CAPE/blob/dae9fa6a254ecdbabeb7eb0d2389fa63722c1e82/lib/cuckoo/core/database.py#L360-L425 | |||
chribsen/simple-machine-learning-examples | dc94e52a4cebdc8bb959ff88b81ff8cfeca25022 | venv/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/specifiers.py | python | BaseSpecifier.__ne__ | (self, other) | Returns a boolean representing whether or not the two Specifier like
objects are not equal. | Returns a boolean representing whether or not the two Specifier like
objects are not equal. | [
"Returns",
"a",
"boolean",
"representing",
"whether",
"or",
"not",
"the",
"two",
"Specifier",
"like",
"objects",
"are",
"not",
"equal",
"."
] | def __ne__(self, other):
"""
Returns a boolean representing whether or not the two Specifier like
objects are not equal.
""" | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":"
] | https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/specifiers.py#L44-L48 | ||
wbond/packagecontrol.io | 9f5eb7e3392e6bc2ad979ad32d3dd27ef9c00b20 | app/lib/package_control/deps/asn1crypto/core.py | python | ParsableOctetString.set | (self, value) | Sets the value of the object
:param value:
A byte string | Sets the value of the object | [
"Sets",
"the",
"value",
"of",
"the",
"object"
] | def set(self, value):
"""
Sets the value of the object
:param value:
A byte string
"""
if not isinstance(value, byte_cls):
raise TypeError(unwrap(
'''
%s value must be a byte string, not %s
''',
... | [
"def",
"set",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"byte_cls",
")",
":",
"raise",
"TypeError",
"(",
"unwrap",
"(",
"'''\n %s value must be a byte string, not %s\n '''",
",",
"type_name",
"("... | https://github.com/wbond/packagecontrol.io/blob/9f5eb7e3392e6bc2ad979ad32d3dd27ef9c00b20/app/lib/package_control/deps/asn1crypto/core.py#L2747-L2771 | ||
llSourcell/How_to_generate_music_in_tensorflow_LIVE | b89c9a0a743a28a8c332bedb8ad2908b3e23c9be | deepmusic/model_old.py | python | Model._build_network | (self) | Create the computational graph | Create the computational graph | [
"Create",
"the",
"computational",
"graph"
] | def _build_network(self):
""" Create the computational graph
"""
# Placeholders (Use tf.SparseTensor with training=False instead) (TODO: Try restoring dynamic batch_size)
with tf.name_scope('placeholder_inputs'):
self.inputs = [
tf.placeholder(
... | [
"def",
"_build_network",
"(",
"self",
")",
":",
"# Placeholders (Use tf.SparseTensor with training=False instead) (TODO: Try restoring dynamic batch_size)",
"with",
"tf",
".",
"name_scope",
"(",
"'placeholder_inputs'",
")",
":",
"self",
".",
"inputs",
"=",
"[",
"tf",
".",
... | https://github.com/llSourcell/How_to_generate_music_in_tensorflow_LIVE/blob/b89c9a0a743a28a8c332bedb8ad2908b3e23c9be/deepmusic/model_old.py#L228-L345 | ||
wbond/oscrypto | d40c62577706682a0f6da5616ad09964f1c9137d | oscrypto/_win/_advapi32.py | python | handle_error | (result) | Extracts the last Windows error message into a python unicode string
:param result:
A function result, 0 or None indicates failure
:return:
A unicode string error message | Extracts the last Windows error message into a python unicode string | [
"Extracts",
"the",
"last",
"Windows",
"error",
"message",
"into",
"a",
"python",
"unicode",
"string"
] | def handle_error(result):
"""
Extracts the last Windows error message into a python unicode string
:param result:
A function result, 0 or None indicates failure
:return:
A unicode string error message
"""
if result:
return
code, error_string = get_error()
if ... | [
"def",
"handle_error",
"(",
"result",
")",
":",
"if",
"result",
":",
"return",
"code",
",",
"error_string",
"=",
"get_error",
"(",
")",
"if",
"code",
"==",
"Advapi32Const",
".",
"NTE_BAD_SIGNATURE",
":",
"raise",
"SignatureError",
"(",
"'Signature is invalid'",
... | https://github.com/wbond/oscrypto/blob/d40c62577706682a0f6da5616ad09964f1c9137d/oscrypto/_win/_advapi32.py#L73-L95 | ||
nosmokingbandit/Watcher3 | 0217e75158b563bdefc8e01c3be7620008cf3977 | lib/requests/packages/urllib3/util/selectors.py | python | BaseSelector.select | (self, timeout=None) | Perform the actual selection until some monitored file objects
are ready or the timeout expires. | Perform the actual selection until some monitored file objects
are ready or the timeout expires. | [
"Perform",
"the",
"actual",
"selection",
"until",
"some",
"monitored",
"file",
"objects",
"are",
"ready",
"or",
"the",
"timeout",
"expires",
"."
] | def select(self, timeout=None):
""" Perform the actual selection until some monitored file objects
are ready or the timeout expires. """
raise NotImplementedError() | [
"def",
"select",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | https://github.com/nosmokingbandit/Watcher3/blob/0217e75158b563bdefc8e01c3be7620008cf3977/lib/requests/packages/urllib3/util/selectors.py#L215-L218 | ||
bbc/brave | 88d4454412ee5acfa5ecf2ac5bc8cf75766c7be5 | brave/connections/connection_to_mixer.py | python | ConnectionToMixer._get_or_create_tee_pad | (self, audio_or_video) | [] | def _get_or_create_tee_pad(self, audio_or_video):
if audio_or_video in self._tee_pad:
return self._tee_pad[audio_or_video]
else:
tee_src_pad_template = self._tee[audio_or_video].get_pad_template("src_%u")
self._tee_pad[audio_or_video] = self._tee[audio_or_video].reque... | [
"def",
"_get_or_create_tee_pad",
"(",
"self",
",",
"audio_or_video",
")",
":",
"if",
"audio_or_video",
"in",
"self",
".",
"_tee_pad",
":",
"return",
"self",
".",
"_tee_pad",
"[",
"audio_or_video",
"]",
"else",
":",
"tee_src_pad_template",
"=",
"self",
".",
"_t... | https://github.com/bbc/brave/blob/88d4454412ee5acfa5ecf2ac5bc8cf75766c7be5/brave/connections/connection_to_mixer.py#L175-L181 | ||||
mikf/gallery-dl | 58a7921b5c990f5072e2b55b4644d0574512d3e1 | gallery_dl/extractor/livedoor.py | python | LivedoorExtractor.posts | (self) | Return an iterable with post objects | Return an iterable with post objects | [
"Return",
"an",
"iterable",
"with",
"post",
"objects"
] | def posts(self):
"""Return an iterable with post objects""" | [
"def",
"posts",
"(",
"self",
")",
":"
] | https://github.com/mikf/gallery-dl/blob/58a7921b5c990f5072e2b55b4644d0574512d3e1/gallery_dl/extractor/livedoor.py#L35-L36 | ||
omni-us/squeezedet-keras | cb3555041cbb175221a42f83677023dbfcbdd00d | main/utils/utils.py | python | sparse_to_dense | (sp_indices, output_shape, values, default_value=0) | return array | Build a dense matrix from sparse representations.
Args:
sp_indices: A [0-2]-D array that contains the index to place values.
shape: shape of the dense matrix.
values: A {0,1}-D array where values corresponds to the index in each row of
sp_indices.
default_value: values to set for indices not spec... | Build a dense matrix from sparse representations. | [
"Build",
"a",
"dense",
"matrix",
"from",
"sparse",
"representations",
"."
] | def sparse_to_dense(sp_indices, output_shape, values, default_value=0):
"""Build a dense matrix from sparse representations.
Args:
sp_indices: A [0-2]-D array that contains the index to place values.
shape: shape of the dense matrix.
values: A {0,1}-D array where values corresponds to the index in each... | [
"def",
"sparse_to_dense",
"(",
"sp_indices",
",",
"output_shape",
",",
"values",
",",
"default_value",
"=",
"0",
")",
":",
"assert",
"len",
"(",
"sp_indices",
")",
"==",
"len",
"(",
"values",
")",
",",
"'Length of sp_indices is not equal to length of values'",
"ar... | https://github.com/omni-us/squeezedet-keras/blob/cb3555041cbb175221a42f83677023dbfcbdd00d/main/utils/utils.py#L155-L174 | |
jimenbian/DataMining | 6b1fc93319a3cdda835e158029ac133665d13191 | DecisionStump/src/Adaboosting.py | python | buildStump | (dataArr,classLabels,D) | return bestStump,minError,bestClasEst | [] | def buildStump(dataArr,classLabels,D):
dataMatrix = mat(dataArr); labelMat = mat(classLabels).T
m,n = shape(dataMatrix)
numSteps = 10.0; bestStump = {}; bestClasEst = mat(zeros((m,1)))
minError = inf #init error sum, to +infinity
for i in range(n):#loop over all dimensions
rangeMin = dataMat... | [
"def",
"buildStump",
"(",
"dataArr",
",",
"classLabels",
",",
"D",
")",
":",
"dataMatrix",
"=",
"mat",
"(",
"dataArr",
")",
"labelMat",
"=",
"mat",
"(",
"classLabels",
")",
".",
"T",
"m",
",",
"n",
"=",
"shape",
"(",
"dataMatrix",
")",
"numSteps",
"=... | https://github.com/jimenbian/DataMining/blob/6b1fc93319a3cdda835e158029ac133665d13191/DecisionStump/src/Adaboosting.py#L35-L62 | |||
pwnieexpress/pwn_plug_sources | 1a23324f5dc2c3de20f9c810269b6a29b2758cad | src/voiper/sulley/impacket/smb.py | python | SMB.read_andx | (self, tid, fid, offset=0, max_size = None, wait_answer=1) | return None | [] | def read_andx(self, tid, fid, offset=0, max_size = None, wait_answer=1):
if not max_size:
max_size = self.__ntlm_dialect.get_max_buffer() # Read in multiple KB blocks
# max_size is not working, because although it would, the server returns an error (More data avail)
smb = N... | [
"def",
"read_andx",
"(",
"self",
",",
"tid",
",",
"fid",
",",
"offset",
"=",
"0",
",",
"max_size",
"=",
"None",
",",
"wait_answer",
"=",
"1",
")",
":",
"if",
"not",
"max_size",
":",
"max_size",
"=",
"self",
".",
"__ntlm_dialect",
".",
"get_max_buffer",... | https://github.com/pwnieexpress/pwn_plug_sources/blob/1a23324f5dc2c3de20f9c810269b6a29b2758cad/src/voiper/sulley/impacket/smb.py#L1849-L1888 | |||
apache/tvm | 6eb4ed813ebcdcd9558f0906a1870db8302ff1e0 | python/tvm/relay/op/image/image.py | python | resize1d | (
data,
size,
roi=None,
layout="NCW",
method="linear",
coordinate_transformation_mode="half_pixel",
rounding_method="",
cubic_alpha=-0.5,
cubic_exclude=0,
extrapolation_value=0.0,
out_dtype=None,
) | return _make.resize1d(
data,
size,
roi,
layout,
method,
coordinate_transformation_mode,
rounding_method,
cubic_alpha,
cubic_exclude,
extrapolation_value,
out_dtype,
) | Image resize1d operator.
This operator takes data as input and does 1D scaling to the given scale factor.
In the default case, where the data_layout is `NCW`
with data of shape (n, c, w)
out will have a shape (n, c, size[0])
method indicates the algorithm to be used while calculating the out value... | Image resize1d operator. | [
"Image",
"resize1d",
"operator",
"."
] | def resize1d(
data,
size,
roi=None,
layout="NCW",
method="linear",
coordinate_transformation_mode="half_pixel",
rounding_method="",
cubic_alpha=-0.5,
cubic_exclude=0,
extrapolation_value=0.0,
out_dtype=None,
):
"""Image resize1d operator.
This operator takes data as ... | [
"def",
"resize1d",
"(",
"data",
",",
"size",
",",
"roi",
"=",
"None",
",",
"layout",
"=",
"\"NCW\"",
",",
"method",
"=",
"\"linear\"",
",",
"coordinate_transformation_mode",
"=",
"\"half_pixel\"",
",",
"rounding_method",
"=",
"\"\"",
",",
"cubic_alpha",
"=",
... | https://github.com/apache/tvm/blob/6eb4ed813ebcdcd9558f0906a1870db8302ff1e0/python/tvm/relay/op/image/image.py#L23-L115 | |
chribsen/simple-machine-learning-examples | dc94e52a4cebdc8bb959ff88b81ff8cfeca25022 | venv/lib/python2.7/site-packages/pandas/tseries/holiday.py | python | Holiday._reference_dates | (self, start_date, end_date) | return dates | Get reference dates for the holiday.
Return reference dates for the holiday also returning the year
prior to the start_date and year following the end_date. This ensures
that any offsets to be applied will yield the holidays within
the passed in dates. | Get reference dates for the holiday. | [
"Get",
"reference",
"dates",
"for",
"the",
"holiday",
"."
] | def _reference_dates(self, start_date, end_date):
"""
Get reference dates for the holiday.
Return reference dates for the holiday also returning the year
prior to the start_date and year following the end_date. This ensures
that any offsets to be applied will yield the holidays... | [
"def",
"_reference_dates",
"(",
"self",
",",
"start_date",
",",
"end_date",
")",
":",
"if",
"self",
".",
"start_date",
"is",
"not",
"None",
":",
"start_date",
"=",
"self",
".",
"start_date",
".",
"tz_localize",
"(",
"start_date",
".",
"tz",
")",
"if",
"s... | https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/pandas/tseries/holiday.py#L232-L258 | |
pypa/pipenv | b21baade71a86ab3ee1429f71fbc14d4f95fb75d | pipenv/vendor/yaspin/api.py | python | yaspin | (*args, **kwargs) | return Yaspin(*args, **kwargs) | Display spinner in stdout.
Can be used as a context manager or as a function decorator.
Arguments:
spinner (base_spinner.Spinner, optional): Spinner object to use.
text (str, optional): Text to show along with spinner.
color (str, optional): Spinner color.
on_color (str, option... | Display spinner in stdout. | [
"Display",
"spinner",
"in",
"stdout",
"."
] | def yaspin(*args, **kwargs):
"""Display spinner in stdout.
Can be used as a context manager or as a function decorator.
Arguments:
spinner (base_spinner.Spinner, optional): Spinner object to use.
text (str, optional): Text to show along with spinner.
color (str, optional): Spinner ... | [
"def",
"yaspin",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Yaspin",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/pypa/pipenv/blob/b21baade71a86ab3ee1429f71fbc14d4f95fb75d/pipenv/vendor/yaspin/api.py#L17-L78 | |
inkandswitch/livebook | 93c8d467734787366ad084fc3566bf5cbe249c51 | public/pypyjs/modules/mimetypes.py | python | guess_all_extensions | (type, strict=True) | return _db.guess_all_extensions(type, strict) | Guess the extensions for a file based on its MIME type.
Return value is a list of strings giving the possible filename
extensions, including the leading dot ('.'). The extension is not
guaranteed to have been associated with any particular data
stream, but would be mapped to the MIME type `type' by
... | Guess the extensions for a file based on its MIME type. | [
"Guess",
"the",
"extensions",
"for",
"a",
"file",
"based",
"on",
"its",
"MIME",
"type",
"."
] | def guess_all_extensions(type, strict=True):
"""Guess the extensions for a file based on its MIME type.
Return value is a list of strings giving the possible filename
extensions, including the leading dot ('.'). The extension is not
guaranteed to have been associated with any particular data
strea... | [
"def",
"guess_all_extensions",
"(",
"type",
",",
"strict",
"=",
"True",
")",
":",
"if",
"_db",
"is",
"None",
":",
"init",
"(",
")",
"return",
"_db",
".",
"guess_all_extensions",
"(",
"type",
",",
"strict",
")"
] | https://github.com/inkandswitch/livebook/blob/93c8d467734787366ad084fc3566bf5cbe249c51/public/pypyjs/modules/mimetypes.py#L294-L309 | |
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework | cb692f527e4e819b6c228187c5702d990a180043 | external/Scripting Engine/Xenotix Python Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/logging/handlers.py | python | NTEventLogHandler.getEventCategory | (self, record) | return 0 | Return the event category for the record.
Override this if you want to specify your own categories. This version
returns 0. | Return the event category for the record. | [
"Return",
"the",
"event",
"category",
"for",
"the",
"record",
"."
] | def getEventCategory(self, record):
"""
Return the event category for the record.
Override this if you want to specify your own categories. This version
returns 0.
"""
return 0 | [
"def",
"getEventCategory",
"(",
"self",
",",
"record",
")",
":",
"return",
"0"
] | https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/Xenotix Python Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/logging/handlers.py#L943-L950 | |
OpenNMT/OpenNMT-py | 4815f07fcd482af9a1fe1d3b620d144197178bc5 | onmt/trainer.py | python | Trainer._maybe_report_training | (self, step, num_steps, learning_rate,
report_stats) | Simple function to report training stats (if report_manager is set)
see `onmt.utils.ReportManagerBase.report_training` for doc | Simple function to report training stats (if report_manager is set)
see `onmt.utils.ReportManagerBase.report_training` for doc | [
"Simple",
"function",
"to",
"report",
"training",
"stats",
"(",
"if",
"report_manager",
"is",
"set",
")",
"see",
"onmt",
".",
"utils",
".",
"ReportManagerBase",
".",
"report_training",
"for",
"doc"
] | def _maybe_report_training(self, step, num_steps, learning_rate,
report_stats):
"""
Simple function to report training stats (if report_manager is set)
see `onmt.utils.ReportManagerBase.report_training` for doc
"""
if self.report_manager is not None... | [
"def",
"_maybe_report_training",
"(",
"self",
",",
"step",
",",
"num_steps",
",",
"learning_rate",
",",
"report_stats",
")",
":",
"if",
"self",
".",
"report_manager",
"is",
"not",
"None",
":",
"return",
"self",
".",
"report_manager",
".",
"report_training",
"(... | https://github.com/OpenNMT/OpenNMT-py/blob/4815f07fcd482af9a1fe1d3b620d144197178bc5/onmt/trainer.py#L447-L461 | ||
tobegit3hub/deep_image_model | 8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e | java_predict_client/src/main/proto/tensorflow/python/training/coordinator.py | python | Coordinator.clear_stop | (self) | Clears the stop flag.
After this is called, calls to `should_stop()` will return `False`. | Clears the stop flag. | [
"Clears",
"the",
"stop",
"flag",
"."
] | def clear_stop(self):
"""Clears the stop flag.
After this is called, calls to `should_stop()` will return `False`.
"""
with self._lock:
self._joined = False
self._exc_info_to_raise = None
if self._stop_event.is_set():
self._stop_event.clear() | [
"def",
"clear_stop",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"self",
".",
"_joined",
"=",
"False",
"self",
".",
"_exc_info_to_raise",
"=",
"None",
"if",
"self",
".",
"_stop_event",
".",
"is_set",
"(",
")",
":",
"self",
".",
"_stop_eve... | https://github.com/tobegit3hub/deep_image_model/blob/8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e/java_predict_client/src/main/proto/tensorflow/python/training/coordinator.py#L244-L253 | ||
vpelletier/python-libusb1 | 86ad8ab73f7442874de71c1f9f824724d21da92b | usb1/_libusb1.py | python | buffer_at | (address, length) | return bytearray((c_char * length).from_address(address)) | Simular to ctypes.string_at, but zero-copy and requires an integer address. | Simular to ctypes.string_at, but zero-copy and requires an integer address. | [
"Simular",
"to",
"ctypes",
".",
"string_at",
"but",
"zero",
"-",
"copy",
"and",
"requires",
"an",
"integer",
"address",
"."
] | def buffer_at(address, length):
"""
Simular to ctypes.string_at, but zero-copy and requires an integer address.
"""
return bytearray((c_char * length).from_address(address)) | [
"def",
"buffer_at",
"(",
"address",
",",
"length",
")",
":",
"return",
"bytearray",
"(",
"(",
"c_char",
"*",
"length",
")",
".",
"from_address",
"(",
"address",
")",
")"
] | https://github.com/vpelletier/python-libusb1/blob/86ad8ab73f7442874de71c1f9f824724d21da92b/usb1/_libusb1.py#L71-L75 | |
duerrp/pyexperiment | c426565d870d944bd5b9712629d8f1ba2527c67f | pyexperiment/utils/stdout_redirector.py | python | stdout_err_redirector | (stream_out, stream_err) | Redirect standard out and err to a buffer | Redirect standard out and err to a buffer | [
"Redirect",
"standard",
"out",
"and",
"err",
"to",
"a",
"buffer"
] | def stdout_err_redirector(stream_out, stream_err):
"""Redirect standard out and err to a buffer
"""
old_stdout = sys.stdout
sys.stdout = stream_out
old_stderr = sys.stderr
sys.stderr = stream_err
try:
yield
finally:
sys.stdout = old_stdout
sys.stderr = old_stderr | [
"def",
"stdout_err_redirector",
"(",
"stream_out",
",",
"stream_err",
")",
":",
"old_stdout",
"=",
"sys",
".",
"stdout",
"sys",
".",
"stdout",
"=",
"stream_out",
"old_stderr",
"=",
"sys",
".",
"stderr",
"sys",
".",
"stderr",
"=",
"stream_err",
"try",
":",
... | https://github.com/duerrp/pyexperiment/blob/c426565d870d944bd5b9712629d8f1ba2527c67f/pyexperiment/utils/stdout_redirector.py#L28-L39 | ||
spyder-ide/spyder | 55da47c032dfcf519600f67f8b30eab467f965e7 | spyder/plugins/ipythonconsole/widgets/shell.py | python | ShellWidget.handle_exec_method | (self, msg) | Handle data returned by silent executions of kernel methods
This is based on the _handle_exec_callback of RichJupyterWidget.
Therefore this is licensed BSD. | Handle data returned by silent executions of kernel methods | [
"Handle",
"data",
"returned",
"by",
"silent",
"executions",
"of",
"kernel",
"methods"
] | def handle_exec_method(self, msg):
"""
Handle data returned by silent executions of kernel methods
This is based on the _handle_exec_callback of RichJupyterWidget.
Therefore this is licensed BSD.
"""
user_exp = msg['content'].get('user_expressions')
if not user_e... | [
"def",
"handle_exec_method",
"(",
"self",
",",
"msg",
")",
":",
"user_exp",
"=",
"msg",
"[",
"'content'",
"]",
".",
"get",
"(",
"'user_expressions'",
")",
"if",
"not",
"user_exp",
":",
"return",
"for",
"expression",
"in",
"user_exp",
":",
"if",
"expression... | https://github.com/spyder-ide/spyder/blob/55da47c032dfcf519600f67f8b30eab467f965e7/spyder/plugins/ipythonconsole/widgets/shell.py#L694-L718 | ||
google/coursebuilder-core | 08f809db3226d9269e30d5edd0edd33bd22041f4 | coursebuilder/models/progress.py | python | UnitLessonCompletionTracker._update_lesson | (self, progress, event_key) | Updates a lesson's progress based on the progress of its children. | Updates a lesson's progress based on the progress of its children. | [
"Updates",
"a",
"lesson",
"s",
"progress",
"based",
"on",
"the",
"progress",
"of",
"its",
"children",
"."
] | def _update_lesson(self, progress, event_key):
"""Updates a lesson's progress based on the progress of its children."""
split_event_key = event_key.split('.')
assert len(split_event_key) == 4
unit_id = split_event_key[1]
lesson_id = split_event_key[3]
if self._get_entity... | [
"def",
"_update_lesson",
"(",
"self",
",",
"progress",
",",
"event_key",
")",
":",
"split_event_key",
"=",
"event_key",
".",
"split",
"(",
"'.'",
")",
"assert",
"len",
"(",
"split_event_key",
")",
"==",
"4",
"unit_id",
"=",
"split_event_key",
"[",
"1",
"]"... | https://github.com/google/coursebuilder-core/blob/08f809db3226d9269e30d5edd0edd33bd22041f4/coursebuilder/models/progress.py#L577-L604 | ||
JacquesLucke/animation_nodes | b1e3ace8dcb0a771fd882fc3ac4e490b009fa0d1 | setup.py | python | build | (configs, skipCompilation = False) | [] | def build(configs, skipCompilation = False):
setupInfoList = getSetupInfoList(addonDirectory)
execute_PyPreprocess(setupInfoList, addonDirectory)
execute_Cythonize(setupInfoList, addonDirectory, configs)
if not skipCompilation:
execute_CompileLibraries(setupInfoList, addonDirectory)
ex... | [
"def",
"build",
"(",
"configs",
",",
"skipCompilation",
"=",
"False",
")",
":",
"setupInfoList",
"=",
"getSetupInfoList",
"(",
"addonDirectory",
")",
"execute_PyPreprocess",
"(",
"setupInfoList",
",",
"addonDirectory",
")",
"execute_Cythonize",
"(",
"setupInfoList",
... | https://github.com/JacquesLucke/animation_nodes/blob/b1e3ace8dcb0a771fd882fc3ac4e490b009fa0d1/setup.py#L188-L196 | ||||
cogitas3d/OrtogOnBlender | 881e93f5beb2263e44c270974dd0e81deca44762 | FerrSegmentacao.py | python | MantemPintado.execute | (self, context) | return {'FINISHED'} | [] | def execute(self, context):
MantemPintadoDef(self, context)
return {'FINISHED'} | [
"def",
"execute",
"(",
"self",
",",
"context",
")",
":",
"MantemPintadoDef",
"(",
"self",
",",
"context",
")",
"return",
"{",
"'FINISHED'",
"}"
] | https://github.com/cogitas3d/OrtogOnBlender/blob/881e93f5beb2263e44c270974dd0e81deca44762/FerrSegmentacao.py#L653-L655 | |||
gramps-project/gramps | 04d4651a43eb210192f40a9f8c2bad8ee8fa3753 | gramps/gen/db/dummydb.py | python | DummyDb.get_citation_cursor | (self) | return [] | Return a reference to a cursor over Citation objects | Return a reference to a cursor over Citation objects | [
"Return",
"a",
"reference",
"to",
"a",
"cursor",
"over",
"Citation",
"objects"
] | def get_citation_cursor(self):
"""
Return a reference to a cursor over Citation objects
"""
if not self.db_is_open:
LOG.warning("database is closed")
return [] | [
"def",
"get_citation_cursor",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"db_is_open",
":",
"LOG",
".",
"warning",
"(",
"\"database is closed\"",
")",
"return",
"[",
"]"
] | https://github.com/gramps-project/gramps/blob/04d4651a43eb210192f40a9f8c2bad8ee8fa3753/gramps/gen/db/dummydb.py#L1150-L1156 | |
ansible/ansible-modules-extras | f216ba8e0616bc8ad8794c22d4b48e1ab18886cf | cloud/misc/virt.py | python | Virt.get_maxVcpus | (self, vmid) | return self.conn.get_maxVcpus(vmid) | Gets the max number of VCPUs on a guest | Gets the max number of VCPUs on a guest | [
"Gets",
"the",
"max",
"number",
"of",
"VCPUs",
"on",
"a",
"guest"
] | def get_maxVcpus(self, vmid):
"""
Gets the max number of VCPUs on a guest
"""
self.__get_conn()
return self.conn.get_maxVcpus(vmid) | [
"def",
"get_maxVcpus",
"(",
"self",
",",
"vmid",
")",
":",
"self",
".",
"__get_conn",
"(",
")",
"return",
"self",
".",
"conn",
".",
"get_maxVcpus",
"(",
"vmid",
")"
] | https://github.com/ansible/ansible-modules-extras/blob/f216ba8e0616bc8ad8794c22d4b48e1ab18886cf/cloud/misc/virt.py#L407-L413 | |
dagster-io/dagster | b27d569d5fcf1072543533a0c763815d96f90b8f | python_modules/dagster/dagster/serdes/serdes.py | python | opt_deserialize_as | (json_str: Optional[str], cls: Type[T]) | return deserialize_as(json_str, cls) if json_str else None | Optionally deserialize a json encoded string to a specific namedtuple class. | Optionally deserialize a json encoded string to a specific namedtuple class. | [
"Optionally",
"deserialize",
"a",
"json",
"encoded",
"string",
"to",
"a",
"specific",
"namedtuple",
"class",
"."
] | def opt_deserialize_as(json_str: Optional[str], cls: Type[T]) -> Optional[T]:
"""Optionally deserialize a json encoded string to a specific namedtuple class."""
return deserialize_as(json_str, cls) if json_str else None | [
"def",
"opt_deserialize_as",
"(",
"json_str",
":",
"Optional",
"[",
"str",
"]",
",",
"cls",
":",
"Type",
"[",
"T",
"]",
")",
"->",
"Optional",
"[",
"T",
"]",
":",
"return",
"deserialize_as",
"(",
"json_str",
",",
"cls",
")",
"if",
"json_str",
"else",
... | https://github.com/dagster-io/dagster/blob/b27d569d5fcf1072543533a0c763815d96f90b8f/python_modules/dagster/dagster/serdes/serdes.py#L397-L399 | |
dimagi/commcare-hq | d67ff1d3b4c51fa050c19e60c3253a79d3452a39 | corehq/apps/translations/app_translations/download.py | python | get_question_row | (question_label_name_media, sheet_name) | return (
[
sheet_name,
'', # case_property
'', # list_or_detail
] +
question_label_name_media +
[''] # unique_id
) | [] | def get_question_row(question_label_name_media, sheet_name):
return (
[
sheet_name,
'', # case_property
'', # list_or_detail
] +
question_label_name_media +
[''] # unique_id
) | [
"def",
"get_question_row",
"(",
"question_label_name_media",
",",
"sheet_name",
")",
":",
"return",
"(",
"[",
"sheet_name",
",",
"''",
",",
"# case_property",
"''",
",",
"# list_or_detail",
"]",
"+",
"question_label_name_media",
"+",
"[",
"''",
"]",
"# unique_id",... | https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/translations/app_translations/download.py#L159-L168 | |||
jeetsukumaran/DendroPy | 29fd294bf05d890ebf6a8d576c501e471db27ca1 | src/dendropy/model/discrete.py | python | hky85_chars | (
seq_len,
tree_model,
mutation_rate=1.0,
kappa=1.0,
base_freqs=[0.25, 0.25, 0.25, 0.25],
root_states=None,
char_matrix=None,
retain_sequences_on_tree=False,
rng=None) | return simulate_discrete_chars(seq_len=seq_len,
tree_model=tree_model,
seq_model=seq_model,
mutation_rate=mutation_rate,
root_states=root_states,
char_matrix=char_ma... | Convenience class to wrap generation of characters (as a CharacterBlock
object) based on the HKY model.
Parameters
----------
seq_len : int
Length of sequence (number of characters).
tree_model : |Tree|
Tree on which to simulate.
mutation_rate : float
Mutation ... | Convenience class to wrap generation of characters (as a CharacterBlock
object) based on the HKY model. | [
"Convenience",
"class",
"to",
"wrap",
"generation",
"of",
"characters",
"(",
"as",
"a",
"CharacterBlock",
"object",
")",
"based",
"on",
"the",
"HKY",
"model",
"."
] | def hky85_chars(
seq_len,
tree_model,
mutation_rate=1.0,
kappa=1.0,
base_freqs=[0.25, 0.25, 0.25, 0.25],
root_states=None,
char_matrix=None,
retain_sequences_on_tree=False,
rng=None):
"""
Convenience class to wrap generation of characters (... | [
"def",
"hky85_chars",
"(",
"seq_len",
",",
"tree_model",
",",
"mutation_rate",
"=",
"1.0",
",",
"kappa",
"=",
"1.0",
",",
"base_freqs",
"=",
"[",
"0.25",
",",
"0.25",
",",
"0.25",
",",
"0.25",
"]",
",",
"root_states",
"=",
"None",
",",
"char_matrix",
"... | https://github.com/jeetsukumaran/DendroPy/blob/29fd294bf05d890ebf6a8d576c501e471db27ca1/src/dendropy/model/discrete.py#L510-L572 | |
neptune-ai/open-solution-salt-identification | 394f16b23b6e30543aee54701f81a06b5dd92a98 | common_blocks/loaders.py | python | ImageSegmentationLoaderBasic.transform | (self, X, y, X_valid=None, y_valid=None, **kwargs) | return {'datagen': (flow, steps),
'validation_datagen': (valid_flow, valid_steps)} | [] | def transform(self, X, y, X_valid=None, y_valid=None, **kwargs):
if self.train_mode and y is not None:
flow, steps = self.get_datagen(X, y, True, self.loader_params.training)
else:
flow, steps = self.get_datagen(X, None, False, self.loader_params.inference)
if X_valid is... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
",",
"X_valid",
"=",
"None",
",",
"y_valid",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"train_mode",
"and",
"y",
"is",
"not",
"None",
":",
"flow",
",",
"steps",
"=",
... | https://github.com/neptune-ai/open-solution-salt-identification/blob/394f16b23b6e30543aee54701f81a06b5dd92a98/common_blocks/loaders.py#L477-L490 | |||
caiiiac/Machine-Learning-with-Python | 1a26c4467da41ca4ebc3d5bd789ea942ef79422f | MachineLearning/venv/lib/python3.5/site-packages/sklearn/decomposition/sparse_pca.py | python | SparsePCA.fit | (self, X, y=None) | return self | Fit the model from data in X.
Parameters
----------
X: array-like, shape (n_samples, n_features)
Training vector, where n_samples in the number of samples
and n_features is the number of features.
Returns
-------
self : object
Returns... | Fit the model from data in X. | [
"Fit",
"the",
"model",
"from",
"data",
"in",
"X",
"."
] | def fit(self, X, y=None):
"""Fit the model from data in X.
Parameters
----------
X: array-like, shape (n_samples, n_features)
Training vector, where n_samples in the number of samples
and n_features is the number of features.
Returns
-------
... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"random_state",
"=",
"check_random_state",
"(",
"self",
".",
"random_state",
")",
"X",
"=",
"check_array",
"(",
"X",
")",
"if",
"self",
".",
"n_components",
"is",
"None",
":",
"n_c... | https://github.com/caiiiac/Machine-Learning-with-Python/blob/1a26c4467da41ca4ebc3d5bd789ea942ef79422f/MachineLearning/venv/lib/python3.5/site-packages/sklearn/decomposition/sparse_pca.py#L96-L131 | |
volatilityfoundation/volatility | a438e768194a9e05eb4d9ee9338b881c0fa25937 | volatility/plugins/addrspaces/paged.py | python | AbstractPagedMemory.is_nx | (self, entry) | True if the page /cannot/ be executed | True if the page /cannot/ be executed | [
"True",
"if",
"the",
"page",
"/",
"cannot",
"/",
"be",
"executed"
] | def is_nx(self, entry):
"""True if the page /cannot/ be executed"""
raise NotImplementedError | [
"def",
"is_nx",
"(",
"self",
",",
"entry",
")",
":",
"raise",
"NotImplementedError"
] | https://github.com/volatilityfoundation/volatility/blob/a438e768194a9e05eb4d9ee9338b881c0fa25937/volatility/plugins/addrspaces/paged.py#L72-L74 | ||
iclavera/learning_to_adapt | bd7d99ba402521c96631e7d09714128f549db0f1 | learning_to_adapt/mujoco_py/mjtypes.py | python | MjOptionWrapper.integrator | (self, value) | [] | def integrator(self, value):
self._wrapped.contents.integrator = value | [
"def",
"integrator",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_wrapped",
".",
"contents",
".",
"integrator",
"=",
"value"
] | https://github.com/iclavera/learning_to_adapt/blob/bd7d99ba402521c96631e7d09714128f549db0f1/learning_to_adapt/mujoco_py/mjtypes.py#L1979-L1980 | ||||
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_hxb2/lib/python3.5/site-packages/pip/_vendor/cachecontrol/controller.py | python | parse_uri | (uri) | return (groups[1], groups[3], groups[4], groups[6], groups[8]) | Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri) | Parses a URI using the regex given in Appendix B of RFC 3986. | [
"Parses",
"a",
"URI",
"using",
"the",
"regex",
"given",
"in",
"Appendix",
"B",
"of",
"RFC",
"3986",
"."
] | def parse_uri(uri):
"""Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri)
"""
groups = URI.match(uri).groups()
return (groups[1], groups[3], groups[4], groups[6], groups[8]) | [
"def",
"parse_uri",
"(",
"uri",
")",
":",
"groups",
"=",
"URI",
".",
"match",
"(",
"uri",
")",
".",
"groups",
"(",
")",
"return",
"(",
"groups",
"[",
"1",
"]",
",",
"groups",
"[",
"3",
"]",
",",
"groups",
"[",
"4",
"]",
",",
"groups",
"[",
"6... | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/pip/_vendor/cachecontrol/controller.py#L21-L27 | |
kexinyi/ns-vqa | df357618af224723acffb66a17ce3e94298642a7 | reason/models/encoder.py | python | Encoder.forward | (self, input_var, input_lengths=None) | return output, hidden | To do: add input, output dimensions to docstring | To do: add input, output dimensions to docstring | [
"To",
"do",
":",
"add",
"input",
"output",
"dimensions",
"to",
"docstring"
] | def forward(self, input_var, input_lengths=None):
"""
To do: add input, output dimensions to docstring
"""
embedded = self.embedding(input_var)
embedded = self.input_dropout(embedded)
if self.variable_lengths:
embedded = nn.utils.rnn.pack_padded_sequence(embed... | [
"def",
"forward",
"(",
"self",
",",
"input_var",
",",
"input_lengths",
"=",
"None",
")",
":",
"embedded",
"=",
"self",
".",
"embedding",
"(",
"input_var",
")",
"embedded",
"=",
"self",
".",
"input_dropout",
"(",
"embedded",
")",
"if",
"self",
".",
"varia... | https://github.com/kexinyi/ns-vqa/blob/df357618af224723acffb66a17ce3e94298642a7/reason/models/encoder.py#L26-L37 | |
asyml/texar | a23f021dae289a3d768dc099b220952111da04fd | texar/tf/modules/classifiers/conv_classifiers.py | python | Conv1DClassifier.layer_outputs | (self) | return self._encoder.layer_outputs | A list containing output tensors of each layer. | A list containing output tensors of each layer. | [
"A",
"list",
"containing",
"output",
"tensors",
"of",
"each",
"layer",
"."
] | def layer_outputs(self):
"""A list containing output tensors of each layer.
"""
return self._encoder.layer_outputs | [
"def",
"layer_outputs",
"(",
"self",
")",
":",
"return",
"self",
".",
"_encoder",
".",
"layer_outputs"
] | https://github.com/asyml/texar/blob/a23f021dae289a3d768dc099b220952111da04fd/texar/tf/modules/classifiers/conv_classifiers.py#L264-L267 | |
llSourcell/pong_neural_network_live | b733fbaf60105b6f9e326e89f3d1f9d68fc423fa | pong.py | python | drawPaddle2 | (paddle2YPos) | [] | def drawPaddle2(paddle2YPos):
#create it, opposite side
paddle2 = pygame.Rect(WINDOW_WIDTH - PADDLE_BUFFER - PADDLE_WIDTH, paddle2YPos, PADDLE_WIDTH, PADDLE_HEIGHT)
#draw it
pygame.draw.rect(screen, WHITE, paddle2) | [
"def",
"drawPaddle2",
"(",
"paddle2YPos",
")",
":",
"#create it, opposite side",
"paddle2",
"=",
"pygame",
".",
"Rect",
"(",
"WINDOW_WIDTH",
"-",
"PADDLE_BUFFER",
"-",
"PADDLE_WIDTH",
",",
"paddle2YPos",
",",
"PADDLE_WIDTH",
",",
"PADDLE_HEIGHT",
")",
"#draw it",
... | https://github.com/llSourcell/pong_neural_network_live/blob/b733fbaf60105b6f9e326e89f3d1f9d68fc423fa/pong.py#L60-L64 | ||||
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py | python | NTLMConnectionPool.urlopen | (self, method, url, body=None, headers=None, retries=3,
redirect=True, assert_same_host=True) | return super(NTLMConnectionPool, self).urlopen(method, url, body,
headers, retries,
redirect,
assert_same_host) | [] | def urlopen(self, method, url, body=None, headers=None, retries=3,
redirect=True, assert_same_host=True):
if headers is None:
headers = {}
headers['Connection'] = 'Keep-Alive'
return super(NTLMConnectionPool, self).urlopen(method, url, body,
... | [
"def",
"urlopen",
"(",
"self",
",",
"method",
",",
"url",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"retries",
"=",
"3",
",",
"redirect",
"=",
"True",
",",
"assert_same_host",
"=",
"True",
")",
":",
"if",
"headers",
"is",
"None",
... | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py#L104-L112 | |||
alpacahq/alpaca-backtrader-api | 475bb54b8b16506092eb97df5a7cb1d05f0b86be | sample/strategy_multiple_indicators.py | python | SmaCross1.stop | (self) | [] | def stop(self):
print('==================================================')
print('Starting Value - %.2f' % self.broker.startingcash)
print('Ending Value - %.2f' % self.broker.getvalue())
print('==================================================') | [
"def",
"stop",
"(",
"self",
")",
":",
"print",
"(",
"'=================================================='",
")",
"print",
"(",
"'Starting Value - %.2f'",
"%",
"self",
".",
"broker",
".",
"startingcash",
")",
"print",
"(",
"'Ending Value - %.2f'",
"%",
"self",
".",... | https://github.com/alpacahq/alpaca-backtrader-api/blob/475bb54b8b16506092eb97df5a7cb1d05f0b86be/sample/strategy_multiple_indicators.py#L51-L55 | ||||
coldfix/udiskie | 5a1f18f63b9fdd82c7c9487ee42c7e829449f13b | udiskie/tray.py | python | TrayIcon._show | (self) | Show the tray icon. | Show the tray icon. | [
"Show",
"the",
"tray",
"icon",
"."
] | def _show(self):
"""Show the tray icon."""
if not self._icon:
self._icon = self._create_statusicon()
widget = self._icon
widget.set_visible(True)
self._conn_left = widget.connect("activate", self._activate)
self._conn_right = widget.connect("popup-menu", self.... | [
"def",
"_show",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_icon",
":",
"self",
".",
"_icon",
"=",
"self",
".",
"_create_statusicon",
"(",
")",
"widget",
"=",
"self",
".",
"_icon",
"widget",
".",
"set_visible",
"(",
"True",
")",
"self",
".",
... | https://github.com/coldfix/udiskie/blob/5a1f18f63b9fdd82c7c9487ee42c7e829449f13b/udiskie/tray.py#L402-L409 | ||
sideeffects/SideFXLabs | 956bc1eef6710882ae8d3a31b4a33dd631a56d5f | scripts/python/labsopui/labs_path.py | python | file_type | (node, _file_type) | return ext | [] | def file_type(node, _file_type):
#default extension
if _file_type == 'geo':
ext = '.bgeo.sc'
elif _file_type == 'img':
ext = '.exr'
if node.parm("file_type") :
ext = node.evalParm("file_type")
return ext | [
"def",
"file_type",
"(",
"node",
",",
"_file_type",
")",
":",
"#default extension",
"if",
"_file_type",
"==",
"'geo'",
":",
"ext",
"=",
"'.bgeo.sc'",
"elif",
"_file_type",
"==",
"'img'",
":",
"ext",
"=",
"'.exr'",
"if",
"node",
".",
"parm",
"(",
"\"file_ty... | https://github.com/sideeffects/SideFXLabs/blob/956bc1eef6710882ae8d3a31b4a33dd631a56d5f/scripts/python/labsopui/labs_path.py#L81-L89 | |||
cloudera/hue | 23f02102d4547c17c32bd5ea0eb24e9eadd657a4 | desktop/core/ext-py/zope.interface-4.5.0/src/zope/interface/interfaces.py | python | IAdapterRegistry.subscribe | (required, provided, subscriber, name=_BLANK) | Register a subscriber
A subscriber is registered for a *sequence* of required
specifications, a provided interface, and a name.
Multiple subscribers may be registered for the same (or
equivalent) interfaces. | Register a subscriber | [
"Register",
"a",
"subscriber"
] | def subscribe(required, provided, subscriber, name=_BLANK):
"""Register a subscriber
A subscriber is registered for a *sequence* of required
specifications, a provided interface, and a name.
Multiple subscribers may be registered for the same (or
equivalent) interfaces.
... | [
"def",
"subscribe",
"(",
"required",
",",
"provided",
",",
"subscriber",
",",
"name",
"=",
"_BLANK",
")",
":"
] | https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/zope.interface-4.5.0/src/zope/interface/interfaces.py#L736-L744 | ||
eerykitty/CVE-2020-0796-PoC | 5378663af950bbb24ef79d4a9050b0e008396caa | smbclient/_io.py | python | SMBRawIO.seekable | (self) | return True | True if file supports random-access. | True if file supports random-access. | [
"True",
"if",
"file",
"supports",
"random",
"-",
"access",
"."
] | def seekable(self):
""" True if file supports random-access. """
return True | [
"def",
"seekable",
"(",
"self",
")",
":",
"return",
"True"
] | https://github.com/eerykitty/CVE-2020-0796-PoC/blob/5378663af950bbb24ef79d4a9050b0e008396caa/smbclient/_io.py#L374-L376 | |
kuri65536/python-for-android | 26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891 | sl4atools/fullscreenwrapper2/py3/fullscreenwrapper2_py3.py | python | FullScreenWrapper2App.exit_FullScreenWrapper2App | (cls) | convenience function to exit the app. this works by signalling the eventloop to stop | convenience function to exit the app. this works by signalling the eventloop to stop | [
"convenience",
"function",
"to",
"exit",
"the",
"app",
".",
"this",
"works",
"by",
"signalling",
"the",
"eventloop",
"to",
"stop"
] | def exit_FullScreenWrapper2App(cls):
'''
convenience function to exit the app. this works by signalling the eventloop to stop
'''
cls.get_android_instance().fullDismiss()
#curlayout = cls._layouts[len(cls._layouts)-1]
#curlayout._reset()
_internal_exit_signal.post... | [
"def",
"exit_FullScreenWrapper2App",
"(",
"cls",
")",
":",
"cls",
".",
"get_android_instance",
"(",
")",
".",
"fullDismiss",
"(",
")",
"#curlayout = cls._layouts[len(cls._layouts)-1]",
"#curlayout._reset()",
"_internal_exit_signal",
".",
"post_internal_exit_signal",
"(",
")... | https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/sl4atools/fullscreenwrapper2/py3/fullscreenwrapper2_py3.py#L482-L489 | ||
GoSecure/pyrdp | abd8b8762b6d7fd0e49d4a927b529f892b412743 | pyrdp/parser/rdp/slowpath.py | python | SlowPathParser.parseInput | (self, stream: BytesIO, header) | return InputPDU(header, inputEvents) | [] | def parseInput(self, stream: BytesIO, header):
numEvents = Uint16LE.unpack(stream)
stream.read(2)
parser = SlowPathInputParser()
inputEvents = [parser.parse(stream) for _ in range(numEvents)]
return InputPDU(header, inputEvents) | [
"def",
"parseInput",
"(",
"self",
",",
"stream",
":",
"BytesIO",
",",
"header",
")",
":",
"numEvents",
"=",
"Uint16LE",
".",
"unpack",
"(",
"stream",
")",
"stream",
".",
"read",
"(",
"2",
")",
"parser",
"=",
"SlowPathInputParser",
"(",
")",
"inputEvents"... | https://github.com/GoSecure/pyrdp/blob/abd8b8762b6d7fd0e49d4a927b529f892b412743/pyrdp/parser/rdp/slowpath.py#L437-L444 | |||
VirtueSecurity/aws-extender | d123b7e1a845847709ba3a481f11996bddc68a1c | BappModules/botocore/__init__.py | python | xform_name | (name, sep='_', _xform_cache=_xform_cache,
partial_renames=_partial_renames) | return _xform_cache[key] | Convert camel case to a "pythonic" name.
If the name contains the ``sep`` character, then it is
returned unchanged. | Convert camel case to a "pythonic" name. | [
"Convert",
"camel",
"case",
"to",
"a",
"pythonic",
"name",
"."
] | def xform_name(name, sep='_', _xform_cache=_xform_cache,
partial_renames=_partial_renames):
"""Convert camel case to a "pythonic" name.
If the name contains the ``sep`` character, then it is
returned unchanged.
"""
if sep in name:
# If the sep is in the name, assume that it'... | [
"def",
"xform_name",
"(",
"name",
",",
"sep",
"=",
"'_'",
",",
"_xform_cache",
"=",
"_xform_cache",
",",
"partial_renames",
"=",
"_partial_renames",
")",
":",
"if",
"sep",
"in",
"name",
":",
"# If the sep is in the name, assume that it's already",
"# transformed and r... | https://github.com/VirtueSecurity/aws-extender/blob/d123b7e1a845847709ba3a481f11996bddc68a1c/BappModules/botocore/__init__.py#L76-L104 | |
pventuzelo/octopus | e8b8c5a9d5f6d9c63605afe9ef1528ab481ec983 | octopus/core/instruction.py | python | Instruction.__str__ | (self) | return self.__simple_output_format(offset=False) | String representation of the instruction | String representation of the instruction | [
"String",
"representation",
"of",
"the",
"instruction"
] | def __str__(self):
""" String representation of the instruction """
return self.__simple_output_format(offset=False) | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"self",
".",
"__simple_output_format",
"(",
"offset",
"=",
"False",
")"
] | https://github.com/pventuzelo/octopus/blob/e8b8c5a9d5f6d9c63605afe9ef1528ab481ec983/octopus/core/instruction.py#L54-L56 | |
wxWidgets/Phoenix | b2199e299a6ca6d866aa6f3d0888499136ead9d6 | wx/lib/masked/maskededit.py | python | MaskedEditMixin._calcTemplate | (self, reset_fillchar, reset_default) | Subroutine for processing current fillchars and default values for
whole control and individual fields, constructing the resulting
overall template, and adjusting the current value as necessary. | Subroutine for processing current fillchars and default values for
whole control and individual fields, constructing the resulting
overall template, and adjusting the current value as necessary. | [
"Subroutine",
"for",
"processing",
"current",
"fillchars",
"and",
"default",
"values",
"for",
"whole",
"control",
"and",
"individual",
"fields",
"constructing",
"the",
"resulting",
"overall",
"template",
"and",
"adjusting",
"the",
"current",
"value",
"as",
"necessar... | def _calcTemplate(self, reset_fillchar, reset_default):
"""
Subroutine for processing current fillchars and default values for
whole control and individual fields, constructing the resulting
overall template, and adjusting the current value as necessary.
"""
default_set =... | [
"def",
"_calcTemplate",
"(",
"self",
",",
"reset_fillchar",
",",
"reset_default",
")",
":",
"default_set",
"=",
"False",
"if",
"self",
".",
"_ctrl_constraints",
".",
"_defaultValue",
":",
"default_set",
"=",
"True",
"else",
":",
"for",
"field",
"in",
"self",
... | https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/masked/maskededit.py#L2453-L2571 | ||
google-research/morph-net | be4d79dea816c473007c5967d45ab4036306c21c | examples/slim/datasets/download_and_convert_cifar10.py | python | run | (dataset_dir) | Runs the download and conversion operation.
Args:
dataset_dir: The dataset directory where the dataset is stored. | Runs the download and conversion operation. | [
"Runs",
"the",
"download",
"and",
"conversion",
"operation",
"."
] | def run(dataset_dir):
"""Runs the download and conversion operation.
Args:
dataset_dir: The dataset directory where the dataset is stored.
"""
if not tf.gfile.Exists(dataset_dir):
tf.gfile.MakeDirs(dataset_dir)
training_filename = _get_output_filename(dataset_dir, 'train')
testing_filename = _get_... | [
"def",
"run",
"(",
"dataset_dir",
")",
":",
"if",
"not",
"tf",
".",
"gfile",
".",
"Exists",
"(",
"dataset_dir",
")",
":",
"tf",
".",
"gfile",
".",
"MakeDirs",
"(",
"dataset_dir",
")",
"training_filename",
"=",
"_get_output_filename",
"(",
"dataset_dir",
",... | https://github.com/google-research/morph-net/blob/be4d79dea816c473007c5967d45ab4036306c21c/examples/slim/datasets/download_and_convert_cifar10.py#L159-L198 | ||
raw-packet/raw-packet | 78d27b3dc9532d27faa6e5d853c62bc9c8b21e71 | raw_packet/Scripts/ARP/arp_scan.py | python | main | () | Start ARP Scanner (arp_scan)
:return: None | Start ARP Scanner (arp_scan)
:return: None | [
"Start",
"ARP",
"Scanner",
"(",
"arp_scan",
")",
":",
"return",
":",
"None"
] | def main() -> None:
"""
Start ARP Scanner (arp_scan)
:return: None
"""
# region Parse script arguments
parser: ArgumentParser = ArgumentParser(description=base.get_banner(__script_name__),
formatter_class=RawDescriptionHelpFormatter)
parser.add_ar... | [
"def",
"main",
"(",
")",
"->",
"None",
":",
"# region Parse script arguments",
"parser",
":",
"ArgumentParser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"base",
".",
"get_banner",
"(",
"__script_name__",
")",
",",
"formatter_class",
"=",
"RawDescriptionHelpFo... | https://github.com/raw-packet/raw-packet/blob/78d27b3dc9532d27faa6e5d853c62bc9c8b21e71/raw_packet/Scripts/ARP/arp_scan.py#L133-L153 | ||
4shadoww/hakkuframework | 409a11fc3819d251f86faa3473439f8c19066a21 | lib/scapy/utils6.py | python | in6_cidr2mask | (m) | return b"".join(struct.pack('!I', x) for x in t) | Return the mask (bitstring) associated with provided length
value. For instance if function is called on 48, return value is
b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'. | Return the mask (bitstring) associated with provided length
value. For instance if function is called on 48, return value is
b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'. | [
"Return",
"the",
"mask",
"(",
"bitstring",
")",
"associated",
"with",
"provided",
"length",
"value",
".",
"For",
"instance",
"if",
"function",
"is",
"called",
"on",
"48",
"return",
"value",
"is",
"b",
"\\",
"xff",
"\\",
"xff",
"\\",
"xff",
"\\",
"xff",
... | def in6_cidr2mask(m):
# type: (int) -> bytes
"""
Return the mask (bitstring) associated with provided length
value. For instance if function is called on 48, return value is
b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'.
"""
if m > 128 or m < 0:
raise Scapy_Exc... | [
"def",
"in6_cidr2mask",
"(",
"m",
")",
":",
"# type: (int) -> bytes",
"if",
"m",
">",
"128",
"or",
"m",
"<",
"0",
":",
"raise",
"Scapy_Exception",
"(",
"\"value provided to in6_cidr2mask outside [0, 128] domain (%d)\"",
"%",
"m",
")",
"# noqa: E501",
"t",
"=",
"["... | https://github.com/4shadoww/hakkuframework/blob/409a11fc3819d251f86faa3473439f8c19066a21/lib/scapy/utils6.py#L636-L652 | |
nipy/nibabel | 4703f4d8e32be4cec30e829c2d93ebe54759bb62 | nibabel/pydicom_compat.py | python | dicom_test | (func) | return dicom_test(func) | [] | def dicom_test(func):
# Import locally to avoid circular dependency
from .nicom.tests import dicom_test
return dicom_test(func) | [
"def",
"dicom_test",
"(",
"func",
")",
":",
"# Import locally to avoid circular dependency",
"from",
".",
"nicom",
".",
"tests",
"import",
"dicom_test",
"return",
"dicom_test",
"(",
"func",
")"
] | https://github.com/nipy/nibabel/blob/4703f4d8e32be4cec30e829c2d93ebe54759bb62/nibabel/pydicom_compat.py#L60-L63 | |||
OCA/stock-logistics-warehouse | 185c1b0cb9e31e3746a89ec269b4bc09c69b2411 | stock_inventory_exclude_sublocation/models/stock_inventory.py | python | Inventory._get_inventory_lines_values | (self) | return new_vals | Discard inventory lines that are from sublocations if option
is enabled.
Done this way for maximizing inheritance compatibility. | Discard inventory lines that are from sublocations if option
is enabled. | [
"Discard",
"inventory",
"lines",
"that",
"are",
"from",
"sublocations",
"if",
"option",
"is",
"enabled",
"."
] | def _get_inventory_lines_values(self):
"""Discard inventory lines that are from sublocations if option
is enabled.
Done this way for maximizing inheritance compatibility.
"""
vals = super()._get_inventory_lines_values()
if not self.exclude_sublocation:
return... | [
"def",
"_get_inventory_lines_values",
"(",
"self",
")",
":",
"vals",
"=",
"super",
"(",
")",
".",
"_get_inventory_lines_values",
"(",
")",
"if",
"not",
"self",
".",
"exclude_sublocation",
":",
"return",
"vals",
"new_vals",
"=",
"[",
"]",
"for",
"val",
"in",
... | https://github.com/OCA/stock-logistics-warehouse/blob/185c1b0cb9e31e3746a89ec269b4bc09c69b2411/stock_inventory_exclude_sublocation/models/stock_inventory.py#L19-L32 | |
Epiphqny/SOLO | d9a80752c82cbcb1462f4f10d446f5f70e3871b0 | mmdet/datasets/pipelines/formating.py | python | to_tensor | (data) | Convert objects of various python types to :obj:`torch.Tensor`.
Supported types are: :class:`numpy.ndarray`, :class:`torch.Tensor`,
:class:`Sequence`, :class:`int` and :class:`float`. | Convert objects of various python types to :obj:`torch.Tensor`. | [
"Convert",
"objects",
"of",
"various",
"python",
"types",
"to",
":",
"obj",
":",
"torch",
".",
"Tensor",
"."
] | def to_tensor(data):
"""Convert objects of various python types to :obj:`torch.Tensor`.
Supported types are: :class:`numpy.ndarray`, :class:`torch.Tensor`,
:class:`Sequence`, :class:`int` and :class:`float`.
"""
if isinstance(data, torch.Tensor):
return data
elif isinstance(data, np.nda... | [
"def",
"to_tensor",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"torch",
".",
"Tensor",
")",
":",
"return",
"data",
"elif",
"isinstance",
"(",
"data",
",",
"np",
".",
"ndarray",
")",
":",
"return",
"torch",
".",
"from_numpy",
"(",
"d... | https://github.com/Epiphqny/SOLO/blob/d9a80752c82cbcb1462f4f10d446f5f70e3871b0/mmdet/datasets/pipelines/formating.py#L11-L29 | ||
pyeventsourcing/eventsourcing | f5a36f434ab2631890092b6c7714b8fb8c94dc7c | eventsourcing/persistence.py | python | Cipher.decrypt | (self, ciphertext: bytes) | Return plaintext for given ciphertext. | Return plaintext for given ciphertext. | [
"Return",
"plaintext",
"for",
"given",
"ciphertext",
"."
] | def decrypt(self, ciphertext: bytes) -> bytes:
"""
Return plaintext for given ciphertext.
""" | [
"def",
"decrypt",
"(",
"self",
",",
"ciphertext",
":",
"bytes",
")",
"->",
"bytes",
":"
] | https://github.com/pyeventsourcing/eventsourcing/blob/f5a36f434ab2631890092b6c7714b8fb8c94dc7c/eventsourcing/persistence.py#L257-L260 | ||
general03/flask-autoindex | 424246242c9f40aeb9ac2c8c63f4d2234024256e | .eggs/click-7.1.1-py3.7.egg/click/types.py | python | ParamType.fail | (self, message, param=None, ctx=None) | Helper method to fail with an invalid value message. | Helper method to fail with an invalid value message. | [
"Helper",
"method",
"to",
"fail",
"with",
"an",
"invalid",
"value",
"message",
"."
] | def fail(self, message, param=None, ctx=None):
"""Helper method to fail with an invalid value message."""
raise BadParameter(message, ctx=ctx, param=param) | [
"def",
"fail",
"(",
"self",
",",
"message",
",",
"param",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"raise",
"BadParameter",
"(",
"message",
",",
"ctx",
"=",
"ctx",
",",
"param",
"=",
"param",
")"
] | https://github.com/general03/flask-autoindex/blob/424246242c9f40aeb9ac2c8c63f4d2234024256e/.eggs/click-7.1.1-py3.7.egg/click/types.py#L74-L76 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.