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 |
|---|---|---|---|---|---|---|---|---|---|
osrg/ryu | ryu/lib/ovs/vsctl.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/ovs/vsctl.py#L2271-L2279 | def _add(self, ctx, table_name, record_id, column_values):
"""
:type column_values: list of (column, value_json)
"""
vsctl_table = self._get_table(table_name)
ovsrec_row = ctx.must_get_row(vsctl_table, record_id)
for column, value in column_values:
ctx.add_col... | [
"def",
"_add",
"(",
"self",
",",
"ctx",
",",
"table_name",
",",
"record_id",
",",
"column_values",
")",
":",
"vsctl_table",
"=",
"self",
".",
"_get_table",
"(",
"table_name",
")",
"ovsrec_row",
"=",
"ctx",
".",
"must_get_row",
"(",
"vsctl_table",
",",
"rec... | :type column_values: list of (column, value_json) | [
":",
"type",
"column_values",
":",
"list",
"of",
"(",
"column",
"value_json",
")"
] | python | train | 41.444444 |
fp12/achallonge | challonge/tournament.py | https://github.com/fp12/achallonge/blob/25780b3c48b66400a50ff9f884e4287afd4c89e4/challonge/tournament.py#L553-L575 | async def search_participant(self, name, force_update=False):
""" search a participant by (display) name
|methcoro|
Args:
name: display name of the participant
force_update (dfault=False): True to force an update to the Challonge API
Returns:
Partic... | [
"async",
"def",
"search_participant",
"(",
"self",
",",
"name",
",",
"force_update",
"=",
"False",
")",
":",
"if",
"force_update",
"or",
"self",
".",
"participants",
"is",
"None",
":",
"await",
"self",
".",
"get_participants",
"(",
")",
"if",
"self",
".",
... | search a participant by (display) name
|methcoro|
Args:
name: display name of the participant
force_update (dfault=False): True to force an update to the Challonge API
Returns:
Participant: None if not found
Raises:
APIException | [
"search",
"a",
"participant",
"by",
"(",
"display",
")",
"name"
] | python | train | 27.782609 |
ansible/ansible-container | container/utils/_text.py | https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/utils/_text.py#L52-L163 | def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
"""Make sure that a string is a byte string
:arg obj: An object to make sure is a byte string. In most cases this
will be either a text string or a byte string. However, with
``nonstring='simplerepr'``, this can be used... | [
"def",
"to_bytes",
"(",
"obj",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"None",
",",
"nonstring",
"=",
"'simplerepr'",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"binary_type",
")",
":",
"return",
"obj",
"# We're given a text string",
"# If i... | Make sure that a string is a byte string
:arg obj: An object to make sure is a byte string. In most cases this
will be either a text string or a byte string. However, with
``nonstring='simplerepr'``, this can be used as a traceback-free
version of ``str(obj)``.
:kwarg encoding: The en... | [
"Make",
"sure",
"that",
"a",
"string",
"is",
"a",
"byte",
"string"
] | python | train | 44.544643 |
roclark/sportsreference | sportsreference/nba/roster.py | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/roster.py#L366-L387 | def _parse_contract_headers(self, table):
"""
Parse the years on the contract.
The years are listed as the headers on the contract. The first header
contains 'Team' which specifies the player's current team and should
not be included in the years.
Parameters
---... | [
"def",
"_parse_contract_headers",
"(",
"self",
",",
"table",
")",
":",
"years",
"=",
"[",
"i",
".",
"text",
"(",
")",
"for",
"i",
"in",
"table",
"(",
"'th'",
")",
".",
"items",
"(",
")",
"]",
"years",
".",
"remove",
"(",
"'Team'",
")",
"return",
... | Parse the years on the contract.
The years are listed as the headers on the contract. The first header
contains 'Team' which specifies the player's current team and should
not be included in the years.
Parameters
----------
table : PyQuery object
A PyQuery o... | [
"Parse",
"the",
"years",
"on",
"the",
"contract",
"."
] | python | train | 30.5 |
googledatalab/pydatalab | datalab/bigquery/_api.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L465-L477 | def table_delete(self, table_name):
"""Issues a request to delete a table.
Args:
table_name: the name of the table as a tuple of components.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation.
"""
url = Api._ENDPOINT + (Api._TABLES... | [
"def",
"table_delete",
"(",
"self",
",",
"table_name",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_TABLES_PATH",
"%",
"table_name",
")",
"return",
"datalab",
".",
"utils",
".",
"Http",
".",
"request",
"(",
"url",
",",
"method... | Issues a request to delete a table.
Args:
table_name: the name of the table as a tuple of components.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation. | [
"Issues",
"a",
"request",
"to",
"delete",
"a",
"table",
"."
] | python | train | 36.538462 |
psss/did | did/stats.py | https://github.com/psss/did/blob/04e4ee6f1aa14c0cae3ba9f9803871f3f98279cb/did/stats.py#L59-L68 | def enabled(self):
""" Check whether we're enabled (or if parent is). """
# Cache into ._enabled
if self._enabled is None:
if self.parent is not None and self.parent.enabled():
self._enabled = True
else:
# Default to Enabled if not otherwis... | [
"def",
"enabled",
"(",
"self",
")",
":",
"# Cache into ._enabled",
"if",
"self",
".",
"_enabled",
"is",
"None",
":",
"if",
"self",
".",
"parent",
"is",
"not",
"None",
"and",
"self",
".",
"parent",
".",
"enabled",
"(",
")",
":",
"self",
".",
"_enabled",... | Check whether we're enabled (or if parent is). | [
"Check",
"whether",
"we",
"re",
"enabled",
"(",
"or",
"if",
"parent",
"is",
")",
"."
] | python | train | 42.1 |
jalanb/pysyte | pysyte/bash/git.py | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L299-L305 | def add(path=None, force=False, quiet=False):
"""Add that path to git's staging area (default current dir)
so that it will be included in next commit
"""
option = '-f' if force else ''
return run('add %s %s' % (option, path) or '.', quiet=quiet) | [
"def",
"add",
"(",
"path",
"=",
"None",
",",
"force",
"=",
"False",
",",
"quiet",
"=",
"False",
")",
":",
"option",
"=",
"'-f'",
"if",
"force",
"else",
"''",
"return",
"run",
"(",
"'add %s %s'",
"%",
"(",
"option",
",",
"path",
")",
"or",
"'.'",
... | Add that path to git's staging area (default current dir)
so that it will be included in next commit | [
"Add",
"that",
"path",
"to",
"git",
"s",
"staging",
"area",
"(",
"default",
"current",
"dir",
")"
] | python | train | 37.142857 |
housecanary/hc-api-python | housecanary/excel/analytics_data_excel.py | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/excel/analytics_data_excel.py#L70-L106 | def write_worksheets(workbook, data_list, result_info_key, identifier_keys):
"""Writes rest of the worksheets to workbook.
Args:
workbook: workbook to write into
data_list: Analytics API data as a list of dicts
result_info_key: the key in api_data dicts that contains the data results
... | [
"def",
"write_worksheets",
"(",
"workbook",
",",
"data_list",
",",
"result_info_key",
",",
"identifier_keys",
")",
":",
"# we can use the first item to figure out the worksheet keys",
"worksheet_keys",
"=",
"get_worksheet_keys",
"(",
"data_list",
"[",
"0",
"]",
",",
"resu... | Writes rest of the worksheets to workbook.
Args:
workbook: workbook to write into
data_list: Analytics API data as a list of dicts
result_info_key: the key in api_data dicts that contains the data results
identifier_keys: the list of keys used as requested identifiers
... | [
"Writes",
"rest",
"of",
"the",
"worksheets",
"to",
"workbook",
"."
] | python | train | 37.567568 |
PiotrDabkowski/Js2Py | js2py/legecy_translators/flow.py | https://github.com/PiotrDabkowski/Js2Py/blob/c0fa43f5679cf91ca8986c5747fcb07a433dc584/js2py/legecy_translators/flow.py#L74-L99 | def do_statement(source, start):
"""returns none if not found other functions that begin with 'do_' raise
also this do_ type function passes white space"""
start = pass_white(source, start)
# start is the fist position after initial start that is not a white space or \n
if not start < len(source): ... | [
"def",
"do_statement",
"(",
"source",
",",
"start",
")",
":",
"start",
"=",
"pass_white",
"(",
"source",
",",
"start",
")",
"# start is the fist position after initial start that is not a white space or \\n",
"if",
"not",
"start",
"<",
"len",
"(",
"source",
")",
":"... | returns none if not found other functions that begin with 'do_' raise
also this do_ type function passes white space | [
"returns",
"none",
"if",
"not",
"found",
"other",
"functions",
"that",
"begin",
"with",
"do_",
"raise",
"also",
"this",
"do_",
"type",
"function",
"passes",
"white",
"space"
] | python | valid | 50.461538 |
bakwc/PySyncObj | pysyncobj/transport.py | https://github.com/bakwc/PySyncObj/blob/be3b0aaa932d5156f5df140c23c962430f51b7b8/pysyncobj/transport.py#L393-L409 | def _connectIfNecessarySingle(self, node):
"""
Connect to a node if necessary.
:param node: node to connect to
:type node: Node
"""
if node in self._connections and self._connections[node].state != CONNECTION_STATE.DISCONNECTED:
return True
if not se... | [
"def",
"_connectIfNecessarySingle",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
"in",
"self",
".",
"_connections",
"and",
"self",
".",
"_connections",
"[",
"node",
"]",
".",
"state",
"!=",
"CONNECTION_STATE",
".",
"DISCONNECTED",
":",
"return",
"True",... | Connect to a node if necessary.
:param node: node to connect to
:type node: Node | [
"Connect",
"to",
"a",
"node",
"if",
"necessary",
"."
] | python | test | 45.705882 |
divio/python-mautic | mautic/emails.py | https://github.com/divio/python-mautic/blob/1fbff629070200002373c5e94c75e01561df418a/mautic/emails.py#L10-L22 | def send(self, obj_id):
"""
Send email to the assigned lists
:param obj_id: int
:return: dict|str
"""
response = self._client.session.post(
'{url}/{id}/send'.format(
url=self.endpoint_url, id=obj_id
)
)
return self.... | [
"def",
"send",
"(",
"self",
",",
"obj_id",
")",
":",
"response",
"=",
"self",
".",
"_client",
".",
"session",
".",
"post",
"(",
"'{url}/{id}/send'",
".",
"format",
"(",
"url",
"=",
"self",
".",
"endpoint_url",
",",
"id",
"=",
"obj_id",
")",
")",
"ret... | Send email to the assigned lists
:param obj_id: int
:return: dict|str | [
"Send",
"email",
"to",
"the",
"assigned",
"lists"
] | python | train | 25.692308 |
teepark/greenhouse | greenhouse/io/files.py | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/files.py#L364-L384 | def seek(self, position, modifier=0):
"""move the cursor on the file descriptor to a different location
:param position:
an integer offset from the location indicated by the modifier
:type position: int
:param modifier:
an indicator of how to find the seek locati... | [
"def",
"seek",
"(",
"self",
",",
"position",
",",
"modifier",
"=",
"0",
")",
":",
"os",
".",
"lseek",
"(",
"self",
".",
"_fileno",
",",
"position",
",",
"modifier",
")",
"# clear out the buffer",
"buf",
"=",
"self",
".",
"_rbuf",
"buf",
".",
"seek",
... | move the cursor on the file descriptor to a different location
:param position:
an integer offset from the location indicated by the modifier
:type position: int
:param modifier:
an indicator of how to find the seek location.
- ``os.SEEK_SET`` means start fr... | [
"move",
"the",
"cursor",
"on",
"the",
"file",
"descriptor",
"to",
"a",
"different",
"location"
] | python | train | 34.47619 |
postlund/pyatv | pyatv/conf.py | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/conf.py#L130-L140 | def superseeded_by(self, other_service):
"""Return True if input service has login id and this has not."""
if not other_service or \
other_service.__class__ != self.__class__ or \
other_service.protocol != self.protocol or \
other_service.port != self.port... | [
"def",
"superseeded_by",
"(",
"self",
",",
"other_service",
")",
":",
"if",
"not",
"other_service",
"or",
"other_service",
".",
"__class__",
"!=",
"self",
".",
"__class__",
"or",
"other_service",
".",
"protocol",
"!=",
"self",
".",
"protocol",
"or",
"other_ser... | Return True if input service has login id and this has not. | [
"Return",
"True",
"if",
"input",
"service",
"has",
"login",
"id",
"and",
"this",
"has",
"not",
"."
] | python | train | 48.545455 |
Yinzo/reprint | reprint/reprint.py | https://github.com/Yinzo/reprint/blob/5bf4129ad7da4086fdb07493e46afabb5fb08e93/reprint/reprint.py#L110-L126 | def lines_of_content(content, width):
"""
计算内容在特定输出宽度下实际显示的行数
calculate the actual rows with specific terminal width
"""
result = 0
if isinstance(content, list):
for line in content:
_line = preprocess(line)
result += ceil(line_width(_line) / width)
elif isins... | [
"def",
"lines_of_content",
"(",
"content",
",",
"width",
")",
":",
"result",
"=",
"0",
"if",
"isinstance",
"(",
"content",
",",
"list",
")",
":",
"for",
"line",
"in",
"content",
":",
"_line",
"=",
"preprocess",
"(",
"line",
")",
"result",
"+=",
"ceil",... | 计算内容在特定输出宽度下实际显示的行数
calculate the actual rows with specific terminal width | [
"计算内容在特定输出宽度下实际显示的行数",
"calculate",
"the",
"actual",
"rows",
"with",
"specific",
"terminal",
"width"
] | python | train | 34.941176 |
ceph/ceph-deploy | ceph_deploy/hosts/remotes.py | https://github.com/ceph/ceph-deploy/blob/86943fcc454cd4c99a86e3493e9e93a59c661fef/ceph_deploy/hosts/remotes.py#L401-L407 | def enable_yum_priority_obsoletes(path="/etc/yum/pluginconf.d/priorities.conf"):
"""Configure Yum priorities to include obsoletes"""
config = configparser.ConfigParser()
config.read(path)
config.set('main', 'check_obsoletes', '1')
with open(path, 'w') as fout:
config.write(fout) | [
"def",
"enable_yum_priority_obsoletes",
"(",
"path",
"=",
"\"/etc/yum/pluginconf.d/priorities.conf\"",
")",
":",
"config",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"config",
".",
"read",
"(",
"path",
")",
"config",
".",
"set",
"(",
"'main'",
",",
"'ch... | Configure Yum priorities to include obsoletes | [
"Configure",
"Yum",
"priorities",
"to",
"include",
"obsoletes"
] | python | train | 43 |
pyviz/holoviews | holoviews/plotting/bokeh/callbacks.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/bokeh/callbacks.py#L322-L330 | def on_change(self, attr, old, new):
"""
Process change events adding timeout to process multiple concerted
value change at once rather than firing off multiple plot updates.
"""
self._queue.append((attr, old, new))
if not self._active and self.plot.document:
... | [
"def",
"on_change",
"(",
"self",
",",
"attr",
",",
"old",
",",
"new",
")",
":",
"self",
".",
"_queue",
".",
"append",
"(",
"(",
"attr",
",",
"old",
",",
"new",
")",
")",
"if",
"not",
"self",
".",
"_active",
"and",
"self",
".",
"plot",
".",
"doc... | Process change events adding timeout to process multiple concerted
value change at once rather than firing off multiple plot updates. | [
"Process",
"change",
"events",
"adding",
"timeout",
"to",
"process",
"multiple",
"concerted",
"value",
"change",
"at",
"once",
"rather",
"than",
"firing",
"off",
"multiple",
"plot",
"updates",
"."
] | python | train | 45.666667 |
envi-idl/envipyarclib | envipyarclib/gptool/parameter/builder.py | https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/gptool/parameter/builder.py#L207-L229 | def create_pre_execute(task_params, parameter_map):
"""
Builds the code block for the GPTool Execute method before the job is
submitted based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GP... | [
"def",
"create_pre_execute",
"(",
"task_params",
",",
"parameter_map",
")",
":",
"gp_params",
"=",
"[",
"_PRE_EXECUTE_INIT_TEMPLATE",
"]",
"for",
"task_param",
"in",
"task_params",
":",
"if",
"task_param",
"[",
"'direction'",
"]",
".",
"upper",
"(",
")",
"==",
... | Builds the code block for the GPTool Execute method before the job is
submitted based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GPTool Execute method. | [
"Builds",
"the",
"code",
"block",
"for",
"the",
"GPTool",
"Execute",
"method",
"before",
"the",
"job",
"is",
"submitted",
"based",
"on",
"the",
"input",
"task_params",
"."
] | python | train | 36.73913 |
korfuri/django-prometheus | django_prometheus/models.py | https://github.com/korfuri/django-prometheus/blob/c3a19ce46d812f76d9316e50a232878c27c9bdf5/django_prometheus/models.py#L19-L44 | def ExportModelOperationsMixin(model_name):
"""Returns a mixin for models to export counters for lifecycle operations.
Usage:
class User(ExportModelOperationsMixin('user'), Model):
...
"""
# Force create the labels for this model in the counters. This
# is not necessary but it avoid... | [
"def",
"ExportModelOperationsMixin",
"(",
"model_name",
")",
":",
"# Force create the labels for this model in the counters. This",
"# is not necessary but it avoids gaps in the aggregated data.",
"model_inserts",
".",
"labels",
"(",
"model_name",
")",
"model_updates",
".",
"labels",... | Returns a mixin for models to export counters for lifecycle operations.
Usage:
class User(ExportModelOperationsMixin('user'), Model):
... | [
"Returns",
"a",
"mixin",
"for",
"models",
"to",
"export",
"counters",
"for",
"lifecycle",
"operations",
"."
] | python | train | 37.115385 |
tanghaibao/jcvi | jcvi/apps/lastz.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/lastz.py#L47-L66 | def lastz_to_blast(row):
"""
Convert the lastz tabular to the blast tabular, see headers above
Obsolete after LASTZ version 1.02.40
"""
atoms = row.strip().split("\t")
name1, name2, coverage, identity, nmismatch, ngap, \
start1, end1, strand1, start2, end2, strand2, score = atoms
... | [
"def",
"lastz_to_blast",
"(",
"row",
")",
":",
"atoms",
"=",
"row",
".",
"strip",
"(",
")",
".",
"split",
"(",
"\"\\t\"",
")",
"name1",
",",
"name2",
",",
"coverage",
",",
"identity",
",",
"nmismatch",
",",
"ngap",
",",
"start1",
",",
"end1",
",",
... | Convert the lastz tabular to the blast tabular, see headers above
Obsolete after LASTZ version 1.02.40 | [
"Convert",
"the",
"lastz",
"tabular",
"to",
"the",
"blast",
"tabular",
"see",
"headers",
"above",
"Obsolete",
"after",
"LASTZ",
"version",
"1",
".",
"02",
".",
"40"
] | python | train | 38.9 |
JoseAntFer/pyny3d | pyny3d/geoms.py | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L2437-L2503 | def shadows(self, data=None, t=None, dt=None, latitude=None,
init='empty', resolution='mid'):
'''
Initializes a ShadowManager object for this ``pyny.Space``
instance.
The 'empty' initialization accepts ``data`` and ``t`` and ``dt``
but the Shadows... | [
"def",
"shadows",
"(",
"self",
",",
"data",
"=",
"None",
",",
"t",
"=",
"None",
",",
"dt",
"=",
"None",
",",
"latitude",
"=",
"None",
",",
"init",
"=",
"'empty'",
",",
"resolution",
"=",
"'mid'",
")",
":",
"from",
"pyny3d",
".",
"shadows",
"import"... | Initializes a ShadowManager object for this ``pyny.Space``
instance.
The 'empty' initialization accepts ``data`` and ``t`` and ``dt``
but the ShadowsManager will not start the calculations. It will
wait the user to manually insert the rest of the parameters.
Call ... | [
"Initializes",
"a",
"ShadowManager",
"object",
"for",
"this",
"pyny",
".",
"Space",
"instance",
".",
"The",
"empty",
"initialization",
"accepts",
"data",
"and",
"t",
"and",
"dt",
"but",
"the",
"ShadowsManager",
"will",
"not",
"start",
"the",
"calculations",
".... | python | train | 40 |
jjjake/iamine | iamine/core.py | https://github.com/jjjake/iamine/blob/f1fc123a5b40b2247c537382368d38bd744eebe0/iamine/core.py#L214-L261 | def search_requests(self, query=None, params=None, callback=None, mine_ids=None):
"""Mine Archive.org search results.
:param query: The Archive.org search query to yield results for.
Refer to https://archive.org/advancedsearch.php#raw
for help formatting your... | [
"def",
"search_requests",
"(",
"self",
",",
"query",
"=",
"None",
",",
"params",
"=",
"None",
",",
"callback",
"=",
"None",
",",
"mine_ids",
"=",
"None",
")",
":",
"# If mining ids, devote half the workers to search and half to item mining.",
"if",
"mine_ids",
":",
... | Mine Archive.org search results.
:param query: The Archive.org search query to yield results for.
Refer to https://archive.org/advancedsearch.php#raw
for help formatting your query.
:type query: str
:param params: The URL parameters to send with each... | [
"Mine",
"Archive",
".",
"org",
"search",
"results",
"."
] | python | train | 45.395833 |
estnltk/estnltk | estnltk/converters/gt_conversion.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/converters/gt_conversion.py#L390-L431 | def convert_to_gt( text, layer_name=GT_WORDS ):
''' Converts all words in a morphologically analysed Text from FS format to
giellatekno (GT) format, and stores in a new layer named GT_WORDS.
If the keyword argument *layer_name=='words'* , overwrites the old 'words'
layer with the new laye... | [
"def",
"convert_to_gt",
"(",
"text",
",",
"layer_name",
"=",
"GT_WORDS",
")",
":",
"assert",
"WORDS",
"in",
"text",
",",
"'(!) The input text should contain \"'",
"+",
"str",
"(",
"WORDS",
")",
"+",
"'\" layer.'",
"assert",
"len",
"(",
"text",
"[",
"WORDS",
... | Converts all words in a morphologically analysed Text from FS format to
giellatekno (GT) format, and stores in a new layer named GT_WORDS.
If the keyword argument *layer_name=='words'* , overwrites the old 'words'
layer with the new layer containing GT format annotations.
Parameters... | [
"Converts",
"all",
"words",
"in",
"a",
"morphologically",
"analysed",
"Text",
"from",
"FS",
"format",
"to",
"giellatekno",
"(",
"GT",
")",
"format",
"and",
"stores",
"in",
"a",
"new",
"layer",
"named",
"GT_WORDS",
".",
"If",
"the",
"keyword",
"argument",
"... | python | train | 44.452381 |
yjzhang/uncurl_python | uncurl/nmf_wrapper.py | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nmf_wrapper.py#L10-L48 | def nmf_init(data, clusters, k, init='enhanced'):
"""
Generates initial M and W given a data set and an array of cluster labels.
There are 3 options for init:
enhanced - uses EIn-NMF from Gong 2013
basic - uses means for M, assigns W such that the chosen cluster for a given cell has value 0... | [
"def",
"nmf_init",
"(",
"data",
",",
"clusters",
",",
"k",
",",
"init",
"=",
"'enhanced'",
")",
":",
"init_m",
"=",
"np",
".",
"zeros",
"(",
"(",
"data",
".",
"shape",
"[",
"0",
"]",
",",
"k",
")",
")",
"if",
"sparse",
".",
"issparse",
"(",
"da... | Generates initial M and W given a data set and an array of cluster labels.
There are 3 options for init:
enhanced - uses EIn-NMF from Gong 2013
basic - uses means for M, assigns W such that the chosen cluster for a given cell has value 0.75 and all others have 0.25/(k-1).
nmf - uses means f... | [
"Generates",
"initial",
"M",
"and",
"W",
"given",
"a",
"data",
"set",
"and",
"an",
"array",
"of",
"cluster",
"labels",
"."
] | python | train | 45.179487 |
shaldengeki/python-mal | myanimelist/manga.py | https://github.com/shaldengeki/python-mal/blob/2c3356411a74d88ba13f6b970388040d696f8392/myanimelist/manga.py#L48-L150 | def parse_sidebar(self, manga_page):
"""Parses the DOM and returns manga attributes in the sidebar.
:type manga_page: :class:`bs4.BeautifulSoup`
:param manga_page: MAL manga page's DOM
:rtype: dict
:return: manga attributes
:raises: :class:`.InvalidMangaError`, :class:`.MalformedMangaPageErro... | [
"def",
"parse_sidebar",
"(",
"self",
",",
"manga_page",
")",
":",
"# if MAL says the series doesn't exist, raise an InvalidMangaError.",
"error_tag",
"=",
"manga_page",
".",
"find",
"(",
"u'div'",
",",
"{",
"'class'",
":",
"'badresult'",
"}",
")",
"if",
"error_tag",
... | Parses the DOM and returns manga attributes in the sidebar.
:type manga_page: :class:`bs4.BeautifulSoup`
:param manga_page: MAL manga page's DOM
:rtype: dict
:return: manga attributes
:raises: :class:`.InvalidMangaError`, :class:`.MalformedMangaPageError` | [
"Parses",
"the",
"DOM",
"and",
"returns",
"manga",
"attributes",
"in",
"the",
"sidebar",
"."
] | python | train | 41.368932 |
inasafe/inasafe | safe/utilities/gis.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/gis.py#L56-L92 | def extent_to_array(extent, source_crs, dest_crs=None):
"""Convert the supplied extent to geographic and return as an array.
:param extent: Rectangle defining a spatial extent in any CRS.
:type extent: QgsRectangle
:param source_crs: Coordinate system used for input extent.
:type source_crs: QgsCo... | [
"def",
"extent_to_array",
"(",
"extent",
",",
"source_crs",
",",
"dest_crs",
"=",
"None",
")",
":",
"if",
"dest_crs",
"is",
"None",
":",
"geo_crs",
"=",
"QgsCoordinateReferenceSystem",
"(",
")",
"geo_crs",
".",
"createFromSrid",
"(",
"4326",
")",
"else",
":"... | Convert the supplied extent to geographic and return as an array.
:param extent: Rectangle defining a spatial extent in any CRS.
:type extent: QgsRectangle
:param source_crs: Coordinate system used for input extent.
:type source_crs: QgsCoordinateReferenceSystem
:param dest_crs: Coordinate system... | [
"Convert",
"the",
"supplied",
"extent",
"to",
"geographic",
"and",
"return",
"as",
"an",
"array",
"."
] | python | train | 32.567568 |
KelSolaar/Umbra | umbra/components/factory/script_editor/script_editor.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/components/factory/script_editor/script_editor.py#L1620-L1808 | def __initialize_menu_bar(self):
"""
Initializes Component menu_bar.
"""
self.__file_menu = QMenu("&File", parent=self.__menu_bar)
self.__file_menu.addAction(self.__engine.actions_manager.register_action(
"Actions|Umbra|Components|factory.script_editor|&File|&New",
... | [
"def",
"__initialize_menu_bar",
"(",
"self",
")",
":",
"self",
".",
"__file_menu",
"=",
"QMenu",
"(",
"\"&File\"",
",",
"parent",
"=",
"self",
".",
"__menu_bar",
")",
"self",
".",
"__file_menu",
".",
"addAction",
"(",
"self",
".",
"__engine",
".",
"actions... | Initializes Component menu_bar. | [
"Initializes",
"Component",
"menu_bar",
"."
] | python | train | 62.063492 |
woolfson-group/isambard | isambard/ampal/pdb_parser.py | https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/pdb_parser.py#L248-L262 | def proc_state(self, state_data, state_id):
"""Processes a state into an `Assembly`.
Parameters
----------
state_data : dict
Contains information about the state, including all
the per line structural data.
state_id : str
ID given to `Assembly... | [
"def",
"proc_state",
"(",
"self",
",",
"state_data",
",",
"state_id",
")",
":",
"assembly",
"=",
"Assembly",
"(",
"assembly_id",
"=",
"state_id",
")",
"for",
"k",
",",
"chain",
"in",
"sorted",
"(",
"state_data",
".",
"items",
"(",
")",
")",
":",
"assem... | Processes a state into an `Assembly`.
Parameters
----------
state_data : dict
Contains information about the state, including all
the per line structural data.
state_id : str
ID given to `Assembly` that represents the state. | [
"Processes",
"a",
"state",
"into",
"an",
"Assembly",
"."
] | python | train | 36.333333 |
consbio/parserutils | parserutils/elements.py | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L480-L497 | def set_element_attributes(elem_to_parse, **attrib_kwargs):
"""
Adds the specified key/value pairs to the element's attributes, and
returns the updated set of attributes.
If the element already contains any of the attributes specified in
attrib_kwargs, they are updated accordingly.
"""
ele... | [
"def",
"set_element_attributes",
"(",
"elem_to_parse",
",",
"*",
"*",
"attrib_kwargs",
")",
":",
"element",
"=",
"get_element",
"(",
"elem_to_parse",
")",
"if",
"element",
"is",
"None",
":",
"return",
"element",
"if",
"len",
"(",
"attrib_kwargs",
")",
":",
"... | Adds the specified key/value pairs to the element's attributes, and
returns the updated set of attributes.
If the element already contains any of the attributes specified in
attrib_kwargs, they are updated accordingly. | [
"Adds",
"the",
"specified",
"key",
"/",
"value",
"pairs",
"to",
"the",
"element",
"s",
"attributes",
"and",
"returns",
"the",
"updated",
"set",
"of",
"attributes",
"."
] | python | train | 26.888889 |
PGower/PyCanvas | pycanvas/apis/conversations.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/conversations.py#L19-L76 | def list_conversations(self, filter=None, filter_mode=None, include=None, include_all_conversation_ids=None, interleave_submissions=None, scope=None):
"""
List conversations.
Returns the list of conversations for the current user, most recent ones first.
"""
path = {}
... | [
"def",
"list_conversations",
"(",
"self",
",",
"filter",
"=",
"None",
",",
"filter_mode",
"=",
"None",
",",
"include",
"=",
"None",
",",
"include_all_conversation_ids",
"=",
"None",
",",
"interleave_submissions",
"=",
"None",
",",
"scope",
"=",
"None",
")",
... | List conversations.
Returns the list of conversations for the current user, most recent ones first. | [
"List",
"conversations",
".",
"Returns",
"the",
"list",
"of",
"conversations",
"for",
"the",
"current",
"user",
"most",
"recent",
"ones",
"first",
"."
] | python | train | 50.568966 |
PyCQA/pylint | pylint/checkers/utils.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/utils.py#L398-L411 | def is_ancestor_name(
frame: astroid.node_classes.NodeNG, node: astroid.node_classes.NodeNG
) -> bool:
"""return True if `frame` is an astroid.Class node with `node` in the
subtree of its bases attribute
"""
try:
bases = frame.bases
except AttributeError:
return False
for bas... | [
"def",
"is_ancestor_name",
"(",
"frame",
":",
"astroid",
".",
"node_classes",
".",
"NodeNG",
",",
"node",
":",
"astroid",
".",
"node_classes",
".",
"NodeNG",
")",
"->",
"bool",
":",
"try",
":",
"bases",
"=",
"frame",
".",
"bases",
"except",
"AttributeError... | return True if `frame` is an astroid.Class node with `node` in the
subtree of its bases attribute | [
"return",
"True",
"if",
"frame",
"is",
"an",
"astroid",
".",
"Class",
"node",
"with",
"node",
"in",
"the",
"subtree",
"of",
"its",
"bases",
"attribute"
] | python | test | 29.5 |
hyperledger/indy-sdk | wrappers/python/indy/anoncreds.py | https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/wrappers/python/indy/anoncreds.py#L1073-L1244 | async def prover_create_proof(wallet_handle: int,
proof_req_json: str,
requested_credentials_json: str,
master_secret_name: str,
schemas_json: str,
credential_defs_json: ... | [
"async",
"def",
"prover_create_proof",
"(",
"wallet_handle",
":",
"int",
",",
"proof_req_json",
":",
"str",
",",
"requested_credentials_json",
":",
"str",
",",
"master_secret_name",
":",
"str",
",",
"schemas_json",
":",
"str",
",",
"credential_defs_json",
":",
"st... | Creates a proof according to the given proof request
Either a corresponding credential with optionally revealed attributes or self-attested attribute must be provided
for each requested attribute (see indy_prover_get_credentials_for_pool_req).
A proof request may request multiple credentials from different ... | [
"Creates",
"a",
"proof",
"according",
"to",
"the",
"given",
"proof",
"request",
"Either",
"a",
"corresponding",
"credential",
"with",
"optionally",
"revealed",
"attributes",
"or",
"self",
"-",
"attested",
"attribute",
"must",
"be",
"provided",
"for",
"each",
"re... | python | train | 48.94186 |
ownaginatious/fbchat-archive-parser | fbchat_archive_parser/main.py | https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/main.py#L174-L187 | def messages(path, thread, fmt, nocolor, timezones, utc, noprogress, resolve, directory):
"""
Conversion of Facebook chat history.
"""
with colorize_output(nocolor):
try:
chat_history = _process_history(
path=path, thread=thread, timezones=timezones,
u... | [
"def",
"messages",
"(",
"path",
",",
"thread",
",",
"fmt",
",",
"nocolor",
",",
"timezones",
",",
"utc",
",",
"noprogress",
",",
"resolve",
",",
"directory",
")",
":",
"with",
"colorize_output",
"(",
"nocolor",
")",
":",
"try",
":",
"chat_history",
"=",
... | Conversion of Facebook chat history. | [
"Conversion",
"of",
"Facebook",
"chat",
"history",
"."
] | python | train | 37.714286 |
vberlier/nbtlib | nbtlib/tag.py | https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L118-L121 | def read_string(buff, byteorder='big'):
"""Read a string from a file-like object."""
length = read_numeric(USHORT, buff, byteorder)
return buff.read(length).decode('utf-8') | [
"def",
"read_string",
"(",
"buff",
",",
"byteorder",
"=",
"'big'",
")",
":",
"length",
"=",
"read_numeric",
"(",
"USHORT",
",",
"buff",
",",
"byteorder",
")",
"return",
"buff",
".",
"read",
"(",
"length",
")",
".",
"decode",
"(",
"'utf-8'",
")"
] | Read a string from a file-like object. | [
"Read",
"a",
"string",
"from",
"a",
"file",
"-",
"like",
"object",
"."
] | python | train | 46 |
bodylabs/lace | lace/topology.py | https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L47-L57 | def all_faces_with_verts(self, v_indices, as_boolean=False):
'''
returns all of the faces that contain at least one of the vertices in v_indices
'''
import numpy as np
included_vertices = np.zeros(self.v.shape[0], dtype=bool)
included_vertices[np.array(v_indices, dtype=np... | [
"def",
"all_faces_with_verts",
"(",
"self",
",",
"v_indices",
",",
"as_boolean",
"=",
"False",
")",
":",
"import",
"numpy",
"as",
"np",
"included_vertices",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"v",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",... | returns all of the faces that contain at least one of the vertices in v_indices | [
"returns",
"all",
"of",
"the",
"faces",
"that",
"contain",
"at",
"least",
"one",
"of",
"the",
"vertices",
"in",
"v_indices"
] | python | train | 45.181818 |
radjkarl/imgProcessor | imgProcessor/interpolate/interpolate2dStructuredPointSpreadIDW.py | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredPointSpreadIDW.py#L7-L28 | def interpolate2dStructuredPointSpreadIDW(grid, mask, kernel=15, power=2,
maxIter=1e5, copy=True):
'''
same as interpolate2dStructuredIDW but using the point spread method
this is faster if there are bigger connected masked areas and the border
length is sm... | [
"def",
"interpolate2dStructuredPointSpreadIDW",
"(",
"grid",
",",
"mask",
",",
"kernel",
"=",
"15",
",",
"power",
"=",
"2",
",",
"maxIter",
"=",
"1e5",
",",
"copy",
"=",
"True",
")",
":",
"assert",
"grid",
".",
"shape",
"==",
"mask",
".",
"shape",
",",... | same as interpolate2dStructuredIDW but using the point spread method
this is faster if there are bigger connected masked areas and the border
length is smaller
replace all values in [grid] indicated by [mask]
with the inverse distance weighted interpolation of all values within
px+-kernel
... | [
"same",
"as",
"interpolate2dStructuredIDW",
"but",
"using",
"the",
"point",
"spread",
"method",
"this",
"is",
"faster",
"if",
"there",
"are",
"bigger",
"connected",
"masked",
"areas",
"and",
"the",
"border",
"length",
"is",
"smaller",
"replace",
"all",
"values",... | python | train | 41.818182 |
usc-isi-i2/dig-extractor | digExtractor/extractor.py | https://github.com/usc-isi-i2/dig-extractor/blob/87c138e0300d77e35ebeb5f5e9488c3d71e60eb3/digExtractor/extractor.py#L36-L43 | def set_renamed_input_fields(self, renamed_input_fields):
"""This method expects a scalar string or a list of input_fields
to """
if not (isinstance(renamed_input_fields, basestring) or
isinstance(renamed_input_fields, ListType)):
raise ValueError("renamed_input_field... | [
"def",
"set_renamed_input_fields",
"(",
"self",
",",
"renamed_input_fields",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"renamed_input_fields",
",",
"basestring",
")",
"or",
"isinstance",
"(",
"renamed_input_fields",
",",
"ListType",
")",
")",
":",
"raise",
... | This method expects a scalar string or a list of input_fields
to | [
"This",
"method",
"expects",
"a",
"scalar",
"string",
"or",
"a",
"list",
"of",
"input_fields",
"to"
] | python | train | 52.5 |
vxgmichel/aiostream | aiostream/stream/aggregate.py | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/aggregate.py#L56-L62 | async def list(source):
"""Generate a single list from an asynchronous sequence."""
result = []
async with streamcontext(source) as streamer:
async for item in streamer:
result.append(item)
yield result | [
"async",
"def",
"list",
"(",
"source",
")",
":",
"result",
"=",
"[",
"]",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",
"async",
"for",
"item",
"in",
"streamer",
":",
"result",
".",
"append",
"(",
"item",
")",
"yield",
... | Generate a single list from an asynchronous sequence. | [
"Generate",
"a",
"single",
"list",
"from",
"an",
"asynchronous",
"sequence",
"."
] | python | train | 33.142857 |
alfred82santa/dirty-models | dirty_models/model_types.py | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L11-L25 | def modified_data_decorator(function):
"""
Decorator to initialise the modified_data if necessary. To be used in list functions
to modify the list
"""
@wraps(function)
def func(self, *args, **kwargs):
"""Decorator function"""
if not self.get_read_only() or not self.is_locked():
... | [
"def",
"modified_data_decorator",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"func",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Decorator function\"\"\"",
"if",
"not",
"self",
".",
"get_read_only",
"... | Decorator to initialise the modified_data if necessary. To be used in list functions
to modify the list | [
"Decorator",
"to",
"initialise",
"the",
"modified_data",
"if",
"necessary",
".",
"To",
"be",
"used",
"in",
"list",
"functions",
"to",
"modify",
"the",
"list"
] | python | train | 29.666667 |
fracpete/python-weka-wrapper3 | python/weka/core/database.py | https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/database.py#L132-L140 | def custom_properties(self, props):
"""
Sets the custom properties file to use.
:param props: the props file
:type props: str
"""
fprops = javabridge.make_instance("java/io/File", "(Ljava/lang/String;)V", props)
javabridge.call(self.jobject, "setCustomPropsFile",... | [
"def",
"custom_properties",
"(",
"self",
",",
"props",
")",
":",
"fprops",
"=",
"javabridge",
".",
"make_instance",
"(",
"\"java/io/File\"",
",",
"\"(Ljava/lang/String;)V\"",
",",
"props",
")",
"javabridge",
".",
"call",
"(",
"self",
".",
"jobject",
",",
"\"se... | Sets the custom properties file to use.
:param props: the props file
:type props: str | [
"Sets",
"the",
"custom",
"properties",
"file",
"to",
"use",
"."
] | python | train | 37.888889 |
timothydmorton/isochrones | isochrones/mist/utils.py | https://github.com/timothydmorton/isochrones/blob/d84495573044c66db2fd6b959fe69e370757ea14/isochrones/mist/utils.py#L155-L234 | def interp_value(mass, age, feh, icol,
grid, mass_col, ages, fehs, grid_Ns):
# return_box):
"""mass, age, feh are *single values* at which values are desired
icol is the column index of desired value
grid is nfeh x nage x max(nmass) x ncols array
mass_col is the colum... | [
"def",
"interp_value",
"(",
"mass",
",",
"age",
",",
"feh",
",",
"icol",
",",
"grid",
",",
"mass_col",
",",
"ages",
",",
"fehs",
",",
"grid_Ns",
")",
":",
"# return_box):",
"Nage",
"=",
"len",
"(",
"ages",
")",
"Nfeh",
"=",
"len",
"(",
"fehs",
")",... | mass, age, feh are *single values* at which values are desired
icol is the column index of desired value
grid is nfeh x nage x max(nmass) x ncols array
mass_col is the column index of mass
ages is grid of ages
fehs is grid of fehs
grid_Ns keeps track of nmass in each slice (beyond this are nans... | [
"mass",
"age",
"feh",
"are",
"*",
"single",
"values",
"*",
"at",
"which",
"values",
"are",
"desired"
] | python | train | 29.575 |
numberoverzero/bloop | bloop/conditions.py | https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/conditions.py#L388-L396 | def rendered(self):
"""The rendered wire format for all conditions that have been rendered. Rendered conditions are never
cleared. A new :class:`~bloop.conditions.ConditionRenderer` should be used for each operation."""
expressions = {k: v for (k, v) in self.expressions.items() if v is not Non... | [
"def",
"rendered",
"(",
"self",
")",
":",
"expressions",
"=",
"{",
"k",
":",
"v",
"for",
"(",
"k",
",",
"v",
")",
"in",
"self",
".",
"expressions",
".",
"items",
"(",
")",
"if",
"v",
"is",
"not",
"None",
"}",
"if",
"self",
".",
"refs",
".",
"... | The rendered wire format for all conditions that have been rendered. Rendered conditions are never
cleared. A new :class:`~bloop.conditions.ConditionRenderer` should be used for each operation. | [
"The",
"rendered",
"wire",
"format",
"for",
"all",
"conditions",
"that",
"have",
"been",
"rendered",
".",
"Rendered",
"conditions",
"are",
"never",
"cleared",
".",
"A",
"new",
":",
"class",
":",
"~bloop",
".",
"conditions",
".",
"ConditionRenderer",
"should",
... | python | train | 62.222222 |
guaix-ucm/numina | numina/array/wavecalib/__main__.py | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/__main__.py#L382-L499 | def wvcal_spectrum(sp, fxpeaks, poly_degree_wfit, wv_master,
wv_ini_search=None, wv_end_search=None,
wvmin_useful=None, wvmax_useful=None,
geometry=None, debugplot=0):
"""Execute wavelength calibration of a spectrum using fixed line peaks.
Parameters
... | [
"def",
"wvcal_spectrum",
"(",
"sp",
",",
"fxpeaks",
",",
"poly_degree_wfit",
",",
"wv_master",
",",
"wv_ini_search",
"=",
"None",
",",
"wv_end_search",
"=",
"None",
",",
"wvmin_useful",
"=",
"None",
",",
"wvmax_useful",
"=",
"None",
",",
"geometry",
"=",
"No... | Execute wavelength calibration of a spectrum using fixed line peaks.
Parameters
----------
sp : 1d numpy array
Spectrum to be wavelength calibrated.
fxpeaks : 1d numpy array
Refined location of peaks in array index scale, i.e, from 0
to naxis1 - 1. The wavelength calibration is ... | [
"Execute",
"wavelength",
"calibration",
"of",
"a",
"spectrum",
"using",
"fixed",
"line",
"peaks",
"."
] | python | train | 33.694915 |
rnwolf/jira-metrics-extract | jira_metrics_extract/query.py | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/query.py#L139-L183 | def iter_size_changes(self, issue):
"""Yield an IssueSnapshot for each time the issue size changed
"""
# Find the first size change, if any
try:
size_changes = list(filter(lambda h: h.field == 'Story Points',
itertools.chain.from_iterab... | [
"def",
"iter_size_changes",
"(",
"self",
",",
"issue",
")",
":",
"# Find the first size change, if any",
"try",
":",
"size_changes",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"h",
":",
"h",
".",
"field",
"==",
"'Story Points'",
",",
"itertools",
".",
"chain",... | Yield an IssueSnapshot for each time the issue size changed | [
"Yield",
"an",
"IssueSnapshot",
"for",
"each",
"time",
"the",
"issue",
"size",
"changed"
] | python | train | 37.266667 |
cuihantao/andes | andes/models/governor.py | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/governor.py#L63-L68 | def data_to_elem_base(self):
"""Custom system base unconversion function"""
if not self.n or self._flags['sysbase'] is False:
return
self.R = mul(self.R, self.Sn) / self.system.mva
super(GovernorBase, self).data_to_elem_base() | [
"def",
"data_to_elem_base",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"n",
"or",
"self",
".",
"_flags",
"[",
"'sysbase'",
"]",
"is",
"False",
":",
"return",
"self",
".",
"R",
"=",
"mul",
"(",
"self",
".",
"R",
",",
"self",
".",
"Sn",
")",
... | Custom system base unconversion function | [
"Custom",
"system",
"base",
"unconversion",
"function"
] | python | train | 44.166667 |
F-Secure/see | see/context/resources/resources.py | https://github.com/F-Secure/see/blob/3e053e52a45229f96a12db9e98caf7fb3880e811/see/context/resources/resources.py#L109-L126 | def provider_image(self):
"""Image path getter.
This method uses a pluggable image provider to retrieve an
image's path.
"""
if self._image is None:
if isinstance(self.configuration['disk']['image'], dict):
ProviderClass = lookup_provider_class(
... | [
"def",
"provider_image",
"(",
"self",
")",
":",
"if",
"self",
".",
"_image",
"is",
"None",
":",
"if",
"isinstance",
"(",
"self",
".",
"configuration",
"[",
"'disk'",
"]",
"[",
"'image'",
"]",
",",
"dict",
")",
":",
"ProviderClass",
"=",
"lookup_provider_... | Image path getter.
This method uses a pluggable image provider to retrieve an
image's path. | [
"Image",
"path",
"getter",
"."
] | python | train | 38.666667 |
oscarbranson/latools | latools/helpers/plot.py | https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/helpers/plot.py#L393-L456 | def histograms(dat, keys=None, bins=25, logy=False, cmap=None, ncol=4):
"""
Plot histograms of all items in dat.
Parameters
----------
dat : dict
Data in {key: array} pairs.
keys : arra-like
The keys in dat that you want to plot. If None,
all are plotted.
bins : int
... | [
"def",
"histograms",
"(",
"dat",
",",
"keys",
"=",
"None",
",",
"bins",
"=",
"25",
",",
"logy",
"=",
"False",
",",
"cmap",
"=",
"None",
",",
"ncol",
"=",
"4",
")",
":",
"if",
"keys",
"is",
"None",
":",
"keys",
"=",
"dat",
".",
"keys",
"(",
")... | Plot histograms of all items in dat.
Parameters
----------
dat : dict
Data in {key: array} pairs.
keys : arra-like
The keys in dat that you want to plot. If None,
all are plotted.
bins : int
The number of bins in each histogram (default = 25)
logy : bool
... | [
"Plot",
"histograms",
"of",
"all",
"items",
"in",
"dat",
"."
] | python | test | 22.046875 |
quantmind/pulsar | pulsar/apps/wsgi/content.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/wsgi/content.py#L210-L222 | def html_factory(tag, **defaults):
'''Returns an :class:`Html` factory function for ``tag`` and a given
dictionary of ``defaults`` parameters. For example::
>>> input_factory = html_factory('input', type='text')
>>> html = input_factory(value='bla')
'''
def html_input(*children, **params):
... | [
"def",
"html_factory",
"(",
"tag",
",",
"*",
"*",
"defaults",
")",
":",
"def",
"html_input",
"(",
"*",
"children",
",",
"*",
"*",
"params",
")",
":",
"p",
"=",
"defaults",
".",
"copy",
"(",
")",
"p",
".",
"update",
"(",
"params",
")",
"return",
"... | Returns an :class:`Html` factory function for ``tag`` and a given
dictionary of ``defaults`` parameters. For example::
>>> input_factory = html_factory('input', type='text')
>>> html = input_factory(value='bla') | [
"Returns",
"an",
":",
"class",
":",
"Html",
"factory",
"function",
"for",
"tag",
"and",
"a",
"given",
"dictionary",
"of",
"defaults",
"parameters",
".",
"For",
"example",
"::"
] | python | train | 32.307692 |
bloomberg/bqplot | bqplot/pyplot.py | https://github.com/bloomberg/bqplot/blob/8eb8b163abe9ee6306f6918067e2f36c1caef2ef/bqplot/pyplot.py#L552-L565 | def _process_cmap(cmap):
'''
Returns a kwarg dict suitable for a ColorScale
'''
option = {}
if isinstance(cmap, str):
option['scheme'] = cmap
elif isinstance(cmap, list):
option['colors'] = cmap
else:
raise ValueError('''`cmap` must be a string (name of a color scheme... | [
"def",
"_process_cmap",
"(",
"cmap",
")",
":",
"option",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"cmap",
",",
"str",
")",
":",
"option",
"[",
"'scheme'",
"]",
"=",
"cmap",
"elif",
"isinstance",
"(",
"cmap",
",",
"list",
")",
":",
"option",
"[",
"'c... | Returns a kwarg dict suitable for a ColorScale | [
"Returns",
"a",
"kwarg",
"dict",
"suitable",
"for",
"a",
"ColorScale"
] | python | train | 31.642857 |
wbond/oscrypto | oscrypto/_openssl/tls.py | https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_openssl/tls.py#L926-L968 | def write(self, data):
"""
Writes data to the TLS-wrapped socket
:param data:
A byte string to write to the socket
:raises:
socket.socket - when a non-TLS socket error occurs
oscrypto.errors.TLSError - when a TLS-related error occurs
Valu... | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"data_len",
"=",
"len",
"(",
"data",
")",
"while",
"data_len",
":",
"if",
"self",
".",
"_ssl",
"is",
"None",
":",
"self",
".",
"_raise_closed",
"(",
")",
"result",
"=",
"libssl",
".",
"SSL_write",
... | Writes data to the TLS-wrapped socket
:param data:
A byte string to write to the socket
:raises:
socket.socket - when a non-TLS socket error occurs
oscrypto.errors.TLSError - when a TLS-related error occurs
ValueError - when any of the parameters contain... | [
"Writes",
"data",
"to",
"the",
"TLS",
"-",
"wrapped",
"socket"
] | python | valid | 34.162791 |
crackinglandia/pype32 | pype32/pype32.py | https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L627-L650 | def _adjustFileAlignment(self, value, fileAlignment):
"""
Align a value to C{FileAligment}.
@type value: int
@param value: The value to align.
@type fileAlignment: int
@param fileAlignment: The value to be used to align the C{value} parameter.
... | [
"def",
"_adjustFileAlignment",
"(",
"self",
",",
"value",
",",
"fileAlignment",
")",
":",
"if",
"fileAlignment",
">",
"consts",
".",
"DEFAULT_FILE_ALIGNMENT",
":",
"if",
"not",
"utils",
".",
"powerOfTwo",
"(",
"fileAlignment",
")",
":",
"print",
"\"Warning: File... | Align a value to C{FileAligment}.
@type value: int
@param value: The value to align.
@type fileAlignment: int
@param fileAlignment: The value to be used to align the C{value} parameter.
@rtype: int
@return: The aligned value. | [
"Align",
"a",
"value",
"to",
"C",
"{",
"FileAligment",
"}",
"."
] | python | train | 35.291667 |
bigchaindb/bigchaindb | bigchaindb/common/transaction.py | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L904-L948 | def _sign_threshold_signature_fulfillment(cls, input_, message, key_pairs):
"""Signs a ThresholdSha256.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`) The Input to be signed.
message (str): The message to be signed
k... | [
"def",
"_sign_threshold_signature_fulfillment",
"(",
"cls",
",",
"input_",
",",
"message",
",",
"key_pairs",
")",
":",
"input_",
"=",
"deepcopy",
"(",
"input_",
")",
"message",
"=",
"sha3_256",
"(",
"message",
".",
"encode",
"(",
")",
")",
"if",
"input_",
... | Signs a ThresholdSha256.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`) The Input to be signed.
message (str): The message to be signed
key_pairs (dict): The keys to sign the Transaction with. | [
"Signs",
"a",
"ThresholdSha256",
"."
] | python | train | 46.422222 |
oscarlazoarjona/fast | fast/misc.py | https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/misc.py#L602-L613 | def find_omega_min(omega, Nl, detuningsij, i_d, I_nd):
r"""This function returns a list of length Nl containing the mininmal frequency
that each laser excites.
"""
omega_min = []
omega_min_indices = []
for l in range(Nl):
omegas = sorted([(omega[i_d(p[0]+1)-1][i_d(p[1]+1)-1], p)
... | [
"def",
"find_omega_min",
"(",
"omega",
",",
"Nl",
",",
"detuningsij",
",",
"i_d",
",",
"I_nd",
")",
":",
"omega_min",
"=",
"[",
"]",
"omega_min_indices",
"=",
"[",
"]",
"for",
"l",
"in",
"range",
"(",
"Nl",
")",
":",
"omegas",
"=",
"sorted",
"(",
"... | r"""This function returns a list of length Nl containing the mininmal frequency
that each laser excites. | [
"r",
"This",
"function",
"returns",
"a",
"list",
"of",
"length",
"Nl",
"containing",
"the",
"mininmal",
"frequency",
"that",
"each",
"laser",
"excites",
"."
] | python | train | 39.25 |
recurly/recurly-client-python | recurly/resource.py | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L673-L685 | def post(self, url, body=None):
"""Sends this `Resource` instance to the service with a
``POST`` request to the given URL. Takes an optional body"""
response = self.http_request(url, 'POST', body or self, {'Content-Type': 'application/xml; charset=utf-8'})
if response.status not in (200,... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"body",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"http_request",
"(",
"url",
",",
"'POST'",
",",
"body",
"or",
"self",
",",
"{",
"'Content-Type'",
":",
"'application/xml; charset=utf-8'",
"}",
")",... | Sends this `Resource` instance to the service with a
``POST`` request to the given URL. Takes an optional body | [
"Sends",
"this",
"Resource",
"instance",
"to",
"the",
"service",
"with",
"a",
"POST",
"request",
"to",
"the",
"given",
"URL",
".",
"Takes",
"an",
"optional",
"body"
] | python | train | 50.076923 |
scopus-api/scopus | scopus/deprecated_/scopus_api.py | https://github.com/scopus-api/scopus/blob/27ce02dd3095bfdab9d3e8475543d7c17767d1ab/scopus/deprecated_/scopus_api.py#L164-L174 | def references(self):
"""Return EIDs of references of an article.
Note: Requires the FULL view of the article.
"""
refs = self.items.find('bibrecord/tail/bibliography', ns)
if refs is not None:
eids = [r.find("ref-info/refd-itemidlist/itemid", ns).text for r
... | [
"def",
"references",
"(",
"self",
")",
":",
"refs",
"=",
"self",
".",
"items",
".",
"find",
"(",
"'bibrecord/tail/bibliography'",
",",
"ns",
")",
"if",
"refs",
"is",
"not",
"None",
":",
"eids",
"=",
"[",
"r",
".",
"find",
"(",
"\"ref-info/refd-itemidlist... | Return EIDs of references of an article.
Note: Requires the FULL view of the article. | [
"Return",
"EIDs",
"of",
"references",
"of",
"an",
"article",
".",
"Note",
":",
"Requires",
"the",
"FULL",
"view",
"of",
"the",
"article",
"."
] | python | train | 40.454545 |
osrg/ryu | ryu/services/protocols/bgp/speaker.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/speaker.py#L264-L275 | def _run(self, peer):
"""Sends open message to peer and handles received messages.
Parameters:
- `peer`: the peer to which this protocol instance is connected to.
"""
# We know the peer we are connected to, we send open message.
self._peer = peer
self.connect... | [
"def",
"_run",
"(",
"self",
",",
"peer",
")",
":",
"# We know the peer we are connected to, we send open message.",
"self",
".",
"_peer",
"=",
"peer",
"self",
".",
"connection_made",
"(",
")",
"# We wait for peer to send messages.",
"self",
".",
"_recv_loop",
"(",
")"... | Sends open message to peer and handles received messages.
Parameters:
- `peer`: the peer to which this protocol instance is connected to. | [
"Sends",
"open",
"message",
"to",
"peer",
"and",
"handles",
"received",
"messages",
"."
] | python | train | 32.583333 |
ansible/tower-cli | tower_cli/resources/notification_template.py | https://github.com/ansible/tower-cli/blob/a2b151fed93c47725018d3034848cb3a1814bed7/tower_cli/resources/notification_template.py#L397-L422 | def get(self, pk=None, **kwargs):
"""Return one and exactly one notification template.
Note here configuration-related fields like
'notification_configuration' and 'channels' will not be
used even provided.
Lookups may be through a primary key, specified as a positional
... | [
"def",
"get",
"(",
"self",
",",
"pk",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_separate",
"(",
"kwargs",
")",
"return",
"super",
"(",
"Resource",
",",
"self",
")",
".",
"get",
"(",
"pk",
"=",
"pk",
",",
"*",
"*",
"kwargs",... | Return one and exactly one notification template.
Note here configuration-related fields like
'notification_configuration' and 'channels' will not be
used even provided.
Lookups may be through a primary key, specified as a positional
argument, and/or through filters specified t... | [
"Return",
"one",
"and",
"exactly",
"one",
"notification",
"template",
"."
] | python | valid | 39.653846 |
JoshAshby/pyRethinkORM | rethinkORM/rethinkCollection.py | https://github.com/JoshAshby/pyRethinkORM/blob/92158d146dea6cfe9022d7de2537403f5f2c1e02/rethinkORM/rethinkCollection.py#L54-L65 | def _joinOnAsPriv(self, model, onIndex, whatAs):
"""
Private method for handling joins.
"""
if self._join:
raise Exception("Already joined with a table!")
self._join = model
self._joinedField = whatAs
table = model.table
self._query = self._qu... | [
"def",
"_joinOnAsPriv",
"(",
"self",
",",
"model",
",",
"onIndex",
",",
"whatAs",
")",
":",
"if",
"self",
".",
"_join",
":",
"raise",
"Exception",
"(",
"\"Already joined with a table!\"",
")",
"self",
".",
"_join",
"=",
"model",
"self",
".",
"_joinedField",
... | Private method for handling joins. | [
"Private",
"method",
"for",
"handling",
"joins",
"."
] | python | train | 30.416667 |
lambdalisue/maidenhair | src/maidenhair/utils/environment.py | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/utils/environment.py#L19-L32 | def get_system_root_directory():
"""
Get system root directory (application installed root directory)
Returns
-------
string
A full path
"""
root = os.path.dirname(__file__)
root = os.path.dirname(root)
root = os.path.abspath(root)
return root | [
"def",
"get_system_root_directory",
"(",
")",
":",
"root",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"root",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"root",
")",
"root",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"root",
... | Get system root directory (application installed root directory)
Returns
-------
string
A full path | [
"Get",
"system",
"root",
"directory",
"(",
"application",
"installed",
"root",
"directory",
")"
] | python | train | 20 |
linkedin/Zopkio | zopkio/runtime.py | https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/runtime.py#L163-L180 | def reset_all():
"""
Clear relevant globals to start fresh
:return:
"""
global _username
global _password
global _active_config
global _active_tests
global _machine_names
global _deployers
reset_deployers()
reset_collector()
_username = None
_password = None
_active_config = None
_active... | [
"def",
"reset_all",
"(",
")",
":",
"global",
"_username",
"global",
"_password",
"global",
"_active_config",
"global",
"_active_tests",
"global",
"_machine_names",
"global",
"_deployers",
"reset_deployers",
"(",
")",
"reset_collector",
"(",
")",
"_username",
"=",
"N... | Clear relevant globals to start fresh
:return: | [
"Clear",
"relevant",
"globals",
"to",
"start",
"fresh",
":",
"return",
":"
] | python | train | 19.277778 |
quantumlib/Cirq | cirq/ops/pauli_string_raw_types.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/pauli_string_raw_types.py#L42-L49 | def map_qubits(self: TSelf_PauliStringGateOperation,
qubit_map: Dict[raw_types.Qid, raw_types.Qid]
) -> TSelf_PauliStringGateOperation:
"""Return an equivalent operation on new qubits with its Pauli string
mapped to new qubits.
new_pauli_string = self.pauli_... | [
"def",
"map_qubits",
"(",
"self",
":",
"TSelf_PauliStringGateOperation",
",",
"qubit_map",
":",
"Dict",
"[",
"raw_types",
".",
"Qid",
",",
"raw_types",
".",
"Qid",
"]",
")",
"->",
"TSelf_PauliStringGateOperation",
":"
] | Return an equivalent operation on new qubits with its Pauli string
mapped to new qubits.
new_pauli_string = self.pauli_string.map_qubits(qubit_map) | [
"Return",
"an",
"equivalent",
"operation",
"on",
"new",
"qubits",
"with",
"its",
"Pauli",
"string",
"mapped",
"to",
"new",
"qubits",
"."
] | python | train | 44.125 |
almarklein/pyelastix | pyelastix.py | https://github.com/almarklein/pyelastix/blob/971a677ce9a3ef8eb0b95ae393db8e2506d2f8a4/pyelastix.py#L941-L967 | def _compile_params(params, im1):
""" Compile the params dictionary:
* Combine parameters from different sources
* Perform checks to prevent non-compatible parameters
* Extend parameters that need a list with one element per dimension
"""
# Compile parameters
p = _get_fixed_params(im1) ... | [
"def",
"_compile_params",
"(",
"params",
",",
"im1",
")",
":",
"# Compile parameters",
"p",
"=",
"_get_fixed_params",
"(",
"im1",
")",
"+",
"get_advanced_params",
"(",
")",
"p",
"=",
"p",
"+",
"params",
"params",
"=",
"p",
".",
"as_dict",
"(",
")",
"# Ch... | Compile the params dictionary:
* Combine parameters from different sources
* Perform checks to prevent non-compatible parameters
* Extend parameters that need a list with one element per dimension | [
"Compile",
"the",
"params",
"dictionary",
":",
"*",
"Combine",
"parameters",
"from",
"different",
"sources",
"*",
"Perform",
"checks",
"to",
"prevent",
"non",
"-",
"compatible",
"parameters",
"*",
"Extend",
"parameters",
"that",
"need",
"a",
"list",
"with",
"o... | python | train | 34.481481 |
Workiva/furious | furious/async.py | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/async.py#L389-L403 | def _prepare_persistence_engine(self):
"""Load the specified persistence engine, or the default if none is
set.
"""
if self._persistence_engine:
return
persistence_engine = self._options.get('persistence_engine')
if persistence_engine:
self._persi... | [
"def",
"_prepare_persistence_engine",
"(",
"self",
")",
":",
"if",
"self",
".",
"_persistence_engine",
":",
"return",
"persistence_engine",
"=",
"self",
".",
"_options",
".",
"get",
"(",
"'persistence_engine'",
")",
"if",
"persistence_engine",
":",
"self",
".",
... | Load the specified persistence engine, or the default if none is
set. | [
"Load",
"the",
"specified",
"persistence",
"engine",
"or",
"the",
"default",
"if",
"none",
"is",
"set",
"."
] | python | train | 34.266667 |
odlgroup/odl | odl/set/space.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/set/space.py#L228-L247 | def dist(self, x1, x2):
"""Return the distance between ``x1`` and ``x2``.
Parameters
----------
x1, x2 : `LinearSpaceElement`
Elements whose distance to compute.
Returns
-------
dist : float
Distance between ``x1`` and ``x2``.
"""... | [
"def",
"dist",
"(",
"self",
",",
"x1",
",",
"x2",
")",
":",
"if",
"x1",
"not",
"in",
"self",
":",
"raise",
"LinearSpaceTypeError",
"(",
"'`x1` {!r} is not an element of '",
"'{!r}'",
".",
"format",
"(",
"x1",
",",
"self",
")",
")",
"if",
"x2",
"not",
"... | Return the distance between ``x1`` and ``x2``.
Parameters
----------
x1, x2 : `LinearSpaceElement`
Elements whose distance to compute.
Returns
-------
dist : float
Distance between ``x1`` and ``x2``. | [
"Return",
"the",
"distance",
"between",
"x1",
"and",
"x2",
"."
] | python | train | 33.5 |
althonos/pronto | pronto/term.py | https://github.com/althonos/pronto/blob/a768adcba19fb34f26f67cde4a03d317f932c274/pronto/term.py#L290-L325 | def rparents(self, level=-1, intermediate=True):
"""Create a recursive list of children.
Note that the :param:`intermediate` can be used to include every
parents to the returned list, not only the most nested ones.
Parameters:
level (int): The depth level to continue fetchi... | [
"def",
"rparents",
"(",
"self",
",",
"level",
"=",
"-",
"1",
",",
"intermediate",
"=",
"True",
")",
":",
"try",
":",
"return",
"self",
".",
"_rparents",
"[",
"(",
"level",
",",
"intermediate",
")",
"]",
"except",
"KeyError",
":",
"rparents",
"=",
"["... | Create a recursive list of children.
Note that the :param:`intermediate` can be used to include every
parents to the returned list, not only the most nested ones.
Parameters:
level (int): The depth level to continue fetching parents from
(default is -1, to get paren... | [
"Create",
"a",
"recursive",
"list",
"of",
"children",
"."
] | python | train | 33.694444 |
wummel/linkchecker | third_party/miniboa-r42/miniboa/async.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/miniboa-r42/miniboa/async.py#L112-L188 | def poll(self):
"""
Perform a non-blocking scan of recv and send states on the server
and client connection sockets. Process new connection requests,
read incomming data, and send outgoing data. Sends and receives may
be partial.
"""
#print len(self.connections)... | [
"def",
"poll",
"(",
"self",
")",
":",
"#print len(self.connections)",
"## Build a list of connections to test for receive data pending",
"recv_list",
"=",
"[",
"self",
".",
"server_fileno",
"]",
"# always add the server",
"for",
"client",
"in",
"self",
".",
"clients",
"."... | Perform a non-blocking scan of recv and send states on the server
and client connection sockets. Process new connection requests,
read incomming data, and send outgoing data. Sends and receives may
be partial. | [
"Perform",
"a",
"non",
"-",
"blocking",
"scan",
"of",
"recv",
"and",
"send",
"states",
"on",
"the",
"server",
"and",
"client",
"connection",
"sockets",
".",
"Process",
"new",
"connection",
"requests",
"read",
"incomming",
"data",
"and",
"send",
"outgoing",
"... | python | train | 38.25974 |
elastic/apm-agent-python | elasticapm/processors.py | https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L148-L170 | def sanitize_http_headers(client, event):
"""
Sanitizes http request/response headers
:param client: an ElasticAPM client
:param event: a transaction or error event
:return: The modified event
"""
# request headers
try:
headers = event["context"]["request"]["headers"]
ev... | [
"def",
"sanitize_http_headers",
"(",
"client",
",",
"event",
")",
":",
"# request headers",
"try",
":",
"headers",
"=",
"event",
"[",
"\"context\"",
"]",
"[",
"\"request\"",
"]",
"[",
"\"headers\"",
"]",
"event",
"[",
"\"context\"",
"]",
"[",
"\"request\"",
... | Sanitizes http request/response headers
:param client: an ElasticAPM client
:param event: a transaction or error event
:return: The modified event | [
"Sanitizes",
"http",
"request",
"/",
"response",
"headers"
] | python | train | 27.956522 |
PyCQA/pyflakes | pyflakes/checker.py | https://github.com/PyCQA/pyflakes/blob/232cb1d27ee134bf96adc8f37e53589dc259b159/pyflakes/checker.py#L1519-L1542 | def CLASSDEF(self, node):
"""
Check names used in a class definition, including its decorators, base
classes, and the body of its definition. Additionally, add its name to
the current scope.
"""
for deco in node.decorator_list:
self.handleNode(deco, node)
... | [
"def",
"CLASSDEF",
"(",
"self",
",",
"node",
")",
":",
"for",
"deco",
"in",
"node",
".",
"decorator_list",
":",
"self",
".",
"handleNode",
"(",
"deco",
",",
"node",
")",
"for",
"baseNode",
"in",
"node",
".",
"bases",
":",
"self",
".",
"handleNode",
"... | Check names used in a class definition, including its decorators, base
classes, and the body of its definition. Additionally, add its name to
the current scope. | [
"Check",
"names",
"used",
"in",
"a",
"class",
"definition",
"including",
"its",
"decorators",
"base",
"classes",
"and",
"the",
"body",
"of",
"its",
"definition",
".",
"Additionally",
"add",
"its",
"name",
"to",
"the",
"current",
"scope",
"."
] | python | train | 41.416667 |
StackStorm/pybind | pybind/nos/v6_0_2f/router/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/router/__init__.py#L96-L119 | def _set_fabric_virtual_gateway(self, v, load=False):
"""
Setter method for fabric_virtual_gateway, mapped from YANG variable /router/fabric_virtual_gateway (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_fabric_virtual_gateway is considered as a private
... | [
"def",
"_set_fabric_virtual_gateway",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
... | Setter method for fabric_virtual_gateway, mapped from YANG variable /router/fabric_virtual_gateway (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_fabric_virtual_gateway is considered as a private
method. Backends looking to populate this variable should
do s... | [
"Setter",
"method",
"for",
"fabric_virtual_gateway",
"mapped",
"from",
"YANG",
"variable",
"/",
"router",
"/",
"fabric_virtual_gateway",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
... | python | train | 91.291667 |
lobocv/crashreporter | crashreporter/tools.py | https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L155-L183 | def analyze_traceback(tb, inspection_level=None, limit=None):
"""
Extract trace back information into a list of dictionaries.
:param tb: traceback
:return: list of dicts containing filepath, line, module, code, traceback level and source code for tracebacks
"""
info = []
tb_level = tb
e... | [
"def",
"analyze_traceback",
"(",
"tb",
",",
"inspection_level",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"info",
"=",
"[",
"]",
"tb_level",
"=",
"tb",
"extracted_tb",
"=",
"traceback",
".",
"extract_tb",
"(",
"tb",
",",
"limit",
"=",
"limit",
... | Extract trace back information into a list of dictionaries.
:param tb: traceback
:return: list of dicts containing filepath, line, module, code, traceback level and source code for tracebacks | [
"Extract",
"trace",
"back",
"information",
"into",
"a",
"list",
"of",
"dictionaries",
"."
] | python | train | 41.758621 |
apache/incubator-mxnet | python/mxnet/executor_manager.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor_manager.py#L363-L375 | def set_params(self, arg_params, aux_params):
"""Set parameter and aux values.
Parameters
----------
arg_params : list of NDArray
Source parameter arrays
aux_params : list of NDArray
Source aux arrays.
"""
for texec in self.execgrp.train_... | [
"def",
"set_params",
"(",
"self",
",",
"arg_params",
",",
"aux_params",
")",
":",
"for",
"texec",
"in",
"self",
".",
"execgrp",
".",
"train_execs",
":",
"texec",
".",
"copy_params_from",
"(",
"arg_params",
",",
"aux_params",
")"
] | Set parameter and aux values.
Parameters
----------
arg_params : list of NDArray
Source parameter arrays
aux_params : list of NDArray
Source aux arrays. | [
"Set",
"parameter",
"and",
"aux",
"values",
"."
] | python | train | 28.692308 |
lreis2415/PyGeoC | pygeoc/TauDEM.py | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/TauDEM.py#L604-L613 | def peukerdouglas(np, fel, streamSkeleton, workingdir=None, mpiexedir=None, exedir=None,
log_file=None, runtime_file=None, hostfile=None):
"""Run peuker-douglas function"""
fname = TauDEM.func_name('peukerdouglas')
return TauDEM.run(FileClass.get_executable_fullpath(fname, ... | [
"def",
"peukerdouglas",
"(",
"np",
",",
"fel",
",",
"streamSkeleton",
",",
"workingdir",
"=",
"None",
",",
"mpiexedir",
"=",
"None",
",",
"exedir",
"=",
"None",
",",
"log_file",
"=",
"None",
",",
"runtime_file",
"=",
"None",
",",
"hostfile",
"=",
"None",... | Run peuker-douglas function | [
"Run",
"peuker",
"-",
"douglas",
"function"
] | python | train | 61.4 |
wanshot/holiday | holiday/core.py | https://github.com/wanshot/holiday/blob/e08681c237d684aa05ba2f98b3baa388dab9eea6/holiday/core.py#L75-L96 | def _check_holiday_structure(self, times):
""" To check the structure of the HolidayClass
:param list times: years or months or days or number week
:rtype: None or Exception
:return: in the case of exception returns the exception
"""
if not isinstance(times, list):
... | [
"def",
"_check_holiday_structure",
"(",
"self",
",",
"times",
")",
":",
"if",
"not",
"isinstance",
"(",
"times",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"\"an list is required\"",
")",
"for",
"time",
"in",
"times",
":",
"if",
"not",
"isinstance",
... | To check the structure of the HolidayClass
:param list times: years or months or days or number week
:rtype: None or Exception
:return: in the case of exception returns the exception | [
"To",
"check",
"the",
"structure",
"of",
"the",
"HolidayClass"
] | python | train | 39.590909 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/distribute-0.6.31-py2.7.egg/setuptools/command/easy_install.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/distribute-0.6.31-py2.7.egg/setuptools/command/easy_install.py#L1688-L1692 | def uncache_zipdir(path):
"""Ensure that the importer caches dont have stale info for `path`"""
from zipimport import _zip_directory_cache as zdc
_uncache(path, zdc)
_uncache(path, sys.path_importer_cache) | [
"def",
"uncache_zipdir",
"(",
"path",
")",
":",
"from",
"zipimport",
"import",
"_zip_directory_cache",
"as",
"zdc",
"_uncache",
"(",
"path",
",",
"zdc",
")",
"_uncache",
"(",
"path",
",",
"sys",
".",
"path_importer_cache",
")"
] | Ensure that the importer caches dont have stale info for `path` | [
"Ensure",
"that",
"the",
"importer",
"caches",
"dont",
"have",
"stale",
"info",
"for",
"path"
] | python | test | 43.4 |
micahhausler/container-transform | container_transform/kubernetes.py | https://github.com/micahhausler/container-transform/blob/68223fae98f30b8bb2ce0f02ba9e58afbc80f196/container_transform/kubernetes.py#L124-L136 | def flatten_container(self, container):
"""
Accepts a kubernetes container and pulls out the nested values into the top level
"""
for names in ARG_MAP.values():
if names[TransformationTypes.KUBERNETES.value]['name'] and \
'.' in names[Transformatio... | [
"def",
"flatten_container",
"(",
"self",
",",
"container",
")",
":",
"for",
"names",
"in",
"ARG_MAP",
".",
"values",
"(",
")",
":",
"if",
"names",
"[",
"TransformationTypes",
".",
"KUBERNETES",
".",
"value",
"]",
"[",
"'name'",
"]",
"and",
"'.'",
"in",
... | Accepts a kubernetes container and pulls out the nested values into the top level | [
"Accepts",
"a",
"kubernetes",
"container",
"and",
"pulls",
"out",
"the",
"nested",
"values",
"into",
"the",
"top",
"level"
] | python | train | 51.538462 |
persephone-tools/persephone | persephone/corpus_reader.py | https://github.com/persephone-tools/persephone/blob/f94c63e4d5fe719fb1deba449b177bb299d225fb/persephone/corpus_reader.py#L205-L241 | def calc_time(self) -> None:
"""
Prints statistics about the the total duration of recordings in the
corpus.
"""
def get_number_of_frames(feat_fns):
""" fns: A list of numpy files which contain a number of feature
frames. """
total = 0
... | [
"def",
"calc_time",
"(",
"self",
")",
"->",
"None",
":",
"def",
"get_number_of_frames",
"(",
"feat_fns",
")",
":",
"\"\"\" fns: A list of numpy files which contain a number of feature\n frames. \"\"\"",
"total",
"=",
"0",
"for",
"feat_fn",
"in",
"feat_fns",
":"... | Prints statistics about the the total duration of recordings in the
corpus. | [
"Prints",
"statistics",
"about",
"the",
"the",
"total",
"duration",
"of",
"recordings",
"in",
"the",
"corpus",
"."
] | python | train | 39.405405 |
materialsproject/pymatgen | pymatgen/electronic_structure/core.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/core.py#L345-L368 | def get_suggested_saxis(magmoms):
"""
This method returns a suggested spin axis for a set of magmoms,
taking the largest magnetic moment as the reference. For calculations
with collinear spins, this would give a sensible saxis for a ncl
calculation.
:param magmoms: list ... | [
"def",
"get_suggested_saxis",
"(",
"magmoms",
")",
":",
"# heuristic, will pick largest magmom as reference",
"# useful for creating collinear approximations of",
"# e.g. slightly canted magnetic structures",
"# for fully collinear structures, will return expected",
"# result",
"magmoms",
"=... | This method returns a suggested spin axis for a set of magmoms,
taking the largest magnetic moment as the reference. For calculations
with collinear spins, this would give a sensible saxis for a ncl
calculation.
:param magmoms: list of magmoms (Magmoms, scalars or vectors)
:retu... | [
"This",
"method",
"returns",
"a",
"suggested",
"spin",
"axis",
"for",
"a",
"set",
"of",
"magmoms",
"taking",
"the",
"largest",
"magnetic",
"moment",
"as",
"the",
"reference",
".",
"For",
"calculations",
"with",
"collinear",
"spins",
"this",
"would",
"give",
... | python | train | 41.416667 |
romana/multi-ping | multiping/__init__.py | https://github.com/romana/multi-ping/blob/59f024c867a17fae5b4a7b52f97effc6fb1b0ca5/multiping/__init__.py#L209-L266 | def _send_ping(self, dest_addr, payload):
"""
Send a single ICMPecho (ping) packet to the specified address.
The payload must be specified as a packed byte string. Note that its
length has to be divisible by 2 for this to work correctly.
"""
pkt_id = self._last_used_id
... | [
"def",
"_send_ping",
"(",
"self",
",",
"dest_addr",
",",
"payload",
")",
":",
"pkt_id",
"=",
"self",
".",
"_last_used_id",
"is_ipv6",
"=",
"':'",
"in",
"dest_addr",
"if",
"is_ipv6",
":",
"self",
".",
"_ipv6_address_present",
"=",
"True",
"icmp_echo_request",
... | Send a single ICMPecho (ping) packet to the specified address.
The payload must be specified as a packed byte string. Note that its
length has to be divisible by 2 for this to work correctly. | [
"Send",
"a",
"single",
"ICMPecho",
"(",
"ping",
")",
"packet",
"to",
"the",
"specified",
"address",
"."
] | python | train | 40.137931 |
pvizeli/ha-ffmpeg | haffmpeg/tools.py | https://github.com/pvizeli/ha-ffmpeg/blob/fce1d4b77e76b9cb07d814bcb858b89657e1f32b/haffmpeg/tools.py#L57-L85 | async def get_version(self, timeout: int = 15) -> Optional[str]:
"""Execute FFmpeg process and parse the version information.
Return full FFmpeg version string. Such as 3.4.2-tessus
"""
command = ["-version"]
# open input for capture 1 frame
is_open = await self.open(cm... | [
"async",
"def",
"get_version",
"(",
"self",
",",
"timeout",
":",
"int",
"=",
"15",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"command",
"=",
"[",
"\"-version\"",
"]",
"# open input for capture 1 frame",
"is_open",
"=",
"await",
"self",
".",
"open",
"(",... | Execute FFmpeg process and parse the version information.
Return full FFmpeg version string. Such as 3.4.2-tessus | [
"Execute",
"FFmpeg",
"process",
"and",
"parse",
"the",
"version",
"information",
"."
] | python | train | 32.965517 |
python-bonobo/bonobo | docs/_templates/alabaster/__init__.py | https://github.com/python-bonobo/bonobo/blob/70c8e62c4a88576976e5b52e58d380d6e3227ab4/docs/_templates/alabaster/__init__.py#L6-L11 | def get_path():
"""
Shortcut for users whose theme is next to their conf.py.
"""
# Theme directory is defined as our parent directory
return os.path.abspath(os.path.dirname(os.path.dirname(__file__))) | [
"def",
"get_path",
"(",
")",
":",
"# Theme directory is defined as our parent directory",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
")"
] | Shortcut for users whose theme is next to their conf.py. | [
"Shortcut",
"for",
"users",
"whose",
"theme",
"is",
"next",
"to",
"their",
"conf",
".",
"py",
"."
] | python | train | 35.833333 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8530-L8538 | def read_sis_ini(fh, byteorder, dtype, count, offsetsize):
"""Read OlympusSIS INI string and return as dict."""
inistr = fh.read(count)
inistr = bytes2str(stripnull(inistr))
try:
return olympusini_metadata(inistr)
except Exception as exc:
log.warning('olympusini_metadata: %s: %s', ex... | [
"def",
"read_sis_ini",
"(",
"fh",
",",
"byteorder",
",",
"dtype",
",",
"count",
",",
"offsetsize",
")",
":",
"inistr",
"=",
"fh",
".",
"read",
"(",
"count",
")",
"inistr",
"=",
"bytes2str",
"(",
"stripnull",
"(",
"inistr",
")",
")",
"try",
":",
"retu... | Read OlympusSIS INI string and return as dict. | [
"Read",
"OlympusSIS",
"INI",
"string",
"and",
"return",
"as",
"dict",
"."
] | python | train | 39.555556 |
jxtech/wechatpy | wechatpy/client/api/scan.py | https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/scan.py#L144-L159 | def clear_product(self, standard, key):
"""
清除商品信息
详情请参考
http://mp.weixin.qq.com/wiki/15/7fa787701295b884410b5163e13313af.html
:param standard: 商品编码标准
:param key: 商品编码内容
:return: 返回的 JSON 数据包
"""
data = {
'keystandard': standard,
... | [
"def",
"clear_product",
"(",
"self",
",",
"standard",
",",
"key",
")",
":",
"data",
"=",
"{",
"'keystandard'",
":",
"standard",
",",
"'keystr'",
":",
"key",
",",
"}",
"return",
"self",
".",
"_post",
"(",
"'product/clear'",
",",
"data",
"=",
"data",
")"... | 清除商品信息
详情请参考
http://mp.weixin.qq.com/wiki/15/7fa787701295b884410b5163e13313af.html
:param standard: 商品编码标准
:param key: 商品编码内容
:return: 返回的 JSON 数据包 | [
"清除商品信息"
] | python | train | 24.4375 |
matrix-org/matrix-python-sdk | matrix_client/room.py | https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L239-L256 | def add_listener(self, callback, event_type=None):
"""Add a callback handler for events going to this room.
Args:
callback (func(room, event)): Callback called when an event arrives.
event_type (str): The event_type to filter for.
Returns:
uuid.UUID: Unique i... | [
"def",
"add_listener",
"(",
"self",
",",
"callback",
",",
"event_type",
"=",
"None",
")",
":",
"listener_id",
"=",
"uuid4",
"(",
")",
"self",
".",
"listeners",
".",
"append",
"(",
"{",
"'uid'",
":",
"listener_id",
",",
"'callback'",
":",
"callback",
",",... | Add a callback handler for events going to this room.
Args:
callback (func(room, event)): Callback called when an event arrives.
event_type (str): The event_type to filter for.
Returns:
uuid.UUID: Unique id of the listener, can be used to identify the listener. | [
"Add",
"a",
"callback",
"handler",
"for",
"events",
"going",
"to",
"this",
"room",
"."
] | python | train | 34 |
mojaie/chorus | chorus/molutil.py | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L111-L114 | def H_acceptor_count(mol):
"""Hydrogen bond acceptor count """
mol.require("Valence")
return sum(1 for _, a in mol.atoms_iter() if a.H_acceptor) | [
"def",
"H_acceptor_count",
"(",
"mol",
")",
":",
"mol",
".",
"require",
"(",
"\"Valence\"",
")",
"return",
"sum",
"(",
"1",
"for",
"_",
",",
"a",
"in",
"mol",
".",
"atoms_iter",
"(",
")",
"if",
"a",
".",
"H_acceptor",
")"
] | Hydrogen bond acceptor count | [
"Hydrogen",
"bond",
"acceptor",
"count"
] | python | train | 38.25 |
dmwm/DBS | Server/Python/src/dbs/web/DBSReaderModel.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/web/DBSReaderModel.py#L744-L776 | def listBlocksParents(self):
"""
API to list block parents of multiple blocks. To be called by blockparents url with post call.
:param block_names: list of block names [block_name1, block_name2, ...] (Required). Mwx length 1000.
:type block_names: list
"""
try :
... | [
"def",
"listBlocksParents",
"(",
"self",
")",
":",
"try",
":",
"body",
"=",
"request",
".",
"body",
".",
"read",
"(",
")",
"data",
"=",
"cjson",
".",
"decode",
"(",
"body",
")",
"data",
"=",
"validateJSONInputNoCopy",
"(",
"\"block\"",
",",
"data",
","... | API to list block parents of multiple blocks. To be called by blockparents url with post call.
:param block_names: list of block names [block_name1, block_name2, ...] (Required). Mwx length 1000.
:type block_names: list | [
"API",
"to",
"list",
"block",
"parents",
"of",
"multiple",
"blocks",
".",
"To",
"be",
"called",
"by",
"blockparents",
"url",
"with",
"post",
"call",
"."
] | python | train | 57.454545 |
scanny/python-pptx | pptx/dml/line.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/dml/line.py#L26-L37 | def color(self):
"""
The |ColorFormat| instance that provides access to the color settings
for this line. Essentially a shortcut for ``line.fill.fore_color``.
As a side-effect, accessing this property causes the line fill type
to be set to ``MSO_FILL.SOLID``. If this sounds risky... | [
"def",
"color",
"(",
"self",
")",
":",
"if",
"self",
".",
"fill",
".",
"type",
"!=",
"MSO_FILL",
".",
"SOLID",
":",
"self",
".",
"fill",
".",
"solid",
"(",
")",
"return",
"self",
".",
"fill",
".",
"fore_color"
] | The |ColorFormat| instance that provides access to the color settings
for this line. Essentially a shortcut for ``line.fill.fore_color``.
As a side-effect, accessing this property causes the line fill type
to be set to ``MSO_FILL.SOLID``. If this sounds risky for your use
case, use ``lin... | [
"The",
"|ColorFormat|",
"instance",
"that",
"provides",
"access",
"to",
"the",
"color",
"settings",
"for",
"this",
"line",
".",
"Essentially",
"a",
"shortcut",
"for",
"line",
".",
"fill",
".",
"fore_color",
".",
"As",
"a",
"side",
"-",
"effect",
"accessing",... | python | train | 45.333333 |
PyProphet/pyprophet | pyprophet/main.py | https://github.com/PyProphet/pyprophet/blob/f546ad171750cd7685afbde6785fe71f82cadb35/pyprophet/main.py#L75-L95 | def score(infile, outfile, classifier, xgb_autotune, apply_weights, xeval_fraction, xeval_num_iter, ss_initial_fdr, ss_iteration_fdr, ss_num_iter, ss_main_score, group_id, parametric, pfdr, pi0_lambda, pi0_method, pi0_smooth_df, pi0_smooth_log_pi0, lfdr_truncate, lfdr_monotone, lfdr_transformation, lfdr_adj, lfdr_eps, ... | [
"def",
"score",
"(",
"infile",
",",
"outfile",
",",
"classifier",
",",
"xgb_autotune",
",",
"apply_weights",
",",
"xeval_fraction",
",",
"xeval_num_iter",
",",
"ss_initial_fdr",
",",
"ss_iteration_fdr",
",",
"ss_num_iter",
",",
"ss_main_score",
",",
"group_id",
",... | Conduct semi-supervised learning and error-rate estimation for MS1, MS2 and transition-level data. | [
"Conduct",
"semi",
"-",
"supervised",
"learning",
"and",
"error",
"-",
"rate",
"estimation",
"for",
"MS1",
"MS2",
"and",
"transition",
"-",
"level",
"data",
"."
] | python | test | 127.952381 |
yjzhang/uncurl_python | uncurl/nb_state_estimation.py | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_state_estimation.py#L12-L42 | def _create_w_objective(m, X, R):
"""
Creates an objective function and its derivative for W, given M and X (data)
Args:
m (array): genes x clusters
X (array): genes x cells
R (array): 1 x genes
"""
genes, clusters = m.shape
cells = X.shape[1]
R1 = R.reshape((genes, ... | [
"def",
"_create_w_objective",
"(",
"m",
",",
"X",
",",
"R",
")",
":",
"genes",
",",
"clusters",
"=",
"m",
".",
"shape",
"cells",
"=",
"X",
".",
"shape",
"[",
"1",
"]",
"R1",
"=",
"R",
".",
"reshape",
"(",
"(",
"genes",
",",
"1",
")",
")",
"."... | Creates an objective function and its derivative for W, given M and X (data)
Args:
m (array): genes x clusters
X (array): genes x cells
R (array): 1 x genes | [
"Creates",
"an",
"objective",
"function",
"and",
"its",
"derivative",
"for",
"W",
"given",
"M",
"and",
"X",
"(",
"data",
")"
] | python | train | 32.806452 |
a1ezzz/wasp-general | wasp_general/cache.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L334-L352 | def get_cache(self, decorated_function, *args, **kwargs):
""" :meth:`WCacheStorage.get_cache` method implementation
"""
self.__check(decorated_function, *args, **kwargs)
if decorated_function in self._storage:
for i in self._storage[decorated_function]:
if i['instance']() == args[0]:
result = i['res... | [
"def",
"get_cache",
"(",
"self",
",",
"decorated_function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"__check",
"(",
"decorated_function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"decorated_function",
"in",
"self",
... | :meth:`WCacheStorage.get_cache` method implementation | [
":",
"meth",
":",
"WCacheStorage",
".",
"get_cache",
"method",
"implementation"
] | python | train | 31.263158 |
graphcommons/graphcommons-python | graphcommons.py | https://github.com/graphcommons/graphcommons-python/blob/ebfa5bb2c800e17e6cffae83ece574f6d3a05428/graphcommons.py#L119-L134 | def sync(self, graph_commons):
"""Synchronize local and remote representations."""
if self['id'] is None:
return
remote_graph = graph_commons.graphs(self['id'])
# TODO: less forceful, more elegant
self.edges = remote_graph.edges
self.nodes = remote_graph.nod... | [
"def",
"sync",
"(",
"self",
",",
"graph_commons",
")",
":",
"if",
"self",
"[",
"'id'",
"]",
"is",
"None",
":",
"return",
"remote_graph",
"=",
"graph_commons",
".",
"graphs",
"(",
"self",
"[",
"'id'",
"]",
")",
"# TODO: less forceful, more elegant",
"self",
... | Synchronize local and remote representations. | [
"Synchronize",
"local",
"and",
"remote",
"representations",
"."
] | python | train | 43.0625 |
horazont/aioxmpp | aioxmpp/presence/service.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/presence/service.py#L164-L180 | def get_stanza(self, peer_jid):
"""
Return the last presence recieved for the given bare or full
`peer_jid`. If the last presence was unavailable, the return value is
:data:`None`, as if no presence was ever received.
If no presence was ever received for the given bare JID, :dat... | [
"def",
"get_stanza",
"(",
"self",
",",
"peer_jid",
")",
":",
"try",
":",
"return",
"self",
".",
"_presences",
"[",
"peer_jid",
".",
"bare",
"(",
")",
"]",
"[",
"peer_jid",
".",
"resource",
"]",
"except",
"KeyError",
":",
"pass",
"try",
":",
"return",
... | Return the last presence recieved for the given bare or full
`peer_jid`. If the last presence was unavailable, the return value is
:data:`None`, as if no presence was ever received.
If no presence was ever received for the given bare JID, :data:`None`
is returned. | [
"Return",
"the",
"last",
"presence",
"recieved",
"for",
"the",
"given",
"bare",
"or",
"full",
"peer_jid",
".",
"If",
"the",
"last",
"presence",
"was",
"unavailable",
"the",
"return",
"value",
"is",
":",
"data",
":",
"None",
"as",
"if",
"no",
"presence",
... | python | train | 34.352941 |
census-instrumentation/opencensus-python | contrib/opencensus-ext-grpc/opencensus/ext/grpc/utils.py | https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/contrib/opencensus-ext-grpc/opencensus/ext/grpc/utils.py#L25-L40 | def wrap_iter_with_message_events(
request_or_response_iter,
span,
message_event_type
):
"""Wraps a request or response iterator to add message events to the span
for each proto message sent or received
"""
for message_id, message in enumerate(request_or_response_iter, start=1):
add_... | [
"def",
"wrap_iter_with_message_events",
"(",
"request_or_response_iter",
",",
"span",
",",
"message_event_type",
")",
":",
"for",
"message_id",
",",
"message",
"in",
"enumerate",
"(",
"request_or_response_iter",
",",
"start",
"=",
"1",
")",
":",
"add_message_event",
... | Wraps a request or response iterator to add message events to the span
for each proto message sent or received | [
"Wraps",
"a",
"request",
"or",
"response",
"iterator",
"to",
"add",
"message",
"events",
"to",
"the",
"span",
"for",
"each",
"proto",
"message",
"sent",
"or",
"received"
] | python | train | 30.875 |
gwastro/pycbc-glue | pycbc_glue/ligolw/dbtables.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/dbtables.py#L488-L508 | def idmap_get_max_id(connection, id_class):
"""
Given an ilwd:char ID class, return the highest ID from the table
for whose IDs that is the class.
Example:
>>> event_id = ilwd.ilwdchar("sngl_burst:event_id:0")
>>> print event_id
sngl_inspiral:event_id:0
>>> max_id = get_max_id(connection, type(event_id))
>>>... | [
"def",
"idmap_get_max_id",
"(",
"connection",
",",
"id_class",
")",
":",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"\"SELECT MAX(CAST(SUBSTR(%s, %d, 10) AS INTEGER)) FROM %s\"",
"%",
"(",
"id_class",
".",
"column_name",
","... | Given an ilwd:char ID class, return the highest ID from the table
for whose IDs that is the class.
Example:
>>> event_id = ilwd.ilwdchar("sngl_burst:event_id:0")
>>> print event_id
sngl_inspiral:event_id:0
>>> max_id = get_max_id(connection, type(event_id))
>>> print max_id
sngl_inspiral:event_id:1054 | [
"Given",
"an",
"ilwd",
":",
"char",
"ID",
"class",
"return",
"the",
"highest",
"ID",
"from",
"the",
"table",
"for",
"whose",
"IDs",
"that",
"is",
"the",
"class",
"."
] | python | train | 29.904762 |
cognitect/transit-python | transit/rolling_cache.py | https://github.com/cognitect/transit-python/blob/59e27e7d322feaa3a7e8eb3de06ae96d8adb614f/transit/rolling_cache.py#L67-L71 | def encode(self, name, as_map_key=False):
"""Returns the name the first time and the key after that"""
if name in self.key_to_value:
return self.key_to_value[name]
return self.encache(name) if is_cacheable(name, as_map_key) else name | [
"def",
"encode",
"(",
"self",
",",
"name",
",",
"as_map_key",
"=",
"False",
")",
":",
"if",
"name",
"in",
"self",
".",
"key_to_value",
":",
"return",
"self",
".",
"key_to_value",
"[",
"name",
"]",
"return",
"self",
".",
"encache",
"(",
"name",
")",
"... | Returns the name the first time and the key after that | [
"Returns",
"the",
"name",
"the",
"first",
"time",
"and",
"the",
"key",
"after",
"that"
] | python | train | 53 |
JonathanRaiman/pytreebank | pytreebank/treelstm.py | https://github.com/JonathanRaiman/pytreebank/blob/7b4c671d3dff661cc3677e54db817e50c5a1c666/pytreebank/treelstm.py#L8-L42 | def import_tree_corpus(labels_path, parents_path, texts_path):
"""
Import dataset from the TreeLSTM data generation scrips.
Arguments:
----------
labels_path : str, where are labels are stored (should be in
data/sst/labels.txt).
parents_path : str, where the parent relations... | [
"def",
"import_tree_corpus",
"(",
"labels_path",
",",
"parents_path",
",",
"texts_path",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"labels_path",
",",
"\"r\"",
",",
"\"UTF-8\"",
")",
"as",
"f",
":",
"label_lines",
"=",
"f",
".",
"readlines",
"(",
")",
... | Import dataset from the TreeLSTM data generation scrips.
Arguments:
----------
labels_path : str, where are labels are stored (should be in
data/sst/labels.txt).
parents_path : str, where the parent relationships are stored
(should be in data/sst/parents.txt).
te... | [
"Import",
"dataset",
"from",
"the",
"TreeLSTM",
"data",
"generation",
"scrips",
"."
] | python | train | 37.142857 |
derpston/python-multitail2 | src/multitail2.py | https://github.com/derpston/python-multitail2/blob/4f05311da3b18f7a8cfe2877e68e35e88c07298d/src/multitail2.py#L213-L216 | def offsets(self):
"""A generator producing a (path, offset) tuple for all tailed files."""
for path, tailedfile in self._tailedfiles.iteritems():
yield path, tailedfile._offset | [
"def",
"offsets",
"(",
"self",
")",
":",
"for",
"path",
",",
"tailedfile",
"in",
"self",
".",
"_tailedfiles",
".",
"iteritems",
"(",
")",
":",
"yield",
"path",
",",
"tailedfile",
".",
"_offset"
] | A generator producing a (path, offset) tuple for all tailed files. | [
"A",
"generator",
"producing",
"a",
"(",
"path",
"offset",
")",
"tuple",
"for",
"all",
"tailed",
"files",
"."
] | python | train | 48.75 |
apache/incubator-mxnet | example/gluon/embedding_learning/data.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/embedding_learning/data.py#L26-L53 | def transform(data, target_wd, target_ht, is_train, box):
"""Crop and normnalize an image nd array."""
if box is not None:
x, y, w, h = box
data = data[y:min(y+h, data.shape[0]), x:min(x+w, data.shape[1])]
# Resize to target_wd * target_ht.
data = mx.image.imresize(data, target_wd, targ... | [
"def",
"transform",
"(",
"data",
",",
"target_wd",
",",
"target_ht",
",",
"is_train",
",",
"box",
")",
":",
"if",
"box",
"is",
"not",
"None",
":",
"x",
",",
"y",
",",
"w",
",",
"h",
"=",
"box",
"data",
"=",
"data",
"[",
"y",
":",
"min",
"(",
... | Crop and normnalize an image nd array. | [
"Crop",
"and",
"normnalize",
"an",
"image",
"nd",
"array",
"."
] | python | train | 36 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ClientFactory.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ClientFactory.py#L489-L495 | def create_network(self):
"""Get an instance of vlan services facade."""
return Network(
self.networkapi_url,
self.user,
self.password,
self.user_ldap) | [
"def",
"create_network",
"(",
"self",
")",
":",
"return",
"Network",
"(",
"self",
".",
"networkapi_url",
",",
"self",
".",
"user",
",",
"self",
".",
"password",
",",
"self",
".",
"user_ldap",
")"
] | Get an instance of vlan services facade. | [
"Get",
"an",
"instance",
"of",
"vlan",
"services",
"facade",
"."
] | python | train | 29.857143 |
numenta/htmresearch | htmresearch/frameworks/pytorch/continual_learning_experiment.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/pytorch/continual_learning_experiment.py#L157-L189 | def createDenseCNNModel(self):
"""
Create a standard network composed of two CNN / MaxPool layers followed by a
linear layer with using ReLU activation between the layers
"""
# Create denseCNN2 model
model = nn.Sequential(
nn.Conv2d(in_channels=self.in_channels, out_channels=self.out_chan... | [
"def",
"createDenseCNNModel",
"(",
"self",
")",
":",
"# Create denseCNN2 model",
"model",
"=",
"nn",
".",
"Sequential",
"(",
"nn",
".",
"Conv2d",
"(",
"in_channels",
"=",
"self",
".",
"in_channels",
",",
"out_channels",
"=",
"self",
".",
"out_channels",
"[",
... | Create a standard network composed of two CNN / MaxPool layers followed by a
linear layer with using ReLU activation between the layers | [
"Create",
"a",
"standard",
"network",
"composed",
"of",
"two",
"CNN",
"/",
"MaxPool",
"layers",
"followed",
"by",
"a",
"linear",
"layer",
"with",
"using",
"ReLU",
"activation",
"between",
"the",
"layers"
] | python | train | 30.333333 |
pywbem/pywbem | pywbem/cim_operations.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_operations.py#L2233-L2251 | def _iparam_instancename(instancename):
"""
Convert an instance name specified in an operation method into a CIM
object that can be passed to imethodcall().
"""
if isinstance(instancename, CIMInstanceName):
instancename = instancename.copy()
instancename.... | [
"def",
"_iparam_instancename",
"(",
"instancename",
")",
":",
"if",
"isinstance",
"(",
"instancename",
",",
"CIMInstanceName",
")",
":",
"instancename",
"=",
"instancename",
".",
"copy",
"(",
")",
"instancename",
".",
"host",
"=",
"None",
"instancename",
".",
... | Convert an instance name specified in an operation method into a CIM
object that can be passed to imethodcall(). | [
"Convert",
"an",
"instance",
"name",
"specified",
"in",
"an",
"operation",
"method",
"into",
"a",
"CIM",
"object",
"that",
"can",
"be",
"passed",
"to",
"imethodcall",
"()",
"."
] | python | train | 38.526316 |
pyamg/pyamg | pyamg/strength.py | https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/strength.py#L329-L473 | def energy_based_strength_of_connection(A, theta=0.0, k=2):
"""Energy Strength Measure.
Compute a strength of connection matrix using an energy-based measure.
Parameters
----------
A : sparse-matrix
matrix from which to generate strength of connection information
theta : float
... | [
"def",
"energy_based_strength_of_connection",
"(",
"A",
",",
"theta",
"=",
"0.0",
",",
"k",
"=",
"2",
")",
":",
"if",
"(",
"theta",
"<",
"0",
")",
":",
"raise",
"ValueError",
"(",
"'expected a positive theta'",
")",
"if",
"not",
"sparse",
".",
"isspmatrix"... | Energy Strength Measure.
Compute a strength of connection matrix using an energy-based measure.
Parameters
----------
A : sparse-matrix
matrix from which to generate strength of connection information
theta : float
Threshold parameter in [0,1]
k : int
Number of relaxati... | [
"Energy",
"Strength",
"Measure",
"."
] | python | train | 34.186207 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.