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 |
|---|---|---|---|---|---|---|---|---|
joke2k/faker | faker/providers/address/ko_KR/__init__.py | https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ko_KR/__init__.py#L274-L279 | def land_address(self):
"""
:example ์ธ์ข
ํน๋ณ์์น์ ์ด์ง๋ 507
"""
pattern = self.random_element(self.land_address_formats)
return self.generator.parse(pattern) | [
"def",
"land_address",
"(",
"self",
")",
":",
"pattern",
"=",
"self",
".",
"random_element",
"(",
"self",
".",
"land_address_formats",
")",
"return",
"self",
".",
"generator",
".",
"parse",
"(",
"pattern",
")"
] | :example ์ธ์ข
ํน๋ณ์์น์ ์ด์ง๋ 507 | [
":",
"example",
"์ธ์ข
ํน๋ณ์์น์",
"์ด์ง๋",
"507"
] | python | train |
Nekroze/partpy | partpy/sourcestring.py | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L38-L42 | def set_string(self, string):
"""Set the working string and its length then reset positions."""
self.string = string
self.length = len(string)
self.reset_position() | [
"def",
"set_string",
"(",
"self",
",",
"string",
")",
":",
"self",
".",
"string",
"=",
"string",
"self",
".",
"length",
"=",
"len",
"(",
"string",
")",
"self",
".",
"reset_position",
"(",
")"
] | Set the working string and its length then reset positions. | [
"Set",
"the",
"working",
"string",
"and",
"its",
"length",
"then",
"reset",
"positions",
"."
] | python | train |
saltstack/salt | salt/states/host.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/host.py#L70-L165 | def present(name, ip, clean=False): # pylint: disable=C0103
'''
Ensures that the named host is present with the given ip
name
The host to assign an ip to
ip
The ip addr(s) to apply to the host. Can be a single IP or a list of IP
addresses.
clean : False
Remove any... | [
"def",
"present",
"(",
"name",
",",
"ip",
",",
"clean",
"=",
"False",
")",
":",
"# pylint: disable=C0103",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"None",
"if",
"__opts__",
"[",
"'test'",
"]",
"e... | Ensures that the named host is present with the given ip
name
The host to assign an ip to
ip
The ip addr(s) to apply to the host. Can be a single IP or a list of IP
addresses.
clean : False
Remove any entries which don't match those configured in the ``ip``
option.... | [
"Ensures",
"that",
"the",
"named",
"host",
"is",
"present",
"with",
"the",
"given",
"ip"
] | python | train |
saltstack/salt | salt/modules/lxd.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1836-L1911 | def container_execute(name, cmd, remote_addr=None,
cert=None, key=None, verify_cert=True):
'''
Execute a command list on a container.
name :
Name of the container
cmd :
Command to be executed (as a list)
Example :
'["ls", "-l"]'
remote_ad... | [
"def",
"container_execute",
"(",
"name",
",",
"cmd",
",",
"remote_addr",
"=",
"None",
",",
"cert",
"=",
"None",
",",
"key",
"=",
"None",
",",
"verify_cert",
"=",
"True",
")",
":",
"container",
"=",
"container_get",
"(",
"name",
",",
"remote_addr",
",",
... | Execute a command list on a container.
name :
Name of the container
cmd :
Command to be executed (as a list)
Example :
'["ls", "-l"]'
remote_addr :
An URL to a remote Server, you also have to give cert and key if
you provide remote_addr and its a TCP A... | [
"Execute",
"a",
"command",
"list",
"on",
"a",
"container",
"."
] | python | train |
saltstack/salt | salt/modules/lxc.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L2312-L2340 | def _ensure_running(name, no_start=False, path=None):
'''
If the container is not currently running, start it. This function returns
the state that the container was in before changing
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: ... | [
"def",
"_ensure_running",
"(",
"name",
",",
"no_start",
"=",
"False",
",",
"path",
"=",
"None",
")",
":",
"_ensure_exists",
"(",
"name",
",",
"path",
"=",
"path",
")",
"pre",
"=",
"state",
"(",
"name",
",",
"path",
"=",
"path",
")",
"if",
"pre",
"=... | If the container is not currently running, start it. This function returns
the state that the container was in before changing
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0 | [
"If",
"the",
"container",
"is",
"not",
"currently",
"running",
"start",
"it",
".",
"This",
"function",
"returns",
"the",
"state",
"that",
"the",
"container",
"was",
"in",
"before",
"changing"
] | python | train |
oanda/v20-python | src/v20/pricing.py | https://github.com/oanda/v20-python/blob/f28192f4a31bce038cf6dfa302f5878bec192fe5/src/v20/pricing.py#L273-L298 | def from_dict(data, ctx):
"""
Instantiate a new HomeConversions from a dict (generally from loading a
JSON response). The data used to instantiate the HomeConversions is a
shallow copy of the dict passed in, with any complex child types
instantiated appropriately.
"""
... | [
"def",
"from_dict",
"(",
"data",
",",
"ctx",
")",
":",
"data",
"=",
"data",
".",
"copy",
"(",
")",
"if",
"data",
".",
"get",
"(",
"'accountGain'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'accountGain'",
"]",
"=",
"ctx",
".",
"convert_decimal_num... | Instantiate a new HomeConversions from a dict (generally from loading a
JSON response). The data used to instantiate the HomeConversions is a
shallow copy of the dict passed in, with any complex child types
instantiated appropriately. | [
"Instantiate",
"a",
"new",
"HomeConversions",
"from",
"a",
"dict",
"(",
"generally",
"from",
"loading",
"a",
"JSON",
"response",
")",
".",
"The",
"data",
"used",
"to",
"instantiate",
"the",
"HomeConversions",
"is",
"a",
"shallow",
"copy",
"of",
"the",
"dict"... | python | train |
hydpy-dev/hydpy | hydpy/core/filetools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/filetools.py#L765-L779 | def save_files(self, selections) -> None:
"""Save the |Selection| objects contained in the given |Selections|
instance to separate network files."""
try:
currentpath = self.currentpath
selections = selectiontools.Selections(selections)
for selection in selecti... | [
"def",
"save_files",
"(",
"self",
",",
"selections",
")",
"->",
"None",
":",
"try",
":",
"currentpath",
"=",
"self",
".",
"currentpath",
"selections",
"=",
"selectiontools",
".",
"Selections",
"(",
"selections",
")",
"for",
"selection",
"in",
"selections",
"... | Save the |Selection| objects contained in the given |Selections|
instance to separate network files. | [
"Save",
"the",
"|Selection|",
"objects",
"contained",
"in",
"the",
"given",
"|Selections|",
"instance",
"to",
"separate",
"network",
"files",
"."
] | python | train |
CivicSpleen/ambry | ambry/metadata/proptree.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/metadata/proptree.py#L390-L399 | def scalar_term(self, st):
"""Return a _ScalarTermS or _ScalarTermU from a string, to perform text and HTML substitutions"""
if isinstance(st, binary_type):
return _ScalarTermS(st, self._jinja_sub)
elif isinstance(st, text_type):
return _ScalarTermU(st, self._jinja_sub)
... | [
"def",
"scalar_term",
"(",
"self",
",",
"st",
")",
":",
"if",
"isinstance",
"(",
"st",
",",
"binary_type",
")",
":",
"return",
"_ScalarTermS",
"(",
"st",
",",
"self",
".",
"_jinja_sub",
")",
"elif",
"isinstance",
"(",
"st",
",",
"text_type",
")",
":",
... | Return a _ScalarTermS or _ScalarTermU from a string, to perform text and HTML substitutions | [
"Return",
"a",
"_ScalarTermS",
"or",
"_ScalarTermU",
"from",
"a",
"string",
"to",
"perform",
"text",
"and",
"HTML",
"substitutions"
] | python | train |
GeospatialPython/pyshp | shapefile.py | https://github.com/GeospatialPython/pyshp/blob/71231ddc5aa54f155d4f0563c56006fffbfc84e7/shapefile.py#L702-L711 | def __getFileObj(self, f):
"""Checks to see if the requested shapefile file object is
available. If not a ShapefileException is raised."""
if not f:
raise ShapefileException("Shapefile Reader requires a shapefile or file-like object.")
if self.shp and self.shpLength is N... | [
"def",
"__getFileObj",
"(",
"self",
",",
"f",
")",
":",
"if",
"not",
"f",
":",
"raise",
"ShapefileException",
"(",
"\"Shapefile Reader requires a shapefile or file-like object.\"",
")",
"if",
"self",
".",
"shp",
"and",
"self",
".",
"shpLength",
"is",
"None",
":"... | Checks to see if the requested shapefile file object is
available. If not a ShapefileException is raised. | [
"Checks",
"to",
"see",
"if",
"the",
"requested",
"shapefile",
"file",
"object",
"is",
"available",
".",
"If",
"not",
"a",
"ShapefileException",
"is",
"raised",
"."
] | python | train |
wq/django-natural-keys | natural_keys/models.py | https://github.com/wq/django-natural-keys/blob/f6bd6baf848e709ae9920b259a3ad1a6be8af615/natural_keys/models.py#L194-L203 | def natural_key(self):
"""
Return the natural key for this object.
(This is a generic implementation of the standard Django function)
"""
# Recursively extract properties from related objects if needed
vals = [reduce(getattr, name.split('__'), self)
for n... | [
"def",
"natural_key",
"(",
"self",
")",
":",
"# Recursively extract properties from related objects if needed",
"vals",
"=",
"[",
"reduce",
"(",
"getattr",
",",
"name",
".",
"split",
"(",
"'__'",
")",
",",
"self",
")",
"for",
"name",
"in",
"self",
".",
"get_na... | Return the natural key for this object.
(This is a generic implementation of the standard Django function) | [
"Return",
"the",
"natural",
"key",
"for",
"this",
"object",
"."
] | python | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1314-L1327 | def checkUpdate(self, *args):
"""
Updates values after first checking instrument parameters are OK.
This is not integrated within update to prevent ifinite recursion
since update gets called from ipars.
"""
g = get_root(self).globals
if not self.check():
... | [
"def",
"checkUpdate",
"(",
"self",
",",
"*",
"args",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"if",
"not",
"self",
".",
"check",
"(",
")",
":",
"g",
".",
"clog",
".",
"warn",
"(",
"'Current observing parameters are not valid.'",
... | Updates values after first checking instrument parameters are OK.
This is not integrated within update to prevent ifinite recursion
since update gets called from ipars. | [
"Updates",
"values",
"after",
"first",
"checking",
"instrument",
"parameters",
"are",
"OK",
".",
"This",
"is",
"not",
"integrated",
"within",
"update",
"to",
"prevent",
"ifinite",
"recursion",
"since",
"update",
"gets",
"called",
"from",
"ipars",
"."
] | python | train |
pytroll/satpy | satpy/multiscene.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/multiscene.py#L92-L96 | def _create_cached_iter(self):
"""Iterate over the provided scenes, caching them for later."""
for scn in self._scene_gen:
self._scene_cache.append(scn)
yield scn | [
"def",
"_create_cached_iter",
"(",
"self",
")",
":",
"for",
"scn",
"in",
"self",
".",
"_scene_gen",
":",
"self",
".",
"_scene_cache",
".",
"append",
"(",
"scn",
")",
"yield",
"scn"
] | Iterate over the provided scenes, caching them for later. | [
"Iterate",
"over",
"the",
"provided",
"scenes",
"caching",
"them",
"for",
"later",
"."
] | python | train |
assamite/creamas | creamas/mp.py | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L446-L481 | def get_agents(self, addr=True, agent_cls=None, as_coro=False):
"""Get agents from the slave environments.
:param bool addr:
If ``True``, returns only addresses of the agents, otherwise
returns a :class:`Proxy` object for each agent.
:param agent_cls:
If spe... | [
"def",
"get_agents",
"(",
"self",
",",
"addr",
"=",
"True",
",",
"agent_cls",
"=",
"None",
",",
"as_coro",
"=",
"False",
")",
":",
"async",
"def",
"slave_task",
"(",
"mgr_addr",
",",
"addr",
"=",
"True",
",",
"agent_cls",
"=",
"None",
")",
":",
"r_ma... | Get agents from the slave environments.
:param bool addr:
If ``True``, returns only addresses of the agents, otherwise
returns a :class:`Proxy` object for each agent.
:param agent_cls:
If specified, returns only agents that are members of that
particular... | [
"Get",
"agents",
"from",
"the",
"slave",
"environments",
"."
] | python | train |
rgmining/ria | ria/bipartite.py | https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L363-L389 | def add_review(self, reviewer, product, review, date=None):
"""Add a new review from a given reviewer to a given product.
Args:
reviewer: an instance of Reviewer.
product: an instance of Product.
review: a float value.
date: date the review issued.
Retur... | [
"def",
"add_review",
"(",
"self",
",",
"reviewer",
",",
"product",
",",
"review",
",",
"date",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"reviewer",
",",
"self",
".",
"_reviewer_cls",
")",
":",
"raise",
"TypeError",
"(",
"\"Type of given revie... | Add a new review from a given reviewer to a given product.
Args:
reviewer: an instance of Reviewer.
product: an instance of Product.
review: a float value.
date: date the review issued.
Returns:
the added new review object.
Raises:
T... | [
"Add",
"a",
"new",
"review",
"from",
"a",
"given",
"reviewer",
"to",
"a",
"given",
"product",
"."
] | python | train |
xeroc/python-graphenelib | graphenestorage/masterpassword.py | https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenestorage/masterpassword.py#L116-L131 | def _new_masterpassword(self, password):
""" Generate a new random masterkey, encrypt it with the password and
store it in the store.
:param str password: Password to use for en-/de-cryption
"""
# make sure to not overwrite an existing key
if self.config_key in s... | [
"def",
"_new_masterpassword",
"(",
"self",
",",
"password",
")",
":",
"# make sure to not overwrite an existing key",
"if",
"self",
".",
"config_key",
"in",
"self",
".",
"config",
"and",
"self",
".",
"config",
"[",
"self",
".",
"config_key",
"]",
":",
"raise",
... | Generate a new random masterkey, encrypt it with the password and
store it in the store.
:param str password: Password to use for en-/de-cryption | [
"Generate",
"a",
"new",
"random",
"masterkey",
"encrypt",
"it",
"with",
"the",
"password",
"and",
"store",
"it",
"in",
"the",
"store",
"."
] | python | valid |
studionow/pybrightcove | pybrightcove/video.py | https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/video.py#L345-L410 | def to_xml(self):
# pylint: disable=R0912
"""
Converts object into an XML string.
"""
xml = ''
for asset in self.assets:
xml += '<asset filename="%s" ' % \
os.path.basename(asset['filename'])
xml += ' refid="%(refid)s"' % asset
... | [
"def",
"to_xml",
"(",
"self",
")",
":",
"# pylint: disable=R0912",
"xml",
"=",
"''",
"for",
"asset",
"in",
"self",
".",
"assets",
":",
"xml",
"+=",
"'<asset filename=\"%s\" '",
"%",
"os",
".",
"path",
".",
"basename",
"(",
"asset",
"[",
"'filename'",
"]",
... | Converts object into an XML string. | [
"Converts",
"object",
"into",
"an",
"XML",
"string",
"."
] | python | train |
Murali-group/halp | halp/utilities/priority_queue.py | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/priority_queue.py#L41-L52 | def add_element(self, priority, element, count=None):
"""Adds an element with a specific priority.
:param priority: priority of the element.
:param element: element to add.
"""
if count is None:
count = next(self.counter)
entry = [priority, count, element]
... | [
"def",
"add_element",
"(",
"self",
",",
"priority",
",",
"element",
",",
"count",
"=",
"None",
")",
":",
"if",
"count",
"is",
"None",
":",
"count",
"=",
"next",
"(",
"self",
".",
"counter",
")",
"entry",
"=",
"[",
"priority",
",",
"count",
",",
"el... | Adds an element with a specific priority.
:param priority: priority of the element.
:param element: element to add. | [
"Adds",
"an",
"element",
"with",
"a",
"specific",
"priority",
"."
] | python | train |
ungarj/mapchete | mapchete/tile.py | https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/tile.py#L42-L60 | def tile(self, zoom, row, col):
"""
Return ``BufferedTile`` object of this ``BufferedTilePyramid``.
Parameters
----------
zoom : integer
zoom level
row : integer
tile matrix row
col : integer
tile matrix column
Returns... | [
"def",
"tile",
"(",
"self",
",",
"zoom",
",",
"row",
",",
"col",
")",
":",
"tile",
"=",
"self",
".",
"tile_pyramid",
".",
"tile",
"(",
"zoom",
",",
"row",
",",
"col",
")",
"return",
"BufferedTile",
"(",
"tile",
",",
"pixelbuffer",
"=",
"self",
".",... | Return ``BufferedTile`` object of this ``BufferedTilePyramid``.
Parameters
----------
zoom : integer
zoom level
row : integer
tile matrix row
col : integer
tile matrix column
Returns
-------
buffered tile : ``BufferedT... | [
"Return",
"BufferedTile",
"object",
"of",
"this",
"BufferedTilePyramid",
"."
] | python | valid |
threeML/astromodels | astromodels/core/parameter.py | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L962-L1011 | def set_uninformative_prior(self, prior_class):
"""
Sets the prior for the parameter to a uniform prior between the current minimum and maximum, or a
log-uniform prior between the current minimum and maximum.
NOTE: if the current minimum and maximum are not defined, the default bounds f... | [
"def",
"set_uninformative_prior",
"(",
"self",
",",
"prior_class",
")",
":",
"prior_instance",
"=",
"prior_class",
"(",
")",
"if",
"self",
".",
"min_value",
"is",
"None",
":",
"raise",
"ParameterMustHaveBounds",
"(",
"\"Parameter %s does not have a defined minimum. Set ... | Sets the prior for the parameter to a uniform prior between the current minimum and maximum, or a
log-uniform prior between the current minimum and maximum.
NOTE: if the current minimum and maximum are not defined, the default bounds for the prior class will be used.
:param prior_class : the c... | [
"Sets",
"the",
"prior",
"for",
"the",
"parameter",
"to",
"a",
"uniform",
"prior",
"between",
"the",
"current",
"minimum",
"and",
"maximum",
"or",
"a",
"log",
"-",
"uniform",
"prior",
"between",
"the",
"current",
"minimum",
"and",
"maximum",
"."
] | python | train |
Erotemic/utool | utool/util_str.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L2650-L2682 | def to_camel_case(underscore_case, mixed=False):
r"""
Args:
underscore_case (?):
Returns:
str: camel_case_str
CommandLine:
python -m utool.util_str --exec-to_camel_case
References:
https://en.wikipedia.org/wiki/CamelCase
Example:
>>> # ENABLE_DOCTEST
... | [
"def",
"to_camel_case",
"(",
"underscore_case",
",",
"mixed",
"=",
"False",
")",
":",
"thresh",
"=",
"0",
"if",
"mixed",
"else",
"-",
"1",
"words",
"=",
"underscore_case",
".",
"split",
"(",
"'_'",
")",
"words2",
"=",
"[",
"word",
"[",
"0",
"]",
".",... | r"""
Args:
underscore_case (?):
Returns:
str: camel_case_str
CommandLine:
python -m utool.util_str --exec-to_camel_case
References:
https://en.wikipedia.org/wiki/CamelCase
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_str import * # NOQA
... | [
"r",
"Args",
":",
"underscore_case",
"(",
"?",
")",
":"
] | python | train |
viswa-swami/python-foscam | libpyfoscam/foscam.py | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L172-L182 | def set_port_info(self, webport, mediaport, httpsport,
onvifport, callback=None):
'''
Set http port and media port of camera.
'''
params = {'webPort' : webport,
'mediaPort' : mediaport,
'httpsPort' : httpsport,
... | [
"def",
"set_port_info",
"(",
"self",
",",
"webport",
",",
"mediaport",
",",
"httpsport",
",",
"onvifport",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'webPort'",
":",
"webport",
",",
"'mediaPort'",
":",
"mediaport",
",",
"'httpsPort'",
":... | Set http port and media port of camera. | [
"Set",
"http",
"port",
"and",
"media",
"port",
"of",
"camera",
"."
] | python | train |
CalebBell/fluids | fluids/geometry.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L156-L221 | def V_horiz_conical(D, L, a, h, headonly=False):
r'''Calculates volume of a tank with conical ends, according to [1]_.
.. math::
V_f = A_fL + \frac{2aR^2}{3}K, \;\;0 \le h < R\\
.. math::
V_f = A_fL + \frac{2aR^2}{3}\pi/2,\;\; h = R\\
.. math::
V_f = A_fL + \frac{2aR^2}{3}(\pi... | [
"def",
"V_horiz_conical",
"(",
"D",
",",
"L",
",",
"a",
",",
"h",
",",
"headonly",
"=",
"False",
")",
":",
"R",
"=",
"D",
"/",
"2.",
"Af",
"=",
"R",
"*",
"R",
"*",
"acos",
"(",
"(",
"R",
"-",
"h",
")",
"/",
"R",
")",
"-",
"(",
"R",
"-",... | r'''Calculates volume of a tank with conical ends, according to [1]_.
.. math::
V_f = A_fL + \frac{2aR^2}{3}K, \;\;0 \le h < R\\
.. math::
V_f = A_fL + \frac{2aR^2}{3}\pi/2,\;\; h = R\\
.. math::
V_f = A_fL + \frac{2aR^2}{3}(\pi-K), \;\; R< h \le 2R
.. math::
K = \cos... | [
"r",
"Calculates",
"volume",
"of",
"a",
"tank",
"with",
"conical",
"ends",
"according",
"to",
"[",
"1",
"]",
"_",
"."
] | python | train |
google/tangent | tangent/tf_extensions.py | https://github.com/google/tangent/blob/6533e83af09de7345d1b438512679992f080dcc9/tangent/tf_extensions.py#L116-L138 | def unreduce_tensor(tensor, shape, axis, keepdims):
"""Reverse summing over a dimension.
See utils.py.
Args:
tensor: The tensor that was reduced.
shape: A list, the original shape of the tensor before reduction.
axis: The axis or axes that were summed.
keepdims: Whether these axes were kept as s... | [
"def",
"unreduce_tensor",
"(",
"tensor",
",",
"shape",
",",
"axis",
",",
"keepdims",
")",
":",
"if",
"not",
"keepdims",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"range",
"(",
"len",
"(",
"shape",
")",
")",
"elif",
"isinstance",
"(",
"axis",... | Reverse summing over a dimension.
See utils.py.
Args:
tensor: The tensor that was reduced.
shape: A list, the original shape of the tensor before reduction.
axis: The axis or axes that were summed.
keepdims: Whether these axes were kept as singleton axes.
Returns:
A tensor with axes broadca... | [
"Reverse",
"summing",
"over",
"a",
"dimension",
"."
] | python | train |
awslabs/serverless-application-model | examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py#L28-L45 | def get_thing_shadow(self, **kwargs):
r"""
Call shadow lambda to obtain current shadow state.
:Keyword Arguments:
* *thingName* (``string``) --
[REQUIRED]
The name of the thing.
:returns: (``dict``) --
The output from the GetThingShadow o... | [
"def",
"get_thing_shadow",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"thing_name",
"=",
"self",
".",
"_get_required_parameter",
"(",
"'thingName'",
",",
"*",
"*",
"kwargs",
")",
"payload",
"=",
"b''",
"return",
"self",
".",
"_shadow_op",
"(",
"'get'"... | r"""
Call shadow lambda to obtain current shadow state.
:Keyword Arguments:
* *thingName* (``string``) --
[REQUIRED]
The name of the thing.
:returns: (``dict``) --
The output from the GetThingShadow operation
* *payload* (``bytes``) -... | [
"r",
"Call",
"shadow",
"lambda",
"to",
"obtain",
"current",
"shadow",
"state",
"."
] | python | train |
adamzap/landslide | landslide/parser.py | https://github.com/adamzap/landslide/blob/59b0403d7a7cca4b8ff6ba7fb76efb9748b3f832/landslide/parser.py#L49-L86 | def parse(self, text):
"""Parses and renders a text as HTML regarding current format.
"""
if self.format == 'markdown':
try:
import markdown
except ImportError:
raise RuntimeError(u"Looks like markdown is not installed")
if tex... | [
"def",
"parse",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"format",
"==",
"'markdown'",
":",
"try",
":",
"import",
"markdown",
"except",
"ImportError",
":",
"raise",
"RuntimeError",
"(",
"u\"Looks like markdown is not installed\"",
")",
"if",
"tex... | Parses and renders a text as HTML regarding current format. | [
"Parses",
"and",
"renders",
"a",
"text",
"as",
"HTML",
"regarding",
"current",
"format",
"."
] | python | train |
square/connect-python-sdk | squareconnect/models/order_fulfillment_recipient.py | https://github.com/square/connect-python-sdk/blob/adc1d09e817986cdc607391580f71d6b48ed4066/squareconnect/models/order_fulfillment_recipient.py#L149-L163 | def phone_number(self, phone_number):
"""
Sets the phone_number of this OrderFulfillmentRecipient.
The phone number of the fulfillment recipient. If provided, overrides the value from customer profile indicated by customer_id.
:param phone_number: The phone_number of this OrderFulfillm... | [
"def",
"phone_number",
"(",
"self",
",",
"phone_number",
")",
":",
"if",
"phone_number",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `phone_number`, must not be `None`\"",
")",
"if",
"len",
"(",
"phone_number",
")",
">",
"16",
":",
"raise",... | Sets the phone_number of this OrderFulfillmentRecipient.
The phone number of the fulfillment recipient. If provided, overrides the value from customer profile indicated by customer_id.
:param phone_number: The phone_number of this OrderFulfillmentRecipient.
:type: str | [
"Sets",
"the",
"phone_number",
"of",
"this",
"OrderFulfillmentRecipient",
".",
"The",
"phone",
"number",
"of",
"the",
"fulfillment",
"recipient",
".",
"If",
"provided",
"overrides",
"the",
"value",
"from",
"customer",
"profile",
"indicated",
"by",
"customer_id",
"... | python | train |
PyCQA/pylint | pylint/checkers/base.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/base.py#L1327-L1342 | def visit_call(self, node):
"""visit a Call node -> check if this is not a blacklisted builtin
call and check for * or ** use
"""
self._check_misplaced_format_function(node)
if isinstance(node.func, astroid.Name):
name = node.func.name
# ignore the name if... | [
"def",
"visit_call",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"_check_misplaced_format_function",
"(",
"node",
")",
"if",
"isinstance",
"(",
"node",
".",
"func",
",",
"astroid",
".",
"Name",
")",
":",
"name",
"=",
"node",
".",
"func",
".",
"nam... | visit a Call node -> check if this is not a blacklisted builtin
call and check for * or ** use | [
"visit",
"a",
"Call",
"node",
"-",
">",
"check",
"if",
"this",
"is",
"not",
"a",
"blacklisted",
"builtin",
"call",
"and",
"check",
"for",
"*",
"or",
"**",
"use"
] | python | test |
memsql/memsql-python | memsql/common/query_builder.py | https://github.com/memsql/memsql-python/blob/aac223a1b937d5b348b42af3c601a6c685ca633a/memsql/common/query_builder.py#L1-L14 | def simple_expression(joiner=', ', **fields):
""" Build a simple expression ready to be added onto another query.
>>> simple_expression(joiner=' AND ', name='bob', role='admin')
"`name`=%(_QB_name)s AND `name`=%(_QB_role)s", { '_QB_name': 'bob', '_QB_role': 'admin' }
"""
expression, params = [], {}... | [
"def",
"simple_expression",
"(",
"joiner",
"=",
"', '",
",",
"*",
"*",
"fields",
")",
":",
"expression",
",",
"params",
"=",
"[",
"]",
",",
"{",
"}",
"for",
"field_name",
",",
"value",
"in",
"sorted",
"(",
"fields",
".",
"items",
"(",
")",
",",
"ke... | Build a simple expression ready to be added onto another query.
>>> simple_expression(joiner=' AND ', name='bob', role='admin')
"`name`=%(_QB_name)s AND `name`=%(_QB_role)s", { '_QB_name': 'bob', '_QB_role': 'admin' } | [
"Build",
"a",
"simple",
"expression",
"ready",
"to",
"be",
"added",
"onto",
"another",
"query",
"."
] | python | test |
CxAalto/gtfspy | gtfspy/import_validator.py | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/import_validator.py#L267-L281 | def _compute_number_of_frequency_generated_stop_times(self, gtfs_source_path):
"""
Parameters
----------
Same as for "_frequency_generated_trips_rows" but for stop times table
gtfs_source_path:
table_name:
Return
------
"""
df_freq = self.... | [
"def",
"_compute_number_of_frequency_generated_stop_times",
"(",
"self",
",",
"gtfs_source_path",
")",
":",
"df_freq",
"=",
"self",
".",
"_frequency_generated_trips_rows",
"(",
"gtfs_source_path",
",",
"return_df_freq",
"=",
"True",
")",
"df_stop_times",
"=",
"source_csv_... | Parameters
----------
Same as for "_frequency_generated_trips_rows" but for stop times table
gtfs_source_path:
table_name:
Return
------ | [
"Parameters",
"----------",
"Same",
"as",
"for",
"_frequency_generated_trips_rows",
"but",
"for",
"stop",
"times",
"table",
"gtfs_source_path",
":",
"table_name",
":"
] | python | valid |
rigetti/pyquil | pyquil/api/_qpu.py | https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/api/_qpu.py#L128-L173 | def run(self, run_priority: Optional[int] = None):
"""
Run a pyquil program on the QPU.
This formats the classified data from the QPU server by stacking measured bits into
an array of shape (trials, classical_addresses). The mapping of qubit to
classical address is backed out fr... | [
"def",
"run",
"(",
"self",
",",
"run_priority",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
":",
"# This prevents a common error where users expect QVM.run()",
"# and QPU.run() to be interchangeable. QPU.run() needs the",
"# supplied executable to have been compiled, QVM.ru... | Run a pyquil program on the QPU.
This formats the classified data from the QPU server by stacking measured bits into
an array of shape (trials, classical_addresses). The mapping of qubit to
classical address is backed out from MEASURE instructions in the program, so
only do measurements... | [
"Run",
"a",
"pyquil",
"program",
"on",
"the",
"QPU",
"."
] | python | train |
chrisspen/burlap | burlap/project.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/project.py#L164-L181 | def update_settings(self, d, role, path='roles/{role}/settings.yaml'):
"""
Writes a key/value pair to a settings file.
"""
try:
import ruamel.yaml
load_func = ruamel.yaml.round_trip_load
dump_func = ruamel.yaml.round_trip_dump
except ImportErro... | [
"def",
"update_settings",
"(",
"self",
",",
"d",
",",
"role",
",",
"path",
"=",
"'roles/{role}/settings.yaml'",
")",
":",
"try",
":",
"import",
"ruamel",
".",
"yaml",
"load_func",
"=",
"ruamel",
".",
"yaml",
".",
"round_trip_load",
"dump_func",
"=",
"ruamel"... | Writes a key/value pair to a settings file. | [
"Writes",
"a",
"key",
"/",
"value",
"pair",
"to",
"a",
"settings",
"file",
"."
] | python | valid |
estnltk/estnltk | estnltk/clausesegmenter.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/clausesegmenter.py#L93-L106 | def rename_annotations(self, sentence):
"""Function that renames and restructures clause information."""
annotations = []
for token in sentence:
data = {CLAUSE_IDX: token[CLAUSE_IDX]}
if CLAUSE_ANNOT in token:
if 'KINDEL_PIIR' in token[CLAUSE_ANNOT]:
... | [
"def",
"rename_annotations",
"(",
"self",
",",
"sentence",
")",
":",
"annotations",
"=",
"[",
"]",
"for",
"token",
"in",
"sentence",
":",
"data",
"=",
"{",
"CLAUSE_IDX",
":",
"token",
"[",
"CLAUSE_IDX",
"]",
"}",
"if",
"CLAUSE_ANNOT",
"in",
"token",
":",... | Function that renames and restructures clause information. | [
"Function",
"that",
"renames",
"and",
"restructures",
"clause",
"information",
"."
] | python | train |
edx/edx-organizations | organizations/data.py | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L75-L85 | def _activate_organization_course_relationship(relationship): # pylint: disable=invalid-name
"""
Activates an inactive organization-course relationship
"""
# If the relationship doesn't exist or the organization isn't active we'll want to raise an error
relationship = internal.OrganizationCourse.ob... | [
"def",
"_activate_organization_course_relationship",
"(",
"relationship",
")",
":",
"# pylint: disable=invalid-name",
"# If the relationship doesn't exist or the organization isn't active we'll want to raise an error",
"relationship",
"=",
"internal",
".",
"OrganizationCourse",
".",
"obj... | Activates an inactive organization-course relationship | [
"Activates",
"an",
"inactive",
"organization",
"-",
"course",
"relationship"
] | python | valid |
iskandr/fancyimpute | fancyimpute/dictionary_helpers.py | https://github.com/iskandr/fancyimpute/blob/9f0837d387c7303d5c8c925a9989ca77a1a96e3e/fancyimpute/dictionary_helpers.py#L191-L200 | def uncurry_nested_dictionary(curried_dict):
"""
Transform dictionary from (key_a -> key_b -> float) to
(key_a, key_b) -> float
"""
result = {}
for a, a_dict in curried_dict.items():
for b, value in a_dict.items():
result[(a, b)] = value
return result | [
"def",
"uncurry_nested_dictionary",
"(",
"curried_dict",
")",
":",
"result",
"=",
"{",
"}",
"for",
"a",
",",
"a_dict",
"in",
"curried_dict",
".",
"items",
"(",
")",
":",
"for",
"b",
",",
"value",
"in",
"a_dict",
".",
"items",
"(",
")",
":",
"result",
... | Transform dictionary from (key_a -> key_b -> float) to
(key_a, key_b) -> float | [
"Transform",
"dictionary",
"from",
"(",
"key_a",
"-",
">",
"key_b",
"-",
">",
"float",
")",
"to",
"(",
"key_a",
"key_b",
")",
"-",
">",
"float"
] | python | train |
pdkit/pdkit | pdkit/utils.py | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/utils.py#L633-L660 | def smoothing_window(data, window=[1, 1, 1]):
""" This is a smoothing functionality so we can fix misclassifications.
It will run a sliding window of form [border, smoothing, border] on the
signal and if the border elements are the same it will change the
smooth elements to match the border... | [
"def",
"smoothing_window",
"(",
"data",
",",
"window",
"=",
"[",
"1",
",",
"1",
",",
"1",
"]",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"data",
")",
"-",
"sum",
"(",
"window",
")",
")",
":",
"start_window_from",
"=",
"i",
"start_wind... | This is a smoothing functionality so we can fix misclassifications.
It will run a sliding window of form [border, smoothing, border] on the
signal and if the border elements are the same it will change the
smooth elements to match the border. An example would be for a window
of [2, 1, 2... | [
"This",
"is",
"a",
"smoothing",
"functionality",
"so",
"we",
"can",
"fix",
"misclassifications",
".",
"It",
"will",
"run",
"a",
"sliding",
"window",
"of",
"form",
"[",
"border",
"smoothing",
"border",
"]",
"on",
"the",
"signal",
"and",
"if",
"the",
"border... | python | train |
quantopian/trading_calendars | trading_calendars/trading_calendar.py | https://github.com/quantopian/trading_calendars/blob/951711c82c8a2875c09e96e2979faaf8734fb4df/trading_calendars/trading_calendar.py#L465-L492 | def next_session_label(self, session_label):
"""
Given a session label, returns the label of the next session.
Parameters
----------
session_label: pd.Timestamp
A session whose next session is desired.
Returns
-------
pd.Timestamp
... | [
"def",
"next_session_label",
"(",
"self",
",",
"session_label",
")",
":",
"idx",
"=",
"self",
".",
"schedule",
".",
"index",
".",
"get_loc",
"(",
"session_label",
")",
"try",
":",
"return",
"self",
".",
"schedule",
".",
"index",
"[",
"idx",
"+",
"1",
"... | Given a session label, returns the label of the next session.
Parameters
----------
session_label: pd.Timestamp
A session whose next session is desired.
Returns
-------
pd.Timestamp
The next session label (midnight UTC).
Notes
--... | [
"Given",
"a",
"session",
"label",
"returns",
"the",
"label",
"of",
"the",
"next",
"session",
"."
] | python | train |
lambdamusic/Ontospy | ontospy/extras/hacks/click_example.py | https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/hacks/click_example.py#L37-L56 | def hello():
""""http://click.pocoo.org/5/
http://click.pocoo.org/5/api/
"""
click.clear()
click.secho('Hello World!', fg='green')
click.secho('Some more text', bg='blue', fg='white')
click.secho('ATTENTION', blink=True, bold=True)
click.echo('Continue? [yn] ', nl=False)
c = click.g... | [
"def",
"hello",
"(",
")",
":",
"click",
".",
"clear",
"(",
")",
"click",
".",
"secho",
"(",
"'Hello World!'",
",",
"fg",
"=",
"'green'",
")",
"click",
".",
"secho",
"(",
"'Some more text'",
",",
"bg",
"=",
"'blue'",
",",
"fg",
"=",
"'white'",
")",
... | http://click.pocoo.org/5/
http://click.pocoo.org/5/api/ | [
"http",
":",
"//",
"click",
".",
"pocoo",
".",
"org",
"/",
"5",
"/",
"http",
":",
"//",
"click",
".",
"pocoo",
".",
"org",
"/",
"5",
"/",
"api",
"/"
] | python | train |
Microsoft/botbuilder-python | libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_context.py | https://github.com/Microsoft/botbuilder-python/blob/274663dd91c811bae6ac4488915ba5880771b0a7/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_context.py#L202-L214 | async def replace_dialog(self, dialog_id: str, options: object = None) -> DialogTurnResult:
"""
Ends the active dialog and starts a new dialog in its place. This is particularly useful
for creating loops or redirecting to another dialog.
:param dialog_id: ID of the dialog to search for.
... | [
"async",
"def",
"replace_dialog",
"(",
"self",
",",
"dialog_id",
":",
"str",
",",
"options",
":",
"object",
"=",
"None",
")",
"->",
"DialogTurnResult",
":",
"# End the current dialog and giving the reason.",
"await",
"self",
".",
"end_active_dialog",
"(",
"DialogRea... | Ends the active dialog and starts a new dialog in its place. This is particularly useful
for creating loops or redirecting to another dialog.
:param dialog_id: ID of the dialog to search for.
:param options: (Optional) additional argument(s) to pass to the new dialog.
:return: | [
"Ends",
"the",
"active",
"dialog",
"and",
"starts",
"a",
"new",
"dialog",
"in",
"its",
"place",
".",
"This",
"is",
"particularly",
"useful",
"for",
"creating",
"loops",
"or",
"redirecting",
"to",
"another",
"dialog",
".",
":",
"param",
"dialog_id",
":",
"I... | python | test |
binux/pyspider | pyspider/libs/utils.py | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L316-L330 | def decode_unicode_obj(obj):
"""
Decode unicoded dict/list/tuple encoded by `unicode_obj`
"""
if isinstance(obj, dict):
r = {}
for k, v in iteritems(obj):
r[decode_unicode_string(k)] = decode_unicode_obj(v)
return r
elif isinstance(obj, six.string_types):
... | [
"def",
"decode_unicode_obj",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"r",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"obj",
")",
":",
"r",
"[",
"decode_unicode_string",
"(",
"k",
")",
"]",
"=... | Decode unicoded dict/list/tuple encoded by `unicode_obj` | [
"Decode",
"unicoded",
"dict",
"/",
"list",
"/",
"tuple",
"encoded",
"by",
"unicode_obj"
] | python | train |
AguaClara/aguaclara | aguaclara/research/environmental_processes_analysis.py | https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/research/environmental_processes_analysis.py#L58-L75 | def alpha1_carbonate(pH):
"""Calculate the fraction of total carbonates in bicarbonate form (HCO3-)
:param pH: pH of the system
:type pH: float
:return: Fraction of carbonates in bicarbonate form (HCO3-)
:rtype: float
:Examples:
>>> from aguaclara.research.environmental_processes_analysi... | [
"def",
"alpha1_carbonate",
"(",
"pH",
")",
":",
"alpha1_carbonate",
"=",
"1",
"/",
"(",
"(",
"invpH",
"(",
"pH",
")",
"/",
"K1_carbonate",
")",
"+",
"1",
"+",
"(",
"K2_carbonate",
"/",
"invpH",
"(",
"pH",
")",
")",
")",
"return",
"alpha1_carbonate"
] | Calculate the fraction of total carbonates in bicarbonate form (HCO3-)
:param pH: pH of the system
:type pH: float
:return: Fraction of carbonates in bicarbonate form (HCO3-)
:rtype: float
:Examples:
>>> from aguaclara.research.environmental_processes_analysis import alpha1_carbonate
>>>... | [
"Calculate",
"the",
"fraction",
"of",
"total",
"carbonates",
"in",
"bicarbonate",
"form",
"(",
"HCO3",
"-",
")"
] | python | train |
brutasse/graphite-api | graphite_api/functions.py | https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1789-L1828 | def areaBetween(requestContext, *seriesLists):
"""
Draws the vertical area in between the two series in seriesList. Useful for
visualizing a range such as the minimum and maximum latency for a service.
areaBetween expects **exactly one argument** that results in exactly two
series (see example belo... | [
"def",
"areaBetween",
"(",
"requestContext",
",",
"*",
"seriesLists",
")",
":",
"if",
"len",
"(",
"seriesLists",
")",
"==",
"1",
":",
"[",
"seriesLists",
"]",
"=",
"seriesLists",
"assert",
"len",
"(",
"seriesLists",
")",
"==",
"2",
",",
"(",
"\"areaBetwe... | Draws the vertical area in between the two series in seriesList. Useful for
visualizing a range such as the minimum and maximum latency for a service.
areaBetween expects **exactly one argument** that results in exactly two
series (see example below). The order of the lower and higher values
series doe... | [
"Draws",
"the",
"vertical",
"area",
"in",
"between",
"the",
"two",
"series",
"in",
"seriesList",
".",
"Useful",
"for",
"visualizing",
"a",
"range",
"such",
"as",
"the",
"minimum",
"and",
"maximum",
"latency",
"for",
"a",
"service",
"."
] | python | train |
gijzelaerr/python-snap7 | snap7/client.py | https://github.com/gijzelaerr/python-snap7/blob/a6db134c7a3a2ef187b9eca04669221d6fc634c3/snap7/client.py#L388-L397 | def get_connected(self):
"""
Returns the connection status
:returns: a boolean that indicates if connected.
"""
connected = c_int32()
result = self.library.Cli_GetConnected(self.pointer, byref(connected))
check_error(result, context="client")
return bool(... | [
"def",
"get_connected",
"(",
"self",
")",
":",
"connected",
"=",
"c_int32",
"(",
")",
"result",
"=",
"self",
".",
"library",
".",
"Cli_GetConnected",
"(",
"self",
".",
"pointer",
",",
"byref",
"(",
"connected",
")",
")",
"check_error",
"(",
"result",
","... | Returns the connection status
:returns: a boolean that indicates if connected. | [
"Returns",
"the",
"connection",
"status"
] | python | train |
myint/rstcheck | rstcheck.py | https://github.com/myint/rstcheck/blob/2f975906b75f3b88d501ef3b13d213815cf7079a/rstcheck.py#L447-L471 | def ignore_sphinx():
"""Register Sphinx directives and roles to ignore."""
(directives, roles) = _get_directives_and_roles_from_sphinx()
directives += [
'centered',
'include',
'deprecated',
'index',
'no-code-block',
'literalinclude',
'hlist',
... | [
"def",
"ignore_sphinx",
"(",
")",
":",
"(",
"directives",
",",
"roles",
")",
"=",
"_get_directives_and_roles_from_sphinx",
"(",
")",
"directives",
"+=",
"[",
"'centered'",
",",
"'include'",
",",
"'deprecated'",
",",
"'index'",
",",
"'no-code-block'",
",",
"'lite... | Register Sphinx directives and roles to ignore. | [
"Register",
"Sphinx",
"directives",
"and",
"roles",
"to",
"ignore",
"."
] | python | train |
jbeluch/xbmcswift2 | xbmcswift2/xbmcmixin.py | https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/xbmcmixin.py#L420-L434 | def end_of_directory(self, succeeded=True, update_listing=False,
cache_to_disc=True):
'''Wrapper for xbmcplugin.endOfDirectory. Records state in
self._end_of_directory.
Typically it is not necessary to call this method directly, as
calling :meth:`~xbmcswift2.Plu... | [
"def",
"end_of_directory",
"(",
"self",
",",
"succeeded",
"=",
"True",
",",
"update_listing",
"=",
"False",
",",
"cache_to_disc",
"=",
"True",
")",
":",
"self",
".",
"_update_listing",
"=",
"update_listing",
"if",
"not",
"self",
".",
"_end_of_directory",
":",
... | Wrapper for xbmcplugin.endOfDirectory. Records state in
self._end_of_directory.
Typically it is not necessary to call this method directly, as
calling :meth:`~xbmcswift2.Plugin.finish` will call this method. | [
"Wrapper",
"for",
"xbmcplugin",
".",
"endOfDirectory",
".",
"Records",
"state",
"in",
"self",
".",
"_end_of_directory",
"."
] | python | train |
limix/limix-core | limix_core/optimize/optimize_bfgs.py | https://github.com/limix/limix-core/blob/5c590b4d351409f83ca320844b4897ce92203814/limix_core/optimize/optimize_bfgs.py#L66-L142 | def opt_hyper(gpr,Ifilter=None,bounds=None,opts={},*args,**kw_args):
"""
optimize params
Input:
gpr: GP regression class
params0: dictionary filled with starting hyperparameters
opts: options for optimizer
"""
if 'gradcheck' in opts:
gradcheck = opts['gradcheck']
else:
... | [
"def",
"opt_hyper",
"(",
"gpr",
",",
"Ifilter",
"=",
"None",
",",
"bounds",
"=",
"None",
",",
"opts",
"=",
"{",
"}",
",",
"*",
"args",
",",
"*",
"*",
"kw_args",
")",
":",
"if",
"'gradcheck'",
"in",
"opts",
":",
"gradcheck",
"=",
"opts",
"[",
"'gr... | optimize params
Input:
gpr: GP regression class
params0: dictionary filled with starting hyperparameters
opts: options for optimizer | [
"optimize",
"params"
] | python | train |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/export.py | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/export.py#L265-L317 | def tsv(self, path, features, filtered=True, override=False):
"""Export the data of the current instance to a .tsv file
Parameters
----------
path: str
Path to a .tsv file. The ending .tsv is added automatically.
features: list of str
The features in the ... | [
"def",
"tsv",
"(",
"self",
",",
"path",
",",
"features",
",",
"filtered",
"=",
"True",
",",
"override",
"=",
"False",
")",
":",
"features",
"=",
"[",
"c",
".",
"lower",
"(",
")",
"for",
"c",
"in",
"features",
"]",
"path",
"=",
"pathlib",
".",
"Pa... | Export the data of the current instance to a .tsv file
Parameters
----------
path: str
Path to a .tsv file. The ending .tsv is added automatically.
features: list of str
The features in the resulting .tsv file. These are strings
that are defined in `d... | [
"Export",
"the",
"data",
"of",
"the",
"current",
"instance",
"to",
"a",
".",
"tsv",
"file"
] | python | train |
python-openxml/python-docx | docx/text/font.py | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/font.py#L397-L404 | def _get_bool_prop(self, name):
"""
Return the value of boolean child of `w:rPr` having *name*.
"""
rPr = self._element.rPr
if rPr is None:
return None
return rPr._get_bool_val(name) | [
"def",
"_get_bool_prop",
"(",
"self",
",",
"name",
")",
":",
"rPr",
"=",
"self",
".",
"_element",
".",
"rPr",
"if",
"rPr",
"is",
"None",
":",
"return",
"None",
"return",
"rPr",
".",
"_get_bool_val",
"(",
"name",
")"
] | Return the value of boolean child of `w:rPr` having *name*. | [
"Return",
"the",
"value",
"of",
"boolean",
"child",
"of",
"w",
":",
"rPr",
"having",
"*",
"name",
"*",
"."
] | python | train |
UCL-INGI/INGInious | inginious/frontend/pages/api/authentication.py | https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/api/authentication.py#L18-L25 | def API_GET(self): # pylint: disable=arguments-differ
"""
Returns {"authenticated": false} or {"authenticated": true, "username": "your_username"} (always 200 OK)
"""
if self.user_manager.session_logged_in():
return 200, {"authenticated": True, "username": self.user_mana... | [
"def",
"API_GET",
"(",
"self",
")",
":",
"# pylint: disable=arguments-differ",
"if",
"self",
".",
"user_manager",
".",
"session_logged_in",
"(",
")",
":",
"return",
"200",
",",
"{",
"\"authenticated\"",
":",
"True",
",",
"\"username\"",
":",
"self",
".",
"user... | Returns {"authenticated": false} or {"authenticated": true, "username": "your_username"} (always 200 OK) | [
"Returns",
"{",
"authenticated",
":",
"false",
"}",
"or",
"{",
"authenticated",
":",
"true",
"username",
":",
"your_username",
"}",
"(",
"always",
"200",
"OK",
")"
] | python | train |
foxx/python-helpful | helpful.py | https://github.com/foxx/python-helpful/blob/e31ad9bdf45051d8b9a0d1808d214e2293c3bbed/helpful.py#L196-L209 | def iter_ensure_instance(iterable, types):
"""
Iterate over object and check each item type
>>> iter_ensure_instance([1,2,3], [str])
Traceback (most recent call last):
TypeError:
>>> iter_ensure_instance([1,2,3], int)
>>> iter_ensure_instance(1, int)
Traceback (most recent call last):
... | [
"def",
"iter_ensure_instance",
"(",
"iterable",
",",
"types",
")",
":",
"ensure_instance",
"(",
"iterable",
",",
"Iterable",
")",
"[",
"ensure_instance",
"(",
"item",
",",
"types",
")",
"for",
"item",
"in",
"iterable",
"]"
] | Iterate over object and check each item type
>>> iter_ensure_instance([1,2,3], [str])
Traceback (most recent call last):
TypeError:
>>> iter_ensure_instance([1,2,3], int)
>>> iter_ensure_instance(1, int)
Traceback (most recent call last):
TypeError: | [
"Iterate",
"over",
"object",
"and",
"check",
"each",
"item",
"type"
] | python | train |
proycon/pynlpl | pynlpl/formats/folia.py | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L5514-L5520 | def annotation(self, type, set=None):
"""Will return a **single** annotation (even if there are multiple). Raises a ``NoSuchAnnotation`` exception if none was found"""
l = self.count(type,set,True,default_ignore_annotations)
if len(l) >= 1:
return l[0]
else:
raise... | [
"def",
"annotation",
"(",
"self",
",",
"type",
",",
"set",
"=",
"None",
")",
":",
"l",
"=",
"self",
".",
"count",
"(",
"type",
",",
"set",
",",
"True",
",",
"default_ignore_annotations",
")",
"if",
"len",
"(",
"l",
")",
">=",
"1",
":",
"return",
... | Will return a **single** annotation (even if there are multiple). Raises a ``NoSuchAnnotation`` exception if none was found | [
"Will",
"return",
"a",
"**",
"single",
"**",
"annotation",
"(",
"even",
"if",
"there",
"are",
"multiple",
")",
".",
"Raises",
"a",
"NoSuchAnnotation",
"exception",
"if",
"none",
"was",
"found"
] | python | train |
bitesofcode/projexui | projexui/widgets/xtreewidget/xtreewidgetitem.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidgetitem.py#L105-L123 | def adjustHeight(self, column):
"""
Adjusts the height for this item based on the columna and its text.
:param column | <int>
"""
tree = self.treeWidget()
if not tree:
return
w = tree.width()
if tree.verticalSc... | [
"def",
"adjustHeight",
"(",
"self",
",",
"column",
")",
":",
"tree",
"=",
"self",
".",
"treeWidget",
"(",
")",
"if",
"not",
"tree",
":",
"return",
"w",
"=",
"tree",
".",
"width",
"(",
")",
"if",
"tree",
".",
"verticalScrollBar",
"(",
")",
".",
"isV... | Adjusts the height for this item based on the columna and its text.
:param column | <int> | [
"Adjusts",
"the",
"height",
"for",
"this",
"item",
"based",
"on",
"the",
"columna",
"and",
"its",
"text",
".",
":",
"param",
"column",
"|",
"<int",
">"
] | python | train |
fermiPy/fermipy | fermipy/jobs/target_analysis.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_analysis.py#L107-L172 | def run_analysis(self, argv):
"""Run this analysis"""
args = self._parser.parse_args(argv)
if not HAVE_ST:
raise RuntimeError(
"Trying to run fermipy analysis, but don't have ST")
if is_null(args.skydirs):
skydir_dict = None
else:
... | [
"def",
"run_analysis",
"(",
"self",
",",
"argv",
")",
":",
"args",
"=",
"self",
".",
"_parser",
".",
"parse_args",
"(",
"argv",
")",
"if",
"not",
"HAVE_ST",
":",
"raise",
"RuntimeError",
"(",
"\"Trying to run fermipy analysis, but don't have ST\"",
")",
"if",
... | Run this analysis | [
"Run",
"this",
"analysis"
] | python | train |
Deathnerd/pyterp | pyterp/__init__.py | https://github.com/Deathnerd/pyterp/blob/baf2957263685f03873f368226f5752da4e51f08/pyterp/__init__.py#L179-L186 | def _output_current_byte(self):
"""
Prints out the ASCII value of the current byte
"""
if self.tape[self.pointer] is None:
print "{}".format(chr(0)),
else:
print "{}".format(chr(int(self.tape[self.pointer]))), | [
"def",
"_output_current_byte",
"(",
"self",
")",
":",
"if",
"self",
".",
"tape",
"[",
"self",
".",
"pointer",
"]",
"is",
"None",
":",
"print",
"\"{}\"",
".",
"format",
"(",
"chr",
"(",
"0",
")",
")",
",",
"else",
":",
"print",
"\"{}\"",
".",
"forma... | Prints out the ASCII value of the current byte | [
"Prints",
"out",
"the",
"ASCII",
"value",
"of",
"the",
"current",
"byte"
] | python | train |
openstack/python-scciclient | scciclient/irmc/viom/elcm.py | https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/viom/elcm.py#L919-L960 | def get_json(self):
"""Create JSON data for iSCSI target.
:returns: JSON data for iSCSI target as follows:
{
"DHCPUsage":{
},
"Name":{
},
"IPv4Address":{
},
"PortNumber":{
... | [
"def",
"get_json",
"(",
"self",
")",
":",
"json",
"=",
"{",
"'DHCPUsage'",
":",
"self",
".",
"dhcp_usage",
",",
"'AuthenticationMethod'",
":",
"self",
".",
"auth_method",
",",
"}",
"if",
"not",
"self",
".",
"dhcp_usage",
":",
"json",
"[",
"'Name'",
"]",
... | Create JSON data for iSCSI target.
:returns: JSON data for iSCSI target as follows:
{
"DHCPUsage":{
},
"Name":{
},
"IPv4Address":{
},
"PortNumber":{
},
"B... | [
"Create",
"JSON",
"data",
"for",
"iSCSI",
"target",
"."
] | python | train |
fake-name/ChromeController | ChromeController/Generator/Generated.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L3440-L3459 | def DOM_setOuterHTML(self, nodeId, outerHTML):
"""
Function path: DOM.setOuterHTML
Domain: DOM
Method name: setOuterHTML
Parameters:
Required arguments:
'nodeId' (type: NodeId) -> Id of the node to set markup for.
'outerHTML' (type: string) -> Outer HTML markup to set.
No return value.
... | [
"def",
"DOM_setOuterHTML",
"(",
"self",
",",
"nodeId",
",",
"outerHTML",
")",
":",
"assert",
"isinstance",
"(",
"outerHTML",
",",
"(",
"str",
",",
")",
")",
",",
"\"Argument 'outerHTML' must be of type '['str']'. Received type: '%s'\"",
"%",
"type",
"(",
"outerHTML"... | Function path: DOM.setOuterHTML
Domain: DOM
Method name: setOuterHTML
Parameters:
Required arguments:
'nodeId' (type: NodeId) -> Id of the node to set markup for.
'outerHTML' (type: string) -> Outer HTML markup to set.
No return value.
Description: Sets node HTML markup, returns new n... | [
"Function",
"path",
":",
"DOM",
".",
"setOuterHTML",
"Domain",
":",
"DOM",
"Method",
"name",
":",
"setOuterHTML",
"Parameters",
":",
"Required",
"arguments",
":",
"nodeId",
"(",
"type",
":",
"NodeId",
")",
"-",
">",
"Id",
"of",
"the",
"node",
"to",
"set"... | python | train |
Arubacloud/pyArubaCloud | ArubaCloud/ReverseDns/ReverseDns.py | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L23-L34 | def set(self, address, host_name):
"""
Assign one or more PTR record to a single IP Address
:type address: str
:type host_name: list[str]
:param address: (str) The IP address to configure
:param host_name: (list[str]) The list of strings representing PTR records
:... | [
"def",
"set",
"(",
"self",
",",
"address",
",",
"host_name",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"SetEnqueueSetReverseDns",
".",
"SetEnqueueSetReverseDns",
",",
"IP",
"=",
"address",
",",
"Hosts",
"=",
"host_name",
")",
"response",
"=",
"r... | Assign one or more PTR record to a single IP Address
:type address: str
:type host_name: list[str]
:param address: (str) The IP address to configure
:param host_name: (list[str]) The list of strings representing PTR records
:return: (bool) True in case of success, False in case o... | [
"Assign",
"one",
"or",
"more",
"PTR",
"record",
"to",
"a",
"single",
"IP",
"Address",
":",
"type",
"address",
":",
"str",
":",
"type",
"host_name",
":",
"list",
"[",
"str",
"]",
":",
"param",
"address",
":",
"(",
"str",
")",
"The",
"IP",
"address",
... | python | train |
fermiPy/fermipy | fermipy/diffuse/name_policy.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/name_policy.py#L200-L209 | def galprop_ringkey(self, **kwargs):
""" return the sourcekey for galprop input maps : specifies the component and ring
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
try:
return NameFactory.galprop... | [
"def",
"galprop_ringkey",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs_copy",
"=",
"self",
".",
"base_dict",
".",
"copy",
"(",
")",
"kwargs_copy",
".",
"update",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"_replace_none",
"(",
"kwargs_copy",
... | return the sourcekey for galprop input maps : specifies the component and ring | [
"return",
"the",
"sourcekey",
"for",
"galprop",
"input",
"maps",
":",
"specifies",
"the",
"component",
"and",
"ring"
] | python | train |
devassistant/devassistant | devassistant/dapi/dapicli.py | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L102-L111 | def _unpaginated(what):
'''Returns a dictionary with all <what>, unpaginated'''
page = data(what)
results = page['results']
count = page['count']
while page['next']:
page = data(page['next'])
results += page['results']
count += page['count']
return {'results': results, 'c... | [
"def",
"_unpaginated",
"(",
"what",
")",
":",
"page",
"=",
"data",
"(",
"what",
")",
"results",
"=",
"page",
"[",
"'results'",
"]",
"count",
"=",
"page",
"[",
"'count'",
"]",
"while",
"page",
"[",
"'next'",
"]",
":",
"page",
"=",
"data",
"(",
"page... | Returns a dictionary with all <what>, unpaginated | [
"Returns",
"a",
"dictionary",
"with",
"all",
"<what",
">",
"unpaginated"
] | python | train |
lesscpy/lesscpy | lesscpy/lessc/parser.py | https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/lessc/parser.py#L594-L601 | def p_ident_parts(self, p):
""" ident_parts : ident_part
| selector
| filter_group
"""
if not isinstance(p[1], list):
p[1] = [p[1]]
p[0] = p[1] | [
"def",
"p_ident_parts",
"(",
"self",
",",
"p",
")",
":",
"if",
"not",
"isinstance",
"(",
"p",
"[",
"1",
"]",
",",
"list",
")",
":",
"p",
"[",
"1",
"]",
"=",
"[",
"p",
"[",
"1",
"]",
"]",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]"
] | ident_parts : ident_part
| selector
| filter_group | [
"ident_parts",
":",
"ident_part",
"|",
"selector",
"|",
"filter_group"
] | python | valid |
saltstack/salt | salt/modules/git.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/git.py#L1722-L1785 | def describe(cwd,
rev='HEAD',
user=None,
password=None,
ignore_retcode=False,
output_encoding=None):
'''
Returns the `git-describe(1)`_ string (or the SHA1 hash if there are no
tags) for the given revision.
cwd
The path to the git... | [
"def",
"describe",
"(",
"cwd",
",",
"rev",
"=",
"'HEAD'",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"ignore_retcode",
"=",
"False",
",",
"output_encoding",
"=",
"None",
")",
":",
"cwd",
"=",
"_expand_path",
"(",
"cwd",
",",
"user",
... | Returns the `git-describe(1)`_ string (or the SHA1 hash if there are no
tags) for the given revision.
cwd
The path to the git checkout
rev : HEAD
The revision to describe
user
User under which to run the git command. By default, the command is run
by the user under whi... | [
"Returns",
"the",
"git",
"-",
"describe",
"(",
"1",
")",
"_",
"string",
"(",
"or",
"the",
"SHA1",
"hash",
"if",
"there",
"are",
"no",
"tags",
")",
"for",
"the",
"given",
"revision",
"."
] | python | train |
SoCo/SoCo | soco/discovery.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/discovery.py#L188-L213 | def any_soco():
"""Return any visible soco device, for when it doesn't matter which.
Try to obtain an existing instance, or use `discover` if necessary.
Note that this assumes that the existing instance has not left
the network.
Returns:
SoCo: A `SoCo` instance (or subclass if `config.SOCO... | [
"def",
"any_soco",
"(",
")",
":",
"cls",
"=",
"config",
".",
"SOCO_CLASS",
"# pylint: disable=no-member, protected-access",
"try",
":",
"# Try to get the first pre-existing soco instance we know about,",
"# as long as it is visible (i.e. not a bridge etc). Otherwise,",
"# perform disco... | Return any visible soco device, for when it doesn't matter which.
Try to obtain an existing instance, or use `discover` if necessary.
Note that this assumes that the existing instance has not left
the network.
Returns:
SoCo: A `SoCo` instance (or subclass if `config.SOCO_CLASS` is set,
... | [
"Return",
"any",
"visible",
"soco",
"device",
"for",
"when",
"it",
"doesn",
"t",
"matter",
"which",
"."
] | python | train |
klen/muffin-peewee | muffin_peewee/mpeewee.py | https://github.com/klen/muffin-peewee/blob/8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e/muffin_peewee/mpeewee.py#L128-L144 | async def async_connect(self):
"""Asyncronously wait for a connection from the pool."""
if self._waiters is None:
raise Exception('Error, database not properly initialized before async connection')
if self._waiters or self.max_connections and (len(self._in_use) >= self.max_connectio... | [
"async",
"def",
"async_connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"_waiters",
"is",
"None",
":",
"raise",
"Exception",
"(",
"'Error, database not properly initialized before async connection'",
")",
"if",
"self",
".",
"_waiters",
"or",
"self",
".",
"max_c... | Asyncronously wait for a connection from the pool. | [
"Asyncronously",
"wait",
"for",
"a",
"connection",
"from",
"the",
"pool",
"."
] | python | valid |
elastic/apm-agent-python | setup.py | https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/setup.py#L88-L99 | def get_version():
"""
Get version without importing from elasticapm. This avoids any side effects
from importing while installing and/or building the module
:return: a string, indicating the version
"""
version_file = open(os.path.join("elasticapm", "version.py"), encoding="utf-8")
for line... | [
"def",
"get_version",
"(",
")",
":",
"version_file",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"\"elasticapm\"",
",",
"\"version.py\"",
")",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"for",
"line",
"in",
"version_file",
":",
"if",
"line",
".",... | Get version without importing from elasticapm. This avoids any side effects
from importing while installing and/or building the module
:return: a string, indicating the version | [
"Get",
"version",
"without",
"importing",
"from",
"elasticapm",
".",
"This",
"avoids",
"any",
"side",
"effects",
"from",
"importing",
"while",
"installing",
"and",
"/",
"or",
"building",
"the",
"module",
":",
"return",
":",
"a",
"string",
"indicating",
"the",
... | python | train |
roclark/sportsreference | sportsreference/mlb/schedule.py | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/schedule.py#L172-L179 | def datetime(self):
"""
Returns a datetime object of the month, day, year, and time the game
was played.
"""
date_string = '%s %s' % (self._date, self._year)
date_string = re.sub(r' \(\d+\)', '', date_string)
return datetime.strptime(date_string, '%A, %b %d %Y') | [
"def",
"datetime",
"(",
"self",
")",
":",
"date_string",
"=",
"'%s %s'",
"%",
"(",
"self",
".",
"_date",
",",
"self",
".",
"_year",
")",
"date_string",
"=",
"re",
".",
"sub",
"(",
"r' \\(\\d+\\)'",
",",
"''",
",",
"date_string",
")",
"return",
"datetim... | Returns a datetime object of the month, day, year, and time the game
was played. | [
"Returns",
"a",
"datetime",
"object",
"of",
"the",
"month",
"day",
"year",
"and",
"time",
"the",
"game",
"was",
"played",
"."
] | python | train |
chaoss/grimoirelab-sortinghat | sortinghat/api.py | https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/api.py#L884-L939 | def search_unique_identities_slice(db, term, offset, limit):
"""Look for unique identities using slicing.
This function returns those unique identities which match with the
given `term`. The term will be compared with name, email, username
and source values of each identity. When an empty term is given... | [
"def",
"search_unique_identities_slice",
"(",
"db",
",",
"term",
",",
"offset",
",",
"limit",
")",
":",
"uidentities",
"=",
"[",
"]",
"pattern",
"=",
"'%'",
"+",
"term",
"+",
"'%'",
"if",
"term",
"else",
"None",
"if",
"offset",
"<",
"0",
":",
"raise",
... | Look for unique identities using slicing.
This function returns those unique identities which match with the
given `term`. The term will be compared with name, email, username
and source values of each identity. When an empty term is given,
all unique identities will be returned. The results are limite... | [
"Look",
"for",
"unique",
"identities",
"using",
"slicing",
"."
] | python | train |
mattjj/pyslds | pyslds/states.py | https://github.com/mattjj/pyslds/blob/c505c2bd05a5549d450b518f02493b68ed12e590/pyslds/states.py#L366-L407 | def _set_gaussian_expected_stats(self, smoothed_mus, smoothed_sigmas, E_xtp1_xtT):
"""
Both meanfield and VBEM require expected statistics of the continuous latent
states, x. This is a helper function to take E[x_t], E[x_t x_t^T] and E[x_{t+1}, x_t^T]
and compute the expected sufficient... | [
"def",
"_set_gaussian_expected_stats",
"(",
"self",
",",
"smoothed_mus",
",",
"smoothed_sigmas",
",",
"E_xtp1_xtT",
")",
":",
"assert",
"not",
"np",
".",
"isnan",
"(",
"E_xtp1_xtT",
")",
".",
"any",
"(",
")",
"assert",
"not",
"np",
".",
"isnan",
"(",
"smoo... | Both meanfield and VBEM require expected statistics of the continuous latent
states, x. This is a helper function to take E[x_t], E[x_t x_t^T] and E[x_{t+1}, x_t^T]
and compute the expected sufficient statistics for the initial distribution,
dynamics distribution, and Gaussian observation distr... | [
"Both",
"meanfield",
"and",
"VBEM",
"require",
"expected",
"statistics",
"of",
"the",
"continuous",
"latent",
"states",
"x",
".",
"This",
"is",
"a",
"helper",
"function",
"to",
"take",
"E",
"[",
"x_t",
"]",
"E",
"[",
"x_t",
"x_t^T",
"]",
"and",
"E",
"[... | python | train |
inveniosoftware-contrib/record-recommender | record_recommender/profiles.py | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/profiles.py#L129-L139 | def count_records(self, record_counter, file):
"""Count the number of viewed records."""
counter = record_counter
events_counter = 0
for record in file.get_records():
recid = record[2]
counter[recid] = counter.get(recid, 0) + 1
events_counter += 1
... | [
"def",
"count_records",
"(",
"self",
",",
"record_counter",
",",
"file",
")",
":",
"counter",
"=",
"record_counter",
"events_counter",
"=",
"0",
"for",
"record",
"in",
"file",
".",
"get_records",
"(",
")",
":",
"recid",
"=",
"record",
"[",
"2",
"]",
"cou... | Count the number of viewed records. | [
"Count",
"the",
"number",
"of",
"viewed",
"records",
"."
] | python | train |
priestc/giotto | giotto/contrib/static/programs.py | https://github.com/priestc/giotto/blob/d4c26380caefa7745bb27135e315de830f7254d3/giotto/contrib/static/programs.py#L24-L41 | def StaticServe(base_path='/views/static/'):
"""
Meta program for serving any file based on the path
"""
def get_file(path=RAW_INVOCATION_ARGS):
fullpath = get_config('project_path') + os.path.join(base_path, path)
try:
mime, encoding = mimetypes.guess_type(fullpath)
... | [
"def",
"StaticServe",
"(",
"base_path",
"=",
"'/views/static/'",
")",
":",
"def",
"get_file",
"(",
"path",
"=",
"RAW_INVOCATION_ARGS",
")",
":",
"fullpath",
"=",
"get_config",
"(",
"'project_path'",
")",
"+",
"os",
".",
"path",
".",
"join",
"(",
"base_path",... | Meta program for serving any file based on the path | [
"Meta",
"program",
"for",
"serving",
"any",
"file",
"based",
"on",
"the",
"path"
] | python | train |
greenape/mktheapidocs | mktheapidocs/mkapi.py | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L360-L381 | def summary(doc):
"""
Generate markdown for summary section.
Parameters
----------
doc : dict
Output from numpydoc
Returns
-------
list of str
Markdown strings
"""
lines = []
if "Summary" in doc and len(doc["Summary"]) > 0:
lines.append(fix_footnotes... | [
"def",
"summary",
"(",
"doc",
")",
":",
"lines",
"=",
"[",
"]",
"if",
"\"Summary\"",
"in",
"doc",
"and",
"len",
"(",
"doc",
"[",
"\"Summary\"",
"]",
")",
">",
"0",
":",
"lines",
".",
"append",
"(",
"fix_footnotes",
"(",
"\" \"",
".",
"join",
"(",
... | Generate markdown for summary section.
Parameters
----------
doc : dict
Output from numpydoc
Returns
-------
list of str
Markdown strings | [
"Generate",
"markdown",
"for",
"summary",
"section",
"."
] | python | train |
justquick/django-activity-stream | actstream/managers.py | https://github.com/justquick/django-activity-stream/blob/a1e06f2e6429cc5fc321e7801440dd7c5b9d5a35/actstream/managers.py#L145-L155 | def is_following(self, user, instance, flag=''):
"""
Check if a user is following an instance.
"""
if not user or user.is_anonymous:
return False
queryset = self.for_object(instance)
if flag:
queryset = queryset.filter(flag=flag)
return qu... | [
"def",
"is_following",
"(",
"self",
",",
"user",
",",
"instance",
",",
"flag",
"=",
"''",
")",
":",
"if",
"not",
"user",
"or",
"user",
".",
"is_anonymous",
":",
"return",
"False",
"queryset",
"=",
"self",
".",
"for_object",
"(",
"instance",
")",
"if",
... | Check if a user is following an instance. | [
"Check",
"if",
"a",
"user",
"is",
"following",
"an",
"instance",
"."
] | python | train |
Chilipp/model-organization | model_organization/__init__.py | https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L159-L204 | def start(self, **kwargs):
"""
Start the commands of this organizer
Parameters
----------
``**kwargs``
Any keyword from the :attr:`commands` or :attr:`parser_commands`
attribute
Returns
-------
argparse.Namespace
The n... | [
"def",
"start",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"ts",
"=",
"{",
"}",
"ret",
"=",
"{",
"}",
"info_parts",
"=",
"{",
"'info'",
",",
"'get-value'",
",",
"'get_value'",
"}",
"for",
"cmd",
"in",
"self",
".",
"commands",
":",
"parser_cmd"... | Start the commands of this organizer
Parameters
----------
``**kwargs``
Any keyword from the :attr:`commands` or :attr:`parser_commands`
attribute
Returns
-------
argparse.Namespace
The namespace with the commands as given in ``**kwar... | [
"Start",
"the",
"commands",
"of",
"this",
"organizer"
] | python | train |
timkpaine/pyEX | pyEX/stocks.py | https://github.com/timkpaine/pyEX/blob/91cf751dafdb208a0c8b5377945e5808b99f94ba/pyEX/stocks.py#L256-L272 | def bookDF(symbol, token='', version=''):
'''Book data
https://iextrading.com/developer/docs/#book
realtime during Investors Exchange market hours
Args:
symbol (string); Ticker to request
token (string); Access token
version (string); API version
Returns:
DataFrame... | [
"def",
"bookDF",
"(",
"symbol",
",",
"token",
"=",
"''",
",",
"version",
"=",
"''",
")",
":",
"x",
"=",
"book",
"(",
"symbol",
",",
"token",
",",
"version",
")",
"df",
"=",
"_bookToDF",
"(",
"x",
")",
"return",
"df"
] | Book data
https://iextrading.com/developer/docs/#book
realtime during Investors Exchange market hours
Args:
symbol (string); Ticker to request
token (string); Access token
version (string); API version
Returns:
DataFrame: result | [
"Book",
"data"
] | python | valid |
acsone/git-aggregator | git_aggregator/repo.py | https://github.com/acsone/git-aggregator/blob/8631b0e64f9e8ce1857b21adeddb890ebd8469a6/git_aggregator/repo.py#L359-L365 | def show_closed_prs(self):
"""Log only closed PRs."""
all_prs = self.collect_prs_info()
for pr_info in all_prs.get('closed', []):
logger.info(
'{url} in state {state} ({merged})'.format(**pr_info)
) | [
"def",
"show_closed_prs",
"(",
"self",
")",
":",
"all_prs",
"=",
"self",
".",
"collect_prs_info",
"(",
")",
"for",
"pr_info",
"in",
"all_prs",
".",
"get",
"(",
"'closed'",
",",
"[",
"]",
")",
":",
"logger",
".",
"info",
"(",
"'{url} in state {state} ({merg... | Log only closed PRs. | [
"Log",
"only",
"closed",
"PRs",
"."
] | python | train |
Aula13/poloniex | poloniex/poloniex.py | https://github.com/Aula13/poloniex/blob/a5bfc91e766e220bf77f5e3a1b131f095913e714/poloniex/poloniex.py#L250-L266 | def buy(self, currencyPair, rate, amount, fillOrKill=None,
immediateOrCancel=None, postOnly=None):
"""Places a limit buy order in a given market. Required POST parameters
are "currencyPair", "rate", and "amount". If successful, the method
will return the order number.
You may... | [
"def",
"buy",
"(",
"self",
",",
"currencyPair",
",",
"rate",
",",
"amount",
",",
"fillOrKill",
"=",
"None",
",",
"immediateOrCancel",
"=",
"None",
",",
"postOnly",
"=",
"None",
")",
":",
"return",
"self",
".",
"_private",
"(",
"'buy'",
",",
"currencyPair... | Places a limit buy order in a given market. Required POST parameters
are "currencyPair", "rate", and "amount". If successful, the method
will return the order number.
You may optionally set "fillOrKill", "immediateOrCancel", "postOnly"
to 1. A fill-or-kill order will either fill in its e... | [
"Places",
"a",
"limit",
"buy",
"order",
"in",
"a",
"given",
"market",
".",
"Required",
"POST",
"parameters",
"are",
"currencyPair",
"rate",
"and",
"amount",
".",
"If",
"successful",
"the",
"method",
"will",
"return",
"the",
"order",
"number",
".",
"You",
"... | python | train |
ministryofjustice/money-to-prisoners-common | mtp_common/forms/__init__.py | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/forms/__init__.py#L6-L27 | def replace_default_error_messages():
"""
Replace Django's generic error messages with MTP-specific versions
NB: avoid trailing full stops visually, they are added for screen readers in templates
"""
forms.Field.default_error_messages['required'] = _('This field is required')
forms.CharField.def... | [
"def",
"replace_default_error_messages",
"(",
")",
":",
"forms",
".",
"Field",
".",
"default_error_messages",
"[",
"'required'",
"]",
"=",
"_",
"(",
"'This field is required'",
")",
"forms",
".",
"CharField",
".",
"default_error_messages",
"[",
"'min_length'",
"]",
... | Replace Django's generic error messages with MTP-specific versions
NB: avoid trailing full stops visually, they are added for screen readers in templates | [
"Replace",
"Django",
"s",
"generic",
"error",
"messages",
"with",
"MTP",
"-",
"specific",
"versions",
"NB",
":",
"avoid",
"trailing",
"full",
"stops",
"visually",
"they",
"are",
"added",
"for",
"screen",
"readers",
"in",
"templates"
] | python | train |
devopshq/artifactory | artifactory.py | https://github.com/devopshq/artifactory/blob/b9ec08cd72527d7d43159fe45c3a98a0b0838534/artifactory.py#L1280-L1288 | def move(self, dst):
"""
Move artifact from this path to destinaiton.
"""
if self.drive != dst.drive:
raise NotImplementedError(
"Moving between instances is not implemented yet")
self._accessor.move(self, dst) | [
"def",
"move",
"(",
"self",
",",
"dst",
")",
":",
"if",
"self",
".",
"drive",
"!=",
"dst",
".",
"drive",
":",
"raise",
"NotImplementedError",
"(",
"\"Moving between instances is not implemented yet\"",
")",
"self",
".",
"_accessor",
".",
"move",
"(",
"self",
... | Move artifact from this path to destinaiton. | [
"Move",
"artifact",
"from",
"this",
"path",
"to",
"destinaiton",
"."
] | python | train |
jreese/aiosqlite | aiosqlite/core.py | https://github.com/jreese/aiosqlite/blob/3f548b568b8db9a57022b6e2c9627f5cdefb983f/aiosqlite/core.py#L64-L69 | async def fetchmany(self, size: int = None) -> Iterable[sqlite3.Row]:
"""Fetch up to `cursor.arraysize` number of rows."""
args = () # type: Tuple[int, ...]
if size is not None:
args = (size,)
return await self._execute(self._cursor.fetchmany, *args) | [
"async",
"def",
"fetchmany",
"(",
"self",
",",
"size",
":",
"int",
"=",
"None",
")",
"->",
"Iterable",
"[",
"sqlite3",
".",
"Row",
"]",
":",
"args",
"=",
"(",
")",
"# type: Tuple[int, ...]",
"if",
"size",
"is",
"not",
"None",
":",
"args",
"=",
"(",
... | Fetch up to `cursor.arraysize` number of rows. | [
"Fetch",
"up",
"to",
"cursor",
".",
"arraysize",
"number",
"of",
"rows",
"."
] | python | train |
markovmodel/PyEMMA | pyemma/coordinates/transform/nystroem_tica.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/transform/nystroem_tica.py#L604-L643 | def approximate_eig(self, epsilon=1e-6):
""" Compute low-rank approximation of the eigenvalue decomposition of target matrix.
If spd is True, the decomposition will be conducted while ensuring that the spectrum of `A_k^{-1}` is positive.
Parameters
----------
epsilon : float, o... | [
"def",
"approximate_eig",
"(",
"self",
",",
"epsilon",
"=",
"1e-6",
")",
":",
"L",
"=",
"self",
".",
"approximate_cholesky",
"(",
"epsilon",
"=",
"epsilon",
")",
"LL",
"=",
"np",
".",
"dot",
"(",
"L",
".",
"T",
",",
"L",
")",
"s",
",",
"V",
"=",
... | Compute low-rank approximation of the eigenvalue decomposition of target matrix.
If spd is True, the decomposition will be conducted while ensuring that the spectrum of `A_k^{-1}` is positive.
Parameters
----------
epsilon : float, optional, default 1e-6
Cutoff for eigenval... | [
"Compute",
"low",
"-",
"rank",
"approximation",
"of",
"the",
"eigenvalue",
"decomposition",
"of",
"target",
"matrix",
"."
] | python | train |
greenbone/ospd | ospd/misc.py | https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L365-L375 | def inet_pton(address_family, ip_string):
""" A platform independent version of inet_pton """
global __inet_pton
if __inet_pton is None:
if hasattr(socket, 'inet_pton'):
__inet_pton = socket.inet_pton
else:
from ospd import win_socket
__inet_pton = win_soc... | [
"def",
"inet_pton",
"(",
"address_family",
",",
"ip_string",
")",
":",
"global",
"__inet_pton",
"if",
"__inet_pton",
"is",
"None",
":",
"if",
"hasattr",
"(",
"socket",
",",
"'inet_pton'",
")",
":",
"__inet_pton",
"=",
"socket",
".",
"inet_pton",
"else",
":",... | A platform independent version of inet_pton | [
"A",
"platform",
"independent",
"version",
"of",
"inet_pton"
] | python | train |
csparpa/pyowm | pyowm/alertapi30/trigger.py | https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/alertapi30/trigger.py#L93-L107 | def get_alerts_on(self, weather_param):
"""
Returns all the `Alert` objects of this `Trigger` that refer to the specified weather parameter (eg. 'temp',
'pressure', etc.). The allowed weather params are the ones enumerated by class
`pyowm.alertapi30.enums.WeatherParametersEnum`
:... | [
"def",
"get_alerts_on",
"(",
"self",
",",
"weather_param",
")",
":",
"result",
"=",
"[",
"]",
"for",
"alert",
"in",
"self",
".",
"alerts",
":",
"for",
"met_condition",
"in",
"alert",
".",
"met_conditions",
":",
"if",
"met_condition",
"[",
"'condition'",
"]... | Returns all the `Alert` objects of this `Trigger` that refer to the specified weather parameter (eg. 'temp',
'pressure', etc.). The allowed weather params are the ones enumerated by class
`pyowm.alertapi30.enums.WeatherParametersEnum`
:param weather_param: str, values in `pyowm.alertapi30.enums.... | [
"Returns",
"all",
"the",
"Alert",
"objects",
"of",
"this",
"Trigger",
"that",
"refer",
"to",
"the",
"specified",
"weather",
"parameter",
"(",
"eg",
".",
"temp",
"pressure",
"etc",
".",
")",
".",
"The",
"allowed",
"weather",
"params",
"are",
"the",
"ones",
... | python | train |
fabioz/PyDev.Debugger | _pydev_bundle/pydev_versioncheck.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/pydev_versioncheck.py#L3-L15 | def versionok_for_gui():
''' Return True if running Python is suitable for GUI Event Integration and deeper IPython integration '''
# We require Python 2.6+ ...
if sys.hexversion < 0x02060000:
return False
# Or Python 3.2+
if sys.hexversion >= 0x03000000 and sys.hexversion < 0x03020000:
... | [
"def",
"versionok_for_gui",
"(",
")",
":",
"# We require Python 2.6+ ...",
"if",
"sys",
".",
"hexversion",
"<",
"0x02060000",
":",
"return",
"False",
"# Or Python 3.2+",
"if",
"sys",
".",
"hexversion",
">=",
"0x03000000",
"and",
"sys",
".",
"hexversion",
"<",
"0... | Return True if running Python is suitable for GUI Event Integration and deeper IPython integration | [
"Return",
"True",
"if",
"running",
"Python",
"is",
"suitable",
"for",
"GUI",
"Event",
"Integration",
"and",
"deeper",
"IPython",
"integration"
] | python | train |
mardix/Mocha | mocha/extras/md.py | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/extras/md.py#L90-L99 | def toc(text):
"""
Return a table of context list
:param text:
:return:
"""
extensions = ['markdown.extensions.toc']
mkd = markdown.Markdown(extensions=extensions)
html = mkd.convert(text)
return mkd.toc | [
"def",
"toc",
"(",
"text",
")",
":",
"extensions",
"=",
"[",
"'markdown.extensions.toc'",
"]",
"mkd",
"=",
"markdown",
".",
"Markdown",
"(",
"extensions",
"=",
"extensions",
")",
"html",
"=",
"mkd",
".",
"convert",
"(",
"text",
")",
"return",
"mkd",
".",... | Return a table of context list
:param text:
:return: | [
"Return",
"a",
"table",
"of",
"context",
"list",
":",
"param",
"text",
":",
":",
"return",
":"
] | python | train |
vtkiorg/vtki | vtki/renderer.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L433-L439 | def remove_bounding_box(self):
""" Removes bounding box """
if hasattr(self, '_box_object'):
actor = self.bounding_box_actor
self.bounding_box_actor = None
del self._box_object
self.remove_actor(actor, reset_camera=False) | [
"def",
"remove_bounding_box",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_box_object'",
")",
":",
"actor",
"=",
"self",
".",
"bounding_box_actor",
"self",
".",
"bounding_box_actor",
"=",
"None",
"del",
"self",
".",
"_box_object",
"self",
"."... | Removes bounding box | [
"Removes",
"bounding",
"box"
] | python | train |
nikcub/floyd | floyd/util/dateformat.py | https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/dateformat.py#L111-L120 | def f(self):
"""
Time, in 12-hour hours and minutes, with minutes left off if they're
zero.
Examples: '1', '1:30', '2:05', '2'
Proprietary extension.
"""
if self.data.minute == 0:
return self.g()
return u'%s:%s' % (self.g(), self.i()) | [
"def",
"f",
"(",
"self",
")",
":",
"if",
"self",
".",
"data",
".",
"minute",
"==",
"0",
":",
"return",
"self",
".",
"g",
"(",
")",
"return",
"u'%s:%s'",
"%",
"(",
"self",
".",
"g",
"(",
")",
",",
"self",
".",
"i",
"(",
")",
")"
] | Time, in 12-hour hours and minutes, with minutes left off if they're
zero.
Examples: '1', '1:30', '2:05', '2'
Proprietary extension. | [
"Time",
"in",
"12",
"-",
"hour",
"hours",
"and",
"minutes",
"with",
"minutes",
"left",
"off",
"if",
"they",
"re",
"zero",
".",
"Examples",
":",
"1",
"1",
":",
"30",
"2",
":",
"05",
"2",
"Proprietary",
"extension",
"."
] | python | train |
ewiger/mlab | src/mlab/awmstools.py | https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L1864-L1874 | def argmin(iterable, key=None, both=False):
"""See `argmax`.
"""
if key is not None:
it = imap(key, iterable)
else:
it = iter(iterable)
score, argmin = reduce(min, izip(it, count()))
if both:
return argmin, score
return argmin | [
"def",
"argmin",
"(",
"iterable",
",",
"key",
"=",
"None",
",",
"both",
"=",
"False",
")",
":",
"if",
"key",
"is",
"not",
"None",
":",
"it",
"=",
"imap",
"(",
"key",
",",
"iterable",
")",
"else",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"s... | See `argmax`. | [
"See",
"argmax",
"."
] | python | train |
Scoppio/RagnarokEngine3 | RagnarokEngine3/RE3.py | https://github.com/Scoppio/RagnarokEngine3/blob/4395d419ccd64fe9327c41f200b72ee0176ad896/RagnarokEngine3/RE3.py#L3166-L3177 | def find_obj_by_tag(self, tag):
"""Search through all the objects in the world and
return the first instance whose tag matches the specified string."""
for obj in self.__up_objects:
if obj.tag == tag:
return obj
for obj in self.__draw_objects:
if ... | [
"def",
"find_obj_by_tag",
"(",
"self",
",",
"tag",
")",
":",
"for",
"obj",
"in",
"self",
".",
"__up_objects",
":",
"if",
"obj",
".",
"tag",
"==",
"tag",
":",
"return",
"obj",
"for",
"obj",
"in",
"self",
".",
"__draw_objects",
":",
"if",
"obj",
".",
... | Search through all the objects in the world and
return the first instance whose tag matches the specified string. | [
"Search",
"through",
"all",
"the",
"objects",
"in",
"the",
"world",
"and",
"return",
"the",
"first",
"instance",
"whose",
"tag",
"matches",
"the",
"specified",
"string",
"."
] | python | train |
SMTG-UCL/sumo | sumo/cli/dosplot.py | https://github.com/SMTG-UCL/sumo/blob/47aec6bbfa033a624435a65bd4edabd18bfb437f/sumo/cli/dosplot.py#L40-L184 | def dosplot(filename=None, prefix=None, directory=None, elements=None,
lm_orbitals=None, atoms=None, subplot=False, shift=True,
total_only=False, plot_total=True, legend_on=True,
legend_frame_on=False, legend_cutoff=3., gaussian=None, height=6.,
width=8., xmin=-6., xmax=6... | [
"def",
"dosplot",
"(",
"filename",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"directory",
"=",
"None",
",",
"elements",
"=",
"None",
",",
"lm_orbitals",
"=",
"None",
",",
"atoms",
"=",
"None",
",",
"subplot",
"=",
"False",
",",
"shift",
"=",
"Tru... | A script to plot the density of states from a vasprun.xml file.
Args:
filename (:obj:`str`, optional): Path to a vasprun.xml file (can be
gzipped).
prefix (:obj:`str`, optional): Prefix for file names.
directory (:obj:`str`, optional): The directory in which to save files.
... | [
"A",
"script",
"to",
"plot",
"the",
"density",
"of",
"states",
"from",
"a",
"vasprun",
".",
"xml",
"file",
"."
] | python | train |
saltstack/salt | salt/proxy/bluecoat_sslv.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/bluecoat_sslv.py#L170-L198 | def logon():
'''
Logs into the bluecoat_sslv device and returns the session cookies.
'''
session = requests.session()
payload = {"jsonrpc": "2.0",
"id": "ID0",
"method": "login",
"params": [DETAILS['username'], DETAILS['password'], DETAILS['auth'], True]
... | [
"def",
"logon",
"(",
")",
":",
"session",
"=",
"requests",
".",
"session",
"(",
")",
"payload",
"=",
"{",
"\"jsonrpc\"",
":",
"\"2.0\"",
",",
"\"id\"",
":",
"\"ID0\"",
",",
"\"method\"",
":",
"\"login\"",
",",
"\"params\"",
":",
"[",
"DETAILS",
"[",
"'... | Logs into the bluecoat_sslv device and returns the session cookies. | [
"Logs",
"into",
"the",
"bluecoat_sslv",
"device",
"and",
"returns",
"the",
"session",
"cookies",
"."
] | python | train |
PyCQA/astroid | astroid/scoped_nodes.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/scoped_nodes.py#L1917-L1927 | def implicit_locals(self):
"""Get implicitly defined class definition locals.
:returns: the the name and Const pair for each local
:rtype: tuple(tuple(str, node_classes.Const), ...)
"""
locals_ = (("__module__", self.special_attributes.attr___module__),)
if sys.version_i... | [
"def",
"implicit_locals",
"(",
"self",
")",
":",
"locals_",
"=",
"(",
"(",
"\"__module__\"",
",",
"self",
".",
"special_attributes",
".",
"attr___module__",
")",
",",
")",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"3",
")",
":",
"# __qualnam... | Get implicitly defined class definition locals.
:returns: the the name and Const pair for each local
:rtype: tuple(tuple(str, node_classes.Const), ...) | [
"Get",
"implicitly",
"defined",
"class",
"definition",
"locals",
"."
] | python | train |
fishtown-analytics/dbt | core/dbt/task/runnable.py | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/task/runnable.py#L347-L366 | def decode_sql(self, sql):
"""Base64 decode a string. This should only be used for sql in calls.
:param str sql: The base64 encoded form of the original utf-8 string
:return str: The decoded utf-8 string
"""
# JSON is defined as using "unicode", we'll go a step further and
... | [
"def",
"decode_sql",
"(",
"self",
",",
"sql",
")",
":",
"# JSON is defined as using \"unicode\", we'll go a step further and",
"# mandate utf-8 (though for the base64 part, it doesn't really matter!)",
"base64_sql_bytes",
"=",
"to_unicode",
"(",
"sql",
")",
".",
"encode",
"(",
... | Base64 decode a string. This should only be used for sql in calls.
:param str sql: The base64 encoded form of the original utf-8 string
:return str: The decoded utf-8 string | [
"Base64",
"decode",
"a",
"string",
".",
"This",
"should",
"only",
"be",
"used",
"for",
"sql",
"in",
"calls",
"."
] | python | train |
Erotemic/utool | utool/util_list.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2459-L2470 | def depth(sequence, func=max, _depth=0):
"""
Find the nesting depth of a nested sequence
"""
if isinstance(sequence, dict):
sequence = list(sequence.values())
depth_list = [depth(item, func=func, _depth=_depth + 1)
for item in sequence if (isinstance(item, dict) or util_typ... | [
"def",
"depth",
"(",
"sequence",
",",
"func",
"=",
"max",
",",
"_depth",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"sequence",
",",
"dict",
")",
":",
"sequence",
"=",
"list",
"(",
"sequence",
".",
"values",
"(",
")",
")",
"depth_list",
"=",
"[",... | Find the nesting depth of a nested sequence | [
"Find",
"the",
"nesting",
"depth",
"of",
"a",
"nested",
"sequence"
] | python | train |
tgalal/python-axolotl | axolotl/sessionbuilder.py | https://github.com/tgalal/python-axolotl/blob/0c681af4b756f556e23a9bf961abfbc6f82800cc/axolotl/sessionbuilder.py#L100-L138 | def processV3(self, sessionRecord, message):
"""
:param sessionRecord:
:param message:
:type message: PreKeyWhisperMessage
:return:
"""
if sessionRecord.hasSessionState(message.getMessageVersion(), message.getBaseKey().serialize()):
logger.warn("We've... | [
"def",
"processV3",
"(",
"self",
",",
"sessionRecord",
",",
"message",
")",
":",
"if",
"sessionRecord",
".",
"hasSessionState",
"(",
"message",
".",
"getMessageVersion",
"(",
")",
",",
"message",
".",
"getBaseKey",
"(",
")",
".",
"serialize",
"(",
")",
")"... | :param sessionRecord:
:param message:
:type message: PreKeyWhisperMessage
:return: | [
":",
"param",
"sessionRecord",
":",
":",
"param",
"message",
":",
":",
"type",
"message",
":",
"PreKeyWhisperMessage",
":",
"return",
":"
] | python | train |
Grunny/zap-cli | zapcli/zap_helper.py | https://github.com/Grunny/zap-cli/blob/d58d4850ecfc5467badfac5e5bcc841d064bd419/zapcli/zap_helper.py#L277-L291 | def enable_scanners(self, scanners):
"""
Enable the provided scanners by group and/or IDs.
"""
scanner_ids = []
for scanner in scanners:
if scanner in self.scanner_groups:
self.enable_scanners_by_group(scanner)
elif scanner.isdigit():
... | [
"def",
"enable_scanners",
"(",
"self",
",",
"scanners",
")",
":",
"scanner_ids",
"=",
"[",
"]",
"for",
"scanner",
"in",
"scanners",
":",
"if",
"scanner",
"in",
"self",
".",
"scanner_groups",
":",
"self",
".",
"enable_scanners_by_group",
"(",
"scanner",
")",
... | Enable the provided scanners by group and/or IDs. | [
"Enable",
"the",
"provided",
"scanners",
"by",
"group",
"and",
"/",
"or",
"IDs",
"."
] | python | train |
dahlia/sqlalchemy-imageattach | sqlalchemy_imageattach/entity.py | https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L1034-L1041 | def image_sets(self):
"""(:class:`typing.Iterable`\ [:class:`ImageSubset`]) The set of
attached image sets.
"""
images = self._original_images()
for image in images:
yield ImageSubset(self, **image.identity_map) | [
"def",
"image_sets",
"(",
"self",
")",
":",
"images",
"=",
"self",
".",
"_original_images",
"(",
")",
"for",
"image",
"in",
"images",
":",
"yield",
"ImageSubset",
"(",
"self",
",",
"*",
"*",
"image",
".",
"identity_map",
")"
] | (:class:`typing.Iterable`\ [:class:`ImageSubset`]) The set of
attached image sets. | [
"(",
":",
"class",
":",
"typing",
".",
"Iterable",
"\\",
"[",
":",
"class",
":",
"ImageSubset",
"]",
")",
"The",
"set",
"of",
"attached",
"image",
"sets",
"."
] | python | train |
marrow/mongo | marrow/mongo/core/trait/published.py | https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/trait/published.py#L21-L37 | def only_published(cls, at=None):
"""Produce a query fragment suitable for selecting documents public.
Now (no arguments), at a specific time (datetime argument), or relative to now (timedelta).
"""
if isinstance(at, timedelta):
at = utcnow() + at
else:
at = at or utcnow()
pub, ret = cls.publ... | [
"def",
"only_published",
"(",
"cls",
",",
"at",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"at",
",",
"timedelta",
")",
":",
"at",
"=",
"utcnow",
"(",
")",
"+",
"at",
"else",
":",
"at",
"=",
"at",
"or",
"utcnow",
"(",
")",
"pub",
",",
"ret... | Produce a query fragment suitable for selecting documents public.
Now (no arguments), at a specific time (datetime argument), or relative to now (timedelta). | [
"Produce",
"a",
"query",
"fragment",
"suitable",
"for",
"selecting",
"documents",
"public",
".",
"Now",
"(",
"no",
"arguments",
")",
"at",
"a",
"specific",
"time",
"(",
"datetime",
"argument",
")",
"or",
"relative",
"to",
"now",
"(",
"timedelta",
")",
"."
... | python | train |
ctuning/ck | ck/kernel.py | https://github.com/ctuning/ck/blob/7e009814e975f8742790d3106340088a46223714/ck/kernel.py#L4351-L4377 | def get_current_date_time(i):
"""
Input: {}
Output: {
return - return code = 0
array - array with date and time
iso_datetime - date and time in ISO format
}
"""
import datetime
a={}
now1=datetime.datetime.now()
now... | [
"def",
"get_current_date_time",
"(",
"i",
")",
":",
"import",
"datetime",
"a",
"=",
"{",
"}",
"now1",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"now",
"=",
"now1",
".",
"timetuple",
"(",
")",
"a",
"[",
"'date_year'",
"]",
"=",
"now",
... | Input: {}
Output: {
return - return code = 0
array - array with date and time
iso_datetime - date and time in ISO format
} | [
"Input",
":",
"{}"
] | python | train |
teepark/greenhouse | greenhouse/pool.py | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/pool.py#L216-L252 | def get(self):
"""retrieve a result from the pool
if nothing is already completed when this method is called, it will
block until something comes back
if the pool's function exited via exception, that will come back as
a result here as well, but will be re-raised in :meth:`get`... | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"PoolClosed",
"(",
")",
"while",
"self",
".",
"_getcount",
"not",
"in",
"self",
".",
"_cache",
":",
"counter",
",",
"result",
"=",
"self",
".",
"outq",
".",
"get",
"(",... | retrieve a result from the pool
if nothing is already completed when this method is called, it will
block until something comes back
if the pool's function exited via exception, that will come back as
a result here as well, but will be re-raised in :meth:`get`.
.. note::
... | [
"retrieve",
"a",
"result",
"from",
"the",
"pool"
] | python | train |
chrisspen/webarticle2text | webarticle2text/webarticle2text.py | https://github.com/chrisspen/webarticle2text/blob/3c88e948e31aedf1eccfea2106e5848d224771eb/webarticle2text/webarticle2text.py#L337-L355 | def tidyHTML(dirtyHTML):
"""
Runs an arbitrary HTML string through Tidy.
"""
try:
from tidylib import tidy_document
except ImportError as e:
raise ImportError(("%s\nYou need to install pytidylib.\n" +
"e.g. sudo pip install pytidylib") % e)
options = {
'outpu... | [
"def",
"tidyHTML",
"(",
"dirtyHTML",
")",
":",
"try",
":",
"from",
"tidylib",
"import",
"tidy_document",
"except",
"ImportError",
"as",
"e",
":",
"raise",
"ImportError",
"(",
"(",
"\"%s\\nYou need to install pytidylib.\\n\"",
"+",
"\"e.g. sudo pip install pytidylib\"",
... | Runs an arbitrary HTML string through Tidy. | [
"Runs",
"an",
"arbitrary",
"HTML",
"string",
"through",
"Tidy",
"."
] | python | train |
StackStorm/pybind | pybind/nos/v6_0_2f/rbridge_id/router/ospf/max_metric/router_lsa/on_startup/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/router/ospf/max_metric/router_lsa/on_startup/__init__.py#L231-L252 | def _set_summary_lsa_onstartup(self, v, load=False):
"""
Setter method for summary_lsa_onstartup, mapped from YANG variable /rbridge_id/router/ospf/max_metric/router_lsa/on_startup/summary_lsa_onstartup (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_summary_... | [
"def",
"_set_summary_lsa_onstartup",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
... | Setter method for summary_lsa_onstartup, mapped from YANG variable /rbridge_id/router/ospf/max_metric/router_lsa/on_startup/summary_lsa_onstartup (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_summary_lsa_onstartup is considered as a private
method. Backends loo... | [
"Setter",
"method",
"for",
"summary_lsa_onstartup",
"mapped",
"from",
"YANG",
"variable",
"/",
"rbridge_id",
"/",
"router",
"/",
"ospf",
"/",
"max_metric",
"/",
"router_lsa",
"/",
"on_startup",
"/",
"summary_lsa_onstartup",
"(",
"container",
")",
"If",
"this",
"... | python | train |
PyCQA/pylint | pylint/message/message.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message.py#L45-L53 | def format(self, template):
"""Format the message according to the given template.
The template format is the one of the format method :
cf. http://docs.python.org/2/library/string.html#formatstrings
"""
# For some reason, _asdict on derived namedtuples does not work with
... | [
"def",
"format",
"(",
"self",
",",
"template",
")",
":",
"# For some reason, _asdict on derived namedtuples does not work with",
"# Python 3.4. Needs some investigation.",
"return",
"template",
".",
"format",
"(",
"*",
"*",
"dict",
"(",
"zip",
"(",
"self",
".",
"_fields... | Format the message according to the given template.
The template format is the one of the format method :
cf. http://docs.python.org/2/library/string.html#formatstrings | [
"Format",
"the",
"message",
"according",
"to",
"the",
"given",
"template",
"."
] | python | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.