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 |
|---|---|---|---|---|---|---|---|---|---|
atlassian-api/atlassian-python-api | atlassian/jira.py | https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/jira.py#L1167-L1174 | def delete_agile_board(self, board_id):
"""
Delete agile board by id
:param board_id:
:return:
"""
url = 'rest/agile/1.0/board/{}'.format(str(board_id))
return self.delete(url) | [
"def",
"delete_agile_board",
"(",
"self",
",",
"board_id",
")",
":",
"url",
"=",
"'rest/agile/1.0/board/{}'",
".",
"format",
"(",
"str",
"(",
"board_id",
")",
")",
"return",
"self",
".",
"delete",
"(",
"url",
")"
] | Delete agile board by id
:param board_id:
:return: | [
"Delete",
"agile",
"board",
"by",
"id",
":",
"param",
"board_id",
":",
":",
"return",
":"
] | python | train | 28.125 |
sassoftware/sas_kernel | sas_kernel/kernel.py | https://github.com/sassoftware/sas_kernel/blob/ed63dceb9d1d51157b465f4892ffb793c1c32307/sas_kernel/kernel.py#L131-L179 | def do_execute_direct(self, code: str, silent: bool = False) -> [str, dict]:
"""
This is the main method that takes code from the Jupyter cell and submits it to the SAS server
:param code: code from the cell
:param silent:
:return: str with either the log or list
"""
... | [
"def",
"do_execute_direct",
"(",
"self",
",",
"code",
":",
"str",
",",
"silent",
":",
"bool",
"=",
"False",
")",
"->",
"[",
"str",
",",
"dict",
"]",
":",
"if",
"not",
"code",
".",
"strip",
"(",
")",
":",
"return",
"{",
"'status'",
":",
"'ok'",
",... | This is the main method that takes code from the Jupyter cell and submits it to the SAS server
:param code: code from the cell
:param silent:
:return: str with either the log or list | [
"This",
"is",
"the",
"main",
"method",
"that",
"takes",
"code",
"from",
"the",
"Jupyter",
"cell",
"and",
"submits",
"it",
"to",
"the",
"SAS",
"server"
] | python | train | 43.734694 |
internetarchive/doublethink | doublethink/services.py | https://github.com/internetarchive/doublethink/blob/f7fc7da725c9b572d473c717b3dad9af98a7a2b4/doublethink/services.py#L163-L173 | def unregister(self, id):
'''
Remove the service with id `id` from the service registry.
'''
result = self.rr.table(self.table).get(id).delete().run()
if result != {
'deleted':1, 'errors':0,'inserted':0,
'replaced':0,'skipped':0,'unchanged':0}:
... | [
"def",
"unregister",
"(",
"self",
",",
"id",
")",
":",
"result",
"=",
"self",
".",
"rr",
".",
"table",
"(",
"self",
".",
"table",
")",
".",
"get",
"(",
"id",
")",
".",
"delete",
"(",
")",
".",
"run",
"(",
")",
"if",
"result",
"!=",
"{",
"'del... | Remove the service with id `id` from the service registry. | [
"Remove",
"the",
"service",
"with",
"id",
"id",
"from",
"the",
"service",
"registry",
"."
] | python | train | 43 |
RedFantom/ttkwidgets | ttkwidgets/timeline.py | https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/timeline.py#L817-L824 | def _left_click(self, event):
"""Function bound to left click event for marker canvas"""
self.update_active()
iid = self.current_iid
if iid is None:
return
args = (iid, event.x_root, event.y_root)
self.call_callbacks(iid, "left_callback", args) | [
"def",
"_left_click",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"update_active",
"(",
")",
"iid",
"=",
"self",
".",
"current_iid",
"if",
"iid",
"is",
"None",
":",
"return",
"args",
"=",
"(",
"iid",
",",
"event",
".",
"x_root",
",",
"event",
... | Function bound to left click event for marker canvas | [
"Function",
"bound",
"to",
"left",
"click",
"event",
"for",
"marker",
"canvas"
] | python | train | 37.125 |
cloudtools/stacker | stacker/actions/build.py | https://github.com/cloudtools/stacker/blob/ad6013a03a560c46ba3c63c4d153336273e6da5d/stacker/actions/build.py#L62-L76 | def should_submit(stack):
"""Tests whether a stack should be submitted to CF for update/create
Args:
stack (:class:`stacker.stack.Stack`): The stack object to check.
Returns:
bool: If the stack should be submitted, return True.
"""
if stack.enabled:
return True
logger... | [
"def",
"should_submit",
"(",
"stack",
")",
":",
"if",
"stack",
".",
"enabled",
":",
"return",
"True",
"logger",
".",
"debug",
"(",
"\"Stack %s is not enabled. Skipping.\"",
",",
"stack",
".",
"name",
")",
"return",
"False"
] | Tests whether a stack should be submitted to CF for update/create
Args:
stack (:class:`stacker.stack.Stack`): The stack object to check.
Returns:
bool: If the stack should be submitted, return True. | [
"Tests",
"whether",
"a",
"stack",
"should",
"be",
"submitted",
"to",
"CF",
"for",
"update",
"/",
"create"
] | python | train | 25.333333 |
SuperCowPowers/workbench | workbench/server/els_indexer.py | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/els_indexer.py#L29-L50 | def index_data(self, data, index_name, doc_type):
"""Take an arbitrary dictionary of data and index it with ELS.
Args:
data: data to be Indexed. Should be a dictionary.
index_name: Name of the index.
doc_type: The type of the document.
Raises:
Ru... | [
"def",
"index_data",
"(",
"self",
",",
"data",
",",
"index_name",
",",
"doc_type",
")",
":",
"# Index the data (which needs to be a dict/object) if it's not",
"# we're going to toss an exception",
"if",
"not",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"raise",
... | Take an arbitrary dictionary of data and index it with ELS.
Args:
data: data to be Indexed. Should be a dictionary.
index_name: Name of the index.
doc_type: The type of the document.
Raises:
RuntimeError: When the Indexing fails. | [
"Take",
"an",
"arbitrary",
"dictionary",
"of",
"data",
"and",
"index",
"it",
"with",
"ELS",
"."
] | python | train | 37.136364 |
rocky/python3-trepan | trepan/processor/parse/scanner.py | https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/processor/parse/scanner.py#L107-L111 | def t_direction(self, s):
r'^[+-]$'
# Used in the "list" command
self.add_token('DIRECTION', s)
self.pos += len(s) | [
"def",
"t_direction",
"(",
"self",
",",
"s",
")",
":",
"# Used in the \"list\" command",
"self",
".",
"add_token",
"(",
"'DIRECTION'",
",",
"s",
")",
"self",
".",
"pos",
"+=",
"len",
"(",
"s",
")"
] | r'^[+-]$ | [
"r",
"^",
"[",
"+",
"-",
"]",
"$"
] | python | test | 28.4 |
darothen/xbpch | xbpch/uff.py | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L110-L123 | def skipline(self):
"""
Skip the next line and returns position and size of line.
Raises IOError if pre- and suffix of line do not match.
"""
position = self.tell()
prefix = self._fix()
self.seek(prefix, 1) # skip content
suffix = self._fix()
if ... | [
"def",
"skipline",
"(",
"self",
")",
":",
"position",
"=",
"self",
".",
"tell",
"(",
")",
"prefix",
"=",
"self",
".",
"_fix",
"(",
")",
"self",
".",
"seek",
"(",
"prefix",
",",
"1",
")",
"# skip content",
"suffix",
"=",
"self",
".",
"_fix",
"(",
... | Skip the next line and returns position and size of line.
Raises IOError if pre- and suffix of line do not match. | [
"Skip",
"the",
"next",
"line",
"and",
"returns",
"position",
"and",
"size",
"of",
"line",
".",
"Raises",
"IOError",
"if",
"pre",
"-",
"and",
"suffix",
"of",
"line",
"do",
"not",
"match",
"."
] | python | train | 28.214286 |
deepmipt/DeepPavlov | deeppavlov/metrics/accuracy.py | https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/metrics/accuracy.py#L24-L37 | def accuracy(y_true: [list, np.ndarray], y_predicted: [list, np.ndarray]) -> float:
"""
Calculate accuracy in terms of absolute coincidence
Args:
y_true: array of true values
y_predicted: array of predicted values
Returns:
portion of absolutely coincidental samples
"""
... | [
"def",
"accuracy",
"(",
"y_true",
":",
"[",
"list",
",",
"np",
".",
"ndarray",
"]",
",",
"y_predicted",
":",
"[",
"list",
",",
"np",
".",
"ndarray",
"]",
")",
"->",
"float",
":",
"examples_len",
"=",
"len",
"(",
"y_true",
")",
"correct",
"=",
"sum"... | Calculate accuracy in terms of absolute coincidence
Args:
y_true: array of true values
y_predicted: array of predicted values
Returns:
portion of absolutely coincidental samples | [
"Calculate",
"accuracy",
"in",
"terms",
"of",
"absolute",
"coincidence"
] | python | test | 32.785714 |
controversial/livejson | livejson.py | https://github.com/controversial/livejson/blob/91021de60903d2d8b2cfb7d8d8910bcf27ec003b/livejson.py#L214-L233 | def data(self, data):
"""Overwrite the file with new data. You probably shouldn't do
this yourself, it's easy to screw up your whole file with this."""
if self.is_caching:
self.cache = data
else:
fcontents = self.file_contents
with open(self.path, "w")... | [
"def",
"data",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"is_caching",
":",
"self",
".",
"cache",
"=",
"data",
"else",
":",
"fcontents",
"=",
"self",
".",
"file_contents",
"with",
"open",
"(",
"self",
".",
"path",
",",
"\"w\"",
")",
"a... | Overwrite the file with new data. You probably shouldn't do
this yourself, it's easy to screw up your whole file with this. | [
"Overwrite",
"the",
"file",
"with",
"new",
"data",
".",
"You",
"probably",
"shouldn",
"t",
"do",
"this",
"yourself",
"it",
"s",
"easy",
"to",
"screw",
"up",
"your",
"whole",
"file",
"with",
"this",
"."
] | python | valid | 42.55 |
apple/turicreate | src/unity/python/turicreate/toolkits/_decision_tree.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_decision_tree.py#L80-L123 | def get_decision(self, child, is_missing = False):
"""
Get the decision from this node to a child node.
Parameters
----------
child: Node
A child node of this node.
Returns
-------
dict: A dictionary that describes how to get from this node t... | [
"def",
"get_decision",
"(",
"self",
",",
"child",
",",
"is_missing",
"=",
"False",
")",
":",
"# Child does exist and there is a path to the child.",
"value",
"=",
"self",
".",
"value",
"feature",
"=",
"self",
".",
"split_feature_column",
"index",
"=",
"self",
".",... | Get the decision from this node to a child node.
Parameters
----------
child: Node
A child node of this node.
Returns
-------
dict: A dictionary that describes how to get from this node to the
child node. | [
"Get",
"the",
"decision",
"from",
"this",
"node",
"to",
"a",
"child",
"node",
"."
] | python | train | 28.727273 |
h2oai/h2o-3 | scripts/run.py | https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/scripts/run.py#L645-L651 | def get_port(self):
""" Return a port to use to talk to this cluster. """
if len(self.client_nodes) > 0:
node = self.client_nodes[0]
else:
node = self.nodes[0]
return node.get_port() | [
"def",
"get_port",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"client_nodes",
")",
">",
"0",
":",
"node",
"=",
"self",
".",
"client_nodes",
"[",
"0",
"]",
"else",
":",
"node",
"=",
"self",
".",
"nodes",
"[",
"0",
"]",
"return",
"node",... | Return a port to use to talk to this cluster. | [
"Return",
"a",
"port",
"to",
"use",
"to",
"talk",
"to",
"this",
"cluster",
"."
] | python | test | 33.142857 |
google/grr | grr/server/grr_response_server/databases/mem_clients.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L416-L419 | def CountClientPlatformReleasesByLabel(self, day_buckets):
"""Computes client-activity stats for OS-release strings in the DB."""
return self._CountClientStatisticByLabel(
day_buckets, lambda client_info: client_info.last_snapshot.Uname()) | [
"def",
"CountClientPlatformReleasesByLabel",
"(",
"self",
",",
"day_buckets",
")",
":",
"return",
"self",
".",
"_CountClientStatisticByLabel",
"(",
"day_buckets",
",",
"lambda",
"client_info",
":",
"client_info",
".",
"last_snapshot",
".",
"Uname",
"(",
")",
")"
] | Computes client-activity stats for OS-release strings in the DB. | [
"Computes",
"client",
"-",
"activity",
"stats",
"for",
"OS",
"-",
"release",
"strings",
"in",
"the",
"DB",
"."
] | python | train | 63 |
OpenTreeOfLife/peyotl | peyotl/git_storage/sharded_doc_store.py | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/sharded_doc_store.py#L38-L42 | def get_public_url(self, doc_id, branch='master'):
"""Returns a GitHub URL for the doc in question (study, collection, ...)
"""
name, path_frag = self.get_repo_and_path_fragment(doc_id)
return 'https://raw.githubusercontent.com/OpenTreeOfLife/' + name + '/' + branch + '/' + path_frag | [
"def",
"get_public_url",
"(",
"self",
",",
"doc_id",
",",
"branch",
"=",
"'master'",
")",
":",
"name",
",",
"path_frag",
"=",
"self",
".",
"get_repo_and_path_fragment",
"(",
"doc_id",
")",
"return",
"'https://raw.githubusercontent.com/OpenTreeOfLife/'",
"+",
"name",... | Returns a GitHub URL for the doc in question (study, collection, ...) | [
"Returns",
"a",
"GitHub",
"URL",
"for",
"the",
"doc",
"in",
"question",
"(",
"study",
"collection",
"...",
")"
] | python | train | 62.4 |
coghost/izen | izen/helper.py | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L708-L726 | def check_sum(buf, csum):
"""
检查数据的校验和
:param buf:
:type buf:
:param csum:
:type csum:
:return:
:rtype:
"""
csum = csum.encode('utf-8')
_csum = ord(buf[0])
for x in buf[1:]:
_csum ^= ord(x)
_csum = binascii.b2a_hex(chr(_csum).encode('utf-8')).upper()
if _... | [
"def",
"check_sum",
"(",
"buf",
",",
"csum",
")",
":",
"csum",
"=",
"csum",
".",
"encode",
"(",
"'utf-8'",
")",
"_csum",
"=",
"ord",
"(",
"buf",
"[",
"0",
"]",
")",
"for",
"x",
"in",
"buf",
"[",
"1",
":",
"]",
":",
"_csum",
"^=",
"ord",
"(",
... | 检查数据的校验和
:param buf:
:type buf:
:param csum:
:type csum:
:return:
:rtype: | [
"检查数据的校验和",
":",
"param",
"buf",
":",
":",
"type",
"buf",
":",
":",
"param",
"csum",
":",
":",
"type",
"csum",
":",
":",
"return",
":",
":",
"rtype",
":"
] | python | train | 21.894737 |
Drekin/win-unicode-console | win_unicode_console/raw_input.py | https://github.com/Drekin/win-unicode-console/blob/6beb5df5219ac1e5495b415d286e634a27720b2e/win_unicode_console/raw_input.py#L71-L100 | def raw_input(prompt=""):
"""raw_input([prompt]) -> string
Read a string from standard input. The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
On Unix, GNU readline is used if enabled. The prompt string, if given,
is printed without a trailing newline befo... | [
"def",
"raw_input",
"(",
"prompt",
"=",
"\"\"",
")",
":",
"sys",
".",
"stderr",
".",
"flush",
"(",
")",
"tty",
"=",
"STDIN",
".",
"is_a_TTY",
"(",
")",
"and",
"STDOUT",
".",
"is_a_TTY",
"(",
")",
"if",
"RETURN_UNICODE",
":",
"if",
"tty",
":",
"line... | raw_input([prompt]) -> string
Read a string from standard input. The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
On Unix, GNU readline is used if enabled. The prompt string, if given,
is printed without a trailing newline before reading. | [
"raw_input",
"(",
"[",
"prompt",
"]",
")",
"-",
">",
"string"
] | python | train | 24.233333 |
Laufire/ec | ec/modules/core.py | https://github.com/Laufire/ec/blob/63e84a1daef9234487d7de538e5da233a7d13071/ec/modules/core.py#L45-L74 | def execCommand(Argv, collect_missing):
r"""Executes the given task with parameters.
"""
try:
return _execCommand(Argv, collect_missing)
except Exception as e:
if Settings['errorHandler']:
Settings['errorHandler'](e)
if Settings['debug']:
# #ToDo: Have an option to debug throug... | [
"def",
"execCommand",
"(",
"Argv",
",",
"collect_missing",
")",
":",
"try",
":",
"return",
"_execCommand",
"(",
"Argv",
",",
"collect_missing",
")",
"except",
"Exception",
"as",
"e",
":",
"if",
"Settings",
"[",
"'errorHandler'",
"]",
":",
"Settings",
"[",
... | r"""Executes the given task with parameters. | [
"r",
"Executes",
"the",
"given",
"task",
"with",
"parameters",
"."
] | python | train | 32.8 |
bitesofcode/projexui | projexui/widgets/xchart/xchartscene.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchartscene.py#L27-L38 | def addDataset(self, dataset):
"""
Creates a new dataset instance for this scene.
:param dataset | <XChartDataset>
:return <XChartDatasetItem>
"""
item = XChartDatasetItem()
self.addItem(item)
item.setDataset(dataset)
... | [
"def",
"addDataset",
"(",
"self",
",",
"dataset",
")",
":",
"item",
"=",
"XChartDatasetItem",
"(",
")",
"self",
".",
"addItem",
"(",
"item",
")",
"item",
".",
"setDataset",
"(",
"dataset",
")",
"return",
"item"
] | Creates a new dataset instance for this scene.
:param dataset | <XChartDataset>
:return <XChartDatasetItem> | [
"Creates",
"a",
"new",
"dataset",
"instance",
"for",
"this",
"scene",
".",
":",
"param",
"dataset",
"|",
"<XChartDataset",
">",
":",
"return",
"<XChartDatasetItem",
">"
] | python | train | 27.333333 |
tensorflow/tensorboard | tensorboard/plugins/hparams/backend_context.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/hparams/backend_context.py#L152-L192 | def _compute_hparam_info_from_values(self, name, values):
"""Builds an HParamInfo message from the hparam name and list of values.
Args:
name: string. The hparam name.
values: list of google.protobuf.Value messages. The list of values for the
hparam.
Returns:
An api_pb2.HParamInf... | [
"def",
"_compute_hparam_info_from_values",
"(",
"self",
",",
"name",
",",
"values",
")",
":",
"# Figure out the type from the values.",
"# Ignore values whose type is not listed in api_pb2.DataType",
"# If all values have the same type, then that is the type used.",
"# Otherwise, the retur... | Builds an HParamInfo message from the hparam name and list of values.
Args:
name: string. The hparam name.
values: list of google.protobuf.Value messages. The list of values for the
hparam.
Returns:
An api_pb2.HParamInfo message. | [
"Builds",
"an",
"HParamInfo",
"message",
"from",
"the",
"hparam",
"name",
"and",
"list",
"of",
"values",
"."
] | python | train | 37.878049 |
fbcotter/py3nvml | py3nvml/py3nvml.py | https://github.com/fbcotter/py3nvml/blob/47f0f2c0eee56dec4e4beebec26b734e01d357b7/py3nvml/py3nvml.py#L4791-L4826 | def nvmlDeviceSetAccountingMode(handle, mode):
r"""
/**
* Enables or disables per process accounting.
*
* For Kepler &tm; or newer fully supported devices.
* Requires root/admin permissions.
*
* @note This setting is not persistent and will default to disabled after driver unloads.... | [
"def",
"nvmlDeviceSetAccountingMode",
"(",
"handle",
",",
"mode",
")",
":",
"fn",
"=",
"_nvmlGetFunctionPointer",
"(",
"\"nvmlDeviceSetAccountingMode\"",
")",
"ret",
"=",
"fn",
"(",
"handle",
",",
"_nvmlEnableState_t",
"(",
"mode",
")",
")",
"_nvmlCheckReturn",
"(... | r"""
/**
* Enables or disables per process accounting.
*
* For Kepler &tm; or newer fully supported devices.
* Requires root/admin permissions.
*
* @note This setting is not persistent and will default to disabled after driver unloads.
* Enable persistence mode to be sure th... | [
"r",
"/",
"**",
"*",
"Enables",
"or",
"disables",
"per",
"process",
"accounting",
".",
"*",
"*",
"For",
"Kepler",
"&tm",
";",
"or",
"newer",
"fully",
"supported",
"devices",
".",
"*",
"Requires",
"root",
"/",
"admin",
"permissions",
".",
"*",
"*"
] | python | train | 46.138889 |
scraperwiki/dumptruck | dumptruck/dumptruck.py | https://github.com/scraperwiki/dumptruck/blob/ac5855e34d4dffc7e53a13ff925ccabda19604fc/dumptruck/dumptruck.py#L329-L357 | def save_var(self, key, value, **kwargs):
'Save one variable to the database.'
# Check whether Highwall's variables table exists
self.__check_or_create_vars_table()
column_type = get_column_type(value)
tmp = quote(self.__vars_table_tmp)
self.execute(u'DROP TABLE IF EXISTS %s' % tmp, commit = ... | [
"def",
"save_var",
"(",
"self",
",",
"key",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"# Check whether Highwall's variables table exists",
"self",
".",
"__check_or_create_vars_table",
"(",
")",
"column_type",
"=",
"get_column_type",
"(",
"value",
")",
"tmp"... | Save one variable to the database. | [
"Save",
"one",
"variable",
"to",
"the",
"database",
"."
] | python | train | 29.551724 |
budacom/trading-bots | trading_bots/utils.py | https://github.com/budacom/trading-bots/blob/8cb68bb8d0b5f822108db1cc5dae336e3d3c3452/trading_bots/utils.py#L40-L42 | def truncate(value: Decimal, n_digits: int) -> Decimal:
"""Truncates a value to a number of decimals places"""
return Decimal(math.trunc(value * (10 ** n_digits))) / (10 ** n_digits) | [
"def",
"truncate",
"(",
"value",
":",
"Decimal",
",",
"n_digits",
":",
"int",
")",
"->",
"Decimal",
":",
"return",
"Decimal",
"(",
"math",
".",
"trunc",
"(",
"value",
"*",
"(",
"10",
"**",
"n_digits",
")",
")",
")",
"/",
"(",
"10",
"**",
"n_digits"... | Truncates a value to a number of decimals places | [
"Truncates",
"a",
"value",
"to",
"a",
"number",
"of",
"decimals",
"places"
] | python | train | 62.666667 |
atlassian-api/atlassian-python-api | atlassian/service_desk.py | https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/service_desk.py#L268-L280 | def create_organization(self, name):
"""
To create an organization Jira administrator global permission or agent permission is required
depending on the settings
:param name: str
:return: Organization data
"""
log.warning('Creating organization...')
url =... | [
"def",
"create_organization",
"(",
"self",
",",
"name",
")",
":",
"log",
".",
"warning",
"(",
"'Creating organization...'",
")",
"url",
"=",
"'rest/servicedeskapi/organization'",
"data",
"=",
"{",
"'name'",
":",
"name",
"}",
"return",
"self",
".",
"post",
"(",... | To create an organization Jira administrator global permission or agent permission is required
depending on the settings
:param name: str
:return: Organization data | [
"To",
"create",
"an",
"organization",
"Jira",
"administrator",
"global",
"permission",
"or",
"agent",
"permission",
"is",
"required",
"depending",
"on",
"the",
"settings"
] | python | train | 34.615385 |
BlueBrain/NeuroM | neurom/fst/_neuritefunc.py | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L69-L71 | def n_bifurcation_points(neurites, neurite_type=NeuriteType.all):
'''number of bifurcation points in a collection of neurites'''
return n_sections(neurites, neurite_type=neurite_type, iterator_type=Tree.ibifurcation_point) | [
"def",
"n_bifurcation_points",
"(",
"neurites",
",",
"neurite_type",
"=",
"NeuriteType",
".",
"all",
")",
":",
"return",
"n_sections",
"(",
"neurites",
",",
"neurite_type",
"=",
"neurite_type",
",",
"iterator_type",
"=",
"Tree",
".",
"ibifurcation_point",
")"
] | number of bifurcation points in a collection of neurites | [
"number",
"of",
"bifurcation",
"points",
"in",
"a",
"collection",
"of",
"neurites"
] | python | train | 76 |
janpipek/physt | physt/binnings.py | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L106-L120 | def is_consecutive(self, rtol: float = 1.e-5, atol: float = 1.e-8) -> bool:
"""Whether all bins are in a growing order.
Parameters
----------
rtol, atol : numpy tolerance parameters
"""
if self.inconsecutive_allowed:
if self._consecutive is None:
... | [
"def",
"is_consecutive",
"(",
"self",
",",
"rtol",
":",
"float",
"=",
"1.e-5",
",",
"atol",
":",
"float",
"=",
"1.e-8",
")",
"->",
"bool",
":",
"if",
"self",
".",
"inconsecutive_allowed",
":",
"if",
"self",
".",
"_consecutive",
"is",
"None",
":",
"if",... | Whether all bins are in a growing order.
Parameters
----------
rtol, atol : numpy tolerance parameters | [
"Whether",
"all",
"bins",
"are",
"in",
"a",
"growing",
"order",
"."
] | python | train | 35.733333 |
csaez/wishlib | wishlib/si/siwrapper.py | https://github.com/csaez/wishlib/blob/c212fa7875006a332a4cefbf69885ced9647bc2f/wishlib/si/siwrapper.py#L108-L126 | def update(self):
"""
This method should be called when you want to ensure all cached attributes
are in sync with the actual object attributes at runtime.
This happens because attributes could store mutable objects and be
modified outside the scope of this class.
The most... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"holder",
"=",
"siget",
"(",
"self",
".",
"holder",
".",
"FullName",
")",
"# fix dispatch issues",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__dict__",
".",
"iteritems",
"(",
")",
":",
"key",
... | This method should be called when you want to ensure all cached attributes
are in sync with the actual object attributes at runtime.
This happens because attributes could store mutable objects and be
modified outside the scope of this class.
The most common idiom that isn't automagically... | [
"This",
"method",
"should",
"be",
"called",
"when",
"you",
"want",
"to",
"ensure",
"all",
"cached",
"attributes",
"are",
"in",
"sync",
"with",
"the",
"actual",
"object",
"attributes",
"at",
"runtime",
".",
"This",
"happens",
"because",
"attributes",
"could",
... | python | train | 55.210526 |
jaseg/python-mpv | mpv.py | https://github.com/jaseg/python-mpv/blob/7117de4005cc470a45efd9cf2e9657bdf63a9079/mpv.py#L808-L814 | def property_observer(self, name):
"""Function decorator to register a property observer. See ``MPV.observe_property`` for details."""
def wrapper(fun):
self.observe_property(name, fun)
fun.unobserve_mpv_properties = lambda: self.unobserve_property(name, fun)
return f... | [
"def",
"property_observer",
"(",
"self",
",",
"name",
")",
":",
"def",
"wrapper",
"(",
"fun",
")",
":",
"self",
".",
"observe_property",
"(",
"name",
",",
"fun",
")",
"fun",
".",
"unobserve_mpv_properties",
"=",
"lambda",
":",
"self",
".",
"unobserve_prope... | Function decorator to register a property observer. See ``MPV.observe_property`` for details. | [
"Function",
"decorator",
"to",
"register",
"a",
"property",
"observer",
".",
"See",
"MPV",
".",
"observe_property",
"for",
"details",
"."
] | python | train | 48.428571 |
PmagPy/PmagPy | programs/apwp.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/apwp.py#L13-L117 | def main():
"""
NAME
apwp.py
DESCRIPTION
returns predicted paleolatitudes, directions and pole latitude/longitude
from apparent polar wander paths of Besse and Courtillot (2002).
SYNTAX
apwp.py [command line options][< filename]
OPTIONS
-h prints help messa... | [
"def",
"main",
"(",
")",
":",
"infile",
",",
"outfile",
",",
"data",
",",
"indata",
"=",
"\"\"",
",",
"\"\"",
",",
"[",
"]",
",",
"[",
"]",
"if",
"'-h'",
"in",
"sys",
".",
"argv",
":",
"print",
"(",
"main",
".",
"__doc__",
")",
"sys",
".",
"e... | NAME
apwp.py
DESCRIPTION
returns predicted paleolatitudes, directions and pole latitude/longitude
from apparent polar wander paths of Besse and Courtillot (2002).
SYNTAX
apwp.py [command line options][< filename]
OPTIONS
-h prints help message and quits
-i ... | [
"NAME",
"apwp",
".",
"py"
] | python | train | 30.314286 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2dispatch.py | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2dispatch.py#L143-L157 | def setUpImports(self):
'''set import statements
'''
i = self.imports
print >>i, 'from pyremotevbox.ZSI.schema import GED, GTD'
print >>i, 'from pyremotevbox.ZSI.TCcompound import ComplexType, Struct'
module = self.getTypesModuleName()
package = self.getTypesModu... | [
"def",
"setUpImports",
"(",
"self",
")",
":",
"i",
"=",
"self",
".",
"imports",
"print",
">>",
"i",
",",
"'from pyremotevbox.ZSI.schema import GED, GTD'",
"print",
">>",
"i",
",",
"'from pyremotevbox.ZSI.TCcompound import ComplexType, Struct'",
"module",
"=",
"self",
... | set import statements | [
"set",
"import",
"statements"
] | python | train | 36.133333 |
bokeh/bokeh | bokeh/sphinxext/bokeh_plot.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/sphinxext/bokeh_plot.py#L212-L222 | def setup(app):
''' Required Sphinx extension setup function. '''
# These two are deprecated and no longer have any effect, to be removed 2.0
app.add_config_value('bokeh_plot_pyfile_include_dirs', [], 'html')
app.add_config_value('bokeh_plot_use_relative_paths', False, 'html')
app.add_directive('b... | [
"def",
"setup",
"(",
"app",
")",
":",
"# These two are deprecated and no longer have any effect, to be removed 2.0",
"app",
".",
"add_config_value",
"(",
"'bokeh_plot_pyfile_include_dirs'",
",",
"[",
"]",
",",
"'html'",
")",
"app",
".",
"add_config_value",
"(",
"'bokeh_pl... | Required Sphinx extension setup function. | [
"Required",
"Sphinx",
"extension",
"setup",
"function",
"."
] | python | train | 46.818182 |
apache/incubator-mxnet | python/mxnet/callback.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/callback.py#L27-L52 | def module_checkpoint(mod, prefix, period=1, save_optimizer_states=False):
"""Callback to checkpoint Module to prefix every epoch.
Parameters
----------
mod : subclass of BaseModule
The module to checkpoint.
prefix : str
The file prefix for this checkpoint.
period : int
... | [
"def",
"module_checkpoint",
"(",
"mod",
",",
"prefix",
",",
"period",
"=",
"1",
",",
"save_optimizer_states",
"=",
"False",
")",
":",
"period",
"=",
"int",
"(",
"max",
"(",
"1",
",",
"period",
")",
")",
"# pylint: disable=unused-argument",
"def",
"_callback"... | Callback to checkpoint Module to prefix every epoch.
Parameters
----------
mod : subclass of BaseModule
The module to checkpoint.
prefix : str
The file prefix for this checkpoint.
period : int
How many epochs to wait before checkpointing. Defaults to 1.
save_optimizer_st... | [
"Callback",
"to",
"checkpoint",
"Module",
"to",
"prefix",
"every",
"epoch",
"."
] | python | train | 35 |
qbicsoftware/mtb-parser-lib | mtbparser/snv_item.py | https://github.com/qbicsoftware/mtb-parser-lib/blob/e8b96e34b27e457ea7def2927fe44017fa173ba7/mtbparser/snv_item.py#L6-L11 | def _format_dict(self, info_dict):
"""Replaces empty content with 'NA's"""
for key, value in info_dict.items():
if not value:
info_dict[key] = "NA"
return info_dict | [
"def",
"_format_dict",
"(",
"self",
",",
"info_dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"info_dict",
".",
"items",
"(",
")",
":",
"if",
"not",
"value",
":",
"info_dict",
"[",
"key",
"]",
"=",
"\"NA\"",
"return",
"info_dict"
] | Replaces empty content with 'NA's | [
"Replaces",
"empty",
"content",
"with",
"NA",
"s"
] | python | train | 35.166667 |
mottosso/be | be/vendor/requests/packages/urllib3/_collections.py | https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L290-L295 | def iteritems(self):
"""Iterate over all header lines, including duplicate ones."""
for key in self:
vals = _dict_getitem(self, key)
for val in vals[1:]:
yield vals[0], val | [
"def",
"iteritems",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
":",
"vals",
"=",
"_dict_getitem",
"(",
"self",
",",
"key",
")",
"for",
"val",
"in",
"vals",
"[",
"1",
":",
"]",
":",
"yield",
"vals",
"[",
"0",
"]",
",",
"val"
] | Iterate over all header lines, including duplicate ones. | [
"Iterate",
"over",
"all",
"header",
"lines",
"including",
"duplicate",
"ones",
"."
] | python | train | 37.166667 |
aodag/WebDispatch | webdispatch/base.py | https://github.com/aodag/WebDispatch/blob/55f8658a2b4100498e098a80303a346c3940f1bc/webdispatch/base.py#L44-L49 | def on_view_not_found(
self,
environ: Dict[str, Any],
start_response: Callable) -> Iterable[bytes]: # pragma: nocover
""" called when view is not found"""
raise NotImplementedError() | [
"def",
"on_view_not_found",
"(",
"self",
",",
"environ",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"start_response",
":",
"Callable",
")",
"->",
"Iterable",
"[",
"bytes",
"]",
":",
"# pragma: nocover",
"raise",
"NotImplementedError",
"(",
")"
] | called when view is not found | [
"called",
"when",
"view",
"is",
"not",
"found"
] | python | train | 38.333333 |
lbusoni/pysilico | pysilico/gui/image_show_widget/image_show_basic_widget.py | https://github.com/lbusoni/pysilico/blob/44872c8c202bedc8af5d7ac0cd2971912a59a365/pysilico/gui/image_show_widget/image_show_basic_widget.py#L504-L513 | def _getProcessedImage(self):
"""Returns the image data after it has been processed by any normalization options in use.
This method also sets the attributes self.levelMin and self.levelMax
to indicate the range of data in the image."""
if self.imageDisp is None:
self.imageD... | [
"def",
"_getProcessedImage",
"(",
"self",
")",
":",
"if",
"self",
".",
"imageDisp",
"is",
"None",
":",
"self",
".",
"imageDisp",
"=",
"self",
".",
"image",
"self",
".",
"levelMin",
",",
"self",
".",
"levelMax",
"=",
"self",
".",
"_quickLevels",
"(",
"s... | Returns the image data after it has been processed by any normalization options in use.
This method also sets the attributes self.levelMin and self.levelMax
to indicate the range of data in the image. | [
"Returns",
"the",
"image",
"data",
"after",
"it",
"has",
"been",
"processed",
"by",
"any",
"normalization",
"options",
"in",
"use",
".",
"This",
"method",
"also",
"sets",
"the",
"attributes",
"self",
".",
"levelMin",
"and",
"self",
".",
"levelMax",
"to",
"... | python | train | 51.7 |
jkwill87/mapi | mapi/endpoints.py | https://github.com/jkwill87/mapi/blob/730bf57c12aecaf49e18c15bf2b35af7f554b3cc/mapi/endpoints.py#L260-L273 | def tvdb_login(api_key):
""" Logs into TVDb using the provided api key
Note: You can register for a free TVDb key at thetvdb.com/?tab=apiregister
Online docs: api.thetvdb.com/swagger#!/Authentication/post_login=
"""
url = "https://api.thetvdb.com/login"
body = {"apikey": api_key}
status, co... | [
"def",
"tvdb_login",
"(",
"api_key",
")",
":",
"url",
"=",
"\"https://api.thetvdb.com/login\"",
"body",
"=",
"{",
"\"apikey\"",
":",
"api_key",
"}",
"status",
",",
"content",
"=",
"_request_json",
"(",
"url",
",",
"body",
"=",
"body",
",",
"cache",
"=",
"F... | Logs into TVDb using the provided api key
Note: You can register for a free TVDb key at thetvdb.com/?tab=apiregister
Online docs: api.thetvdb.com/swagger#!/Authentication/post_login= | [
"Logs",
"into",
"TVDb",
"using",
"the",
"provided",
"api",
"key"
] | python | train | 41.285714 |
tensorforce/tensorforce | tensorforce/core/optimizers/optimizer.py | https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/optimizer.py#L75-L90 | def apply_step(self, variables, deltas):
"""
Applies the given (and already calculated) step deltas to the variable values.
Args:
variables: List of variables.
deltas: List of deltas of same length.
Returns:
The step-applied operation. A tf.group of ... | [
"def",
"apply_step",
"(",
"self",
",",
"variables",
",",
"deltas",
")",
":",
"if",
"len",
"(",
"variables",
")",
"!=",
"len",
"(",
"deltas",
")",
":",
"raise",
"TensorForceError",
"(",
"\"Invalid variables and deltas lists.\"",
")",
"return",
"tf",
".",
"gro... | Applies the given (and already calculated) step deltas to the variable values.
Args:
variables: List of variables.
deltas: List of deltas of same length.
Returns:
The step-applied operation. A tf.group of tf.assign_add ops. | [
"Applies",
"the",
"given",
"(",
"and",
"already",
"calculated",
")",
"step",
"deltas",
"to",
"the",
"variable",
"values",
"."
] | python | valid | 36.75 |
frmdstryr/enamlx | enamlx/qt/qt_table_view.py | https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_table_view.py#L194-L198 | def data_changed(self, change):
""" Notify the model that data has changed in this cell! """
index = self.index
if index:
self.view.model.dataChanged.emit(index, index) | [
"def",
"data_changed",
"(",
"self",
",",
"change",
")",
":",
"index",
"=",
"self",
".",
"index",
"if",
"index",
":",
"self",
".",
"view",
".",
"model",
".",
"dataChanged",
".",
"emit",
"(",
"index",
",",
"index",
")"
] | Notify the model that data has changed in this cell! | [
"Notify",
"the",
"model",
"that",
"data",
"has",
"changed",
"in",
"this",
"cell!"
] | python | train | 40 |
HPENetworking/PYHPEIMC | pyhpeimc/plat/alarms.py | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/alarms.py#L20-L62 | def get_dev_alarms(auth, url, devid=None, devip=None):
"""
function takes the devId of a specific device and issues a RESTFUL call to get the current
alarms for the target device.
:param devid: int or str value of the target device
:param devip: str of ipv4 address of the target device
:param... | [
"def",
"get_dev_alarms",
"(",
"auth",
",",
"url",
",",
"devid",
"=",
"None",
",",
"devip",
"=",
"None",
")",
":",
"# checks to see if the imc credentials are already available",
"if",
"devip",
"is",
"not",
"None",
":",
"devid",
"=",
"get_dev_details",
"(",
"devi... | function takes the devId of a specific device and issues a RESTFUL call to get the current
alarms for the target device.
:param devid: int or str value of the target device
:param devip: str of ipv4 address of the target device
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.... | [
"function",
"takes",
"the",
"devId",
"of",
"a",
"specific",
"device",
"and",
"issues",
"a",
"RESTFUL",
"call",
"to",
"get",
"the",
"current",
"alarms",
"for",
"the",
"target",
"device",
"."
] | python | train | 35.976744 |
briancappello/flask-unchained | flask_unchained/bundles/security/views/security_controller.py | https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/bundles/security/views/security_controller.py#L198-L242 | def reset_password(self, token):
"""
View function verify a users reset password token from the email we sent to them.
It also handles the form for them to set a new password.
Supports html and json requests.
"""
expired, invalid, user = \
self.security_utils_... | [
"def",
"reset_password",
"(",
"self",
",",
"token",
")",
":",
"expired",
",",
"invalid",
",",
"user",
"=",
"self",
".",
"security_utils_service",
".",
"reset_password_token_status",
"(",
"token",
")",
"if",
"invalid",
":",
"self",
".",
"flash",
"(",
"_",
"... | View function verify a users reset password token from the email we sent to them.
It also handles the form for them to set a new password.
Supports html and json requests. | [
"View",
"function",
"verify",
"a",
"users",
"reset",
"password",
"token",
"from",
"the",
"email",
"we",
"sent",
"to",
"them",
".",
"It",
"also",
"handles",
"the",
"form",
"for",
"them",
"to",
"set",
"a",
"new",
"password",
".",
"Supports",
"html",
"and",... | python | train | 49.288889 |
django-notifications/django-notifications | notifications/views.py | https://github.com/django-notifications/django-notifications/blob/c271193215a053d6477d5ceca6f2524793bf9cb1/notifications/views.py#L143-L187 | def live_unread_notification_list(request):
''' Return a json with a unread notification list '''
try:
user_is_authenticated = request.user.is_authenticated()
except TypeError: # Django >= 1.11
user_is_authenticated = request.user.is_authenticated
if not user_is_authenticated:
... | [
"def",
"live_unread_notification_list",
"(",
"request",
")",
":",
"try",
":",
"user_is_authenticated",
"=",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
"except",
"TypeError",
":",
"# Django >= 1.11",
"user_is_authenticated",
"=",
"request",
".",
"user... | Return a json with a unread notification list | [
"Return",
"a",
"json",
"with",
"a",
"unread",
"notification",
"list"
] | python | train | 36.066667 |
econ-ark/HARK | HARK/ConsumptionSaving/ConsAggShockModel.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsAggShockModel.py#L655-L858 | def solveConsAggMarkov(solution_next,IncomeDstn,LivPrb,DiscFac,CRRA,MrkvArray,
PermGroFac,PermGroFacAgg,aXtraGrid,BoroCnstArt,Mgrid,
AFunc,Rfunc,wFunc,DeprFac):
'''
Solve one period of a consumption-saving problem with idiosyncratic and
aggregate shocks (transit... | [
"def",
"solveConsAggMarkov",
"(",
"solution_next",
",",
"IncomeDstn",
",",
"LivPrb",
",",
"DiscFac",
",",
"CRRA",
",",
"MrkvArray",
",",
"PermGroFac",
",",
"PermGroFacAgg",
",",
"aXtraGrid",
",",
"BoroCnstArt",
",",
"Mgrid",
",",
"AFunc",
",",
"Rfunc",
",",
... | Solve one period of a consumption-saving problem with idiosyncratic and
aggregate shocks (transitory and permanent). Moreover, the macroeconomic
state follows a Markov process that determines the income distribution and
aggregate permanent growth factor. This is a basic solver that can't handle
cubic s... | [
"Solve",
"one",
"period",
"of",
"a",
"consumption",
"-",
"saving",
"problem",
"with",
"idiosyncratic",
"and",
"aggregate",
"shocks",
"(",
"transitory",
"and",
"permanent",
")",
".",
"Moreover",
"the",
"macroeconomic",
"state",
"follows",
"a",
"Markov",
"process"... | python | train | 54.892157 |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L627-L673 | def lookup_zone_exception(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
... | [
"def",
"lookup_zone_exception",
"(",
"self",
",",
"callsign",
",",
"timestamp",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"UTC",
")",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
... | Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
int: Value of the the CQ Zone exception which exists for this callsign (at the given ti... | [
"Returns",
"a",
"CQ",
"Zone",
"if",
"an",
"exception",
"exists",
"for",
"the",
"given",
"callsign"
] | python | train | 35.212766 |
s1s1ty/py-jsonq | pyjsonq/query.py | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L32-L44 | def __parse_json_data(self, data):
"""Process Json data
:@param data
:@type data: json/dict
:throws TypeError
"""
if isinstance(data, dict) or isinstance(data, list):
self._raw_data = data
self._json_data = copy.deepcopy(self._raw_data)
e... | [
"def",
"__parse_json_data",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
"or",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"self",
".",
"_raw_data",
"=",
"data",
"self",
".",
"_json_data",
"=",
"copy",
... | Process Json data
:@param data
:@type data: json/dict
:throws TypeError | [
"Process",
"Json",
"data"
] | python | train | 28.384615 |
usc-isi-i2/etk | etk/extractors/dbpedia_spotlight_extractor.py | https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/extractors/dbpedia_spotlight_extractor.py#L35-L58 | def extract(self, text: str, confidence=0.5, filter=['Person', 'Place', 'Organisation']) -> List[Extraction]:
"""
Extract with the input text, confidence and fields filter to be used.
Args:
text (str): text input to be annotated
confidence (float): the con... | [
"def",
"extract",
"(",
"self",
",",
"text",
":",
"str",
",",
"confidence",
"=",
"0.5",
",",
"filter",
"=",
"[",
"'Person'",
",",
"'Place'",
",",
"'Organisation'",
"]",
")",
"->",
"List",
"[",
"Extraction",
"]",
":",
"filter",
"=",
"','",
".",
"join",... | Extract with the input text, confidence and fields filter to be used.
Args:
text (str): text input to be annotated
confidence (float): the confidence of the annotation
filter (List[str]): the fields that to be extracted
Returns:
Li... | [
"Extract",
"with",
"the",
"input",
"text",
"confidence",
"and",
"fields",
"filter",
"to",
"be",
"used",
".",
"Args",
":",
"text",
"(",
"str",
")",
":",
"text",
"input",
"to",
"be",
"annotated",
"confidence",
"(",
"float",
")",
":",
"the",
"confidence",
... | python | train | 38.375 |
iotile/coretools | iotilecore/iotile/core/hw/transport/adapter/legacy.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/legacy.py#L384-L413 | def debug_sync(self, conn_id, cmd_name, cmd_args, progress_callback):
"""Asynchronously complete a named debug command.
The command name and arguments are passed to the underlying device adapter
and interpreted there. If the command is long running, progress_callback
may be used to pro... | [
"def",
"debug_sync",
"(",
"self",
",",
"conn_id",
",",
"cmd_name",
",",
"cmd_args",
",",
"progress_callback",
")",
":",
"done",
"=",
"threading",
".",
"Event",
"(",
")",
"result",
"=",
"{",
"}",
"def",
"_debug_done",
"(",
"conn_id",
",",
"adapter_id",
",... | Asynchronously complete a named debug command.
The command name and arguments are passed to the underlying device adapter
and interpreted there. If the command is long running, progress_callback
may be used to provide status updates. Callback is called when the command
has finished.
... | [
"Asynchronously",
"complete",
"a",
"named",
"debug",
"command",
"."
] | python | train | 40.533333 |
pantsbuild/pants | src/python/pants/base/worker_pool.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/base/worker_pool.py#L57-L80 | def submit_async_work(self, work, workunit_parent=None, on_success=None, on_failure=None):
"""Submit work to be executed in the background.
:param work: The work to execute.
:param workunit_parent: If specified, work is accounted for under this workunit.
:param on_success: If specified, a callable taki... | [
"def",
"submit_async_work",
"(",
"self",
",",
"work",
",",
"workunit_parent",
"=",
"None",
",",
"on_success",
"=",
"None",
",",
"on_failure",
"=",
"None",
")",
":",
"if",
"work",
"is",
"None",
"or",
"len",
"(",
"work",
".",
"args_tuples",
")",
"==",
"0... | Submit work to be executed in the background.
:param work: The work to execute.
:param workunit_parent: If specified, work is accounted for under this workunit.
:param on_success: If specified, a callable taking a single argument, which will be a list
of return values of each invocation, ... | [
"Submit",
"work",
"to",
"be",
"executed",
"in",
"the",
"background",
"."
] | python | train | 52.541667 |
apple/turicreate | src/unity/python/turicreate/toolkits/topic_model/topic_model.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/topic_model/topic_model.py#L303-L338 | def _get_summary_struct(self):
"""
Returns a structured description of the model, including (where relevant)
the schema of the training data, description of the training data,
training statistics, and model hyperparameters.
Returns
-------
sections : list (of lis... | [
"def",
"_get_summary_struct",
"(",
"self",
")",
":",
"section_titles",
"=",
"[",
"'Schema'",
",",
"'Settings'",
"]",
"vocab_length",
"=",
"len",
"(",
"self",
".",
"vocabulary",
")",
"verbose",
"=",
"self",
".",
"verbose",
"==",
"1",
"sections",
"=",
"[",
... | Returns a structured description of the model, including (where relevant)
the schema of the training data, description of the training data,
training statistics, and model hyperparameters.
Returns
-------
sections : list (of list of tuples)
A list of summary sections... | [
"Returns",
"a",
"structured",
"description",
"of",
"the",
"model",
"including",
"(",
"where",
"relevant",
")",
"the",
"schema",
"of",
"the",
"training",
"data",
"description",
"of",
"the",
"training",
"data",
"training",
"statistics",
"and",
"model",
"hyperparam... | python | train | 36.777778 |
phoebe-project/phoebe2 | phoebe/backend/backends.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/backend/backends.py#L404-L427 | def run(self, b, compute, times=[], **kwargs):
"""
if within mpirun, workers should call _run_worker instead of run
"""
self.run_checks(b, compute, times, **kwargs)
logger.debug("rank:{}/{} calling get_packet_and_syns".format(mpi.myrank, mpi.nprocs))
packet, new_syns = s... | [
"def",
"run",
"(",
"self",
",",
"b",
",",
"compute",
",",
"times",
"=",
"[",
"]",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"run_checks",
"(",
"b",
",",
"compute",
",",
"times",
",",
"*",
"*",
"kwargs",
")",
"logger",
".",
"debug",
"(",
... | if within mpirun, workers should call _run_worker instead of run | [
"if",
"within",
"mpirun",
"workers",
"should",
"call",
"_run_worker",
"instead",
"of",
"run"
] | python | train | 37.083333 |
garyelephant/pygrok | pygrok/pygrok.py | https://github.com/garyelephant/pygrok/blob/de9e3f92f5a52f0fc101aaa0f694f52aee6afba8/pygrok/pygrok.py#L33-L57 | def match(self, text):
"""If text is matched with pattern, return variable names specified(%{pattern:variable name})
in pattern and their corresponding values.If not matched, return None.
custom patterns can be passed in by custom_patterns(pattern name, pattern regular expression pair)
o... | [
"def",
"match",
"(",
"self",
",",
"text",
")",
":",
"match_obj",
"=",
"None",
"if",
"self",
".",
"fullmatch",
":",
"match_obj",
"=",
"self",
".",
"regex_obj",
".",
"fullmatch",
"(",
"text",
")",
"else",
":",
"match_obj",
"=",
"self",
".",
"regex_obj",
... | If text is matched with pattern, return variable names specified(%{pattern:variable name})
in pattern and their corresponding values.If not matched, return None.
custom patterns can be passed in by custom_patterns(pattern name, pattern regular expression pair)
or custom_patterns_dir. | [
"If",
"text",
"is",
"matched",
"with",
"pattern",
"return",
"variable",
"names",
"specified",
"(",
"%",
"{",
"pattern",
":",
"variable",
"name",
"}",
")",
"in",
"pattern",
"and",
"their",
"corresponding",
"values",
".",
"If",
"not",
"matched",
"return",
"N... | python | test | 37.88 |
pantsbuild/pants | src/python/pants/backend/jvm/targets/jarable.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/targets/jarable.py#L32-L43 | def get_artifact_info(self):
"""Returns a tuple composed of a :class:`pants.java.jar.JarDependency`
describing the jar for this target and a bool indicating if this target is exportable.
"""
exported = bool(self.provides)
org = self.provides.org if exported else 'internal'
name = self.provides.... | [
"def",
"get_artifact_info",
"(",
"self",
")",
":",
"exported",
"=",
"bool",
"(",
"self",
".",
"provides",
")",
"org",
"=",
"self",
".",
"provides",
".",
"org",
"if",
"exported",
"else",
"'internal'",
"name",
"=",
"self",
".",
"provides",
".",
"name",
"... | Returns a tuple composed of a :class:`pants.java.jar.JarDependency`
describing the jar for this target and a bool indicating if this target is exportable. | [
"Returns",
"a",
"tuple",
"composed",
"of",
"a",
":",
"class",
":",
"pants",
".",
"java",
".",
"jar",
".",
"JarDependency",
"describing",
"the",
"jar",
"for",
"this",
"target",
"and",
"a",
"bool",
"indicating",
"if",
"this",
"target",
"is",
"exportable",
... | python | train | 46.416667 |
sethmlarson/trytravis | trytravis.py | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L128-L138 | def _load_github_repo():
""" Loads the GitHub repository from the users config. """
if 'TRAVIS' in os.environ:
raise RuntimeError('Detected that we are running in Travis. '
'Stopping to prevent infinite loops.')
try:
with open(os.path.join(config_dir, 'repo'), 'r')... | [
"def",
"_load_github_repo",
"(",
")",
":",
"if",
"'TRAVIS'",
"in",
"os",
".",
"environ",
":",
"raise",
"RuntimeError",
"(",
"'Detected that we are running in Travis. '",
"'Stopping to prevent infinite loops.'",
")",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path"... | Loads the GitHub repository from the users config. | [
"Loads",
"the",
"GitHub",
"repository",
"from",
"the",
"users",
"config",
"."
] | python | train | 45.454545 |
cons3rt/pycons3rt | pycons3rt/awsapi/ec2util.py | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L256-L311 | def allocate_elastic_ip(self):
"""Allocates an elastic IP address
:return: Dict with allocation ID and Public IP that were created
:raises: AWSAPIError, EC2UtilError
"""
log = logging.getLogger(self.cls_logger + '.allocate_elastic_ip')
# Attempt to allocate a new elasti... | [
"def",
"allocate_elastic_ip",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.allocate_elastic_ip'",
")",
"# Attempt to allocate a new elastic IP",
"log",
".",
"info",
"(",
"'Attempting to allocate an elastic IP...... | Allocates an elastic IP address
:return: Dict with allocation ID and Public IP that were created
:raises: AWSAPIError, EC2UtilError | [
"Allocates",
"an",
"elastic",
"IP",
"address"
] | python | train | 41.964286 |
swistakm/graceful | src/graceful/serializers.py | https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/serializers.py#L41-L66 | def _get_fields(mcs, bases, namespace):
"""Create fields dictionary to be used in resource class namespace.
Pop all field objects from attributes dict (namespace) and store them
under _field_storage_key atrribute. Also collect all fields from base
classes in order that ensures fields ca... | [
"def",
"_get_fields",
"(",
"mcs",
",",
"bases",
",",
"namespace",
")",
":",
"fields",
"=",
"[",
"(",
"name",
",",
"namespace",
".",
"pop",
"(",
"name",
")",
")",
"for",
"name",
",",
"attribute",
"in",
"list",
"(",
"namespace",
".",
"items",
"(",
")... | Create fields dictionary to be used in resource class namespace.
Pop all field objects from attributes dict (namespace) and store them
under _field_storage_key atrribute. Also collect all fields from base
classes in order that ensures fields can be overriden.
Args:
bases: a... | [
"Create",
"fields",
"dictionary",
"to",
"be",
"used",
"in",
"resource",
"class",
"namespace",
"."
] | python | train | 35.076923 |
aio-libs/aiomcache | aiomcache/client.py | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L153-L162 | def gets(self, conn, key, default=None):
"""Gets a single value from the server together with the cas token.
:param key: ``bytes``, is the key for the item being fetched
:param default: default value if there is no value.
:return: ``bytes``, ``bytes tuple with the value and the cas
... | [
"def",
"gets",
"(",
"self",
",",
"conn",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"values",
",",
"cas_tokens",
"=",
"yield",
"from",
"self",
".",
"_multi_get",
"(",
"conn",
",",
"key",
",",
"with_cas",
"=",
"True",
")",
"return",
"values",
... | Gets a single value from the server together with the cas token.
:param key: ``bytes``, is the key for the item being fetched
:param default: default value if there is no value.
:return: ``bytes``, ``bytes tuple with the value and the cas | [
"Gets",
"a",
"single",
"value",
"from",
"the",
"server",
"together",
"with",
"the",
"cas",
"token",
"."
] | python | train | 47.4 |
SeleniumHQ/selenium | py/selenium/webdriver/common/touch_actions.py | https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L154-L166 | def flick(self, xspeed, yspeed):
"""
Flicks, starting anywhere on the screen.
:Args:
- xspeed: The X speed in pixels per second.
- yspeed: The Y speed in pixels per second.
"""
self._actions.append(lambda: self._driver.execute(
Command.FLICK, {
... | [
"def",
"flick",
"(",
"self",
",",
"xspeed",
",",
"yspeed",
")",
":",
"self",
".",
"_actions",
".",
"append",
"(",
"lambda",
":",
"self",
".",
"_driver",
".",
"execute",
"(",
"Command",
".",
"FLICK",
",",
"{",
"'xspeed'",
":",
"int",
"(",
"xspeed",
... | Flicks, starting anywhere on the screen.
:Args:
- xspeed: The X speed in pixels per second.
- yspeed: The Y speed in pixels per second. | [
"Flicks",
"starting",
"anywhere",
"on",
"the",
"screen",
"."
] | python | train | 31 |
cnt-dev/cnt.rulebase | cnt/rulebase/rules/interval_based_operations/interval_based_replacer.py | https://github.com/cnt-dev/cnt.rulebase/blob/d1c767c356d8ee05b23ec5b04aaac84784ee547c/cnt/rulebase/rules/interval_based_operations/interval_based_replacer.py#L48-L75 | def _result(self) -> ResultLazyType:
"""
``self.config.replacer_function``(``Callable[[str], str]``) must exists.
"""
config = cast(IntervalsCollectionBasedReplacerConfig, self.config)
diff_acc = 0
for interval, aggregated_mark in self.continuous_intervals():
... | [
"def",
"_result",
"(",
"self",
")",
"->",
"ResultLazyType",
":",
"config",
"=",
"cast",
"(",
"IntervalsCollectionBasedReplacerConfig",
",",
"self",
".",
"config",
")",
"diff_acc",
"=",
"0",
"for",
"interval",
",",
"aggregated_mark",
"in",
"self",
".",
"continu... | ``self.config.replacer_function``(``Callable[[str], str]``) must exists. | [
"self",
".",
"config",
".",
"replacer_function",
"(",
"Callable",
"[[",
"str",
"]",
"str",
"]",
")",
"must",
"exists",
"."
] | python | train | 40.5 |
klmitch/bark | bark/conversions.py | https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/conversions.py#L411-L428 | def convert(self, request, response, data):
"""
Performs the desired Conversion.
:param request: The webob Request object describing the
request.
:param response: The webob Response object describing the
response.
:param data: The... | [
"def",
"convert",
"(",
"self",
",",
"request",
",",
"response",
",",
"data",
")",
":",
"# Notes are in bark.notes dictionary",
"return",
"self",
".",
"escape",
"(",
"request",
".",
"environ",
".",
"get",
"(",
"'bark.notes'",
",",
"{",
"}",
")",
".",
"get",... | Performs the desired Conversion.
:param request: The webob Request object describing the
request.
:param response: The webob Response object describing the
response.
:param data: The data dictionary returned by the prepare()
... | [
"Performs",
"the",
"desired",
"Conversion",
"."
] | python | train | 35.388889 |
delph-in/pydelphin | delphin/itsdb.py | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/itsdb.py#L1648-L1683 | def match_rows(rows1, rows2, key, sort_keys=True):
"""
Yield triples of `(value, left_rows, right_rows)` where
`left_rows` and `right_rows` are lists of rows that share the same
column value for *key*. This means that both *rows1* and *rows2*
must have a column with the same name *key*.
.. warn... | [
"def",
"match_rows",
"(",
"rows1",
",",
"rows2",
",",
"key",
",",
"sort_keys",
"=",
"True",
")",
":",
"matched",
"=",
"OrderedDict",
"(",
")",
"for",
"i",
",",
"rows",
"in",
"enumerate",
"(",
"[",
"rows1",
",",
"rows2",
"]",
")",
":",
"for",
"row",... | Yield triples of `(value, left_rows, right_rows)` where
`left_rows` and `right_rows` are lists of rows that share the same
column value for *key*. This means that both *rows1* and *rows2*
must have a column with the same name *key*.
.. warning::
Both *rows1* and *rows2* will exist in memory for... | [
"Yield",
"triples",
"of",
"(",
"value",
"left_rows",
"right_rows",
")",
"where",
"left_rows",
"and",
"right_rows",
"are",
"lists",
"of",
"rows",
"that",
"share",
"the",
"same",
"column",
"value",
"for",
"*",
"key",
"*",
".",
"This",
"means",
"that",
"both"... | python | train | 35.277778 |
osrg/ryu | ryu/lib/stplib.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/stplib.py#L566-L603 | def _spanning_tree_algorithm(self):
""" Update tree roles.
- Root bridge:
all port is DESIGNATED_PORT.
- Non root bridge:
select one ROOT_PORT and some DESIGNATED_PORT,
and the other port is set to NON_DESIGNATED_PORT."""
port_rol... | [
"def",
"_spanning_tree_algorithm",
"(",
"self",
")",
":",
"port_roles",
"=",
"{",
"}",
"root_port",
"=",
"self",
".",
"_select_root_port",
"(",
")",
"if",
"root_port",
"is",
"None",
":",
"# My bridge is a root bridge.",
"self",
".",
"logger",
".",
"info",
"(",... | Update tree roles.
- Root bridge:
all port is DESIGNATED_PORT.
- Non root bridge:
select one ROOT_PORT and some DESIGNATED_PORT,
and the other port is set to NON_DESIGNATED_PORT. | [
"Update",
"tree",
"roles",
".",
"-",
"Root",
"bridge",
":",
"all",
"port",
"is",
"DESIGNATED_PORT",
".",
"-",
"Non",
"root",
"bridge",
":",
"select",
"one",
"ROOT_PORT",
"and",
"some",
"DESIGNATED_PORT",
"and",
"the",
"other",
"port",
"is",
"set",
"to",
... | python | train | 38.684211 |
autokey/autokey | lib/autokey/model.py | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/model.py#L970-L984 | def _remove_non_serializable_store_entries(store: Store) -> dict:
"""
Copy all serializable data into a new dict, and skip the rest.
This makes sure to keep the items during runtime, even if the user edits and saves the script.
"""
cleaned_store_data = {}
for key, value i... | [
"def",
"_remove_non_serializable_store_entries",
"(",
"store",
":",
"Store",
")",
"->",
"dict",
":",
"cleaned_store_data",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"store",
".",
"items",
"(",
")",
":",
"if",
"Script",
".",
"_is_serializable",
"(",
... | Copy all serializable data into a new dict, and skip the rest.
This makes sure to keep the items during runtime, even if the user edits and saves the script. | [
"Copy",
"all",
"serializable",
"data",
"into",
"a",
"new",
"dict",
"and",
"skip",
"the",
"rest",
".",
"This",
"makes",
"sure",
"to",
"keep",
"the",
"items",
"during",
"runtime",
"even",
"if",
"the",
"user",
"edits",
"and",
"saves",
"the",
"script",
"."
] | python | train | 52.4 |
gc3-uzh-ch/elasticluster | elasticluster/providers/ansible_provider.py | https://github.com/gc3-uzh-ch/elasticluster/blob/e6345633308c76de13b889417df572815aabe744/elasticluster/providers/ansible_provider.py#L158-L179 | def setup_cluster(self, cluster, extra_args=tuple()):
"""
Configure the cluster by running an Ansible playbook.
The ElastiCluster configuration attribute `<kind>_groups`
determines, for each node kind, what Ansible groups nodes of
that kind are assigned to.
:param clust... | [
"def",
"setup_cluster",
"(",
"self",
",",
"cluster",
",",
"extra_args",
"=",
"tuple",
"(",
")",
")",
":",
"return",
"self",
".",
"_run_playbook",
"(",
"cluster",
",",
"self",
".",
"_playbook_path",
",",
"extra_args",
")"
] | Configure the cluster by running an Ansible playbook.
The ElastiCluster configuration attribute `<kind>_groups`
determines, for each node kind, what Ansible groups nodes of
that kind are assigned to.
:param cluster: cluster to configure
:type cluster: :py:class:`elasticluster.c... | [
"Configure",
"the",
"cluster",
"by",
"running",
"an",
"Ansible",
"playbook",
"."
] | python | train | 40.181818 |
googleapis/oauth2client | oauth2client/service_account.py | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/service_account.py#L495-L520 | def create_with_claims(self, claims):
"""Create credentials that specify additional claims.
Args:
claims: dict, key-value pairs for claims.
Returns:
ServiceAccountCredentials, a copy of the current service account
credentials with updated claims to use when ... | [
"def",
"create_with_claims",
"(",
"self",
",",
"claims",
")",
":",
"new_kwargs",
"=",
"dict",
"(",
"self",
".",
"_kwargs",
")",
"new_kwargs",
".",
"update",
"(",
"claims",
")",
"result",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"_service_account_em... | Create credentials that specify additional claims.
Args:
claims: dict, key-value pairs for claims.
Returns:
ServiceAccountCredentials, a copy of the current service account
credentials with updated claims to use when obtaining access
tokens. | [
"Create",
"credentials",
"that",
"specify",
"additional",
"claims",
"."
] | python | valid | 42.884615 |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L835-L847 | def get_dataset_date(self, date_format=None):
# type: (Optional[str]) -> Optional[str]
"""Get dataset date as string in specified format. For range returns start date.
If no format is supplied, an ISO 8601 string is returned.
Args:
date_format (Optional[str]): Date format. N... | [
"def",
"get_dataset_date",
"(",
"self",
",",
"date_format",
"=",
"None",
")",
":",
"# type: (Optional[str]) -> Optional[str]",
"dataset_date",
"=",
"self",
".",
"get_dataset_date_as_datetime",
"(",
")",
"return",
"self",
".",
"_get_formatted_date",
"(",
"dataset_date",
... | Get dataset date as string in specified format. For range returns start date.
If no format is supplied, an ISO 8601 string is returned.
Args:
date_format (Optional[str]): Date format. None is taken to be ISO 8601. Defaults to None.
Returns:
Optional[str]: Dataset date s... | [
"Get",
"dataset",
"date",
"as",
"string",
"in",
"specified",
"format",
".",
"For",
"range",
"returns",
"start",
"date",
".",
"If",
"no",
"format",
"is",
"supplied",
"an",
"ISO",
"8601",
"string",
"is",
"returned",
"."
] | python | train | 44.846154 |
readbeyond/aeneas | aeneas/runtimeconfiguration.py | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/runtimeconfiguration.py#L1119-L1138 | def set_tts(self, level):
"""
Set the values for
:data:`~aeneas.runtimeconfiguration.RuntimeConfiguration.TTS`
and
:data:`~aeneas.runtimeconfiguration.RuntimeConfiguration.TTS_PATH`
matching the given granularity level.
Currently supported levels:
* ``1`... | [
"def",
"set_tts",
"(",
"self",
",",
"level",
")",
":",
"if",
"level",
"in",
"self",
".",
"TTS_GRANULARITY_MAP",
".",
"keys",
"(",
")",
":",
"tts_key",
",",
"tts_path_key",
"=",
"self",
".",
"TTS_GRANULARITY_MAP",
"[",
"level",
"]",
"self",
"[",
"self",
... | Set the values for
:data:`~aeneas.runtimeconfiguration.RuntimeConfiguration.TTS`
and
:data:`~aeneas.runtimeconfiguration.RuntimeConfiguration.TTS_PATH`
matching the given granularity level.
Currently supported levels:
* ``1`` (paragraph)
* ``2`` (sentence)
... | [
"Set",
"the",
"values",
"for",
":",
"data",
":",
"~aeneas",
".",
"runtimeconfiguration",
".",
"RuntimeConfiguration",
".",
"TTS",
"and",
":",
"data",
":",
"~aeneas",
".",
"runtimeconfiguration",
".",
"RuntimeConfiguration",
".",
"TTS_PATH",
"matching",
"the",
"g... | python | train | 32.5 |
pybel/pybel | src/pybel/canonicalize.py | https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/canonicalize.py#L186-L201 | def _to_bel_lines_header(graph) -> Iterable[str]:
"""Iterate the lines of a BEL graph's corresponding BEL script's header.
:param pybel.BELGraph graph: A BEL graph
"""
yield '# This document was created by PyBEL v{} and bel-resources v{} on {}\n'.format(
VERSION, bel_resources.constants.VERSION... | [
"def",
"_to_bel_lines_header",
"(",
"graph",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"yield",
"'# This document was created by PyBEL v{} and bel-resources v{} on {}\\n'",
".",
"format",
"(",
"VERSION",
",",
"bel_resources",
".",
"constants",
".",
"VERSION",
",",
... | Iterate the lines of a BEL graph's corresponding BEL script's header.
:param pybel.BELGraph graph: A BEL graph | [
"Iterate",
"the",
"lines",
"of",
"a",
"BEL",
"graph",
"s",
"corresponding",
"BEL",
"script",
"s",
"header",
"."
] | python | train | 39.8125 |
ivanprjcts/sdklib | sdklib/http/base.py | https://github.com/ivanprjcts/sdklib/blob/7ba4273a05c40e2e338f49f2dd564920ed98fcab/sdklib/http/base.py#L353-L363 | def set_default_host(cls, value):
"""
Default: "http://127.0.0.1:80"
A string that will be automatically included at the beginning of the url generated for doing each http request.
"""
if value is None:
cls.DEFAULT_HOST = "http://127.0.0.1:80"
else:
... | [
"def",
"set_default_host",
"(",
"cls",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"cls",
".",
"DEFAULT_HOST",
"=",
"\"http://127.0.0.1:80\"",
"else",
":",
"scheme",
",",
"host",
",",
"port",
"=",
"get_hostname_parameters_from_url",
"(",
"value",... | Default: "http://127.0.0.1:80"
A string that will be automatically included at the beginning of the url generated for doing each http request. | [
"Default",
":",
"http",
":",
"//",
"127",
".",
"0",
".",
"0",
".",
"1",
":",
"80"
] | python | train | 40 |
apache/spark | python/pyspark/cloudpickle.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/cloudpickle.py#L1060-L1113 | def _fill_function(*args):
"""Fills in the rest of function data into the skeleton function object
The skeleton itself is create by _make_skel_func().
"""
if len(args) == 2:
func = args[0]
state = args[1]
elif len(args) == 5:
# Backwards compat for cloudpickle v0.4.0, after ... | [
"def",
"_fill_function",
"(",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"2",
":",
"func",
"=",
"args",
"[",
"0",
"]",
"state",
"=",
"args",
"[",
"1",
"]",
"elif",
"len",
"(",
"args",
")",
"==",
"5",
":",
"# Backwards compat for ... | Fills in the rest of function data into the skeleton function object
The skeleton itself is create by _make_skel_func(). | [
"Fills",
"in",
"the",
"rest",
"of",
"function",
"data",
"into",
"the",
"skeleton",
"function",
"object"
] | python | train | 39.185185 |
datakortet/dkfileutils | dkfileutils/path.py | https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/dkfileutils/path.py#L99-L121 | def touch(self, mode=0o666, exist_ok=True):
"""Create this file with the given access mode, if it doesn't exist.
Based on:
https://github.com/python/cpython/blob/master/Lib/pathlib.py)
"""
if exist_ok:
# First try to bump modificat... | [
"def",
"touch",
"(",
"self",
",",
"mode",
"=",
"0o666",
",",
"exist_ok",
"=",
"True",
")",
":",
"if",
"exist_ok",
":",
"# First try to bump modification time",
"# Implementation note: GNU touch uses the UTIME_NOW option of",
"# the utimensat() / futimens() functions.",
"try",... | Create this file with the given access mode, if it doesn't exist.
Based on:
https://github.com/python/cpython/blob/master/Lib/pathlib.py) | [
"Create",
"this",
"file",
"with",
"the",
"given",
"access",
"mode",
"if",
"it",
"doesn",
"t",
"exist",
".",
"Based",
"on",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"python",
"/",
"cpython",
"/",
"blob",
"/",
"master",
"/",
"Lib",
"/",
"p... | python | train | 33.869565 |
dhondta/tinyscript | tinyscript/argreparse.py | https://github.com/dhondta/tinyscript/blob/624a0718db698899e7bc3ba6ac694baed251e81d/tinyscript/argreparse.py#L422-L440 | def config_args(self, section="main"):
"""
Additional method for feeding input arguments from a config file.
:param section: current config section name
"""
if self._config_parsed:
return
for a in self._filtered_actions("config"):
for o in... | [
"def",
"config_args",
"(",
"self",
",",
"section",
"=",
"\"main\"",
")",
":",
"if",
"self",
".",
"_config_parsed",
":",
"return",
"for",
"a",
"in",
"self",
".",
"_filtered_actions",
"(",
"\"config\"",
")",
":",
"for",
"o",
"in",
"a",
".",
"option_strings... | Additional method for feeding input arguments from a config file.
:param section: current config section name | [
"Additional",
"method",
"for",
"feeding",
"input",
"arguments",
"from",
"a",
"config",
"file",
".",
":",
"param",
"section",
":",
"current",
"config",
"section",
"name"
] | python | train | 36.631579 |
oauthlib/oauthlib | oauthlib/oauth1/rfc5849/request_validator.py | https://github.com/oauthlib/oauthlib/blob/30321dd3c0ca784d3508a1970cf90d9f76835c79/oauthlib/oauth1/rfc5849/request_validator.py#L190-L196 | def check_verifier(self, verifier):
"""Checks that the verifier contains only safe characters
and is no shorter than lower and no longer than upper.
"""
lower, upper = self.verifier_length
return (set(verifier) <= self.safe_characters and
lower <= len(verifier) <=... | [
"def",
"check_verifier",
"(",
"self",
",",
"verifier",
")",
":",
"lower",
",",
"upper",
"=",
"self",
".",
"verifier_length",
"return",
"(",
"set",
"(",
"verifier",
")",
"<=",
"self",
".",
"safe_characters",
"and",
"lower",
"<=",
"len",
"(",
"verifier",
"... | Checks that the verifier contains only safe characters
and is no shorter than lower and no longer than upper. | [
"Checks",
"that",
"the",
"verifier",
"contains",
"only",
"safe",
"characters",
"and",
"is",
"no",
"shorter",
"than",
"lower",
"and",
"no",
"longer",
"than",
"upper",
"."
] | python | train | 45.857143 |
googlemaps/google-maps-services-python | googlemaps/convert.py | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L83-L107 | def normalize_lat_lng(arg):
"""Take the various lat/lng representations and return a tuple.
Accepts various representations:
1) dict with two entries - "lat" and "lng"
2) list or tuple - e.g. (-33, 151) or [-33, 151]
:param arg: The lat/lng pair.
:type arg: dict or list or tuple
:rtype: t... | [
"def",
"normalize_lat_lng",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"if",
"\"lat\"",
"in",
"arg",
"and",
"\"lng\"",
"in",
"arg",
":",
"return",
"arg",
"[",
"\"lat\"",
"]",
",",
"arg",
"[",
"\"lng\"",
"]",
"if",
... | Take the various lat/lng representations and return a tuple.
Accepts various representations:
1) dict with two entries - "lat" and "lng"
2) list or tuple - e.g. (-33, 151) or [-33, 151]
:param arg: The lat/lng pair.
:type arg: dict or list or tuple
:rtype: tuple (lat, lng) | [
"Take",
"the",
"various",
"lat",
"/",
"lng",
"representations",
"and",
"return",
"a",
"tuple",
"."
] | python | train | 28.92 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/licenses_api.py | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/licenses_api.py#L366-L390 | def get_specific(self, id, **kwargs):
"""
Get specific License
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(... | [
"def",
"get_specific",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"get_specific_with_http_info",
"(... | Get specific License
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
... | [
"Get",
"specific",
"License",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"define",
"a",
"callback",
"function",
"to",
"be",
"invoked",
"when",
"receiv... | python | train | 39 |
Azure/azure-cli-extensions | src/storage-preview/azext_storage_preview/_format.py | https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/storage-preview/azext_storage_preview/_format.py#L72-L90 | def transform_file_output(result):
""" Transform to convert SDK file/dir list output to something that
more clearly distinguishes between files and directories. """
from collections import OrderedDict
new_result = []
iterable = result if isinstance(result, list) else result.get('items', result)
... | [
"def",
"transform_file_output",
"(",
"result",
")",
":",
"from",
"collections",
"import",
"OrderedDict",
"new_result",
"=",
"[",
"]",
"iterable",
"=",
"result",
"if",
"isinstance",
"(",
"result",
",",
"list",
")",
"else",
"result",
".",
"get",
"(",
"'items'"... | Transform to convert SDK file/dir list output to something that
more clearly distinguishes between files and directories. | [
"Transform",
"to",
"convert",
"SDK",
"file",
"/",
"dir",
"list",
"output",
"to",
"something",
"that",
"more",
"clearly",
"distinguishes",
"between",
"files",
"and",
"directories",
"."
] | python | train | 46 |
astropy/pyregion | pyregion/core.py | https://github.com/astropy/pyregion/blob/913af7ea4917855cb2e43d5086d1c8dd99c31363/pyregion/core.py#L223-L242 | def parse(region_string):
"""Parse DS9 region string into a ShapeList.
Parameters
----------
region_string : str
Region string
Returns
-------
shapes : `ShapeList`
List of `~pyregion.Shape`
"""
rp = RegionParser()
ss = rp.parse(region_string)
sss1 = rp.conve... | [
"def",
"parse",
"(",
"region_string",
")",
":",
"rp",
"=",
"RegionParser",
"(",
")",
"ss",
"=",
"rp",
".",
"parse",
"(",
"region_string",
")",
"sss1",
"=",
"rp",
".",
"convert_attr",
"(",
"ss",
")",
"sss2",
"=",
"_check_wcs",
"(",
"sss1",
")",
"shape... | Parse DS9 region string into a ShapeList.
Parameters
----------
region_string : str
Region string
Returns
-------
shapes : `ShapeList`
List of `~pyregion.Shape` | [
"Parse",
"DS9",
"region",
"string",
"into",
"a",
"ShapeList",
"."
] | python | train | 22.75 |
apache/spark | python/pyspark/sql/readwriter.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L521-L569 | def jdbc(self, url, table, column=None, lowerBound=None, upperBound=None, numPartitions=None,
predicates=None, properties=None):
"""
Construct a :class:`DataFrame` representing the database table named ``table``
accessible via JDBC URL ``url`` and connection ``properties``.
... | [
"def",
"jdbc",
"(",
"self",
",",
"url",
",",
"table",
",",
"column",
"=",
"None",
",",
"lowerBound",
"=",
"None",
",",
"upperBound",
"=",
"None",
",",
"numPartitions",
"=",
"None",
",",
"predicates",
"=",
"None",
",",
"properties",
"=",
"None",
")",
... | Construct a :class:`DataFrame` representing the database table named ``table``
accessible via JDBC URL ``url`` and connection ``properties``.
Partitions of the table will be retrieved in parallel if either ``column`` or
``predicates`` is specified. ``lowerBound`, ``upperBound`` and ``numPartiti... | [
"Construct",
"a",
":",
"class",
":",
"DataFrame",
"representing",
"the",
"database",
"table",
"named",
"table",
"accessible",
"via",
"JDBC",
"URL",
"url",
"and",
"connection",
"properties",
"."
] | python | train | 62.612245 |
horazont/aioxmpp | aioxmpp/bookmarks/service.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/bookmarks/service.py#L141-L265 | def _diff_emit_update(self, new_bookmarks):
"""
Diff the bookmark cache and the new bookmark state, emit signals as
needed and set the bookmark cache to the new data.
"""
self.logger.debug("diffing %s, %s", self._bookmark_cache,
new_bookmarks)
... | [
"def",
"_diff_emit_update",
"(",
"self",
",",
"new_bookmarks",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"diffing %s, %s\"",
",",
"self",
".",
"_bookmark_cache",
",",
"new_bookmarks",
")",
"def",
"subdivide",
"(",
"level",
",",
"old",
",",
"new",... | Diff the bookmark cache and the new bookmark state, emit signals as
needed and set the bookmark cache to the new data. | [
"Diff",
"the",
"bookmark",
"cache",
"and",
"the",
"new",
"bookmark",
"state",
"emit",
"signals",
"as",
"needed",
"and",
"set",
"the",
"bookmark",
"cache",
"to",
"the",
"new",
"data",
"."
] | python | train | 37.824 |
jimzhan/pyx | rex/core/cache.py | https://github.com/jimzhan/pyx/blob/819e8251323a7923e196c0c438aa8524f5aaee6e/rex/core/cache.py#L16-L40 | def memorize(func):
"""
Simply memorize the calculated result :data:`func`. previously returned.
Simply cached all calculated results from the decorated method/function into
a global `dict`.
"""
@wraps(func)
def wrapped_func(*args, **kwargs):
if (len(args) > 0 and len(kwargs) > 0): ... | [
"def",
"memorize",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"len",
"(",
"args",
")",
">",
"0",
"and",
"len",
"(",
"kwargs",
")",
">",
"0",
")... | Simply memorize the calculated result :data:`func`. previously returned.
Simply cached all calculated results from the decorated method/function into
a global `dict`. | [
"Simply",
"memorize",
"the",
"calculated",
"result",
":",
"data",
":",
"func",
".",
"previously",
"returned",
"."
] | python | train | 28.52 |
horejsek/python-fastjsonschema | fastjsonschema/ref_resolver.py | https://github.com/horejsek/python-fastjsonschema/blob/8c38d0f91fa5d928ff629080cdb75ab23f96590f/fastjsonschema/ref_resolver.py#L20-L36 | def resolve_path(schema, fragment):
"""
Return definition from path.
Path is unescaped according https://tools.ietf.org/html/rfc6901
"""
fragment = fragment.lstrip('/')
parts = unquote(fragment).split('/') if fragment else []
for part in parts:
part = part.replace('~1', '/'... | [
"def",
"resolve_path",
"(",
"schema",
",",
"fragment",
")",
":",
"fragment",
"=",
"fragment",
".",
"lstrip",
"(",
"'/'",
")",
"parts",
"=",
"unquote",
"(",
"fragment",
")",
".",
"split",
"(",
"'/'",
")",
"if",
"fragment",
"else",
"[",
"]",
"for",
"pa... | Return definition from path.
Path is unescaped according https://tools.ietf.org/html/rfc6901 | [
"Return",
"definition",
"from",
"path",
".",
"Path",
"is",
"unescaped",
"according",
"https",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc6901"
] | python | train | 33.941176 |
mitsei/dlkit | dlkit/json_/grading/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/sessions.py#L2709-L2734 | def delete_grade_entry(self, grade_entry_id):
"""Deletes the ``GradeEntry`` identified by the given ``Id``.
arg: grade_entry_id (osid.id.Id): the ``Id`` of the
``GradeEntry`` to delete
raise: NotFound - a ``GradeEntry`` was not found identified by
the given `... | [
"def",
"delete_grade_entry",
"(",
"self",
",",
"grade_entry_id",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceAdminSession.delete_resource_template",
"collection",
"=",
"JSONClientValidated",
"(",
"'grading'",
",",
"collection",
"=",
"'GradeEntry'",
","... | Deletes the ``GradeEntry`` identified by the given ``Id``.
arg: grade_entry_id (osid.id.Id): the ``Id`` of the
``GradeEntry`` to delete
raise: NotFound - a ``GradeEntry`` was not found identified by
the given ``Id``
raise: NullArgument - ``grade_entry_id`` i... | [
"Deletes",
"the",
"GradeEntry",
"identified",
"by",
"the",
"given",
"Id",
"."
] | python | train | 51.346154 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/MySQL_python-1.2.4c1-py2.7-linux-x86_64.egg/MySQLdb/cursors.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/MySQL_python-1.2.4c1-py2.7-linux-x86_64.egg/MySQLdb/cursors.py#L427-L435 | def fetchmany(self, size=None):
"""Fetch up to size rows from the cursor. Result set may be smaller
than size. If size is not defined, cursor.arraysize is used."""
self._check_executed()
r = self._fetch_row(size or self.arraysize)
self.rownumber = self.rownumber + len(r)
... | [
"def",
"fetchmany",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"self",
".",
"_check_executed",
"(",
")",
"r",
"=",
"self",
".",
"_fetch_row",
"(",
"size",
"or",
"self",
".",
"arraysize",
")",
"self",
".",
"rownumber",
"=",
"self",
".",
"rownumb... | Fetch up to size rows from the cursor. Result set may be smaller
than size. If size is not defined, cursor.arraysize is used. | [
"Fetch",
"up",
"to",
"size",
"rows",
"from",
"the",
"cursor",
".",
"Result",
"set",
"may",
"be",
"smaller",
"than",
"size",
".",
"If",
"size",
"is",
"not",
"defined",
"cursor",
".",
"arraysize",
"is",
"used",
"."
] | python | test | 41.333333 |
blockadeio/analyst_toolbench | blockade/common/utils.py | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L4-L17 | def clean_indicators(indicators):
"""Remove any extra details from indicators."""
output = list()
for indicator in indicators:
strip = ['http://', 'https://']
for item in strip:
indicator = indicator.replace(item, '')
indicator = indicator.strip('.').strip()
parts... | [
"def",
"clean_indicators",
"(",
"indicators",
")",
":",
"output",
"=",
"list",
"(",
")",
"for",
"indicator",
"in",
"indicators",
":",
"strip",
"=",
"[",
"'http://'",
",",
"'https://'",
"]",
"for",
"item",
"in",
"strip",
":",
"indicator",
"=",
"indicator",
... | Remove any extra details from indicators. | [
"Remove",
"any",
"extra",
"details",
"from",
"indicators",
"."
] | python | train | 34 |
bluedazzle/wechat_sender | wechat_sender/listener.py | https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/listener.py#L295-L326 | def listen(bot, receivers=None, token=None, port=10245, status_report=False, status_receiver=None,
status_interval=DEFAULT_REPORT_TIME):
"""
传入 bot 实例并启动 wechat_sender 服务
:param bot: (必填|Bot对象) - wxpy 的 Bot 对象实例
:param receivers: (选填|wxpy.Chat 对象|Chat 对象列表) - 消息接收者,wxpy 的 Chat 对象实例, 或 Chat 对... | [
"def",
"listen",
"(",
"bot",
",",
"receivers",
"=",
"None",
",",
"token",
"=",
"None",
",",
"port",
"=",
"10245",
",",
"status_report",
"=",
"False",
",",
"status_receiver",
"=",
"None",
",",
"status_interval",
"=",
"DEFAULT_REPORT_TIME",
")",
":",
"global... | 传入 bot 实例并启动 wechat_sender 服务
:param bot: (必填|Bot对象) - wxpy 的 Bot 对象实例
:param receivers: (选填|wxpy.Chat 对象|Chat 对象列表) - 消息接收者,wxpy 的 Chat 对象实例, 或 Chat 对象列表,如果为 list 第一个 Chat 为默认接收者。如果为 Chat 对象,则默认接收者也是此对象。 不填为当前 bot 对象的文件接收者
:param token: (选填|str) - 信令,防止 receiver 被非法滥用,建议加上 token 防止非法使用,如果使用 token 请在初始化 `S... | [
"传入",
"bot",
"实例并启动",
"wechat_sender",
"服务"
] | python | train | 49.5 |
lionheart/django-pyodbc | django_pyodbc/operations.py | https://github.com/lionheart/django-pyodbc/blob/46adda7b0bfabfa2640f72592c6f6f407f78b363/django_pyodbc/operations.py#L485-L524 | def convert_values(self, value, field):
"""
Coerce the value returned by the database backend into a consistent
type that is compatible with the field type.
In our case, cater for the fact that SQL Server < 2008 has no
separate Date and Time data types.
TODO: See how we'... | [
"def",
"convert_values",
"(",
"self",
",",
"value",
",",
"field",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"field",
"and",
"field",
".",
"get_internal_type",
"(",
")",
"==",
"'DateTimeField'",
":",
"if",
"isinstance",
"(",
"val... | Coerce the value returned by the database backend into a consistent
type that is compatible with the field type.
In our case, cater for the fact that SQL Server < 2008 has no
separate Date and Time data types.
TODO: See how we'll handle this for SQL Server >= 2008 | [
"Coerce",
"the",
"value",
"returned",
"by",
"the",
"database",
"backend",
"into",
"a",
"consistent",
"type",
"that",
"is",
"compatible",
"with",
"the",
"field",
"type",
"."
] | python | train | 52.275 |
loganasherjones/yapconf | yapconf/items.py | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/items.py#L294-L342 | def get_config_value(self, overrides, skip_environment=False):
"""Get the configuration value from all overrides.
Iterates over all overrides given to see if a value can be pulled
out from them. It will convert each of these values to ensure they
are the correct type.
Args:
... | [
"def",
"get_config_value",
"(",
"self",
",",
"overrides",
",",
"skip_environment",
"=",
"False",
")",
":",
"label",
",",
"override",
",",
"key",
"=",
"self",
".",
"_search_overrides",
"(",
"overrides",
",",
"skip_environment",
")",
"if",
"override",
"is",
"N... | Get the configuration value from all overrides.
Iterates over all overrides given to see if a value can be pulled
out from them. It will convert each of these values to ensure they
are the correct type.
Args:
overrides: A list of tuples where each tuple is a label and a
... | [
"Get",
"the",
"configuration",
"value",
"from",
"all",
"overrides",
"."
] | python | train | 34.77551 |
bxlab/bx-python | lib/bx/bitset_builders.py | https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/bitset_builders.py#L146-L155 | def binned_bitsets_by_chrom( f, chrom, chrom_col=0, start_col=1, end_col=2):
"""Read a file by chrom name into a bitset"""
bitset = BinnedBitSet( MAX )
for line in f:
if line.startswith("#"): continue
fields = line.split()
if fields[chrom_col] == chrom:
start, end = int( ... | [
"def",
"binned_bitsets_by_chrom",
"(",
"f",
",",
"chrom",
",",
"chrom_col",
"=",
"0",
",",
"start_col",
"=",
"1",
",",
"end_col",
"=",
"2",
")",
":",
"bitset",
"=",
"BinnedBitSet",
"(",
"MAX",
")",
"for",
"line",
"in",
"f",
":",
"if",
"line",
".",
... | Read a file by chrom name into a bitset | [
"Read",
"a",
"file",
"by",
"chrom",
"name",
"into",
"a",
"bitset"
] | python | train | 42.1 |
CalebBell/thermo | thermo/identifiers.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/identifiers.py#L359-L528 | def CAS_from_any(ID, autoload=False):
'''Looks up the CAS number of a chemical by searching and testing for the
string being any of the following types of chemical identifiers:
* Name, in IUPAC form or common form or a synonym registered in PubChem
* InChI name, prefixed by 'InChI=1S/' or 'InChI=1/... | [
"def",
"CAS_from_any",
"(",
"ID",
",",
"autoload",
"=",
"False",
")",
":",
"ID",
"=",
"ID",
".",
"strip",
"(",
")",
"ID_lower",
"=",
"ID",
".",
"lower",
"(",
")",
"if",
"ID",
"in",
"periodic_table",
":",
"if",
"periodic_table",
"[",
"ID",
"]",
".",... | Looks up the CAS number of a chemical by searching and testing for the
string being any of the following types of chemical identifiers:
* Name, in IUPAC form or common form or a synonym registered in PubChem
* InChI name, prefixed by 'InChI=1S/' or 'InChI=1/'
* InChI key, prefixed by 'InChIKey='
... | [
"Looks",
"up",
"the",
"CAS",
"number",
"of",
"a",
"chemical",
"by",
"searching",
"and",
"testing",
"for",
"the",
"string",
"being",
"any",
"of",
"the",
"following",
"types",
"of",
"chemical",
"identifiers",
":",
"*",
"Name",
"in",
"IUPAC",
"form",
"or",
... | python | valid | 35.770588 |
fusionbox/django-ogmios | ogmios/__init__.py | https://github.com/fusionbox/django-ogmios/blob/65b818d6059acd90aee5e874f31be8bee7d36ca6/ogmios/__init__.py#L92-L101 | def get_recipients(self, name):
"""
For example get_recipients('to')
"""
to_str = self.render_string(self.data[name])
formatted_emails = [
email.utils.formataddr(addr_pair)
for addr_pair in email.utils.getaddresses([to_str])
]
return [i for... | [
"def",
"get_recipients",
"(",
"self",
",",
"name",
")",
":",
"to_str",
"=",
"self",
".",
"render_string",
"(",
"self",
".",
"data",
"[",
"name",
"]",
")",
"formatted_emails",
"=",
"[",
"email",
".",
"utils",
".",
"formataddr",
"(",
"addr_pair",
")",
"f... | For example get_recipients('to') | [
"For",
"example",
"get_recipients",
"(",
"to",
")"
] | python | train | 33.9 |
openstack/networking-cisco | networking_cisco/apps/saf/server/dfa_openstack_helper.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/dfa_openstack_helper.py#L184-L198 | def get_network_by_name(self, nwk_name):
"""Search for a openstack network by name. """
ret_net_lst = []
try:
body = {}
net_list = self.neutronclient.list_networks(body=body)
net_list = net_list.get('networks')
for net in net_list:
... | [
"def",
"get_network_by_name",
"(",
"self",
",",
"nwk_name",
")",
":",
"ret_net_lst",
"=",
"[",
"]",
"try",
":",
"body",
"=",
"{",
"}",
"net_list",
"=",
"self",
".",
"neutronclient",
".",
"list_networks",
"(",
"body",
"=",
"body",
")",
"net_list",
"=",
... | Search for a openstack network by name. | [
"Search",
"for",
"a",
"openstack",
"network",
"by",
"name",
"."
] | python | train | 40.133333 |
PyGithub/PyGithub | github/PullRequestComment.py | https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/PullRequestComment.py#L180-L195 | def edit(self, body):
"""
:calls: `PATCH /repos/:owner/:repo/pulls/comments/:number <http://developer.github.com/v3/pulls/comments>`_
:param body: string
:rtype: None
"""
assert isinstance(body, (str, unicode)), body
post_parameters = {
"body": body,
... | [
"def",
"edit",
"(",
"self",
",",
"body",
")",
":",
"assert",
"isinstance",
"(",
"body",
",",
"(",
"str",
",",
"unicode",
")",
")",
",",
"body",
"post_parameters",
"=",
"{",
"\"body\"",
":",
"body",
",",
"}",
"headers",
",",
"data",
"=",
"self",
"."... | :calls: `PATCH /repos/:owner/:repo/pulls/comments/:number <http://developer.github.com/v3/pulls/comments>`_
:param body: string
:rtype: None | [
":",
"calls",
":",
"PATCH",
"/",
"repos",
"/",
":",
"owner",
"/",
":",
"repo",
"/",
"pulls",
"/",
"comments",
"/",
":",
"number",
"<http",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"pulls",
"/",
"comments",
">",
"_",
":",... | python | train | 30.9375 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/shared.py | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/shared.py#L39-L72 | def _closeElements(childs, HTMLElement):
"""
Create `endtags` to elements which looks like openers, but doesn't have
proper :attr:`HTMLElement.endtag`.
Args:
childs (list): List of childs (:class:`HTMLElement` obj) - typically
from :attr:`HTMLElement.childs` property.
Return... | [
"def",
"_closeElements",
"(",
"childs",
",",
"HTMLElement",
")",
":",
"out",
"=",
"[",
"]",
"# close all unclosed pair tags",
"for",
"e",
"in",
"childs",
":",
"if",
"not",
"e",
".",
"isTag",
"(",
")",
":",
"out",
".",
"append",
"(",
"e",
")",
"continue... | Create `endtags` to elements which looks like openers, but doesn't have
proper :attr:`HTMLElement.endtag`.
Args:
childs (list): List of childs (:class:`HTMLElement` obj) - typically
from :attr:`HTMLElement.childs` property.
Returns:
list: List of closed elements. | [
"Create",
"endtags",
"to",
"elements",
"which",
"looks",
"like",
"openers",
"but",
"doesn",
"t",
"have",
"proper",
":",
"attr",
":",
"HTMLElement",
".",
"endtag",
"."
] | python | train | 26.529412 |
iotile/typedargs | typedargs/typeinfo.py | https://github.com/iotile/typedargs/blob/0a5091a664b9b4d836e091e9ba583e944f438fd8/typedargs/typeinfo.py#L350-L366 | def load_external_types(self, path):
"""
Given a path to a python package or module, load that module, search for all defined variables
inside of it that do not start with _ or __ and inject them into the type system. If any of the
types cannot be injected, silently ignore them unless v... | [
"def",
"load_external_types",
"(",
"self",
",",
"path",
")",
":",
"folder",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"try",
":",
"fileobj",
",",
"pathname",
",",
"description",
"=",
"imp",
".",
"find_module",
"(",
"filen... | Given a path to a python package or module, load that module, search for all defined variables
inside of it that do not start with _ or __ and inject them into the type system. If any of the
types cannot be injected, silently ignore them unless verbose is True. If path points to a module
it sh... | [
"Given",
"a",
"path",
"to",
"a",
"python",
"package",
"or",
"module",
"load",
"that",
"module",
"search",
"for",
"all",
"defined",
"variables",
"inside",
"of",
"it",
"that",
"do",
"not",
"start",
"with",
"_",
"or",
"__",
"and",
"inject",
"them",
"into",
... | python | test | 54.705882 |
davedoesdev/python-jwt | python_jwt/__init__.py | https://github.com/davedoesdev/python-jwt/blob/5c753a26955cc666f00f6ff8e601406d95071368/python_jwt/__init__.py#L209-L224 | def process_jwt(jwt):
"""
Process a JSON Web Token without verifying it.
Call this before :func:`verify_jwt` if you need access to the header or claims in the token before verifying it. For example, the claims might identify the issuer such that you can retrieve the appropriate public key.
:param jwt:... | [
"def",
"process_jwt",
"(",
"jwt",
")",
":",
"header",
",",
"claims",
",",
"_",
"=",
"jwt",
".",
"split",
"(",
"'.'",
")",
"parsed_header",
"=",
"json_decode",
"(",
"base64url_decode",
"(",
"header",
")",
")",
"parsed_claims",
"=",
"json_decode",
"(",
"ba... | Process a JSON Web Token without verifying it.
Call this before :func:`verify_jwt` if you need access to the header or claims in the token before verifying it. For example, the claims might identify the issuer such that you can retrieve the appropriate public key.
:param jwt: The JSON Web Token to verify.
... | [
"Process",
"a",
"JSON",
"Web",
"Token",
"without",
"verifying",
"it",
"."
] | python | train | 38.875 |
oauthlib/oauthlib | oauthlib/oauth2/rfc6749/endpoints/revocation.py | https://github.com/oauthlib/oauthlib/blob/30321dd3c0ca784d3508a1970cf90d9f76835c79/oauthlib/oauth2/rfc6749/endpoints/revocation.py#L87-L126 | def validate_revocation_request(self, request):
"""Ensure the request is valid.
The client constructs the request by including the following parameters
using the "application/x-www-form-urlencoded" format in the HTTP
request entity-body:
token (REQUIRED). The token that the cl... | [
"def",
"validate_revocation_request",
"(",
"self",
",",
"request",
")",
":",
"self",
".",
"_raise_on_missing_token",
"(",
"request",
")",
"self",
".",
"_raise_on_invalid_client",
"(",
"request",
")",
"self",
".",
"_raise_on_unsupported_token",
"(",
"request",
")"
] | Ensure the request is valid.
The client constructs the request by including the following parameters
using the "application/x-www-form-urlencoded" format in the HTTP
request entity-body:
token (REQUIRED). The token that the client wants to get revoked.
token_type_hint (OPTION... | [
"Ensure",
"the",
"request",
"is",
"valid",
"."
] | python | train | 49.1 |
yvesalexandre/bandicoot | bandicoot/helper/tools.py | https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/helper/tools.py#L210-L234 | def percent_overlapping_calls(records, min_gab=300):
"""
Return the percentage of calls that overlap with the next call.
Parameters
----------
records : list
The records for a single user.
min_gab : int
Number of seconds that the calls must overlap to be considered an issue.
... | [
"def",
"percent_overlapping_calls",
"(",
"records",
",",
"min_gab",
"=",
"300",
")",
":",
"calls",
"=",
"[",
"r",
"for",
"r",
"in",
"records",
"if",
"r",
".",
"interaction",
"==",
"\"call\"",
"]",
"if",
"len",
"(",
"calls",
")",
"==",
"0",
":",
"retu... | Return the percentage of calls that overlap with the next call.
Parameters
----------
records : list
The records for a single user.
min_gab : int
Number of seconds that the calls must overlap to be considered an issue.
Defaults to 5 minutes. | [
"Return",
"the",
"percentage",
"of",
"calls",
"that",
"overlap",
"with",
"the",
"next",
"call",
"."
] | python | train | 28.72 |
facetoe/zenpy | zenpy/__init__.py | https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/__init__.py#L210-L214 | def set_cache_implementation(self, cache_name, impl_name, maxsize, **kwargs):
"""
Changes the cache implementation for the named cache
"""
self._get_cache(cache_name).set_cache_impl(impl_name, maxsize, **kwargs) | [
"def",
"set_cache_implementation",
"(",
"self",
",",
"cache_name",
",",
"impl_name",
",",
"maxsize",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_get_cache",
"(",
"cache_name",
")",
".",
"set_cache_impl",
"(",
"impl_name",
",",
"maxsize",
",",
"*",
"*... | Changes the cache implementation for the named cache | [
"Changes",
"the",
"cache",
"implementation",
"for",
"the",
"named",
"cache"
] | python | train | 47.8 |
pantsbuild/pants | src/python/pants/task/simple_codegen_task.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/task/simple_codegen_task.py#L312-L375 | def _inject_synthetic_target(self, vt, sources):
"""Create, inject, and return a synthetic target for the given target and workdir.
:param vt: A codegen input VersionedTarget to inject a synthetic target for.
:param sources: A FilesetWithSpec to inject for the target.
"""
target = vt.target
# ... | [
"def",
"_inject_synthetic_target",
"(",
"self",
",",
"vt",
",",
"sources",
")",
":",
"target",
"=",
"vt",
".",
"target",
"# NB: For stability, the injected target exposes the stable-symlinked `vt.results_dir`,",
"# rather than the hash-named `vt.current_results_dir`.",
"synthetic_t... | Create, inject, and return a synthetic target for the given target and workdir.
:param vt: A codegen input VersionedTarget to inject a synthetic target for.
:param sources: A FilesetWithSpec to inject for the target. | [
"Create",
"inject",
"and",
"return",
"a",
"synthetic",
"target",
"for",
"the",
"given",
"target",
"and",
"workdir",
"."
] | python | train | 44.375 |
mbrenig/SheetSync | sheetsync/__init__.py | https://github.com/mbrenig/SheetSync/blob/110e10c1f4388a91e5087cba6ea5517e04df8680/sheetsync/__init__.py#L867-L879 | def sync(self, raw_data, row_change_callback=None):
""" Equivalent to the inject method but will delete rows from the
google spreadsheet if their key is not found in the input (raw_data)
dictionary.
Args:
raw_data (dict): See inject method
row_change_... | [
"def",
"sync",
"(",
"self",
",",
"raw_data",
",",
"row_change_callback",
"=",
"None",
")",
":",
"return",
"self",
".",
"_update",
"(",
"raw_data",
",",
"row_change_callback",
",",
"delete_rows",
"=",
"True",
")"
] | Equivalent to the inject method but will delete rows from the
google spreadsheet if their key is not found in the input (raw_data)
dictionary.
Args:
raw_data (dict): See inject method
row_change_callback (Optional) (func): See inject method
Returns:... | [
"Equivalent",
"to",
"the",
"inject",
"method",
"but",
"will",
"delete",
"rows",
"from",
"the",
"google",
"spreadsheet",
"if",
"their",
"key",
"is",
"not",
"found",
"in",
"the",
"input",
"(",
"raw_data",
")",
"dictionary",
".",
"Args",
":",
"raw_data",
"(",... | python | train | 39.923077 |
StorjOld/pyp2p | pyp2p/rendezvous_server.py | https://github.com/StorjOld/pyp2p/blob/7024208c3af20511496a652ff212f54c420e0464/pyp2p/rendezvous_server.py#L151-L177 | def synchronize_simultaneous(self, node_ip):
"""
Because adjacent mappings for certain NAT types can
be stolen by other connections, the purpose of this
function is to ensure the last connection by a passive
simultaneous node is recent compared to the time for
a can... | [
"def",
"synchronize_simultaneous",
"(",
"self",
",",
"node_ip",
")",
":",
"for",
"candidate",
"in",
"self",
".",
"factory",
".",
"candidates",
"[",
"node_ip",
"]",
":",
"# Only if candidate is connected.\r",
"if",
"not",
"candidate",
"[",
"\"con\"",
"]",
".",
... | Because adjacent mappings for certain NAT types can
be stolen by other connections, the purpose of this
function is to ensure the last connection by a passive
simultaneous node is recent compared to the time for
a candidate to increase the chance that the precited
mappings r... | [
"Because",
"adjacent",
"mappings",
"for",
"certain",
"NAT",
"types",
"can",
"be",
"stolen",
"by",
"other",
"connections",
"the",
"purpose",
"of",
"this",
"function",
"is",
"to",
"ensure",
"the",
"last",
"connection",
"by",
"a",
"passive",
"simultaneous",
"node... | python | train | 39.666667 |
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#L905-L931 | def _init_metadata(self):
"""stub"""
DecimalValuesFormRecord._init_metadata(self)
IntegerValuesFormRecord._init_metadata(self)
TextAnswerFormRecord._init_metadata(self)
super(MultiLanguageCalculationInteractionFeedbackAndFilesAnswerFormRecord, self)._init_metadata()
self.... | [
"def",
"_init_metadata",
"(",
"self",
")",
":",
"DecimalValuesFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"IntegerValuesFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"TextAnswerFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"super",
"(",
"... | stub | [
"stub"
] | python | train | 42.222222 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.