repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
stevearc/dql | dql/models.py | https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/models.py#L167-L180 | def schema(self):
""" The DQL syntax for creating this item """
schema = "%s %s %s %s('%s'" % (
self.name,
self.data_type,
self.index_type,
self.key_type,
self.index_name,
)
if self.includes is not None:
schema += ",... | [
"def",
"schema",
"(",
"self",
")",
":",
"schema",
"=",
"\"%s %s %s %s('%s'\"",
"%",
"(",
"self",
".",
"name",
",",
"self",
".",
"data_type",
",",
"self",
".",
"index_type",
",",
"self",
".",
"key_type",
",",
"self",
".",
"index_name",
",",
")",
"if",
... | The DQL syntax for creating this item | [
"The",
"DQL",
"syntax",
"for",
"creating",
"this",
"item"
] | python | train |
jmcarp/betfair.py | betfair/betfair.py | https://github.com/jmcarp/betfair.py/blob/116df2fdc512575d1b4c4f1749d4a5bf98e519ff/betfair/betfair.py#L432-L444 | def update_orders(self, market_id, instructions, customer_ref=None):
"""Update non-exposure changing fields.
:param str market_id: The market id these orders are to be placed on
:param list instructions: List of `UpdateInstruction` objects
:param str customer_ref: Optional order identif... | [
"def",
"update_orders",
"(",
"self",
",",
"market_id",
",",
"instructions",
",",
"customer_ref",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_api_request",
"(",
"'Sports'",
",",
"'updateOrders'",
",",
"utils",
".",
"get_kwargs",
"(",
"locals",
"(",
")... | Update non-exposure changing fields.
:param str market_id: The market id these orders are to be placed on
:param list instructions: List of `UpdateInstruction` objects
:param str customer_ref: Optional order identifier string | [
"Update",
"non",
"-",
"exposure",
"changing",
"fields",
"."
] | python | train |
openstack/pyghmi | pyghmi/ipmi/command.py | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L787-L825 | def set_net_configuration(self, ipv4_address=None, ipv4_configuration=None,
ipv4_gateway=None, channel=None):
"""Set network configuration data.
Apply desired network configuration data, leaving unspecified
parameters alone.
:param ipv4_address: CIDR nota... | [
"def",
"set_net_configuration",
"(",
"self",
",",
"ipv4_address",
"=",
"None",
",",
"ipv4_configuration",
"=",
"None",
",",
"ipv4_gateway",
"=",
"None",
",",
"channel",
"=",
"None",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",... | Set network configuration data.
Apply desired network configuration data, leaving unspecified
parameters alone.
:param ipv4_address: CIDR notation for IP address and netmask
Example: '192.168.0.10/16'
:param ipv4_configuration: Method to use to configure the ... | [
"Set",
"network",
"configuration",
"data",
"."
] | python | train |
thieman/dagobah | dagobah/core/core.py | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L364-L373 | def delete_dependency(self, from_task_name, to_task_name):
""" Delete a dependency between two tasks. """
logger.debug('Deleting dependency from {0} to {1}'.format(from_task_name, to_task_name))
if not self.state.allow_change_graph:
raise DagobahError("job's graph is immutable in it... | [
"def",
"delete_dependency",
"(",
"self",
",",
"from_task_name",
",",
"to_task_name",
")",
":",
"logger",
".",
"debug",
"(",
"'Deleting dependency from {0} to {1}'",
".",
"format",
"(",
"from_task_name",
",",
"to_task_name",
")",
")",
"if",
"not",
"self",
".",
"s... | Delete a dependency between two tasks. | [
"Delete",
"a",
"dependency",
"between",
"two",
"tasks",
"."
] | python | train |
benley/butcher | butcher/buildfile.py | https://github.com/benley/butcher/blob/8b18828ea040af56b7835beab5fd03eab23cc9ee/butcher/buildfile.py#L135-L177 | def _parse(self, stream):
"""Parse a JSON BUILD file.
Args:
builddata: dictionary of buildfile data
reponame: name of the repo that it came from
path: directory path within the repo
"""
builddata = json.load(stream)
log.debug('This is a JSON build f... | [
"def",
"_parse",
"(",
"self",
",",
"stream",
")",
":",
"builddata",
"=",
"json",
".",
"load",
"(",
"stream",
")",
"log",
".",
"debug",
"(",
"'This is a JSON build file.'",
")",
"if",
"'targets'",
"not",
"in",
"builddata",
":",
"log",
".",
"warn",
"(",
... | Parse a JSON BUILD file.
Args:
builddata: dictionary of buildfile data
reponame: name of the repo that it came from
path: directory path within the repo | [
"Parse",
"a",
"JSON",
"BUILD",
"file",
"."
] | python | train |
sendgrid/sendgrid-python | sendgrid/helpers/mail/mail.py | https://github.com/sendgrid/sendgrid-python/blob/266c2abde7a35dfcce263e06bedc6a0bbdebeac9/sendgrid/helpers/mail/mail.py#L967-L990 | def from_EmailMessage(cls, message):
"""Create a Mail object from an instance of
email.message.EmailMessage.
:type message: email.message.EmailMessage
:rtype: Mail
"""
mail = cls(
from_email=Email(message.get('From')),
subject=message.get('Subject... | [
"def",
"from_EmailMessage",
"(",
"cls",
",",
"message",
")",
":",
"mail",
"=",
"cls",
"(",
"from_email",
"=",
"Email",
"(",
"message",
".",
"get",
"(",
"'From'",
")",
")",
",",
"subject",
"=",
"message",
".",
"get",
"(",
"'Subject'",
")",
",",
"to_em... | Create a Mail object from an instance of
email.message.EmailMessage.
:type message: email.message.EmailMessage
:rtype: Mail | [
"Create",
"a",
"Mail",
"object",
"from",
"an",
"instance",
"of",
"email",
".",
"message",
".",
"EmailMessage",
"."
] | python | train |
theosysbio/means | src/means/approximation/mea/mea_helpers.py | https://github.com/theosysbio/means/blob/fe164916a1d84ab2a4fa039871d38ccdf638b1db/src/means/approximation/mea/mea_helpers.py#L80-L90 | def make_k_chose_e(e_vec, k_vec):
"""
Computes the product :math:`{\mathbf{n} \choose \mathbf{k}}`
:param e_vec: the vector e
:type e_vec: :class:`numpy.array`
:param k_vec: the vector k
:type k_vec: :class:`numpy.array`
:return: a scalar
"""
return product([sp.factorial(k) / (sp.fa... | [
"def",
"make_k_chose_e",
"(",
"e_vec",
",",
"k_vec",
")",
":",
"return",
"product",
"(",
"[",
"sp",
".",
"factorial",
"(",
"k",
")",
"/",
"(",
"sp",
".",
"factorial",
"(",
"e",
")",
"*",
"sp",
".",
"factorial",
"(",
"k",
"-",
"e",
")",
")",
"fo... | Computes the product :math:`{\mathbf{n} \choose \mathbf{k}}`
:param e_vec: the vector e
:type e_vec: :class:`numpy.array`
:param k_vec: the vector k
:type k_vec: :class:`numpy.array`
:return: a scalar | [
"Computes",
"the",
"product",
":",
"math",
":",
"{",
"\\",
"mathbf",
"{",
"n",
"}",
"\\",
"choose",
"\\",
"mathbf",
"{",
"k",
"}}"
] | python | train |
ybrs/pydisque | example/poor_consumer.py | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/example/poor_consumer.py#L27-L78 | def main():
"""Start the poor_consumer."""
try:
opts, args = getopt.getopt(sys.argv[1:], "h:v", ["help", "nack=",
"servers=", "queues="])
except getopt.GetoptError as err:
print str(err)
usage()
sys.exit()
# defaults
nack = 0.0
... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"opts",
",",
"args",
"=",
"getopt",
".",
"getopt",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
",",
"\"h:v\"",
",",
"[",
"\"help\"",
",",
"\"nack=\"",
",",
"\"servers=\"",
",",
"\"queues=\"",
"]",
")",
"... | Start the poor_consumer. | [
"Start",
"the",
"poor_consumer",
"."
] | python | train |
wonambi-python/wonambi | wonambi/widgets/notes.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/notes.py#L823-L842 | def delete_row(self):
"""Delete bookmarks or event from annotations, based on row."""
sel_model = self.idx_annot_list.selectionModel()
for row in sel_model.selectedRows():
i = row.row()
start = self.idx_annot_list.property('start')[i]
end = self.idx_annot_list... | [
"def",
"delete_row",
"(",
"self",
")",
":",
"sel_model",
"=",
"self",
".",
"idx_annot_list",
".",
"selectionModel",
"(",
")",
"for",
"row",
"in",
"sel_model",
".",
"selectedRows",
"(",
")",
":",
"i",
"=",
"row",
".",
"row",
"(",
")",
"start",
"=",
"s... | Delete bookmarks or event from annotations, based on row. | [
"Delete",
"bookmarks",
"or",
"event",
"from",
"annotations",
"based",
"on",
"row",
"."
] | python | train |
miyakogi/wdom | wdom/web_node.py | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L259-L266 | def removeChild(self, child: Node) -> Node:
"""Remove the child node from this node.
If the node is not a child of this node, raise ValueError.
"""
if self.connected:
self._remove_child_web(child)
return self._remove_child(child) | [
"def",
"removeChild",
"(",
"self",
",",
"child",
":",
"Node",
")",
"->",
"Node",
":",
"if",
"self",
".",
"connected",
":",
"self",
".",
"_remove_child_web",
"(",
"child",
")",
"return",
"self",
".",
"_remove_child",
"(",
"child",
")"
] | Remove the child node from this node.
If the node is not a child of this node, raise ValueError. | [
"Remove",
"the",
"child",
"node",
"from",
"this",
"node",
"."
] | python | train |
greyli/flask-avatars | flask_avatars/__init__.py | https://github.com/greyli/flask-avatars/blob/13eca90342349c58962fef0ec541edcb1b009c70/flask_avatars/__init__.py#L122-L134 | def crop_box(endpoint=None, filename=None):
"""Create a crop box.
:param endpoint: The endpoint of view function that serve avatar image file.
:param filename: The filename of the image that need to be crop.
"""
crop_size = current_app.config['AVATARS_CROP_BASE_WIDTH']
... | [
"def",
"crop_box",
"(",
"endpoint",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"crop_size",
"=",
"current_app",
".",
"config",
"[",
"'AVATARS_CROP_BASE_WIDTH'",
"]",
"if",
"endpoint",
"is",
"None",
"or",
"filename",
"is",
"None",
":",
"url",
"=",... | Create a crop box.
:param endpoint: The endpoint of view function that serve avatar image file.
:param filename: The filename of the image that need to be crop. | [
"Create",
"a",
"crop",
"box",
"."
] | python | train |
hotdoc/hotdoc | hotdoc/utils/setup_utils.py | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/utils/setup_utils.py#L93-L113 | def require_clean_submodules(repo_root, submodules):
"""Check on git submodules before distutils can do anything
Since distutils cannot be trusted to update the tree
after everything has been set in motion,
this is not a distutils command.
"""
# PACKAGERS: Add a return here to skip checks for gi... | [
"def",
"require_clean_submodules",
"(",
"repo_root",
",",
"submodules",
")",
":",
"# PACKAGERS: Add a return here to skip checks for git submodules",
"# don't do anything if nothing is actually supposed to happen",
"for",
"do_nothing",
"in",
"(",
"'-h'",
",",
"'--help'",
",",
"'-... | Check on git submodules before distutils can do anything
Since distutils cannot be trusted to update the tree
after everything has been set in motion,
this is not a distutils command. | [
"Check",
"on",
"git",
"submodules",
"before",
"distutils",
"can",
"do",
"anything",
"Since",
"distutils",
"cannot",
"be",
"trusted",
"to",
"update",
"the",
"tree",
"after",
"everything",
"has",
"been",
"set",
"in",
"motion",
"this",
"is",
"not",
"a",
"distut... | python | train |
GoogleCloudPlatform/appengine-pipelines | python/src/pipeline/pipeline.py | https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1708-L1771 | def continue_abort(self,
root_pipeline_key,
cursor=None,
max_to_notify=_MAX_ABORTS_TO_BEGIN):
"""Sends the abort signal to all children for a root pipeline.
Args:
root_pipeline_key: db.Key of the root pipeline to abort.
cursor: The quer... | [
"def",
"continue_abort",
"(",
"self",
",",
"root_pipeline_key",
",",
"cursor",
"=",
"None",
",",
"max_to_notify",
"=",
"_MAX_ABORTS_TO_BEGIN",
")",
":",
"if",
"not",
"isinstance",
"(",
"root_pipeline_key",
",",
"db",
".",
"Key",
")",
":",
"root_pipeline_key",
... | Sends the abort signal to all children for a root pipeline.
Args:
root_pipeline_key: db.Key of the root pipeline to abort.
cursor: The query cursor for enumerating _PipelineRecords when inserting
tasks to cause child pipelines to terminate.
max_to_notify: Used for testing. | [
"Sends",
"the",
"abort",
"signal",
"to",
"all",
"children",
"for",
"a",
"root",
"pipeline",
"."
] | python | train |
pandas-dev/pandas | pandas/io/pytables.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pytables.py#L3793-L3829 | def read_column(self, column, where=None, start=None, stop=None):
"""return a single column from the table, generally only indexables
are interesting
"""
# validate the version
self.validate_version()
# infer the data kind
if not self.infer_axes():
r... | [
"def",
"read_column",
"(",
"self",
",",
"column",
",",
"where",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"# validate the version",
"self",
".",
"validate_version",
"(",
")",
"# infer the data kind",
"if",
"not",
"self",
"... | return a single column from the table, generally only indexables
are interesting | [
"return",
"a",
"single",
"column",
"from",
"the",
"table",
"generally",
"only",
"indexables",
"are",
"interesting"
] | python | train |
wummel/dosage | dosagelib/scraper.py | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/scraper.py#L528-L537 | def check_scrapers():
"""Check for duplicate scraper class names."""
d = {}
for scraperclass in _scraperclasses:
name = scraperclass.getName().lower()
if name in d:
name1 = scraperclass.getName()
name2 = d[name].getName()
raise ValueError('duplicate scrape... | [
"def",
"check_scrapers",
"(",
")",
":",
"d",
"=",
"{",
"}",
"for",
"scraperclass",
"in",
"_scraperclasses",
":",
"name",
"=",
"scraperclass",
".",
"getName",
"(",
")",
".",
"lower",
"(",
")",
"if",
"name",
"in",
"d",
":",
"name1",
"=",
"scraperclass",
... | Check for duplicate scraper class names. | [
"Check",
"for",
"duplicate",
"scraper",
"class",
"names",
"."
] | python | train |
contains-io/rcli | rcli/call.py | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/call.py#L45-L78 | def call(func, args):
"""Call the function with args normalized and cast to the correct types.
Args:
func: The function to call.
args: The arguments parsed by docopt.
Returns:
The return value of func.
"""
assert hasattr(func, '__call__'), 'Cannot call func: {}'.format(
... | [
"def",
"call",
"(",
"func",
",",
"args",
")",
":",
"assert",
"hasattr",
"(",
"func",
",",
"'__call__'",
")",
",",
"'Cannot call func: {}'",
".",
"format",
"(",
"func",
".",
"__name__",
")",
"raw_func",
"=",
"(",
"func",
"if",
"isinstance",
"(",
"func",
... | Call the function with args normalized and cast to the correct types.
Args:
func: The function to call.
args: The arguments parsed by docopt.
Returns:
The return value of func. | [
"Call",
"the",
"function",
"with",
"args",
"normalized",
"and",
"cast",
"to",
"the",
"correct",
"types",
"."
] | python | train |
OpenTreeOfLife/peyotl | peyotl/utility/input_output.py | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/input_output.py#L53-L58 | def download(url, encoding='utf-8'):
"""Returns the text fetched via http GET from URL, read as `encoding`"""
import requests
response = requests.get(url)
response.encoding = encoding
return response.text | [
"def",
"download",
"(",
"url",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"import",
"requests",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"response",
".",
"encoding",
"=",
"encoding",
"return",
"response",
".",
"text"
] | Returns the text fetched via http GET from URL, read as `encoding` | [
"Returns",
"the",
"text",
"fetched",
"via",
"http",
"GET",
"from",
"URL",
"read",
"as",
"encoding"
] | python | train |
IdentityPython/pysaml2 | src/saml2/assertion.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/assertion.py#L736-L808 | def construct(self, sp_entity_id, attrconvs, policy, issuer, farg,
authn_class=None, authn_auth=None, authn_decl=None,
encrypt=None, sec_context=None, authn_decl_ref=None,
authn_instant="", subject_locality="", authn_statem=None,
name_id=None, sess... | [
"def",
"construct",
"(",
"self",
",",
"sp_entity_id",
",",
"attrconvs",
",",
"policy",
",",
"issuer",
",",
"farg",
",",
"authn_class",
"=",
"None",
",",
"authn_auth",
"=",
"None",
",",
"authn_decl",
"=",
"None",
",",
"encrypt",
"=",
"None",
",",
"sec_con... | Construct the Assertion
:param sp_entity_id: The entityid of the SP
:param in_response_to: An identifier of the message, this message is
a response to
:param name_id: An NameID instance
:param attrconvs: AttributeConverters
:param policy: The policy that should be ad... | [
"Construct",
"the",
"Assertion"
] | python | train |
pandas-dev/pandas | pandas/io/html.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/html.py#L806-L846 | def _parser_dispatch(flavor):
"""Choose the parser based on the input flavor.
Parameters
----------
flavor : str
The type of parser to use. This must be a valid backend.
Returns
-------
cls : _HtmlFrameParser subclass
The parser class based on the requested input flavor.
... | [
"def",
"_parser_dispatch",
"(",
"flavor",
")",
":",
"valid_parsers",
"=",
"list",
"(",
"_valid_parsers",
".",
"keys",
"(",
")",
")",
"if",
"flavor",
"not",
"in",
"valid_parsers",
":",
"raise",
"ValueError",
"(",
"'{invalid!r} is not a valid flavor, valid flavors '",... | Choose the parser based on the input flavor.
Parameters
----------
flavor : str
The type of parser to use. This must be a valid backend.
Returns
-------
cls : _HtmlFrameParser subclass
The parser class based on the requested input flavor.
Raises
------
ValueError
... | [
"Choose",
"the",
"parser",
"based",
"on",
"the",
"input",
"flavor",
"."
] | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/textio.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/textio.py#L1816-L1835 | def __do_log(self, text):
"""
Writes the given text verbatim into the log file (if any)
and/or standard input (if the verbose flag is turned on).
Used internally.
@type text: str
@param text: Text to print.
"""
if isinstance(text, compat.unicode):
... | [
"def",
"__do_log",
"(",
"self",
",",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"compat",
".",
"unicode",
")",
":",
"text",
"=",
"text",
".",
"encode",
"(",
"'cp1252'",
")",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"text",
")",... | Writes the given text verbatim into the log file (if any)
and/or standard input (if the verbose flag is turned on).
Used internally.
@type text: str
@param text: Text to print. | [
"Writes",
"the",
"given",
"text",
"verbatim",
"into",
"the",
"log",
"file",
"(",
"if",
"any",
")",
"and",
"/",
"or",
"standard",
"input",
"(",
"if",
"the",
"verbose",
"flag",
"is",
"turned",
"on",
")",
"."
] | python | train |
SMTG-UCL/sumo | sumo/plotting/phonon_bs_plotter.py | https://github.com/SMTG-UCL/sumo/blob/47aec6bbfa033a624435a65bd4edabd18bfb437f/sumo/plotting/phonon_bs_plotter.py#L169-L208 | def _maketicks(self, ax, units='THz'):
"""Utility method to add tick marks to a band structure."""
# set y-ticks
ax.yaxis.set_major_locator(MaxNLocator(6))
ax.yaxis.set_minor_locator(AutoMinorLocator(2))
ax.xaxis.set_minor_locator(AutoMinorLocator(2))
# set x-ticks; only... | [
"def",
"_maketicks",
"(",
"self",
",",
"ax",
",",
"units",
"=",
"'THz'",
")",
":",
"# set y-ticks",
"ax",
".",
"yaxis",
".",
"set_major_locator",
"(",
"MaxNLocator",
"(",
"6",
")",
")",
"ax",
".",
"yaxis",
".",
"set_minor_locator",
"(",
"AutoMinorLocator",... | Utility method to add tick marks to a band structure. | [
"Utility",
"method",
"to",
"add",
"tick",
"marks",
"to",
"a",
"band",
"structure",
"."
] | python | train |
googlefonts/fontbakery | Lib/fontbakery/profiles/googlefonts.py | https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/googlefonts.py#L1465-L1477 | def com_google_fonts_check_metadata_menu_and_latin(family_metadata):
"""METADATA.pb should contain at least "menu" and "latin" subsets."""
missing = []
for s in ["menu", "latin"]:
if s not in list(family_metadata.subsets):
missing.append(s)
if missing != []:
yield FAIL, ("Subsets \"menu\" and \"l... | [
"def",
"com_google_fonts_check_metadata_menu_and_latin",
"(",
"family_metadata",
")",
":",
"missing",
"=",
"[",
"]",
"for",
"s",
"in",
"[",
"\"menu\"",
",",
"\"latin\"",
"]",
":",
"if",
"s",
"not",
"in",
"list",
"(",
"family_metadata",
".",
"subsets",
")",
"... | METADATA.pb should contain at least "menu" and "latin" subsets. | [
"METADATA",
".",
"pb",
"should",
"contain",
"at",
"least",
"menu",
"and",
"latin",
"subsets",
"."
] | python | train |
ming060/robotframework-uiautomatorlibrary | uiautomatorlibrary/Mobile.py | https://github.com/ming060/robotframework-uiautomatorlibrary/blob/b70202b6a8aa68b4efd9d029c2845407fb33451a/uiautomatorlibrary/Mobile.py#L255-L263 | def swipe_by_coordinates(self, sx, sy, ex, ey, steps=10):
"""
Swipe from (sx, sy) to (ex, ey) with *steps* .
Example:
| Swipe By Coordinates | 540 | 1340 | 940 | 1340 | | # Swipe from (540, 1340) to (940, 100) with default steps 10 |
| Swipe By Coordinates | 540 | 1340 | 940... | [
"def",
"swipe_by_coordinates",
"(",
"self",
",",
"sx",
",",
"sy",
",",
"ex",
",",
"ey",
",",
"steps",
"=",
"10",
")",
":",
"self",
".",
"device",
".",
"swipe",
"(",
"sx",
",",
"sy",
",",
"ex",
",",
"ey",
",",
"steps",
")"
] | Swipe from (sx, sy) to (ex, ey) with *steps* .
Example:
| Swipe By Coordinates | 540 | 1340 | 940 | 1340 | | # Swipe from (540, 1340) to (940, 100) with default steps 10 |
| Swipe By Coordinates | 540 | 1340 | 940 | 1340 | 100 | # Swipe from (540, 1340) to (940, 100) with steps 100 | | [
"Swipe",
"from",
"(",
"sx",
"sy",
")",
"to",
"(",
"ex",
"ey",
")",
"with",
"*",
"steps",
"*",
"."
] | python | train |
yoavaviram/python-amazon-simple-product-api | amazon/api.py | https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L321-L356 | def cart_add(self, items, CartId=None, HMAC=None, **kwargs):
"""CartAdd.
:param items:
A dictionary containing the items to be added to the cart.
Or a list containing these dictionaries.
It is not possible to create an empty cart!
example: [{'offer_id': 'r... | [
"def",
"cart_add",
"(",
"self",
",",
"items",
",",
"CartId",
"=",
"None",
",",
"HMAC",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"CartId",
"or",
"not",
"HMAC",
":",
"raise",
"CartException",
"(",
"'CartId and HMAC required for CartAdd ca... | CartAdd.
:param items:
A dictionary containing the items to be added to the cart.
Or a list containing these dictionaries.
It is not possible to create an empty cart!
example: [{'offer_id': 'rt2ofih3f389nwiuhf8934z87o3f4h',
'quantity': 1}]
:par... | [
"CartAdd",
".",
":",
"param",
"items",
":",
"A",
"dictionary",
"containing",
"the",
"items",
"to",
"be",
"added",
"to",
"the",
"cart",
".",
"Or",
"a",
"list",
"containing",
"these",
"dictionaries",
".",
"It",
"is",
"not",
"possible",
"to",
"create",
"an"... | python | train |
The-Politico/politico-civic-election-night | electionnight/serializers/office.py | https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/serializers/office.py#L59-L63 | def get_content(self, obj):
"""All content for office's page on an election day."""
election_day = ElectionDay.objects.get(
date=self.context['election_date'])
return PageContent.objects.office_content(election_day, obj) | [
"def",
"get_content",
"(",
"self",
",",
"obj",
")",
":",
"election_day",
"=",
"ElectionDay",
".",
"objects",
".",
"get",
"(",
"date",
"=",
"self",
".",
"context",
"[",
"'election_date'",
"]",
")",
"return",
"PageContent",
".",
"objects",
".",
"office_conte... | All content for office's page on an election day. | [
"All",
"content",
"for",
"office",
"s",
"page",
"on",
"an",
"election",
"day",
"."
] | python | train |
AirtestProject/Poco | poco/utils/simplerpc/transport/tcp/protocol.py | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/transport/tcp/protocol.py#L25-L37 | def input(self, data):
""" 小数据片段拼接成完整数据包
如果内容足够则yield数据包
"""
self.buf += data
while len(self.buf) > HEADER_SIZE:
data_len = struct.unpack('i', self.buf[0:HEADER_SIZE])[0]
if len(self.buf) >= data_len + HEADER_SIZE:
content = self.buf[HE... | [
"def",
"input",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"buf",
"+=",
"data",
"while",
"len",
"(",
"self",
".",
"buf",
")",
">",
"HEADER_SIZE",
":",
"data_len",
"=",
"struct",
".",
"unpack",
"(",
"'i'",
",",
"self",
".",
"buf",
"[",
"0",
... | 小数据片段拼接成完整数据包
如果内容足够则yield数据包 | [
"小数据片段拼接成完整数据包",
"如果内容足够则yield数据包"
] | python | train |
watson-developer-cloud/python-sdk | ibm_watson/discovery_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/discovery_v1.py#L5016-L5027 | def _from_dict(cls, _dict):
"""Initialize a DocumentAccepted object from a json dictionary."""
args = {}
if 'document_id' in _dict:
args['document_id'] = _dict.get('document_id')
if 'status' in _dict:
args['status'] = _dict.get('status')
if 'notices' in _d... | [
"def",
"_from_dict",
"(",
"cls",
",",
"_dict",
")",
":",
"args",
"=",
"{",
"}",
"if",
"'document_id'",
"in",
"_dict",
":",
"args",
"[",
"'document_id'",
"]",
"=",
"_dict",
".",
"get",
"(",
"'document_id'",
")",
"if",
"'status'",
"in",
"_dict",
":",
"... | Initialize a DocumentAccepted object from a json dictionary. | [
"Initialize",
"a",
"DocumentAccepted",
"object",
"from",
"a",
"json",
"dictionary",
"."
] | python | train |
pyout/pyout | pyout/common.py | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L283-L304 | def _compose(self, name, attributes):
"""Construct a style taking `attributes` from the column styles.
Parameters
----------
name : str
Name of main style (e.g., "header_").
attributes : set of str
Adopt these elements from the column styles.
Ret... | [
"def",
"_compose",
"(",
"self",
",",
"name",
",",
"attributes",
")",
":",
"name_style",
"=",
"_safe_get",
"(",
"self",
".",
"init_style",
",",
"name",
",",
"elements",
".",
"default",
"(",
"name",
")",
")",
"if",
"self",
".",
"init_style",
"is",
"not",... | Construct a style taking `attributes` from the column styles.
Parameters
----------
name : str
Name of main style (e.g., "header_").
attributes : set of str
Adopt these elements from the column styles.
Returns
-------
The composite style ... | [
"Construct",
"a",
"style",
"taking",
"attributes",
"from",
"the",
"column",
"styles",
"."
] | python | train |
jaraco/irc | irc/client.py | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L454-L474 | def disconnect(self, message=""):
"""Hang up the connection.
Arguments:
message -- Quit message.
"""
try:
del self.connected
except AttributeError:
return
self.quit(message)
try:
self.socket.shutdown(socket.SHUT_... | [
"def",
"disconnect",
"(",
"self",
",",
"message",
"=",
"\"\"",
")",
":",
"try",
":",
"del",
"self",
".",
"connected",
"except",
"AttributeError",
":",
"return",
"self",
".",
"quit",
"(",
"message",
")",
"try",
":",
"self",
".",
"socket",
".",
"shutdown... | Hang up the connection.
Arguments:
message -- Quit message. | [
"Hang",
"up",
"the",
"connection",
"."
] | python | train |
joyent/python-manta | manta/cmdln.py | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1472-L1503 | def argv2line(argv):
r"""Put together the given argument vector into a command line.
"argv" is the argument vector to process.
>>> from cmdln import argv2line
>>> argv2line(['foo'])
'foo'
>>> argv2line(['foo', 'bar'])
'foo bar'
>>> argv2line(['foo', 'bar baz'])
'foo "bar baz"'
... | [
"def",
"argv2line",
"(",
"argv",
")",
":",
"escapedArgs",
"=",
"[",
"]",
"for",
"arg",
"in",
"argv",
":",
"if",
"' '",
"in",
"arg",
"and",
"'\"'",
"not",
"in",
"arg",
":",
"arg",
"=",
"'\"'",
"+",
"arg",
"+",
"'\"'",
"elif",
"' '",
"in",
"arg",
... | r"""Put together the given argument vector into a command line.
"argv" is the argument vector to process.
>>> from cmdln import argv2line
>>> argv2line(['foo'])
'foo'
>>> argv2line(['foo', 'bar'])
'foo bar'
>>> argv2line(['foo', 'bar baz'])
'foo "bar baz"'
>>> argv2line(['foo"b... | [
"r",
"Put",
"together",
"the",
"given",
"argument",
"vector",
"into",
"a",
"command",
"line",
"."
] | python | train |
Dapid/tmscoring | tmscoring/tmscore.py | https://github.com/Dapid/tmscoring/blob/353c567e201ee9835c8209f6130b80b1cfb5b10f/tmscoring/tmscore.py#L230-L259 | def _load_data_alignment(self, chain1, chain2):
"""
Extract the sequences from the PDB file, perform the alignment,
and load the coordinates of the CA of the common residues.
"""
parser = PDB.PDBParser(QUIET=True)
ppb = PDB.PPBuilder()
structure1 = parser.get_str... | [
"def",
"_load_data_alignment",
"(",
"self",
",",
"chain1",
",",
"chain2",
")",
":",
"parser",
"=",
"PDB",
".",
"PDBParser",
"(",
"QUIET",
"=",
"True",
")",
"ppb",
"=",
"PDB",
".",
"PPBuilder",
"(",
")",
"structure1",
"=",
"parser",
".",
"get_structure",
... | Extract the sequences from the PDB file, perform the alignment,
and load the coordinates of the CA of the common residues. | [
"Extract",
"the",
"sequences",
"from",
"the",
"PDB",
"file",
"perform",
"the",
"alignment",
"and",
"load",
"the",
"coordinates",
"of",
"the",
"CA",
"of",
"the",
"common",
"residues",
"."
] | python | train |
robmarkcole/HASS-data-detective | detective/core.py | https://github.com/robmarkcole/HASS-data-detective/blob/f67dfde9dd63a3af411944d1857b0835632617c5/detective/core.py#L106-L153 | def fetch_data_by_list(self, entities: List[str], limit=50000):
"""
Basic query from list of entities. Must be from same domain.
Attempts to unpack lists up to 2 deep.
Parameters
----------
entities : a list of entities
returns a df
"""
if not l... | [
"def",
"fetch_data_by_list",
"(",
"self",
",",
"entities",
":",
"List",
"[",
"str",
"]",
",",
"limit",
"=",
"50000",
")",
":",
"if",
"not",
"len",
"(",
"set",
"(",
"[",
"e",
".",
"split",
"(",
"\".\"",
")",
"[",
"0",
"]",
"for",
"e",
"in",
"ent... | Basic query from list of entities. Must be from same domain.
Attempts to unpack lists up to 2 deep.
Parameters
----------
entities : a list of entities
returns a df | [
"Basic",
"query",
"from",
"list",
"of",
"entities",
".",
"Must",
"be",
"from",
"same",
"domain",
".",
"Attempts",
"to",
"unpack",
"lists",
"up",
"to",
"2",
"deep",
"."
] | python | train |
ungarj/mapchete | mapchete/tile.py | https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/tile.py#L260-L289 | def get_neighbors(self, connectedness=8):
"""
Return tile neighbors.
Tile neighbors are unique, i.e. in some edge cases, where both the left
and right neighbor wrapped around the antimeridian is the same. Also,
neighbors ouside the northern and southern TilePyramid boundaries ar... | [
"def",
"get_neighbors",
"(",
"self",
",",
"connectedness",
"=",
"8",
")",
":",
"return",
"[",
"BufferedTile",
"(",
"t",
",",
"self",
".",
"pixelbuffer",
")",
"for",
"t",
"in",
"self",
".",
"_tile",
".",
"get_neighbors",
"(",
"connectedness",
"=",
"connec... | Return tile neighbors.
Tile neighbors are unique, i.e. in some edge cases, where both the left
and right neighbor wrapped around the antimeridian is the same. Also,
neighbors ouside the northern and southern TilePyramid boundaries are
excluded, because they are invalid.
-------... | [
"Return",
"tile",
"neighbors",
"."
] | python | valid |
pndurette/gTTS | gtts/tokenizer/pre_processors.py | https://github.com/pndurette/gTTS/blob/b01ac4eb22d40c6241202e202d0418ccf4f98460/gtts/tokenizer/pre_processors.py#L19-L28 | def end_of_line(text):
"""Re-form words cut by end-of-line hyphens.
Remove "<hyphen><newline>".
"""
return PreProcessorRegex(
search_args=u'-',
search_func=lambda x: u"{}\n".format(x),
repl='').run(text) | [
"def",
"end_of_line",
"(",
"text",
")",
":",
"return",
"PreProcessorRegex",
"(",
"search_args",
"=",
"u'-'",
",",
"search_func",
"=",
"lambda",
"x",
":",
"u\"{}\\n\"",
".",
"format",
"(",
"x",
")",
",",
"repl",
"=",
"''",
")",
".",
"run",
"(",
"text",
... | Re-form words cut by end-of-line hyphens.
Remove "<hyphen><newline>". | [
"Re",
"-",
"form",
"words",
"cut",
"by",
"end",
"-",
"of",
"-",
"line",
"hyphens",
"."
] | python | train |
xiyouMc/ncmbot | ncmbot/core.py | https://github.com/xiyouMc/ncmbot/blob/c4832f3ee7630ba104a89559f09c1fc366d1547b/ncmbot/core.py#L456-L471 | def music_comment(id, offset=0, limit=20):
"""获取歌曲的评论列表
:param id: 歌曲 ID
:param offset: (optional) 分段起始位置,默认 0
:param limit: (optional) 数据上限多少行,默认 20
"""
if id is None:
raise ParamsError()
r = NCloudBot()
r.method = 'MUSIC_COMMENT'
r.params = {'id': id}
r.data = {'offset... | [
"def",
"music_comment",
"(",
"id",
",",
"offset",
"=",
"0",
",",
"limit",
"=",
"20",
")",
":",
"if",
"id",
"is",
"None",
":",
"raise",
"ParamsError",
"(",
")",
"r",
"=",
"NCloudBot",
"(",
")",
"r",
".",
"method",
"=",
"'MUSIC_COMMENT'",
"r",
".",
... | 获取歌曲的评论列表
:param id: 歌曲 ID
:param offset: (optional) 分段起始位置,默认 0
:param limit: (optional) 数据上限多少行,默认 20 | [
"获取歌曲的评论列表"
] | python | train |
SylvanasSun/python-common-cache | common_cache/__init__.py | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L612-L720 | def access_cache(self, key=None, key_location_on_param=0, expire=None, auto_update=True,
cache_loader=None, cache_writer=None, timeout=1):
"""
The decorator for simplifying of use cache, it supports auto-update
cache(if parameter auto_update is True), load cache from other l... | [
"def",
"access_cache",
"(",
"self",
",",
"key",
"=",
"None",
",",
"key_location_on_param",
"=",
"0",
",",
"expire",
"=",
"None",
",",
"auto_update",
"=",
"True",
",",
"cache_loader",
"=",
"None",
",",
"cache_writer",
"=",
"None",
",",
"timeout",
"=",
"1"... | The decorator for simplifying of use cache, it supports auto-update
cache(if parameter auto_update is True), load cache from other level cache
system or data source and writes back the update result to the
other level cache system or data source if cache miss.
The parameter key assigns ... | [
"The",
"decorator",
"for",
"simplifying",
"of",
"use",
"cache",
"it",
"supports",
"auto",
"-",
"update",
"cache",
"(",
"if",
"parameter",
"auto_update",
"is",
"True",
")",
"load",
"cache",
"from",
"other",
"level",
"cache",
"system",
"or",
"data",
"source",
... | python | train |
google/dotty | efilter/parsers/common/tokenizer.py | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L237-L240 | def skip(self, steps=1):
"""Skip ahead by 'steps' tokens."""
for _ in six.moves.range(steps):
self.next_token() | [
"def",
"skip",
"(",
"self",
",",
"steps",
"=",
"1",
")",
":",
"for",
"_",
"in",
"six",
".",
"moves",
".",
"range",
"(",
"steps",
")",
":",
"self",
".",
"next_token",
"(",
")"
] | Skip ahead by 'steps' tokens. | [
"Skip",
"ahead",
"by",
"steps",
"tokens",
"."
] | python | train |
allianceauth/allianceauth | allianceauth/eveonline/autogroups/signals.py | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/eveonline/autogroups/signals.py#L53-L65 | def autogroups_states_changed(sender, instance, action, reverse, model, pk_set, *args, **kwargs):
"""
Trigger group membership update when a state is added or removed from
an autogroup config.
"""
if action.startswith('post_'):
for pk in pk_set:
try:
state = State... | [
"def",
"autogroups_states_changed",
"(",
"sender",
",",
"instance",
",",
"action",
",",
"reverse",
",",
"model",
",",
"pk_set",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"action",
".",
"startswith",
"(",
"'post_'",
")",
":",
"for",
"pk... | Trigger group membership update when a state is added or removed from
an autogroup config. | [
"Trigger",
"group",
"membership",
"update",
"when",
"a",
"state",
"is",
"added",
"or",
"removed",
"from",
"an",
"autogroup",
"config",
"."
] | python | train |
Nachtfeuer/pipeline | spline/matrix.py | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/matrix.py#L115-L134 | def can_process_matrix(entry, matrix_tags):
"""
Check given matrix tags to be in the given list of matric tags.
Args:
entry (dict): matrix item (in yaml).
matrix_tags (list): represents --matrix-tags defined by user in command line.
Returns:
bool: Tru... | [
"def",
"can_process_matrix",
"(",
"entry",
",",
"matrix_tags",
")",
":",
"if",
"len",
"(",
"matrix_tags",
")",
"==",
"0",
":",
"return",
"True",
"count",
"=",
"0",
"if",
"'tags'",
"in",
"entry",
":",
"for",
"tag",
"in",
"matrix_tags",
":",
"if",
"tag",... | Check given matrix tags to be in the given list of matric tags.
Args:
entry (dict): matrix item (in yaml).
matrix_tags (list): represents --matrix-tags defined by user in command line.
Returns:
bool: True when matrix entry can be processed. | [
"Check",
"given",
"matrix",
"tags",
"to",
"be",
"in",
"the",
"given",
"list",
"of",
"matric",
"tags",
"."
] | python | train |
lobocv/crashreporter | crashreporter/injector.py | https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/injector.py#L11-L33 | def inject_path(path):
"""
Imports :func: from a python file at :path: and executes it with *args, **kwargs arguments. Everytime this function
is called the module is reloaded so that you can alter your debug code while the application is running.
The result of the function is returned, otherwise the e... | [
"def",
"inject_path",
"(",
"path",
")",
":",
"try",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
"if",
"dirname",
"not",
"in",
"sys",
".",
"path",
":",
"exists_in_sys",
"=",
"False",
"sys",
".",
"path",
".",
"append",
"... | Imports :func: from a python file at :path: and executes it with *args, **kwargs arguments. Everytime this function
is called the module is reloaded so that you can alter your debug code while the application is running.
The result of the function is returned, otherwise the exception is returned (if one is rai... | [
"Imports",
":",
"func",
":",
"from",
"a",
"python",
"file",
"at",
":",
"path",
":",
"and",
"executes",
"it",
"with",
"*",
"args",
"**",
"kwargs",
"arguments",
".",
"Everytime",
"this",
"function",
"is",
"called",
"the",
"module",
"is",
"reloaded",
"so",
... | python | train |
limodou/uliweb | uliweb/contrib/model_config/__init__.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/model_config/__init__.py#L69-L100 | def get_model_fields(model, add_reserver_flag=True):
"""
Creating fields suit for model_config , id will be skipped.
"""
import uliweb.orm as orm
fields = []
m = {'type':'type_name', 'hint':'hint',
'default':'default', 'required':'required'}
m1 = {'index':'index', 'unique':'unique'... | [
"def",
"get_model_fields",
"(",
"model",
",",
"add_reserver_flag",
"=",
"True",
")",
":",
"import",
"uliweb",
".",
"orm",
"as",
"orm",
"fields",
"=",
"[",
"]",
"m",
"=",
"{",
"'type'",
":",
"'type_name'",
",",
"'hint'",
":",
"'hint'",
",",
"'default'",
... | Creating fields suit for model_config , id will be skipped. | [
"Creating",
"fields",
"suit",
"for",
"model_config",
"id",
"will",
"be",
"skipped",
"."
] | python | train |
zkbt/the-friendly-stars | thefriendlystars/constellations/constellation.py | https://github.com/zkbt/the-friendly-stars/blob/50d3f979e79e63c66629065c75595696dc79802e/thefriendlystars/constellations/constellation.py#L281-L314 | def plot(self, sizescale=10, color=None, alpha=0.5, label=None, edgecolor='none', **kw):
'''
Plot the ra and dec of the coordinates,
at a given epoch, scaled by their magnitude.
(This does *not* create a new empty figure.)
Parameters
----------
sizescale : (opti... | [
"def",
"plot",
"(",
"self",
",",
"sizescale",
"=",
"10",
",",
"color",
"=",
"None",
",",
"alpha",
"=",
"0.5",
",",
"label",
"=",
"None",
",",
"edgecolor",
"=",
"'none'",
",",
"*",
"*",
"kw",
")",
":",
"# calculate the sizes of the stars (logarithmic with b... | Plot the ra and dec of the coordinates,
at a given epoch, scaled by their magnitude.
(This does *not* create a new empty figure.)
Parameters
----------
sizescale : (optional) float
The marker size for scatter for a star at the magnitudelimit.
color : (option... | [
"Plot",
"the",
"ra",
"and",
"dec",
"of",
"the",
"coordinates",
"at",
"a",
"given",
"epoch",
"scaled",
"by",
"their",
"magnitude",
"."
] | python | train |
inspirehep/harvesting-kit | harvestingkit/inspire_cds_package/from_cds.py | https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L111-L157 | def determine_collections(self):
"""Try to determine which collections this record should belong to."""
for value in record_get_field_values(self.record, '980', code='a'):
if 'NOTE' in value.upper():
self.collections.add('NOTE')
if 'THESIS' in value.upper():
... | [
"def",
"determine_collections",
"(",
"self",
")",
":",
"for",
"value",
"in",
"record_get_field_values",
"(",
"self",
".",
"record",
",",
"'980'",
",",
"code",
"=",
"'a'",
")",
":",
"if",
"'NOTE'",
"in",
"value",
".",
"upper",
"(",
")",
":",
"self",
"."... | Try to determine which collections this record should belong to. | [
"Try",
"to",
"determine",
"which",
"collections",
"this",
"record",
"should",
"belong",
"to",
"."
] | python | valid |
CalebBell/thermo | thermo/volume.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/volume.py#L252-L294 | def Townsend_Hales(T, Tc, Vc, omega):
r'''Calculates saturation liquid density, using the Townsend and Hales
CSP method as modified from the original Riedel equation. Uses
chemical critical volume and temperature, as well as acentric factor
The density of a liquid is given by:
.. math::
Vs... | [
"def",
"Townsend_Hales",
"(",
"T",
",",
"Tc",
",",
"Vc",
",",
"omega",
")",
":",
"Tr",
"=",
"T",
"/",
"Tc",
"return",
"Vc",
"/",
"(",
"1",
"+",
"0.85",
"*",
"(",
"1",
"-",
"Tr",
")",
"+",
"(",
"1.692",
"+",
"0.986",
"*",
"omega",
")",
"*",
... | r'''Calculates saturation liquid density, using the Townsend and Hales
CSP method as modified from the original Riedel equation. Uses
chemical critical volume and temperature, as well as acentric factor
The density of a liquid is given by:
.. math::
Vs = V_c/\left(1+0.85(1-T_r)+(1.692+0.986\om... | [
"r",
"Calculates",
"saturation",
"liquid",
"density",
"using",
"the",
"Townsend",
"and",
"Hales",
"CSP",
"method",
"as",
"modified",
"from",
"the",
"original",
"Riedel",
"equation",
".",
"Uses",
"chemical",
"critical",
"volume",
"and",
"temperature",
"as",
"well... | python | valid |
RudolfCardinal/pythonlib | cardinal_pythonlib/source_reformatting.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/source_reformatting.py#L239-L243 | def _debug_line(linenum: int, line: str, extramsg: str = "") -> None:
"""
Writes a debugging report on a line.
"""
log.critical("{}Line {}: {!r}", extramsg, linenum, line) | [
"def",
"_debug_line",
"(",
"linenum",
":",
"int",
",",
"line",
":",
"str",
",",
"extramsg",
":",
"str",
"=",
"\"\"",
")",
"->",
"None",
":",
"log",
".",
"critical",
"(",
"\"{}Line {}: {!r}\"",
",",
"extramsg",
",",
"linenum",
",",
"line",
")"
] | Writes a debugging report on a line. | [
"Writes",
"a",
"debugging",
"report",
"on",
"a",
"line",
"."
] | python | train |
pypa/setuptools | setuptools/command/build_py.py | https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/build_py.py#L99-L114 | def find_data_files(self, package, src_dir):
"""Return filenames for package's data files in 'src_dir'"""
patterns = self._get_platform_patterns(
self.package_data,
package,
src_dir,
)
globs_expanded = map(glob, patterns)
# flatten the expanded... | [
"def",
"find_data_files",
"(",
"self",
",",
"package",
",",
"src_dir",
")",
":",
"patterns",
"=",
"self",
".",
"_get_platform_patterns",
"(",
"self",
".",
"package_data",
",",
"package",
",",
"src_dir",
",",
")",
"globs_expanded",
"=",
"map",
"(",
"glob",
... | Return filenames for package's data files in 'src_dir | [
"Return",
"filenames",
"for",
"package",
"s",
"data",
"files",
"in",
"src_dir"
] | python | train |
SHTOOLS/SHTOOLS | pyshtools/shclasses/shtensor.py | https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/shtensor.py#L501-L553 | def plot_vyz(self, colorbar=True, cb_orientation='vertical',
cb_label=None, ax=None, show=True, fname=None, **kwargs):
"""
Plot the Vyz component of the tensor.
Usage
-----
x.plot_vyz([tick_interval, xlabel, ylabel, ax, colorbar,
cb_orientati... | [
"def",
"plot_vyz",
"(",
"self",
",",
"colorbar",
"=",
"True",
",",
"cb_orientation",
"=",
"'vertical'",
",",
"cb_label",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"show",
"=",
"True",
",",
"fname",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"i... | Plot the Vyz component of the tensor.
Usage
-----
x.plot_vyz([tick_interval, xlabel, ylabel, ax, colorbar,
cb_orientation, cb_label, show, fname])
Parameters
----------
tick_interval : list or tuple, optional, default = [30, 30]
Intervals... | [
"Plot",
"the",
"Vyz",
"component",
"of",
"the",
"tensor",
"."
] | python | train |
FutunnOpen/futuquant | futuquant/examples/learn/get_realtime_data.py | https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/examples/learn/get_realtime_data.py#L174-L183 | def _example_plate_subplate(quote_ctx):
"""
获取板块集合下的子板块列表,输出 市场,板块分类,板块代码,名称,ID
"""
ret_status, ret_data = quote_ctx.get_plate_list(ft.Market.SZ, ft.Plate.ALL)
if ret_status != ft.RET_OK:
print(ret_data)
exit()
print("plate_subplate")
print(ret_data) | [
"def",
"_example_plate_subplate",
"(",
"quote_ctx",
")",
":",
"ret_status",
",",
"ret_data",
"=",
"quote_ctx",
".",
"get_plate_list",
"(",
"ft",
".",
"Market",
".",
"SZ",
",",
"ft",
".",
"Plate",
".",
"ALL",
")",
"if",
"ret_status",
"!=",
"ft",
".",
"RET... | 获取板块集合下的子板块列表,输出 市场,板块分类,板块代码,名称,ID | [
"获取板块集合下的子板块列表,输出",
"市场,板块分类",
"板块代码,名称,ID"
] | python | train |
Varkal/chuda | chuda/shell.py | https://github.com/Varkal/chuda/blob/0d93b716dede35231c21be97bcc19a656655983f/chuda/shell.py#L114-L129 | def send(self, value):
"""
Send text to stdin. Can only be used on non blocking commands
Args:
value (str): the text to write on stdin
Raises:
TypeError: If command is blocking
Returns:
ShellCommand: return this ShellCommand instance for chain... | [
"def",
"send",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"block",
"and",
"self",
".",
"_stdin",
"is",
"not",
"None",
":",
"self",
".",
"writer",
".",
"write",
"(",
"\"{}\\n\"",
".",
"format",
"(",
"value",
")",
")",
"return",
... | Send text to stdin. Can only be used on non blocking commands
Args:
value (str): the text to write on stdin
Raises:
TypeError: If command is blocking
Returns:
ShellCommand: return this ShellCommand instance for chaining | [
"Send",
"text",
"to",
"stdin",
".",
"Can",
"only",
"be",
"used",
"on",
"non",
"blocking",
"commands"
] | python | train |
lreis2415/PyGeoC | pygeoc/postTauDEM.py | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/postTauDEM.py#L111-L132 | def output_compressed_dinf(dinfflowang, compdinffile, weightfile):
"""Output compressed Dinf flow direction and weight to raster file
Args:
dinfflowang: Dinf flow direction raster file
compdinffile: Compressed D8 flow code
weightfile: The correspond weight
"""... | [
"def",
"output_compressed_dinf",
"(",
"dinfflowang",
",",
"compdinffile",
",",
"weightfile",
")",
":",
"dinf_r",
"=",
"RasterUtilClass",
".",
"read_raster",
"(",
"dinfflowang",
")",
"data",
"=",
"dinf_r",
".",
"data",
"xsize",
"=",
"dinf_r",
".",
"nCols",
"ysi... | Output compressed Dinf flow direction and weight to raster file
Args:
dinfflowang: Dinf flow direction raster file
compdinffile: Compressed D8 flow code
weightfile: The correspond weight | [
"Output",
"compressed",
"Dinf",
"flow",
"direction",
"and",
"weight",
"to",
"raster",
"file",
"Args",
":",
"dinfflowang",
":",
"Dinf",
"flow",
"direction",
"raster",
"file",
"compdinffile",
":",
"Compressed",
"D8",
"flow",
"code",
"weightfile",
":",
"The",
"co... | python | train |
4Catalyzer/flask-resty | flask_resty/spec/declaration.py | https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/declaration.py#L85-L94 | def get_marshmallow_schema_name(self, plugin, schema):
"""Get the schema name.
If the schema doesn't exist, create it.
"""
try:
return plugin.openapi.refs[schema]
except KeyError:
plugin.spec.definition(schema.__name__, schema=schema)
return s... | [
"def",
"get_marshmallow_schema_name",
"(",
"self",
",",
"plugin",
",",
"schema",
")",
":",
"try",
":",
"return",
"plugin",
".",
"openapi",
".",
"refs",
"[",
"schema",
"]",
"except",
"KeyError",
":",
"plugin",
".",
"spec",
".",
"definition",
"(",
"schema",
... | Get the schema name.
If the schema doesn't exist, create it. | [
"Get",
"the",
"schema",
"name",
"."
] | python | train |
ray-project/ray | python/ray/tune/trial.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial.py#L346-L365 | def init_logger(self):
"""Init logger."""
if not self.result_logger:
if not os.path.exists(self.local_dir):
os.makedirs(self.local_dir)
if not self.logdir:
self.logdir = tempfile.mkdtemp(
prefix="{}_{}".format(
... | [
"def",
"init_logger",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"result_logger",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"local_dir",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"local_dir",
")",
"if",
"n... | Init logger. | [
"Init",
"logger",
"."
] | python | train |
mrstephenneal/mysql-toolkit | mysql/toolkit/datatypes/text.py | https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/datatypes/text.py#L10-L16 | def is_varchar(self):
"""Determine if a data record is of the type VARCHAR."""
dt = DATA_TYPES['varchar']
if type(self.data) is dt['type'] and len(self.data) < dt['max']:
self.type = 'VARCHAR'
self.len = len(self.data)
return True | [
"def",
"is_varchar",
"(",
"self",
")",
":",
"dt",
"=",
"DATA_TYPES",
"[",
"'varchar'",
"]",
"if",
"type",
"(",
"self",
".",
"data",
")",
"is",
"dt",
"[",
"'type'",
"]",
"and",
"len",
"(",
"self",
".",
"data",
")",
"<",
"dt",
"[",
"'max'",
"]",
... | Determine if a data record is of the type VARCHAR. | [
"Determine",
"if",
"a",
"data",
"record",
"is",
"of",
"the",
"type",
"VARCHAR",
"."
] | python | train |
har07/PySastrawi | src/Sastrawi/Stemmer/Context/Context.py | https://github.com/har07/PySastrawi/blob/01afc81c579bde14dcb41c33686b26af8afab121/src/Sastrawi/Stemmer/Context/Context.py#L33-L43 | def execute(self):
"""Execute stemming process; the result can be retrieved with result"""
#step 1 - 5
self.start_stemming_process()
#step 6
if self.dictionary.contains(self.current_word):
self.result = self.current_word
else:
self.result = self.... | [
"def",
"execute",
"(",
"self",
")",
":",
"#step 1 - 5",
"self",
".",
"start_stemming_process",
"(",
")",
"#step 6",
"if",
"self",
".",
"dictionary",
".",
"contains",
"(",
"self",
".",
"current_word",
")",
":",
"self",
".",
"result",
"=",
"self",
".",
"cu... | Execute stemming process; the result can be retrieved with result | [
"Execute",
"stemming",
"process",
";",
"the",
"result",
"can",
"be",
"retrieved",
"with",
"result"
] | python | train |
collectiveacuity/labPack | labpack/databases/sql.py | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L268-L308 | def _extract_columns(self, table_name):
''' a method to extract the column properties of an existing table '''
import re
from sqlalchemy import MetaData, VARCHAR, INTEGER, BLOB, BOOLEAN, FLOAT
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, BIT, BYTEA
... | [
"def",
"_extract_columns",
"(",
"self",
",",
"table_name",
")",
":",
"import",
"re",
"from",
"sqlalchemy",
"import",
"MetaData",
",",
"VARCHAR",
",",
"INTEGER",
",",
"BLOB",
",",
"BOOLEAN",
",",
"FLOAT",
"from",
"sqlalchemy",
".",
"dialects",
".",
"postgresq... | a method to extract the column properties of an existing table | [
"a",
"method",
"to",
"extract",
"the",
"column",
"properties",
"of",
"an",
"existing",
"table"
] | python | train |
apache/spark | python/pyspark/conf.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L191-L196 | def getAll(self):
"""Get all values as a list of key-value pairs."""
if self._jconf is not None:
return [(elem._1(), elem._2()) for elem in self._jconf.getAll()]
else:
return self._conf.items() | [
"def",
"getAll",
"(",
"self",
")",
":",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"return",
"[",
"(",
"elem",
".",
"_1",
"(",
")",
",",
"elem",
".",
"_2",
"(",
")",
")",
"for",
"elem",
"in",
"self",
".",
"_jconf",
".",
"getAll",
... | Get all values as a list of key-value pairs. | [
"Get",
"all",
"values",
"as",
"a",
"list",
"of",
"key",
"-",
"value",
"pairs",
"."
] | python | train |
tensorflow/tensorboard | tensorboard/plugins/debugger/debugger_plugin.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/debugger/debugger_plugin.py#L449-L488 | def _process_health_pill_value(self,
wall_time,
step,
device_name,
output_slot,
node_name,
tensor_proto,
... | [
"def",
"_process_health_pill_value",
"(",
"self",
",",
"wall_time",
",",
"step",
",",
"device_name",
",",
"output_slot",
",",
"node_name",
",",
"tensor_proto",
",",
"node_name_set",
"=",
"None",
")",
":",
"if",
"node_name_set",
"and",
"node_name",
"not",
"in",
... | Creates a HealthPillEvent containing various properties of a health pill.
Args:
wall_time: The wall time in seconds.
step: The session run step of the event.
device_name: The name of the node's device.
output_slot: The numeric output slot.
node_name: The name of the node (without the ... | [
"Creates",
"a",
"HealthPillEvent",
"containing",
"various",
"properties",
"of",
"a",
"health",
"pill",
"."
] | python | train |
jobovy/galpy | galpy/orbit/OrbitTop.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/orbit/OrbitTop.py#L278-L298 | def z(self,*args,**kwargs):
"""
NAME:
z
PURPOSE:
return vertical height
INPUT:
t - (optional) time at which to get the vertical height
ro= (Object-wide default) physical scale for distances to use to convert
use_physical= use to over... | [
"def",
"z",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"self",
".",
"vxvv",
")",
"<",
"5",
":",
"raise",
"AttributeError",
"(",
"\"linear and planar orbits do not have z()\"",
")",
"thiso",
"=",
"self",
"(",
"*"... | NAME:
z
PURPOSE:
return vertical height
INPUT:
t - (optional) time at which to get the vertical height
ro= (Object-wide default) physical scale for distances to use to convert
use_physical= use to override Object-wide default for using a physical sc... | [
"NAME",
":",
"z",
"PURPOSE",
":",
"return",
"vertical",
"height",
"INPUT",
":",
"t",
"-",
"(",
"optional",
")",
"time",
"at",
"which",
"to",
"get",
"the",
"vertical",
"height",
"ro",
"=",
"(",
"Object",
"-",
"wide",
"default",
")",
"physical",
"scale",... | python | train |
yyuu/botornado | boto/manage/server.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/manage/server.py#L270-L348 | def create(cls, config_file=None, logical_volume = None, cfg = None, **params):
"""
Create a new instance based on the specified configuration file or the specified
configuration and the passed in parameters.
If the config_file argument is not None, the configuration is read fro... | [
"def",
"create",
"(",
"cls",
",",
"config_file",
"=",
"None",
",",
"logical_volume",
"=",
"None",
",",
"cfg",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"if",
"config_file",
":",
"cfg",
"=",
"Config",
"(",
"path",
"=",
"config_file",
")",
"if",
... | Create a new instance based on the specified configuration file or the specified
configuration and the passed in parameters.
If the config_file argument is not None, the configuration is read from there.
Otherwise, the cfg argument is used.
The config file may include ... | [
"Create",
"a",
"new",
"instance",
"based",
"on",
"the",
"specified",
"configuration",
"file",
"or",
"the",
"specified",
"configuration",
"and",
"the",
"passed",
"in",
"parameters",
".",
"If",
"the",
"config_file",
"argument",
"is",
"not",
"None",
"the",
"confi... | python | train |
mlperf/training | reinforcement/tensorflow/minigo/strategies.py | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/strategies.py#L175-L188 | def pick_move(self):
"""Picks a move to play, based on MCTS readout statistics.
Highest N is most robust indicator. In the early stage of the game, pick
a move weighted by visit count; later on, pick the absolute max."""
if self.root.position.n >= self.temp_threshold:
fcoord... | [
"def",
"pick_move",
"(",
"self",
")",
":",
"if",
"self",
".",
"root",
".",
"position",
".",
"n",
">=",
"self",
".",
"temp_threshold",
":",
"fcoord",
"=",
"self",
".",
"root",
".",
"best_child",
"(",
")",
"else",
":",
"cdf",
"=",
"self",
".",
"root"... | Picks a move to play, based on MCTS readout statistics.
Highest N is most robust indicator. In the early stage of the game, pick
a move weighted by visit count; later on, pick the absolute max. | [
"Picks",
"a",
"move",
"to",
"play",
"based",
"on",
"MCTS",
"readout",
"statistics",
"."
] | python | train |
sckott/pygbif | pygbif/occurrences/get.py | https://github.com/sckott/pygbif/blob/bf54f2920bc46d97d7e2e1b0c8059e5878f3c5ab/pygbif/occurrences/get.py#L3-L20 | def get(key, **kwargs):
'''
Gets details for a single, interpreted occurrence
:param key: [int] A GBIF occurrence key
:return: A dictionary, of results
Usage::
from pygbif import occurrences
occurrences.get(key = 1258202889)
occurrences.get(key = 1227768771)
occur... | [
"def",
"get",
"(",
"key",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"gbif_baseurl",
"+",
"'occurrence/'",
"+",
"str",
"(",
"key",
")",
"out",
"=",
"gbif_GET",
"(",
"url",
",",
"{",
"}",
",",
"*",
"*",
"kwargs",
")",
"return",
"out"
] | Gets details for a single, interpreted occurrence
:param key: [int] A GBIF occurrence key
:return: A dictionary, of results
Usage::
from pygbif import occurrences
occurrences.get(key = 1258202889)
occurrences.get(key = 1227768771)
occurrences.get(key = 1227769518) | [
"Gets",
"details",
"for",
"a",
"single",
"interpreted",
"occurrence"
] | python | train |
sublee/zeronimo | zeronimo/core.py | https://github.com/sublee/zeronimo/blob/b216638232932718d2cbc5eabd870c8f5b5e83fb/zeronimo/core.py#L675-L694 | def dispatch_reply(self, reply, value):
"""Dispatches the reply to the proper queue."""
method = reply.method
call_id = reply.call_id
task_id = reply.task_id
if method & ACK:
try:
result_queue = self.result_queues[call_id]
except KeyError:
... | [
"def",
"dispatch_reply",
"(",
"self",
",",
"reply",
",",
"value",
")",
":",
"method",
"=",
"reply",
".",
"method",
"call_id",
"=",
"reply",
".",
"call_id",
"task_id",
"=",
"reply",
".",
"task_id",
"if",
"method",
"&",
"ACK",
":",
"try",
":",
"result_qu... | Dispatches the reply to the proper queue. | [
"Dispatches",
"the",
"reply",
"to",
"the",
"proper",
"queue",
"."
] | python | test |
klen/muffin-session | muffin_session.py | https://github.com/klen/muffin-session/blob/f1d14d12b7d09d8cc40be14b0dfa0b1e2f4ae8e9/muffin_session.py#L80-L85 | async def save(self, request, response):
"""Save session to response cookies."""
if isinstance(response, Response) and SESSION_KEY in request and not response.prepared:
session = request[SESSION_KEY]
if session.save(response.set_cookie):
self.app.logger.debug('Ses... | [
"async",
"def",
"save",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"isinstance",
"(",
"response",
",",
"Response",
")",
"and",
"SESSION_KEY",
"in",
"request",
"and",
"not",
"response",
".",
"prepared",
":",
"session",
"=",
"request",
"... | Save session to response cookies. | [
"Save",
"session",
"to",
"response",
"cookies",
"."
] | python | train |
coursera-dl/coursera-dl | coursera/cookies.py | https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L111-L157 | def login(session, username, password, class_name=None):
"""
Login on coursera.org with the given credentials.
This adds the following cookies to the session:
sessionid, maestro_login, maestro_login_flag
"""
logging.debug('Initiating login.')
try:
session.cookies.clear('.course... | [
"def",
"login",
"(",
"session",
",",
"username",
",",
"password",
",",
"class_name",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"'Initiating login.'",
")",
"try",
":",
"session",
".",
"cookies",
".",
"clear",
"(",
"'.coursera.org'",
")",
"logging... | Login on coursera.org with the given credentials.
This adds the following cookies to the session:
sessionid, maestro_login, maestro_login_flag | [
"Login",
"on",
"coursera",
".",
"org",
"with",
"the",
"given",
"credentials",
"."
] | python | train |
ContextLab/quail | quail/distance.py | https://github.com/ContextLab/quail/blob/71dd53c792dd915dc84879d8237e3582dd68b7a4/quail/distance.py#L19-L21 | def euclidean(a, b):
"Returns euclidean distance between a and b"
return np.linalg.norm(np.subtract(a, b)) | [
"def",
"euclidean",
"(",
"a",
",",
"b",
")",
":",
"return",
"np",
".",
"linalg",
".",
"norm",
"(",
"np",
".",
"subtract",
"(",
"a",
",",
"b",
")",
")"
] | Returns euclidean distance between a and b | [
"Returns",
"euclidean",
"distance",
"between",
"a",
"and",
"b"
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/layers/area_attention.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/area_attention.py#L47-L75 | def _pool_one_shape(features_2d, area_width, area_height, batch_size,
width, height, depth, fn=tf.reduce_max, name=None):
"""Pools for an area in features_2d.
Args:
features_2d: a Tensor in a shape of [batch_size, height, width, depth].
area_width: the max width allowed for an area.
... | [
"def",
"_pool_one_shape",
"(",
"features_2d",
",",
"area_width",
",",
"area_height",
",",
"batch_size",
",",
"width",
",",
"height",
",",
"depth",
",",
"fn",
"=",
"tf",
".",
"reduce_max",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope... | Pools for an area in features_2d.
Args:
features_2d: a Tensor in a shape of [batch_size, height, width, depth].
area_width: the max width allowed for an area.
area_height: the max height allowed for an area.
batch_size: the batch size.
width: the width of the memory.
height: the height of the... | [
"Pools",
"for",
"an",
"area",
"in",
"features_2d",
"."
] | python | train |
petebachant/PXL | pxl/timeseries.py | https://github.com/petebachant/PXL/blob/d7d06cb74422e1ac0154741351fbecea080cfcc0/pxl/timeseries.py#L199-L202 | def student_t(degrees_of_freedom, confidence=0.95):
"""Return Student-t statistic for given DOF and confidence interval."""
return scipy.stats.t.interval(alpha=confidence,
df=degrees_of_freedom)[-1] | [
"def",
"student_t",
"(",
"degrees_of_freedom",
",",
"confidence",
"=",
"0.95",
")",
":",
"return",
"scipy",
".",
"stats",
".",
"t",
".",
"interval",
"(",
"alpha",
"=",
"confidence",
",",
"df",
"=",
"degrees_of_freedom",
")",
"[",
"-",
"1",
"]"
] | Return Student-t statistic for given DOF and confidence interval. | [
"Return",
"Student",
"-",
"t",
"statistic",
"for",
"given",
"DOF",
"and",
"confidence",
"interval",
"."
] | python | train |
markchil/gptools | gptools/gaussian_process.py | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L342-L348 | def free_param_bounds(self):
"""Combined free hyperparameter bounds for the kernel, noise kernel and (if present) mean function.
"""
fpb = CombinedBounds(self.k.free_param_bounds, self.noise_k.free_param_bounds)
if self.mu is not None:
fpb = CombinedBounds(fpb, self.mu.free_p... | [
"def",
"free_param_bounds",
"(",
"self",
")",
":",
"fpb",
"=",
"CombinedBounds",
"(",
"self",
".",
"k",
".",
"free_param_bounds",
",",
"self",
".",
"noise_k",
".",
"free_param_bounds",
")",
"if",
"self",
".",
"mu",
"is",
"not",
"None",
":",
"fpb",
"=",
... | Combined free hyperparameter bounds for the kernel, noise kernel and (if present) mean function. | [
"Combined",
"free",
"hyperparameter",
"bounds",
"for",
"the",
"kernel",
"noise",
"kernel",
"and",
"(",
"if",
"present",
")",
"mean",
"function",
"."
] | python | train |
saltstack/salt | salt/utils/docker/translate/helpers.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/docker/translate/helpers.py#L176-L190 | def translate_command(val):
'''
Input should either be a single string, or a list of strings. This is used
for the two args that deal with commands ("command" and "entrypoint").
'''
if isinstance(val, six.string_types):
return val
elif isinstance(val, list):
for idx in range(len(... | [
"def",
"translate_command",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"six",
".",
"string_types",
")",
":",
"return",
"val",
"elif",
"isinstance",
"(",
"val",
",",
"list",
")",
":",
"for",
"idx",
"in",
"range",
"(",
"len",
"(",
"val"... | Input should either be a single string, or a list of strings. This is used
for the two args that deal with commands ("command" and "entrypoint"). | [
"Input",
"should",
"either",
"be",
"a",
"single",
"string",
"or",
"a",
"list",
"of",
"strings",
".",
"This",
"is",
"used",
"for",
"the",
"two",
"args",
"that",
"deal",
"with",
"commands",
"(",
"command",
"and",
"entrypoint",
")",
"."
] | python | train |
klen/muffin-peewee | muffin_peewee/plugin.py | https://github.com/klen/muffin-peewee/blob/8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e/muffin_peewee/plugin.py#L43-L109 | def setup(self, app): # noqa
"""Initialize the application."""
super().setup(app)
# Setup Database
self.database.initialize(connect(self.cfg.connection, **self.cfg.connection_params))
# Fix SQLite in-memory database
if self.database.database == ':memory:':
... | [
"def",
"setup",
"(",
"self",
",",
"app",
")",
":",
"# noqa",
"super",
"(",
")",
".",
"setup",
"(",
"app",
")",
"# Setup Database",
"self",
".",
"database",
".",
"initialize",
"(",
"connect",
"(",
"self",
".",
"cfg",
".",
"connection",
",",
"*",
"*",
... | Initialize the application. | [
"Initialize",
"the",
"application",
"."
] | python | valid |
Netflix-Skunkworks/cloudaux | cloudaux/orchestration/aws/image.py | https://github.com/Netflix-Skunkworks/cloudaux/blob/c4b0870c3ac68b1c69e71d33cf78b6a8bdf437ea/cloudaux/orchestration/aws/image.py#L50-L88 | def get_image(image_id, flags=FLAGS.ALL, **conn):
"""
Orchestrates all the calls required to fully build out an EC2 Image (AMI, AKI, ARI)
{
"Architecture": "x86_64",
"Arn": "arn:aws:ec2:us-east-1::image/ami-11111111",
"BlockDeviceMappings": [],
"CreationDate": "2013-07-11... | [
"def",
"get_image",
"(",
"image_id",
",",
"flags",
"=",
"FLAGS",
".",
"ALL",
",",
"*",
"*",
"conn",
")",
":",
"image",
"=",
"dict",
"(",
"ImageId",
"=",
"image_id",
")",
"conn",
"[",
"'region'",
"]",
"=",
"conn",
".",
"get",
"(",
"'region'",
",",
... | Orchestrates all the calls required to fully build out an EC2 Image (AMI, AKI, ARI)
{
"Architecture": "x86_64",
"Arn": "arn:aws:ec2:us-east-1::image/ami-11111111",
"BlockDeviceMappings": [],
"CreationDate": "2013-07-11T16:04:06.000Z",
"Description": "...",
"Hype... | [
"Orchestrates",
"all",
"the",
"calls",
"required",
"to",
"fully",
"build",
"out",
"an",
"EC2",
"Image",
"(",
"AMI",
"AKI",
"ARI",
")"
] | python | valid |
qacafe/cdrouter.py | cdrouter/configs.py | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/configs.py#L357-L364 | def bulk_copy(self, ids):
"""Bulk copy a set of configs.
:param ids: Int list of config IDs.
:return: :class:`configs.Config <configs.Config>` list
"""
schema = self.GET_SCHEMA
return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema) | [
"def",
"bulk_copy",
"(",
"self",
",",
"ids",
")",
":",
"schema",
"=",
"self",
".",
"GET_SCHEMA",
"return",
"self",
".",
"service",
".",
"bulk_copy",
"(",
"self",
".",
"base",
",",
"self",
".",
"RESOURCE",
",",
"ids",
",",
"schema",
")"
] | Bulk copy a set of configs.
:param ids: Int list of config IDs.
:return: :class:`configs.Config <configs.Config>` list | [
"Bulk",
"copy",
"a",
"set",
"of",
"configs",
"."
] | python | train |
bitprophet/releases | releases/line_manager.py | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/line_manager.py#L59-L75 | def has_stable_releases(self):
"""
Returns whether stable (post-0.x) releases seem to exist.
"""
nonzeroes = self.stable_families
# Nothing but 0.x releases -> yup we're prehistory
if not nonzeroes:
return False
# Presumably, if there's >1 major family... | [
"def",
"has_stable_releases",
"(",
"self",
")",
":",
"nonzeroes",
"=",
"self",
".",
"stable_families",
"# Nothing but 0.x releases -> yup we're prehistory",
"if",
"not",
"nonzeroes",
":",
"return",
"False",
"# Presumably, if there's >1 major family besides 0.x, we're at least",
... | Returns whether stable (post-0.x) releases seem to exist. | [
"Returns",
"whether",
"stable",
"(",
"post",
"-",
"0",
".",
"x",
")",
"releases",
"seem",
"to",
"exist",
"."
] | python | train |
reorx/torext | torext/handlers/oauth.py | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/oauth.py#L511-L569 | def get_authenticated_user(self, redirect_uri, callback, scope=None, **args):
"""
class RenrenHandler(tornado.web.RequestHandler, RenrenGraphMixin):
@tornado.web.asynchronous
@gen.engine
def get(self):
self.get_authenticated_user(
c... | [
"def",
"get_authenticated_user",
"(",
"self",
",",
"redirect_uri",
",",
"callback",
",",
"scope",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"code",
"=",
"self",
".",
"get_argument",
"(",
"'code'",
",",
"None",
")",
"if",
"not",
"code",
":",
"self",... | class RenrenHandler(tornado.web.RequestHandler, RenrenGraphMixin):
@tornado.web.asynchronous
@gen.engine
def get(self):
self.get_authenticated_user(
callback=(yield gen.Callback('key')),
redirect_uri=url)
user = ... | [
"class",
"RenrenHandler",
"(",
"tornado",
".",
"web",
".",
"RequestHandler",
"RenrenGraphMixin",
")",
":"
] | python | train |
cackharot/suds-py3 | suds/wsdl.py | https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/wsdl.py#L849-L860 | def setlocation(self, url, names=None):
"""
Override the invocation location (url) for service method.
@param url: A url location.
@type url: A url.
@param names: A list of method names. None=ALL
@type names: [str,..]
"""
for p in self.ports:
... | [
"def",
"setlocation",
"(",
"self",
",",
"url",
",",
"names",
"=",
"None",
")",
":",
"for",
"p",
"in",
"self",
".",
"ports",
":",
"for",
"m",
"in",
"p",
".",
"methods",
".",
"values",
"(",
")",
":",
"if",
"names",
"is",
"None",
"or",
"m",
".",
... | Override the invocation location (url) for service method.
@param url: A url location.
@type url: A url.
@param names: A list of method names. None=ALL
@type names: [str,..] | [
"Override",
"the",
"invocation",
"location",
"(",
"url",
")",
"for",
"service",
"method",
"."
] | python | train |
pyamg/pyamg | pyamg/multilevel.py | https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/multilevel.py#L260-L269 | def grid_complexity(self):
"""Grid complexity of this multigrid hierarchy.
Defined as:
Number of unknowns on all levels /
Number of unknowns on the finest level
"""
return sum([level.A.shape[0] for level in self.levels]) /\
float(self.levels[0].A.sha... | [
"def",
"grid_complexity",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"[",
"level",
".",
"A",
".",
"shape",
"[",
"0",
"]",
"for",
"level",
"in",
"self",
".",
"levels",
"]",
")",
"/",
"float",
"(",
"self",
".",
"levels",
"[",
"0",
"]",
".",
"A"... | Grid complexity of this multigrid hierarchy.
Defined as:
Number of unknowns on all levels /
Number of unknowns on the finest level | [
"Grid",
"complexity",
"of",
"this",
"multigrid",
"hierarchy",
"."
] | python | train |
TheEnigmaBlade/praw-script-oauth | praw_script_oauth/praw_script_oauth.py | https://github.com/TheEnigmaBlade/praw-script-oauth/blob/8ff53e226facecd49b6bd2a5b235eaba53dc76b6/praw_script_oauth/praw_script_oauth.py#L43-L66 | def get_oauth_token(oauth_key, oauth_secret, username, password, useragent=_DEFAULT_USERAGENT, script_key=None):
"""
Gets an OAuth token from Reddit or returns a valid locally stored token.
Because the retrieved token is stored on the file system (script_key is used to distinguish between files), this function is sa... | [
"def",
"get_oauth_token",
"(",
"oauth_key",
",",
"oauth_secret",
",",
"username",
",",
"password",
",",
"useragent",
"=",
"_DEFAULT_USERAGENT",
",",
"script_key",
"=",
"None",
")",
":",
"token",
"=",
"_get_local_token",
"(",
"script_key",
",",
"username",
")",
... | Gets an OAuth token from Reddit or returns a valid locally stored token.
Because the retrieved token is stored on the file system (script_key is used to distinguish between files), this function is safe
to call across multiple instances or runs. The token is renewed after one hour.
This function can be used without ... | [
"Gets",
"an",
"OAuth",
"token",
"from",
"Reddit",
"or",
"returns",
"a",
"valid",
"locally",
"stored",
"token",
".",
"Because",
"the",
"retrieved",
"token",
"is",
"stored",
"on",
"the",
"file",
"system",
"(",
"script_key",
"is",
"used",
"to",
"distinguish",
... | python | train |
tensorlayer/tensorlayer | tensorlayer/layers/recurrent.py | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/layers/recurrent.py#L596-L648 | def _conv_linear(args, filter_size, num_features, bias, bias_start=0.0, scope=None):
"""convolution:
Parameters
----------
args : tensor
4D Tensor or a list of 4D, batch x n, Tensors.
filter_size : tuple of int
Filter height and width.
num_features : int
Nnumber of featu... | [
"def",
"_conv_linear",
"(",
"args",
",",
"filter_size",
",",
"num_features",
",",
"bias",
",",
"bias_start",
"=",
"0.0",
",",
"scope",
"=",
"None",
")",
":",
"# Calculate the total size of arguments on dimension 1.",
"total_arg_size_depth",
"=",
"0",
"shapes",
"=",
... | convolution:
Parameters
----------
args : tensor
4D Tensor or a list of 4D, batch x n, Tensors.
filter_size : tuple of int
Filter height and width.
num_features : int
Nnumber of features.
bias_start : float
Starting value to initialize the bias; 0 by default.
... | [
"convolution",
":"
] | python | valid |
django-extensions/django-extensions | django_extensions/management/mysql.py | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/mysql.py#L5-L43 | def parse_mysql_cnf(dbinfo):
"""
Attempt to parse mysql database config file for connection settings.
Ideally we would hook into django's code to do this, but read_default_file is handled by the mysql C libs
so we have to emulate the behaviour
Settings that are missing will return ''
returns (u... | [
"def",
"parse_mysql_cnf",
"(",
"dbinfo",
")",
":",
"read_default_file",
"=",
"dbinfo",
".",
"get",
"(",
"'OPTIONS'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'read_default_file'",
")",
"if",
"read_default_file",
":",
"config",
"=",
"configparser",
".",
"RawConf... | Attempt to parse mysql database config file for connection settings.
Ideally we would hook into django's code to do this, but read_default_file is handled by the mysql C libs
so we have to emulate the behaviour
Settings that are missing will return ''
returns (user, password, database_name, database_ho... | [
"Attempt",
"to",
"parse",
"mysql",
"database",
"config",
"file",
"for",
"connection",
"settings",
".",
"Ideally",
"we",
"would",
"hook",
"into",
"django",
"s",
"code",
"to",
"do",
"this",
"but",
"read_default_file",
"is",
"handled",
"by",
"the",
"mysql",
"C"... | python | train |
skyfielders/python-skyfield | skyfield/relativity.py | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/relativity.py#L23-L97 | def add_deflection(position, observer, ephemeris, t,
include_earth_deflection, count=3):
"""Update `position` for how solar system masses will deflect its light.
Given the ICRS `position` [x,y,z] of an object (au) that is being
viewed from the `observer` also expressed as [x,y,z], and gi... | [
"def",
"add_deflection",
"(",
"position",
",",
"observer",
",",
"ephemeris",
",",
"t",
",",
"include_earth_deflection",
",",
"count",
"=",
"3",
")",
":",
"# Compute light-time to observed object.",
"tlt",
"=",
"length_of",
"(",
"position",
")",
"/",
"C_AUDAY",
"... | Update `position` for how solar system masses will deflect its light.
Given the ICRS `position` [x,y,z] of an object (au) that is being
viewed from the `observer` also expressed as [x,y,z], and given an
ephemeris that can be used to determine solar system body positions,
and given the time `t` and Bool... | [
"Update",
"position",
"for",
"how",
"solar",
"system",
"masses",
"will",
"deflect",
"its",
"light",
"."
] | python | train |
StorjOld/heartbeat | heartbeat/Merkle/Merkle.py | https://github.com/StorjOld/heartbeat/blob/4d54f2011f1e9f688073d4347bc51bb7bd682718/heartbeat/Merkle/Merkle.py#L481-L515 | def get_chunk_hash(file,
seed,
filesz=None,
chunksz=DEFAULT_CHUNK_SIZE,
bufsz=DEFAULT_BUFFER_SIZE):
"""returns a hash of a chunk of the file provided. the position of
the chunk is determined by the seed. additi... | [
"def",
"get_chunk_hash",
"(",
"file",
",",
"seed",
",",
"filesz",
"=",
"None",
",",
"chunksz",
"=",
"DEFAULT_CHUNK_SIZE",
",",
"bufsz",
"=",
"DEFAULT_BUFFER_SIZE",
")",
":",
"if",
"(",
"filesz",
"is",
"None",
")",
":",
"file",
".",
"seek",
"(",
"0",
",... | returns a hash of a chunk of the file provided. the position of
the chunk is determined by the seed. additionally, the hmac of the
chunk is calculated from the seed.
:param file: a file like object to get the chunk hash from. should
support `read()`, `seek()` and `tell()`.
:p... | [
"returns",
"a",
"hash",
"of",
"a",
"chunk",
"of",
"the",
"file",
"provided",
".",
"the",
"position",
"of",
"the",
"chunk",
"is",
"determined",
"by",
"the",
"seed",
".",
"additionally",
"the",
"hmac",
"of",
"the",
"chunk",
"is",
"calculated",
"from",
"the... | python | train |
tnkteja/myhelp | virtualEnvironment/lib/python2.7/site-packages/coverage/cmdline.py | https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/coverage/cmdline.py#L558-L585 | def do_execute(self, options, args):
"""Implementation of 'coverage run'."""
# Set the first path element properly.
old_path0 = sys.path[0]
# Run the script.
self.coverage.start()
code_ran = True
try:
try:
if options.module:
... | [
"def",
"do_execute",
"(",
"self",
",",
"options",
",",
"args",
")",
":",
"# Set the first path element properly.",
"old_path0",
"=",
"sys",
".",
"path",
"[",
"0",
"]",
"# Run the script.",
"self",
".",
"coverage",
".",
"start",
"(",
")",
"code_ran",
"=",
"Tr... | Implementation of 'coverage run'. | [
"Implementation",
"of",
"coverage",
"run",
"."
] | python | test |
andycasey/ads | ads/search.py | https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/ads/search.py#L111-L132 | def _get_field(self, field):
"""
Queries the api for a single field for the record by `id`.
This method should only be called indirectly by cached properties.
:param field: name of the record field to load
"""
if not hasattr(self, "id") or self.id is None:
rai... | [
"def",
"_get_field",
"(",
"self",
",",
"field",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"id\"",
")",
"or",
"self",
".",
"id",
"is",
"None",
":",
"raise",
"APIResponseError",
"(",
"\"Cannot query an article without an id\"",
")",
"sq",
"=",
"n... | Queries the api for a single field for the record by `id`.
This method should only be called indirectly by cached properties.
:param field: name of the record field to load | [
"Queries",
"the",
"api",
"for",
"a",
"single",
"field",
"for",
"the",
"record",
"by",
"id",
".",
"This",
"method",
"should",
"only",
"be",
"called",
"indirectly",
"by",
"cached",
"properties",
".",
":",
"param",
"field",
":",
"name",
"of",
"the",
"record... | python | train |
instacart/lore | lore/env.py | https://github.com/instacart/lore/blob/0367bde9a52e69162832906acc61e8d65c5ec5d4/lore/env.py#L174-L191 | def launch():
"""Ensure that python is running from the Lore virtualenv past this point.
"""
if launched():
check_version()
os.chdir(ROOT)
return
if not os.path.exists(BIN_LORE):
missing = ' %s virtualenv is missing.' % APP
if '--launched' in sys.argv:
... | [
"def",
"launch",
"(",
")",
":",
"if",
"launched",
"(",
")",
":",
"check_version",
"(",
")",
"os",
".",
"chdir",
"(",
"ROOT",
")",
"return",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"BIN_LORE",
")",
":",
"missing",
"=",
"' %s virtualenv is ... | Ensure that python is running from the Lore virtualenv past this point. | [
"Ensure",
"that",
"python",
"is",
"running",
"from",
"the",
"Lore",
"virtualenv",
"past",
"this",
"point",
"."
] | python | train |
gc3-uzh-ch/elasticluster | elasticluster/cluster.py | https://github.com/gc3-uzh-ch/elasticluster/blob/e6345633308c76de13b889417df572815aabe744/elasticluster/cluster.py#L372-L396 | def add_nodes(self, kind, num, image_id, image_user, flavor,
security_group, image_userdata='', **extra):
"""Helper method to add multiple nodes of the same kind to a cluster.
:param str kind: kind of node to start. this refers to the groups
defined in the ans... | [
"def",
"add_nodes",
"(",
"self",
",",
"kind",
",",
"num",
",",
"image_id",
",",
"image_user",
",",
"flavor",
",",
"security_group",
",",
"image_userdata",
"=",
"''",
",",
"*",
"*",
"extra",
")",
":",
"for",
"i",
"in",
"range",
"(",
"num",
")",
":",
... | Helper method to add multiple nodes of the same kind to a cluster.
:param str kind: kind of node to start. this refers to the groups
defined in the ansible setup provider
:py:class:`elasticluster.providers.AnsibleSetupProvider`
:param int num: number o... | [
"Helper",
"method",
"to",
"add",
"multiple",
"nodes",
"of",
"the",
"same",
"kind",
"to",
"a",
"cluster",
"."
] | python | train |
Eyepea/systemDream | src/systemdream/journal/helpers.py | https://github.com/Eyepea/systemDream/blob/018fa5e9ff0f4fdc62fa85b235725d0f8b24f1a8/src/systemdream/journal/helpers.py#L13-L61 | def send(MESSAGE, SOCKET, MESSAGE_ID=None,
CODE_FILE=None, CODE_LINE=None, CODE_FUNC=None,
**kwargs):
r"""Send a message to the journal.
>>> journal.send('Hello world')
>>> journal.send('Hello, again, world', FIELD2='Greetings!')
>>> journal.send('Binary message', BINARY=b'\xde\xad\xb... | [
"def",
"send",
"(",
"MESSAGE",
",",
"SOCKET",
",",
"MESSAGE_ID",
"=",
"None",
",",
"CODE_FILE",
"=",
"None",
",",
"CODE_LINE",
"=",
"None",
",",
"CODE_FUNC",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"[",
"'MESSAGE='",
"+",
"MESSAG... | r"""Send a message to the journal.
>>> journal.send('Hello world')
>>> journal.send('Hello, again, world', FIELD2='Greetings!')
>>> journal.send('Binary message', BINARY=b'\xde\xad\xbe\xef')
Value of the MESSAGE argument will be used for the MESSAGE=
field. MESSAGE must be a string and will be sen... | [
"r",
"Send",
"a",
"message",
"to",
"the",
"journal",
"."
] | python | train |
infoxchange/supervisor-logging | supervisor_logging/__init__.py | https://github.com/infoxchange/supervisor-logging/blob/2d4411378fb52799bc506a68f1a914cbe671b13b/supervisor_logging/__init__.py#L74-L81 | def eventdata(payload):
"""
Parse a Supervisor event.
"""
headerinfo, data = payload.split('\n', 1)
headers = get_headers(headerinfo)
return headers, data | [
"def",
"eventdata",
"(",
"payload",
")",
":",
"headerinfo",
",",
"data",
"=",
"payload",
".",
"split",
"(",
"'\\n'",
",",
"1",
")",
"headers",
"=",
"get_headers",
"(",
"headerinfo",
")",
"return",
"headers",
",",
"data"
] | Parse a Supervisor event. | [
"Parse",
"a",
"Supervisor",
"event",
"."
] | python | train |
googleapis/google-cloud-python | firestore/google/cloud/firestore_v1beta1/_helpers.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/_helpers.py#L552-L580 | def pbs_for_set_no_merge(document_path, document_data):
"""Make ``Write`` protobufs for ``set()`` methods.
Args:
document_path (str): A fully-qualified document path.
document_data (dict): Property names and values to use for
replacing a document.
Returns:
List[google.c... | [
"def",
"pbs_for_set_no_merge",
"(",
"document_path",
",",
"document_data",
")",
":",
"extractor",
"=",
"DocumentExtractor",
"(",
"document_data",
")",
"if",
"extractor",
".",
"deleted_fields",
":",
"raise",
"ValueError",
"(",
"\"Cannot apply DELETE_FIELD in a set request ... | Make ``Write`` protobufs for ``set()`` methods.
Args:
document_path (str): A fully-qualified document path.
document_data (dict): Property names and values to use for
replacing a document.
Returns:
List[google.cloud.firestore_v1beta1.types.Write]: One
or two ``Write... | [
"Make",
"Write",
"protobufs",
"for",
"set",
"()",
"methods",
"."
] | python | train |
singularityhub/sregistry-cli | sregistry/main/globus/__init__.py | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/globus/__init__.py#L92-L113 | def _update_tokens(self):
'''Present the client with authentication flow to get tokens from code.
This simply updates the client _response to be used to get tokens
for auth and transfer (both use access_token as index). We call
this not on client initialization, but when the cli... | [
"def",
"_update_tokens",
"(",
"self",
")",
":",
"self",
".",
"_client",
".",
"oauth2_start_flow",
"(",
"refresh_tokens",
"=",
"True",
")",
"authorize_url",
"=",
"self",
".",
"_client",
".",
"oauth2_get_authorize_url",
"(",
")",
"print",
"(",
"'Please go to this ... | Present the client with authentication flow to get tokens from code.
This simply updates the client _response to be used to get tokens
for auth and transfer (both use access_token as index). We call
this not on client initialization, but when the client is actually
needed. | [
"Present",
"the",
"client",
"with",
"authentication",
"flow",
"to",
"get",
"tokens",
"from",
"code",
".",
"This",
"simply",
"updates",
"the",
"client",
"_response",
"to",
"be",
"used",
"to",
"get",
"tokens",
"for",
"auth",
"and",
"transfer",
"(",
"both",
"... | python | test |
MeirKriheli/python-bidi | bidi/algorithm.py | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L580-L596 | def apply_mirroring(storage, debug):
"""Applies L4: mirroring
See: http://unicode.org/reports/tr9/#L4
"""
# L4. A character is depicted by a mirrored glyph if and only if (a) the
# resolved directionality of that character is R, and (b) the
# Bidi_Mirrored property value of that character is t... | [
"def",
"apply_mirroring",
"(",
"storage",
",",
"debug",
")",
":",
"# L4. A character is depicted by a mirrored glyph if and only if (a) the",
"# resolved directionality of that character is R, and (b) the",
"# Bidi_Mirrored property value of that character is true.",
"for",
"_ch",
"in",
... | Applies L4: mirroring
See: http://unicode.org/reports/tr9/#L4 | [
"Applies",
"L4",
":",
"mirroring"
] | python | test |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L71-L73 | def error(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.error``"""
return self.logger.error(self._indent(msg, indent), **kwargs) | [
"def",
"error",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"error",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | invoke ``self.logger.error`` | [
"invoke",
"self",
".",
"logger",
".",
"error"
] | python | train |
rbit/pydtls | dtls/sslconnection.py | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L699-L715 | def connect(self, peer_address):
"""Client-side UDP connection establishment
This method connects this object's underlying socket. It subsequently
performs a handshake if do_handshake_on_connect was set during
initialization.
Arguments:
peer_address - address tuple of s... | [
"def",
"connect",
"(",
"self",
",",
"peer_address",
")",
":",
"self",
".",
"_sock",
".",
"connect",
"(",
"peer_address",
")",
"peer_address",
"=",
"self",
".",
"_sock",
".",
"getpeername",
"(",
")",
"# substituted host addrinfo",
"BIO_dgram_set_connected",
"(",
... | Client-side UDP connection establishment
This method connects this object's underlying socket. It subsequently
performs a handshake if do_handshake_on_connect was set during
initialization.
Arguments:
peer_address - address tuple of server peer | [
"Client",
"-",
"side",
"UDP",
"connection",
"establishment"
] | python | train |
SpriteLink/NIPAP | utilities/export-template.py | https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/utilities/export-template.py#L40-L54 | def get_prefixes(self, query):
""" Get prefix data from NIPAP
"""
try:
res = Prefix.smart_search(query, {})
except socket.error:
print >> sys.stderr, "Connection refused, please check hostname & port"
sys.exit(1)
except xmlrpclib.ProtocolError:... | [
"def",
"get_prefixes",
"(",
"self",
",",
"query",
")",
":",
"try",
":",
"res",
"=",
"Prefix",
".",
"smart_search",
"(",
"query",
",",
"{",
"}",
")",
"except",
"socket",
".",
"error",
":",
"print",
">>",
"sys",
".",
"stderr",
",",
"\"Connection refused,... | Get prefix data from NIPAP | [
"Get",
"prefix",
"data",
"from",
"NIPAP"
] | python | train |
limodou/uliweb | uliweb/utils/common.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L612-L617 | def application_path(path):
"""
Join application project_dir and path
"""
from uliweb import application
return os.path.join(application.project_dir, path) | [
"def",
"application_path",
"(",
"path",
")",
":",
"from",
"uliweb",
"import",
"application",
"return",
"os",
".",
"path",
".",
"join",
"(",
"application",
".",
"project_dir",
",",
"path",
")"
] | Join application project_dir and path | [
"Join",
"application",
"project_dir",
"and",
"path"
] | python | train |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L1008-L1025 | def get_objects(self):
"""Return iterable of "object descriptions", which are tuple with these items:
* `name`
* `dispname`
* `type`
* `docname`
* `anchor`
* `priority`
For details on each item, see
:py:meth:`~sphinx.domains.Domain.get_objects`.
... | [
"def",
"get_objects",
"(",
"self",
")",
":",
"for",
"modname",
",",
"info",
"in",
"self",
".",
"data",
"[",
"'modules'",
"]",
".",
"items",
"(",
")",
":",
"yield",
"(",
"modname",
",",
"modname",
",",
"'module'",
",",
"info",
"[",
"0",
"]",
",",
... | Return iterable of "object descriptions", which are tuple with these items:
* `name`
* `dispname`
* `type`
* `docname`
* `anchor`
* `priority`
For details on each item, see
:py:meth:`~sphinx.domains.Domain.get_objects`. | [
"Return",
"iterable",
"of",
"object",
"descriptions",
"which",
"are",
"tuple",
"with",
"these",
"items",
":"
] | python | train |
MillionIntegrals/vel | vel/api/model.py | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/api/model.py#L139-L142 | def loss(self, x_data, y_true):
""" Forward propagate network and return a value of loss function """
y_pred = self(x_data)
return y_pred, self.loss_value(x_data, y_true, y_pred) | [
"def",
"loss",
"(",
"self",
",",
"x_data",
",",
"y_true",
")",
":",
"y_pred",
"=",
"self",
"(",
"x_data",
")",
"return",
"y_pred",
",",
"self",
".",
"loss_value",
"(",
"x_data",
",",
"y_true",
",",
"y_pred",
")"
] | Forward propagate network and return a value of loss function | [
"Forward",
"propagate",
"network",
"and",
"return",
"a",
"value",
"of",
"loss",
"function"
] | python | train |
yinkaisheng/Python-UIAutomation-for-Windows | uiautomation/uiautomation.py | https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L2057-L2065 | def MessageBox(content: str, title: str, flags: int = MB.Ok) -> int:
"""
MessageBox from Win32.
content: str.
title: str.
flags: int, a value or some combined values in class `MB`.
Return int, a value in MB whose name starts with Id, such as MB.IdOk
"""
return ctypes.windll.user32.Messag... | [
"def",
"MessageBox",
"(",
"content",
":",
"str",
",",
"title",
":",
"str",
",",
"flags",
":",
"int",
"=",
"MB",
".",
"Ok",
")",
"->",
"int",
":",
"return",
"ctypes",
".",
"windll",
".",
"user32",
".",
"MessageBoxW",
"(",
"ctypes",
".",
"c_void_p",
... | MessageBox from Win32.
content: str.
title: str.
flags: int, a value or some combined values in class `MB`.
Return int, a value in MB whose name starts with Id, such as MB.IdOk | [
"MessageBox",
"from",
"Win32",
".",
"content",
":",
"str",
".",
"title",
":",
"str",
".",
"flags",
":",
"int",
"a",
"value",
"or",
"some",
"combined",
"values",
"in",
"class",
"MB",
".",
"Return",
"int",
"a",
"value",
"in",
"MB",
"whose",
"name",
"st... | python | valid |
urinieto/msaf | msaf/algorithms/olda/segmenter.py | https://github.com/urinieto/msaf/blob/9dbb57d77a1310465a65cc40f1641d083ca74385/msaf/algorithms/olda/segmenter.py#L154-L166 | def gaussian_cost(X):
'''Return the average log-likelihood of data under a standard normal
'''
d, n = X.shape
if n < 2:
return 0
sigma = np.var(X, axis=1, ddof=1)
cost = -0.5 * d * n * np.log(2. * np.pi) - 0.5 * (n - 1.) * np.sum(sigma)
return cost | [
"def",
"gaussian_cost",
"(",
"X",
")",
":",
"d",
",",
"n",
"=",
"X",
".",
"shape",
"if",
"n",
"<",
"2",
":",
"return",
"0",
"sigma",
"=",
"np",
".",
"var",
"(",
"X",
",",
"axis",
"=",
"1",
",",
"ddof",
"=",
"1",
")",
"cost",
"=",
"-",
"0.... | Return the average log-likelihood of data under a standard normal | [
"Return",
"the",
"average",
"log",
"-",
"likelihood",
"of",
"data",
"under",
"a",
"standard",
"normal"
] | python | test |
uogbuji/versa | tools/py/writer/csv.py | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/writer/csv.py#L25-L33 | def omap(m):
'''
Create a nested mapping from origin to property to values/attributes covering an entire Versa model
'''
om = {}
for s, p, o, a in m.match():
om.setdefault(s, {})
om[s].setdefault(p, []).append((o, a))
return om | [
"def",
"omap",
"(",
"m",
")",
":",
"om",
"=",
"{",
"}",
"for",
"s",
",",
"p",
",",
"o",
",",
"a",
"in",
"m",
".",
"match",
"(",
")",
":",
"om",
".",
"setdefault",
"(",
"s",
",",
"{",
"}",
")",
"om",
"[",
"s",
"]",
".",
"setdefault",
"("... | Create a nested mapping from origin to property to values/attributes covering an entire Versa model | [
"Create",
"a",
"nested",
"mapping",
"from",
"origin",
"to",
"property",
"to",
"values",
"/",
"attributes",
"covering",
"an",
"entire",
"Versa",
"model"
] | python | train |
edx/edx-django-release-util | release_util/management/commands/__init__.py | https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L159-L184 | def _get_unapplied_migrations(self, loader):
"""
Output a list of unapplied migrations in the form [['migration1', migration2'], ...].
This implementation is mostly copied from the Django 'showmigrations' mgmt command.
https://github.com/django/django/blob/stable/1.8.x/django/core/manage... | [
"def",
"_get_unapplied_migrations",
"(",
"self",
",",
"loader",
")",
":",
"unapplied",
"=",
"[",
"]",
"graph",
"=",
"loader",
".",
"graph",
"plan",
"=",
"[",
"]",
"seen",
"=",
"set",
"(",
")",
"# Generate the plan, in the order that migrations have been/should be ... | Output a list of unapplied migrations in the form [['migration1', migration2'], ...].
This implementation is mostly copied from the Django 'showmigrations' mgmt command.
https://github.com/django/django/blob/stable/1.8.x/django/core/management/commands/showmigrations.py
This should only be call... | [
"Output",
"a",
"list",
"of",
"unapplied",
"migrations",
"in",
"the",
"form",
"[[",
"migration1",
"migration2",
"]",
"...",
"]",
".",
"This",
"implementation",
"is",
"mostly",
"copied",
"from",
"the",
"Django",
"showmigrations",
"mgmt",
"command",
".",
"https",... | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.