repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
mkorpela/overrides | overrides/overrides.py | https://github.com/mkorpela/overrides/blob/196c2fa3c79fe7a7d319d2ade25bb25f6d78f1c2/overrides/overrides.py#L126-L155 | def _get_base_class_names(frame):
""" Get baseclass names from the code object """
co, lasti = frame.f_code, frame.f_lasti
code = co.co_code
extends = []
for (op, oparg) in op_stream(code, lasti):
if op in dis.hasconst:
if type(co.co_consts[oparg]) == str:
extend... | [
"def",
"_get_base_class_names",
"(",
"frame",
")",
":",
"co",
",",
"lasti",
"=",
"frame",
".",
"f_code",
",",
"frame",
".",
"f_lasti",
"code",
"=",
"co",
".",
"co_code",
"extends",
"=",
"[",
"]",
"for",
"(",
"op",
",",
"oparg",
")",
"in",
"op_stream"... | Get baseclass names from the code object | [
"Get",
"baseclass",
"names",
"from",
"the",
"code",
"object"
] | python | train | 32.266667 |
saltstack/salt | salt/utils/pbm.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/pbm.py#L123-L147 | def get_capability_definitions(profile_manager):
'''
Returns a list of all capability definitions.
profile_manager
Reference to the profile manager.
'''
res_type = pbm.profile.ResourceType(
resourceType=pbm.profile.ResourceTypeEnum.STORAGE)
try:
cap_categories = profile_... | [
"def",
"get_capability_definitions",
"(",
"profile_manager",
")",
":",
"res_type",
"=",
"pbm",
".",
"profile",
".",
"ResourceType",
"(",
"resourceType",
"=",
"pbm",
".",
"profile",
".",
"ResourceTypeEnum",
".",
"STORAGE",
")",
"try",
":",
"cap_categories",
"=",
... | Returns a list of all capability definitions.
profile_manager
Reference to the profile manager. | [
"Returns",
"a",
"list",
"of",
"all",
"capability",
"definitions",
"."
] | python | train | 35.6 |
Alignak-monitoring/alignak | alignak/external_command.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L1576-L1591 | def change_svc_event_handler(self, service, event_handler_command):
"""Modify service event handler
Format of the line that triggers function call::
CHANGE_SVC_EVENT_HANDLER;<host_name>;<service_description>;<event_handler_command>
:param service: service to modify event handler
... | [
"def",
"change_svc_event_handler",
"(",
"self",
",",
"service",
",",
"event_handler_command",
")",
":",
"service",
".",
"modified_attributes",
"|=",
"DICT_MODATTR",
"[",
"\"MODATTR_EVENT_HANDLER_COMMAND\"",
"]",
".",
"value",
"data",
"=",
"{",
"\"commands\"",
":",
"... | Modify service event handler
Format of the line that triggers function call::
CHANGE_SVC_EVENT_HANDLER;<host_name>;<service_description>;<event_handler_command>
:param service: service to modify event handler
:type service: alignak.objects.service.Service
:param event_handler_c... | [
"Modify",
"service",
"event",
"handler",
"Format",
"of",
"the",
"line",
"that",
"triggers",
"function",
"call",
"::"
] | python | train | 47.5 |
wtsi-hgi/python-baton-wrapper | baton/collections.py | https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/collections.py#L18-L27 | def from_metadata(metadata: Metadata) -> Any:
"""
Static factory method to create an equivalent instance of this type from the given `Metadata` instance.
:param metadata: the `Metadata` instance to create an instance of this class from
:return: the created instance of this class
... | [
"def",
"from_metadata",
"(",
"metadata",
":",
"Metadata",
")",
"->",
"Any",
":",
"irods_metadata",
"=",
"IrodsMetadata",
"(",
")",
"for",
"key",
",",
"value",
"in",
"metadata",
".",
"items",
"(",
")",
":",
"irods_metadata",
"[",
"key",
"]",
"=",
"{",
"... | Static factory method to create an equivalent instance of this type from the given `Metadata` instance.
:param metadata: the `Metadata` instance to create an instance of this class from
:return: the created instance of this class | [
"Static",
"factory",
"method",
"to",
"create",
"an",
"equivalent",
"instance",
"of",
"this",
"type",
"from",
"the",
"given",
"Metadata",
"instance",
".",
":",
"param",
"metadata",
":",
"the",
"Metadata",
"instance",
"to",
"create",
"an",
"instance",
"of",
"t... | python | train | 47.1 |
qacafe/cdrouter.py | cdrouter/system.py | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/system.py#L379-L391 | def manual_update_license(self, fd, filename='cdrouter.lic'):
"""Update the license on your CDRouter system manually by uploading a
.lic license from the CDRouter Support Lounge.
:param fd: File-like object to upload.
:param filename: (optional) Filename to use for license as string.
... | [
"def",
"manual_update_license",
"(",
"self",
",",
"fd",
",",
"filename",
"=",
"'cdrouter.lic'",
")",
":",
"schema",
"=",
"UpgradeSchema",
"(",
")",
"resp",
"=",
"self",
".",
"service",
".",
"post",
"(",
"self",
".",
"base",
"+",
"'license/'",
",",
"files... | Update the license on your CDRouter system manually by uploading a
.lic license from the CDRouter Support Lounge.
:param fd: File-like object to upload.
:param filename: (optional) Filename to use for license as string.
:return: :class:`system.Upgrade <system.Upgrade>` object
:r... | [
"Update",
"the",
"license",
"on",
"your",
"CDRouter",
"system",
"manually",
"by",
"uploading",
"a",
".",
"lic",
"license",
"from",
"the",
"CDRouter",
"Support",
"Lounge",
"."
] | python | train | 47.307692 |
dlintott/gns3-converter | gns3converter/converter.py | https://github.com/dlintott/gns3-converter/blob/acbc55da51de86388dc5b5f6da55809b3c86b7ca/gns3converter/converter.py#L412-L429 | def get_port_name_from_id(node_id, port_id, nodes):
"""
Get the name of a port for a given node and port ID
:param int node_id: node ID
:param int port_id: port ID
:param list nodes: list of nodes from :py:meth:`generate_nodes`
:return: port name
:rtype: str
... | [
"def",
"get_port_name_from_id",
"(",
"node_id",
",",
"port_id",
",",
"nodes",
")",
":",
"port_name",
"=",
"''",
"for",
"node",
"in",
"nodes",
":",
"if",
"node",
"[",
"'id'",
"]",
"==",
"node_id",
":",
"for",
"port",
"in",
"node",
"[",
"'ports'",
"]",
... | Get the name of a port for a given node and port ID
:param int node_id: node ID
:param int port_id: port ID
:param list nodes: list of nodes from :py:meth:`generate_nodes`
:return: port name
:rtype: str | [
"Get",
"the",
"name",
"of",
"a",
"port",
"for",
"a",
"given",
"node",
"and",
"port",
"ID"
] | python | train | 32.833333 |
summanlp/textrank | summa/preprocessing/porter.py | https://github.com/summanlp/textrank/blob/6844bbe8c4b2b468020ae0dfd6574a743f9ad442/summa/preprocessing/porter.py#L432-L465 | def _step3(self, word):
"""step3() deals with -ic-, -full, -ness etc. similar strategy to step2."""
ch = word[-1]
if ch == 'e':
if word.endswith("icate"):
return word[:-3] if self._m(word, len(word)-6) else word
elif word.endswith("ative"):
... | [
"def",
"_step3",
"(",
"self",
",",
"word",
")",
":",
"ch",
"=",
"word",
"[",
"-",
"1",
"]",
"if",
"ch",
"==",
"'e'",
":",
"if",
"word",
".",
"endswith",
"(",
"\"icate\"",
")",
":",
"return",
"word",
"[",
":",
"-",
"3",
"]",
"if",
"self",
".",... | step3() deals with -ic-, -full, -ness etc. similar strategy to step2. | [
"step3",
"()",
"deals",
"with",
"-",
"ic",
"-",
"-",
"full",
"-",
"ness",
"etc",
".",
"similar",
"strategy",
"to",
"step2",
"."
] | python | train | 35.323529 |
tcpcloud/python-aptly | aptly/publisher/__init__.py | https://github.com/tcpcloud/python-aptly/blob/7eb4ce1c508666bad0e6a0d4c5c561b1485ed558/aptly/publisher/__init__.py#L351-L361 | def _get_publish(self):
"""
Find this publish on remote
"""
publishes = self._get_publishes(self.client)
for publish in publishes:
if publish['Distribution'] == self.distribution and \
publish['Prefix'].replace("/", "_") == (self.prefix or '.') and... | [
"def",
"_get_publish",
"(",
"self",
")",
":",
"publishes",
"=",
"self",
".",
"_get_publishes",
"(",
"self",
".",
"client",
")",
"for",
"publish",
"in",
"publishes",
":",
"if",
"publish",
"[",
"'Distribution'",
"]",
"==",
"self",
".",
"distribution",
"and",... | Find this publish on remote | [
"Find",
"this",
"publish",
"on",
"remote"
] | python | train | 45.454545 |
webrecorder/pywb | pywb/warcserver/index/cdxops.py | https://github.com/webrecorder/pywb/blob/77f8bb647639dd66f6b92b7a9174c28810e4b1d9/pywb/warcserver/index/cdxops.py#L236-L253 | def cdx_clamp(cdx_iter, from_ts, to_ts):
"""
Clamp by start and end ts
"""
if from_ts and len(from_ts) < 14:
from_ts = pad_timestamp(from_ts, PAD_14_DOWN)
if to_ts and len(to_ts) < 14:
to_ts = pad_timestamp(to_ts, PAD_14_UP)
for cdx in cdx_iter:
if from_ts and cdx[TIMES... | [
"def",
"cdx_clamp",
"(",
"cdx_iter",
",",
"from_ts",
",",
"to_ts",
")",
":",
"if",
"from_ts",
"and",
"len",
"(",
"from_ts",
")",
"<",
"14",
":",
"from_ts",
"=",
"pad_timestamp",
"(",
"from_ts",
",",
"PAD_14_DOWN",
")",
"if",
"to_ts",
"and",
"len",
"(",... | Clamp by start and end ts | [
"Clamp",
"by",
"start",
"and",
"end",
"ts"
] | python | train | 23.666667 |
alvarogzp/telegram-bot-framework | bot/action/util/format.py | https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L79-L92 | def full_data(self):
"""
Returns all the info available for the user in the following format:
name [username] <id> (locale) bot_or_user
If any data is not available, it is not added.
"""
data = [
self.full_name,
self._username(),
se... | [
"def",
"full_data",
"(",
"self",
")",
":",
"data",
"=",
"[",
"self",
".",
"full_name",
",",
"self",
".",
"_username",
"(",
")",
",",
"self",
".",
"_id",
"(",
")",
",",
"self",
".",
"_language_code",
"(",
")",
",",
"self",
".",
"_is_bot",
"(",
")"... | Returns all the info available for the user in the following format:
name [username] <id> (locale) bot_or_user
If any data is not available, it is not added. | [
"Returns",
"all",
"the",
"info",
"available",
"for",
"the",
"user",
"in",
"the",
"following",
"format",
":",
"name",
"[",
"username",
"]",
"<id",
">",
"(",
"locale",
")",
"bot_or_user",
"If",
"any",
"data",
"is",
"not",
"available",
"it",
"is",
"not",
... | python | train | 30.857143 |
Phyks/libbmc | libbmc/repositories/arxiv.py | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/repositories/arxiv.py#L235-L273 | def is_valid(arxiv_id):
"""
Check that a given arXiv ID is a valid one.
:param arxiv_id: The arXiv ID to be checked.
:returns: Boolean indicating whether the arXiv ID is valid or not.
>>> is_valid('1506.06690')
True
>>> is_valid('1506.06690v1')
True
>>> is_valid('arXiv:1506.06690... | [
"def",
"is_valid",
"(",
"arxiv_id",
")",
":",
"match",
"=",
"REGEX",
".",
"match",
"(",
"arxiv_id",
")",
"return",
"(",
"match",
"is",
"not",
"None",
")",
"and",
"(",
"match",
".",
"group",
"(",
"0",
")",
"==",
"arxiv_id",
")"
] | Check that a given arXiv ID is a valid one.
:param arxiv_id: The arXiv ID to be checked.
:returns: Boolean indicating whether the arXiv ID is valid or not.
>>> is_valid('1506.06690')
True
>>> is_valid('1506.06690v1')
True
>>> is_valid('arXiv:1506.06690')
True
>>> is_valid('arXiv... | [
"Check",
"that",
"a",
"given",
"arXiv",
"ID",
"is",
"a",
"valid",
"one",
"."
] | python | train | 18.538462 |
Duke-GCB/DukeDSClient | ddsc/core/parallel.py | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/parallel.py#L130-L141 | def run(self):
"""
Runs all tasks in this runner on the executor.
Blocks until all tasks have been completed.
:return:
"""
for task in self.get_next_tasks(None):
self.executor.add_task(task, None)
while not self.executor.is_done():
done_tas... | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"task",
"in",
"self",
".",
"get_next_tasks",
"(",
"None",
")",
":",
"self",
".",
"executor",
".",
"add_task",
"(",
"task",
",",
"None",
")",
"while",
"not",
"self",
".",
"executor",
".",
"is_done",
"(",
"... | Runs all tasks in this runner on the executor.
Blocks until all tasks have been completed.
:return: | [
"Runs",
"all",
"tasks",
"in",
"this",
"runner",
"on",
"the",
"executor",
".",
"Blocks",
"until",
"all",
"tasks",
"have",
"been",
"completed",
".",
":",
"return",
":"
] | python | train | 40 |
adafruit/Adafruit_Python_GPIO | Adafruit_GPIO/FT232H.py | https://github.com/adafruit/Adafruit_Python_GPIO/blob/a92a23d6b5869663b2bc1ccf78bb11585076a9c4/Adafruit_GPIO/FT232H.py#L52-L69 | def disable_FTDI_driver():
"""Disable the FTDI drivers for the current platform. This is necessary
because they will conflict with libftdi and accessing the FT232H. Note you
can enable the FTDI drivers again by calling enable_FTDI_driver.
"""
logger.debug('Disabling FTDI driver.')
if sys.platf... | [
"def",
"disable_FTDI_driver",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"'Disabling FTDI driver.'",
")",
"if",
"sys",
".",
"platform",
"==",
"'darwin'",
":",
"logger",
".",
"debug",
"(",
"'Detected Mac OSX'",
")",
"# Mac OS commands to disable FTDI driver.",
"_che... | Disable the FTDI drivers for the current platform. This is necessary
because they will conflict with libftdi and accessing the FT232H. Note you
can enable the FTDI drivers again by calling enable_FTDI_driver. | [
"Disable",
"the",
"FTDI",
"drivers",
"for",
"the",
"current",
"platform",
".",
"This",
"is",
"necessary",
"because",
"they",
"will",
"conflict",
"with",
"libftdi",
"and",
"accessing",
"the",
"FT232H",
".",
"Note",
"you",
"can",
"enable",
"the",
"FTDI",
"driv... | python | valid | 51.055556 |
blockstack/blockstack-core | blockstack/lib/atlas.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3606-L3614 | def atlas_node_add_callback(atlas_state, callback_name, callback):
"""
Add a callback to the initialized atlas state
"""
if callback_name == 'store_zonefile':
atlas_state['zonefile_crawler'].set_store_zonefile_callback(callback)
else:
raise ValueError("Unrecognized callback {}".form... | [
"def",
"atlas_node_add_callback",
"(",
"atlas_state",
",",
"callback_name",
",",
"callback",
")",
":",
"if",
"callback_name",
"==",
"'store_zonefile'",
":",
"atlas_state",
"[",
"'zonefile_crawler'",
"]",
".",
"set_store_zonefile_callback",
"(",
"callback",
")",
"else"... | Add a callback to the initialized atlas state | [
"Add",
"a",
"callback",
"to",
"the",
"initialized",
"atlas",
"state"
] | python | train | 36.666667 |
tonyfischetti/sake | sakelib/acts.py | https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L599-L623 | def write_dot_file(G, filename):
"""
Writes the graph G in dot file format for graphviz visualization.
Args:
a Networkx graph
A filename to name the dot files
"""
with io.open(filename, "w") as fh:
fh.write("strict digraph DependencyDiagram {\n")
edge_list = G.edges(... | [
"def",
"write_dot_file",
"(",
"G",
",",
"filename",
")",
":",
"with",
"io",
".",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"as",
"fh",
":",
"fh",
".",
"write",
"(",
"\"strict digraph DependencyDiagram {\\n\"",
")",
"edge_list",
"=",
"G",
".",
"edges",
... | Writes the graph G in dot file format for graphviz visualization.
Args:
a Networkx graph
A filename to name the dot files | [
"Writes",
"the",
"graph",
"G",
"in",
"dot",
"file",
"format",
"for",
"graphviz",
"visualization",
"."
] | python | valid | 33.04 |
pybel/pybel | src/pybel/struct/summary/node_summary.py | https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/summary/node_summary.py#L163-L167 | def _namespace_filtered_iterator(graph, namespace):
"""Iterate over names in the given namespace."""
for it_namespace, name in _identifier_filtered_iterator(graph):
if namespace == it_namespace:
yield name | [
"def",
"_namespace_filtered_iterator",
"(",
"graph",
",",
"namespace",
")",
":",
"for",
"it_namespace",
",",
"name",
"in",
"_identifier_filtered_iterator",
"(",
"graph",
")",
":",
"if",
"namespace",
"==",
"it_namespace",
":",
"yield",
"name"
] | Iterate over names in the given namespace. | [
"Iterate",
"over",
"names",
"in",
"the",
"given",
"namespace",
"."
] | python | train | 45.8 |
KeithSSmith/switcheo-python | switcheo/public_client.py | https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/public_client.py#L254-L283 | def get_offers(self, pair="SWTH_NEO"):
"""
Function to fetch the open orders on the order book for the trade pair requested.
Execution of this function is as follows::
get_offers(pair="SWTH_NEO")
The expected return result for this function is as follows::
[{
... | [
"def",
"get_offers",
"(",
"self",
",",
"pair",
"=",
"\"SWTH_NEO\"",
")",
":",
"api_params",
"=",
"{",
"\"pair\"",
":",
"pair",
",",
"\"contract_hash\"",
":",
"self",
".",
"contract_hash",
"}",
"return",
"self",
".",
"request",
".",
"get",
"(",
"path",
"=... | Function to fetch the open orders on the order book for the trade pair requested.
Execution of this function is as follows::
get_offers(pair="SWTH_NEO")
The expected return result for this function is as follows::
[{
'id': '2716c0ca-59bb-4c86-8ee4-6b9528d0e5d2'... | [
"Function",
"to",
"fetch",
"the",
"open",
"orders",
"on",
"the",
"order",
"book",
"for",
"the",
"trade",
"pair",
"requested",
".",
"Execution",
"of",
"this",
"function",
"is",
"as",
"follows",
"::"
] | python | train | 36.233333 |
Mindwerks/worldengine | worldengine/image_io.py | https://github.com/Mindwerks/worldengine/blob/64dff8eb7824ce46b5b6cb8006bcef21822ef144/worldengine/image_io.py#L136-L174 | def set_pixel(self, x, y, color):
"""
Color may be: value, tuple, list etc.
If the image is set to contain more color-channels than len(color), the
remaining channels will be filled automatically.
Example (channels = 4, i.e. RGBA output):
color = 17 -> color = [... | [
"def",
"set_pixel",
"(",
"self",
",",
"x",
",",
"y",
",",
"color",
")",
":",
"try",
":",
"# these checks are for convenience, not for safety\r",
"if",
"len",
"(",
"color",
")",
"<",
"self",
".",
"channels",
":",
"# color is a a tuple (length >= 1)\r",
"if",
"len... | Color may be: value, tuple, list etc.
If the image is set to contain more color-channels than len(color), the
remaining channels will be filled automatically.
Example (channels = 4, i.e. RGBA output):
color = 17 -> color = [17,17,17,255]
color = (17, 99) -> color = [17... | [
"Color",
"may",
"be",
":",
"value",
"tuple",
"list",
"etc",
".",
"If",
"the",
"image",
"is",
"set",
"to",
"contain",
"more",
"color",
"-",
"channels",
"than",
"len",
"(",
"color",
")",
"the",
"remaining",
"channels",
"will",
"be",
"filled",
"automaticall... | python | train | 46.615385 |
DLR-RM/RAFCON | source/rafcon/gui/controllers/preferences_window.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/preferences_window.py#L514-L528 | def _on_library_path_changed(self, renderer, path, new_library_path):
"""Callback handling a change of a library path
:param Gtk.CellRenderer renderer: Cell renderer showing the library path
:param path: Path of library within the list store
:param str new_library_path: New library path... | [
"def",
"_on_library_path_changed",
"(",
"self",
",",
"renderer",
",",
"path",
",",
"new_library_path",
")",
":",
"library_name",
"=",
"self",
".",
"library_list_store",
"[",
"int",
"(",
"path",
")",
"]",
"[",
"self",
".",
"KEY_STORAGE_ID",
"]",
"library_config... | Callback handling a change of a library path
:param Gtk.CellRenderer renderer: Cell renderer showing the library path
:param path: Path of library within the list store
:param str new_library_path: New library path | [
"Callback",
"handling",
"a",
"change",
"of",
"a",
"library",
"path"
] | python | train | 61.2 |
mswart/pyopenmensa | feed.py | https://github.com/mswart/pyopenmensa/blob/c651da6ace33e2278349636daaa709d043dee6ff/feed.py#L251-L281 | def toTag(self, output):
''' This methods returns all data of this feed as feed xml tag
:param output: XML Document to which the data should be added
:type output: xml.dom.DOMImplementation.createDocument
'''
feed = output.createElement('feed')
feed.setAttribute('name', ... | [
"def",
"toTag",
"(",
"self",
",",
"output",
")",
":",
"feed",
"=",
"output",
".",
"createElement",
"(",
"'feed'",
")",
"feed",
".",
"setAttribute",
"(",
"'name'",
",",
"self",
".",
"name",
")",
"feed",
".",
"setAttribute",
"(",
"'priority'",
",",
"str"... | This methods returns all data of this feed as feed xml tag
:param output: XML Document to which the data should be added
:type output: xml.dom.DOMImplementation.createDocument | [
"This",
"methods",
"returns",
"all",
"data",
"of",
"this",
"feed",
"as",
"feed",
"xml",
"tag"
] | python | train | 36.354839 |
buildinspace/peru | peru/cache.py | https://github.com/buildinspace/peru/blob/76e4012c6c34e85fb53a4c6d85f4ac3633d93f77/peru/cache.py#L516-L524 | def delete_if_error(path):
'''If any exception is raised inside the context, delete the file at the
given path, and allow the exception to continue.'''
try:
yield
except Exception:
if os.path.exists(path):
os.remove(path)
raise | [
"def",
"delete_if_error",
"(",
"path",
")",
":",
"try",
":",
"yield",
"except",
"Exception",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"os",
".",
"remove",
"(",
"path",
")",
"raise"
] | If any exception is raised inside the context, delete the file at the
given path, and allow the exception to continue. | [
"If",
"any",
"exception",
"is",
"raised",
"inside",
"the",
"context",
"delete",
"the",
"file",
"at",
"the",
"given",
"path",
"and",
"allow",
"the",
"exception",
"to",
"continue",
"."
] | python | train | 30.111111 |
vmware/pyvmomi | pyVmomi/DynamicTypeManagerHelper.py | https://github.com/vmware/pyvmomi/blob/3ffcb23bf77d757175c0d5216ba9a25345d824cd/pyVmomi/DynamicTypeManagerHelper.py#L177-L209 | def _ConvertMethodType(self, methodType):
"""
Convert vmodl.reflect.DynamicTypeManager.MethodTypeInfo to pyVmomi method
definition
"""
if methodType:
name = methodType.name
wsdlName = methodType.wsdlName
version = methodType.version
params = self._Filter... | [
"def",
"_ConvertMethodType",
"(",
"self",
",",
"methodType",
")",
":",
"if",
"methodType",
":",
"name",
"=",
"methodType",
".",
"name",
"wsdlName",
"=",
"methodType",
".",
"wsdlName",
"version",
"=",
"methodType",
".",
"version",
"params",
"=",
"self",
".",
... | Convert vmodl.reflect.DynamicTypeManager.MethodTypeInfo to pyVmomi method
definition | [
"Convert",
"vmodl",
".",
"reflect",
".",
"DynamicTypeManager",
".",
"MethodTypeInfo",
"to",
"pyVmomi",
"method",
"definition"
] | python | train | 35.575758 |
saltstack/salt | salt/cloud/clouds/oneandone.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/oneandone.py#L286-L312 | def _get_block_storage(kwargs):
'''
Construct a block storage instance from passed arguments
'''
if kwargs is None:
kwargs = {}
block_storage_name = kwargs.get('name', None)
block_storage_size = kwargs.get('size', None)
block_storage_description = kwargs.get('description', None)
... | [
"def",
"_get_block_storage",
"(",
"kwargs",
")",
":",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"block_storage_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"None",
")",
"block_storage_size",
"=",
"kwargs",
".",
"get",
"(",
"'si... | Construct a block storage instance from passed arguments | [
"Construct",
"a",
"block",
"storage",
"instance",
"from",
"passed",
"arguments"
] | python | train | 27.851852 |
numenta/nupic | src/nupic/encoders/logarithm.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/logarithm.py#L162-L177 | def encodeIntoArray(self, inpt, output):
"""
See the function description in base.py
"""
# Get the scaled value
scaledVal = self._getScaledValue(inpt)
if scaledVal is None:
output[0:] = 0
else:
self.encoder.encodeIntoArray(scaledVal, output)
if self.verbosity >= 2:
... | [
"def",
"encodeIntoArray",
"(",
"self",
",",
"inpt",
",",
"output",
")",
":",
"# Get the scaled value",
"scaledVal",
"=",
"self",
".",
"_getScaledValue",
"(",
"inpt",
")",
"if",
"scaledVal",
"is",
"None",
":",
"output",
"[",
"0",
":",
"]",
"=",
"0",
"else... | See the function description in base.py | [
"See",
"the",
"function",
"description",
"in",
"base",
".",
"py"
] | python | valid | 27.3125 |
openai/universe | universe/vncdriver/vendor/pydes.py | https://github.com/openai/universe/blob/cc9ce6ec241821bfb0f3b85dd455bd36e4ee7a8c/universe/vncdriver/vendor/pydes.py#L745-L749 | def setPadding(self, pad):
"""setPadding() -> bytes of length 1. Padding character."""
_baseDes.setPadding(self, pad)
for key in (self.__key1, self.__key2, self.__key3):
key.setPadding(pad) | [
"def",
"setPadding",
"(",
"self",
",",
"pad",
")",
":",
"_baseDes",
".",
"setPadding",
"(",
"self",
",",
"pad",
")",
"for",
"key",
"in",
"(",
"self",
".",
"__key1",
",",
"self",
".",
"__key2",
",",
"self",
".",
"__key3",
")",
":",
"key",
".",
"se... | setPadding() -> bytes of length 1. Padding character. | [
"setPadding",
"()",
"-",
">",
"bytes",
"of",
"length",
"1",
".",
"Padding",
"character",
"."
] | python | train | 38.8 |
CI-WATER/gsshapy | gsshapy/orm/prj.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/prj.py#L511-L534 | def _readXputFile(self, file_cards, card_name, directory, session,
spatial=False, spatialReferenceID=None,
replaceParamFile=None, **kwargs):
"""
Read specific IO file for a GSSHA project to the database.
"""
# Automatically derive the spatial r... | [
"def",
"_readXputFile",
"(",
"self",
",",
"file_cards",
",",
"card_name",
",",
"directory",
",",
"session",
",",
"spatial",
"=",
"False",
",",
"spatialReferenceID",
"=",
"None",
",",
"replaceParamFile",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Au... | Read specific IO file for a GSSHA project to the database. | [
"Read",
"specific",
"IO",
"file",
"for",
"a",
"GSSHA",
"project",
"to",
"the",
"database",
"."
] | python | train | 46.5 |
yyuu/botornado | boto/emr/connection.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/emr/connection.py#L170-L198 | def modify_instance_groups(self, instance_group_ids, new_sizes):
"""
Modify the number of nodes and configuration settings in an
instance group.
:type instance_group_ids: list(str)
:param instance_group_ids: A list of the ID's of the instance
groups to be modified
... | [
"def",
"modify_instance_groups",
"(",
"self",
",",
"instance_group_ids",
",",
"new_sizes",
")",
":",
"if",
"type",
"(",
"instance_group_ids",
")",
"!=",
"types",
".",
"ListType",
":",
"instance_group_ids",
"=",
"[",
"instance_group_ids",
"]",
"if",
"type",
"(",
... | Modify the number of nodes and configuration settings in an
instance group.
:type instance_group_ids: list(str)
:param instance_group_ids: A list of the ID's of the instance
groups to be modified
:type new_sizes: list(int)
:param new_sizes: A list of the... | [
"Modify",
"the",
"number",
"of",
"nodes",
"and",
"configuration",
"settings",
"in",
"an",
"instance",
"group",
"."
] | python | train | 41.37931 |
evhub/coconut | coconut/exceptions.py | https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/exceptions.py#L62-L72 | def internal_assert(condition, message=None, item=None, extra=None):
"""Raise InternalException if condition is False.
If condition is a function, execute it on DEVELOP only."""
if DEVELOP and callable(condition):
condition = condition()
if not condition:
if message is None:
... | [
"def",
"internal_assert",
"(",
"condition",
",",
"message",
"=",
"None",
",",
"item",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"if",
"DEVELOP",
"and",
"callable",
"(",
"condition",
")",
":",
"condition",
"=",
"condition",
"(",
")",
"if",
"not"... | Raise InternalException if condition is False.
If condition is a function, execute it on DEVELOP only. | [
"Raise",
"InternalException",
"if",
"condition",
"is",
"False",
".",
"If",
"condition",
"is",
"a",
"function",
"execute",
"it",
"on",
"DEVELOP",
"only",
"."
] | python | train | 41.909091 |
apache/airflow | airflow/contrib/hooks/azure_container_instance_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_container_instance_hook.py#L80-L93 | def create_or_update(self, resource_group, name, container_group):
"""
Create a new container group
:param resource_group: the name of the resource group
:type resource_group: str
:param name: the name of the container group
:type name: str
:param container_group... | [
"def",
"create_or_update",
"(",
"self",
",",
"resource_group",
",",
"name",
",",
"container_group",
")",
":",
"self",
".",
"connection",
".",
"container_groups",
".",
"create_or_update",
"(",
"resource_group",
",",
"name",
",",
"container_group",
")"
] | Create a new container group
:param resource_group: the name of the resource group
:type resource_group: str
:param name: the name of the container group
:type name: str
:param container_group: the properties of the container group
:type container_group: azure.mgmt.conta... | [
"Create",
"a",
"new",
"container",
"group"
] | python | test | 46.642857 |
roycehaynes/scrapy-rabbitmq | scrapy_rabbitmq/queue.py | https://github.com/roycehaynes/scrapy-rabbitmq/blob/5053b500aff1d6679cc0e3d3e338c2bf74fadc22/scrapy_rabbitmq/queue.py#L65-L71 | def pop(self):
"""Pop a request"""
method_frame, header, body = self.server.basic_get(queue=self.key)
if body:
return self._decode_request(body) | [
"def",
"pop",
"(",
"self",
")",
":",
"method_frame",
",",
"header",
",",
"body",
"=",
"self",
".",
"server",
".",
"basic_get",
"(",
"queue",
"=",
"self",
".",
"key",
")",
"if",
"body",
":",
"return",
"self",
".",
"_decode_request",
"(",
"body",
")"
] | Pop a request | [
"Pop",
"a",
"request"
] | python | train | 25.142857 |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L8714-L8740 | def mxmtg(m1, m2, nrow1, nc1c2, nrow2):
"""
Multiply a matrix and the transpose of a matrix, both of arbitrary size.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/mxmtg_c.html
:param m1: Left-hand matrix to be multiplied.
:type m1: NxM-Element Array of floats
:param m2: Right-hand ma... | [
"def",
"mxmtg",
"(",
"m1",
",",
"m2",
",",
"nrow1",
",",
"nc1c2",
",",
"nrow2",
")",
":",
"m1",
"=",
"stypes",
".",
"toDoubleMatrix",
"(",
"m1",
")",
"m2",
"=",
"stypes",
".",
"toDoubleMatrix",
"(",
"m2",
")",
"mout",
"=",
"stypes",
".",
"emptyDoub... | Multiply a matrix and the transpose of a matrix, both of arbitrary size.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/mxmtg_c.html
:param m1: Left-hand matrix to be multiplied.
:type m1: NxM-Element Array of floats
:param m2: Right-hand matrix whose transpose is to be multiplied
:type m... | [
"Multiply",
"a",
"matrix",
"and",
"the",
"transpose",
"of",
"a",
"matrix",
"both",
"of",
"arbitrary",
"size",
"."
] | python | train | 38.259259 |
secdev/scapy | scapy/contrib/ethercat.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ethercat.py#L561-L619 | def post_build(self, pkt, pay):
"""
need to set the length of the whole PDU manually
to avoid any bit fiddling use a dummy class to build the layer content
also add padding if frame is < 64 bytes
Note: padding only handles Ether/n*Dot1Q/EtherCat
(no special mumbo ... | [
"def",
"post_build",
"(",
"self",
",",
"pkt",
",",
"pay",
")",
":",
"class",
"_EtherCatLengthCalc",
"(",
"Packet",
")",
":",
"\"\"\"\n dummy class used to generate str representation easily\n \"\"\"",
"fields_desc",
"=",
"[",
"LEBitField",
"(",
"'len... | need to set the length of the whole PDU manually
to avoid any bit fiddling use a dummy class to build the layer content
also add padding if frame is < 64 bytes
Note: padding only handles Ether/n*Dot1Q/EtherCat
(no special mumbo jumbo)
:param pkt: raw string containing th... | [
"need",
"to",
"set",
"the",
"length",
"of",
"the",
"whole",
"PDU",
"manually",
"to",
"avoid",
"any",
"bit",
"fiddling",
"use",
"a",
"dummy",
"class",
"to",
"build",
"the",
"layer",
"content"
] | python | train | 36.627119 |
radjkarl/appBase | appbase/Session.py | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L208-L218 | def checkMaxSessions(self, nMax=None):
"""
check whether max. number of saved sessions is reached
if: remove the oldest session
"""
if nMax is None:
nMax = self.opts['maxSessions']
l = self.stateNames()
if len(l) > nMax:
for f in l... | [
"def",
"checkMaxSessions",
"(",
"self",
",",
"nMax",
"=",
"None",
")",
":",
"if",
"nMax",
"is",
"None",
":",
"nMax",
"=",
"self",
".",
"opts",
"[",
"'maxSessions'",
"]",
"l",
"=",
"self",
".",
"stateNames",
"(",
")",
"if",
"len",
"(",
"l",
")",
"... | check whether max. number of saved sessions is reached
if: remove the oldest session | [
"check",
"whether",
"max",
".",
"number",
"of",
"saved",
"sessions",
"is",
"reached",
"if",
":",
"remove",
"the",
"oldest",
"session"
] | python | train | 34.545455 |
rackerlabs/simpl | simpl/db/mongodb.py | https://github.com/rackerlabs/simpl/blob/60ed3336a931cd6a7a7246e60f26165d9dc7c99c/simpl/db/mongodb.py#L428-L458 | def list(self, offset=0, limit=0, fields=None, sort=None, **kwargs):
"""Return filtered list of documents in a collection.
For text-based search, we support searching on a name/string field by
regex and text index. So strings passed in to a r=text search are
used to filter collections b... | [
"def",
"list",
"(",
"self",
",",
"offset",
"=",
"0",
",",
"limit",
"=",
"0",
",",
"fields",
"=",
"None",
",",
"sort",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"cursor",
"=",
"self",
".",
"_cursor",
"(",
"offset",
"=",
"offset... | Return filtered list of documents in a collection.
For text-based search, we support searching on a name/string field by
regex and text index. So strings passed in to a r=text search are
used to filter collections by text index and regex on a named field.
:param offset: for pagination,... | [
"Return",
"filtered",
"list",
"of",
"documents",
"in",
"a",
"collection",
"."
] | python | train | 52.096774 |
openid/python-openid | openid/consumer/consumer.py | https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/consumer/consumer.py#L843-L873 | def _verifyReturnToArgs(query):
"""Verify that the arguments in the return_to URL are present in this
response.
"""
message = Message.fromPostArgs(query)
return_to = message.getArg(OPENID_NS, 'return_to')
if return_to is None:
raise ProtocolError('Response ha... | [
"def",
"_verifyReturnToArgs",
"(",
"query",
")",
":",
"message",
"=",
"Message",
".",
"fromPostArgs",
"(",
"query",
")",
"return_to",
"=",
"message",
".",
"getArg",
"(",
"OPENID_NS",
",",
"'return_to'",
")",
"if",
"return_to",
"is",
"None",
":",
"raise",
"... | Verify that the arguments in the return_to URL are present in this
response. | [
"Verify",
"that",
"the",
"arguments",
"in",
"the",
"return_to",
"URL",
"are",
"present",
"in",
"this",
"response",
"."
] | python | train | 40.258065 |
hydpy-dev/hydpy | hydpy/exe/servertools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/exe/servertools.py#L1080-L1084 | def GET_save_modifiedconditionitemvalues(self) -> None:
"""ToDo: extend functionality and add tests"""
for item in state.conditionitems:
state.modifiedconditionitemvalues[self._id][item.name] = \
list(item.device2target.values())[0].value | [
"def",
"GET_save_modifiedconditionitemvalues",
"(",
"self",
")",
"->",
"None",
":",
"for",
"item",
"in",
"state",
".",
"conditionitems",
":",
"state",
".",
"modifiedconditionitemvalues",
"[",
"self",
".",
"_id",
"]",
"[",
"item",
".",
"name",
"]",
"=",
"list... | ToDo: extend functionality and add tests | [
"ToDo",
":",
"extend",
"functionality",
"and",
"add",
"tests"
] | python | train | 55.6 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/utils.py | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/utils.py#L51-L65 | def base64url_to_long(data):
"""
Stricter then base64_to_long since it really checks that it's
base64url encoded
:param data: The base64 string
:return:
"""
_data = as_bytes(data)
_d = base64.urlsafe_b64decode(_data + b'==')
# verify that it's base64url encoded and not just base64
... | [
"def",
"base64url_to_long",
"(",
"data",
")",
":",
"_data",
"=",
"as_bytes",
"(",
"data",
")",
"_d",
"=",
"base64",
".",
"urlsafe_b64decode",
"(",
"_data",
"+",
"b'=='",
")",
"# verify that it's base64url encoded and not just base64",
"# that is no '+' and '/' character... | Stricter then base64_to_long since it really checks that it's
base64url encoded
:param data: The base64 string
:return: | [
"Stricter",
"then",
"base64_to_long",
"since",
"it",
"really",
"checks",
"that",
"it",
"s",
"base64url",
"encoded"
] | python | train | 35.333333 |
phn/angles | angles.py | https://github.com/phn/angles/blob/5c30ed7c3a7412177daaed180bf3b2351b287589/angles.py#L1969-L2003 | def normalize_sphere(alpha, delta):
"""Normalize angles of a point on a sphere.
Parameters
----------
alpha: float
The alpha (right ascension/longitude like) angle in degrees.
delta: float
The delta (declination/latitude like) angle in degrees.
Returns
-------
(alpha, d... | [
"def",
"normalize_sphere",
"(",
"alpha",
",",
"delta",
")",
":",
"v",
"=",
"CartesianVector",
".",
"from_spherical",
"(",
"r",
"=",
"1.0",
",",
"alpha",
"=",
"d2r",
"(",
"alpha",
")",
",",
"delta",
"=",
"d2r",
"(",
"delta",
")",
")",
"angles",
"=",
... | Normalize angles of a point on a sphere.
Parameters
----------
alpha: float
The alpha (right ascension/longitude like) angle in degrees.
delta: float
The delta (declination/latitude like) angle in degrees.
Returns
-------
(alpha, delta): (float, float)
Normalized al... | [
"Normalize",
"angles",
"of",
"a",
"point",
"on",
"a",
"sphere",
"."
] | python | train | 28.4 |
dmort27/panphon | panphon/_panphon.py | https://github.com/dmort27/panphon/blob/17eaa482e3edb211f3a8138137d76e4b9246d201/panphon/_panphon.py#L378-L399 | def fts_contrast2(self, fs, ft_name, inv):
"""Return `True` if there is a segment in `inv` that contrasts in feature
`ft_name`.
Args:
fs (list): feature specifications used to filter `inv`.
ft_name (str): name of the feature where contrast must be present.
in... | [
"def",
"fts_contrast2",
"(",
"self",
",",
"fs",
",",
"ft_name",
",",
"inv",
")",
":",
"inv_fts",
"=",
"[",
"self",
".",
"fts",
"(",
"x",
")",
"for",
"x",
"in",
"inv",
"if",
"set",
"(",
"fs",
")",
"<=",
"self",
".",
"fts",
"(",
"x",
")",
"]",
... | Return `True` if there is a segment in `inv` that contrasts in feature
`ft_name`.
Args:
fs (list): feature specifications used to filter `inv`.
ft_name (str): name of the feature where contrast must be present.
inv (list): collection of segments represented as Unicod... | [
"Return",
"True",
"if",
"there",
"is",
"a",
"segment",
"in",
"inv",
"that",
"contrasts",
"in",
"feature",
"ft_name",
"."
] | python | train | 39.681818 |
maxcountryman/flask-login | flask_login/login_manager.py | https://github.com/maxcountryman/flask-login/blob/d22f80d166ee260d44e0d2d9ea973b784ef3621b/flask_login/login_manager.py#L245-L290 | def needs_refresh(self):
'''
This is called when the user is logged in, but they need to be
reauthenticated because their session is stale. If you register a
callback with `needs_refresh_handler`, then it will be called.
Otherwise, it will take the following actions:
... | [
"def",
"needs_refresh",
"(",
"self",
")",
":",
"user_needs_refresh",
".",
"send",
"(",
"current_app",
".",
"_get_current_object",
"(",
")",
")",
"if",
"self",
".",
"needs_refresh_callback",
":",
"return",
"self",
".",
"needs_refresh_callback",
"(",
")",
"if",
... | This is called when the user is logged in, but they need to be
reauthenticated because their session is stale. If you register a
callback with `needs_refresh_handler`, then it will be called.
Otherwise, it will take the following actions:
- Flash :attr:`LoginManager.needs_refresh_me... | [
"This",
"is",
"called",
"when",
"the",
"user",
"is",
"logged",
"in",
"but",
"they",
"need",
"to",
"be",
"reauthenticated",
"because",
"their",
"session",
"is",
"stale",
".",
"If",
"you",
"register",
"a",
"callback",
"with",
"needs_refresh_handler",
"then",
"... | python | train | 42.282609 |
cokelaer/spectrum | doc/sphinxext/sphinx_gallery/gen_rst.py | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_rst.py#L520-L607 | def generate_file_rst(fname, target_dir, src_dir, gallery_conf):
""" Generate the rst file for a given example.
Returns the amout of code (in characters) of the corresponding
files.
"""
src_file = os.path.join(src_dir, fname)
example_file = os.path.join(target_dir, fname)
shutil.co... | [
"def",
"generate_file_rst",
"(",
"fname",
",",
"target_dir",
",",
"src_dir",
",",
"gallery_conf",
")",
":",
"src_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"src_dir",
",",
"fname",
")",
"example_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"t... | Generate the rst file for a given example.
Returns the amout of code (in characters) of the corresponding
files. | [
"Generate",
"the",
"rst",
"file",
"for",
"a",
"given",
"example",
"."
] | python | valid | 40.772727 |
pvlib/pvlib-python | pvlib/pvsystem.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/pvsystem.py#L352-L379 | def calcparams_cec(self, effective_irradiance, temp_cell, **kwargs):
"""
Use the :py:func:`calcparams_cec` function, the input
parameters and ``self.module_parameters`` to calculate the
module currents and resistances.
Parameters
----------
effective_irradiance :... | [
"def",
"calcparams_cec",
"(",
"self",
",",
"effective_irradiance",
",",
"temp_cell",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"_build_kwargs",
"(",
"[",
"'a_ref'",
",",
"'I_L_ref'",
",",
"'I_o_ref'",
",",
"'R_sh_ref'",
",",
"'R_s'",
",",
"'alpha_sc'... | Use the :py:func:`calcparams_cec` function, the input
parameters and ``self.module_parameters`` to calculate the
module currents and resistances.
Parameters
----------
effective_irradiance : numeric
The irradiance (W/m2) that is converted to photocurrent.
te... | [
"Use",
"the",
":",
"py",
":",
"func",
":",
"calcparams_cec",
"function",
"the",
"input",
"parameters",
"and",
"self",
".",
"module_parameters",
"to",
"calculate",
"the",
"module",
"currents",
"and",
"resistances",
"."
] | python | train | 35.142857 |
peopledoc/django-pimpmytheme | pimpmytheme/management/commands/update_themefolder_from_git.py | https://github.com/peopledoc/django-pimpmytheme/blob/302c65bec52bbd9e0a17de68ad337ef4a6205556/pimpmytheme/management/commands/update_themefolder_from_git.py#L90-L97 | def clone(self, folder, git_repository):
"""Ensures theme destination folder and clone git specified repo in it.
:param git_repository: git url of the theme folder
:param folder: path of the git managed theme folder
"""
os.makedirs(folder)
git.Git().clone(git_repository,... | [
"def",
"clone",
"(",
"self",
",",
"folder",
",",
"git_repository",
")",
":",
"os",
".",
"makedirs",
"(",
"folder",
")",
"git",
".",
"Git",
"(",
")",
".",
"clone",
"(",
"git_repository",
",",
"folder",
")"
] | Ensures theme destination folder and clone git specified repo in it.
:param git_repository: git url of the theme folder
:param folder: path of the git managed theme folder | [
"Ensures",
"theme",
"destination",
"folder",
"and",
"clone",
"git",
"specified",
"repo",
"in",
"it",
"."
] | python | train | 40.125 |
open-mmlab/mmcv | mmcv/utils/misc.py | https://github.com/open-mmlab/mmcv/blob/0d77f61450aab4dde8b8585a577cc496acb95d7f/mmcv/utils/misc.py#L102-L123 | def slice_list(in_list, lens):
"""Slice a list into several sub lists by a list of given length.
Args:
in_list (list): The list to be sliced.
lens(int or list): The expected length of each out list.
Returns:
list: A list of sliced list.
"""
if not isinstance(lens, list):
... | [
"def",
"slice_list",
"(",
"in_list",
",",
"lens",
")",
":",
"if",
"not",
"isinstance",
"(",
"lens",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"'\"indices\" must be a list of integers'",
")",
"elif",
"sum",
"(",
"lens",
")",
"!=",
"len",
"(",
"in_li... | Slice a list into several sub lists by a list of given length.
Args:
in_list (list): The list to be sliced.
lens(int or list): The expected length of each out list.
Returns:
list: A list of sliced list. | [
"Slice",
"a",
"list",
"into",
"several",
"sub",
"lists",
"by",
"a",
"list",
"of",
"given",
"length",
"."
] | python | test | 31.590909 |
phoebe-project/phoebe2 | phoebe/frontend/bundle.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/frontend/bundle.py#L2991-L3002 | def remove_compute(self, compute, **kwargs):
"""
Remove a 'compute' from the bundle
:parameter str compute: name of the compute options
:parameter **kwargs: any other tags to do the filter
(except twig or context)
:raise NotImplementedError: because it isn't
... | [
"def",
"remove_compute",
"(",
"self",
",",
"compute",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'compute'",
"]",
"=",
"compute",
"kwargs",
"[",
"'context'",
"]",
"=",
"'comute'",
"self",
".",
"remove_parameters_all",
"(",
"*",
"*",
"kwargs",
")"... | Remove a 'compute' from the bundle
:parameter str compute: name of the compute options
:parameter **kwargs: any other tags to do the filter
(except twig or context)
:raise NotImplementedError: because it isn't | [
"Remove",
"a",
"compute",
"from",
"the",
"bundle"
] | python | train | 35.833333 |
artefactual-labs/mets-reader-writer | metsrw/mets.py | https://github.com/artefactual-labs/mets-reader-writer/blob/d95939cabdfdc25cb1bf67df0c84bd0d6e6a73ff/metsrw/mets.py#L262-L286 | def _filesec(self, files=None):
"""
Returns fileSec Element containing all files grouped by use.
"""
if files is None:
files = self.all_files()
filesec = etree.Element(utils.lxmlns("mets") + "fileSec")
filegrps = {}
for file_ in files:
if ... | [
"def",
"_filesec",
"(",
"self",
",",
"files",
"=",
"None",
")",
":",
"if",
"files",
"is",
"None",
":",
"files",
"=",
"self",
".",
"all_files",
"(",
")",
"filesec",
"=",
"etree",
".",
"Element",
"(",
"utils",
".",
"lxmlns",
"(",
"\"mets\"",
")",
"+"... | Returns fileSec Element containing all files grouped by use. | [
"Returns",
"fileSec",
"Element",
"containing",
"all",
"files",
"grouped",
"by",
"use",
"."
] | python | train | 33.36 |
saschpe/rapport | rapport/template.py | https://github.com/saschpe/rapport/blob/ccceb8f84bd7e8add88ab5e137cdab6424aa4683/rapport/template.py#L42-L44 | def subn_filter(s, find, replace, count=0):
"""A non-optimal implementation of a regex filter"""
return re.gsub(find, replace, count, s) | [
"def",
"subn_filter",
"(",
"s",
",",
"find",
",",
"replace",
",",
"count",
"=",
"0",
")",
":",
"return",
"re",
".",
"gsub",
"(",
"find",
",",
"replace",
",",
"count",
",",
"s",
")"
] | A non-optimal implementation of a regex filter | [
"A",
"non",
"-",
"optimal",
"implementation",
"of",
"a",
"regex",
"filter"
] | python | train | 47.333333 |
materialsproject/pymatgen | pymatgen/electronic_structure/boltztrap.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/boltztrap.py#L987-L1020 | def get_seebeck(self, output='eigs', doping_levels=True):
"""
Gives the seebeck coefficient (microV/K) in either a
full 3x3 tensor form, as 3 eigenvalues, or as the average value
(trace/3.0) If doping_levels=True, the results are given at
different p and n doping
... | [
"def",
"get_seebeck",
"(",
"self",
",",
"output",
"=",
"'eigs'",
",",
"doping_levels",
"=",
"True",
")",
":",
"return",
"BoltztrapAnalyzer",
".",
"_format_to_output",
"(",
"self",
".",
"_seebeck",
",",
"self",
".",
"_seebeck_doping",
",",
"output",
",",
"dop... | Gives the seebeck coefficient (microV/K) in either a
full 3x3 tensor form, as 3 eigenvalues, or as the average value
(trace/3.0) If doping_levels=True, the results are given at
different p and n doping
levels (given by self.doping), otherwise it is given as a series
... | [
"Gives",
"the",
"seebeck",
"coefficient",
"(",
"microV",
"/",
"K",
")",
"in",
"either",
"a",
"full",
"3x3",
"tensor",
"form",
"as",
"3",
"eigenvalues",
"or",
"as",
"the",
"average",
"value",
"(",
"trace",
"/",
"3",
".",
"0",
")",
"If",
"doping_levels",... | python | train | 49.382353 |
chibisov/drf-extensions | docs/backdoc.py | https://github.com/chibisov/drf-extensions/blob/1d28a4b28890eab5cd19e93e042f8590c8c2fb8b/docs/backdoc.py#L1961-L1969 | def _slugify(text, delim=u'-'):
"""Generates an ASCII-only slug."""
result = []
for word in _punct_re.split(text.lower()):
word = word.encode('utf-8')
if word:
result.append(word)
slugified = delim.join([i.decode('utf-8') for i in result])
return re.sub('[^a-zA-Z0-9\\s\\-... | [
"def",
"_slugify",
"(",
"text",
",",
"delim",
"=",
"u'-'",
")",
":",
"result",
"=",
"[",
"]",
"for",
"word",
"in",
"_punct_re",
".",
"split",
"(",
"text",
".",
"lower",
"(",
")",
")",
":",
"word",
"=",
"word",
".",
"encode",
"(",
"'utf-8'",
")",
... | Generates an ASCII-only slug. | [
"Generates",
"an",
"ASCII",
"-",
"only",
"slug",
"."
] | python | train | 39 |
gwastro/pycbc | pycbc/workflow/jobsetup.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/jobsetup.py#L38-L58 | def int_gps_time_to_str(t):
"""Takes an integer GPS time, either given as int or lal.LIGOTimeGPS, and
converts it to a string. If a LIGOTimeGPS with nonzero decimal part is
given, raises a ValueError."""
if isinstance(t, int):
return str(t)
elif isinstance(t, float):
# Wouldn't this... | [
"def",
"int_gps_time_to_str",
"(",
"t",
")",
":",
"if",
"isinstance",
"(",
"t",
",",
"int",
")",
":",
"return",
"str",
"(",
"t",
")",
"elif",
"isinstance",
"(",
"t",
",",
"float",
")",
":",
"# Wouldn't this just work generically?",
"int_t",
"=",
"int",
"... | Takes an integer GPS time, either given as int or lal.LIGOTimeGPS, and
converts it to a string. If a LIGOTimeGPS with nonzero decimal part is
given, raises a ValueError. | [
"Takes",
"an",
"integer",
"GPS",
"time",
"either",
"given",
"as",
"int",
"or",
"lal",
".",
"LIGOTimeGPS",
"and",
"converts",
"it",
"to",
"a",
"string",
".",
"If",
"a",
"LIGOTimeGPS",
"with",
"nonzero",
"decimal",
"part",
"is",
"given",
"raises",
"a",
"Va... | python | train | 37.619048 |
COLORFULBOARD/revision | revision/client_manager.py | https://github.com/COLORFULBOARD/revision/blob/2f22e72cce5b60032a80c002ac45c2ecef0ed987/revision/client_manager.py#L29-L47 | def instantiate_client(self, config):
"""
:param config: The config object.
:type config: dict
:return: The instantiated class.
:rtype: :class:`revision.client.Client`
"""
modules = config.module.split('.')
class_name = modules.pop()
module_path = ... | [
"def",
"instantiate_client",
"(",
"self",
",",
"config",
")",
":",
"modules",
"=",
"config",
".",
"module",
".",
"split",
"(",
"'.'",
")",
"class_name",
"=",
"modules",
".",
"pop",
"(",
")",
"module_path",
"=",
"'.'",
".",
"join",
"(",
"modules",
")",
... | :param config: The config object.
:type config: dict
:return: The instantiated class.
:rtype: :class:`revision.client.Client` | [
":",
"param",
"config",
":",
"The",
"config",
"object",
".",
":",
"type",
"config",
":",
"dict",
":",
"return",
":",
"The",
"instantiated",
"class",
".",
":",
"rtype",
":",
":",
"class",
":",
"revision",
".",
"client",
".",
"Client"
] | python | train | 27.210526 |
hkff/FodtlMon | fodtlmon/tools/color.py | https://github.com/hkff/FodtlMon/blob/0c9015a1a1f0a4a64d52945c86b45441d5871c56/fodtlmon/tools/color.py#L237-L267 | def _parse_input(incoming):
"""Performs the actual conversion of tags to ANSI escaped codes.
Provides a version of the input without any colors for len() and other methods.
Positional arguments:
incoming -- the input unicode value.
Returns:
2-item tuple. First item is the parsed output. Secon... | [
"def",
"_parse_input",
"(",
"incoming",
")",
":",
"codes",
"=",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"_AutoCodes",
"(",
")",
".",
"items",
"(",
")",
"if",
"'{%s}'",
"%",
"k",
"in",
"incoming",
")",
"color_codes",
"=",... | Performs the actual conversion of tags to ANSI escaped codes.
Provides a version of the input without any colors for len() and other methods.
Positional arguments:
incoming -- the input unicode value.
Returns:
2-item tuple. First item is the parsed output. Second item is a version of the input wi... | [
"Performs",
"the",
"actual",
"conversion",
"of",
"tags",
"to",
"ANSI",
"escaped",
"codes",
"."
] | python | train | 50.419355 |
tulir/mautrix-python | mautrix_appservice/intent_api.py | https://github.com/tulir/mautrix-python/blob/21bb0870e4103dd03ecc61396ce02adb9301f382/mautrix_appservice/intent_api.py#L362-L374 | async def set_avatar(self, url: str):
"""
Set the avatar of the user. See also: `API reference`_
Args:
url: The new avatar URL for the user. Must be a MXC URI.
.. _API reference:
https://matrix.org/docs/spec/client_server/r0.3.0.html#put-matrix-client-r0-profile-... | [
"async",
"def",
"set_avatar",
"(",
"self",
",",
"url",
":",
"str",
")",
":",
"await",
"self",
".",
"ensure_registered",
"(",
")",
"content",
"=",
"{",
"\"avatar_url\"",
":",
"url",
"}",
"await",
"self",
".",
"client",
".",
"request",
"(",
"\"PUT\"",
",... | Set the avatar of the user. See also: `API reference`_
Args:
url: The new avatar URL for the user. Must be a MXC URI.
.. _API reference:
https://matrix.org/docs/spec/client_server/r0.3.0.html#put-matrix-client-r0-profile-userid-avatar-url | [
"Set",
"the",
"avatar",
"of",
"the",
"user",
".",
"See",
"also",
":",
"API",
"reference",
"_"
] | python | train | 38.461538 |
cisco-sas/kitty | kitty/model/low_level/container.py | https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/model/low_level/container.py#L769-L780 | def get_rendered_fields(self, ctx=None):
'''
:param ctx: rendering context in which the method was called
:return: ordered list of the fields that will be rendered
'''
if ctx is None:
ctx = RenderContext()
ctx.push(self)
current = self._fields[self._fi... | [
"def",
"get_rendered_fields",
"(",
"self",
",",
"ctx",
"=",
"None",
")",
":",
"if",
"ctx",
"is",
"None",
":",
"ctx",
"=",
"RenderContext",
"(",
")",
"ctx",
".",
"push",
"(",
"self",
")",
"current",
"=",
"self",
".",
"_fields",
"[",
"self",
".",
"_f... | :param ctx: rendering context in which the method was called
:return: ordered list of the fields that will be rendered | [
":",
"param",
"ctx",
":",
"rendering",
"context",
"in",
"which",
"the",
"method",
"was",
"called",
":",
"return",
":",
"ordered",
"list",
"of",
"the",
"fields",
"that",
"will",
"be",
"rendered"
] | python | train | 33.416667 |
atztogo/phonopy | phonopy/api_phonopy.py | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L652-L675 | def get_dynamical_matrix_at_q(self, q):
"""Calculate dynamical matrix at a given q-point
Parameters
----------
q: array_like
A q-vector.
shape=(3,), dtype='double'
Returns
-------
dynamical_matrix: ndarray
Dynamical matrix.
... | [
"def",
"get_dynamical_matrix_at_q",
"(",
"self",
",",
"q",
")",
":",
"self",
".",
"_set_dynamical_matrix",
"(",
")",
"if",
"self",
".",
"_dynamical_matrix",
"is",
"None",
":",
"msg",
"=",
"(",
"\"Dynamical matrix has not yet built.\"",
")",
"raise",
"RuntimeError"... | Calculate dynamical matrix at a given q-point
Parameters
----------
q: array_like
A q-vector.
shape=(3,), dtype='double'
Returns
-------
dynamical_matrix: ndarray
Dynamical matrix.
shape=(bands, bands), dtype='complex' | [
"Calculate",
"dynamical",
"matrix",
"at",
"a",
"given",
"q",
"-",
"point"
] | python | train | 27.041667 |
protream/iquery | iquery/trains.py | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/trains.py#L197-L218 | def _parse_date(date):
"""Parse from the user input `date`.
e.g. current year 2016:
input 6-26, 626, ... return 2016626
input 2016-6-26, 2016/6/26, ... retrun 2016626
This fn wouldn't check the date, it only gather the number as a string.
"""
result = ''.j... | [
"def",
"_parse_date",
"(",
"date",
")",
":",
"result",
"=",
"''",
".",
"join",
"(",
"re",
".",
"findall",
"(",
"'\\d'",
",",
"date",
")",
")",
"l",
"=",
"len",
"(",
"result",
")",
"# User only input month and day, eg 6-1, 6.26, 0626...",
"if",
"l",
"in",
... | Parse from the user input `date`.
e.g. current year 2016:
input 6-26, 626, ... return 2016626
input 2016-6-26, 2016/6/26, ... retrun 2016626
This fn wouldn't check the date, it only gather the number as a string. | [
"Parse",
"from",
"the",
"user",
"input",
"date",
"."
] | python | train | 30.272727 |
5monkeys/django-bananas | bananas/secrets.py | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/secrets.py#L8-L22 | def get_secret(secret_name, default=None):
"""
Gets contents of secret file
:param secret_name: The name of the secret present in BANANAS_SECRETS_DIR
:param default: Default value to return if no secret was found
:return: The secret or default if not found
"""
secrets_dir = get_secrets_dir(... | [
"def",
"get_secret",
"(",
"secret_name",
",",
"default",
"=",
"None",
")",
":",
"secrets_dir",
"=",
"get_secrets_dir",
"(",
")",
"secret_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"secrets_dir",
",",
"secret_name",
")",
"try",
":",
"with",
"open",
... | Gets contents of secret file
:param secret_name: The name of the secret present in BANANAS_SECRETS_DIR
:param default: Default value to return if no secret was found
:return: The secret or default if not found | [
"Gets",
"contents",
"of",
"secret",
"file"
] | python | test | 33.733333 |
spyder-ide/spyder | spyder/utils/workers.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/workers.py#L303-L314 | def terminate_all(self):
"""Terminate all worker processes."""
for worker in self._workers:
worker.terminate()
# for thread in self._threads:
# try:
# thread.terminate()
# thread.wait()
# except Exception:
# pas... | [
"def",
"terminate_all",
"(",
"self",
")",
":",
"for",
"worker",
"in",
"self",
".",
"_workers",
":",
"worker",
".",
"terminate",
"(",
")",
"# for thread in self._threads:",
"# try:",
"# thread.terminate()",
"# thread.wait()",
"# except Exception:",
... | Terminate all worker processes. | [
"Terminate",
"all",
"worker",
"processes",
"."
] | python | train | 29 |
PMEAL/OpenPNM | openpnm/topotools/topotools.py | https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/topotools/topotools.py#L1947-L2032 | def plot_coordinates(network, pores=None, fig=None, **kwargs):
r"""
Produces a 3D plot showing specified pore coordinates as markers
Parameters
----------
network : OpenPNM Network Object
The network whose topological connections to plot
pores : array_like (optional)
The list o... | [
"def",
"plot_coordinates",
"(",
"network",
",",
"pores",
"=",
"None",
",",
"fig",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"from",
"mpl_toolkits",
".",
"mplot3d",
"import",
"Axes3D",
"if",
"pores... | r"""
Produces a 3D plot showing specified pore coordinates as markers
Parameters
----------
network : OpenPNM Network Object
The network whose topological connections to plot
pores : array_like (optional)
The list of pores to plot if only a sub-sample is desired. This is
u... | [
"r",
"Produces",
"a",
"3D",
"plot",
"showing",
"specified",
"pore",
"coordinates",
"as",
"markers"
] | python | train | 30.081395 |
polysquare/polysquare-generic-file-linter | polysquarelinter/spelling.py | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L910-L930 | def corrections(self, word, prefix=1, distance=2):
"""Get corrections for word, if word is an invalid word.
:prefix: is the number of characters the prefix of the word must
have in common with the suggested corrections.
:distance: is the character distance the corrections may have betw... | [
"def",
"corrections",
"(",
"self",
",",
"word",
",",
"prefix",
"=",
"1",
",",
"distance",
"=",
"2",
")",
":",
"if",
"word",
"not",
"in",
"self",
".",
"_words",
":",
"return",
"Dictionary",
".",
"Result",
"(",
"False",
",",
"self",
".",
"_corrector",
... | Get corrections for word, if word is an invalid word.
:prefix: is the number of characters the prefix of the word must
have in common with the suggested corrections.
:distance: is the character distance the corrections may have between
the input word. This limits the number of availabl... | [
"Get",
"corrections",
"for",
"word",
"if",
"word",
"is",
"an",
"invalid",
"word",
"."
] | python | train | 48.380952 |
LeKono/pyhgnc | src/pyhgnc/manager/query.py | https://github.com/LeKono/pyhgnc/blob/1cae20c40874bfb51581b7c5c1481707e942b5d0/src/pyhgnc/manager/query.py#L692-L731 | def mgd(self, mgdid=None, hgnc_symbol=None, hgnc_identifier=None, limit=None, as_df=False):
"""Method to query :class:`.models.MGD` objects in database
:param mgdid: Mouse genome informatics database ID(s)
:type mgdid: str or tuple(str) or None
:param hgnc_symbol: HGNC symbol(s)
... | [
"def",
"mgd",
"(",
"self",
",",
"mgdid",
"=",
"None",
",",
"hgnc_symbol",
"=",
"None",
",",
"hgnc_identifier",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"as_df",
"=",
"False",
")",
":",
"q",
"=",
"self",
".",
"session",
".",
"query",
"(",
"model... | Method to query :class:`.models.MGD` objects in database
:param mgdid: Mouse genome informatics database ID(s)
:type mgdid: str or tuple(str) or None
:param hgnc_symbol: HGNC symbol(s)
:type hgnc_symbol: str or tuple(str) or None
:param hgnc_identifier: identifiers(s) in :clas... | [
"Method",
"to",
"query",
":",
"class",
":",
".",
"models",
".",
"MGD",
"objects",
"in",
"database"
] | python | train | 38.65 |
yinkaisheng/Python-UIAutomation-for-Windows | uiautomation/uiautomation.py | https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L5601-L5609 | def GetPatternAs(self, patternId: int, riid):
"""
Call IUIAutomationElement::GetCurrentPatternAs.
Get a new pattern by pattern id if it supports the pattern, todo.
patternId: int, a value in class `PatternId`.
riid: GUID.
Refer https://docs.microsoft.com/en-us/windows/des... | [
"def",
"GetPatternAs",
"(",
"self",
",",
"patternId",
":",
"int",
",",
"riid",
")",
":",
"return",
"self",
".",
"Element",
".",
"GetCurrentPatternAs",
"(",
"patternId",
",",
"riid",
")"
] | Call IUIAutomationElement::GetCurrentPatternAs.
Get a new pattern by pattern id if it supports the pattern, todo.
patternId: int, a value in class `PatternId`.
riid: GUID.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationele... | [
"Call",
"IUIAutomationElement",
"::",
"GetCurrentPatternAs",
".",
"Get",
"a",
"new",
"pattern",
"by",
"pattern",
"id",
"if",
"it",
"supports",
"the",
"pattern",
"todo",
".",
"patternId",
":",
"int",
"a",
"value",
"in",
"class",
"PatternId",
".",
"riid",
":",... | python | valid | 53.222222 |
brentp/toolshed | toolshed/pool.py | https://github.com/brentp/toolshed/blob/c9529d6872bf28207642896c3b416f68e79b1269/toolshed/pool.py#L99-L138 | def pmap(f, iterable, n=None, dummy=False, p=None):
"""
parallel map of a function to an iterable
if each item in iterable is itself an iterable, then
automatically call f(*item) instead of f(item)
Arguments:
f: function
iterable: any iterable where each item is sent to f
n: numbe... | [
"def",
"pmap",
"(",
"f",
",",
"iterable",
",",
"n",
"=",
"None",
",",
"dummy",
"=",
"False",
",",
"p",
"=",
"None",
")",
":",
"# make it easier to debug.",
"if",
"n",
"==",
"1",
":",
"for",
"r",
"in",
"it",
".",
"starmap",
"(",
"f",
",",
"iterabl... | parallel map of a function to an iterable
if each item in iterable is itself an iterable, then
automatically call f(*item) instead of f(item)
Arguments:
f: function
iterable: any iterable where each item is sent to f
n: number of cpus (default is number on machine)
dummy: use dummy ... | [
"parallel",
"map",
"of",
"a",
"function",
"to",
"an",
"iterable",
"if",
"each",
"item",
"in",
"iterable",
"is",
"itself",
"an",
"iterable",
"then",
"automatically",
"call",
"f",
"(",
"*",
"item",
")",
"instead",
"of",
"f",
"(",
"item",
")"
] | python | train | 22.725 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/refgraph.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L355-L361 | def write_graph(self, filename):
"""
Write raw graph data which can be post-processed using graphviz.
"""
f = open(filename, 'w')
f.write(self._get_graphviz_data())
f.close() | [
"def",
"write_graph",
"(",
"self",
",",
"filename",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"f",
".",
"write",
"(",
"self",
".",
"_get_graphviz_data",
"(",
")",
")",
"f",
".",
"close",
"(",
")"
] | Write raw graph data which can be post-processed using graphviz. | [
"Write",
"raw",
"graph",
"data",
"which",
"can",
"be",
"post",
"-",
"processed",
"using",
"graphviz",
"."
] | python | train | 30.857143 |
pavoni/pyvera | pyvera/__init__.py | https://github.com/pavoni/pyvera/blob/e05e3d13f76153444787d31948feb5419d77a8c8/pyvera/__init__.py#L471-L481 | def call_service(self, service_id, action):
"""Call a Vera service.
This will call the Vera api to change device state.
"""
result = self.vera_request(id='action', serviceId=service_id,
action=action)
logger.debug("call_service: "
... | [
"def",
"call_service",
"(",
"self",
",",
"service_id",
",",
"action",
")",
":",
"result",
"=",
"self",
".",
"vera_request",
"(",
"id",
"=",
"'action'",
",",
"serviceId",
"=",
"service_id",
",",
"action",
"=",
"action",
")",
"logger",
".",
"debug",
"(",
... | Call a Vera service.
This will call the Vera api to change device state. | [
"Call",
"a",
"Vera",
"service",
"."
] | python | train | 38.181818 |
miyakogi/wdom | wdom/tag.py | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L139-L145 | def textContent(self, text: str) -> None: # type: ignore
"""Set text content to inner node."""
if self._inner_element:
self._inner_element.textContent = text
else:
# Need a trick to call property of super-class
super().textContent = text | [
"def",
"textContent",
"(",
"self",
",",
"text",
":",
"str",
")",
"->",
"None",
":",
"# type: ignore",
"if",
"self",
".",
"_inner_element",
":",
"self",
".",
"_inner_element",
".",
"textContent",
"=",
"text",
"else",
":",
"# Need a trick to call property of super... | Set text content to inner node. | [
"Set",
"text",
"content",
"to",
"inner",
"node",
"."
] | python | train | 41.714286 |
nephila/djangocms-page-meta | djangocms_page_meta/utils.py | https://github.com/nephila/djangocms-page-meta/blob/a38efe3fe3a717d9ad91bfc6aacab90989cd04a4/djangocms_page_meta/utils.py#L10-L19 | def get_cache_key(page, language):
"""
Create the cache key for the current page and language
"""
from cms.cache import _get_cache_key
try:
site_id = page.node.site_id
except AttributeError: # CMS_3_4
site_id = page.site_id
return _get_cache_key('page_meta', page, language, ... | [
"def",
"get_cache_key",
"(",
"page",
",",
"language",
")",
":",
"from",
"cms",
".",
"cache",
"import",
"_get_cache_key",
"try",
":",
"site_id",
"=",
"page",
".",
"node",
".",
"site_id",
"except",
"AttributeError",
":",
"# CMS_3_4",
"site_id",
"=",
"page",
... | Create the cache key for the current page and language | [
"Create",
"the",
"cache",
"key",
"for",
"the",
"current",
"page",
"and",
"language"
] | python | train | 31.9 |
flowersteam/explauto | explauto/sensorimotor_model/inverse/cma.py | https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L1808-L1889 | def geno(self, y, from_bounds=None,
copy_if_changed=True, copy_always=False,
repair=None, archive=None):
"""maps the phenotypic input argument into the genotypic space,
that is, computes essentially the inverse of ``pheno``.
By default a copy is made only to prevent to... | [
"def",
"geno",
"(",
"self",
",",
"y",
",",
"from_bounds",
"=",
"None",
",",
"copy_if_changed",
"=",
"True",
",",
"copy_always",
"=",
"False",
",",
"repair",
"=",
"None",
",",
"archive",
"=",
"None",
")",
":",
"if",
"from_bounds",
"is",
"None",
":",
"... | maps the phenotypic input argument into the genotypic space,
that is, computes essentially the inverse of ``pheno``.
By default a copy is made only to prevent to modify ``y``.
The inverse of the user-defined transformation (if any)
is only needed if external solutions are injected, it ... | [
"maps",
"the",
"phenotypic",
"input",
"argument",
"into",
"the",
"genotypic",
"space",
"that",
"is",
"computes",
"essentially",
"the",
"inverse",
"of",
"pheno",
"."
] | python | train | 35.585366 |
saltstack/salt | salt/grains/core.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/core.py#L2847-L2869 | def kernelparams():
'''
Return the kernel boot parameters
'''
if salt.utils.platform.is_windows():
# TODO: add grains using `bcdedit /enum {current}`
return {}
else:
try:
with salt.utils.files.fopen('/proc/cmdline', 'r') as fhr:
cmdline = fhr.read(... | [
"def",
"kernelparams",
"(",
")",
":",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
":",
"# TODO: add grains using `bcdedit /enum {current}`",
"return",
"{",
"}",
"else",
":",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files"... | Return the kernel boot parameters | [
"Return",
"the",
"kernel",
"boot",
"parameters"
] | python | train | 33.521739 |
spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/arrayeditor.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/arrayeditor.py#L472-L481 | def setup_menu(self):
"""Setup context menu"""
self.copy_action = create_action(self, _('Copy'),
shortcut=keybinding('Copy'),
icon=ima.icon('editcopy'),
triggered=self.copy,
... | [
"def",
"setup_menu",
"(",
"self",
")",
":",
"self",
".",
"copy_action",
"=",
"create_action",
"(",
"self",
",",
"_",
"(",
"'Copy'",
")",
",",
"shortcut",
"=",
"keybinding",
"(",
"'Copy'",
")",
",",
"icon",
"=",
"ima",
".",
"icon",
"(",
"'editcopy'",
... | Setup context menu | [
"Setup",
"context",
"menu"
] | python | train | 47.5 |
edx/edx-val | edxval/api.py | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L322-L332 | def get_video_transcript_url(video_id, language_code):
"""
Returns course video transcript url or None if no transcript
Arguments:
video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component.
language_code: language code of a video transcript
... | [
"def",
"get_video_transcript_url",
"(",
"video_id",
",",
"language_code",
")",
":",
"video_transcript",
"=",
"VideoTranscript",
".",
"get_or_none",
"(",
"video_id",
",",
"language_code",
")",
"if",
"video_transcript",
":",
"return",
"video_transcript",
".",
"url",
"... | Returns course video transcript url or None if no transcript
Arguments:
video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component.
language_code: language code of a video transcript | [
"Returns",
"course",
"video",
"transcript",
"url",
"or",
"None",
"if",
"no",
"transcript"
] | python | train | 41.363636 |
mar10/wsgidav | wsgidav/prop_man/couch_property_manager.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/prop_man/couch_property_manager.py#L115-L124 | def _find(self, url):
"""Return properties document for path."""
# Query the permanent view to find a url
vr = self.db.view("properties/by_url", key=url, include_docs=True)
_logger.debug("find(%r) returned %s" % (url, len(vr)))
assert len(vr) <= 1, "Found multiple matches for %r"... | [
"def",
"_find",
"(",
"self",
",",
"url",
")",
":",
"# Query the permanent view to find a url",
"vr",
"=",
"self",
".",
"db",
".",
"view",
"(",
"\"properties/by_url\"",
",",
"key",
"=",
"url",
",",
"include_docs",
"=",
"True",
")",
"_logger",
".",
"debug",
... | Return properties document for path. | [
"Return",
"properties",
"document",
"for",
"path",
"."
] | python | valid | 41.4 |
rollbar/pyrollbar | rollbar/__init__.py | https://github.com/rollbar/pyrollbar/blob/33ef2e723a33d09dd6302f978f4a3908be95b9d2/rollbar/__init__.py#L291-L370 | def init(access_token, environment='production', scrub_fields=None, url_fields=None, **kw):
"""
Saves configuration variables in this module's SETTINGS.
access_token: project access token. Get this from the Rollbar UI:
- click "Settings" in the top nav
- click "Projects"... | [
"def",
"init",
"(",
"access_token",
",",
"environment",
"=",
"'production'",
",",
"scrub_fields",
"=",
"None",
",",
"url_fields",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"global",
"SETTINGS",
",",
"agent_log",
",",
"_initialized",
",",
"_transforms",
"... | Saves configuration variables in this module's SETTINGS.
access_token: project access token. Get this from the Rollbar UI:
- click "Settings" in the top nav
- click "Projects" in the left nav
- copy-paste the appropriate token.
environment: environment name... | [
"Saves",
"configuration",
"variables",
"in",
"this",
"module",
"s",
"SETTINGS",
"."
] | python | test | 43.5875 |
apache/incubator-mxnet | python/mxnet/optimizer/optimizer.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L347-L382 | def set_wd_mult(self, args_wd_mult):
"""Sets an individual weight decay multiplier for each parameter.
By default, if `param_idx2name` was provided in the
constructor, the weight decay multipler is set as 0 for all
parameters whose name don't end with ``_weight`` or
``_gamma``.
... | [
"def",
"set_wd_mult",
"(",
"self",
",",
"args_wd_mult",
")",
":",
"self",
".",
"wd_mult",
"=",
"{",
"}",
"for",
"n",
"in",
"self",
".",
"idx2name",
".",
"values",
"(",
")",
":",
"if",
"not",
"(",
"n",
".",
"endswith",
"(",
"'_weight'",
")",
"or",
... | Sets an individual weight decay multiplier for each parameter.
By default, if `param_idx2name` was provided in the
constructor, the weight decay multipler is set as 0 for all
parameters whose name don't end with ``_weight`` or
``_gamma``.
.. note:: The default weight decay mult... | [
"Sets",
"an",
"individual",
"weight",
"decay",
"multiplier",
"for",
"each",
"parameter",
"."
] | python | train | 46.944444 |
mitsei/dlkit | dlkit/records/assessment/qti/numeric_response_records.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/qti/numeric_response_records.py#L390-L429 | def _init_metadata(self):
"""stub"""
super(CalculationInteractionQuestionFormRecord, self)._init_metadata()
QuestionTextFormRecord._init_metadata(self)
QuestionFilesFormRecord._init_metadata(self)
self._variables_metadata = {
'element_id': Id(self.my_osid_object_form.... | [
"def",
"_init_metadata",
"(",
"self",
")",
":",
"super",
"(",
"CalculationInteractionQuestionFormRecord",
",",
"self",
")",
".",
"_init_metadata",
"(",
")",
"QuestionTextFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"QuestionFilesFormRecord",
".",
"_init_metad... | stub | [
"stub"
] | python | train | 39.25 |
rackerlabs/rackspace-python-neutronclient | neutronclient/v2_0/client.py | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L1104-L1107 | def list_lbaas_loadbalancers(self, retrieve_all=True, **_params):
"""Fetches a list of all lbaas_loadbalancers for a project."""
return self.list('loadbalancers', self.lbaas_loadbalancers_path,
retrieve_all, **_params) | [
"def",
"list_lbaas_loadbalancers",
"(",
"self",
",",
"retrieve_all",
"=",
"True",
",",
"*",
"*",
"_params",
")",
":",
"return",
"self",
".",
"list",
"(",
"'loadbalancers'",
",",
"self",
".",
"lbaas_loadbalancers_path",
",",
"retrieve_all",
",",
"*",
"*",
"_p... | Fetches a list of all lbaas_loadbalancers for a project. | [
"Fetches",
"a",
"list",
"of",
"all",
"lbaas_loadbalancers",
"for",
"a",
"project",
"."
] | python | train | 64 |
bitesofcode/projex | projex/addon.py | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/addon.py#L42-L62 | def addonModules(cls, recurse=True):
"""
Returns all the modules that this addon class uses to load plugins
from.
:param recurse | <bool>
:return [<str> || <module>, ..]
"""
prop = '_{0}__addon_modules'.format(cls.__name__)
out =... | [
"def",
"addonModules",
"(",
"cls",
",",
"recurse",
"=",
"True",
")",
":",
"prop",
"=",
"'_{0}__addon_modules'",
".",
"format",
"(",
"cls",
".",
"__name__",
")",
"out",
"=",
"set",
"(",
")",
"# lookup base classes",
"if",
"recurse",
":",
"for",
"base",
"i... | Returns all the modules that this addon class uses to load plugins
from.
:param recurse | <bool>
:return [<str> || <module>, ..] | [
"Returns",
"all",
"the",
"modules",
"that",
"this",
"addon",
"class",
"uses",
"to",
"load",
"plugins",
"from",
".",
":",
"param",
"recurse",
"|",
"<bool",
">",
":",
"return",
"[",
"<str",
">",
"||",
"<module",
">",
"..",
"]"
] | python | train | 29.952381 |
ladybug-tools/ladybug | ladybug/epw.py | https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/epw.py#L328-L337 | def annual_heating_design_day_996(self):
"""A design day object representing the annual 99.6% heating design day."""
self._load_header_check()
if bool(self._heating_dict) is True:
avg_press = self.atmospheric_station_pressure.average
avg_press = None if avg_press == 99999... | [
"def",
"annual_heating_design_day_996",
"(",
"self",
")",
":",
"self",
".",
"_load_header_check",
"(",
")",
"if",
"bool",
"(",
"self",
".",
"_heating_dict",
")",
"is",
"True",
":",
"avg_press",
"=",
"self",
".",
"atmospheric_station_pressure",
".",
"average",
... | A design day object representing the annual 99.6% heating design day. | [
"A",
"design",
"day",
"object",
"representing",
"the",
"annual",
"99",
".",
"6%",
"heating",
"design",
"day",
"."
] | python | train | 48.9 |
websauna/pyramid_notebook | pyramid_notebook/startup.py | https://github.com/websauna/pyramid_notebook/blob/8a7ecfa0259810de1a818e4b415a62811a7b077a/pyramid_notebook/startup.py#L88-L104 | def include_sqlalchemy_models(nc, Base):
"""Include all SQLAlchemy models in the script context.
:param nc: notebook_context dictionary
:param Base: SQLAlchemy model Base class from where the all models inherit.
"""
from sqlalchemy.ext.declarative.clsregistry import _ModuleMarker
# Include al... | [
"def",
"include_sqlalchemy_models",
"(",
"nc",
",",
"Base",
")",
":",
"from",
"sqlalchemy",
".",
"ext",
".",
"declarative",
".",
"clsregistry",
"import",
"_ModuleMarker",
"# Include all SQLAlchemy models in the local namespace",
"for",
"name",
",",
"klass",
"in",
"Bas... | Include all SQLAlchemy models in the script context.
:param nc: notebook_context dictionary
:param Base: SQLAlchemy model Base class from where the all models inherit. | [
"Include",
"all",
"SQLAlchemy",
"models",
"in",
"the",
"script",
"context",
"."
] | python | train | 37.588235 |
materialsproject/pymatgen | pymatgen/transformations/site_transformations.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/transformations/site_transformations.py#L434-L496 | def apply_transformation(self, structure, return_ranked_list=False):
"""
Apply the transformation.
Args:
structure: input structure
return_ranked_list (bool): Whether or not multiple structures are
returned. If return_ranked_list is a number, that number ... | [
"def",
"apply_transformation",
"(",
"self",
",",
"structure",
",",
"return_ranked_list",
"=",
"False",
")",
":",
"num_remove_dict",
"=",
"{",
"}",
"total_combis",
"=",
"0",
"for",
"indices",
",",
"frac",
"in",
"zip",
"(",
"self",
".",
"indices",
",",
"self... | Apply the transformation.
Args:
structure: input structure
return_ranked_list (bool): Whether or not multiple structures are
returned. If return_ranked_list is a number, that number of
structures is returned.
Returns:
Depending on ret... | [
"Apply",
"the",
"transformation",
"."
] | python | train | 46.968254 |
brocade/pynos | pynos/versions/base/yang/ietf_netconf.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/ietf_netconf.py#L27-L40 | def get_config_input_source_config_source_running_running(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_config = ET.Element("get_config")
config = get_config
input = ET.SubElement(get_config, "input")
source = ET.SubElement(input, "... | [
"def",
"get_config_input_source_config_source_running_running",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_config",
"=",
"ET",
".",
"Element",
"(",
"\"get_config\"",
")",
"config",
"=",
"ge... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 41.357143 |
pytroll/pyorbital | pyorbital/tlefile.py | https://github.com/pytroll/pyorbital/blob/647007934dc827a4c698629cf32a84a5167844b2/pyorbital/tlefile.py#L162-L173 | def _checksum(self):
"""Performs the checksum for the current TLE."""
for line in [self._line1, self._line2]:
check = 0
for char in line[:-1]:
if char.isdigit():
check += int(char)
if char == "-":
check += 1
... | [
"def",
"_checksum",
"(",
"self",
")",
":",
"for",
"line",
"in",
"[",
"self",
".",
"_line1",
",",
"self",
".",
"_line2",
"]",
":",
"check",
"=",
"0",
"for",
"char",
"in",
"line",
"[",
":",
"-",
"1",
"]",
":",
"if",
"char",
".",
"isdigit",
"(",
... | Performs the checksum for the current TLE. | [
"Performs",
"the",
"checksum",
"for",
"the",
"current",
"TLE",
"."
] | python | train | 35 |
google/openhtf | openhtf/output/servers/pub_sub.py | https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/servers/pub_sub.py#L43-L55 | def publish(cls, message, client_filter=None):
"""Publish messages to subscribers.
Args:
message: The message to publish.
client_filter: A filter function to call passing in each client. Only
clients for whom the function returns True will have the
message ... | [
"def",
"publish",
"(",
"cls",
",",
"message",
",",
"client_filter",
"=",
"None",
")",
":",
"with",
"cls",
".",
"_lock",
":",
"for",
"client",
"in",
"cls",
".",
"subscribers",
":",
"if",
"(",
"not",
"client_filter",
")",
"or",
"client_filter",
"(",
"cli... | Publish messages to subscribers.
Args:
message: The message to publish.
client_filter: A filter function to call passing in each client. Only
clients for whom the function returns True will have the
message sent to them. | [
"Publish",
"messages",
"to",
"subscribers",
"."
] | python | train | 36.461538 |
PyFilesystem/pyfilesystem2 | fs/iotools.py | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/iotools.py#L153-L204 | def make_stream(
name, # type: Text
bin_file, # type: RawIOBase
mode="r", # type: Text
buffering=-1, # type: int
encoding=None, # type: Optional[Text]
errors=None, # type: Optional[Text]
newline="", # type: Optional[Text]
line_buffering=False, # type: bool
**kwargs # type: A... | [
"def",
"make_stream",
"(",
"name",
",",
"# type: Text",
"bin_file",
",",
"# type: RawIOBase",
"mode",
"=",
"\"r\"",
",",
"# type: Text",
"buffering",
"=",
"-",
"1",
",",
"# type: int",
"encoding",
"=",
"None",
",",
"# type: Optional[Text]",
"errors",
"=",
"None"... | Take a Python 2.x binary file and return an IO Stream. | [
"Take",
"a",
"Python",
"2",
".",
"x",
"binary",
"file",
"and",
"return",
"an",
"IO",
"Stream",
"."
] | python | train | 29.288462 |
bykof/billomapy | billomapy/billomapy.py | https://github.com/bykof/billomapy/blob/a28ba69fd37654fa145d0411d52c200e7f8984ab/billomapy/billomapy.py#L3401-L3413 | def update_reminder_item(self, reminder_item_id, reminder_item_dict):
"""
Updates a reminder item
:param reminder_item_id: the reminder item id
:param reminder_item_dict: dict
:return: dict
"""
return self._create_put_request(
resource=REMINDER_ITEMS,... | [
"def",
"update_reminder_item",
"(",
"self",
",",
"reminder_item_id",
",",
"reminder_item_dict",
")",
":",
"return",
"self",
".",
"_create_put_request",
"(",
"resource",
"=",
"REMINDER_ITEMS",
",",
"billomat_id",
"=",
"reminder_item_id",
",",
"send_data",
"=",
"remin... | Updates a reminder item
:param reminder_item_id: the reminder item id
:param reminder_item_dict: dict
:return: dict | [
"Updates",
"a",
"reminder",
"item"
] | python | train | 30.846154 |
juju/charm-helpers | charmhelpers/contrib/openstack/amulet/utils.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L674-L682 | def create_flavor(self, nova, name, ram, vcpus, disk, flavorid="auto",
ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True):
"""Create the specified flavor."""
try:
nova.flavors.find(name=name)
except (exceptions.NotFound, exceptions.NoUniqueMatch):
... | [
"def",
"create_flavor",
"(",
"self",
",",
"nova",
",",
"name",
",",
"ram",
",",
"vcpus",
",",
"disk",
",",
"flavorid",
"=",
"\"auto\"",
",",
"ephemeral",
"=",
"0",
",",
"swap",
"=",
"0",
",",
"rxtx_factor",
"=",
"1.0",
",",
"is_public",
"=",
"True",
... | Create the specified flavor. | [
"Create",
"the",
"specified",
"flavor",
"."
] | python | train | 55.888889 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/core/profileapp.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/profileapp.py#L108-L117 | def list_bundled_profiles():
"""list profiles that are bundled with IPython."""
path = os.path.join(get_ipython_package_dir(), u'config', u'profile')
files = os.listdir(path)
profiles = []
for profile in files:
full_path = os.path.join(path, profile)
if os.path.isdir(full_path) and p... | [
"def",
"list_bundled_profiles",
"(",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"get_ipython_package_dir",
"(",
")",
",",
"u'config'",
",",
"u'profile'",
")",
"files",
"=",
"os",
".",
"listdir",
"(",
"path",
")",
"profiles",
"=",
"[",
... | list profiles that are bundled with IPython. | [
"list",
"profiles",
"that",
"are",
"bundled",
"with",
"IPython",
"."
] | python | test | 39.2 |
PmagPy/PmagPy | SPD/lib/lib_arai_plot_statistics.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_arai_plot_statistics.py#L297-L307 | def get_normed_points(point_array, norm): # good to go
"""
input: point_array, norm
output: normed array
"""
norm = float(norm)
#floated_array = []
#for p in point_array: # need to make sure each point is a float
#floated_array.append(float(p))
points = old_div(numpy.array(point_... | [
"def",
"get_normed_points",
"(",
"point_array",
",",
"norm",
")",
":",
"# good to go",
"norm",
"=",
"float",
"(",
"norm",
")",
"#floated_array = []",
"#for p in point_array: # need to make sure each point is a float",
"#floated_array.append(float(p))",
"points",
"=",
"old_div... | input: point_array, norm
output: normed array | [
"input",
":",
"point_array",
"norm",
"output",
":",
"normed",
"array"
] | python | train | 31 |
amueller/word_cloud | wordcloud/wordcloud.py | https://github.com/amueller/word_cloud/blob/d36f526e3d8346e6d7a2656631f05f68e402517d/wordcloud/wordcloud.py#L113-L147 | def get_single_color_func(color):
"""Create a color function which returns a single hue and saturation with.
different values (HSV). Accepted values are color strings as usable by
PIL/Pillow.
>>> color_func1 = get_single_color_func('deepskyblue')
>>> color_func2 = get_single_color_func('#00b4d2')
... | [
"def",
"get_single_color_func",
"(",
"color",
")",
":",
"old_r",
",",
"old_g",
",",
"old_b",
"=",
"ImageColor",
".",
"getrgb",
"(",
"color",
")",
"rgb_max",
"=",
"255.",
"h",
",",
"s",
",",
"v",
"=",
"colorsys",
".",
"rgb_to_hsv",
"(",
"old_r",
"/",
... | Create a color function which returns a single hue and saturation with.
different values (HSV). Accepted values are color strings as usable by
PIL/Pillow.
>>> color_func1 = get_single_color_func('deepskyblue')
>>> color_func2 = get_single_color_func('#00b4d2') | [
"Create",
"a",
"color",
"function",
"which",
"returns",
"a",
"single",
"hue",
"and",
"saturation",
"with",
".",
"different",
"values",
"(",
"HSV",
")",
".",
"Accepted",
"values",
"are",
"color",
"strings",
"as",
"usable",
"by",
"PIL",
"/",
"Pillow",
"."
] | python | train | 40 |
gboeing/osmnx | osmnx/plot.py | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L284-L444 | def plot_graph(G, bbox=None, fig_height=6, fig_width=None, margin=0.02,
axis_off=True, equal_aspect=False, bgcolor='w', show=True,
save=False, close=True, file_format='png', filename='temp',
dpi=300, annotate=False, node_color='#66ccff', node_size=15,
node_alp... | [
"def",
"plot_graph",
"(",
"G",
",",
"bbox",
"=",
"None",
",",
"fig_height",
"=",
"6",
",",
"fig_width",
"=",
"None",
",",
"margin",
"=",
"0.02",
",",
"axis_off",
"=",
"True",
",",
"equal_aspect",
"=",
"False",
",",
"bgcolor",
"=",
"'w'",
",",
"show",... | Plot a networkx spatial graph.
Parameters
----------
G : networkx multidigraph
bbox : tuple
bounding box as north,south,east,west - if None will calculate from
spatial extents of data. if passing a bbox, you probably also want to
pass margin=0 to constrain it.
fig_height : i... | [
"Plot",
"a",
"networkx",
"spatial",
"graph",
"."
] | python | train | 36.496894 |
gbiggs/rtctree | rtctree/component.py | https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/component.py#L783-L797 | def participating_ec_states(self):
'''The state of each execution context this component is participating
in.
'''
with self._mutex:
if not self._participating_ec_states:
if self.participating_ecs:
states = []
for ec in ... | [
"def",
"participating_ec_states",
"(",
"self",
")",
":",
"with",
"self",
".",
"_mutex",
":",
"if",
"not",
"self",
".",
"_participating_ec_states",
":",
"if",
"self",
".",
"participating_ecs",
":",
"states",
"=",
"[",
"]",
"for",
"ec",
"in",
"self",
".",
... | The state of each execution context this component is participating
in. | [
"The",
"state",
"of",
"each",
"execution",
"context",
"this",
"component",
"is",
"participating",
"in",
"."
] | python | train | 38.133333 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiVrf.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiVrf.py#L66-L75 | def delete(self, ids):
"""
Method to delete vrf's by their id's
:param ids: Identifiers of vrf's
:return: None
"""
url = build_uri_with_ids('api/v3/vrf/%s/', ids)
return super(ApiVrf, self).delete(url) | [
"def",
"delete",
"(",
"self",
",",
"ids",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v3/vrf/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiVrf",
",",
"self",
")",
".",
"delete",
"(",
"url",
")"
] | Method to delete vrf's by their id's
:param ids: Identifiers of vrf's
:return: None | [
"Method",
"to",
"delete",
"vrf",
"s",
"by",
"their",
"id",
"s"
] | python | train | 25 |
ahmontero/dop | dop/client.py | https://github.com/ahmontero/dop/blob/40354ac6feefe92a7555fe2d1834138c9a03e518/dop/client.py#L576-L597 | def add_ssh_key(self, name, ssh_pub_key):
"""
This method allows you to add a new public SSH key to your account.
Required parameters
name:
String, the name you want to give this SSH key.
ssh_pub_key:
String, the actual public SSH key.
... | [
"def",
"add_ssh_key",
"(",
"self",
",",
"name",
",",
"ssh_pub_key",
")",
":",
"params",
"=",
"{",
"'name'",
":",
"name",
",",
"'ssh_pub_key'",
":",
"ssh_pub_key",
"}",
"json",
"=",
"self",
".",
"request",
"(",
"'/ssh_keys/new'",
",",
"method",
"=",
"'GET... | This method allows you to add a new public SSH key to your account.
Required parameters
name:
String, the name you want to give this SSH key.
ssh_pub_key:
String, the actual public SSH key. | [
"This",
"method",
"allows",
"you",
"to",
"add",
"a",
"new",
"public",
"SSH",
"key",
"to",
"your",
"account",
"."
] | python | train | 34.181818 |
django-haystack/pysolr | pysolr.py | https://github.com/django-haystack/pysolr/blob/ee28b39324fa21a99842d297e313c1759d8adbd2/pysolr.py#L505-L529 | def _extract_error(self, resp):
"""
Extract the actual error message from a solr response.
"""
reason = resp.headers.get('reason', None)
full_response = None
if reason is None:
try:
# if response is in json format
reason = resp... | [
"def",
"_extract_error",
"(",
"self",
",",
"resp",
")",
":",
"reason",
"=",
"resp",
".",
"headers",
".",
"get",
"(",
"'reason'",
",",
"None",
")",
"full_response",
"=",
"None",
"if",
"reason",
"is",
"None",
":",
"try",
":",
"# if response is in json format... | Extract the actual error message from a solr response. | [
"Extract",
"the",
"actual",
"error",
"message",
"from",
"a",
"solr",
"response",
"."
] | python | train | 32.16 |
google/apitools | apitools/base/py/base_api.py | https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/base_api.py#L511-L522 | def __CombineGlobalParams(self, global_params, default_params):
"""Combine the given params with the defaults."""
util.Typecheck(global_params, (type(None), self.__client.params_type))
result = self.__client.params_type()
global_params = global_params or self.__client.params_type()
... | [
"def",
"__CombineGlobalParams",
"(",
"self",
",",
"global_params",
",",
"default_params",
")",
":",
"util",
".",
"Typecheck",
"(",
"global_params",
",",
"(",
"type",
"(",
"None",
")",
",",
"self",
".",
"__client",
".",
"params_type",
")",
")",
"result",
"=... | Combine the given params with the defaults. | [
"Combine",
"the",
"given",
"params",
"with",
"the",
"defaults",
"."
] | python | train | 52.25 |
kwikteam/phy | phy/cluster/views/trace.py | https://github.com/kwikteam/phy/blob/7e9313dc364304b7d2bd03b92938347343703003/phy/cluster/views/trace.py#L419-L423 | def narrow(self):
"""Decrease the interval size."""
t, h = self.time, self.half_duration
h /= self.scaling_coeff_x
self.set_interval((t - h, t + h)) | [
"def",
"narrow",
"(",
"self",
")",
":",
"t",
",",
"h",
"=",
"self",
".",
"time",
",",
"self",
".",
"half_duration",
"h",
"/=",
"self",
".",
"scaling_coeff_x",
"self",
".",
"set_interval",
"(",
"(",
"t",
"-",
"h",
",",
"t",
"+",
"h",
")",
")"
] | Decrease the interval size. | [
"Decrease",
"the",
"interval",
"size",
"."
] | python | train | 35.2 |
twilio/twilio-python | twilio/rest/api/v2010/account/message/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/message/__init__.py#L269-L278 | def get_instance(self, payload):
"""
Build an instance of MessageInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.api.v2010.account.message.MessageInstance
:rtype: twilio.rest.api.v2010.account.message.MessageInstance
"""
return ... | [
"def",
"get_instance",
"(",
"self",
",",
"payload",
")",
":",
"return",
"MessageInstance",
"(",
"self",
".",
"_version",
",",
"payload",
",",
"account_sid",
"=",
"self",
".",
"_solution",
"[",
"'account_sid'",
"]",
",",
")"
] | Build an instance of MessageInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.api.v2010.account.message.MessageInstance
:rtype: twilio.rest.api.v2010.account.message.MessageInstance | [
"Build",
"an",
"instance",
"of",
"MessageInstance"
] | python | train | 39.5 |
SiLab-Bonn/pyBAR | pybar/fei4/register_utils.py | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L264-L313 | def read_chip_sn(self):
'''Reading Chip S/N
Note
----
Bits [MSB-LSB] | [15] | [14-6] | [5-0]
Content | reserved | wafer number | chip number
'''
commands = []
commands.extend(self.register.get_commands("ConfMode"))
self.register_utils.send_commands(com... | [
"def",
"read_chip_sn",
"(",
"self",
")",
":",
"commands",
"=",
"[",
"]",
"commands",
".",
"extend",
"(",
"self",
".",
"register",
".",
"get_commands",
"(",
"\"ConfMode\"",
")",
")",
"self",
".",
"register_utils",
".",
"send_commands",
"(",
"commands",
")",... | Reading Chip S/N
Note
----
Bits [MSB-LSB] | [15] | [14-6] | [5-0]
Content | reserved | wafer number | chip number | [
"Reading",
"Chip",
"S",
"/",
"N",
"Note",
"----",
"Bits",
"[",
"MSB",
"-",
"LSB",
"]",
"|",
"[",
"15",
"]",
"|",
"[",
"14",
"-",
"6",
"]",
"|",
"[",
"5",
"-",
"0",
"]",
"Content",
"|",
"reserved",
"|",
"wafer",
"number",
"|",
"chip",
"number"... | python | train | 44.58 |
caseyjlaw/activegit | activegit/activegit.py | https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L153-L157 | def classifier(self):
""" Returns classifier from classifier.pkl """
clf = pickle.load(open(os.path.join(self.repopath, 'classifier.pkl')))
return clf | [
"def",
"classifier",
"(",
"self",
")",
":",
"clf",
"=",
"pickle",
".",
"load",
"(",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"repopath",
",",
"'classifier.pkl'",
")",
")",
")",
"return",
"clf"
] | Returns classifier from classifier.pkl | [
"Returns",
"classifier",
"from",
"classifier",
".",
"pkl"
] | python | train | 35.8 |
ShadowBlip/Neteria | neteria/core.py | https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/core.py#L218-L242 | def listen_loop(self):
"""Starts the listen loop and executes the receieve_datagram method
whenever a packet is receieved.
Args:
None
Returns:
None
"""
while self.listening:
try:
data, address = self.sock.recvfrom(self.b... | [
"def",
"listen_loop",
"(",
"self",
")",
":",
"while",
"self",
".",
"listening",
":",
"try",
":",
"data",
",",
"address",
"=",
"self",
".",
"sock",
".",
"recvfrom",
"(",
"self",
".",
"bufsize",
")",
"self",
".",
"receive_datagram",
"(",
"data",
",",
"... | Starts the listen loop and executes the receieve_datagram method
whenever a packet is receieved.
Args:
None
Returns:
None | [
"Starts",
"the",
"listen",
"loop",
"and",
"executes",
"the",
"receieve_datagram",
"method",
"whenever",
"a",
"packet",
"is",
"receieved",
"."
] | python | train | 28.32 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.