repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
tkem/uritools | uritools/split.py | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/split.py#L189-L199 | def getquerydict(self, sep='&', encoding='utf-8', errors='strict'):
"""Split the query component into individual `name=value` pairs
separated by `sep` and return a dictionary of query variables.
The dictionary keys are the unique query variable names and
the values are lists of values fo... | [
"def",
"getquerydict",
"(",
"self",
",",
"sep",
"=",
"'&'",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"dict",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"name",
",",
"value",
"in",
"self",
".",
"... | Split the query component into individual `name=value` pairs
separated by `sep` and return a dictionary of query variables.
The dictionary keys are the unique query variable names and
the values are lists of values for each name. | [
"Split",
"the",
"query",
"component",
"into",
"individual",
"name",
"=",
"value",
"pairs",
"separated",
"by",
"sep",
"and",
"return",
"a",
"dictionary",
"of",
"query",
"variables",
".",
"The",
"dictionary",
"keys",
"are",
"the",
"unique",
"query",
"variable",
... | python | train | 46 |
BlueHack-Core/blueforge | blueforge/util/file.py | https://github.com/BlueHack-Core/blueforge/blob/ac40a888ee9c388638a8f312c51f7500b8891b6c/blueforge/util/file.py#L69-L81 | def move_file(originals, destination):
"""
Move file from original path to destination path.
:type originals: Array of str
:param originals: The original path
:type destination: str
:param destination: The destination path
"""
for original in originals:
if o... | [
"def",
"move_file",
"(",
"originals",
",",
"destination",
")",
":",
"for",
"original",
"in",
"originals",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"original",
")",
":",
"shutil",
".",
"move",
"(",
"original",
",",
"destination",
")"
] | Move file from original path to destination path.
:type originals: Array of str
:param originals: The original path
:type destination: str
:param destination: The destination path | [
"Move",
"file",
"from",
"original",
"path",
"to",
"destination",
"path",
"."
] | python | train | 29.153846 |
Calysto/calysto | calysto/ai/conx.py | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2128-L2136 | def activationFunctionASIG(self, x):
"""
Determine the activation of a node based on that nodes net input.
"""
def act(v):
if v < -15.0: return 0.0
elif v > 15.0: return 1.0
else: return 1.0 / (1.0 + Numeric.exp(-v))
return Numeric.array(lis... | [
"def",
"activationFunctionASIG",
"(",
"self",
",",
"x",
")",
":",
"def",
"act",
"(",
"v",
")",
":",
"if",
"v",
"<",
"-",
"15.0",
":",
"return",
"0.0",
"elif",
"v",
">",
"15.0",
":",
"return",
"1.0",
"else",
":",
"return",
"1.0",
"/",
"(",
"1.0",
... | Determine the activation of a node based on that nodes net input. | [
"Determine",
"the",
"activation",
"of",
"a",
"node",
"based",
"on",
"that",
"nodes",
"net",
"input",
"."
] | python | train | 36.888889 |
Jajcus/pyxmpp2 | pyxmpp2/ext/vcard.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/vcard.py#L1172-L1186 | def as_xml(self,parent):
"""Create vcard-tmp XML representation of the field.
:Parameters:
- `parent`: parent node for the element
:Types:
- `parent`: `libxml2.xmlNode`
:return: xml node with the field data.
:returntype: `libxml2.xmlNode`"""
if s... | [
"def",
"as_xml",
"(",
"self",
",",
"parent",
")",
":",
"if",
"self",
".",
"value",
"in",
"(",
"\"public\"",
",",
"\"private\"",
",",
"\"confidental\"",
")",
":",
"n",
"=",
"parent",
".",
"newChild",
"(",
"None",
",",
"self",
".",
"name",
".",
"upper"... | Create vcard-tmp XML representation of the field.
:Parameters:
- `parent`: parent node for the element
:Types:
- `parent`: `libxml2.xmlNode`
:return: xml node with the field data.
:returntype: `libxml2.xmlNode` | [
"Create",
"vcard",
"-",
"tmp",
"XML",
"representation",
"of",
"the",
"field",
"."
] | python | valid | 33.8 |
koordinates/python-client | koordinates/base.py | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L610-L621 | def refresh(self):
"""
Refresh this model from the server.
Updates attributes with the server-defined values. This is useful where the Model
instance came from a partial response (eg. a list query) and additional details
are required.
Existing attribute values will be o... | [
"def",
"refresh",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_client",
".",
"request",
"(",
"'GET'",
",",
"self",
".",
"url",
")",
"return",
"self",
".",
"_deserialize",
"(",
"r",
".",
"json",
"(",
")",
",",
"self",
".",
"_manager",
")"
] | Refresh this model from the server.
Updates attributes with the server-defined values. This is useful where the Model
instance came from a partial response (eg. a list query) and additional details
are required.
Existing attribute values will be overwritten. | [
"Refresh",
"this",
"model",
"from",
"the",
"server",
"."
] | python | train | 36.666667 |
iotile/coretools | iotilesensorgraph/iotile/sg/processors.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/processors.py#L13-L31 | def copy_all_a(input_a, *other_inputs, **kwargs):
"""Copy all readings in input a into the output.
All other inputs are skipped so that after this function runs there are no
readings left in any of the input walkers when the function finishes, even
if it generated no output readings.
Returns:
... | [
"def",
"copy_all_a",
"(",
"input_a",
",",
"*",
"other_inputs",
",",
"*",
"*",
"kwargs",
")",
":",
"output",
"=",
"[",
"]",
"while",
"input_a",
".",
"count",
"(",
")",
">",
"0",
":",
"output",
".",
"append",
"(",
"input_a",
".",
"pop",
"(",
")",
"... | Copy all readings in input a into the output.
All other inputs are skipped so that after this function runs there are no
readings left in any of the input walkers when the function finishes, even
if it generated no output readings.
Returns:
list(IOTileReading) | [
"Copy",
"all",
"readings",
"in",
"input",
"a",
"into",
"the",
"output",
"."
] | python | train | 26.210526 |
KelSolaar/Umbra | umbra/ui/widgets/active_QLabel.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/active_QLabel.py#L203-L214 | def active_pixmap(self, value):
"""
Setter for **self.__active_pixmap** attribute.
:param value: Attribute value.
:type value: QPixmap
"""
if value is not None:
assert type(value) is QPixmap, "'{0}' attribute: '{1}' type is not 'QPixmap'!".format(
... | [
"def",
"active_pixmap",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"QPixmap",
",",
"\"'{0}' attribute: '{1}' type is not 'QPixmap'!\"",
".",
"format",
"(",
"\"active_pixmap\"",
",",
... | Setter for **self.__active_pixmap** attribute.
:param value: Attribute value.
:type value: QPixmap | [
"Setter",
"for",
"**",
"self",
".",
"__active_pixmap",
"**",
"attribute",
"."
] | python | train | 31.25 |
vertexproject/synapse | synapse/cortex.py | https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/cortex.py#L225-L231 | async def updateTrigger(self, iden, query):
'''
Change an existing trigger's query
'''
trig = self.cell.triggers.get(iden)
self._trig_auth_check(trig.get('useriden'))
self.cell.triggers.mod(iden, query) | [
"async",
"def",
"updateTrigger",
"(",
"self",
",",
"iden",
",",
"query",
")",
":",
"trig",
"=",
"self",
".",
"cell",
".",
"triggers",
".",
"get",
"(",
"iden",
")",
"self",
".",
"_trig_auth_check",
"(",
"trig",
".",
"get",
"(",
"'useriden'",
")",
")",... | Change an existing trigger's query | [
"Change",
"an",
"existing",
"trigger",
"s",
"query"
] | python | train | 34.857143 |
vatlab/SoS | src/sos/dag.py | https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/src/sos/dag.py#L184-L222 | def find_executable(self):
'''Find an executable node, which means nodes that has not been completed
and has no input dependency.'''
if 'DAG' in env.config['SOS_DEBUG'] or 'ALL' in env.config['SOS_DEBUG']:
env.log_to_file('DAG', 'find_executable')
for node in self.nodes():
... | [
"def",
"find_executable",
"(",
"self",
")",
":",
"if",
"'DAG'",
"in",
"env",
".",
"config",
"[",
"'SOS_DEBUG'",
"]",
"or",
"'ALL'",
"in",
"env",
".",
"config",
"[",
"'SOS_DEBUG'",
"]",
":",
"env",
".",
"log_to_file",
"(",
"'DAG'",
",",
"'find_executable'... | Find an executable node, which means nodes that has not been completed
and has no input dependency. | [
"Find",
"an",
"executable",
"node",
"which",
"means",
"nodes",
"that",
"has",
"not",
"been",
"completed",
"and",
"has",
"no",
"input",
"dependency",
"."
] | python | train | 48.487179 |
datosgobar/pydatajson | pydatajson/core.py | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L153-L189 | def _build_index(self):
"""Itera todos los datasets, distribucioens y fields indexandolos."""
datasets_index = {}
distributions_index = {}
fields_index = {}
# recorre todos los datasets
for dataset_index, dataset in enumerate(self.datasets):
if "identifier" ... | [
"def",
"_build_index",
"(",
"self",
")",
":",
"datasets_index",
"=",
"{",
"}",
"distributions_index",
"=",
"{",
"}",
"fields_index",
"=",
"{",
"}",
"# recorre todos los datasets",
"for",
"dataset_index",
",",
"dataset",
"in",
"enumerate",
"(",
"self",
".",
"da... | Itera todos los datasets, distribucioens y fields indexandolos. | [
"Itera",
"todos",
"los",
"datasets",
"distribucioens",
"y",
"fields",
"indexandolos",
"."
] | python | train | 47.702703 |
timknip/pyswf | swf/export.py | https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/export.py#L827-L876 | def export(self, swf, shape, **export_opts):
""" Exports the specified shape of the SWF to SVG.
@param swf The SWF.
@param shape Which shape to export, either by characterId(int) or as a Tag object.
"""
# If `shape` is given as int, find corresponding shape tag.
if is... | [
"def",
"export",
"(",
"self",
",",
"swf",
",",
"shape",
",",
"*",
"*",
"export_opts",
")",
":",
"# If `shape` is given as int, find corresponding shape tag.",
"if",
"isinstance",
"(",
"shape",
",",
"Tag",
")",
":",
"shape_tag",
"=",
"shape",
"else",
":",
"shap... | Exports the specified shape of the SWF to SVG.
@param swf The SWF.
@param shape Which shape to export, either by characterId(int) or as a Tag object. | [
"Exports",
"the",
"specified",
"shape",
"of",
"the",
"SWF",
"to",
"SVG",
"."
] | python | train | 38.8 |
Robpol86/libnl | libnl/nl80211/iw_scan.py | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl80211/iw_scan.py#L341-L367 | def get_ht_op(_, data):
"""http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n766.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict.
"""
protection = ('no', 'nonmember', 20, 'non-HT mixed')
sta_chan_width = (20, 'any')
answers = {
... | [
"def",
"get_ht_op",
"(",
"_",
",",
"data",
")",
":",
"protection",
"=",
"(",
"'no'",
",",
"'nonmember'",
",",
"20",
",",
"'non-HT mixed'",
")",
"sta_chan_width",
"=",
"(",
"20",
",",
"'any'",
")",
"answers",
"=",
"{",
"'primary channel'",
":",
"data",
... | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n766.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | [
"http",
":",
"//",
"git",
".",
"kernel",
".",
"org",
"/",
"cgit",
"/",
"linux",
"/",
"kernel",
"/",
"git",
"/",
"jberg",
"/",
"iw",
".",
"git",
"/",
"tree",
"/",
"scan",
".",
"c?id",
"=",
"v3",
".",
"17#n766",
"."
] | python | train | 35.37037 |
HazyResearch/fonduer | src/fonduer/parser/spacy_parser.py | https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/parser/spacy_parser.py#L87-L104 | def model_installed(name):
"""Check if spaCy language model is installed.
From https://github.com/explosion/spaCy/blob/master/spacy/util.py
:param name:
:return:
"""
data_path = util.get_data_path()
if not data_path or not data_path.exists():
raise I... | [
"def",
"model_installed",
"(",
"name",
")",
":",
"data_path",
"=",
"util",
".",
"get_data_path",
"(",
")",
"if",
"not",
"data_path",
"or",
"not",
"data_path",
".",
"exists",
"(",
")",
":",
"raise",
"IOError",
"(",
"f\"Can't find spaCy data path: {data_path}\"",
... | Check if spaCy language model is installed.
From https://github.com/explosion/spaCy/blob/master/spacy/util.py
:param name:
:return: | [
"Check",
"if",
"spaCy",
"language",
"model",
"is",
"installed",
"."
] | python | train | 34.833333 |
diffeo/rejester | rejester/_task_master.py | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L745-L771 | def idle_all_workers(self):
'''Set the global mode to :attr:`IDLE` and wait for workers to stop.
This can wait arbitrarily long before returning. The worst
case in "normal" usage involves waiting five minutes for a
"lost" job to expire; a well-behaved but very-long-running job
... | [
"def",
"idle_all_workers",
"(",
"self",
")",
":",
"self",
".",
"set_mode",
"(",
"self",
".",
"IDLE",
")",
"while",
"1",
":",
"num_pending",
"=",
"dict",
"(",
")",
"for",
"work_spec_name",
"in",
"self",
".",
"registry",
".",
"pull",
"(",
"NICE_LEVELS",
... | Set the global mode to :attr:`IDLE` and wait for workers to stop.
This can wait arbitrarily long before returning. The worst
case in "normal" usage involves waiting five minutes for a
"lost" job to expire; a well-behaved but very-long-running job
can extend its own lease further, and t... | [
"Set",
"the",
"global",
"mode",
"to",
":",
"attr",
":",
"IDLE",
"and",
"wait",
"for",
"workers",
"to",
"stop",
"."
] | python | train | 46.148148 |
SatelliteQE/nailgun | nailgun/config.py | https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/config.py#L261-L285 | def get_client_kwargs(self):
"""Get kwargs for use with the methods in :mod:`nailgun.client`.
This method returns a dict of attributes that can be unpacked and used
as kwargs via the ``**`` operator. For example::
cfg = ServerConfig.get()
client.get(cfg.url + '/api/v2',... | [
"def",
"get_client_kwargs",
"(",
"self",
")",
":",
"config",
"=",
"vars",
"(",
"self",
")",
".",
"copy",
"(",
")",
"config",
".",
"pop",
"(",
"'url'",
")",
"config",
".",
"pop",
"(",
"'version'",
",",
"None",
")",
"return",
"config"
] | Get kwargs for use with the methods in :mod:`nailgun.client`.
This method returns a dict of attributes that can be unpacked and used
as kwargs via the ``**`` operator. For example::
cfg = ServerConfig.get()
client.get(cfg.url + '/api/v2', **cfg.get_client_kwargs())
Thi... | [
"Get",
"kwargs",
"for",
"use",
"with",
"the",
"methods",
"in",
":",
"mod",
":",
"nailgun",
".",
"client",
"."
] | python | train | 38.76 |
mnboos/airtiler | airtiler/__init__.py | https://github.com/mnboos/airtiler/blob/6e79cdf22c5cd8a9cfffe07b58824fc1d1027104/airtiler/__init__.py#L44-L63 | def _tiles_from_bbox(bbox, zoom_level):
"""
* Returns all tiles for the specified bounding box
"""
if isinstance(bbox, dict):
point_min = Point.from_latitude_longitude(latitude=bbox['tl'], longitude=bbox['tr'])
point_max = Point.from_latitude_longitude(latitude=... | [
"def",
"_tiles_from_bbox",
"(",
"bbox",
",",
"zoom_level",
")",
":",
"if",
"isinstance",
"(",
"bbox",
",",
"dict",
")",
":",
"point_min",
"=",
"Point",
".",
"from_latitude_longitude",
"(",
"latitude",
"=",
"bbox",
"[",
"'tl'",
"]",
",",
"longitude",
"=",
... | * Returns all tiles for the specified bounding box | [
"*",
"Returns",
"all",
"tiles",
"for",
"the",
"specified",
"bounding",
"box"
] | python | train | 49.8 |
genepattern/nbtools | nbtools/jsobject/jsobject.py | https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/jsobject/jsobject.py#L89-L104 | def serialize(self, obj):
"""Serialize an object for sending to the front-end."""
if hasattr(obj, '_jsid'):
return {'immutable': False, 'value': obj._jsid}
else:
obj_json = {'immutable': True}
try:
json.dumps(obj)
obj_json['valu... | [
"def",
"serialize",
"(",
"self",
",",
"obj",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'_jsid'",
")",
":",
"return",
"{",
"'immutable'",
":",
"False",
",",
"'value'",
":",
"obj",
".",
"_jsid",
"}",
"else",
":",
"obj_json",
"=",
"{",
"'immutable'",... | Serialize an object for sending to the front-end. | [
"Serialize",
"an",
"object",
"for",
"sending",
"to",
"the",
"front",
"-",
"end",
"."
] | python | train | 34 |
chaoss/grimoirelab-sortinghat | sortinghat/api.py | https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/api.py#L339-L363 | def delete_unique_identity(db, uuid):
"""Remove a unique identity from the registry.
Function that removes from the registry, the unique identity
that matches with uuid. Data related to this identity will be
also removed.
It checks first whether the unique identity is already on the registry.
... | [
"def",
"delete_unique_identity",
"(",
"db",
",",
"uuid",
")",
":",
"with",
"db",
".",
"connect",
"(",
")",
"as",
"session",
":",
"uidentity",
"=",
"find_unique_identity",
"(",
"session",
",",
"uuid",
")",
"if",
"not",
"uidentity",
":",
"raise",
"NotFoundEr... | Remove a unique identity from the registry.
Function that removes from the registry, the unique identity
that matches with uuid. Data related to this identity will be
also removed.
It checks first whether the unique identity is already on the registry.
When it is found, the unique identity is remo... | [
"Remove",
"a",
"unique",
"identity",
"from",
"the",
"registry",
"."
] | python | train | 34.32 |
miyakogi/wdom | wdom/element.py | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L600-L604 | def hasAttribute(self, attr: str) -> bool:
"""Return True if this node has ``attr``."""
if attr == 'class':
return bool(self.classList)
return attr in self.attributes | [
"def",
"hasAttribute",
"(",
"self",
",",
"attr",
":",
"str",
")",
"->",
"bool",
":",
"if",
"attr",
"==",
"'class'",
":",
"return",
"bool",
"(",
"self",
".",
"classList",
")",
"return",
"attr",
"in",
"self",
".",
"attributes"
] | Return True if this node has ``attr``. | [
"Return",
"True",
"if",
"this",
"node",
"has",
"attr",
"."
] | python | train | 39.6 |
duniter/duniter-python-api | duniterpy/documents/document.py | https://github.com/duniter/duniter-python-api/blob/3a1e5d61a2f72f5afaf29d010c6cf4dff3648165/duniterpy/documents/document.py#L106-L112 | def sha_hash(self) -> str:
"""
Return uppercase hex sha256 hash from signed raw document
:return:
"""
return hashlib.sha256(self.signed_raw().encode("ascii")).hexdigest().upper() | [
"def",
"sha_hash",
"(",
"self",
")",
"->",
"str",
":",
"return",
"hashlib",
".",
"sha256",
"(",
"self",
".",
"signed_raw",
"(",
")",
".",
"encode",
"(",
"\"ascii\"",
")",
")",
".",
"hexdigest",
"(",
")",
".",
"upper",
"(",
")"
] | Return uppercase hex sha256 hash from signed raw document
:return: | [
"Return",
"uppercase",
"hex",
"sha256",
"hash",
"from",
"signed",
"raw",
"document"
] | python | train | 30.428571 |
harlowja/failure | failure/finders.py | https://github.com/harlowja/failure/blob/9ea9a46ebb26c6d7da2553c80e36892f3997bd6f/failure/finders.py#L44-L73 | def match_modules(allowed_modules):
"""Creates a matcher that matches a list/set/tuple of allowed modules."""
cleaned_allowed_modules = [
utils.mod_to_mod_name(tmp_mod)
for tmp_mod in allowed_modules
]
cleaned_split_allowed_modules = [
tmp_mod.split(".")
for tmp_mod in cl... | [
"def",
"match_modules",
"(",
"allowed_modules",
")",
":",
"cleaned_allowed_modules",
"=",
"[",
"utils",
".",
"mod_to_mod_name",
"(",
"tmp_mod",
")",
"for",
"tmp_mod",
"in",
"allowed_modules",
"]",
"cleaned_split_allowed_modules",
"=",
"[",
"tmp_mod",
".",
"split",
... | Creates a matcher that matches a list/set/tuple of allowed modules. | [
"Creates",
"a",
"matcher",
"that",
"matches",
"a",
"list",
"/",
"set",
"/",
"tuple",
"of",
"allowed",
"modules",
"."
] | python | train | 38.3 |
singularityhub/singularity-cli | spython/oci/cmd/states.py | https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/oci/cmd/states.py#L13-L52 | def state(self, container_id=None, sudo=None, sync_socket=None):
''' get the state of an OciImage, if it exists. The optional states that
can be returned are created, running, stopped or (not existing).
Equivalent command line example:
singularity oci state <container_ID>
... | [
"def",
"state",
"(",
"self",
",",
"container_id",
"=",
"None",
",",
"sudo",
"=",
"None",
",",
"sync_socket",
"=",
"None",
")",
":",
"sudo",
"=",
"self",
".",
"_get_sudo",
"(",
"sudo",
")",
"container_id",
"=",
"self",
".",
"get_container_id",
"(",
"con... | get the state of an OciImage, if it exists. The optional states that
can be returned are created, running, stopped or (not existing).
Equivalent command line example:
singularity oci state <container_ID>
Parameters
==========
container_id: the id to g... | [
"get",
"the",
"state",
"of",
"an",
"OciImage",
"if",
"it",
"exists",
".",
"The",
"optional",
"states",
"that",
"can",
"be",
"returned",
"are",
"created",
"running",
"stopped",
"or",
"(",
"not",
"existing",
")",
"."
] | python | train | 32.35 |
sorgerlab/indra | indra/literature/elsevier_client.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/elsevier_client.py#L89-L106 | def check_entitlement(doi):
"""Check whether IP and credentials enable access to content for a doi.
This function uses the entitlement endpoint of the Elsevier API to check
whether an article is available to a given institution. Note that this
feature of the API is itself not available for all institut... | [
"def",
"check_entitlement",
"(",
"doi",
")",
":",
"if",
"doi",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'doi:'",
")",
":",
"doi",
"=",
"doi",
"[",
"4",
":",
"]",
"url",
"=",
"'%s/%s'",
"%",
"(",
"elsevier_entitlement_url",
",",
"doi",
")",
... | Check whether IP and credentials enable access to content for a doi.
This function uses the entitlement endpoint of the Elsevier API to check
whether an article is available to a given institution. Note that this
feature of the API is itself not available for all institution keys. | [
"Check",
"whether",
"IP",
"and",
"credentials",
"enable",
"access",
"to",
"content",
"for",
"a",
"doi",
"."
] | python | train | 44.055556 |
wummel/linkchecker | linkcheck/checker/urlbase.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/urlbase.py#L537-L546 | def allows_simple_recursion(self):
"""Check recursion level and extern status."""
rec_level = self.aggregate.config["recursionlevel"]
if rec_level >= 0 and self.recursion_level >= rec_level:
log.debug(LOG_CHECK, "... no, maximum recursion level reached.")
return False
... | [
"def",
"allows_simple_recursion",
"(",
"self",
")",
":",
"rec_level",
"=",
"self",
".",
"aggregate",
".",
"config",
"[",
"\"recursionlevel\"",
"]",
"if",
"rec_level",
">=",
"0",
"and",
"self",
".",
"recursion_level",
">=",
"rec_level",
":",
"log",
".",
"debu... | Check recursion level and extern status. | [
"Check",
"recursion",
"level",
"and",
"extern",
"status",
"."
] | python | train | 43.1 |
jgillick/LendingClub | lendingclub/session.py | https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/session.py#L292-L296 | def post(self, path, query=None, data=None, redirects=True):
"""
POST request wrapper for :func:`request()`
"""
return self.request('POST', path, query, data, redirects) | [
"def",
"post",
"(",
"self",
",",
"path",
",",
"query",
"=",
"None",
",",
"data",
"=",
"None",
",",
"redirects",
"=",
"True",
")",
":",
"return",
"self",
".",
"request",
"(",
"'POST'",
",",
"path",
",",
"query",
",",
"data",
",",
"redirects",
")"
] | POST request wrapper for :func:`request()` | [
"POST",
"request",
"wrapper",
"for",
":",
"func",
":",
"request",
"()"
] | python | train | 39.4 |
h2oai/h2o-3 | h2o-py/h2o/h2o.py | https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/h2o.py#L1297-L1316 | def as_list(data, use_pandas=True, header=True):
"""
Convert an H2O data object into a python-specific object.
WARNING! This will pull all data local!
If Pandas is available (and use_pandas is True), then pandas will be used to parse the
data frame. Otherwise, a list-of-lists populated by characte... | [
"def",
"as_list",
"(",
"data",
",",
"use_pandas",
"=",
"True",
",",
"header",
"=",
"True",
")",
":",
"assert_is_type",
"(",
"data",
",",
"H2OFrame",
")",
"assert_is_type",
"(",
"use_pandas",
",",
"bool",
")",
"assert_is_type",
"(",
"header",
",",
"bool",
... | Convert an H2O data object into a python-specific object.
WARNING! This will pull all data local!
If Pandas is available (and use_pandas is True), then pandas will be used to parse the
data frame. Otherwise, a list-of-lists populated by character data will be returned (so
the types of data will all be... | [
"Convert",
"an",
"H2O",
"data",
"object",
"into",
"a",
"python",
"-",
"specific",
"object",
"."
] | python | test | 39.6 |
captin411/ofxclient | ofxclient/account.py | https://github.com/captin411/ofxclient/blob/4da2719f0ecbbf5eee62fb82c1b3b34ec955ee5e/ofxclient/account.py#L198-L227 | def from_ofxparse(data, institution):
"""Instantiate :py:class:`ofxclient.Account` subclass from ofxparse
module
:param data: an ofxparse account
:type data: An :py:class:`ofxparse.Account` object
:param institution: The parent institution of the account
:type institutio... | [
"def",
"from_ofxparse",
"(",
"data",
",",
"institution",
")",
":",
"description",
"=",
"data",
".",
"desc",
"if",
"hasattr",
"(",
"data",
",",
"'desc'",
")",
"else",
"None",
"if",
"data",
".",
"type",
"==",
"AccountType",
".",
"Bank",
":",
"return",
"B... | Instantiate :py:class:`ofxclient.Account` subclass from ofxparse
module
:param data: an ofxparse account
:type data: An :py:class:`ofxparse.Account` object
:param institution: The parent institution of the account
:type institution: :py:class:`ofxclient.Institution` object | [
"Instantiate",
":",
"py",
":",
"class",
":",
"ofxclient",
".",
"Account",
"subclass",
"from",
"ofxparse",
"module"
] | python | train | 41.166667 |
vivangkumar/uberpy | uberpy/api.py | https://github.com/vivangkumar/uberpy/blob/abc62ccb5399424eb5690f12c392ab2dbd9d96e0/uberpy/api.py#L105-L138 | def get_json(self, uri_path, http_method='GET', query_parameters=None, body=None, headers=None):
"""
Fetches the JSON returned, after making the call and checking for errors.
:param uri_path: Endpoint to be used to make a request.
:param http_method: HTTP method to be used.
:para... | [
"def",
"get_json",
"(",
"self",
",",
"uri_path",
",",
"http_method",
"=",
"'GET'",
",",
"query_parameters",
"=",
"None",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"query_parameters",
"=",
"query_parameters",
"or",
"{",
"}",
"headers"... | Fetches the JSON returned, after making the call and checking for errors.
:param uri_path: Endpoint to be used to make a request.
:param http_method: HTTP method to be used.
:param query_parameters: Parameters to be added to the request.
:param body: Optional body, if required.
:... | [
"Fetches",
"the",
"JSON",
"returned",
"after",
"making",
"the",
"call",
"and",
"checking",
"for",
"errors",
".",
":",
"param",
"uri_path",
":",
"Endpoint",
"to",
"be",
"used",
"to",
"make",
"a",
"request",
".",
":",
"param",
"http_method",
":",
"HTTP",
"... | python | valid | 38.029412 |
hyperledger/indy-plenum | stp_core/ratchet.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/ratchet.py#L30-L40 | def _sumSeries(a: float, b: float, steps: int) -> float:
"""
Return value of the the following polynomial.
.. math::
(a * e^(b*steps) - 1) / (e^b - 1)
:param a: multiplier
:param b: exponent multiplier
:param steps: the number of steps
"""
retu... | [
"def",
"_sumSeries",
"(",
"a",
":",
"float",
",",
"b",
":",
"float",
",",
"steps",
":",
"int",
")",
"->",
"float",
":",
"return",
"a",
"*",
"(",
"exp",
"(",
"b",
"*",
"steps",
")",
"-",
"1",
")",
"/",
"(",
"exp",
"(",
"b",
")",
"-",
"1",
... | Return value of the the following polynomial.
.. math::
(a * e^(b*steps) - 1) / (e^b - 1)
:param a: multiplier
:param b: exponent multiplier
:param steps: the number of steps | [
"Return",
"value",
"of",
"the",
"the",
"following",
"polynomial",
".",
"..",
"math",
"::",
"(",
"a",
"*",
"e^",
"(",
"b",
"*",
"steps",
")",
"-",
"1",
")",
"/",
"(",
"e^b",
"-",
"1",
")"
] | python | train | 32 |
saltstack/salt | salt/modules/systemd_service.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/systemd_service.py#L1189-L1237 | def disable(name, no_block=False, root=None, **kwargs): # pylint: disable=unused-argument
'''
.. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
On minions running systemd>=205, `systemd-run(1)`_ is now used to
isolate commands run by this function from the ``salt-minion`` daemon's
contro... | [
"def",
"disable",
"(",
"name",
",",
"no_block",
"=",
"False",
",",
"root",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=unused-argument",
"_check_for_unit_changes",
"(",
"name",
")",
"if",
"name",
"in",
"_get_sysv_services",
"(",
"root",
... | .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
On minions running systemd>=205, `systemd-run(1)`_ is now used to
isolate commands run by this function from the ``salt-minion`` daemon's
control group. This is done to avoid a race condition in cases where
the ``salt-minion`` service is r... | [
"..",
"versionchanged",
"::",
"2015",
".",
"8",
".",
"12",
"2016",
".",
"3",
".",
"3",
"2016",
".",
"11",
".",
"0",
"On",
"minions",
"running",
"systemd",
">",
"=",
"205",
"systemd",
"-",
"run",
"(",
"1",
")",
"_",
"is",
"now",
"used",
"to",
"i... | python | train | 42.44898 |
mdickinson/bigfloat | bigfloat/core.py | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L537-L556 | def hex(self):
"""Return a hexadecimal representation of a BigFloat."""
sign = '-' if self._sign() else ''
e = self._exponent()
if isinstance(e, six.string_types):
return sign + e
m = self._significand()
_, digits, _ = _mpfr_get_str2(
16,
... | [
"def",
"hex",
"(",
"self",
")",
":",
"sign",
"=",
"'-'",
"if",
"self",
".",
"_sign",
"(",
")",
"else",
"''",
"e",
"=",
"self",
".",
"_exponent",
"(",
")",
"if",
"isinstance",
"(",
"e",
",",
"six",
".",
"string_types",
")",
":",
"return",
"sign",
... | Return a hexadecimal representation of a BigFloat. | [
"Return",
"a",
"hexadecimal",
"representation",
"of",
"a",
"BigFloat",
"."
] | python | train | 30.2 |
keiichishima/pcalg | pcalg.py | https://github.com/keiichishima/pcalg/blob/f270e2bdb76b88c8f80a1ea07317ff4be88e2359/pcalg.py#L37-L123 | def estimate_skeleton(indep_test_func, data_matrix, alpha, **kwargs):
"""Estimate a skeleton graph from the statistis information.
Args:
indep_test_func: the function name for a conditional
independency test.
data_matrix: data (as a numpy array).
alpha: the significance leve... | [
"def",
"estimate_skeleton",
"(",
"indep_test_func",
",",
"data_matrix",
",",
"alpha",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"method_stable",
"(",
"kwargs",
")",
":",
"return",
"(",
"'method'",
"in",
"kwargs",
")",
"and",
"kwargs",
"[",
"'method'",
"]",... | Estimate a skeleton graph from the statistis information.
Args:
indep_test_func: the function name for a conditional
independency test.
data_matrix: data (as a numpy array).
alpha: the significance level.
kwargs:
'max_reach': maximum value of l (see the code)... | [
"Estimate",
"a",
"skeleton",
"graph",
"from",
"the",
"statistis",
"information",
"."
] | python | train | 39.45977 |
pvlib/pvlib-python | pvlib/forecast.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/forecast.py#L327-L375 | def _netcdf2pandas(self, netcdf_data, query_variables, start, end):
"""
Transforms data from netcdf to pandas DataFrame.
Parameters
----------
data: netcdf
Data returned from UNIDATA NCSS query.
query_variables: list
The variables requested.
... | [
"def",
"_netcdf2pandas",
"(",
"self",
",",
"netcdf_data",
",",
"query_variables",
",",
"start",
",",
"end",
")",
":",
"# set self.time",
"try",
":",
"time_var",
"=",
"'time'",
"self",
".",
"set_time",
"(",
"netcdf_data",
".",
"variables",
"[",
"time_var",
"]... | Transforms data from netcdf to pandas DataFrame.
Parameters
----------
data: netcdf
Data returned from UNIDATA NCSS query.
query_variables: list
The variables requested.
start: Timestamp
The start time
end: Timestamp
The en... | [
"Transforms",
"data",
"from",
"netcdf",
"to",
"pandas",
"DataFrame",
"."
] | python | train | 33.285714 |
okeuday/erlang_py | erlang.py | https://github.com/okeuday/erlang_py/blob/81b7c2ace66b6bdee23602a6802efff541223fa3/erlang.py#L276-L292 | def binary(self):
"""
return encoded representation
"""
creation_size = len(self.creation)
if creation_size == 1:
return (
b_chr(_TAG_PID_EXT) +
self.node.binary() + self.id + self.serial + self.creation
)
elif creat... | [
"def",
"binary",
"(",
"self",
")",
":",
"creation_size",
"=",
"len",
"(",
"self",
".",
"creation",
")",
"if",
"creation_size",
"==",
"1",
":",
"return",
"(",
"b_chr",
"(",
"_TAG_PID_EXT",
")",
"+",
"self",
".",
"node",
".",
"binary",
"(",
")",
"+",
... | return encoded representation | [
"return",
"encoded",
"representation"
] | python | train | 31.647059 |
mwgielen/jackal | jackal/core.py | https://github.com/mwgielen/jackal/blob/7fe62732eb5194b7246215d5277fb37c398097bf/jackal/core.py#L129-L140 | def get_pipe(self, object_type):
"""
Returns a generator that maps the input of the pipe to an elasticsearch object.
Will call id_to_object if it cannot serialize the data from json.
"""
for line in sys.stdin:
try:
data = json.loads(line.strip(... | [
"def",
"get_pipe",
"(",
"self",
",",
"object_type",
")",
":",
"for",
"line",
"in",
"sys",
".",
"stdin",
":",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"line",
".",
"strip",
"(",
")",
")",
"obj",
"=",
"object_type",
"(",
"*",
"*",
"data"... | Returns a generator that maps the input of the pipe to an elasticsearch object.
Will call id_to_object if it cannot serialize the data from json. | [
"Returns",
"a",
"generator",
"that",
"maps",
"the",
"input",
"of",
"the",
"pipe",
"to",
"an",
"elasticsearch",
"object",
".",
"Will",
"call",
"id_to_object",
"if",
"it",
"cannot",
"serialize",
"the",
"data",
"from",
"json",
"."
] | python | valid | 38.666667 |
pettarin/ipapy | ipapy/compatibility.py | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/compatibility.py#L25-L39 | def is_unicode_string(string):
"""
Return ``True`` if the given string is a Unicode string,
that is, of type ``unicode`` in Python 2 or ``str`` in Python 3.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to be checked
:rtype: bool
"""
if string is None:
... | [
"def",
"is_unicode_string",
"(",
"string",
")",
":",
"if",
"string",
"is",
"None",
":",
"return",
"None",
"if",
"PY2",
":",
"return",
"isinstance",
"(",
"string",
",",
"unicode",
")",
"return",
"isinstance",
"(",
"string",
",",
"str",
")"
] | Return ``True`` if the given string is a Unicode string,
that is, of type ``unicode`` in Python 2 or ``str`` in Python 3.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to be checked
:rtype: bool | [
"Return",
"True",
"if",
"the",
"given",
"string",
"is",
"a",
"Unicode",
"string",
"that",
"is",
"of",
"type",
"unicode",
"in",
"Python",
"2",
"or",
"str",
"in",
"Python",
"3",
"."
] | python | train | 27.266667 |
tcalmant/ipopo | pelix/ipopo/handlers/requiresmap.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/requiresmap.py#L354-L367 | def stop(self):
"""
Stops the dependency manager (must be called before clear())
:return: The removed bindings (list) or None
"""
self._context.remove_service_listener(self)
if self.services:
return [
(service, reference)
for r... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"_context",
".",
"remove_service_listener",
"(",
"self",
")",
"if",
"self",
".",
"services",
":",
"return",
"[",
"(",
"service",
",",
"reference",
")",
"for",
"reference",
",",
"service",
"in",
"self",
... | Stops the dependency manager (must be called before clear())
:return: The removed bindings (list) or None | [
"Stops",
"the",
"dependency",
"manager",
"(",
"must",
"be",
"called",
"before",
"clear",
"()",
")"
] | python | train | 27.428571 |
ubyssey/dispatch | dispatch/modules/content/models.py | https://github.com/ubyssey/dispatch/blob/8da6084fe61726f20e9cf675190480cfc45ee764/dispatch/modules/content/models.py#L509-L513 | def get_medium_url(self):
"""Returns the medium size image URL."""
if self.is_gif():
return self.get_absolute_url()
return '%s%s-%s.jpg' % (settings.MEDIA_URL, self.get_name(), 'medium') | [
"def",
"get_medium_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_gif",
"(",
")",
":",
"return",
"self",
".",
"get_absolute_url",
"(",
")",
"return",
"'%s%s-%s.jpg'",
"%",
"(",
"settings",
".",
"MEDIA_URL",
",",
"self",
".",
"get_name",
"(",
")",
... | Returns the medium size image URL. | [
"Returns",
"the",
"medium",
"size",
"image",
"URL",
"."
] | python | test | 43.6 |
7sDream/zhihu-py3 | zhihu/author.py | https://github.com/7sDream/zhihu-py3/blob/bcb4aa8325f8b54d3b44bd0bdc959edd9761fcfc/zhihu/author.py#L538-L562 | def columns(self):
"""获取用户专栏.
:return: 用户专栏,返回生成器
:rtype: Column.Iterable
"""
from .column import Column
if self.url is None or self.post_num == 0:
return
soup = BeautifulSoup(self._session.get(self.url + 'posts').text)
column_list = soup.fin... | [
"def",
"columns",
"(",
"self",
")",
":",
"from",
".",
"column",
"import",
"Column",
"if",
"self",
".",
"url",
"is",
"None",
"or",
"self",
".",
"post_num",
"==",
"0",
":",
"return",
"soup",
"=",
"BeautifulSoup",
"(",
"self",
".",
"_session",
".",
"get... | 获取用户专栏.
:return: 用户专栏,返回生成器
:rtype: Column.Iterable | [
"获取用户专栏",
"."
] | python | train | 37.72 |
saltstack/salt | salt/modules/aptly.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aptly.py#L70-L103 | def _format_repo_args(comment=None, component=None, distribution=None,
uploaders_file=None, saltenv='base'):
'''
Format the common arguments for creating or editing a repository.
:param str comment: The description of the repository.
:param str component: The default component to ... | [
"def",
"_format_repo_args",
"(",
"comment",
"=",
"None",
",",
"component",
"=",
"None",
",",
"distribution",
"=",
"None",
",",
"uploaders_file",
"=",
"None",
",",
"saltenv",
"=",
"'base'",
")",
":",
"ret",
"=",
"list",
"(",
")",
"cached_uploaders_path",
"=... | Format the common arguments for creating or editing a repository.
:param str comment: The description of the repository.
:param str component: The default component to use when publishing.
:param str distribution: The default distribution to use when publishing.
:param str uploaders_file: The repositor... | [
"Format",
"the",
"common",
"arguments",
"for",
"creating",
"or",
"editing",
"a",
"repository",
"."
] | python | train | 37.558824 |
fastavro/fastavro | fastavro/_write_py.py | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L57-L67 | def prepare_timestamp_micros(data, schema):
"""Converts datetime.datetime to int timestamp with microseconds"""
if isinstance(data, datetime.datetime):
if data.tzinfo is not None:
delta = (data - epoch)
return int(delta.total_seconds() * MCS_PER_SECOND)
t = int(time.mktim... | [
"def",
"prepare_timestamp_micros",
"(",
"data",
",",
"schema",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"datetime",
".",
"datetime",
")",
":",
"if",
"data",
".",
"tzinfo",
"is",
"not",
"None",
":",
"delta",
"=",
"(",
"data",
"-",
"epoch",
")",
... | Converts datetime.datetime to int timestamp with microseconds | [
"Converts",
"datetime",
".",
"datetime",
"to",
"int",
"timestamp",
"with",
"microseconds"
] | python | train | 38.818182 |
MSchnei/pyprf_feature | pyprf_feature/analysis/utils_general.py | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/utils_general.py#L26-L102 | def load_nii(strPathIn, varSzeThr=5000.0):
"""
Load nii file.
Parameters
----------
strPathIn : str
Path to nii file to load.
varSzeThr : float
If the nii file is larger than this threshold (in MB), the file is
loaded volume-by-volume in order to prevent memory overflow.... | [
"def",
"load_nii",
"(",
"strPathIn",
",",
"varSzeThr",
"=",
"5000.0",
")",
":",
"# Load nii file (this does not load the data into memory yet):",
"objNii",
"=",
"nb",
".",
"load",
"(",
"strPathIn",
")",
"# Get size of nii file:",
"varNiiSze",
"=",
"os",
".",
"path",
... | Load nii file.
Parameters
----------
strPathIn : str
Path to nii file to load.
varSzeThr : float
If the nii file is larger than this threshold (in MB), the file is
loaded volume-by-volume in order to prevent memory overflow. Default
threshold is 1000 MB.
Returns
... | [
"Load",
"nii",
"file",
"."
] | python | train | 28.779221 |
MacHu-GWU/constant2-project | constant2/_constant2.py | https://github.com/MacHu-GWU/constant2-project/blob/ccf7e14b0e23f9f4bfd13a3e2ce4a1142e570d4f/constant2/_constant2.py#L447-L469 | def load(cls, data):
"""Construct a Constant class from it's dict data.
.. versionadded:: 0.0.2
"""
if len(data) == 1:
for key, value in data.items():
if "__classname__" not in value: # pragma: no cover
raise ValueError
na... | [
"def",
"load",
"(",
"cls",
",",
"data",
")",
":",
"if",
"len",
"(",
"data",
")",
"==",
"1",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"\"__classname__\"",
"not",
"in",
"value",
":",
"# pragma: no cover",
"rai... | Construct a Constant class from it's dict data.
.. versionadded:: 0.0.2 | [
"Construct",
"a",
"Constant",
"class",
"from",
"it",
"s",
"dict",
"data",
"."
] | python | train | 35.043478 |
edx/edx-celeryutils | celery_utils/chordable_django_backend.py | https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/chordable_django_backend.py#L89-L96 | def chord_task(*args, **kwargs):
u"""
Override of the default task decorator to specify use of this backend.
"""
given_backend = kwargs.get(u'backend', None)
if not isinstance(given_backend, ChordableDjangoBackend):
kwargs[u'backend'] = ChordableDjangoBackend(kwargs.get('app', current_app))
... | [
"def",
"chord_task",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"given_backend",
"=",
"kwargs",
".",
"get",
"(",
"u'backend'",
",",
"None",
")",
"if",
"not",
"isinstance",
"(",
"given_backend",
",",
"ChordableDjangoBackend",
")",
":",
"kwargs",
... | u"""
Override of the default task decorator to specify use of this backend. | [
"u",
"Override",
"of",
"the",
"default",
"task",
"decorator",
"to",
"specify",
"use",
"of",
"this",
"backend",
"."
] | python | train | 43.125 |
BreakingBytes/simkit | simkit/core/models.py | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L166-L219 | def _initialize(self):
"""
Initialize model and layers.
"""
meta = getattr(self, ModelBase._meta_attr)
# read modelfile, convert JSON and load/update model
if self.param_file is not None:
self._load()
LOGGER.debug('model:\n%r', self.model)
# in... | [
"def",
"_initialize",
"(",
"self",
")",
":",
"meta",
"=",
"getattr",
"(",
"self",
",",
"ModelBase",
".",
"_meta_attr",
")",
"# read modelfile, convert JSON and load/update model",
"if",
"self",
".",
"param_file",
"is",
"not",
"None",
":",
"self",
".",
"_load",
... | Initialize model and layers. | [
"Initialize",
"model",
"and",
"layers",
"."
] | python | train | 45.518519 |
belbio/bel | bel/edge/edges.py | https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/edge/edges.py#L33-L196 | def nanopub_to_edges(nanopub: dict = {}, rules: List[str] = [], orthologize_targets: list = []):
"""Process nanopub into edges and load into EdgeStore
Args:
nanopub: BEL Nanopub
rules: list of compute rules to process
orthologize_targets: list of species in TAX:<int> format
Returns... | [
"def",
"nanopub_to_edges",
"(",
"nanopub",
":",
"dict",
"=",
"{",
"}",
",",
"rules",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"]",
",",
"orthologize_targets",
":",
"list",
"=",
"[",
"]",
")",
":",
"# Collect input values ########################################... | Process nanopub into edges and load into EdgeStore
Args:
nanopub: BEL Nanopub
rules: list of compute rules to process
orthologize_targets: list of species in TAX:<int> format
Returns:
list: of edges
Edge object:
{
"edge": {
"subject": {
... | [
"Process",
"nanopub",
"into",
"edges",
"and",
"load",
"into",
"EdgeStore"
] | python | train | 39.786585 |
cbclab/MOT | mot/random.py | https://github.com/cbclab/MOT/blob/fb3243b65025705842e82704705c00902f9a35af/mot/random.py#L76-L112 | def normal(nmr_distributions, nmr_samples, mean=0, std=1, ctype='float', seed=None):
"""Draw random samples from the Gaussian distribution.
Args:
nmr_distributions (int): the number of unique continuous_distributions to create
nmr_samples (int): The number of samples to draw
mean (float... | [
"def",
"normal",
"(",
"nmr_distributions",
",",
"nmr_samples",
",",
"mean",
"=",
"0",
",",
"std",
"=",
"1",
",",
"ctype",
"=",
"'float'",
",",
"seed",
"=",
"None",
")",
":",
"if",
"is_scalar",
"(",
"mean",
")",
":",
"mean",
"=",
"np",
".",
"ones",
... | Draw random samples from the Gaussian distribution.
Args:
nmr_distributions (int): the number of unique continuous_distributions to create
nmr_samples (int): The number of samples to draw
mean (float or ndarray): The mean of the distribution
std (float or ndarray): The standard devi... | [
"Draw",
"random",
"samples",
"from",
"the",
"Gaussian",
"distribution",
"."
] | python | train | 44.135135 |
ask/carrot | carrot/messaging.py | https://github.com/ask/carrot/blob/5889a25cd2e274642071c9bba39772f4b3e3d9da/carrot/messaging.py#L507-L544 | def qos(self, prefetch_size=0, prefetch_count=0, apply_global=False):
"""Request specific Quality of Service.
This method requests a specific quality of service. The QoS
can be specified for the current channel or for all channels
on the connection. The particular properties and seman... | [
"def",
"qos",
"(",
"self",
",",
"prefetch_size",
"=",
"0",
",",
"prefetch_count",
"=",
"0",
",",
"apply_global",
"=",
"False",
")",
":",
"return",
"self",
".",
"backend",
".",
"qos",
"(",
"prefetch_size",
",",
"prefetch_count",
",",
"apply_global",
")"
] | Request specific Quality of Service.
This method requests a specific quality of service. The QoS
can be specified for the current channel or for all channels
on the connection. The particular properties and semantics of
a qos method always depend on the content class semantics.
... | [
"Request",
"specific",
"Quality",
"of",
"Service",
"."
] | python | train | 52.631579 |
openpermissions/perch | perch/views.py | https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/views.py#L310-L320 | def active_service_location(doc):
"""View for getting active service by location"""
if doc.get('state') != 'deactivated':
for service_id, service in doc.get('services', {}).items():
if service.get('state') != 'deactivated':
service['id'] = service_id
service['... | [
"def",
"active_service_location",
"(",
"doc",
")",
":",
"if",
"doc",
".",
"get",
"(",
"'state'",
")",
"!=",
"'deactivated'",
":",
"for",
"service_id",
",",
"service",
"in",
"doc",
".",
"get",
"(",
"'services'",
",",
"{",
"}",
")",
".",
"items",
"(",
... | View for getting active service by location | [
"View",
"for",
"getting",
"active",
"service",
"by",
"location"
] | python | train | 42.818182 |
dereneaton/ipyrad | ipyrad/assemble/write_outfiles.py | https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/assemble/write_outfiles.py#L973-L1024 | def get_edges(data, superints, splits):
"""
Gets edge trimming based on the overlap of sequences at the edges of
alignments and the tuple arg passed in for edge_trimming. Trims as
(R1 left, R1 right, R2 left, R2 right). We also trim off the restriction
site if it present. This modifies superints, an... | [
"def",
"get_edges",
"(",
"data",
",",
"superints",
",",
"splits",
")",
":",
"## the filtering arg and parse it into minsamp numbers",
"if",
"\"trim_overhang\"",
"in",
"data",
".",
"paramsdict",
":",
"edgetrims",
"=",
"np",
".",
"array",
"(",
"data",
".",
"paramsdi... | Gets edge trimming based on the overlap of sequences at the edges of
alignments and the tuple arg passed in for edge_trimming. Trims as
(R1 left, R1 right, R2 left, R2 right). We also trim off the restriction
site if it present. This modifies superints, and so should be run on an
engine so it doesn't af... | [
"Gets",
"edge",
"trimming",
"based",
"on",
"the",
"overlap",
"of",
"sequences",
"at",
"the",
"edges",
"of",
"alignments",
"and",
"the",
"tuple",
"arg",
"passed",
"in",
"for",
"edge_trimming",
".",
"Trims",
"as",
"(",
"R1",
"left",
"R1",
"right",
"R2",
"l... | python | valid | 44.480769 |
polyaxon/polyaxon | polyaxon/streams/consumers/consumers.py | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L280-L286 | def open_channel(self):
"""Open a new channel with RabbitMQ by issuing the Channel.Open RPC
command. When RabbitMQ responds that the channel is open, the
on_channel_open callback will be invoked by pika.
"""
_logger.info('Creating a new channel')
self._connection.channel(... | [
"def",
"open_channel",
"(",
"self",
")",
":",
"_logger",
".",
"info",
"(",
"'Creating a new channel'",
")",
"self",
".",
"_connection",
".",
"channel",
"(",
"on_open_callback",
"=",
"self",
".",
"on_channel_open",
")"
] | Open a new channel with RabbitMQ by issuing the Channel.Open RPC
command. When RabbitMQ responds that the channel is open, the
on_channel_open callback will be invoked by pika. | [
"Open",
"a",
"new",
"channel",
"with",
"RabbitMQ",
"by",
"issuing",
"the",
"Channel",
".",
"Open",
"RPC",
"command",
".",
"When",
"RabbitMQ",
"responds",
"that",
"the",
"channel",
"is",
"open",
"the",
"on_channel_open",
"callback",
"will",
"be",
"invoked",
"... | python | train | 50.285714 |
fastai/fastai | fastai/gen_doc/gen_notebooks.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/gen_doc/gen_notebooks.py#L204-L212 | def update_nb_metadata(nb_path=None, title=None, summary=None, keywords='fastai', overwrite=True, **kwargs):
"Creates jekyll metadata for given notebook path."
nb = read_nb(nb_path)
data = {'title': title, 'summary': summary, 'keywords': keywords, **kwargs}
data = {k:v for (k,v) in data.items() if v is ... | [
"def",
"update_nb_metadata",
"(",
"nb_path",
"=",
"None",
",",
"title",
"=",
"None",
",",
"summary",
"=",
"None",
",",
"keywords",
"=",
"'fastai'",
",",
"overwrite",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"nb",
"=",
"read_nb",
"(",
"nb_path",
... | Creates jekyll metadata for given notebook path. | [
"Creates",
"jekyll",
"metadata",
"for",
"given",
"notebook",
"path",
"."
] | python | train | 50.888889 |
edx/edx-search | search/api.py | https://github.com/edx/edx-search/blob/476cf02b71ceba34ae7d8b798f36d60692317c55/search/api.py#L80-L112 | def course_discovery_search(search_term=None, size=20, from_=0, field_dictionary=None):
"""
Course Discovery activities against the search engine index of course details
"""
# We'll ignore the course-enrollemnt informaiton in field and filter
# dictionary, and use our own logic upon enrollment dates... | [
"def",
"course_discovery_search",
"(",
"search_term",
"=",
"None",
",",
"size",
"=",
"20",
",",
"from_",
"=",
"0",
",",
"field_dictionary",
"=",
"None",
")",
":",
"# We'll ignore the course-enrollemnt informaiton in field and filter",
"# dictionary, and use our own logic up... | Course Discovery activities against the search engine index of course details | [
"Course",
"Discovery",
"activities",
"against",
"the",
"search",
"engine",
"index",
"of",
"course",
"details"
] | python | valid | 47.848485 |
Samreay/ChainConsumer | chainconsumer/chainconsumer.py | https://github.com/Samreay/ChainConsumer/blob/902288e4d85c2677a9051a2172e03128a6169ad7/chainconsumer/chainconsumer.py#L49-L234 | def add_chain(self, chain, parameters=None, name=None, weights=None, posterior=None, walkers=None,
grid=False, num_eff_data_points=None, num_free_params=None, color=None, linewidth=None,
linestyle=None, kde=None, shade=None, shade_alpha=None, power=None, marker_style=None, marker_siz... | [
"def",
"add_chain",
"(",
"self",
",",
"chain",
",",
"parameters",
"=",
"None",
",",
"name",
"=",
"None",
",",
"weights",
"=",
"None",
",",
"posterior",
"=",
"None",
",",
"walkers",
"=",
"None",
",",
"grid",
"=",
"False",
",",
"num_eff_data_points",
"="... | Add a chain to the consumer.
Parameters
----------
chain : str|ndarray|dict
The chain to load. Normally a ``numpy.ndarray``. If a string is found, it
interprets the string as a filename and attempts to load it in. If a ``dict``
is passed in, it assumes the di... | [
"Add",
"a",
"chain",
"to",
"the",
"consumer",
"."
] | python | train | 59.478495 |
xeroc/python-graphenelib | graphenebase/operations.py | https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenebase/operations.py#L88-L109 | def detail(self, *args, **kwargs):
prefix = kwargs.pop("prefix", default_prefix)
# remove dublicates
kwargs["votes"] = list(set(kwargs["votes"]))
""" This is an example how to sort votes prior to using them in the
Object
"""
# # Sort votes
# kwargs["vo... | [
"def",
"detail",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"prefix",
"=",
"kwargs",
".",
"pop",
"(",
"\"prefix\"",
",",
"default_prefix",
")",
"# remove dublicates",
"kwargs",
"[",
"\"votes\"",
"]",
"=",
"list",
"(",
"set",
"(",... | This is an example how to sort votes prior to using them in the
Object | [
"This",
"is",
"an",
"example",
"how",
"to",
"sort",
"votes",
"prior",
"to",
"using",
"them",
"in",
"the",
"Object"
] | python | valid | 39.954545 |
mozilla-services/pyramid_multiauth | pyramid_multiauth/__init__.py | https://github.com/mozilla-services/pyramid_multiauth/blob/9548aa55f726920a666791d7c89ac2b9779d2bc1/pyramid_multiauth/__init__.py#L293-L336 | def policy_factory_from_module(config, module):
"""Create a policy factory that works by config.include()'ing a module.
This function does some trickery with the Pyramid config system. Loosely,
it does config.include(module), and then sucks out information about the
authn policy that was registered. I... | [
"def",
"policy_factory_from_module",
"(",
"config",
",",
"module",
")",
":",
"# Remember the policy that's active before including the module, if any.",
"orig_policy",
"=",
"config",
".",
"registry",
".",
"queryUtility",
"(",
"IAuthenticationPolicy",
")",
"# Include the module,... | Create a policy factory that works by config.include()'ing a module.
This function does some trickery with the Pyramid config system. Loosely,
it does config.include(module), and then sucks out information about the
authn policy that was registered. It's complicated by pyramid's delayed-
commit system... | [
"Create",
"a",
"policy",
"factory",
"that",
"works",
"by",
"config",
".",
"include",
"()",
"ing",
"a",
"module",
"."
] | python | train | 49.795455 |
cnobile2012/pololu-motors | pololu/motors/crc7.py | https://github.com/cnobile2012/pololu-motors/blob/453d2283a63cfe15cda96cad6dffa73372d52a7c/pololu/motors/crc7.py#L26-L35 | def crc7(data):
"""
Compute CRC of a whole message.
"""
crc = 0
for c in data:
crc = CRC7_TABLE[crc ^ c]
return crc | [
"def",
"crc7",
"(",
"data",
")",
":",
"crc",
"=",
"0",
"for",
"c",
"in",
"data",
":",
"crc",
"=",
"CRC7_TABLE",
"[",
"crc",
"^",
"c",
"]",
"return",
"crc"
] | Compute CRC of a whole message. | [
"Compute",
"CRC",
"of",
"a",
"whole",
"message",
"."
] | python | train | 14 |
acutesoftware/AIKIF | aikif/agents/agent.py | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/agent.py#L104-L112 | def set_coords(self, x=0, y=0, z=0, t=0):
"""
set coords of agent in an arbitrary world
"""
self.coords = {}
self.coords['x'] = x
self.coords['y'] = y
self.coords['z'] = z
self.coords['t'] = t | [
"def",
"set_coords",
"(",
"self",
",",
"x",
"=",
"0",
",",
"y",
"=",
"0",
",",
"z",
"=",
"0",
",",
"t",
"=",
"0",
")",
":",
"self",
".",
"coords",
"=",
"{",
"}",
"self",
".",
"coords",
"[",
"'x'",
"]",
"=",
"x",
"self",
".",
"coords",
"["... | set coords of agent in an arbitrary world | [
"set",
"coords",
"of",
"agent",
"in",
"an",
"arbitrary",
"world"
] | python | train | 27.555556 |
KrishnaswamyLab/graphtools | graphtools/graphs.py | https://github.com/KrishnaswamyLab/graphtools/blob/44685352be7df2005d44722903092207967457f2/graphtools/graphs.py#L673-L700 | def interpolate(self, transform, transitions=None, Y=None):
"""Interpolate new data onto a transformation of the graph data
One of either transitions or Y should be provided
Parameters
----------
transform : array-like, shape=[n_samples, n_transform_features]
transiti... | [
"def",
"interpolate",
"(",
"self",
",",
"transform",
",",
"transitions",
"=",
"None",
",",
"Y",
"=",
"None",
")",
":",
"if",
"transitions",
"is",
"None",
"and",
"Y",
"is",
"None",
":",
"# assume Y is self.data and use standard landmark transitions",
"transitions",... | Interpolate new data onto a transformation of the graph data
One of either transitions or Y should be provided
Parameters
----------
transform : array-like, shape=[n_samples, n_transform_features]
transitions : array-like, optional, shape=[n_samples_y, n_samples]
... | [
"Interpolate",
"new",
"data",
"onto",
"a",
"transformation",
"of",
"the",
"graph",
"data"
] | python | train | 38.035714 |
fy0/slim | slim/base/sqlfuncs.py | https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/base/sqlfuncs.py#L24-L33 | async def select_page(self, info: SQLQueryInfo, size=1, page=1) -> Tuple[Tuple[DataRecord, ...], int]:
"""
Select from database
:param info:
:param size: -1 means infinite
:param page:
:param need_count: if True, get count as second return value, otherwise -1
:ret... | [
"async",
"def",
"select_page",
"(",
"self",
",",
"info",
":",
"SQLQueryInfo",
",",
"size",
"=",
"1",
",",
"page",
"=",
"1",
")",
"->",
"Tuple",
"[",
"Tuple",
"[",
"DataRecord",
",",
"...",
"]",
",",
"int",
"]",
":",
"raise",
"NotImplementedError",
"(... | Select from database
:param info:
:param size: -1 means infinite
:param page:
:param need_count: if True, get count as second return value, otherwise -1
:return: records. count | [
"Select",
"from",
"database",
":",
"param",
"info",
":",
":",
"param",
"size",
":",
"-",
"1",
"means",
"infinite",
":",
"param",
"page",
":",
":",
"param",
"need_count",
":",
"if",
"True",
"get",
"count",
"as",
"second",
"return",
"value",
"otherwise",
... | python | valid | 37.8 |
pantsbuild/pants | src/python/pants/goal/workspace.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/goal/workspace.py#L46-L55 | def touched_files(self, parent):
"""
:API: public
"""
try:
return self._scm.changed_files(from_commit=parent,
include_untracked=True,
relative_to=get_buildroot())
except Scm.ScmException as e:
raise self.WorkspaceE... | [
"def",
"touched_files",
"(",
"self",
",",
"parent",
")",
":",
"try",
":",
"return",
"self",
".",
"_scm",
".",
"changed_files",
"(",
"from_commit",
"=",
"parent",
",",
"include_untracked",
"=",
"True",
",",
"relative_to",
"=",
"get_buildroot",
"(",
")",
")"... | :API: public | [
":",
"API",
":",
"public"
] | python | train | 35.4 |
angr/angr | angr/calling_conventions.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/calling_conventions.py#L485-L520 | def get_args(self, state, is_fp=None, sizes=None, stack_base=None):
"""
`is_fp` should be a list of booleans specifying whether each corresponding argument is floating-point -
True for fp and False for int. For a shorthand to assume that all the parameters are int, pass the number of
par... | [
"def",
"get_args",
"(",
"self",
",",
"state",
",",
"is_fp",
"=",
"None",
",",
"sizes",
"=",
"None",
",",
"stack_base",
"=",
"None",
")",
":",
"if",
"sizes",
"is",
"None",
"and",
"self",
".",
"func_ty",
"is",
"not",
"None",
":",
"sizes",
"=",
"[",
... | `is_fp` should be a list of booleans specifying whether each corresponding argument is floating-point -
True for fp and False for int. For a shorthand to assume that all the parameters are int, pass the number of
parameters as an int.
If you've customized this CC, you may omit this parameter en... | [
"is_fp",
"should",
"be",
"a",
"list",
"of",
"booleans",
"specifying",
"whether",
"each",
"corresponding",
"argument",
"is",
"floating",
"-",
"point",
"-",
"True",
"for",
"fp",
"and",
"False",
"for",
"int",
".",
"For",
"a",
"shorthand",
"to",
"assume",
"tha... | python | train | 50.222222 |
ljcooke/see | see/output.py | https://github.com/ljcooke/see/blob/4cbc67a31c92367977ecb4bbb1f0736fa688a6ba/see/output.py#L151-L172 | def display_name(name, obj, local):
"""
Get the display name of an object.
Keyword arguments (all required):
* ``name`` -- the name of the object as a string.
* ``obj`` -- the object itself.
* ``local`` -- a boolean value indicating whether the object is in local
scope or owned by an obj... | [
"def",
"display_name",
"(",
"name",
",",
"obj",
",",
"local",
")",
":",
"prefix",
"=",
"''",
"if",
"local",
"else",
"'.'",
"if",
"isinstance",
"(",
"obj",
",",
"SeeError",
")",
":",
"suffix",
"=",
"'?'",
"elif",
"hasattr",
"(",
"obj",
",",
"'__call__... | Get the display name of an object.
Keyword arguments (all required):
* ``name`` -- the name of the object as a string.
* ``obj`` -- the object itself.
* ``local`` -- a boolean value indicating whether the object is in local
scope or owned by an object. | [
"Get",
"the",
"display",
"name",
"of",
"an",
"object",
"."
] | python | train | 24.227273 |
mojaie/chorus | chorus/v2000reader.py | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L192-L253 | def mol_supplier(lines, no_halt, assign_descriptors):
"""Yields molecules generated from CTAB text
Args:
lines (iterable): CTAB text lines
no_halt (boolean):
True: shows warning messages for invalid format and go on.
False: throws an exception for it and stop parsing.
... | [
"def",
"mol_supplier",
"(",
"lines",
",",
"no_halt",
",",
"assign_descriptors",
")",
":",
"def",
"sdf_block",
"(",
"lns",
")",
":",
"mol",
"=",
"[",
"]",
"opt",
"=",
"[",
"]",
"is_mol",
"=",
"True",
"for",
"line",
"in",
"lns",
":",
"if",
"line",
".... | Yields molecules generated from CTAB text
Args:
lines (iterable): CTAB text lines
no_halt (boolean):
True: shows warning messages for invalid format and go on.
False: throws an exception for it and stop parsing.
assign_descriptors (boolean):
if True, defa... | [
"Yields",
"molecules",
"generated",
"from",
"CTAB",
"text"
] | python | train | 34.451613 |
CalebBell/fluids | fluids/geometry.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L224-L269 | def V_horiz_ellipsoidal(D, L, a, h, headonly=False):
r'''Calculates volume of a tank with ellipsoidal ends, according to [1]_.
.. math::
V_f = A_fL + \pi a h^2\left(1 - \frac{h}{3R}\right)
.. math::
Af = R^2\cos^{-1}\frac{R-h}{R} - (R-h)\sqrt{2Rh - h^2}
Parameters
----------
D... | [
"def",
"V_horiz_ellipsoidal",
"(",
"D",
",",
"L",
",",
"a",
",",
"h",
",",
"headonly",
"=",
"False",
")",
":",
"R",
"=",
"0.5",
"*",
"D",
"Af",
"=",
"R",
"*",
"R",
"*",
"acos",
"(",
"(",
"R",
"-",
"h",
")",
"/",
"R",
")",
"-",
"(",
"R",
... | r'''Calculates volume of a tank with ellipsoidal ends, according to [1]_.
.. math::
V_f = A_fL + \pi a h^2\left(1 - \frac{h}{3R}\right)
.. math::
Af = R^2\cos^{-1}\frac{R-h}{R} - (R-h)\sqrt{2Rh - h^2}
Parameters
----------
D : float
Diameter of the main cylindrical section... | [
"r",
"Calculates",
"volume",
"of",
"a",
"tank",
"with",
"ellipsoidal",
"ends",
"according",
"to",
"[",
"1",
"]",
"_",
"."
] | python | train | 27.23913 |
quantopian/zipline | zipline/utils/pandas_utils.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/pandas_utils.py#L247-L287 | def categorical_df_concat(df_list, inplace=False):
"""
Prepare list of pandas DataFrames to be used as input to pd.concat.
Ensure any columns of type 'category' have the same categories across each
dataframe.
Parameters
----------
df_list : list
List of dataframes with same columns.... | [
"def",
"categorical_df_concat",
"(",
"df_list",
",",
"inplace",
"=",
"False",
")",
":",
"if",
"not",
"inplace",
":",
"df_list",
"=",
"deepcopy",
"(",
"df_list",
")",
"# Assert each dataframe has the same columns/dtypes",
"df",
"=",
"df_list",
"[",
"0",
"]",
"if"... | Prepare list of pandas DataFrames to be used as input to pd.concat.
Ensure any columns of type 'category' have the same categories across each
dataframe.
Parameters
----------
df_list : list
List of dataframes with same columns.
inplace : bool
True if input list can be modified.... | [
"Prepare",
"list",
"of",
"pandas",
"DataFrames",
"to",
"be",
"used",
"as",
"input",
"to",
"pd",
".",
"concat",
".",
"Ensure",
"any",
"columns",
"of",
"type",
"category",
"have",
"the",
"same",
"categories",
"across",
"each",
"dataframe",
"."
] | python | train | 28.853659 |
DLR-RM/RAFCON | source/rafcon/gui/controllers/state_machine_tree.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/state_machine_tree.py#L300-L336 | def update(self, changed_state_model=None, with_expand=False):
"""Checks if all states are in tree and if tree has states which were deleted
:param changed_state_model: Model that row has to be updated
:param with_expand: The expand flag for the tree
"""
if not self.view_is_regi... | [
"def",
"update",
"(",
"self",
",",
"changed_state_model",
"=",
"None",
",",
"with_expand",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"view_is_registered",
":",
"return",
"# define initial state-model for update",
"if",
"changed_state_model",
"is",
"None",
... | Checks if all states are in tree and if tree has states which were deleted
:param changed_state_model: Model that row has to be updated
:param with_expand: The expand flag for the tree | [
"Checks",
"if",
"all",
"states",
"are",
"in",
"tree",
"and",
"if",
"tree",
"has",
"states",
"which",
"were",
"deleted"
] | python | train | 53.351351 |
devassistant/devassistant | devassistant/cache.py | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cache.py#L94-L139 | def _refresh_hierarchy_recursive(self, cached_hierarchy, file_hierarchy):
"""Recursively goes through given corresponding hierarchies from cache and filesystem
and adds/refreshes/removes added/changed/removed assistants.
Args:
cached_hierarchy: the respective hierarchy part from cur... | [
"def",
"_refresh_hierarchy_recursive",
"(",
"self",
",",
"cached_hierarchy",
",",
"file_hierarchy",
")",
":",
"was_change",
"=",
"False",
"cached_ass",
"=",
"set",
"(",
"cached_hierarchy",
".",
"keys",
"(",
")",
")",
"new_ass",
"=",
"set",
"(",
"file_hierarchy",... | Recursively goes through given corresponding hierarchies from cache and filesystem
and adds/refreshes/removes added/changed/removed assistants.
Args:
cached_hierarchy: the respective hierarchy part from current cache
(for format see Cache class docstring)
... | [
"Recursively",
"goes",
"through",
"given",
"corresponding",
"hierarchies",
"from",
"cache",
"and",
"filesystem",
"and",
"adds",
"/",
"refreshes",
"/",
"removes",
"added",
"/",
"changed",
"/",
"removed",
"assistants",
"."
] | python | train | 37.23913 |
diamondman/proteusisc | proteusisc/drivers/digilentdriver.py | https://github.com/diamondman/proteusisc/blob/7622b7b04e63f9dc0f5a04429ff78d9a490c9c5c/proteusisc/drivers/digilentdriver.py#L170-L188 | def _get_adv_trans_stats(self, cmd, return_tdo=False):
"""Utility function to fetch the transfer statistics for the last
advanced transfer. Checking the stats appears to sync the
controller. For details on the advanced transfer please refer
to the documentation at
http://diamondm... | [
"def",
"_get_adv_trans_stats",
"(",
"self",
",",
"cmd",
",",
"return_tdo",
"=",
"False",
")",
":",
"t",
"=",
"time",
"(",
")",
"code",
",",
"res",
"=",
"self",
".",
"bulkCommand",
"(",
"b'\\x03\\x02%c\\x00'",
"%",
"(",
"0x80",
"|",
"cmd",
")",
",",
"... | Utility function to fetch the transfer statistics for the last
advanced transfer. Checking the stats appears to sync the
controller. For details on the advanced transfer please refer
to the documentation at
http://diamondman.github.io/Adapt/cable_digilent_adept.html#bulk-requests | [
"Utility",
"function",
"to",
"fetch",
"the",
"transfer",
"statistics",
"for",
"the",
"last",
"advanced",
"transfer",
".",
"Checking",
"the",
"stats",
"appears",
"to",
"sync",
"the",
"controller",
".",
"For",
"details",
"on",
"the",
"advanced",
"transfer",
"ple... | python | train | 43.473684 |
openstack/proliantutils | proliantutils/redfish/resources/system/bios.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/bios.py#L52-L61 | def pending_settings(self):
"""Property to provide reference to bios_pending_settings instance
It is calculated once when the first time it is queried. On refresh,
this property gets reset.
"""
return BIOSPendingSettings(
self._conn, utils.get_subresource_path_by(
... | [
"def",
"pending_settings",
"(",
"self",
")",
":",
"return",
"BIOSPendingSettings",
"(",
"self",
".",
"_conn",
",",
"utils",
".",
"get_subresource_path_by",
"(",
"self",
",",
"[",
"\"@Redfish.Settings\"",
",",
"\"SettingsObject\"",
"]",
")",
",",
"redfish_version",... | Property to provide reference to bios_pending_settings instance
It is calculated once when the first time it is queried. On refresh,
this property gets reset. | [
"Property",
"to",
"provide",
"reference",
"to",
"bios_pending_settings",
"instance"
] | python | train | 42.2 |
reingart/gui2py | gui/controls/listview.py | https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/controls/listview.py#L397-L402 | def clear(self):
"Remove all items and reset internal structures"
dict.clear(self)
self._key = 0
if hasattr(self._list_view, "wx_obj"):
self._list_view.wx_obj.DeleteAllItems() | [
"def",
"clear",
"(",
"self",
")",
":",
"dict",
".",
"clear",
"(",
"self",
")",
"self",
".",
"_key",
"=",
"0",
"if",
"hasattr",
"(",
"self",
".",
"_list_view",
",",
"\"wx_obj\"",
")",
":",
"self",
".",
"_list_view",
".",
"wx_obj",
".",
"DeleteAllItems... | Remove all items and reset internal structures | [
"Remove",
"all",
"items",
"and",
"reset",
"internal",
"structures"
] | python | test | 36.5 |
dagwieers/vmguestlib | vmguestlib.py | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L325-L330 | def GetMemBalloonMaxMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemBalloonMaxMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetMemBalloonMaxMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemBalloonMaxMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"... | Undocumented. | [
"Undocumented",
"."
] | python | train | 45.5 |
mrstephenneal/dirutility | dirutility/compare.py | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/compare.py#L6-L13 | def unique(list1, list2):
"""
Get unique items in list1 that are not in list2
:return: Unique items only in list 1
"""
set2 = set(list2)
list1_unique = [x for x in tqdm(list1, desc='Unique', total=len(list1)) if x not in set2]
return list1_unique | [
"def",
"unique",
"(",
"list1",
",",
"list2",
")",
":",
"set2",
"=",
"set",
"(",
"list2",
")",
"list1_unique",
"=",
"[",
"x",
"for",
"x",
"in",
"tqdm",
"(",
"list1",
",",
"desc",
"=",
"'Unique'",
",",
"total",
"=",
"len",
"(",
"list1",
")",
")",
... | Get unique items in list1 that are not in list2
:return: Unique items only in list 1 | [
"Get",
"unique",
"items",
"in",
"list1",
"that",
"are",
"not",
"in",
"list2",
":",
"return",
":",
"Unique",
"items",
"only",
"in",
"list",
"1"
] | python | train | 33.375 |
jhermann/rituals | src/rituals/config.py | https://github.com/jhermann/rituals/blob/1534f50d81e19bbbe799e2eba0acdefbce047c06/src/rituals/config.py#L42-L49 | def get_project_root():
""" Determine location of `tasks.py`."""
try:
tasks_py = sys.modules['tasks']
except KeyError:
return None
else:
return os.path.abspath(os.path.dirname(tasks_py.__file__)) | [
"def",
"get_project_root",
"(",
")",
":",
"try",
":",
"tasks_py",
"=",
"sys",
".",
"modules",
"[",
"'tasks'",
"]",
"except",
"KeyError",
":",
"return",
"None",
"else",
":",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"di... | Determine location of `tasks.py`. | [
"Determine",
"location",
"of",
"tasks",
".",
"py",
"."
] | python | valid | 28.5 |
aouyar/PyMunin | pysysinfo/diskio.py | https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/diskio.py#L367-L380 | def getDevStats(self, dev, devtype = None):
"""Returns I/O stats for block device.
@param dev: Device name
@param devtype: Device type. (Ignored if None.)
@return: Dict of stats.
"""
if devtype is not None:
if self._devClassTree is... | [
"def",
"getDevStats",
"(",
"self",
",",
"dev",
",",
"devtype",
"=",
"None",
")",
":",
"if",
"devtype",
"is",
"not",
"None",
":",
"if",
"self",
".",
"_devClassTree",
"is",
"None",
":",
"self",
".",
"_initDevClasses",
"(",
")",
"if",
"devtype",
"<>",
"... | Returns I/O stats for block device.
@param dev: Device name
@param devtype: Device type. (Ignored if None.)
@return: Dict of stats. | [
"Returns",
"I",
"/",
"O",
"stats",
"for",
"block",
"device",
"."
] | python | train | 33.785714 |
the01/python-paps | paps/si/app/sensorServer.py | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/paps/si/app/sensorServer.py#L392-L405 | def stop(self):
"""
Stop the sensor server (soft stop - signal packet loop to stop)
Warning: Is non blocking (server might still do something after this!)
:rtype: None
"""
self.debug("()")
super(SensorServer, self).stop()
# No new clients
if self.... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"debug",
"(",
"\"()\"",
")",
"super",
"(",
"SensorServer",
",",
"self",
")",
".",
"stop",
"(",
")",
"# No new clients",
"if",
"self",
".",
"_multicast_socket",
"is",
"not",
"None",
":",
"self",
".",
... | Stop the sensor server (soft stop - signal packet loop to stop)
Warning: Is non blocking (server might still do something after this!)
:rtype: None | [
"Stop",
"the",
"sensor",
"server",
"(",
"soft",
"stop",
"-",
"signal",
"packet",
"loop",
"to",
"stop",
")",
"Warning",
":",
"Is",
"non",
"blocking",
"(",
"server",
"might",
"still",
"do",
"something",
"after",
"this!",
")"
] | python | train | 32.5 |
wtolson/gnsq | gnsq/nsqd.py | https://github.com/wtolson/gnsq/blob/0fd02578b2c9c5fa30626d78579db2a46c10edac/gnsq/nsqd.py#L453-L462 | def requeue(self, message_id, timeout=0, backoff=True):
"""Re-queue a message (indicate failure to process)."""
self.send(nsq.requeue(message_id, timeout))
self.finish_inflight()
self.on_requeue.send(
self,
message_id=message_id,
timeout=timeout,
... | [
"def",
"requeue",
"(",
"self",
",",
"message_id",
",",
"timeout",
"=",
"0",
",",
"backoff",
"=",
"True",
")",
":",
"self",
".",
"send",
"(",
"nsq",
".",
"requeue",
"(",
"message_id",
",",
"timeout",
")",
")",
"self",
".",
"finish_inflight",
"(",
")",... | Re-queue a message (indicate failure to process). | [
"Re",
"-",
"queue",
"a",
"message",
"(",
"indicate",
"failure",
"to",
"process",
")",
"."
] | python | train | 34.3 |
iotaledger/iota.lib.py | iota/codecs.py | https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/codecs.py#L61-L78 | def get_codec_info(cls):
"""
Returns information used by the codecs library to configure the
codec for use.
"""
codec = cls()
codec_info = {
'encode': codec.encode,
'decode': codec.decode,
}
# In Python 2, all codecs are made equa... | [
"def",
"get_codec_info",
"(",
"cls",
")",
":",
"codec",
"=",
"cls",
"(",
")",
"codec_info",
"=",
"{",
"'encode'",
":",
"codec",
".",
"encode",
",",
"'decode'",
":",
"codec",
".",
"decode",
",",
"}",
"# In Python 2, all codecs are made equal.",
"# In Python 3, ... | Returns information used by the codecs library to configure the
codec for use. | [
"Returns",
"information",
"used",
"by",
"the",
"codecs",
"library",
"to",
"configure",
"the",
"codec",
"for",
"use",
"."
] | python | test | 26.444444 |
dcaune/perseus-lib-python-common | majormode/perseus/utils/rdbms.py | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/rdbms.py#L596-L629 | def _expand_placeholder_value(value):
"""
Return the SQL string representation of the specified placeholder's
value.
@param value: the value of a placeholder such as a simple element, a
list, or a tuple of one string.
@note: by convention, a tuple of one string in... | [
"def",
"_expand_placeholder_value",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"set",
")",
")",
"or",
"(",
"isinstance",
"(",
"value",
",",
"tuple",
")",
"and",
"len",
"(",
"value",
")",
"!=",
"1",
")",
":",
"s... | Return the SQL string representation of the specified placeholder's
value.
@param value: the value of a placeholder such as a simple element, a
list, or a tuple of one string.
@note: by convention, a tuple of one string indicates that this string
MUST not be quoted as... | [
"Return",
"the",
"SQL",
"string",
"representation",
"of",
"the",
"specified",
"placeholder",
"s",
"value",
"."
] | python | train | 37.558824 |
radjkarl/imgProcessor | imgProcessor/array/subCell2D.py | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L74-L84 | def subCell2DCoords(*args, **kwargs):
'''Same as subCell2DSlices but returning coordinates
Example:
g = subCell2DCoords(arr, shape)
for x, y in g:
plt.plot(x, y)
'''
for _, _, s0, s1 in subCell2DSlices(*args, **kwargs):
yield ((s1.start, s1.start, s1.sto... | [
"def",
"subCell2DCoords",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"_",
",",
"_",
",",
"s0",
",",
"s1",
"in",
"subCell2DSlices",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"yield",
"(",
"(",
"s1",
".",
"start",
",",... | Same as subCell2DSlices but returning coordinates
Example:
g = subCell2DCoords(arr, shape)
for x, y in g:
plt.plot(x, y) | [
"Same",
"as",
"subCell2DSlices",
"but",
"returning",
"coordinates",
"Example",
":",
"g",
"=",
"subCell2DCoords",
"(",
"arr",
"shape",
")",
"for",
"x",
"y",
"in",
"g",
":",
"plt",
".",
"plot",
"(",
"x",
"y",
")"
] | python | train | 32.727273 |
benhoff/pluginmanager | pluginmanager/file_manager.py | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_manager.py#L164-L177 | def add_blacklisted_filepaths(self, filepaths, remove_from_stored=True):
"""
Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
`plugin_filepaths` will be automatically removed.
Recommend passing in absolute filepaths but method will ... | [
"def",
"add_blacklisted_filepaths",
"(",
"self",
",",
"filepaths",
",",
"remove_from_stored",
"=",
"True",
")",
":",
"filepaths",
"=",
"util",
".",
"to_absolute_paths",
"(",
"filepaths",
")",
"self",
".",
"blacklisted_filepaths",
".",
"update",
"(",
"filepaths",
... | Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
`plugin_filepaths` will be automatically removed.
Recommend passing in absolute filepaths but method will attempt
to convert to absolute filepaths based on current working directory. | [
"Add",
"filepaths",
"to",
"blacklisted",
"filepaths",
".",
"If",
"remove_from_stored",
"is",
"True",
"any",
"filepaths",
"in",
"plugin_filepaths",
"will",
"be",
"automatically",
"removed",
"."
] | python | train | 49.214286 |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Taskmaster.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Taskmaster.py#L760-L950 | def _find_next_ready_node(self):
"""
Finds the next node that is ready to be built.
This is *the* main guts of the DAG walk. We loop through the
list of candidates, looking for something that has no un-built
children (i.e., that is a leaf Node or has dependencies that are
... | [
"def",
"_find_next_ready_node",
"(",
"self",
")",
":",
"self",
".",
"ready_exc",
"=",
"None",
"T",
"=",
"self",
".",
"trace",
"if",
"T",
":",
"T",
".",
"write",
"(",
"SCons",
".",
"Util",
".",
"UnicodeType",
"(",
"'\\n'",
")",
"+",
"self",
".",
"tr... | Finds the next node that is ready to be built.
This is *the* main guts of the DAG walk. We loop through the
list of candidates, looking for something that has no un-built
children (i.e., that is a leaf Node or has dependencies that are
all leaf Nodes or up-to-date). Candidate Nodes ar... | [
"Finds",
"the",
"next",
"node",
"that",
"is",
"ready",
"to",
"be",
"built",
"."
] | python | train | 42.753927 |
insightindustry/validator-collection | validator_collection/validators.py | https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/validators.py#L716-L892 | def datetime(value,
allow_empty = False,
minimum = None,
maximum = None,
coerce_value = True,
**kwargs):
"""Validate that ``value`` is a valid datetime.
.. caution::
If supplying a string, the string needs to be in an ISO 8601-format to pa... | [
"def",
"datetime",
"(",
"value",
",",
"allow_empty",
"=",
"False",
",",
"minimum",
"=",
"None",
",",
"maximum",
"=",
"None",
",",
"coerce_value",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=too-many-branches",
"if",
"not",
"value",
"... | Validate that ``value`` is a valid datetime.
.. caution::
If supplying a string, the string needs to be in an ISO 8601-format to pass
validation. If it is not in an ISO 8601-format, validation will fail.
:param value: The value to validate.
:type value: :class:`str <python:str>` / :class:`dat... | [
"Validate",
"that",
"value",
"is",
"a",
"valid",
"datetime",
"."
] | python | train | 47.79661 |
michael-lazar/rtv | rtv/packages/praw/__init__.py | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1008-L1024 | def get_random_subreddit(self, nsfw=False):
"""Return a random Subreddit object.
:param nsfw: When true, return a random NSFW Subreddit object. Calling
in this manner will set the 'over18' cookie for the duration of the
PRAW session.
"""
path = 'random'
... | [
"def",
"get_random_subreddit",
"(",
"self",
",",
"nsfw",
"=",
"False",
")",
":",
"path",
"=",
"'random'",
"if",
"nsfw",
":",
"self",
".",
"http",
".",
"cookies",
".",
"set",
"(",
"'over18'",
",",
"'1'",
")",
"path",
"=",
"'randnsfw'",
"url",
"=",
"se... | Return a random Subreddit object.
:param nsfw: When true, return a random NSFW Subreddit object. Calling
in this manner will set the 'over18' cookie for the duration of the
PRAW session. | [
"Return",
"a",
"random",
"Subreddit",
"object",
"."
] | python | train | 40.058824 |
log2timeline/plaso | plaso/parsers/bsm.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/bsm.py#L728-L744 | def _ParseTokenType(self, file_object, file_offset):
"""Parses a token type.
Args:
file_object (dfvfs.FileIO): file-like object.
file_offset (int): offset of the token relative to the start of
the file-like object.
Returns:
int: token type
"""
token_type_map = self._Get... | [
"def",
"_ParseTokenType",
"(",
"self",
",",
"file_object",
",",
"file_offset",
")",
":",
"token_type_map",
"=",
"self",
".",
"_GetDataTypeMap",
"(",
"'uint8'",
")",
"token_type",
",",
"_",
"=",
"self",
".",
"_ReadStructureFromFileObject",
"(",
"file_object",
","... | Parses a token type.
Args:
file_object (dfvfs.FileIO): file-like object.
file_offset (int): offset of the token relative to the start of
the file-like object.
Returns:
int: token type | [
"Parses",
"a",
"token",
"type",
"."
] | python | train | 26.647059 |
smarie/python-parsyfiles | parsyfiles/parsing_core_api.py | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core_api.py#L275-L291 | def create_for_wrong_result_type(parser: _BaseParserDeclarationForRegistries, desired_type: Type[T],
obj: PersistedObject, result: T, options: Dict[str, Dict[str, Any]]):
"""
Helper method provided because we actually can't put that in the constructor, it creates a b... | [
"def",
"create_for_wrong_result_type",
"(",
"parser",
":",
"_BaseParserDeclarationForRegistries",
",",
"desired_type",
":",
"Type",
"[",
"T",
"]",
",",
"obj",
":",
"PersistedObject",
",",
"result",
":",
"T",
",",
"options",
":",
"Dict",
"[",
"str",
",",
"Dict"... | Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests
https://github.com/nose-devs/nose/issues/725
:param parser:
:param desired_type:
:param obj:
:param result:
:param options:
:return: | [
"Helper",
"method",
"provided",
"because",
"we",
"actually",
"can",
"t",
"put",
"that",
"in",
"the",
"constructor",
"it",
"creates",
"a",
"bug",
"in",
"Nose",
"tests",
"https",
":",
"//",
"github",
".",
"com",
"/",
"nose",
"-",
"devs",
"/",
"nose",
"/"... | python | train | 52.470588 |
ruipgil/TrackToTrip | tracktotrip/track.py | https://github.com/ruipgil/TrackToTrip/blob/5537c14ee9748091b5255b658ab528e1d6227f99/tracktotrip/track.py#L82-L97 | def segment(self, eps, min_time):
"""In-place segmentation of segments
Spatio-temporal segmentation of each segment
The number of segments may increse after this step
Returns:
This track
"""
new_segments = []
for segment in self.segments:
... | [
"def",
"segment",
"(",
"self",
",",
"eps",
",",
"min_time",
")",
":",
"new_segments",
"=",
"[",
"]",
"for",
"segment",
"in",
"self",
".",
"segments",
":",
"segmented",
"=",
"segment",
".",
"segment",
"(",
"eps",
",",
"min_time",
")",
"for",
"seg",
"i... | In-place segmentation of segments
Spatio-temporal segmentation of each segment
The number of segments may increse after this step
Returns:
This track | [
"In",
"-",
"place",
"segmentation",
"of",
"segments"
] | python | train | 30.5625 |
Kaggle/kaggle-api | kaggle/api/kaggle_api.py | https://github.com/Kaggle/kaggle-api/blob/65f14b1386470c5784d4753e491478e7537660d9/kaggle/api/kaggle_api.py#L973-L992 | def datasets_create_new(self, dataset_new_request, **kwargs): # noqa: E501
"""Create a new dataset # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_create_new(dataset_new_re... | [
"def",
"datasets_create_new",
"(",
"self",
",",
"dataset_new_request",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
... | Create a new dataset # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_create_new(dataset_new_request, async_req=True)
>>> result = thread.get()
:param async_req bool... | [
"Create",
"a",
"new",
"dataset",
"#",
"noqa",
":",
"E501"
] | python | train | 48.1 |
scrapinghub/kafka-scanner | kafka_scanner/msg_processor_handlers.py | https://github.com/scrapinghub/kafka-scanner/blob/8a71901012e8c948180f70a485b57f8d2e7e3ec1/kafka_scanner/msg_processor_handlers.py#L85-L91 | def decompress_messages(self, partitions_offmsgs):
""" Decompress pre-defined compressed fields for each message. """
for pomsg in partitions_offmsgs:
if pomsg['message']:
pomsg['message'] = self.decompress_fun(pomsg['message'])
yield pomsg | [
"def",
"decompress_messages",
"(",
"self",
",",
"partitions_offmsgs",
")",
":",
"for",
"pomsg",
"in",
"partitions_offmsgs",
":",
"if",
"pomsg",
"[",
"'message'",
"]",
":",
"pomsg",
"[",
"'message'",
"]",
"=",
"self",
".",
"decompress_fun",
"(",
"pomsg",
"[",... | Decompress pre-defined compressed fields for each message. | [
"Decompress",
"pre",
"-",
"defined",
"compressed",
"fields",
"for",
"each",
"message",
"."
] | python | train | 41.571429 |
honzajavorek/redis-collections | redis_collections/lists.py | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L482-L498 | def reverse(self):
"""
Reverses the items of this collection "in place" (only two values are
retrieved from Redis at a time).
"""
def reverse_trans(pipe):
if self.writeback:
self._sync_helper(pipe)
n = self.__len__(pipe)
for i ... | [
"def",
"reverse",
"(",
"self",
")",
":",
"def",
"reverse_trans",
"(",
"pipe",
")",
":",
"if",
"self",
".",
"writeback",
":",
"self",
".",
"_sync_helper",
"(",
"pipe",
")",
"n",
"=",
"self",
".",
"__len__",
"(",
"pipe",
")",
"for",
"i",
"in",
"range... | Reverses the items of this collection "in place" (only two values are
retrieved from Redis at a time). | [
"Reverses",
"the",
"items",
"of",
"this",
"collection",
"in",
"place",
"(",
"only",
"two",
"values",
"are",
"retrieved",
"from",
"Redis",
"at",
"a",
"time",
")",
"."
] | python | train | 33.352941 |
ArchiveTeam/wpull | wpull/application/tasks/download.py | https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/application/tasks/download.py#L259-L271 | def _build_processor(cls, session: AppSession):
'''Create the Processor
Returns:
Processor: An instance of :class:`.processor.BaseProcessor`.
'''
web_processor = cls._build_web_processor(session)
ftp_processor = cls._build_ftp_processor(session)
delegate_proc... | [
"def",
"_build_processor",
"(",
"cls",
",",
"session",
":",
"AppSession",
")",
":",
"web_processor",
"=",
"cls",
".",
"_build_web_processor",
"(",
"session",
")",
"ftp_processor",
"=",
"cls",
".",
"_build_ftp_processor",
"(",
"session",
")",
"delegate_processor",
... | Create the Processor
Returns:
Processor: An instance of :class:`.processor.BaseProcessor`. | [
"Create",
"the",
"Processor"
] | python | train | 40.461538 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/guerilla/guerillamgmt.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/guerilla/guerillamgmt.py#L1173-L1185 | def create_seq(self, project):
"""Create and return a new sequence
:param project: the project for the sequence
:type deps: :class:`jukeboxcore.djadapter.models.Project`
:returns: The created sequence or None
:rtype: None | :class:`jukeboxcore.djadapter.models.Sequence`
... | [
"def",
"create_seq",
"(",
"self",
",",
"project",
")",
":",
"dialog",
"=",
"SequenceCreatorDialog",
"(",
"project",
"=",
"project",
",",
"parent",
"=",
"self",
")",
"dialog",
".",
"exec_",
"(",
")",
"seq",
"=",
"dialog",
".",
"sequence",
"return",
"seq"
... | Create and return a new sequence
:param project: the project for the sequence
:type deps: :class:`jukeboxcore.djadapter.models.Project`
:returns: The created sequence or None
:rtype: None | :class:`jukeboxcore.djadapter.models.Sequence`
:raises: None | [
"Create",
"and",
"return",
"a",
"new",
"sequence"
] | python | train | 36.461538 |
google/grr | grr/server/grr_response_server/databases/mysql_flows.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_flows.py#L1230-L1237 | def UnregisterFlowProcessingHandler(self, timeout=None):
"""Unregisters any registered flow processing handler."""
if self.flow_processing_request_handler_thread:
self.flow_processing_request_handler_stop = True
self.flow_processing_request_handler_thread.join(timeout)
if self.flow_processing_... | [
"def",
"UnregisterFlowProcessingHandler",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"flow_processing_request_handler_thread",
":",
"self",
".",
"flow_processing_request_handler_stop",
"=",
"True",
"self",
".",
"flow_processing_request_handler_... | Unregisters any registered flow processing handler. | [
"Unregisters",
"any",
"registered",
"flow",
"processing",
"handler",
"."
] | python | train | 59.875 |
kwikteam/phy | phy/plot/plot.py | https://github.com/kwikteam/phy/blob/7e9313dc364304b7d2bd03b92938347343703003/phy/plot/plot.py#L153-L158 | def scatter(self, *args, **kwargs):
"""Add a scatter plot."""
cls = _make_class(ScatterVisual,
_default_marker=kwargs.pop('marker', None),
)
return self._add_item(cls, *args, **kwargs) | [
"def",
"scatter",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cls",
"=",
"_make_class",
"(",
"ScatterVisual",
",",
"_default_marker",
"=",
"kwargs",
".",
"pop",
"(",
"'marker'",
",",
"None",
")",
",",
")",
"return",
"self",
"."... | Add a scatter plot. | [
"Add",
"a",
"scatter",
"plot",
"."
] | python | train | 42.5 |
saltstack/salt | salt/modules/systemd_service.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/systemd_service.py#L73-L80 | def _root(path, root):
'''
Relocate an absolute path to a new root directory.
'''
if root:
return os.path.join(root, os.path.relpath(path, os.path.sep))
else:
return path | [
"def",
"_root",
"(",
"path",
",",
"root",
")",
":",
"if",
"root",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"os",
".",
"path",
".",
"relpath",
"(",
"path",
",",
"os",
".",
"path",
".",
"sep",
")",
")",
"else",
":",
"ret... | Relocate an absolute path to a new root directory. | [
"Relocate",
"an",
"absolute",
"path",
"to",
"a",
"new",
"root",
"directory",
"."
] | python | train | 24.875 |
Chilipp/funcargparse | funcargparse/__init__.py | https://github.com/Chilipp/funcargparse/blob/398ce8e7fa5aa35c465215446bda151cf1ecf7ad/funcargparse/__init__.py#L1006-L1022 | def get_subparser(self, name):
"""
Convenience method to get a certain subparser
Parameters
----------
name: str
The name of the subparser
Returns
-------
FuncArgParser
The subparsers corresponding to `name`
"""
if... | [
"def",
"get_subparser",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_subparsers_action",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"%s has no subparsers defined!\"",
"%",
"self",
")",
"return",
"self",
".",
"_subparsers_action",
".",
"choices"... | Convenience method to get a certain subparser
Parameters
----------
name: str
The name of the subparser
Returns
-------
FuncArgParser
The subparsers corresponding to `name` | [
"Convenience",
"method",
"to",
"get",
"a",
"certain",
"subparser"
] | python | train | 27 |
pyblish/pyblish-houdini | pyblish_houdini/lib.py | https://github.com/pyblish/pyblish-houdini/blob/661b08696f04b4c5d8b03aa0c75cba3ca72f1e8d/pyblish_houdini/lib.py#L20-L38 | def setup(console=False, port=None):
"""Setup integration
Register plug-ins and integrate into the host
Arguments:
console (bool): DEPRECATED
port (int, optional): DEPRECATED
"""
if self._has_been_setup:
teardown()
register_plugins()
register_host()
self._ha... | [
"def",
"setup",
"(",
"console",
"=",
"False",
",",
"port",
"=",
"None",
")",
":",
"if",
"self",
".",
"_has_been_setup",
":",
"teardown",
"(",
")",
"register_plugins",
"(",
")",
"register_host",
"(",
")",
"self",
".",
"_has_been_setup",
"=",
"True",
"prin... | Setup integration
Register plug-ins and integrate into the host
Arguments:
console (bool): DEPRECATED
port (int, optional): DEPRECATED | [
"Setup",
"integration"
] | python | train | 19.578947 |
DataBiosphere/toil | src/toil/common.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/common.py#L1001-L1027 | def getWorkflowDir(workflowID, configWorkDir=None):
"""
Returns a path to the directory where worker directories and the cache will be located
for this workflow.
:param str workflowID: Unique identifier for the workflow
:param str configWorkDir: Value passed to the program using... | [
"def",
"getWorkflowDir",
"(",
"workflowID",
",",
"configWorkDir",
"=",
"None",
")",
":",
"workDir",
"=",
"configWorkDir",
"or",
"os",
".",
"getenv",
"(",
"'TOIL_WORKDIR'",
")",
"or",
"tempfile",
".",
"gettempdir",
"(",
")",
"if",
"not",
"os",
".",
"path",
... | Returns a path to the directory where worker directories and the cache will be located
for this workflow.
:param str workflowID: Unique identifier for the workflow
:param str configWorkDir: Value passed to the program using the --workDir flag
:return: Path to the workflow directory
... | [
"Returns",
"a",
"path",
"to",
"the",
"directory",
"where",
"worker",
"directories",
"and",
"the",
"cache",
"will",
"be",
"located",
"for",
"this",
"workflow",
"."
] | python | train | 48.555556 |
tradenity/python-sdk | tradenity/resources/table_rate_rule.py | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/table_rate_rule.py#L492-L512 | def get_table_rate_rule_by_id(cls, table_rate_rule_id, **kwargs):
"""Find TableRateRule
Return single instance of TableRateRule by its ID.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_t... | [
"def",
"get_table_rate_rule_by_id",
"(",
"cls",
",",
"table_rate_rule_id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async'",
")",
":",
"return",
"cls",
".",
"_get_table... | Find TableRateRule
Return single instance of TableRateRule by its ID.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_table_rate_rule_by_id(table_rate_rule_id, async=True)
>>> result = thr... | [
"Find",
"TableRateRule"
] | python | train | 45.142857 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py#L1380-L1394 | def get_media_detail_output_interface_interface_name(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_media_detail = ET.Element("get_media_detail")
config = get_media_detail
output = ET.SubElement(get_media_detail, "output")
interface ... | [
"def",
"get_media_detail_output_interface_interface_name",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_media_detail",
"=",
"ET",
".",
"Element",
"(",
"\"get_media_detail\"",
")",
"config",
"="... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 46.333333 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.