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 |
|---|---|---|---|---|---|---|---|---|
amperser/proselint | proselint/checks/terms/denizen_labels.py | https://github.com/amperser/proselint/blob/cb619ee4023cc7856f5fb96aec2a33a2c9f1a2e2/proselint/checks/terms/denizen_labels.py#L62-L88 | def check_denizen_labels_norris(text):
"""Suggest the preferred forms.
source: Mary Norris
source_url: http://nyr.kr/1rGienj
"""
err = "terms.denizen_labels.norris"
msg = "Would you like '{}'?"
preferences = [
["Mancunian", ["Manchesterian"]],
["Mancunians", ... | [
"def",
"check_denizen_labels_norris",
"(",
"text",
")",
":",
"err",
"=",
"\"terms.denizen_labels.norris\"",
"msg",
"=",
"\"Would you like '{}'?\"",
"preferences",
"=",
"[",
"[",
"\"Mancunian\"",
",",
"[",
"\"Manchesterian\"",
"]",
"]",
",",
"[",
"\"Mancunians\"",
",... | Suggest the preferred forms.
source: Mary Norris
source_url: http://nyr.kr/1rGienj | [
"Suggest",
"the",
"preferred",
"forms",
"."
] | python | train |
capnproto/pycapnp | examples/calculator_client.py | https://github.com/capnproto/pycapnp/blob/cb3f190b955bdb1bfb6e0ac0b2f9306a5c79f7b5/examples/calculator_client.py#L35-L303 | def main(host):
client = capnp.TwoPartyClient(host)
# Pass "calculator" to ez_restore (there's also a `restore` function that
# takes a struct or AnyPointer as an argument), and then cast the returned
# capability to it's proper type. This casting is due to capabilities not
# having a reference to ... | [
"def",
"main",
"(",
"host",
")",
":",
"client",
"=",
"capnp",
".",
"TwoPartyClient",
"(",
"host",
")",
"# Pass \"calculator\" to ez_restore (there's also a `restore` function that",
"# takes a struct or AnyPointer as an argument), and then cast the returned",
"# capability to it's pr... | Make a request that just evaluates the literal value 123.
What's interesting here is that evaluate() returns a "Value", which is
another interface and therefore points back to an object living on the
server. We then have to call read() on that object to read it.
However, even though we are making two ... | [
"Make",
"a",
"request",
"that",
"just",
"evaluates",
"the",
"literal",
"value",
"123",
"."
] | python | train |
enkore/i3pystatus | i3pystatus/timer.py | https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/timer.py#L147-L158 | def start(self, seconds=300):
"""
Starts timer.
If timer is already running it will increase remaining time instead.
:param int seconds: Initial time.
"""
if self.state is TimerState.stopped:
self.compare = time.time() + abs(seconds)
self.state = ... | [
"def",
"start",
"(",
"self",
",",
"seconds",
"=",
"300",
")",
":",
"if",
"self",
".",
"state",
"is",
"TimerState",
".",
"stopped",
":",
"self",
".",
"compare",
"=",
"time",
".",
"time",
"(",
")",
"+",
"abs",
"(",
"seconds",
")",
"self",
".",
"sta... | Starts timer.
If timer is already running it will increase remaining time instead.
:param int seconds: Initial time. | [
"Starts",
"timer",
".",
"If",
"timer",
"is",
"already",
"running",
"it",
"will",
"increase",
"remaining",
"time",
"instead",
"."
] | python | train |
Unidata/MetPy | metpy/interpolate/geometry.py | https://github.com/Unidata/MetPy/blob/16f68a94919b9a82dcf9cada2169cf039129e67b/metpy/interpolate/geometry.py#L377-L415 | def find_local_boundary(tri, triangles):
r"""Find and return the outside edges of a collection of natural neighbor triangles.
There is no guarantee that this boundary is convex, so ConvexHull is not
sufficient in some situations.
Parameters
----------
tri: Object
A Delaunay Triangulati... | [
"def",
"find_local_boundary",
"(",
"tri",
",",
"triangles",
")",
":",
"edges",
"=",
"[",
"]",
"for",
"triangle",
"in",
"triangles",
":",
"for",
"i",
"in",
"range",
"(",
"3",
")",
":",
"pt1",
"=",
"tri",
".",
"simplices",
"[",
"triangle",
"]",
"[",
... | r"""Find and return the outside edges of a collection of natural neighbor triangles.
There is no guarantee that this boundary is convex, so ConvexHull is not
sufficient in some situations.
Parameters
----------
tri: Object
A Delaunay Triangulation
triangles: (N, ) array
List of... | [
"r",
"Find",
"and",
"return",
"the",
"outside",
"edges",
"of",
"a",
"collection",
"of",
"natural",
"neighbor",
"triangles",
"."
] | python | train |
openstack/horizon | horizon/tabs/base.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/base.py#L170-L178 | def load_tab_data(self):
"""Preload all data that for the tabs that will be displayed."""
for tab in self._tabs.values():
if tab.load and not tab.data_loaded:
try:
tab._data = tab.get_context_data(self.request)
except Exception:
... | [
"def",
"load_tab_data",
"(",
"self",
")",
":",
"for",
"tab",
"in",
"self",
".",
"_tabs",
".",
"values",
"(",
")",
":",
"if",
"tab",
".",
"load",
"and",
"not",
"tab",
".",
"data_loaded",
":",
"try",
":",
"tab",
".",
"_data",
"=",
"tab",
".",
"get_... | Preload all data that for the tabs that will be displayed. | [
"Preload",
"all",
"data",
"that",
"for",
"the",
"tabs",
"that",
"will",
"be",
"displayed",
"."
] | python | train |
fermiPy/fermipy | fermipy/gtanalysis.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1307-L1370 | def add_source(self, name, src_dict, free=None, init_source=True,
save_source_maps=True, use_pylike=True,
use_single_psf=False, **kwargs):
"""Add a source to the ROI model. This function may be called
either before or after `~fermipy.gtanalysis.GTAnalysis.setup`.
... | [
"def",
"add_source",
"(",
"self",
",",
"name",
",",
"src_dict",
",",
"free",
"=",
"None",
",",
"init_source",
"=",
"True",
",",
"save_source_maps",
"=",
"True",
",",
"use_pylike",
"=",
"True",
",",
"use_single_psf",
"=",
"False",
",",
"*",
"*",
"kwargs",... | Add a source to the ROI model. This function may be called
either before or after `~fermipy.gtanalysis.GTAnalysis.setup`.
Parameters
----------
name : str
Source name.
src_dict : dict or `~fermipy.roi_model.Source` object
Dictionary or source object def... | [
"Add",
"a",
"source",
"to",
"the",
"ROI",
"model",
".",
"This",
"function",
"may",
"be",
"called",
"either",
"before",
"or",
"after",
"~fermipy",
".",
"gtanalysis",
".",
"GTAnalysis",
".",
"setup",
"."
] | python | train |
chaoss/grimoirelab-perceval | perceval/backends/core/slack.py | https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/slack.py#L435-L457 | def setup_cmd_parser(cls):
"""Returns the Slack argument parser."""
parser = BackendCommandArgumentParser(cls.BACKEND.CATEGORIES,
from_date=True,
token_auth=True,
ar... | [
"def",
"setup_cmd_parser",
"(",
"cls",
")",
":",
"parser",
"=",
"BackendCommandArgumentParser",
"(",
"cls",
".",
"BACKEND",
".",
"CATEGORIES",
",",
"from_date",
"=",
"True",
",",
"token_auth",
"=",
"True",
",",
"archive",
"=",
"True",
")",
"# Backend token is ... | Returns the Slack argument parser. | [
"Returns",
"the",
"Slack",
"argument",
"parser",
"."
] | python | test |
bioidiap/bob.ip.facedetect | bob/ip/facedetect/detector/cascade.py | https://github.com/bioidiap/bob.ip.facedetect/blob/601da5141ca7302ad36424d1421b33190ba46779/bob/ip/facedetect/detector/cascade.py#L44-L65 | def add(self, classifier, threshold, begin=None, end=None):
"""Adds a new strong classifier with the given threshold to the cascade.
**Parameters:**
classifier : :py:class:`bob.learn.boosting.BoostedMachine`
A strong classifier to add
``threshold`` : float
The classification threshold for... | [
"def",
"add",
"(",
"self",
",",
"classifier",
",",
"threshold",
",",
"begin",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"boosted_machine",
"=",
"bob",
".",
"learn",
".",
"boosting",
".",
"BoostedMachine",
"(",
")",
"if",
"begin",
"is",
"None",
... | Adds a new strong classifier with the given threshold to the cascade.
**Parameters:**
classifier : :py:class:`bob.learn.boosting.BoostedMachine`
A strong classifier to add
``threshold`` : float
The classification threshold for this cascade step
``begin``, ``end`` : int or ``None``
... | [
"Adds",
"a",
"new",
"strong",
"classifier",
"with",
"the",
"given",
"threshold",
"to",
"the",
"cascade",
"."
] | python | train |
timstaley/voevent-parse | src/voeventparse/convenience.py | https://github.com/timstaley/voevent-parse/blob/58fc1eb3af5eca23d9e819c727204950615402a7/src/voeventparse/convenience.py#L186-L198 | def pull_astro_coords(voevent, index=0):
"""
Deprecated alias of :func:`.get_event_position`
"""
import warnings
warnings.warn(
"""
The function `pull_astro_coords` has been renamed to
`get_event_position`. This alias is preserved for backwards
compatibility, and may ... | [
"def",
"pull_astro_coords",
"(",
"voevent",
",",
"index",
"=",
"0",
")",
":",
"import",
"warnings",
"warnings",
".",
"warn",
"(",
"\"\"\"\n The function `pull_astro_coords` has been renamed to\n `get_event_position`. This alias is preserved for backwards\n compat... | Deprecated alias of :func:`.get_event_position` | [
"Deprecated",
"alias",
"of",
":",
"func",
":",
".",
"get_event_position"
] | python | train |
inasafe/inasafe | safe/datastore/geopackage.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/datastore/geopackage.py#L182-L228 | def _add_vector_layer(self, vector_layer, layer_name, save_style=False):
"""Add a vector layer to the geopackage.
:param vector_layer: The layer to add.
:type vector_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
... | [
"def",
"_add_vector_layer",
"(",
"self",
",",
"vector_layer",
",",
"layer_name",
",",
"save_style",
"=",
"False",
")",
":",
"# Fixme",
"# if not self.is_writable():",
"# return False, 'The destination is not writable.'",
"geometry",
"=",
"QGIS_OGR_GEOMETRY_MAP",
"[",
"ve... | Add a vector layer to the geopackage.
:param vector_layer: The layer to add.
:type vector_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
:param save_style: If we have to save a QML too. Default to False.
Not imple... | [
"Add",
"a",
"vector",
"layer",
"to",
"the",
"geopackage",
"."
] | python | train |
klahnakoski/pyLibrary | jx_base/expressions.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/expressions.py#L157-L201 | def define(cls, expr):
"""
GENERAL SUPPORT FOR BUILDING EXPRESSIONS FROM JSON EXPRESSIONS
OVERRIDE THIS IF AN OPERATOR EXPECTS COMPLICATED PARAMETERS
:param expr: Data representing a JSON Expression
:return: parse tree
"""
try:
lang = cls.lang
... | [
"def",
"define",
"(",
"cls",
",",
"expr",
")",
":",
"try",
":",
"lang",
"=",
"cls",
".",
"lang",
"items",
"=",
"items_",
"(",
"expr",
")",
"for",
"item",
"in",
"items",
":",
"op",
",",
"term",
"=",
"item",
"full_op",
"=",
"operators",
".",
"get",... | GENERAL SUPPORT FOR BUILDING EXPRESSIONS FROM JSON EXPRESSIONS
OVERRIDE THIS IF AN OPERATOR EXPECTS COMPLICATED PARAMETERS
:param expr: Data representing a JSON Expression
:return: parse tree | [
"GENERAL",
"SUPPORT",
"FOR",
"BUILDING",
"EXPRESSIONS",
"FROM",
"JSON",
"EXPRESSIONS",
"OVERRIDE",
"THIS",
"IF",
"AN",
"OPERATOR",
"EXPECTS",
"COMPLICATED",
"PARAMETERS",
":",
"param",
"expr",
":",
"Data",
"representing",
"a",
"JSON",
"Expression",
":",
"return",
... | python | train |
napalm-automation/napalm | napalm/base/helpers.py | https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/base/helpers.py#L307-L333 | def ip(addr, version=None):
"""
Converts a raw string to a valid IP address. Optional version argument will detect that \
object matches specified version.
Motivation: the groups of the IP addreses may contain leading zeros. IPv6 addresses can \
contain sometimes uppercase characters. E.g.: 2001:0d... | [
"def",
"ip",
"(",
"addr",
",",
"version",
"=",
"None",
")",
":",
"addr_obj",
"=",
"IPAddress",
"(",
"addr",
")",
"if",
"version",
"and",
"addr_obj",
".",
"version",
"!=",
"version",
":",
"raise",
"ValueError",
"(",
"\"{} is not an ipv{} address\"",
".",
"f... | Converts a raw string to a valid IP address. Optional version argument will detect that \
object matches specified version.
Motivation: the groups of the IP addreses may contain leading zeros. IPv6 addresses can \
contain sometimes uppercase characters. E.g.: 2001:0dB8:85a3:0000:0000:8A2e:0370:7334 has \
... | [
"Converts",
"a",
"raw",
"string",
"to",
"a",
"valid",
"IP",
"address",
".",
"Optional",
"version",
"argument",
"will",
"detect",
"that",
"\\",
"object",
"matches",
"specified",
"version",
"."
] | python | train |
wbond/asn1crypto | asn1crypto/core.py | https://github.com/wbond/asn1crypto/blob/ecda20176f55d37021cbca1f6da9083a8e491197/asn1crypto/core.py#L1733-L1757 | def set(self, value):
"""
Sets the value of the string
:param value:
A unicode string
"""
if not isinstance(value, str_cls):
raise TypeError(unwrap(
'''
%s value must be a unicode string, not %s
''',
... | [
"def",
"set",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"str_cls",
")",
":",
"raise",
"TypeError",
"(",
"unwrap",
"(",
"'''\n %s value must be a unicode string, not %s\n '''",
",",
"type_name",
"... | Sets the value of the string
:param value:
A unicode string | [
"Sets",
"the",
"value",
"of",
"the",
"string"
] | python | train |
spacetelescope/drizzlepac | drizzlepac/util.py | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/util.py#L1021-L1031 | def getRotatedSize(corners, angle):
""" Determine the size of a rotated (meta)image."""
if angle:
_rotm = fileutil.buildRotMatrix(angle)
# Rotate about the center
_corners = np.dot(corners, _rotm)
else:
# If there is no rotation, simply return original values
_corners... | [
"def",
"getRotatedSize",
"(",
"corners",
",",
"angle",
")",
":",
"if",
"angle",
":",
"_rotm",
"=",
"fileutil",
".",
"buildRotMatrix",
"(",
"angle",
")",
"# Rotate about the center",
"_corners",
"=",
"np",
".",
"dot",
"(",
"corners",
",",
"_rotm",
")",
"els... | Determine the size of a rotated (meta)image. | [
"Determine",
"the",
"size",
"of",
"a",
"rotated",
"(",
"meta",
")",
"image",
"."
] | python | train |
zhihu/redis-shard | redis_shard/shard.py | https://github.com/zhihu/redis-shard/blob/57c166ef7d55f7272b50efc1dedc1f6ed4691137/redis_shard/shard.py#L159-L170 | def mset(self, mapping):
"""
Sets each key in the ``mapping`` dict to its corresponding value
"""
servers = {}
for key, value in mapping.items():
server_name = self.get_server_name(key)
servers.setdefault(server_name, [])
servers[server_name].a... | [
"def",
"mset",
"(",
"self",
",",
"mapping",
")",
":",
"servers",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"mapping",
".",
"items",
"(",
")",
":",
"server_name",
"=",
"self",
".",
"get_server_name",
"(",
"key",
")",
"servers",
".",
"setdefault... | Sets each key in the ``mapping`` dict to its corresponding value | [
"Sets",
"each",
"key",
"in",
"the",
"mapping",
"dict",
"to",
"its",
"corresponding",
"value"
] | python | valid |
pyviz/holoviews | holoviews/core/accessors.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/accessors.py#L170-L204 | def replace_dimensions(cls, dimensions, overrides):
"""Replaces dimensions in list with dictionary of overrides.
Args:
dimensions: List of dimensions
overrides: Dictionary of dimension specs indexed by name
Returns:
list: List of dimensions with replacements... | [
"def",
"replace_dimensions",
"(",
"cls",
",",
"dimensions",
",",
"overrides",
")",
":",
"from",
".",
"dimension",
"import",
"Dimension",
"replaced",
"=",
"[",
"]",
"for",
"d",
"in",
"dimensions",
":",
"if",
"d",
".",
"name",
"in",
"overrides",
":",
"over... | Replaces dimensions in list with dictionary of overrides.
Args:
dimensions: List of dimensions
overrides: Dictionary of dimension specs indexed by name
Returns:
list: List of dimensions with replacements applied | [
"Replaces",
"dimensions",
"in",
"list",
"with",
"dictionary",
"of",
"overrides",
"."
] | python | train |
log2timeline/plaso | plaso/parsers/sqlite_plugins/imessage.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/sqlite_plugins/imessage.py#L130-L156 | def ParseMessageRow(self, parser_mediator, query, row, **unused_kwargs):
"""Parses a message row.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
query (str): query that created the row.
row (sqlite3.Row)... | [
"def",
"ParseMessageRow",
"(",
"self",
",",
"parser_mediator",
",",
"query",
",",
"row",
",",
"*",
"*",
"unused_kwargs",
")",
":",
"query_hash",
"=",
"hash",
"(",
"query",
")",
"event_data",
"=",
"IMessageEventData",
"(",
")",
"event_data",
".",
"attachment_... | Parses a message row.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
query (str): query that created the row.
row (sqlite3.Row): row. | [
"Parses",
"a",
"message",
"row",
"."
] | python | train |
dagwieers/vmguestlib | vmguestlib.py | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L393-L399 | def GetMemSharedSavedMB(self):
'''Retrieves the estimated amount of physical memory on the host saved
from copy-on-write (COW) shared guest physical memory.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemSharedSavedMB(self.handle.value, byref(counter))
if ret != VMGUE... | [
"def",
"GetMemSharedSavedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemSharedSavedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
... | Retrieves the estimated amount of physical memory on the host saved
from copy-on-write (COW) shared guest physical memory. | [
"Retrieves",
"the",
"estimated",
"amount",
"of",
"physical",
"memory",
"on",
"the",
"host",
"saved",
"from",
"copy",
"-",
"on",
"-",
"write",
"(",
"COW",
")",
"shared",
"guest",
"physical",
"memory",
"."
] | python | train |
alexhayes/django-toolkit | django_toolkit/templatetags/actions.py | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/templatetags/actions.py#L8-L18 | def actions(obj, **kwargs):
"""
Return actions available for an object
"""
if 'exclude' in kwargs:
kwargs['exclude'] = kwargs['exclude'].split(',')
actions = obj.get_actions(**kwargs)
if isinstance(actions, dict):
actions = actions.values()
buttons = "".join("%s" % action.ren... | [
"def",
"actions",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'exclude'",
"in",
"kwargs",
":",
"kwargs",
"[",
"'exclude'",
"]",
"=",
"kwargs",
"[",
"'exclude'",
"]",
".",
"split",
"(",
"','",
")",
"actions",
"=",
"obj",
".",
"get_actions",
... | Return actions available for an object | [
"Return",
"actions",
"available",
"for",
"an",
"object"
] | python | train |
pescadores/pescador | pescador/mux.py | https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/mux.py#L932-L947 | def _new_stream(self, idx):
'''Randomly select and create a new stream.
Parameters
----------
idx : int, [0:n_streams - 1]
The stream index to replace
'''
# Don't activate the stream if the weight is 0 or None
if self.stream_weights_[idx]:
... | [
"def",
"_new_stream",
"(",
"self",
",",
"idx",
")",
":",
"# Don't activate the stream if the weight is 0 or None",
"if",
"self",
".",
"stream_weights_",
"[",
"idx",
"]",
":",
"self",
".",
"streams_",
"[",
"idx",
"]",
"=",
"self",
".",
"streamers",
"[",
"idx",
... | Randomly select and create a new stream.
Parameters
----------
idx : int, [0:n_streams - 1]
The stream index to replace | [
"Randomly",
"select",
"and",
"create",
"a",
"new",
"stream",
"."
] | python | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/engine.py | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/engine.py#L331-L339 | def after_processing(eng, objects):
"""Process to update status."""
super(InvenioProcessingFactory, InvenioProcessingFactory)\
.after_processing(eng, objects)
if eng.has_completed:
eng.save(WorkflowStatus.COMPLETED)
else:
eng.save(WorkflowStatus.HALTED... | [
"def",
"after_processing",
"(",
"eng",
",",
"objects",
")",
":",
"super",
"(",
"InvenioProcessingFactory",
",",
"InvenioProcessingFactory",
")",
".",
"after_processing",
"(",
"eng",
",",
"objects",
")",
"if",
"eng",
".",
"has_completed",
":",
"eng",
".",
"save... | Process to update status. | [
"Process",
"to",
"update",
"status",
"."
] | python | train |
numberoverzero/bloop | bloop/models.py | https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/models.py#L591-L608 | def unpack_from_dynamodb(*, attrs, expected, model=None, obj=None, engine=None, context=None, **kwargs):
"""Push values by dynamo_name into an object"""
context = context or {"engine": engine}
engine = engine or context.get("engine", None)
if not engine:
raise ValueError("You must provide engine... | [
"def",
"unpack_from_dynamodb",
"(",
"*",
",",
"attrs",
",",
"expected",
",",
"model",
"=",
"None",
",",
"obj",
"=",
"None",
",",
"engine",
"=",
"None",
",",
"context",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"context",
"or",
... | Push values by dynamo_name into an object | [
"Push",
"values",
"by",
"dynamo_name",
"into",
"an",
"object"
] | python | train |
tanghaibao/jcvi | jcvi/compara/catalog.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/compara/catalog.py#L587-L708 | def ortholog(args):
"""
%prog ortholog species_a species_b
Run a sensitive pipeline to find orthologs between two species a and b.
The pipeline runs LAST and generate .lifted.anchors.
`--full` mode would assume 1-to-1 quota synteny blocks as the backbone of
such predictions. Extra orthologs wi... | [
"def",
"ortholog",
"(",
"args",
")",
":",
"from",
"jcvi",
".",
"apps",
".",
"align",
"import",
"last",
"as",
"last_main",
"from",
"jcvi",
".",
"compara",
".",
"blastfilter",
"import",
"main",
"as",
"blastfilter_main",
"from",
"jcvi",
".",
"compara",
".",
... | %prog ortholog species_a species_b
Run a sensitive pipeline to find orthologs between two species a and b.
The pipeline runs LAST and generate .lifted.anchors.
`--full` mode would assume 1-to-1 quota synteny blocks as the backbone of
such predictions. Extra orthologs will be recruited from reciprocal ... | [
"%prog",
"ortholog",
"species_a",
"species_b"
] | python | train |
spyder-ide/spyder | spyder/config/user.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/user.py#L263-L272 | def _load_old_defaults(self, old_version):
"""Read old defaults"""
old_defaults = cp.ConfigParser()
if check_version(old_version, '3.0.0', '<='):
path = get_module_source_path('spyder')
else:
path = osp.dirname(self.filename())
path = osp.join(path,... | [
"def",
"_load_old_defaults",
"(",
"self",
",",
"old_version",
")",
":",
"old_defaults",
"=",
"cp",
".",
"ConfigParser",
"(",
")",
"if",
"check_version",
"(",
"old_version",
",",
"'3.0.0'",
",",
"'<='",
")",
":",
"path",
"=",
"get_module_source_path",
"(",
"'... | Read old defaults | [
"Read",
"old",
"defaults"
] | python | train |
zerotk/easyfs | zerotk/easyfs/_easyfs.py | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L614-L638 | def IsDir(directory):
'''
:param unicode directory:
A path
:rtype: bool
:returns:
Returns whether the given path points to an existent directory.
:raises NotImplementedProtocol:
If the path protocol is not local or ftp
.. seealso:: FTP LIMITATIONS at this module's doc ... | [
"def",
"IsDir",
"(",
"directory",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"directory_url",
"=",
"urlparse",
"(",
"directory",
")",
"if",
"_UrlIsLocal",
"(",
"directory_url",
")",
":",
"return",
"os",
".",
... | :param unicode directory:
A path
:rtype: bool
:returns:
Returns whether the given path points to an existent directory.
:raises NotImplementedProtocol:
If the path protocol is not local or ftp
.. seealso:: FTP LIMITATIONS at this module's doc for performance issues information | [
":",
"param",
"unicode",
"directory",
":",
"A",
"path"
] | python | valid |
hobson/aima | aima/learning.py | https://github.com/hobson/aima/blob/3572b2fb92039b4a1abe384be8545560fbd3d470/aima/learning.py#L168-L174 | def smooth_for(self, o):
"""Include o among the possible observations, whether or not
it's been observed yet."""
if o not in self.dictionary:
self.dictionary[o] = self.default
self.n_obs += self.default
self.sampler = None | [
"def",
"smooth_for",
"(",
"self",
",",
"o",
")",
":",
"if",
"o",
"not",
"in",
"self",
".",
"dictionary",
":",
"self",
".",
"dictionary",
"[",
"o",
"]",
"=",
"self",
".",
"default",
"self",
".",
"n_obs",
"+=",
"self",
".",
"default",
"self",
".",
... | Include o among the possible observations, whether or not
it's been observed yet. | [
"Include",
"o",
"among",
"the",
"possible",
"observations",
"whether",
"or",
"not",
"it",
"s",
"been",
"observed",
"yet",
"."
] | python | valid |
GoogleCloudPlatform/psq | psq/psqworker.py | https://github.com/GoogleCloudPlatform/psq/blob/3c5130731d72b6c32d09a6a5d478f3580ff36d50/psq/psqworker.py#L72-L103 | def main(path, pid, queue):
"""
Standalone PSQ worker.
The queue argument must be the full importable path to a psq.Queue
instance.
Example usage:
psqworker config.q
psqworker --path /opt/app queues.fast
"""
setup_logging()
if pid:
with open(os.path.expandus... | [
"def",
"main",
"(",
"path",
",",
"pid",
",",
"queue",
")",
":",
"setup_logging",
"(",
")",
"if",
"pid",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"pid",
")",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
... | Standalone PSQ worker.
The queue argument must be the full importable path to a psq.Queue
instance.
Example usage:
psqworker config.q
psqworker --path /opt/app queues.fast | [
"Standalone",
"PSQ",
"worker",
"."
] | python | valid |
noahbenson/neuropythy | neuropythy/vision/cmag.py | https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/vision/cmag.py#L545-L645 | def cmag(mesh, retinotopy='any', surface=None, to='vertices'):
'''
cmag(mesh) yields the neighborhood-based cortical magnification for the given mesh.
cmag(mesh, retinotopy) uses the given retinotopy argument; this must be interpretable by
the as_retinotopy function, or should be the name of a source ... | [
"def",
"cmag",
"(",
"mesh",
",",
"retinotopy",
"=",
"'any'",
",",
"surface",
"=",
"None",
",",
"to",
"=",
"'vertices'",
")",
":",
"# First, find the retino data",
"if",
"pimms",
".",
"is_str",
"(",
"retinotopy",
")",
":",
"retino",
"=",
"retinotopy_data",
... | cmag(mesh) yields the neighborhood-based cortical magnification for the given mesh.
cmag(mesh, retinotopy) uses the given retinotopy argument; this must be interpretable by
the as_retinotopy function, or should be the name of a source (such as 'empirical' or
'any').
The neighborhood-based cortical ... | [
"cmag",
"(",
"mesh",
")",
"yields",
"the",
"neighborhood",
"-",
"based",
"cortical",
"magnification",
"for",
"the",
"given",
"mesh",
".",
"cmag",
"(",
"mesh",
"retinotopy",
")",
"uses",
"the",
"given",
"retinotopy",
"argument",
";",
"this",
"must",
"be",
"... | python | train |
h2oai/h2o-3 | scripts/run.py | https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/scripts/run.py#L2614-L2733 | def main(argv):
"""
Main program.
:param argv Command-line arguments
:return none
"""
global g_script_name
global g_num_clouds
global g_nodes_per_cloud
global g_output_dir
global g_test_to_run
global g_test_list_file
global g_exclude_list_file
global g_test_group
... | [
"def",
"main",
"(",
"argv",
")",
":",
"global",
"g_script_name",
"global",
"g_num_clouds",
"global",
"g_nodes_per_cloud",
"global",
"g_output_dir",
"global",
"g_test_to_run",
"global",
"g_test_list_file",
"global",
"g_exclude_list_file",
"global",
"g_test_group",
"global"... | Main program.
:param argv Command-line arguments
:return none | [
"Main",
"program",
".",
":",
"param",
"argv",
"Command",
"-",
"line",
"arguments",
":",
"return",
"none"
] | python | test |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L8642-L8659 | def mxm(m1, m2):
"""
Multiply two 3x3 matrices.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/mxm_c.html
:param m1: 3x3 double precision matrix.
:type m1: 3x3-Element Array of floats
:param m2: 3x3 double precision matrix.
:type m2: 3x3-Element Array of floats
:return: 3x3 do... | [
"def",
"mxm",
"(",
"m1",
",",
"m2",
")",
":",
"m1",
"=",
"stypes",
".",
"toDoubleMatrix",
"(",
"m1",
")",
"m2",
"=",
"stypes",
".",
"toDoubleMatrix",
"(",
"m2",
")",
"mout",
"=",
"stypes",
".",
"emptyDoubleMatrix",
"(",
")",
"libspice",
".",
"mxm_c",... | Multiply two 3x3 matrices.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/mxm_c.html
:param m1: 3x3 double precision matrix.
:type m1: 3x3-Element Array of floats
:param m2: 3x3 double precision matrix.
:type m2: 3x3-Element Array of floats
:return: 3x3 double precision matrix.
:r... | [
"Multiply",
"two",
"3x3",
"matrices",
"."
] | python | train |
TaurusOlson/incisive | incisive/core.py | https://github.com/TaurusOlson/incisive/blob/25bb9f53495985c1416c82e26f54158df4050cb0/incisive/core.py#L91-L152 | def write_csv(filename, header, data=None, rows=None, mode="w"):
"""Write the data to the specified filename
Usage
-----
>>> write_csv(filename, header, data, mode=mode)
Parameters
----------
filename : str
The name of the file
header : list of strings
The names of... | [
"def",
"write_csv",
"(",
"filename",
",",
"header",
",",
"data",
"=",
"None",
",",
"rows",
"=",
"None",
",",
"mode",
"=",
"\"w\"",
")",
":",
"if",
"data",
"==",
"rows",
"==",
"None",
":",
"msg",
"=",
"\"You must specify either data or rows\"",
"raise",
"... | Write the data to the specified filename
Usage
-----
>>> write_csv(filename, header, data, mode=mode)
Parameters
----------
filename : str
The name of the file
header : list of strings
The names of the columns (or fields):
(fieldname1, fieldname2, ...)
dat... | [
"Write",
"the",
"data",
"to",
"the",
"specified",
"filename",
"Usage",
"-----",
">>>",
"write_csv",
"(",
"filename",
"header",
"data",
"mode",
"=",
"mode",
")"
] | python | valid |
briancappello/flask-unchained | flask_unchained/bundles/controller/utils.py | https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/bundles/controller/utils.py#L52-L67 | def controller_name(cls, _remove_suffixes=None) -> str:
"""
Returns the snake-cased name for a controller/resource class. Automatically
strips ``Controller``, ``View``, and ``MethodView`` suffixes, eg::
SiteController -> site
FooBarBazView -> foo_bar_baz
UsersMethodView -> users
... | [
"def",
"controller_name",
"(",
"cls",
",",
"_remove_suffixes",
"=",
"None",
")",
"->",
"str",
":",
"name",
"=",
"cls",
"if",
"isinstance",
"(",
"cls",
",",
"str",
")",
"else",
"cls",
".",
"__name__",
"remove_suffixes",
"=",
"_remove_suffixes",
"or",
"getat... | Returns the snake-cased name for a controller/resource class. Automatically
strips ``Controller``, ``View``, and ``MethodView`` suffixes, eg::
SiteController -> site
FooBarBazView -> foo_bar_baz
UsersMethodView -> users | [
"Returns",
"the",
"snake",
"-",
"cased",
"name",
"for",
"a",
"controller",
"/",
"resource",
"class",
".",
"Automatically",
"strips",
"Controller",
"View",
"and",
"MethodView",
"suffixes",
"eg",
"::"
] | python | train |
KnowledgeLinks/rdfframework | rdfframework/search/esloaders_temp.py | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders_temp.py#L59-L65 | def _index_item(self, uri, num, batch_num):
""" queries the triplestore for an item sends it to elasticsearch """
data = RdfDataset(get_all_item_data(uri, self.namespace),
uri).base_class.es_json()
self.batch_data[batch_num].append(data)
self.count += 1 | [
"def",
"_index_item",
"(",
"self",
",",
"uri",
",",
"num",
",",
"batch_num",
")",
":",
"data",
"=",
"RdfDataset",
"(",
"get_all_item_data",
"(",
"uri",
",",
"self",
".",
"namespace",
")",
",",
"uri",
")",
".",
"base_class",
".",
"es_json",
"(",
")",
... | queries the triplestore for an item sends it to elasticsearch | [
"queries",
"the",
"triplestore",
"for",
"an",
"item",
"sends",
"it",
"to",
"elasticsearch"
] | python | train |
awslabs/serverless-application-model | samtranslator/intrinsics/actions.py | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L196-L253 | def resolve_resource_refs(self, input_dict, supported_resource_refs):
"""
Resolves reference to some property of a resource. Inside string to be substituted, there could be either a
"Ref" or a "GetAtt" usage of this property. They have to be handled differently.
Ref usages are directly ... | [
"def",
"resolve_resource_refs",
"(",
"self",
",",
"input_dict",
",",
"supported_resource_refs",
")",
":",
"def",
"do_replacement",
"(",
"full_ref",
",",
"ref_value",
")",
":",
"\"\"\"\n Perform the appropriate replacement to handle ${LogicalId.Property} type references... | Resolves reference to some property of a resource. Inside string to be substituted, there could be either a
"Ref" or a "GetAtt" usage of this property. They have to be handled differently.
Ref usages are directly converted to a Ref on the resolved value. GetAtt usages are split under the assumption
... | [
"Resolves",
"reference",
"to",
"some",
"property",
"of",
"a",
"resource",
".",
"Inside",
"string",
"to",
"be",
"substituted",
"there",
"could",
"be",
"either",
"a",
"Ref",
"or",
"a",
"GetAtt",
"usage",
"of",
"this",
"property",
".",
"They",
"have",
"to",
... | python | train |
saltstack/salt | salt/minion.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/minion.py#L2583-L2611 | def _handle_tag_master_connected(self, tag, data):
'''
Handle a master_connected event
'''
# handle this event only once. otherwise it will pollute the log
# also if master type is failover all the reconnection work is done
# by `disconnected` event handler and this event... | [
"def",
"_handle_tag_master_connected",
"(",
"self",
",",
"tag",
",",
"data",
")",
":",
"# handle this event only once. otherwise it will pollute the log",
"# also if master type is failover all the reconnection work is done",
"# by `disconnected` event handler and this event must never happe... | Handle a master_connected event | [
"Handle",
"a",
"master_connected",
"event"
] | python | train |
yinkaisheng/Python-UIAutomation-for-Windows | uiautomation/uiautomation.py | https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L6094-L6101 | def SetWindowText(self, text: str) -> bool:
"""
Call native SetWindowText if control has a valid native handle.
"""
handle = self.NativeWindowHandle
if handle:
return SetWindowText(handle, text)
return False | [
"def",
"SetWindowText",
"(",
"self",
",",
"text",
":",
"str",
")",
"->",
"bool",
":",
"handle",
"=",
"self",
".",
"NativeWindowHandle",
"if",
"handle",
":",
"return",
"SetWindowText",
"(",
"handle",
",",
"text",
")",
"return",
"False"
] | Call native SetWindowText if control has a valid native handle. | [
"Call",
"native",
"SetWindowText",
"if",
"control",
"has",
"a",
"valid",
"native",
"handle",
"."
] | python | valid |
pokerregion/poker | poker/card.py | https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/card.py#L42-L48 | def difference(cls, first, second):
"""Tells the numerical difference between two ranks."""
# so we always get a Rank instance even if string were passed in
first, second = cls(first), cls(second)
rank_list = list(cls)
return abs(rank_list.index(first) - rank_list.index(second)) | [
"def",
"difference",
"(",
"cls",
",",
"first",
",",
"second",
")",
":",
"# so we always get a Rank instance even if string were passed in",
"first",
",",
"second",
"=",
"cls",
"(",
"first",
")",
",",
"cls",
"(",
"second",
")",
"rank_list",
"=",
"list",
"(",
"c... | Tells the numerical difference between two ranks. | [
"Tells",
"the",
"numerical",
"difference",
"between",
"two",
"ranks",
"."
] | python | train |
googlefonts/glyphsLib | Lib/glyphsLib/builder/kerning.py | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/kerning.py#L27-L46 | def _to_ufo_kerning(self, ufo, kerning_data):
"""Add .glyphs kerning to an UFO."""
warning_msg = "Non-existent glyph class %s found in kerning rules."
for left, pairs in kerning_data.items():
match = re.match(r"@MMK_L_(.+)", left)
left_is_class = bool(match)
if left_is_class:
... | [
"def",
"_to_ufo_kerning",
"(",
"self",
",",
"ufo",
",",
"kerning_data",
")",
":",
"warning_msg",
"=",
"\"Non-existent glyph class %s found in kerning rules.\"",
"for",
"left",
",",
"pairs",
"in",
"kerning_data",
".",
"items",
"(",
")",
":",
"match",
"=",
"re",
"... | Add .glyphs kerning to an UFO. | [
"Add",
".",
"glyphs",
"kerning",
"to",
"an",
"UFO",
"."
] | python | train |
djgagne/hagelslag | hagelslag/processing/TrackModeler.py | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/TrackModeler.py#L879-L905 | def output_forecasts_csv(self, forecasts, mode, csv_path, run_date_format="%Y%m%d-%H%M"):
"""
Output hail forecast values to csv files by run date and ensemble member.
Args:
forecasts:
mode:
csv_path:
Returns:
"""
merged_forecasts = pd... | [
"def",
"output_forecasts_csv",
"(",
"self",
",",
"forecasts",
",",
"mode",
",",
"csv_path",
",",
"run_date_format",
"=",
"\"%Y%m%d-%H%M\"",
")",
":",
"merged_forecasts",
"=",
"pd",
".",
"merge",
"(",
"forecasts",
"[",
"\"condition\"",
"]",
",",
"forecasts",
"[... | Output hail forecast values to csv files by run date and ensemble member.
Args:
forecasts:
mode:
csv_path:
Returns: | [
"Output",
"hail",
"forecast",
"values",
"to",
"csv",
"files",
"by",
"run",
"date",
"and",
"ensemble",
"member",
"."
] | python | train |
pandas-dev/pandas | pandas/core/resample.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/resample.py#L391-L406 | def _wrap_result(self, result):
"""
Potentially wrap any results.
"""
if isinstance(result, ABCSeries) and self._selection is not None:
result.name = self._selection
if isinstance(result, ABCSeries) and result.empty:
obj = self.obj
if isinstan... | [
"def",
"_wrap_result",
"(",
"self",
",",
"result",
")",
":",
"if",
"isinstance",
"(",
"result",
",",
"ABCSeries",
")",
"and",
"self",
".",
"_selection",
"is",
"not",
"None",
":",
"result",
".",
"name",
"=",
"self",
".",
"_selection",
"if",
"isinstance",
... | Potentially wrap any results. | [
"Potentially",
"wrap",
"any",
"results",
"."
] | python | train |
sibirrer/lenstronomy | lenstronomy/ImSim/MultiBand/multiband.py | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/MultiBand/multiband.py#L54-L71 | def likelihood_data_given_model(self, kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps, source_marg=False):
"""
computes the likelihood of the data given a model
This is specified with the non-linear parameters and a linear inversion and prior marginalisation.
:param kwargs_lens:... | [
"def",
"likelihood_data_given_model",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_source",
",",
"kwargs_lens_light",
",",
"kwargs_ps",
",",
"source_marg",
"=",
"False",
")",
":",
"# generate image",
"logL",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"self",
"... | computes the likelihood of the data given a model
This is specified with the non-linear parameters and a linear inversion and prior marginalisation.
:param kwargs_lens:
:param kwargs_source:
:param kwargs_lens_light:
:param kwargs_ps:
:return: log likelihood (natural loga... | [
"computes",
"the",
"likelihood",
"of",
"the",
"data",
"given",
"a",
"model",
"This",
"is",
"specified",
"with",
"the",
"non",
"-",
"linear",
"parameters",
"and",
"a",
"linear",
"inversion",
"and",
"prior",
"marginalisation",
".",
":",
"param",
"kwargs_lens",
... | python | train |
saltstack/salt | salt/states/win_dacl.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_dacl.py#L191-L222 | def disinherit(name, objectType, copy_inherited_acl=True):
'''
Ensure an object is not inheriting ACLs from its parent
'''
ret = {'name': name,
'result': True,
'changes': {},
'comment': ''}
tRet = __salt__['win_dacl.check_inheritance'](name, objectType)
if tRet['... | [
"def",
"disinherit",
"(",
"name",
",",
"objectType",
",",
"copy_inherited_acl",
"=",
"True",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
"}",
"tRet",
"=... | Ensure an object is not inheriting ACLs from its parent | [
"Ensure",
"an",
"object",
"is",
"not",
"inheriting",
"ACLs",
"from",
"its",
"parent"
] | python | train |
cihai/cihai | examples/variants.py | https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/examples/variants.py#L15-L34 | def run(unihan_options={}):
"""Wrapped so we can test in tests/test_examples.py"""
print("This example prints variant character data.")
c = Cihai()
if not c.unihan.is_bootstrapped: # download and install Unihan to db
c.unihan.bootstrap(unihan_options)
c.unihan.add_plugin(
'cihai.d... | [
"def",
"run",
"(",
"unihan_options",
"=",
"{",
"}",
")",
":",
"print",
"(",
"\"This example prints variant character data.\"",
")",
"c",
"=",
"Cihai",
"(",
")",
"if",
"not",
"c",
".",
"unihan",
".",
"is_bootstrapped",
":",
"# download and install Unihan to db",
... | Wrapped so we can test in tests/test_examples.py | [
"Wrapped",
"so",
"we",
"can",
"test",
"in",
"tests",
"/",
"test_examples",
".",
"py"
] | python | train |
googlemaps/google-maps-services-python | googlemaps/convert.py | https://github.com/googlemaps/google-maps-services-python/blob/7ed40b4d8df63479794c46ce29d03ed6083071d7/googlemaps/convert.py#L156-L164 | def _is_list(arg):
"""Checks if arg is list-like. This excludes strings and dicts."""
if isinstance(arg, dict):
return False
if isinstance(arg, str): # Python 3-only, as str has __iter__
return False
return (not _has_method(arg, "strip")
and _has_method(arg, "__getitem__")
... | [
"def",
"_is_list",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"return",
"False",
"if",
"isinstance",
"(",
"arg",
",",
"str",
")",
":",
"# Python 3-only, as str has __iter__",
"return",
"False",
"return",
"(",
"not",
"_has_... | Checks if arg is list-like. This excludes strings and dicts. | [
"Checks",
"if",
"arg",
"is",
"list",
"-",
"like",
".",
"This",
"excludes",
"strings",
"and",
"dicts",
"."
] | python | train |
glitchassassin/lackey | lackey/RegionMatching.py | https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/RegionMatching.py#L922-L942 | def paste(self, *args):
""" Usage: paste([PSMRL], text)
If a pattern is specified, the pattern is clicked first. Doesn't support text paths.
``text`` is pasted as is using the OS paste shortcut (Ctrl+V for Windows/Linux, Cmd+V
for OS X). Note that `paste()` does NOT use special formatti... | [
"def",
"paste",
"(",
"self",
",",
"*",
"args",
")",
":",
"target",
"=",
"None",
"text",
"=",
"\"\"",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"basestring",
")",
":",
"text",
"=",
"args",
"[... | Usage: paste([PSMRL], text)
If a pattern is specified, the pattern is clicked first. Doesn't support text paths.
``text`` is pasted as is using the OS paste shortcut (Ctrl+V for Windows/Linux, Cmd+V
for OS X). Note that `paste()` does NOT use special formatting like `type()`. | [
"Usage",
":",
"paste",
"(",
"[",
"PSMRL",
"]",
"text",
")"
] | python | train |
kivy/python-for-android | pythonforandroid/build.py | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/build.py#L596-L806 | def run_pymodules_install(ctx, modules, project_dir, ignore_setup_py=False):
""" This function will take care of all non-recipe things, by:
1. Processing them from --requirements (the modules argument)
and installing them
2. Installing the user project/app itself via setup.py if
... | [
"def",
"run_pymodules_install",
"(",
"ctx",
",",
"modules",
",",
"project_dir",
",",
"ignore_setup_py",
"=",
"False",
")",
":",
"info",
"(",
"'*** PYTHON PACKAGE / PROJECT INSTALL STAGE ***'",
")",
"modules",
"=",
"list",
"(",
"filter",
"(",
"ctx",
".",
"not_has_p... | This function will take care of all non-recipe things, by:
1. Processing them from --requirements (the modules argument)
and installing them
2. Installing the user project/app itself via setup.py if
ignore_setup_py=True | [
"This",
"function",
"will",
"take",
"care",
"of",
"all",
"non",
"-",
"recipe",
"things",
"by",
":"
] | python | train |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L173-L189 | def shot_taskfile_sel_changed(self, tf):
"""Callback for when the version selection has changed
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileInfo` | None
:returns: None
:rtype: None
:raises: None
"""
self.shot_open_pb.setEnabled(bool(tf)... | [
"def",
"shot_taskfile_sel_changed",
"(",
"self",
",",
"tf",
")",
":",
"self",
".",
"shot_open_pb",
".",
"setEnabled",
"(",
"bool",
"(",
"tf",
")",
")",
"# only allow new, if the releasetype is work",
"# only allow new, if there is a shot. if there is a shot, there should alwa... | Callback for when the version selection has changed
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileInfo` | None
:returns: None
:rtype: None
:raises: None | [
"Callback",
"for",
"when",
"the",
"version",
"selection",
"has",
"changed"
] | python | train |
onelogin/python3-saml | src/onelogin/saml2/utils.py | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/utils.py#L986-L1009 | def sign_binary(msg, key, algorithm=xmlsec.Transform.RSA_SHA1, debug=False):
"""
Sign binary message
:param msg: The element we should validate
:type: bytes
:param key: The private key
:type: string
:param debug: Activate the xmlsec debug
:type: bool
... | [
"def",
"sign_binary",
"(",
"msg",
",",
"key",
",",
"algorithm",
"=",
"xmlsec",
".",
"Transform",
".",
"RSA_SHA1",
",",
"debug",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"msg",
",",
"str",
")",
":",
"msg",
"=",
"msg",
".",
"encode",
"(",
"'u... | Sign binary message
:param msg: The element we should validate
:type: bytes
:param key: The private key
:type: string
:param debug: Activate the xmlsec debug
:type: bool
:return signed message
:rtype str | [
"Sign",
"binary",
"message"
] | python | train |
libtcod/python-tcod | tdl/__init__.py | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/__init__.py#L342-L376 | def write(self, string):
"""This method mimics basic file-like behaviour.
Because of this method you can replace sys.stdout or sys.stderr with
a :any:`Console` or :any:`Window` instance.
This is a convoluted process and behaviour seen now can be excepted to
change on later vers... | [
"def",
"write",
"(",
"self",
",",
"string",
")",
":",
"# some 'basic' line buffer stuff.",
"# there must be an easier way to do this. The textwrap module didn't",
"# help much.",
"x",
",",
"y",
"=",
"self",
".",
"_normalizeCursor",
"(",
"*",
"self",
".",
"_cursor",
")"... | This method mimics basic file-like behaviour.
Because of this method you can replace sys.stdout or sys.stderr with
a :any:`Console` or :any:`Window` instance.
This is a convoluted process and behaviour seen now can be excepted to
change on later versions.
Args:
str... | [
"This",
"method",
"mimics",
"basic",
"file",
"-",
"like",
"behaviour",
"."
] | python | train |
jd/tenacity | tenacity/compat.py | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L82-L94 | def func_takes_last_result(waiter):
"""Check if function has a "last_result" parameter.
Needed to provide backward compatibility for wait functions that didn't
take "last_result" in the beginning.
"""
if not six.callable(waiter):
return False
if not inspect.isfunction(waiter) and not in... | [
"def",
"func_takes_last_result",
"(",
"waiter",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"waiter",
")",
":",
"return",
"False",
"if",
"not",
"inspect",
".",
"isfunction",
"(",
"waiter",
")",
"and",
"not",
"inspect",
".",
"ismethod",
"(",
"wait... | Check if function has a "last_result" parameter.
Needed to provide backward compatibility for wait functions that didn't
take "last_result" in the beginning. | [
"Check",
"if",
"function",
"has",
"a",
"last_result",
"parameter",
"."
] | python | train |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/text/clean_text.py | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/text/clean_text.py#L324-L334 | def separate_camel_case(word, first_cap_re, all_cap_re):
"""
What it says on the tin.
Input: - word: A string that may be in camelCase.
Output: - separated_word: A list of strings with camel case separated.
"""
s1 = first_cap_re.sub(r'\1 \2', word)
separated_word = all_cap_re.sub(r'\1 \2'... | [
"def",
"separate_camel_case",
"(",
"word",
",",
"first_cap_re",
",",
"all_cap_re",
")",
":",
"s1",
"=",
"first_cap_re",
".",
"sub",
"(",
"r'\\1 \\2'",
",",
"word",
")",
"separated_word",
"=",
"all_cap_re",
".",
"sub",
"(",
"r'\\1 \\2'",
",",
"s1",
")",
"re... | What it says on the tin.
Input: - word: A string that may be in camelCase.
Output: - separated_word: A list of strings with camel case separated. | [
"What",
"it",
"says",
"on",
"the",
"tin",
"."
] | python | train |
nsqio/pynsq | nsq/event.py | https://github.com/nsqio/pynsq/blob/48bf62d65ea63cddaa401efb23187b95511dbc84/nsq/event.py#L73-L84 | def trigger(self, name, *args, **kwargs):
"""
Execute the callbacks for the listeners on the specified event with the
supplied arguments.
All extra arguments are passed through to each callback.
:param name: the name of the event
:type name: string
"""
f... | [
"def",
"trigger",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"ev",
"in",
"self",
".",
"__listeners",
"[",
"name",
"]",
":",
"ev",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Execute the callbacks for the listeners on the specified event with the
supplied arguments.
All extra arguments are passed through to each callback.
:param name: the name of the event
:type name: string | [
"Execute",
"the",
"callbacks",
"for",
"the",
"listeners",
"on",
"the",
"specified",
"event",
"with",
"the",
"supplied",
"arguments",
"."
] | python | test |
euske/pdfminer | pdfminer/utils.py | https://github.com/euske/pdfminer/blob/8150458718e9024c80b00e74965510b20206e588/pdfminer/utils.py#L107-L110 | def csort(objs, key):
"""Order-preserving sorting function."""
idxs = dict((obj, i) for (i, obj) in enumerate(objs))
return sorted(objs, key=lambda obj: (key(obj), idxs[obj])) | [
"def",
"csort",
"(",
"objs",
",",
"key",
")",
":",
"idxs",
"=",
"dict",
"(",
"(",
"obj",
",",
"i",
")",
"for",
"(",
"i",
",",
"obj",
")",
"in",
"enumerate",
"(",
"objs",
")",
")",
"return",
"sorted",
"(",
"objs",
",",
"key",
"=",
"lambda",
"o... | Order-preserving sorting function. | [
"Order",
"-",
"preserving",
"sorting",
"function",
"."
] | python | train |
ceph/ceph-deploy | vendor.py | https://github.com/ceph/ceph-deploy/blob/86943fcc454cd4c99a86e3493e9e93a59c661fef/vendor.py#L83-L90 | def clean_vendor(name):
"""
Ensure that vendored code/dirs are removed, possibly when packaging when
the environment flag is set to avoid vendoring.
"""
this_dir = path.dirname(path.abspath(__file__))
vendor_dest = path.join(this_dir, 'ceph_deploy/lib/vendor/%s' % name)
run(['rm', '-rf', ven... | [
"def",
"clean_vendor",
"(",
"name",
")",
":",
"this_dir",
"=",
"path",
".",
"dirname",
"(",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
"vendor_dest",
"=",
"path",
".",
"join",
"(",
"this_dir",
",",
"'ceph_deploy/lib/vendor/%s'",
"%",
"name",
")",
... | Ensure that vendored code/dirs are removed, possibly when packaging when
the environment flag is set to avoid vendoring. | [
"Ensure",
"that",
"vendored",
"code",
"/",
"dirs",
"are",
"removed",
"possibly",
"when",
"packaging",
"when",
"the",
"environment",
"flag",
"is",
"set",
"to",
"avoid",
"vendoring",
"."
] | python | train |
peterdemin/pip-compile-multi | pipcompilemulti/cli_v2.py | https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/cli_v2.py#L38-L46 | def verify(ctx):
"""Upgrade locked dependency versions"""
oks = run_configurations(
skipper(verify_environments),
read_sections,
)
ctx.exit(0
if False not in oks
else 1) | [
"def",
"verify",
"(",
"ctx",
")",
":",
"oks",
"=",
"run_configurations",
"(",
"skipper",
"(",
"verify_environments",
")",
",",
"read_sections",
",",
")",
"ctx",
".",
"exit",
"(",
"0",
"if",
"False",
"not",
"in",
"oks",
"else",
"1",
")"
] | Upgrade locked dependency versions | [
"Upgrade",
"locked",
"dependency",
"versions"
] | python | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1339-L1356 | def set_init_score(self, init_score):
"""Set init score of Booster to start from.
Parameters
----------
init_score : list, numpy 1-D array, pandas Series or None
Init score for Booster.
Returns
-------
self : Dataset
Dataset with set init... | [
"def",
"set_init_score",
"(",
"self",
",",
"init_score",
")",
":",
"self",
".",
"init_score",
"=",
"init_score",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
"and",
"init_score",
"is",
"not",
"None",
":",
"init_score",
"=",
"list_to_1d_numpy",
"(",
"i... | Set init score of Booster to start from.
Parameters
----------
init_score : list, numpy 1-D array, pandas Series or None
Init score for Booster.
Returns
-------
self : Dataset
Dataset with set init score. | [
"Set",
"init",
"score",
"of",
"Booster",
"to",
"start",
"from",
"."
] | python | train |
b-ryan/powerline-shell | powerline_shell/__init__.py | https://github.com/b-ryan/powerline-shell/blob/a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc/powerline_shell/__init__.py#L30-L54 | def get_valid_cwd():
"""Determine and check the current working directory for validity.
Typically, an directory arises when you checkout a different branch on git
that doesn't have this directory. When an invalid directory is found, a
warning is printed to the screen, but the directory is still returne... | [
"def",
"get_valid_cwd",
"(",
")",
":",
"try",
":",
"cwd",
"=",
"_current_dir",
"(",
")",
"except",
":",
"warn",
"(",
"\"Your current directory is invalid. If you open a ticket at \"",
"+",
"\"https://github.com/milkbikis/powerline-shell/issues/new \"",
"+",
"\"we would love t... | Determine and check the current working directory for validity.
Typically, an directory arises when you checkout a different branch on git
that doesn't have this directory. When an invalid directory is found, a
warning is printed to the screen, but the directory is still returned
as-is, since this is w... | [
"Determine",
"and",
"check",
"the",
"current",
"working",
"directory",
"for",
"validity",
"."
] | python | train |
michaelpb/omnic | omnic/web/viewer.py | https://github.com/michaelpb/omnic/blob/1111cfd73c9dc1955afe42d9cf2a468c46f83cd6/omnic/web/viewer.py#L40-L56 | def get_resource(self):
'''
Returns a BytesResource to build the viewers JavaScript
'''
# Basename could be used for controlling caching
# basename = 'viewers_%s' % settings.get_cache_string()
node_packages = self.get_node_packages()
# sort_keys is essential to en... | [
"def",
"get_resource",
"(",
"self",
")",
":",
"# Basename could be used for controlling caching",
"# basename = 'viewers_%s' % settings.get_cache_string()",
"node_packages",
"=",
"self",
".",
"get_node_packages",
"(",
")",
"# sort_keys is essential to ensure resulting string is",
"# ... | Returns a BytesResource to build the viewers JavaScript | [
"Returns",
"a",
"BytesResource",
"to",
"build",
"the",
"viewers",
"JavaScript"
] | python | train |
PiotrDabkowski/Js2Py | js2py/legecy_translators/translator.py | https://github.com/PiotrDabkowski/Js2Py/blob/c0fa43f5679cf91ca8986c5747fcb07a433dc584/js2py/legecy_translators/translator.py#L10-L70 | def translate_js(js, top=TOP_GLOBAL):
"""js has to be a javascript source code.
returns equivalent python code."""
# Remove constant literals
no_const, constants = remove_constants(js)
#print 'const count', len(constants)
# Remove object literals
no_obj, objects, obj_count = remove_object... | [
"def",
"translate_js",
"(",
"js",
",",
"top",
"=",
"TOP_GLOBAL",
")",
":",
"# Remove constant literals",
"no_const",
",",
"constants",
"=",
"remove_constants",
"(",
"js",
")",
"#print 'const count', len(constants)",
"# Remove object literals",
"no_obj",
",",
"objects",
... | js has to be a javascript source code.
returns equivalent python code. | [
"js",
"has",
"to",
"be",
"a",
"javascript",
"source",
"code",
".",
"returns",
"equivalent",
"python",
"code",
"."
] | python | valid |
markovmodel/PyEMMA | pyemma/coordinates/data/featurization/featurizer.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/data/featurization/featurizer.py#L586-L622 | def add_group_mindist(self, group_definitions, group_pairs='all', threshold=None, periodic=True):
r"""
Adds the minimum distance between groups of atoms to the feature list. If the groups of
atoms are identical to residues, use :py:obj:`add_residue_mindist <pyemma.coordinates.data.featurizer.MDF... | [
"def",
"add_group_mindist",
"(",
"self",
",",
"group_definitions",
",",
"group_pairs",
"=",
"'all'",
",",
"threshold",
"=",
"None",
",",
"periodic",
"=",
"True",
")",
":",
"from",
".",
"distances",
"import",
"GroupMinDistanceFeature",
"# Some thorough input checking... | r"""
Adds the minimum distance between groups of atoms to the feature list. If the groups of
atoms are identical to residues, use :py:obj:`add_residue_mindist <pyemma.coordinates.data.featurizer.MDFeaturizer.add_residue_mindist>`.
Parameters
----------
group_definitions : list ... | [
"r",
"Adds",
"the",
"minimum",
"distance",
"between",
"groups",
"of",
"atoms",
"to",
"the",
"feature",
"list",
".",
"If",
"the",
"groups",
"of",
"atoms",
"are",
"identical",
"to",
"residues",
"use",
":",
"py",
":",
"obj",
":",
"add_residue_mindist",
"<pyem... | python | train |
architv/soccer-cli | soccer/writers.py | https://github.com/architv/soccer-cli/blob/472e9f492f7633a8e9739e228a6c31de454da88b/soccer/writers.py#L220-L228 | def live_scores(self, live_scores):
"""Store output of live scores to a CSV file"""
headers = ['League', 'Home Team Name', 'Home Team Goals',
'Away Team Goals', 'Away Team Name']
result = [headers]
result.extend([game['league'], game['homeTeamName'],
... | [
"def",
"live_scores",
"(",
"self",
",",
"live_scores",
")",
":",
"headers",
"=",
"[",
"'League'",
",",
"'Home Team Name'",
",",
"'Home Team Goals'",
",",
"'Away Team Goals'",
",",
"'Away Team Name'",
"]",
"result",
"=",
"[",
"headers",
"]",
"result",
".",
"ext... | Store output of live scores to a CSV file | [
"Store",
"output",
"of",
"live",
"scores",
"to",
"a",
"CSV",
"file"
] | python | train |
IdentityPython/pysaml2 | src/saml2/ident.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/ident.py#L49-L56 | def code_binary(item):
"""
Return a binary 'code' suitable for hashing.
"""
code_str = code(item)
if isinstance(code_str, six.string_types):
return code_str.encode('utf-8')
return code_str | [
"def",
"code_binary",
"(",
"item",
")",
":",
"code_str",
"=",
"code",
"(",
"item",
")",
"if",
"isinstance",
"(",
"code_str",
",",
"six",
".",
"string_types",
")",
":",
"return",
"code_str",
".",
"encode",
"(",
"'utf-8'",
")",
"return",
"code_str"
] | Return a binary 'code' suitable for hashing. | [
"Return",
"a",
"binary",
"code",
"suitable",
"for",
"hashing",
"."
] | python | train |
klen/pyserve | pyserve/bottle.py | https://github.com/klen/pyserve/blob/5942ff2eb41566fd39d73abbd3e5c7caa7366aa8/pyserve/bottle.py#L968-L974 | def cookies(self):
""" Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT
decoded. Use :meth:`get_cookie` if you expect signed cookies. """
cookies = SimpleCookie(self.environ.get('HTTP_COOKIE','')).values()
if len(cookies) > self.MAX_PARAMS:
raise HTTPError... | [
"def",
"cookies",
"(",
"self",
")",
":",
"cookies",
"=",
"SimpleCookie",
"(",
"self",
".",
"environ",
".",
"get",
"(",
"'HTTP_COOKIE'",
",",
"''",
")",
")",
".",
"values",
"(",
")",
"if",
"len",
"(",
"cookies",
")",
">",
"self",
".",
"MAX_PARAMS",
... | Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT
decoded. Use :meth:`get_cookie` if you expect signed cookies. | [
"Cookies",
"parsed",
"into",
"a",
":",
"class",
":",
"FormsDict",
".",
"Signed",
"cookies",
"are",
"NOT",
"decoded",
".",
"Use",
":",
"meth",
":",
"get_cookie",
"if",
"you",
"expect",
"signed",
"cookies",
"."
] | python | train |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/__notebook_support__.py | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/__notebook_support__.py#L1304-L1389 | def plot_resp_slow(signal, rect_signal, sample_rate):
"""
-----
Brief
-----
Figure intended to represent the acquired RIP signal together with a rectangular signal defining
inhalation and exhalation periods.
-----------
Description
-----------
Function design to generate a Bokeh... | [
"def",
"plot_resp_slow",
"(",
"signal",
",",
"rect_signal",
",",
"sample_rate",
")",
":",
"signal",
"=",
"numpy",
".",
"array",
"(",
"signal",
")",
"-",
"numpy",
".",
"average",
"(",
"signal",
")",
"rect_signal",
"=",
"numpy",
".",
"array",
"(",
"rect_si... | -----
Brief
-----
Figure intended to represent the acquired RIP signal together with a rectangular signal defining
inhalation and exhalation periods.
-----------
Description
-----------
Function design to generate a Bokeh figure containing the evolution of RIP signal, when
slow resp... | [
"-----",
"Brief",
"-----",
"Figure",
"intended",
"to",
"represent",
"the",
"acquired",
"RIP",
"signal",
"together",
"with",
"a",
"rectangular",
"signal",
"defining",
"inhalation",
"and",
"exhalation",
"periods",
"."
] | python | train |
PyCQA/astroid | astroid/builder.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/builder.py#L193-L214 | def add_from_names_to_locals(self, node):
"""Store imported names to the locals
Resort the locals if coming from a delayed node
"""
_key_func = lambda node: node.fromlineno
def sort_locals(my_list):
my_list.sort(key=_key_func)
for (name, asname) in node.nam... | [
"def",
"add_from_names_to_locals",
"(",
"self",
",",
"node",
")",
":",
"_key_func",
"=",
"lambda",
"node",
":",
"node",
".",
"fromlineno",
"def",
"sort_locals",
"(",
"my_list",
")",
":",
"my_list",
".",
"sort",
"(",
"key",
"=",
"_key_func",
")",
"for",
"... | Store imported names to the locals
Resort the locals if coming from a delayed node | [
"Store",
"imported",
"names",
"to",
"the",
"locals"
] | python | train |
quantumlib/Cirq | cirq/circuits/_bucket_priority_queue.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/_bucket_priority_queue.py#L86-L130 | def enqueue(self, priority: int, item: TItem) -> bool:
"""Adds an entry to the priority queue.
If drop_duplicate_entries is set and there is already a (priority, item)
entry in the queue, then the enqueue is ignored. Check the return value
to determine if an enqueue was kept or dropped.... | [
"def",
"enqueue",
"(",
"self",
",",
"priority",
":",
"int",
",",
"item",
":",
"TItem",
")",
"->",
"bool",
":",
"if",
"self",
".",
"_drop_set",
"is",
"not",
"None",
":",
"if",
"(",
"priority",
",",
"item",
")",
"in",
"self",
".",
"_drop_set",
":",
... | Adds an entry to the priority queue.
If drop_duplicate_entries is set and there is already a (priority, item)
entry in the queue, then the enqueue is ignored. Check the return value
to determine if an enqueue was kept or dropped.
Args:
priority: The priority of the item. Lo... | [
"Adds",
"an",
"entry",
"to",
"the",
"priority",
"queue",
"."
] | python | train |
dslackw/slpkg | slpkg/init.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/init.py#L712-L716 | def file_remove(self, path, filename):
"""Check if filename exists and remove
"""
if os.path.isfile(path + filename):
os.remove(path + filename) | [
"def",
"file_remove",
"(",
"self",
",",
"path",
",",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
"+",
"filename",
")",
":",
"os",
".",
"remove",
"(",
"path",
"+",
"filename",
")"
] | Check if filename exists and remove | [
"Check",
"if",
"filename",
"exists",
"and",
"remove"
] | python | train |
suds-community/suds | suds/xsd/sxbasic.py | https://github.com/suds-community/suds/blob/6fb0a829337b5037a66c20aae6f89b41acd77e40/suds/xsd/sxbasic.py#L443-L459 | def namespace(self, prefix=None):
"""
Get this schema element's target namespace.
In case of reference elements, the target namespace is defined by the
referenced and not the referencing element node.
@param prefix: The default prefix.
@type prefix: str
@return:... | [
"def",
"namespace",
"(",
"self",
",",
"prefix",
"=",
"None",
")",
":",
"e",
"=",
"self",
".",
"__deref",
"(",
")",
"if",
"e",
"is",
"not",
"None",
":",
"return",
"e",
".",
"namespace",
"(",
"prefix",
")",
"return",
"super",
"(",
"Element",
",",
"... | Get this schema element's target namespace.
In case of reference elements, the target namespace is defined by the
referenced and not the referencing element node.
@param prefix: The default prefix.
@type prefix: str
@return: The schema element's target namespace
@rtype:... | [
"Get",
"this",
"schema",
"element",
"s",
"target",
"namespace",
"."
] | python | train |
kolypto/py-good | good/schema/compiler.py | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L173-L190 | def sub_compile(self, schema, path=None, matcher=False):
""" Compile a sub-schema
:param schema: Validation schema
:type schema: *
:param path: Path to this schema, if any
:type path: list|None
:param matcher: Compile a matcher?
:type matcher: bool
:rtype... | [
"def",
"sub_compile",
"(",
"self",
",",
"schema",
",",
"path",
"=",
"None",
",",
"matcher",
"=",
"False",
")",
":",
"return",
"type",
"(",
"self",
")",
"(",
"schema",
",",
"self",
".",
"path",
"+",
"(",
"path",
"or",
"[",
"]",
")",
",",
"None",
... | Compile a sub-schema
:param schema: Validation schema
:type schema: *
:param path: Path to this schema, if any
:type path: list|None
:param matcher: Compile a matcher?
:type matcher: bool
:rtype: CompiledSchema | [
"Compile",
"a",
"sub",
"-",
"schema"
] | python | train |
loganasherjones/yapconf | yapconf/spec.py | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/spec.py#L211-L225 | def get_item(self, name, bootstrap=False):
"""Get a particular item in the specification.
Args:
name (str): The name of the item to retrieve.
bootstrap (bool): Only search bootstrap items
Returns (YapconfItem):
A YapconfItem if it is found, None otherwise.
... | [
"def",
"get_item",
"(",
"self",
",",
"name",
",",
"bootstrap",
"=",
"False",
")",
":",
"for",
"item",
"in",
"self",
".",
"_get_items",
"(",
"bootstrap",
")",
":",
"if",
"item",
".",
"name",
"==",
"name",
":",
"return",
"item",
"return",
"None"
] | Get a particular item in the specification.
Args:
name (str): The name of the item to retrieve.
bootstrap (bool): Only search bootstrap items
Returns (YapconfItem):
A YapconfItem if it is found, None otherwise. | [
"Get",
"a",
"particular",
"item",
"in",
"the",
"specification",
"."
] | python | train |
rocky/python-uncompyle6 | uncompyle6/verify.py | https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/verify.py#L417-L425 | def compare_files(pyc_filename1, pyc_filename2, verify):
"""Compare two .pyc files."""
(version1, timestamp, magic_int1, code_obj1, is_pypy,
source_size) = uncompyle6.load_module(pyc_filename1)
(version2, timestamp, magic_int2, code_obj2, is_pypy,
source_size) = uncompyle6.load_module(pyc_filen... | [
"def",
"compare_files",
"(",
"pyc_filename1",
",",
"pyc_filename2",
",",
"verify",
")",
":",
"(",
"version1",
",",
"timestamp",
",",
"magic_int1",
",",
"code_obj1",
",",
"is_pypy",
",",
"source_size",
")",
"=",
"uncompyle6",
".",
"load_module",
"(",
"pyc_filen... | Compare two .pyc files. | [
"Compare",
"two",
".",
"pyc",
"files",
"."
] | python | train |
sanoma/django-arctic | arctic/generics.py | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L563-L575 | def get_ordering(self):
"""Ordering used for queryset filtering (should not contain prefix)."""
if self.sorting_field:
return [self.sorting_field]
prefix = self.get_prefix()
fields = self.get_ordering_with_prefix()
if self.prefix:
fields = [f.replace(prefi... | [
"def",
"get_ordering",
"(",
"self",
")",
":",
"if",
"self",
".",
"sorting_field",
":",
"return",
"[",
"self",
".",
"sorting_field",
"]",
"prefix",
"=",
"self",
".",
"get_prefix",
"(",
")",
"fields",
"=",
"self",
".",
"get_ordering_with_prefix",
"(",
")",
... | Ordering used for queryset filtering (should not contain prefix). | [
"Ordering",
"used",
"for",
"queryset",
"filtering",
"(",
"should",
"not",
"contain",
"prefix",
")",
"."
] | python | train |
crytic/slither | slither/__main__.py | https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/__main__.py#L38-L53 | def process(filename, args, detector_classes, printer_classes):
"""
The core high-level code for running Slither static analysis.
Returns:
list(result), int: Result list and number of contracts analyzed
"""
ast = '--ast-compact-json'
if args.legacy_ast:
ast = '--ast-json'
ar... | [
"def",
"process",
"(",
"filename",
",",
"args",
",",
"detector_classes",
",",
"printer_classes",
")",
":",
"ast",
"=",
"'--ast-compact-json'",
"if",
"args",
".",
"legacy_ast",
":",
"ast",
"=",
"'--ast-json'",
"args",
".",
"filter_paths",
"=",
"parse_filter_paths... | The core high-level code for running Slither static analysis.
Returns:
list(result), int: Result list and number of contracts analyzed | [
"The",
"core",
"high",
"-",
"level",
"code",
"for",
"running",
"Slither",
"static",
"analysis",
"."
] | python | train |
numenta/nupic | src/nupic/data/utils.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/utils.py#L207-L215 | def parseStringList(s):
"""
Parse a string of space-separated numbers, returning a Python list.
:param s: (string) to parse
:returns: (list) binary SDR
"""
assert isinstance(s, basestring)
return [int(i) for i in s.split()] | [
"def",
"parseStringList",
"(",
"s",
")",
":",
"assert",
"isinstance",
"(",
"s",
",",
"basestring",
")",
"return",
"[",
"int",
"(",
"i",
")",
"for",
"i",
"in",
"s",
".",
"split",
"(",
")",
"]"
] | Parse a string of space-separated numbers, returning a Python list.
:param s: (string) to parse
:returns: (list) binary SDR | [
"Parse",
"a",
"string",
"of",
"space",
"-",
"separated",
"numbers",
"returning",
"a",
"Python",
"list",
"."
] | python | valid |
pyviz/holoviews | holoviews/util/parser.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/util/parser.py#L349-L362 | def parse_options(cls, line, ns={}):
"""
Similar to parse but returns a list of Options objects instead
of the dictionary format.
"""
parsed = cls.parse(line, ns=ns)
options_list = []
for spec in sorted(parsed.keys()):
options = parsed[spec]
... | [
"def",
"parse_options",
"(",
"cls",
",",
"line",
",",
"ns",
"=",
"{",
"}",
")",
":",
"parsed",
"=",
"cls",
".",
"parse",
"(",
"line",
",",
"ns",
"=",
"ns",
")",
"options_list",
"=",
"[",
"]",
"for",
"spec",
"in",
"sorted",
"(",
"parsed",
".",
"... | Similar to parse but returns a list of Options objects instead
of the dictionary format. | [
"Similar",
"to",
"parse",
"but",
"returns",
"a",
"list",
"of",
"Options",
"objects",
"instead",
"of",
"the",
"dictionary",
"format",
"."
] | python | train |
trailofbits/manticore | manticore/platforms/decree.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/decree.py#L798-L831 | def wait(self, readfds, writefds, timeout):
""" Wait for filedescriptors or timeout.
Adds the current process to the corresponding waiting list and
yields the cpu to another running process.
"""
logger.info("WAIT:")
logger.info("\tProcess %d is going to wait for [... | [
"def",
"wait",
"(",
"self",
",",
"readfds",
",",
"writefds",
",",
"timeout",
")",
":",
"logger",
".",
"info",
"(",
"\"WAIT:\"",
")",
"logger",
".",
"info",
"(",
"\"\\tProcess %d is going to wait for [ %r %r %r ]\"",
",",
"self",
".",
"_current",
",",
"readfds"... | Wait for filedescriptors or timeout.
Adds the current process to the corresponding waiting list and
yields the cpu to another running process. | [
"Wait",
"for",
"filedescriptors",
"or",
"timeout",
".",
"Adds",
"the",
"current",
"process",
"to",
"the",
"corresponding",
"waiting",
"list",
"and",
"yields",
"the",
"cpu",
"to",
"another",
"running",
"process",
"."
] | python | valid |
maximkulkin/lollipop | lollipop/types.py | https://github.com/maximkulkin/lollipop/blob/042e8a24508cc3b28630863253c38ffbfc52c882/lollipop/types.py#L1534-L1550 | def validate_for(self, obj, data, *args, **kwargs):
"""Takes target object and serialized data, tries to update that object
with data and validate result. Returns validation errors or None.
Object is not updated.
:param obj: Object to check data validity against. In case the data is
... | [
"def",
"validate_for",
"(",
"self",
",",
"obj",
",",
"data",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"load_into",
"(",
"obj",
",",
"data",
",",
"inplace",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwa... | Takes target object and serialized data, tries to update that object
with data and validate result. Returns validation errors or None.
Object is not updated.
:param obj: Object to check data validity against. In case the data is
partial object is used to get the rest of data from.
... | [
"Takes",
"target",
"object",
"and",
"serialized",
"data",
"tries",
"to",
"update",
"that",
"object",
"with",
"data",
"and",
"validate",
"result",
".",
"Returns",
"validation",
"errors",
"or",
"None",
".",
"Object",
"is",
"not",
"updated",
"."
] | python | train |
neurodata/ndio | ndio/remote/ndingest.py | https://github.com/neurodata/ndio/blob/792dd5816bc770b05a3db2f4327da42ff6253531/ndio/remote/ndingest.py#L220-L236 | def dataset_dict(
self, dataset_name, imagesize, voxelres,
offset, timerange, scalinglevels, scaling):
"""Generate the dataset dictionary"""
dataset_dict = {}
dataset_dict['dataset_name'] = dataset_name
dataset_dict['imagesize'] = imagesize
dataset_dict['voxel... | [
"def",
"dataset_dict",
"(",
"self",
",",
"dataset_name",
",",
"imagesize",
",",
"voxelres",
",",
"offset",
",",
"timerange",
",",
"scalinglevels",
",",
"scaling",
")",
":",
"dataset_dict",
"=",
"{",
"}",
"dataset_dict",
"[",
"'dataset_name'",
"]",
"=",
"data... | Generate the dataset dictionary | [
"Generate",
"the",
"dataset",
"dictionary"
] | python | test |
vtkiorg/vtki | vtki/plotting.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/plotting.py#L2308-L2369 | def screenshot(self, filename=None, transparent_background=None,
return_img=None, window_size=None):
"""
Takes screenshot at current camera position
Parameters
----------
filename : str, optional
Location to write image to. If None, no image is wr... | [
"def",
"screenshot",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"transparent_background",
"=",
"None",
",",
"return_img",
"=",
"None",
",",
"window_size",
"=",
"None",
")",
":",
"if",
"window_size",
"is",
"not",
"None",
":",
"self",
".",
"window_size"... | Takes screenshot at current camera position
Parameters
----------
filename : str, optional
Location to write image to. If None, no image is written.
transparent_background : bool, optional
Makes the background transparent. Default False.
return_img : ... | [
"Takes",
"screenshot",
"at",
"current",
"camera",
"position"
] | python | train |
pvlib/pvlib-python | pvlib/tracking.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/tracking.py#L260-L580 | def singleaxis(apparent_zenith, apparent_azimuth,
axis_tilt=0, axis_azimuth=0, max_angle=90,
backtrack=True, gcr=2.0/7.0):
"""
Determine the rotation angle of a single axis tracker using the
equations in [1] when given a particular sun zenith and azimuth
angle. backtracking... | [
"def",
"singleaxis",
"(",
"apparent_zenith",
",",
"apparent_azimuth",
",",
"axis_tilt",
"=",
"0",
",",
"axis_azimuth",
"=",
"0",
",",
"max_angle",
"=",
"90",
",",
"backtrack",
"=",
"True",
",",
"gcr",
"=",
"2.0",
"/",
"7.0",
")",
":",
"# MATLAB to Python c... | Determine the rotation angle of a single axis tracker using the
equations in [1] when given a particular sun zenith and azimuth
angle. backtracking may be specified, and if so, a ground coverage
ratio is required.
Rotation angle is determined in a panel-oriented coordinate system.
The tracker azimu... | [
"Determine",
"the",
"rotation",
"angle",
"of",
"a",
"single",
"axis",
"tracker",
"using",
"the",
"equations",
"in",
"[",
"1",
"]",
"when",
"given",
"a",
"particular",
"sun",
"zenith",
"and",
"azimuth",
"angle",
".",
"backtracking",
"may",
"be",
"specified",
... | python | train |
sixty-north/asq | asq/queryables.py | https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1537-L1567 | def first(self, predicate=None):
'''The first element in a sequence (optionally satisfying a predicate).
If the predicate is omitted or is None this query returns the first
element in the sequence; otherwise, it returns the first element in
the sequence for which the predicate evaluates... | [
"def",
"first",
"(",
"self",
",",
"predicate",
"=",
"None",
")",
":",
"if",
"self",
".",
"closed",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"Attempt to call first() on a closed Queryable.\"",
")",
"return",
"self",
".",
"_first",
"(",
")",
"if",
"predica... | The first element in a sequence (optionally satisfying a predicate).
If the predicate is omitted or is None this query returns the first
element in the sequence; otherwise, it returns the first element in
the sequence for which the predicate evaluates to True. Exceptions are
raised if t... | [
"The",
"first",
"element",
"in",
"a",
"sequence",
"(",
"optionally",
"satisfying",
"a",
"predicate",
")",
"."
] | python | train |
erijo/tellcore-py | tellcore/telldus.py | https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L478-L486 | def value(self, datatype):
"""Return the :class:`SensorValue` for the given data type.
sensor.value(TELLSTICK_TEMPERATURE) is identical to calling
sensor.temperature().
"""
value = self.lib.tdSensorValue(
self.protocol, self.model, self.id, datatype)
return S... | [
"def",
"value",
"(",
"self",
",",
"datatype",
")",
":",
"value",
"=",
"self",
".",
"lib",
".",
"tdSensorValue",
"(",
"self",
".",
"protocol",
",",
"self",
".",
"model",
",",
"self",
".",
"id",
",",
"datatype",
")",
"return",
"SensorValue",
"(",
"data... | Return the :class:`SensorValue` for the given data type.
sensor.value(TELLSTICK_TEMPERATURE) is identical to calling
sensor.temperature(). | [
"Return",
"the",
":",
"class",
":",
"SensorValue",
"for",
"the",
"given",
"data",
"type",
"."
] | python | train |
acutesoftware/AIKIF | aikif/ontology/cyc_extract.py | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/ontology/cyc_extract.py#L75-L80 | def create_sample_file(ip, op, num_lines):
""" make a short version of an RDF file """
with open(ip, "rb") as f:
with open(op, "wb") as fout:
for _ in range(num_lines):
fout.write(f.readline() ) | [
"def",
"create_sample_file",
"(",
"ip",
",",
"op",
",",
"num_lines",
")",
":",
"with",
"open",
"(",
"ip",
",",
"\"rb\"",
")",
"as",
"f",
":",
"with",
"open",
"(",
"op",
",",
"\"wb\"",
")",
"as",
"fout",
":",
"for",
"_",
"in",
"range",
"(",
"num_l... | make a short version of an RDF file | [
"make",
"a",
"short",
"version",
"of",
"an",
"RDF",
"file"
] | python | train |
helixyte/everest | everest/repositories/memory/cache.py | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/memory/cache.py#L118-L133 | def retrieve(self, filter_expression=None,
order_expression=None, slice_key=None):
"""
Retrieve entities from this cache, possibly after filtering, ordering
and slicing.
"""
ents = iter(self.__entities)
if not filter_expression is None:
ents =... | [
"def",
"retrieve",
"(",
"self",
",",
"filter_expression",
"=",
"None",
",",
"order_expression",
"=",
"None",
",",
"slice_key",
"=",
"None",
")",
":",
"ents",
"=",
"iter",
"(",
"self",
".",
"__entities",
")",
"if",
"not",
"filter_expression",
"is",
"None",
... | Retrieve entities from this cache, possibly after filtering, ordering
and slicing. | [
"Retrieve",
"entities",
"from",
"this",
"cache",
"possibly",
"after",
"filtering",
"ordering",
"and",
"slicing",
"."
] | python | train |
gwpy/gwpy | gwpy/types/io/hdf5.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/types/io/hdf5.py#L226-L233 | def write_hdf5_series(series, output, path=None, attrs=None, **kwargs):
"""Write a Series to HDF5.
See :func:`write_hdf5_array` for details of arguments and keywords.
"""
if attrs is None:
attrs = format_index_array_attrs(series)
return write_hdf5_array(series, output, path=path, attrs=attr... | [
"def",
"write_hdf5_series",
"(",
"series",
",",
"output",
",",
"path",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"attrs",
"is",
"None",
":",
"attrs",
"=",
"format_index_array_attrs",
"(",
"series",
")",
"return",
... | Write a Series to HDF5.
See :func:`write_hdf5_array` for details of arguments and keywords. | [
"Write",
"a",
"Series",
"to",
"HDF5",
"."
] | python | train |
odlgroup/odl | odl/util/vectorization.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/util/vectorization.py#L62-L68 | def out_shape_from_array(arr):
"""Get the output shape from an array."""
arr = np.asarray(arr)
if arr.ndim == 1:
return arr.shape
else:
return (arr.shape[1],) | [
"def",
"out_shape_from_array",
"(",
"arr",
")",
":",
"arr",
"=",
"np",
".",
"asarray",
"(",
"arr",
")",
"if",
"arr",
".",
"ndim",
"==",
"1",
":",
"return",
"arr",
".",
"shape",
"else",
":",
"return",
"(",
"arr",
".",
"shape",
"[",
"1",
"]",
",",
... | Get the output shape from an array. | [
"Get",
"the",
"output",
"shape",
"from",
"an",
"array",
"."
] | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L9149-L9163 | def attitude_send(self, time_boot_ms, roll, pitch, yaw, rollspeed, pitchspeed, yawspeed, force_mavlink1=False):
'''
The attitude in the aeronautical frame (right-handed, Z-down, X-front,
Y-right).
time_boot_ms : Timestamp (milliseconds since ... | [
"def",
"attitude_send",
"(",
"self",
",",
"time_boot_ms",
",",
"roll",
",",
"pitch",
",",
"yaw",
",",
"rollspeed",
",",
"pitchspeed",
",",
"yawspeed",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"attitu... | The attitude in the aeronautical frame (right-handed, Z-down, X-front,
Y-right).
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
roll : Roll angle (rad, -pi..+pi) (float)
pitch : P... | [
"The",
"attitude",
"in",
"the",
"aeronautical",
"frame",
"(",
"right",
"-",
"handed",
"Z",
"-",
"down",
"X",
"-",
"front",
"Y",
"-",
"right",
")",
"."
] | python | train |
ungarj/mapchete | mapchete/formats/default/gtiff.py | https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/formats/default/gtiff.py#L271-L281 | def open(self, tile, process, **kwargs):
"""
Open process output as input for other process.
Parameters
----------
tile : ``Tile``
process : ``MapcheteProcess``
kwargs : keyword arguments
"""
return InputTile(tile, process, kwargs.get("resampling"... | [
"def",
"open",
"(",
"self",
",",
"tile",
",",
"process",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"InputTile",
"(",
"tile",
",",
"process",
",",
"kwargs",
".",
"get",
"(",
"\"resampling\"",
",",
"None",
")",
")"
] | Open process output as input for other process.
Parameters
----------
tile : ``Tile``
process : ``MapcheteProcess``
kwargs : keyword arguments | [
"Open",
"process",
"output",
"as",
"input",
"for",
"other",
"process",
"."
] | python | valid |
Hackerfleet/hfos | hfos/tool/templates.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/templates.py#L27-L39 | def format_template(template, content):
"""Render a given pystache template
with given content"""
import pystache
result = u""
if True: # try:
result = pystache.render(template, content, string_encoding='utf-8')
# except (ValueError, KeyError) as e:
# print("Templating error: %s... | [
"def",
"format_template",
"(",
"template",
",",
"content",
")",
":",
"import",
"pystache",
"result",
"=",
"u\"\"",
"if",
"True",
":",
"# try:",
"result",
"=",
"pystache",
".",
"render",
"(",
"template",
",",
"content",
",",
"string_encoding",
"=",
"'utf-8'",... | Render a given pystache template
with given content | [
"Render",
"a",
"given",
"pystache",
"template",
"with",
"given",
"content"
] | python | train |
HDI-Project/MLBlocks | mlblocks/mlpipeline.py | https://github.com/HDI-Project/MLBlocks/blob/e1ca77bce3c4537c0800a4c1395e1b6bbde5465d/mlblocks/mlpipeline.py#L276-L323 | def to_dict(self):
"""Return all the details of this MLPipeline in a dict.
The dict structure contains all the `__init__` arguments of the
MLPipeline, as well as the current hyperparameter values and the
specification of the tunable_hyperparameters::
{
"prim... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'primitives'",
":",
"self",
".",
"primitives",
",",
"'init_params'",
":",
"self",
".",
"init_params",
",",
"'input_names'",
":",
"self",
".",
"input_names",
",",
"'output_names'",
":",
"self",
".",
"... | Return all the details of this MLPipeline in a dict.
The dict structure contains all the `__init__` arguments of the
MLPipeline, as well as the current hyperparameter values and the
specification of the tunable_hyperparameters::
{
"primitives": [
... | [
"Return",
"all",
"the",
"details",
"of",
"this",
"MLPipeline",
"in",
"a",
"dict",
"."
] | python | train |
getpelican/pelican-plugins | slim/slim.py | https://github.com/getpelican/pelican-plugins/blob/cfc7a3f224f1743063b034561f89a6a712d13587/slim/slim.py#L154-L173 | def register():
"""Plugin registration."""
if not plim:
logger.warning('`slim` failed to load dependency `plim`. '
'`slim` plugin not loaded.')
return
if not mako:
logger.warning('`slim` failed to load dependency `mako`. '
'`slim` plugin ... | [
"def",
"register",
"(",
")",
":",
"if",
"not",
"plim",
":",
"logger",
".",
"warning",
"(",
"'`slim` failed to load dependency `plim`. '",
"'`slim` plugin not loaded.'",
")",
"return",
"if",
"not",
"mako",
":",
"logger",
".",
"warning",
"(",
"'`slim` failed to load d... | Plugin registration. | [
"Plugin",
"registration",
"."
] | python | train |
v1k45/python-qBittorrent | qbittorrent/client.py | https://github.com/v1k45/python-qBittorrent/blob/04f9482a022dcc78c56b0b9acb9ca455f855ae24/qbittorrent/client.py#L609-L616 | def toggle_sequential_download(self, infohash_list):
"""
Toggle sequential download in supplied torrents.
:param infohash_list: Single or list() of infohashes.
"""
data = self._process_infohash_list(infohash_list)
return self._post('command/toggleSequentialDownload', dat... | [
"def",
"toggle_sequential_download",
"(",
"self",
",",
"infohash_list",
")",
":",
"data",
"=",
"self",
".",
"_process_infohash_list",
"(",
"infohash_list",
")",
"return",
"self",
".",
"_post",
"(",
"'command/toggleSequentialDownload'",
",",
"data",
"=",
"data",
")... | Toggle sequential download in supplied torrents.
:param infohash_list: Single or list() of infohashes. | [
"Toggle",
"sequential",
"download",
"in",
"supplied",
"torrents",
"."
] | python | train |
heikomuller/sco-datastore | scodata/__init__.py | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L200-L226 | def experiments_fmri_delete(self, experiment_id):
"""Delete fMRI data object associated with given experiment.
Raises ValueError if an attempt is made to delete a read-only resource.
Parameters
----------
experiment_id : string
Unique experiment identifier
... | [
"def",
"experiments_fmri_delete",
"(",
"self",
",",
"experiment_id",
")",
":",
"# Get experiment fMRI to ensure that it exists",
"fmri",
"=",
"self",
".",
"experiments_fmri_get",
"(",
"experiment_id",
")",
"if",
"fmri",
"is",
"None",
":",
"return",
"None",
"# Delete r... | Delete fMRI data object associated with given experiment.
Raises ValueError if an attempt is made to delete a read-only resource.
Parameters
----------
experiment_id : string
Unique experiment identifier
Returns
-------
FMRIDataHandle
Ha... | [
"Delete",
"fMRI",
"data",
"object",
"associated",
"with",
"given",
"experiment",
"."
] | python | train |
deepmind/sonnet | sonnet/python/modules/conv.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2270-L2295 | def _construct_w(self, inputs):
"""Construct the convolution weight matrix.
Figures out the shape of the weight matrix, initialize it, and return it.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
Returns:
w: A weight matri... | [
"def",
"_construct_w",
"(",
"self",
",",
"inputs",
")",
":",
"weight_shape",
"=",
"self",
".",
"_kernel_shape",
"+",
"(",
"1",
",",
"1",
")",
"if",
"\"w\"",
"not",
"in",
"self",
".",
"_initializers",
":",
"self",
".",
"_initializers",
"[",
"\"w\"",
"]"... | Construct the convolution weight matrix.
Figures out the shape of the weight matrix, initialize it, and return it.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
Returns:
w: A weight matrix of the same type as `inputs` and of s... | [
"Construct",
"the",
"convolution",
"weight",
"matrix",
"."
] | python | train |
aaugustin/django-sesame | sesame/backends.py | https://github.com/aaugustin/django-sesame/blob/4bf902c637b0674b8fc78bc95937271948c99282/sesame/backends.py#L58-L67 | def unsign(self, token):
"""
Extract the data from a signed ``token``.
"""
if self.max_age is None:
data = self.signer.unsign(token)
else:
data = self.signer.unsign(token, max_age=self.max_age)
return signing.b64_decode(data.encode()) | [
"def",
"unsign",
"(",
"self",
",",
"token",
")",
":",
"if",
"self",
".",
"max_age",
"is",
"None",
":",
"data",
"=",
"self",
".",
"signer",
".",
"unsign",
"(",
"token",
")",
"else",
":",
"data",
"=",
"self",
".",
"signer",
".",
"unsign",
"(",
"tok... | Extract the data from a signed ``token``. | [
"Extract",
"the",
"data",
"from",
"a",
"signed",
"token",
"."
] | python | train |
bwohlberg/sporco | docs/source/docntbk.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/docs/source/docntbk.py#L914-L959 | def substitute_ref_with_url(self, txt):
"""
In the string `txt`, replace sphinx references with
corresponding links to online docs.
"""
# Find sphinx cross-references
mi = re.finditer(r':([^:]+):`([^`]+)`', txt)
if mi:
# Iterate over match objects in ... | [
"def",
"substitute_ref_with_url",
"(",
"self",
",",
"txt",
")",
":",
"# Find sphinx cross-references",
"mi",
"=",
"re",
".",
"finditer",
"(",
"r':([^:]+):`([^`]+)`'",
",",
"txt",
")",
"if",
"mi",
":",
"# Iterate over match objects in iterator returned by re.finditer",
"... | In the string `txt`, replace sphinx references with
corresponding links to online docs. | [
"In",
"the",
"string",
"txt",
"replace",
"sphinx",
"references",
"with",
"corresponding",
"links",
"to",
"online",
"docs",
"."
] | python | train |
SmokinCaterpillar/pypet | examples/example_17_wrapping_an_existing_project/pypetwrap.py | https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/examples/example_17_wrapping_an_existing_project/pypetwrap.py#L34-L49 | def wrap_automaton(traj):
""" Simple wrapper function for compatibility with *pypet*.
We will call the original simulation functions with data extracted from ``traj``.
The resulting automaton patterns wil also be stored into the trajectory.
:param traj: Trajectory container for data
"""
# Ma... | [
"def",
"wrap_automaton",
"(",
"traj",
")",
":",
"# Make initial state",
"initial_state",
"=",
"make_initial_state",
"(",
"traj",
".",
"initial_name",
",",
"traj",
".",
"ncells",
",",
"traj",
".",
"seed",
")",
"# Run simulation",
"pattern",
"=",
"cellular_automaton... | Simple wrapper function for compatibility with *pypet*.
We will call the original simulation functions with data extracted from ``traj``.
The resulting automaton patterns wil also be stored into the trajectory.
:param traj: Trajectory container for data | [
"Simple",
"wrapper",
"function",
"for",
"compatibility",
"with",
"*",
"pypet",
"*",
"."
] | python | test |
wavycloud/pyboto3 | pyboto3/rds.py | https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/rds.py#L8639-L8941 | def restore_db_instance_from_db_snapshot(DBInstanceIdentifier=None, DBSnapshotIdentifier=None, DBInstanceClass=None, Port=None, AvailabilityZone=None, DBSubnetGroupName=None, MultiAZ=None, PubliclyAccessible=None, AutoMinorVersionUpgrade=None, LicenseModel=None, DBName=None, Engine=None, Iops=None, OptionGroupName=None... | [
"def",
"restore_db_instance_from_db_snapshot",
"(",
"DBInstanceIdentifier",
"=",
"None",
",",
"DBSnapshotIdentifier",
"=",
"None",
",",
"DBInstanceClass",
"=",
"None",
",",
"Port",
"=",
"None",
",",
"AvailabilityZone",
"=",
"None",
",",
"DBSubnetGroupName",
"=",
"No... | Creates a new DB instance from a DB snapshot. The target database is created from the source database restore point with the most of original configuration with the default security group and the default DB parameter group. By default, the new DB instance is created as a single-AZ deployment except when the instance is... | [
"Creates",
"a",
"new",
"DB",
"instance",
"from",
"a",
"DB",
"snapshot",
".",
"The",
"target",
"database",
"is",
"created",
"from",
"the",
"source",
"database",
"restore",
"point",
"with",
"the",
"most",
"of",
"original",
"configuration",
"with",
"the",
"defa... | python | train |
mwickert/scikit-dsp-comm | sk_dsp_comm/fir_design_helper.py | https://github.com/mwickert/scikit-dsp-comm/blob/5c1353412a4d81a8d7da169057564ecf940f8b5b/sk_dsp_comm/fir_design_helper.py#L373-L396 | def fir_remez_bsf(f_pass1, f_stop1, f_stop2, f_pass2, d_pass, d_stop,
fs = 1.0, N_bump=5):
"""
Design an FIR bandstop filter using remez with order
determination. The filter order is determined based on
f_pass1 Hz, f_stop1 Hz, f_stop2 Hz, f_pass2 Hz, and the
desired passba... | [
"def",
"fir_remez_bsf",
"(",
"f_pass1",
",",
"f_stop1",
",",
"f_stop2",
",",
"f_pass2",
",",
"d_pass",
",",
"d_stop",
",",
"fs",
"=",
"1.0",
",",
"N_bump",
"=",
"5",
")",
":",
"n",
",",
"ff",
",",
"aa",
",",
"wts",
"=",
"bandstop_order",
"(",
"f_pa... | Design an FIR bandstop filter using remez with order
determination. The filter order is determined based on
f_pass1 Hz, f_stop1 Hz, f_stop2 Hz, f_pass2 Hz, and the
desired passband ripple d_pass dB and stopband attenuation
d_stop dB all relative to a sampling rate of fs Hz.
Mark Wickert Oct... | [
"Design",
"an",
"FIR",
"bandstop",
"filter",
"using",
"remez",
"with",
"order",
"determination",
".",
"The",
"filter",
"order",
"is",
"determined",
"based",
"on",
"f_pass1",
"Hz",
"f_stop1",
"Hz",
"f_stop2",
"Hz",
"f_pass2",
"Hz",
"and",
"the",
"desired",
"p... | python | valid |
arista-eosplus/pyeapi | pyeapi/api/staticroute.py | https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/api/staticroute.py#L182-L201 | def create(self, ip_dest, next_hop, **kwargs):
"""Create a static route
Args:
ip_dest (string): The ip address of the destination in the
form of A.B.C.D/E
next_hop (string): The next hop interface or ip address
**kwargs['next_hop_ip'] (string): The ne... | [
"def",
"create",
"(",
"self",
",",
"ip_dest",
",",
"next_hop",
",",
"*",
"*",
"kwargs",
")",
":",
"# Call _set_route with delete and default set to False",
"return",
"self",
".",
"_set_route",
"(",
"ip_dest",
",",
"next_hop",
",",
"*",
"*",
"kwargs",
")"
] | Create a static route
Args:
ip_dest (string): The ip address of the destination in the
form of A.B.C.D/E
next_hop (string): The next hop interface or ip address
**kwargs['next_hop_ip'] (string): The next hop address on
destination interface
... | [
"Create",
"a",
"static",
"route"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.