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 |
|---|---|---|---|---|---|---|---|---|---|
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L59-L61 | def debug(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.debug``"""
return self.logger.debug(self._indent(msg, indent), **kwargs) | [
"def",
"debug",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"debug",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | invoke ``self.logger.debug`` | [
"invoke",
"self",
".",
"logger",
".",
"debug"
] | python | train | 50.666667 |
jmurty/xml4h | xml4h/__init__.py | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/__init__.py#L41-L70 | def parse(to_parse, ignore_whitespace_text_nodes=True, adapter=None):
"""
Parse an XML document into an *xml4h*-wrapped DOM representation
using an underlying XML library implementation.
:param to_parse: an XML document file, document string, or the
path to an XML file. If a string value is giv... | [
"def",
"parse",
"(",
"to_parse",
",",
"ignore_whitespace_text_nodes",
"=",
"True",
",",
"adapter",
"=",
"None",
")",
":",
"if",
"adapter",
"is",
"None",
":",
"adapter",
"=",
"best_adapter",
"if",
"isinstance",
"(",
"to_parse",
",",
"basestring",
")",
"and",
... | Parse an XML document into an *xml4h*-wrapped DOM representation
using an underlying XML library implementation.
:param to_parse: an XML document file, document string, or the
path to an XML file. If a string value is given that contains
a ``<`` character it is treated as literal XML data, othe... | [
"Parse",
"an",
"XML",
"document",
"into",
"an",
"*",
"xml4h",
"*",
"-",
"wrapped",
"DOM",
"representation",
"using",
"an",
"underlying",
"XML",
"library",
"implementation",
"."
] | python | train | 48.233333 |
delph-in/pydelphin | delphin/itsdb.py | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/itsdb.py#L1603-L1645 | def select_rows(cols, rows, mode='list', cast=True):
"""
Yield data selected from rows.
It is sometimes useful to select a subset of data from a profile.
This function selects the data in *cols* from *rows* and yields it
in a form specified by *mode*. Possible values of *mode* are:
===========... | [
"def",
"select_rows",
"(",
"cols",
",",
"rows",
",",
"mode",
"=",
"'list'",
",",
"cast",
"=",
"True",
")",
":",
"mode",
"=",
"mode",
".",
"lower",
"(",
")",
"if",
"mode",
"==",
"'list'",
":",
"modecast",
"=",
"lambda",
"cols",
",",
"data",
":",
"... | Yield data selected from rows.
It is sometimes useful to select a subset of data from a profile.
This function selects the data in *cols* from *rows* and yields it
in a form specified by *mode*. Possible values of *mode* are:
================== ================= ==========================
mode ... | [
"Yield",
"data",
"selected",
"from",
"rows",
"."
] | python | train | 40 |
learningequality/morango | morango/utils/sync_utils.py | https://github.com/learningequality/morango/blob/c3ec2554b026f65ac5f0fc5c9d439277fbac14f9/morango/utils/sync_utils.py#L38-L47 | def _fsic_queuing_calc(fsic1, fsic2):
"""
We set the lower counter between two same instance ids.
If an instance_id exists in one fsic but not the other we want to give that counter a value of 0.
:param fsic1: dictionary containing (instance_id, counter) pairs
:param fsic2: dictionary containing (i... | [
"def",
"_fsic_queuing_calc",
"(",
"fsic1",
",",
"fsic2",
")",
":",
"return",
"{",
"instance",
":",
"fsic2",
".",
"get",
"(",
"instance",
",",
"0",
")",
"for",
"instance",
",",
"counter",
"in",
"six",
".",
"iteritems",
"(",
"fsic1",
")",
"if",
"fsic2",
... | We set the lower counter between two same instance ids.
If an instance_id exists in one fsic but not the other we want to give that counter a value of 0.
:param fsic1: dictionary containing (instance_id, counter) pairs
:param fsic2: dictionary containing (instance_id, counter) pairs
:return ``dict`` of... | [
"We",
"set",
"the",
"lower",
"counter",
"between",
"two",
"same",
"instance",
"ids",
".",
"If",
"an",
"instance_id",
"exists",
"in",
"one",
"fsic",
"but",
"not",
"the",
"other",
"we",
"want",
"to",
"give",
"that",
"counter",
"a",
"value",
"of",
"0",
".... | python | valid | 56 |
senaite/senaite.core | bika/lims/browser/analysisrequest/add2.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/analysisrequest/add2.py#L486-L510 | def get_service_categories(self, restricted=True):
"""Return all service categories in the right order
:param restricted: Client settings restrict categories
:type restricted: bool
:returns: Category catalog results
:rtype: brains
"""
bsc = api.get_tool("bika_set... | [
"def",
"get_service_categories",
"(",
"self",
",",
"restricted",
"=",
"True",
")",
":",
"bsc",
"=",
"api",
".",
"get_tool",
"(",
"\"bika_setup_catalog\"",
")",
"query",
"=",
"{",
"\"portal_type\"",
":",
"\"AnalysisCategory\"",
",",
"\"is_active\"",
":",
"True",
... | Return all service categories in the right order
:param restricted: Client settings restrict categories
:type restricted: bool
:returns: Category catalog results
:rtype: brains | [
"Return",
"all",
"service",
"categories",
"in",
"the",
"right",
"order"
] | python | train | 38.24 |
nkavaldj/myhdl_lib | myhdl_lib/simulation/_DUTer.py | https://github.com/nkavaldj/myhdl_lib/blob/9902afd2031e7847373f692821b2135fd0810aa8/myhdl_lib/simulation/_DUTer.py#L29-L51 | def registerSimulator(self, name=None, hdl=None, analyze_cmd=None, elaborate_cmd=None, simulate_cmd=None):
''' Registers an HDL _simulator
name - str, user defined name, used to identify this _simulator record
hdl - str, case insensitive, (verilog, vhdl), the HDL to which the sim... | [
"def",
"registerSimulator",
"(",
"self",
",",
"name",
"=",
"None",
",",
"hdl",
"=",
"None",
",",
"analyze_cmd",
"=",
"None",
",",
"elaborate_cmd",
"=",
"None",
",",
"simulate_cmd",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"st... | Registers an HDL _simulator
name - str, user defined name, used to identify this _simulator record
hdl - str, case insensitive, (verilog, vhdl), the HDL to which the simulated MyHDL code will be converted
analyze_cmd - str, system command that will be run to analyze the g... | [
"Registers",
"an",
"HDL",
"_simulator",
"name",
"-",
"str",
"user",
"defined",
"name",
"used",
"to",
"identify",
"this",
"_simulator",
"record",
"hdl",
"-",
"str",
"case",
"insensitive",
"(",
"verilog",
"vhdl",
")",
"the",
"HDL",
"to",
"which",
"the",
"sim... | python | train | 70.217391 |
freelawproject/reporters-db | reporters_db/utils.py | https://github.com/freelawproject/reporters-db/blob/ee17ee38a4e39de8d83beb78d84d146cd7e8afbc/reporters_db/utils.py#L7-L34 | def suck_out_variations_only(reporters):
"""Builds a dictionary of variations to canonical reporters.
The dictionary takes the form of:
{
"A. 2d": ["A.2d"],
...
"P.R.": ["Pen. & W.", "P.R.R.", "P."],
}
In other words, it's a dictionary that maps each variation to... | [
"def",
"suck_out_variations_only",
"(",
"reporters",
")",
":",
"variations_out",
"=",
"{",
"}",
"for",
"reporter_key",
",",
"data_list",
"in",
"reporters",
".",
"items",
"(",
")",
":",
"# For each reporter key...",
"for",
"data",
"in",
"data_list",
":",
"# For e... | Builds a dictionary of variations to canonical reporters.
The dictionary takes the form of:
{
"A. 2d": ["A.2d"],
...
"P.R.": ["Pen. & W.", "P.R.R.", "P."],
}
In other words, it's a dictionary that maps each variation to a list of
reporters that it could be possib... | [
"Builds",
"a",
"dictionary",
"of",
"variations",
"to",
"canonical",
"reporters",
"."
] | python | train | 36.714286 |
RudolfCardinal/pythonlib | cardinal_pythonlib/django/serve.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/serve.py#L166-L175 | def file_response(data: Union[bytes, str], # HttpResponse encodes str if req'd
content_type: str,
filename: str) -> HttpResponse:
"""
Returns an ``HttpResponse`` with an attachment containing the specified
data with the specified filename as an attachment.
"""
re... | [
"def",
"file_response",
"(",
"data",
":",
"Union",
"[",
"bytes",
",",
"str",
"]",
",",
"# HttpResponse encodes str if req'd",
"content_type",
":",
"str",
",",
"filename",
":",
"str",
")",
"->",
"HttpResponse",
":",
"response",
"=",
"HttpResponse",
"(",
"data",... | Returns an ``HttpResponse`` with an attachment containing the specified
data with the specified filename as an attachment. | [
"Returns",
"an",
"HttpResponse",
"with",
"an",
"attachment",
"containing",
"the",
"specified",
"data",
"with",
"the",
"specified",
"filename",
"as",
"an",
"attachment",
"."
] | python | train | 43.1 |
mikemaccana/python-docx | docx.py | https://github.com/mikemaccana/python-docx/blob/4c9b46dbebe3d2a9b82dbcd35af36584a36fd9fe/docx.py#L759-L907 | def advReplace(document, search, replace, bs=3):
"""
Replace all occurences of string with a different string, return updated
document
This is a modified version of python-docx.replace() that takes into
account blocks of <bs> elements at a time. The replace element can also
be a string or an xm... | [
"def",
"advReplace",
"(",
"document",
",",
"search",
",",
"replace",
",",
"bs",
"=",
"3",
")",
":",
"# Enables debug output",
"DEBUG",
"=",
"False",
"newdocument",
"=",
"document",
"# Compile the search regexp",
"searchre",
"=",
"re",
".",
"compile",
"(",
"sea... | Replace all occurences of string with a different string, return updated
document
This is a modified version of python-docx.replace() that takes into
account blocks of <bs> elements at a time. The replace element can also
be a string or an xml etree element.
What it does:
It searches the entir... | [
"Replace",
"all",
"occurences",
"of",
"string",
"with",
"a",
"different",
"string",
"return",
"updated",
"document"
] | python | train | 48.812081 |
osrg/ryu | ryu/services/protocols/bgp/peer.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/peer.py#L970-L1254 | def _construct_update(self, outgoing_route):
"""Construct update message with Outgoing-routes path attribute
appropriately cloned/copied/updated.
"""
update = None
path = outgoing_route.path
# Get copy of path's path attributes.
pathattr_map = path.pathattr_map
... | [
"def",
"_construct_update",
"(",
"self",
",",
"outgoing_route",
")",
":",
"update",
"=",
"None",
"path",
"=",
"outgoing_route",
".",
"path",
"# Get copy of path's path attributes.",
"pathattr_map",
"=",
"path",
".",
"pathattr_map",
"new_pathattr",
"=",
"[",
"]",
"... | Construct update message with Outgoing-routes path attribute
appropriately cloned/copied/updated. | [
"Construct",
"update",
"message",
"with",
"Outgoing",
"-",
"routes",
"path",
"attribute",
"appropriately",
"cloned",
"/",
"copied",
"/",
"updated",
"."
] | python | train | 46.677193 |
bskinn/opan | opan/utils/symm.py | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L779-L832 | def mtx_refl(nv, reps=1):
""" Generate block-diagonal reflection matrix about nv.
reps must be >=1 and indicates the number of times the reflection
matrix should be repeated along the block diagonal. Typically this
will be the number of atoms in a geometry.
.. todo:: Complete mtx_refl docstring
... | [
"def",
"mtx_refl",
"(",
"nv",
",",
"reps",
"=",
"1",
")",
":",
"# Imports",
"import",
"numpy",
"as",
"np",
"from",
"scipy",
"import",
"linalg",
"as",
"spla",
"from",
".",
".",
"const",
"import",
"PRM",
"# Ensure |nv| is large enough for confident directionality"... | Generate block-diagonal reflection matrix about nv.
reps must be >=1 and indicates the number of times the reflection
matrix should be repeated along the block diagonal. Typically this
will be the number of atoms in a geometry.
.. todo:: Complete mtx_refl docstring | [
"Generate",
"block",
"-",
"diagonal",
"reflection",
"matrix",
"about",
"nv",
"."
] | python | train | 29.833333 |
Opentrons/opentrons | update-server/otupdate/balena/install.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/update-server/otupdate/balena/install.py#L95-L139 | async def _update_firmware(filename, loop):
"""
Currently uses the robot singleton from the API server to connect to
Smoothie. Those calls should be separated out from the singleton so it can
be used directly without requiring a full initialization of the API robot.
"""
try:
from opentro... | [
"async",
"def",
"_update_firmware",
"(",
"filename",
",",
"loop",
")",
":",
"try",
":",
"from",
"opentrons",
"import",
"robot",
"except",
"ModuleNotFoundError",
":",
"res",
"=",
"\"Unable to find module `opentrons`--not updating firmware\"",
"rc",
"=",
"1",
"log",
"... | Currently uses the robot singleton from the API server to connect to
Smoothie. Those calls should be separated out from the singleton so it can
be used directly without requiring a full initialization of the API robot. | [
"Currently",
"uses",
"the",
"robot",
"singleton",
"from",
"the",
"API",
"server",
"to",
"connect",
"to",
"Smoothie",
".",
"Those",
"calls",
"should",
"be",
"separated",
"out",
"from",
"the",
"singleton",
"so",
"it",
"can",
"be",
"used",
"directly",
"without"... | python | train | 34.733333 |
hyperledger/indy-plenum | plenum/server/replica.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L2785-L2800 | def revert_unordered_batches(self):
"""
Revert changes to ledger (uncommitted) and state made by any requests
that have not been ordered.
"""
i = 0
for key in sorted(self.batches.keys(), reverse=True):
if compare_3PC_keys(self.last_ordered_3pc, key) > 0:
... | [
"def",
"revert_unordered_batches",
"(",
"self",
")",
":",
"i",
"=",
"0",
"for",
"key",
"in",
"sorted",
"(",
"self",
".",
"batches",
".",
"keys",
"(",
")",
",",
"reverse",
"=",
"True",
")",
":",
"if",
"compare_3PC_keys",
"(",
"self",
".",
"last_ordered_... | Revert changes to ledger (uncommitted) and state made by any requests
that have not been ordered. | [
"Revert",
"changes",
"to",
"ledger",
"(",
"uncommitted",
")",
"and",
"state",
"made",
"by",
"any",
"requests",
"that",
"have",
"not",
"been",
"ordered",
"."
] | python | train | 44.25 |
sdispater/orator | orator/migrations/migrator.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/migrator.py#L224-L242 | def _get_queries(self, migration, method):
"""
Get all of the queries that would be run for a migration.
:param migration: The migration
:type migration: orator.migrations.migration.Migration
:param method: The method to execute
:type method: str
:rtype: list
... | [
"def",
"_get_queries",
"(",
"self",
",",
"migration",
",",
"method",
")",
":",
"connection",
"=",
"migration",
".",
"get_connection",
"(",
")",
"db",
"=",
"connection",
"with",
"db",
".",
"pretend",
"(",
")",
":",
"getattr",
"(",
"migration",
",",
"metho... | Get all of the queries that would be run for a migration.
:param migration: The migration
:type migration: orator.migrations.migration.Migration
:param method: The method to execute
:type method: str
:rtype: list | [
"Get",
"all",
"of",
"the",
"queries",
"that",
"would",
"be",
"run",
"for",
"a",
"migration",
"."
] | python | train | 25.947368 |
escaped/django-video-encoding | video_encoding/backends/ffmpeg.py | https://github.com/escaped/django-video-encoding/blob/50d228dd91aca40acc7f9293808b1e87cb645e5d/video_encoding/backends/ffmpeg.py#L84-L139 | def encode(self, source_path, target_path, params): # NOQA: C901
"""
Encodes a video to a specified file. All encoder specific options
are passed in using `params`.
"""
total_time = self.get_media_info(source_path)['duration']
cmds = [self.ffmpeg_path, '-i', source_path... | [
"def",
"encode",
"(",
"self",
",",
"source_path",
",",
"target_path",
",",
"params",
")",
":",
"# NOQA: C901",
"total_time",
"=",
"self",
".",
"get_media_info",
"(",
"source_path",
")",
"[",
"'duration'",
"]",
"cmds",
"=",
"[",
"self",
".",
"ffmpeg_path",
... | Encodes a video to a specified file. All encoder specific options
are passed in using `params`. | [
"Encodes",
"a",
"video",
"to",
"a",
"specified",
"file",
".",
"All",
"encoder",
"specific",
"options",
"are",
"passed",
"in",
"using",
"params",
"."
] | python | train | 27.732143 |
nickw444/flask-ldap3-login | flask_ldap3_login/__init__.py | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L758-L797 | def _make_connection(self, bind_user=None, bind_password=None,
contextualise=True, **kwargs):
"""
Make a connection.
Args:
bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
used, otherwise authentication specified with
... | [
"def",
"_make_connection",
"(",
"self",
",",
"bind_user",
"=",
"None",
",",
"bind_password",
"=",
"None",
",",
"contextualise",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"authentication",
"=",
"ldap3",
".",
"ANONYMOUS",
"if",
"bind_user",
":",
"authe... | Make a connection.
Args:
bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
used, otherwise authentication specified with
config['LDAP_BIND_AUTHENTICATION_TYPE'] is used.
bind_password (str): Password to bind to the directory with
... | [
"Make",
"a",
"connection",
"."
] | python | test | 38.3 |
DBuildService/dockerfile-parse | dockerfile_parse/parser.py | https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/parser.py#L153-L166 | def lines(self, lines):
"""
Fill Dockerfile content with specified lines
:param lines: list of lines to be written to Dockerfile
"""
if self.cache_content:
self.cached_content = ''.join([b2u(l) for l in lines])
try:
with self._open_dockerfile('wb'... | [
"def",
"lines",
"(",
"self",
",",
"lines",
")",
":",
"if",
"self",
".",
"cache_content",
":",
"self",
".",
"cached_content",
"=",
"''",
".",
"join",
"(",
"[",
"b2u",
"(",
"l",
")",
"for",
"l",
"in",
"lines",
"]",
")",
"try",
":",
"with",
"self",
... | Fill Dockerfile content with specified lines
:param lines: list of lines to be written to Dockerfile | [
"Fill",
"Dockerfile",
"content",
"with",
"specified",
"lines",
":",
"param",
"lines",
":",
"list",
"of",
"lines",
"to",
"be",
"written",
"to",
"Dockerfile"
] | python | train | 36.857143 |
ninapavlich/django-imagekit-cropper | imagekit_cropper/utils.py | https://github.com/ninapavlich/django-imagekit-cropper/blob/c1c2dc5c3c4724492052e5d244e9de1cc362dbcc/imagekit_cropper/utils.py#L87-L114 | def source_group_receiver(self, sender, source, signal, **kwargs):
"""
Relay source group signals to the appropriate spec strategy.
"""
from imagekit.cachefiles import ImageCacheFile
source_group = sender
instance = kwargs['instance']
# Ignore signals from unre... | [
"def",
"source_group_receiver",
"(",
"self",
",",
"sender",
",",
"source",
",",
"signal",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"imagekit",
".",
"cachefiles",
"import",
"ImageCacheFile",
"source_group",
"=",
"sender",
"instance",
"=",
"kwargs",
"[",
"'i... | Relay source group signals to the appropriate spec strategy. | [
"Relay",
"source",
"group",
"signals",
"to",
"the",
"appropriate",
"spec",
"strategy",
"."
] | python | train | 38.964286 |
incuna/incuna-auth | incuna_auth/middleware/permission_feincms.py | https://github.com/incuna/incuna-auth/blob/949ccd922da15a4b5de17b9595cc8f5114d5385c/incuna_auth/middleware/permission_feincms.py#L43-L70 | def _get_resource_access_state(self, request):
"""
Returns the FeinCMS resource's access_state, following any INHERITed values.
Will return None if the resource has an access state that should never be
protected. It should not be possible to protect a resource with an access_state
... | [
"def",
"_get_resource_access_state",
"(",
"self",
",",
"request",
")",
":",
"feincms_page",
"=",
"self",
".",
"_get_page_from_path",
"(",
"request",
".",
"path_info",
".",
"lstrip",
"(",
"'/'",
")",
")",
"if",
"not",
"feincms_page",
":",
"return",
"None",
"#... | Returns the FeinCMS resource's access_state, following any INHERITed values.
Will return None if the resource has an access state that should never be
protected. It should not be possible to protect a resource with an access_state
of STATE_ALL_ALLOWED, or an access_state of STATE_INHERIT and no... | [
"Returns",
"the",
"FeinCMS",
"resource",
"s",
"access_state",
"following",
"any",
"INHERITed",
"values",
"."
] | python | train | 46.357143 |
openvax/isovar | isovar/variant_sequences.py | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequences.py#L319-L336 | def trim_variant_sequences(variant_sequences, min_variant_sequence_coverage):
"""
Trim VariantSequences to desired coverage and then combine any
subsequences which get generated.
"""
n_total = len(variant_sequences)
trimmed_variant_sequences = [
variant_sequence.trim_by_coverage(min_vari... | [
"def",
"trim_variant_sequences",
"(",
"variant_sequences",
",",
"min_variant_sequence_coverage",
")",
":",
"n_total",
"=",
"len",
"(",
"variant_sequences",
")",
"trimmed_variant_sequences",
"=",
"[",
"variant_sequence",
".",
"trim_by_coverage",
"(",
"min_variant_sequence_co... | Trim VariantSequences to desired coverage and then combine any
subsequences which get generated. | [
"Trim",
"VariantSequences",
"to",
"desired",
"coverage",
"and",
"then",
"combine",
"any",
"subsequences",
"which",
"get",
"generated",
"."
] | python | train | 40.777778 |
gmr/helper | helper/__init__.py | https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/__init__.py#L149-L171 | def start(controller_class):
"""Start the Helper controller either in the foreground or as a daemon
process.
:param controller_class: The controller class handle to create and run
:type controller_class: callable
"""
args = parser.parse()
obj = controller_class(args, platform.operating_sys... | [
"def",
"start",
"(",
"controller_class",
")",
":",
"args",
"=",
"parser",
".",
"parse",
"(",
")",
"obj",
"=",
"controller_class",
"(",
"args",
",",
"platform",
".",
"operating_system",
"(",
")",
")",
"if",
"args",
".",
"foreground",
":",
"try",
":",
"o... | Start the Helper controller either in the foreground or as a daemon
process.
:param controller_class: The controller class handle to create and run
:type controller_class: callable | [
"Start",
"the",
"Helper",
"controller",
"either",
"in",
"the",
"foreground",
"or",
"as",
"a",
"daemon",
"process",
"."
] | python | train | 30.782609 |
inveniosoftware-attic/invenio-utils | invenio_utils/text.py | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L793-L839 | def show_diff(original, modified, prefix='', suffix='',
prefix_unchanged=' ',
suffix_unchanged='',
prefix_removed='-',
suffix_removed='',
prefix_added='+',
suffix_added=''):
"""Return the diff view between original and modified stri... | [
"def",
"show_diff",
"(",
"original",
",",
"modified",
",",
"prefix",
"=",
"''",
",",
"suffix",
"=",
"''",
",",
"prefix_unchanged",
"=",
"' '",
",",
"suffix_unchanged",
"=",
"''",
",",
"prefix_removed",
"=",
"'-'",
",",
"suffix_removed",
"=",
"''",
",",
"... | Return the diff view between original and modified strings.
Function checks both arguments line by line and returns a string
with a:
- prefix_unchanged when line is common to both sequences
- prefix_removed when line is unique to sequence 1
- prefix_added when line is unique to sequence 2
and a... | [
"Return",
"the",
"diff",
"view",
"between",
"original",
"and",
"modified",
"strings",
"."
] | python | train | 37.957447 |
vint21h/nagios-check-supervisord | check_supervisord.py | https://github.com/vint21h/nagios-check-supervisord/blob/a40a542499197a4b5658bd6cc3b34326fe8d0ada/check_supervisord.py#L241-L249 | def main():
"""
Program main.
"""
options = parse_options()
output, code = create_output(get_status(options), options)
sys.stdout.write(output)
sys.exit(code) | [
"def",
"main",
"(",
")",
":",
"options",
"=",
"parse_options",
"(",
")",
"output",
",",
"code",
"=",
"create_output",
"(",
"get_status",
"(",
"options",
")",
",",
"options",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"output",
")",
"sys",
".",
"ex... | Program main. | [
"Program",
"main",
"."
] | python | test | 19.888889 |
ppaquette/gym-pull | gym_pull/scoreboard/api.py | https://github.com/ppaquette/gym-pull/blob/5b2797fd081ba5be26544983d1eba764e6d9f73b/gym_pull/scoreboard/api.py#L10-L72 | def upload(training_dir, algorithm_id=None, writeup=None, api_key=None, ignore_open_monitors=False):
"""Upload the results of training (as automatically recorded by your
env's monitor) to OpenAI Gym.
Args:
training_dir (Optional[str]): A directory containing the results of a training run.
a... | [
"def",
"upload",
"(",
"training_dir",
",",
"algorithm_id",
"=",
"None",
",",
"writeup",
"=",
"None",
",",
"api_key",
"=",
"None",
",",
"ignore_open_monitors",
"=",
"False",
")",
":",
"if",
"not",
"ignore_open_monitors",
":",
"open_monitors",
"=",
"monitoring",... | Upload the results of training (as automatically recorded by your
env's monitor) to OpenAI Gym.
Args:
training_dir (Optional[str]): A directory containing the results of a training run.
algorithm_id (Optional[str]): An algorithm id indicating the particular version of the algorithm (including c... | [
"Upload",
"the",
"results",
"of",
"training",
"(",
"as",
"automatically",
"recorded",
"by",
"your",
"env",
"s",
"monitor",
")",
"to",
"OpenAI",
"Gym",
"."
] | python | train | 49.190476 |
saltstack/salt | salt/utils/win_dacl.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_dacl.py#L1517-L1599 | def set_permissions(obj_name,
principal,
permissions,
access_mode='grant',
applies_to=None,
obj_type='file',
reset_perms=False,
protected=None):
'''
Set the permissions of ... | [
"def",
"set_permissions",
"(",
"obj_name",
",",
"principal",
",",
"permissions",
",",
"access_mode",
"=",
"'grant'",
",",
"applies_to",
"=",
"None",
",",
"obj_type",
"=",
"'file'",
",",
"reset_perms",
"=",
"False",
",",
"protected",
"=",
"None",
")",
":",
... | Set the permissions of an object. This can be a file, folder, registry key,
printer, service, etc...
Args:
obj_name (str):
The object for which to set permissions. This can be the path to a
file or folder, a registry key, printer, etc. For more information
about how... | [
"Set",
"the",
"permissions",
"of",
"an",
"object",
".",
"This",
"can",
"be",
"a",
"file",
"folder",
"registry",
"key",
"printer",
"service",
"etc",
"..."
] | python | train | 33.807229 |
pypa/pipenv | pipenv/vendor/pexpect/utils.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/utils.py#L69-L127 | def split_command_line(command_line):
'''This splits a command line into a list of arguments. It splits arguments
on spaces, but handles embedded quotes, doublequotes, and escaped
characters. It's impossible to do this with a regular expression, so I
wrote a little state machine to parse the command li... | [
"def",
"split_command_line",
"(",
"command_line",
")",
":",
"arg_list",
"=",
"[",
"]",
"arg",
"=",
"''",
"# Constants to name the states we can be in.",
"state_basic",
"=",
"0",
"state_esc",
"=",
"1",
"state_singlequote",
"=",
"2",
"state_doublequote",
"=",
"3",
"... | This splits a command line into a list of arguments. It splits arguments
on spaces, but handles embedded quotes, doublequotes, and escaped
characters. It's impossible to do this with a regular expression, so I
wrote a little state machine to parse the command line. | [
"This",
"splits",
"a",
"command",
"line",
"into",
"a",
"list",
"of",
"arguments",
".",
"It",
"splits",
"arguments",
"on",
"spaces",
"but",
"handles",
"embedded",
"quotes",
"doublequotes",
"and",
"escaped",
"characters",
".",
"It",
"s",
"impossible",
"to",
"d... | python | train | 31.474576 |
andreikop/qutepart | qutepart/completer.py | https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/completer.py#L69-L77 | def setData(self, wordBeforeCursor, wholeWord):
"""Set model information
"""
self._typedText = wordBeforeCursor
self.words = self._makeListOfCompletions(wordBeforeCursor, wholeWord)
commonStart = self._commonWordStart(self.words)
self.canCompleteText = commonStart[len(wor... | [
"def",
"setData",
"(",
"self",
",",
"wordBeforeCursor",
",",
"wholeWord",
")",
":",
"self",
".",
"_typedText",
"=",
"wordBeforeCursor",
"self",
".",
"words",
"=",
"self",
".",
"_makeListOfCompletions",
"(",
"wordBeforeCursor",
",",
"wholeWord",
")",
"commonStart... | Set model information | [
"Set",
"model",
"information"
] | python | train | 40.333333 |
ninuxorg/nodeshot | nodeshot/core/metrics/utils.py | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/metrics/utils.py#L27-L31 | def write_async(name, values, tags={}, timestamp=None, database=None):
""" write metrics """
thread = Thread(target=write,
args=(name, values, tags, timestamp, database))
thread.start() | [
"def",
"write_async",
"(",
"name",
",",
"values",
",",
"tags",
"=",
"{",
"}",
",",
"timestamp",
"=",
"None",
",",
"database",
"=",
"None",
")",
":",
"thread",
"=",
"Thread",
"(",
"target",
"=",
"write",
",",
"args",
"=",
"(",
"name",
",",
"values",... | write metrics | [
"write",
"metrics"
] | python | train | 42.6 |
nens/qgispluginreleaser | qgispluginreleaser/entry_point.py | https://github.com/nens/qgispluginreleaser/blob/4826dd33e9152cc4f9c4be3b89e5b10b1a881d7e/qgispluginreleaser/entry_point.py#L17-L45 | def create_zipfile(context):
"""This is the actual zest.releaser entry point
Relevant items in the context dict:
name
Name of the project being released
tagdir
Directory where the tag checkout is placed (*if* a tag
checkout has been made)
version
Version we're rel... | [
"def",
"create_zipfile",
"(",
"context",
")",
":",
"if",
"not",
"prerequisites_ok",
"(",
")",
":",
"return",
"# Create a zipfile.",
"subprocess",
".",
"call",
"(",
"[",
"'make'",
",",
"'zip'",
"]",
")",
"for",
"zipfile",
"in",
"glob",
".",
"glob",
"(",
"... | This is the actual zest.releaser entry point
Relevant items in the context dict:
name
Name of the project being released
tagdir
Directory where the tag checkout is placed (*if* a tag
checkout has been made)
version
Version we're releasing
workingdir
Origi... | [
"This",
"is",
"the",
"actual",
"zest",
".",
"releaser",
"entry",
"point"
] | python | test | 26.413793 |
merll/docker-fabric | dockerfabric/apiclient.py | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/apiclient.py#L301-L306 | def stop(self, container, **kwargs):
"""
Identical to :meth:`dockermap.client.base.DockerClientWrapper.stop` with additional logging.
"""
self.push_log("Stopping container '{0}'.".format(container))
super(DockerFabricClient, self).stop(container, **kwargs) | [
"def",
"stop",
"(",
"self",
",",
"container",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"push_log",
"(",
"\"Stopping container '{0}'.\"",
".",
"format",
"(",
"container",
")",
")",
"super",
"(",
"DockerFabricClient",
",",
"self",
")",
".",
"stop",
... | Identical to :meth:`dockermap.client.base.DockerClientWrapper.stop` with additional logging. | [
"Identical",
"to",
":",
"meth",
":",
"dockermap",
".",
"client",
".",
"base",
".",
"DockerClientWrapper",
".",
"stop",
"with",
"additional",
"logging",
"."
] | python | train | 48.5 |
hubo1016/namedstruct | namedstruct/namedstruct.py | https://github.com/hubo1016/namedstruct/blob/5039026e0df4ce23003d212358918dbe1a6e1d76/namedstruct/namedstruct.py#L426-L460 | def dump(val, humanread = True, dumpextra = False, typeinfo = DUMPTYPE_FLAT, ordered=True,
tostr=False, encoding='utf-8'):
'''
Convert a parsed NamedStruct (probably with additional NamedStruct as fields) into a
JSON-friendly format, with only Python primitives (dictionaries, lists, bytes, integers... | [
"def",
"dump",
"(",
"val",
",",
"humanread",
"=",
"True",
",",
"dumpextra",
"=",
"False",
",",
"typeinfo",
"=",
"DUMPTYPE_FLAT",
",",
"ordered",
"=",
"True",
",",
"tostr",
"=",
"False",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"dumped",
"=",
"_dump",... | Convert a parsed NamedStruct (probably with additional NamedStruct as fields) into a
JSON-friendly format, with only Python primitives (dictionaries, lists, bytes, integers etc.)
Then you may use json.dumps, or pprint to further process the result.
:param val: parsed result, may contain NamedStruct
... | [
"Convert",
"a",
"parsed",
"NamedStruct",
"(",
"probably",
"with",
"additional",
"NamedStruct",
"as",
"fields",
")",
"into",
"a",
"JSON",
"-",
"friendly",
"format",
"with",
"only",
"Python",
"primitives",
"(",
"dictionaries",
"lists",
"bytes",
"integers",
"etc",
... | python | train | 44.371429 |
geertj/gruvi | lib/gruvi/poll.py | https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L229-L236 | def close(self):
"""Close all active poll instances and remove all callbacks."""
if self._mpoll is None:
return
for mpoll in self._mpoll.values():
mpoll.close()
self._mpoll.clear()
self._mpoll = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_mpoll",
"is",
"None",
":",
"return",
"for",
"mpoll",
"in",
"self",
".",
"_mpoll",
".",
"values",
"(",
")",
":",
"mpoll",
".",
"close",
"(",
")",
"self",
".",
"_mpoll",
".",
"clear",
"(",... | Close all active poll instances and remove all callbacks. | [
"Close",
"all",
"active",
"poll",
"instances",
"and",
"remove",
"all",
"callbacks",
"."
] | python | train | 32 |
mozilla/treeherder | treeherder/model/models.py | https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/model/models.py#L1149-L1167 | def set_bug(self, bug_number):
"""
Set the bug number of this Classified Failure
If an existing ClassifiedFailure exists with the same bug number
replace this instance with the existing one.
"""
if bug_number == self.bug_number:
return self
other = C... | [
"def",
"set_bug",
"(",
"self",
",",
"bug_number",
")",
":",
"if",
"bug_number",
"==",
"self",
".",
"bug_number",
":",
"return",
"self",
"other",
"=",
"ClassifiedFailure",
".",
"objects",
".",
"filter",
"(",
"bug_number",
"=",
"bug_number",
")",
".",
"first... | Set the bug number of this Classified Failure
If an existing ClassifiedFailure exists with the same bug number
replace this instance with the existing one. | [
"Set",
"the",
"bug",
"number",
"of",
"this",
"Classified",
"Failure"
] | python | train | 29.421053 |
jalmeroth/pymusiccast | pymusiccast/zone.py | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/zone.py#L133-L137 | def set_power(self, power):
"""Send Power command."""
req_url = ENDPOINTS["setPower"].format(self.ip_address, self.zone_id)
params = {"power": "on" if power else "standby"}
return request(req_url, params=params) | [
"def",
"set_power",
"(",
"self",
",",
"power",
")",
":",
"req_url",
"=",
"ENDPOINTS",
"[",
"\"setPower\"",
"]",
".",
"format",
"(",
"self",
".",
"ip_address",
",",
"self",
".",
"zone_id",
")",
"params",
"=",
"{",
"\"power\"",
":",
"\"on\"",
"if",
"powe... | Send Power command. | [
"Send",
"Power",
"command",
"."
] | python | train | 47.8 |
noobermin/pys | pys/__init__.py | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L48-L52 | def chunks(l,n):
'''chunk l in n sized bits'''
#http://stackoverflow.com/a/3226719
#...not that this is hard to understand.
return [l[x:x+n] for x in range(0, len(l), n)]; | [
"def",
"chunks",
"(",
"l",
",",
"n",
")",
":",
"#http://stackoverflow.com/a/3226719",
"#...not that this is hard to understand.",
"return",
"[",
"l",
"[",
"x",
":",
"x",
"+",
"n",
"]",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"l",
")",
",",
... | chunk l in n sized bits | [
"chunk",
"l",
"in",
"n",
"sized",
"bits"
] | python | train | 36.6 |
jakewins/neo4jdb-python | pavement.py | https://github.com/jakewins/neo4jdb-python/blob/cd78cb8397885f219500fb1080d301f0c900f7be/pavement.py#L75-L109 | def change_password():
"""
Changes the standard password from neo4j to testing to be able to run the test suite.
"""
basic_auth = '%s:%s' % (DEFAULT_USERNAME, DEFAULT_PASSWORD)
try: # Python 2
auth = base64.encodestring(basic_auth)
except TypeError: # Python 3
auth = base64.enc... | [
"def",
"change_password",
"(",
")",
":",
"basic_auth",
"=",
"'%s:%s'",
"%",
"(",
"DEFAULT_USERNAME",
",",
"DEFAULT_PASSWORD",
")",
"try",
":",
"# Python 2",
"auth",
"=",
"base64",
".",
"encodestring",
"(",
"basic_auth",
")",
"except",
"TypeError",
":",
"# Pyth... | Changes the standard password from neo4j to testing to be able to run the test suite. | [
"Changes",
"the",
"standard",
"password",
"from",
"neo4j",
"to",
"testing",
"to",
"be",
"able",
"to",
"run",
"the",
"test",
"suite",
"."
] | python | train | 37.028571 |
ClimateImpactLab/DataFS | datafs/datafs.py | https://github.com/ClimateImpactLab/DataFS/blob/0d32c2b4e18d300a11b748a552f6adbc3dd8f59d/datafs/datafs.py#L321-L331 | def set_dependencies(ctx, archive_name, dependency=None):
'''
Set the dependencies of an archive
'''
_generate_api(ctx)
kwargs = _parse_dependencies(dependency)
var = ctx.obj.api.get_archive(archive_name)
var.set_dependencies(dependencies=kwargs) | [
"def",
"set_dependencies",
"(",
"ctx",
",",
"archive_name",
",",
"dependency",
"=",
"None",
")",
":",
"_generate_api",
"(",
"ctx",
")",
"kwargs",
"=",
"_parse_dependencies",
"(",
"dependency",
")",
"var",
"=",
"ctx",
".",
"obj",
".",
"api",
".",
"get_archi... | Set the dependencies of an archive | [
"Set",
"the",
"dependencies",
"of",
"an",
"archive"
] | python | train | 24.272727 |
saltstack/salt | salt/modules/groupadd.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/groupadd.py#L43-L78 | def add(name, gid=None, system=False, root=None):
'''
Add the specified group
name
Name of the new group
gid
Use GID for the new group
system
Create a system account
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' gr... | [
"def",
"add",
"(",
"name",
",",
"gid",
"=",
"None",
",",
"system",
"=",
"False",
",",
"root",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'groupadd'",
"]",
"if",
"gid",
":",
"cmd",
".",
"append",
"(",
"'-g {0}'",
".",
"format",
"(",
"gid",
")",
")... | Add the specified group
name
Name of the new group
gid
Use GID for the new group
system
Create a system account
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' group.add foo 3456 | [
"Add",
"the",
"specified",
"group"
] | python | train | 17.638889 |
google/grr | grr/server/grr_response_server/instant_output_plugin.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/instant_output_plugin.py#L66-L70 | def output_file_name(self):
"""Name of the file where plugin's output should be written to."""
safe_path = re.sub(r":|/", "_", self.source_urn.Path().lstrip("/"))
return "results_%s%s" % (safe_path, self.output_file_extension) | [
"def",
"output_file_name",
"(",
"self",
")",
":",
"safe_path",
"=",
"re",
".",
"sub",
"(",
"r\":|/\"",
",",
"\"_\"",
",",
"self",
".",
"source_urn",
".",
"Path",
"(",
")",
".",
"lstrip",
"(",
"\"/\"",
")",
")",
"return",
"\"results_%s%s\"",
"%",
"(",
... | Name of the file where plugin's output should be written to. | [
"Name",
"of",
"the",
"file",
"where",
"plugin",
"s",
"output",
"should",
"be",
"written",
"to",
"."
] | python | train | 47 |
ultrabug/py3status | py3status/parse_config.py | https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/parse_config.py#L424-L458 | def make_function_value_private(self, value, value_type, function):
"""
Wraps converted value so that it is hidden in logs etc.
Note this is not secure just reduces leaking info
Allows base 64 encode stuff using base64() or plain hide() in the
config
"""
# remove... | [
"def",
"make_function_value_private",
"(",
"self",
",",
"value",
",",
"value_type",
",",
"function",
")",
":",
"# remove quotes",
"value",
"=",
"self",
".",
"remove_quotes",
"(",
"value",
")",
"if",
"function",
"==",
"\"base64\"",
":",
"try",
":",
"import",
... | Wraps converted value so that it is hidden in logs etc.
Note this is not secure just reduces leaking info
Allows base 64 encode stuff using base64() or plain hide() in the
config | [
"Wraps",
"converted",
"value",
"so",
"that",
"it",
"is",
"hidden",
"in",
"logs",
"etc",
".",
"Note",
"this",
"is",
"not",
"secure",
"just",
"reduces",
"leaking",
"info"
] | python | train | 35.057143 |
apache/airflow | airflow/contrib/hooks/gcp_sql_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L943-L959 | def get_sqlproxy_runner(self):
"""
Retrieve Cloud SQL Proxy runner. It is used to manage the proxy
lifecycle per task.
:return: The Cloud SQL Proxy runner.
:rtype: CloudSqlProxyRunner
"""
if not self.use_proxy:
raise AirflowException("Proxy runner can... | [
"def",
"get_sqlproxy_runner",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"use_proxy",
":",
"raise",
"AirflowException",
"(",
"\"Proxy runner can only be retrieved in case of use_proxy = True\"",
")",
"return",
"CloudSqlProxyRunner",
"(",
"path_prefix",
"=",
"self",
... | Retrieve Cloud SQL Proxy runner. It is used to manage the proxy
lifecycle per task.
:return: The Cloud SQL Proxy runner.
:rtype: CloudSqlProxyRunner | [
"Retrieve",
"Cloud",
"SQL",
"Proxy",
"runner",
".",
"It",
"is",
"used",
"to",
"manage",
"the",
"proxy",
"lifecycle",
"per",
"task",
"."
] | python | test | 40.294118 |
saltstack/salt | salt/utils/openstack/nova.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L647-L681 | def volume_detach(self,
name,
timeout=300):
'''
Detach a block device
'''
try:
volume = self.volume_show(name)
except KeyError as exc:
raise SaltCloudSystemExit('Unable to find {0} volume: {1}'.format(name, exc))... | [
"def",
"volume_detach",
"(",
"self",
",",
"name",
",",
"timeout",
"=",
"300",
")",
":",
"try",
":",
"volume",
"=",
"self",
".",
"volume_show",
"(",
"name",
")",
"except",
"KeyError",
"as",
"exc",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'Unable to find {... | Detach a block device | [
"Detach",
"a",
"block",
"device"
] | python | train | 34.942857 |
urschrei/pyzotero | pyzotero/zotero.py | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L121-L207 | def retrieve(func):
"""
Decorator for Zotero read API methods; calls _retrieve_data() and passes
the result to the correct processor, based on a lookup
"""
def wrapped_f(self, *args, **kwargs):
"""
Returns result of _retrieve_data()
func's return value is part of a URI, and... | [
"def",
"retrieve",
"(",
"func",
")",
":",
"def",
"wrapped_f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"\n Returns result of _retrieve_data()\n\n func's return value is part of a URI, and it's this\n which is intercepted and p... | Decorator for Zotero read API methods; calls _retrieve_data() and passes
the result to the correct processor, based on a lookup | [
"Decorator",
"for",
"Zotero",
"read",
"API",
"methods",
";",
"calls",
"_retrieve_data",
"()",
"and",
"passes",
"the",
"result",
"to",
"the",
"correct",
"processor",
"based",
"on",
"a",
"lookup"
] | python | valid | 37.597701 |
opennode/waldur-core | waldur_core/structure/__init__.py | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/__init__.py#L302-L305 | def get_service_resources(cls, model):
""" Get resource models by service model """
key = cls.get_model_key(model)
return cls.get_service_name_resources(key) | [
"def",
"get_service_resources",
"(",
"cls",
",",
"model",
")",
":",
"key",
"=",
"cls",
".",
"get_model_key",
"(",
"model",
")",
"return",
"cls",
".",
"get_service_name_resources",
"(",
"key",
")"
] | Get resource models by service model | [
"Get",
"resource",
"models",
"by",
"service",
"model"
] | python | train | 44.5 |
riga/law | law/workflow/remote.py | https://github.com/riga/law/blob/479f84ce06ecf3bafe9d33cb7b8fc52e39fb80a1/law/workflow/remote.py#L91-L96 | def job_data(cls, job_id=dummy_job_id, status=None, code=None, error=None, **kwargs):
"""
Returns a dictionary containing default job status information such as the *job_id*, a job
*status* string, a job return code, and an *error* message.
"""
return dict(job_id=job_id, status=s... | [
"def",
"job_data",
"(",
"cls",
",",
"job_id",
"=",
"dummy_job_id",
",",
"status",
"=",
"None",
",",
"code",
"=",
"None",
",",
"error",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"dict",
"(",
"job_id",
"=",
"job_id",
",",
"status",
"=... | Returns a dictionary containing default job status information such as the *job_id*, a job
*status* string, a job return code, and an *error* message. | [
"Returns",
"a",
"dictionary",
"containing",
"default",
"job",
"status",
"information",
"such",
"as",
"the",
"*",
"job_id",
"*",
"a",
"job",
"*",
"status",
"*",
"string",
"a",
"job",
"return",
"code",
"and",
"an",
"*",
"error",
"*",
"message",
"."
] | python | train | 57.5 |
gbowerman/azurerm | azurerm/restfns.py | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/restfns.py#L110-L123 | def do_put(endpoint, body, access_token):
'''Do an HTTP PUT request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to put.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response... | [
"def",
"do_put",
"(",
"endpoint",
",",
"body",
",",
"access_token",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
",",
"\"Authorization\"",
":",
"'Bearer '",
"+",
"access_token",
"}",
"headers",
"[",
"'User-Agent'",
"]",
"=",
... | Do an HTTP PUT request and return JSON.
Args:
endpoint (str): Azure Resource Manager management endpoint.
body (str): JSON body of information to put.
access_token (str): A valid Azure authentication token.
Returns:
HTTP response. JSON body. | [
"Do",
"an",
"HTTP",
"PUT",
"request",
"and",
"return",
"JSON",
"."
] | python | train | 37.714286 |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv1/network.py | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv1/network.py#L15-L26 | def GetNetworks(alias=None,location=None):
"""Gets the list of Networks mapped to the account in the specified datacenter.
https://t3n.zendesk.com/entries/21024721-Get-Networks
:param alias: short code for a particular account. If none will use account's default alias
:param location: datacenter where group ... | [
"def",
"GetNetworks",
"(",
"alias",
"=",
"None",
",",
"location",
"=",
"None",
")",
":",
"if",
"alias",
"is",
"None",
":",
"alias",
"=",
"clc",
".",
"v1",
".",
"Account",
".",
"GetAlias",
"(",
")",
"if",
"location",
"is",
"None",
":",
"location",
"... | Gets the list of Networks mapped to the account in the specified datacenter.
https://t3n.zendesk.com/entries/21024721-Get-Networks
:param alias: short code for a particular account. If none will use account's default alias
:param location: datacenter where group resides. If none will use account's primary dat... | [
"Gets",
"the",
"list",
"of",
"Networks",
"mapped",
"to",
"the",
"account",
"in",
"the",
"specified",
"datacenter",
"."
] | python | train | 54.333333 |
SwissDataScienceCenter/renku-python | renku/cli/init.py | https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/cli/init.py#L106-L166 | def init(ctx, client, directory, name, force, use_external_storage):
"""Initialize a project."""
if not client.use_external_storage:
use_external_storage = False
ctx.obj = client = attr.evolve(
client,
path=directory,
use_external_storage=use_external_storage,
)
msg... | [
"def",
"init",
"(",
"ctx",
",",
"client",
",",
"directory",
",",
"name",
",",
"force",
",",
"use_external_storage",
")",
":",
"if",
"not",
"client",
".",
"use_external_storage",
":",
"use_external_storage",
"=",
"False",
"ctx",
".",
"obj",
"=",
"client",
"... | Initialize a project. | [
"Initialize",
"a",
"project",
"."
] | python | train | 29.327869 |
zetaops/zengine | zengine/messaging/model.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L264-L276 | def create_exchange(self):
"""
Creates user's private exchange
Actually user's private channel needed to be defined only once,
and this should be happened when user first created.
But since this has a little performance cost,
to be safe we always call it before binding t... | [
"def",
"create_exchange",
"(",
"self",
")",
":",
"channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"channel",
".",
"exchange_declare",
"(",
"exchange",
"=",
"self",
".",
"user",
".",
"prv_exchange",
",",
"exchange_type",
"=",
"'fanout'",
",",
"durable",
... | Creates user's private exchange
Actually user's private channel needed to be defined only once,
and this should be happened when user first created.
But since this has a little performance cost,
to be safe we always call it before binding to the channel we currently subscribe | [
"Creates",
"user",
"s",
"private",
"exchange"
] | python | train | 43.307692 |
googleapis/oauth2client | oauth2client/crypt.py | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/crypt.py#L74-L102 | def make_signed_jwt(signer, payload, key_id=None):
"""Make a signed JWT.
See http://self-issued.info/docs/draft-jones-json-web-token.html.
Args:
signer: crypt.Signer, Cryptographic signer.
payload: dict, Dictionary of data to convert to JSON and then sign.
key_id: string, (Optional... | [
"def",
"make_signed_jwt",
"(",
"signer",
",",
"payload",
",",
"key_id",
"=",
"None",
")",
":",
"header",
"=",
"{",
"'typ'",
":",
"'JWT'",
",",
"'alg'",
":",
"'RS256'",
"}",
"if",
"key_id",
"is",
"not",
"None",
":",
"header",
"[",
"'kid'",
"]",
"=",
... | Make a signed JWT.
See http://self-issued.info/docs/draft-jones-json-web-token.html.
Args:
signer: crypt.Signer, Cryptographic signer.
payload: dict, Dictionary of data to convert to JSON and then sign.
key_id: string, (Optional) Key ID header.
Returns:
string, The JWT for... | [
"Make",
"a",
"signed",
"JWT",
"."
] | python | valid | 29.068966 |
bukun/TorCMS | torcms/script/tmplchecker/__init__.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/tmplchecker/__init__.py#L99-L109 | def do_for_dir(inws, begin):
'''
do something in the directory.
'''
inws = os.path.abspath(inws)
for wroot, wdirs, wfiles in os.walk(inws):
for wfile in wfiles:
if wfile.endswith('.html'):
if 'autogen' in wroot:
continue
check_h... | [
"def",
"do_for_dir",
"(",
"inws",
",",
"begin",
")",
":",
"inws",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"inws",
")",
"for",
"wroot",
",",
"wdirs",
",",
"wfiles",
"in",
"os",
".",
"walk",
"(",
"inws",
")",
":",
"for",
"wfile",
"in",
"wfiles... | do something in the directory. | [
"do",
"something",
"in",
"the",
"directory",
"."
] | python | train | 33.181818 |
bukun/TorCMS | helper_scripts/script_meta_xlsx_import_v2.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/helper_scripts/script_meta_xlsx_import_v2.py#L29-L59 | def get_meta(catid, sig):
'''
Get metadata of dataset via ID.
'''
meta_base = './static/dataset_list'
if os.path.exists(meta_base):
pass
else:
return False
pp_data = {'logo': '', 'kind': '9'}
for wroot, wdirs, wfiles in os.walk(meta_base):
for wdir in wdirs:
... | [
"def",
"get_meta",
"(",
"catid",
",",
"sig",
")",
":",
"meta_base",
"=",
"'./static/dataset_list'",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"meta_base",
")",
":",
"pass",
"else",
":",
"return",
"False",
"pp_data",
"=",
"{",
"'logo'",
":",
"''",
",... | Get metadata of dataset via ID. | [
"Get",
"metadata",
"of",
"dataset",
"via",
"ID",
"."
] | python | train | 37.741935 |
theiviaxx/Frog | frog/views/gallery.py | https://github.com/theiviaxx/Frog/blob/a9475463a8eed1323fe3ef5d51f9751fb1dc9edd/frog/views/gallery.py#L69-L80 | def index(request, obj_id=None):
"""Handles a request based on method and calls the appropriate function"""
if request.method == 'GET':
return get(request, obj_id)
elif request.method == 'POST':
return post(request)
elif request.method == 'PUT':
getPutData(request)
return... | [
"def",
"index",
"(",
"request",
",",
"obj_id",
"=",
"None",
")",
":",
"if",
"request",
".",
"method",
"==",
"'GET'",
":",
"return",
"get",
"(",
"request",
",",
"obj_id",
")",
"elif",
"request",
".",
"method",
"==",
"'POST'",
":",
"return",
"post",
"(... | Handles a request based on method and calls the appropriate function | [
"Handles",
"a",
"request",
"based",
"on",
"method",
"and",
"calls",
"the",
"appropriate",
"function"
] | python | train | 36.166667 |
hackedd/gw2api | gw2api/__init__.py | https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/__init__.py#L38-L51 | def set_cache_dir(directory):
"""Set the directory to cache JSON responses from most API endpoints.
"""
global cache_dir
if directory is None:
cache_dir = None
return
if not os.path.exists(directory):
os.makedirs(directory)
if not os.path.isdir(directory):
raise... | [
"def",
"set_cache_dir",
"(",
"directory",
")",
":",
"global",
"cache_dir",
"if",
"directory",
"is",
"None",
":",
"cache_dir",
"=",
"None",
"return",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"directory",
")",
":",
"os",
".",
"makedirs",
"(",
... | Set the directory to cache JSON responses from most API endpoints. | [
"Set",
"the",
"directory",
"to",
"cache",
"JSON",
"responses",
"from",
"most",
"API",
"endpoints",
"."
] | python | train | 25.928571 |
h2oai/h2o-3 | h2o-docs/src/product/sphinxext/apigen.py | https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-docs/src/product/sphinxext/apigen.py#L268-L307 | def _survives_exclude(self, matchstr, match_type):
''' Returns True if *matchstr* does not match patterns
``self.package_name`` removed from front of string if present
Examples
--------
>>> dw = ApiDocWriter('sphinx')
>>> dw._survives_exclude('sphinx.okpkg', 'package')
... | [
"def",
"_survives_exclude",
"(",
"self",
",",
"matchstr",
",",
"match_type",
")",
":",
"if",
"match_type",
"==",
"'module'",
":",
"patterns",
"=",
"self",
".",
"module_skip_patterns",
"elif",
"match_type",
"==",
"'package'",
":",
"patterns",
"=",
"self",
".",
... | Returns True if *matchstr* does not match patterns
``self.package_name`` removed from front of string if present
Examples
--------
>>> dw = ApiDocWriter('sphinx')
>>> dw._survives_exclude('sphinx.okpkg', 'package')
True
>>> dw.package_skip_patterns.append('^\\.b... | [
"Returns",
"True",
"if",
"*",
"matchstr",
"*",
"does",
"not",
"match",
"patterns"
] | python | test | 35.1 |
cablehead/python-consul | consul/twisted.py | https://github.com/cablehead/python-consul/blob/53eb41c4760b983aec878ef73e72c11e0af501bb/consul/twisted.py#L54-L62 | def compat_string(value):
"""
Provide a python2/3 compatible string representation of the value
:type value:
:rtype :
"""
if isinstance(value, bytes):
return value.decode(encoding='utf-8')
return str(value) | [
"def",
"compat_string",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"return",
"value",
".",
"decode",
"(",
"encoding",
"=",
"'utf-8'",
")",
"return",
"str",
"(",
"value",
")"
] | Provide a python2/3 compatible string representation of the value
:type value:
:rtype : | [
"Provide",
"a",
"python2",
"/",
"3",
"compatible",
"string",
"representation",
"of",
"the",
"value",
":",
"type",
"value",
":",
":",
"rtype",
":"
] | python | train | 29.555556 |
cloudendpoints/endpoints-python | endpoints/api_config.py | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1896-L1958 | def __method_descriptor(self, service, method_info,
rosy_method, protorpc_method_info):
"""Describes a method.
Args:
service: endpoints.Service, Implementation of the API as a service.
method_info: _MethodInfo, Configuration for the method.
rosy_method: string, Proto... | [
"def",
"__method_descriptor",
"(",
"self",
",",
"service",
",",
"method_info",
",",
"rosy_method",
",",
"protorpc_method_info",
")",
":",
"descriptor",
"=",
"{",
"}",
"request_message_type",
"=",
"(",
"resource_container",
".",
"ResourceContainer",
".",
"get_request... | Describes a method.
Args:
service: endpoints.Service, Implementation of the API as a service.
method_info: _MethodInfo, Configuration for the method.
rosy_method: string, ProtoRPC method name prefixed with the
name of the service.
protorpc_method_info: protorpc.remote._RemoteMethodI... | [
"Describes",
"a",
"method",
"."
] | python | train | 40.857143 |
numenta/htmresearch | htmresearch/algorithms/column_pooler.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/algorithms/column_pooler.py#L455-L468 | def numberOfConnectedProximalSynapses(self, cells=None):
"""
Returns the number of proximal connected synapses on these cells.
Parameters:
----------------------------
@param cells (iterable)
Indices of the cells. If None return count for all cells.
"""
if cells is None:
... | [
"def",
"numberOfConnectedProximalSynapses",
"(",
"self",
",",
"cells",
"=",
"None",
")",
":",
"if",
"cells",
"is",
"None",
":",
"cells",
"=",
"xrange",
"(",
"self",
".",
"numberOfCells",
"(",
")",
")",
"return",
"_countWhereGreaterEqualInRows",
"(",
"self",
... | Returns the number of proximal connected synapses on these cells.
Parameters:
----------------------------
@param cells (iterable)
Indices of the cells. If None return count for all cells. | [
"Returns",
"the",
"number",
"of",
"proximal",
"connected",
"synapses",
"on",
"these",
"cells",
"."
] | python | train | 35.214286 |
F-Secure/see | plugins/agent.py | https://github.com/F-Secure/see/blob/3e053e52a45229f96a12db9e98caf7fb3880e811/plugins/agent.py#L85-L95 | def respond(self, output):
"""Generates server response."""
response = {'exit_code': output.code,
'command_output': output.log}
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
self.wfile.write(bytes(js... | [
"def",
"respond",
"(",
"self",
",",
"output",
")",
":",
"response",
"=",
"{",
"'exit_code'",
":",
"output",
".",
"code",
",",
"'command_output'",
":",
"output",
".",
"log",
"}",
"self",
".",
"send_response",
"(",
"200",
")",
"self",
".",
"send_header",
... | Generates server response. | [
"Generates",
"server",
"response",
"."
] | python | train | 30.727273 |
Capitains/MyCapytain | MyCapytain/resources/texts/remote/cts.py | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/texts/remote/cts.py#L155-L186 | def _parse_request(self, xml):
""" Parse a request with metadata information
:param xml: LXML Object
:type xml: Union[lxml.etree._Element]
"""
for node in xml.xpath(".//ti:groupname", namespaces=XPATH_NAMESPACES):
lang = node.get("xml:lang") or CtsText.DEFAULT_LANG
... | [
"def",
"_parse_request",
"(",
"self",
",",
"xml",
")",
":",
"for",
"node",
"in",
"xml",
".",
"xpath",
"(",
"\".//ti:groupname\"",
",",
"namespaces",
"=",
"XPATH_NAMESPACES",
")",
":",
"lang",
"=",
"node",
".",
"get",
"(",
"\"xml:lang\"",
")",
"or",
"CtsT... | Parse a request with metadata information
:param xml: LXML Object
:type xml: Union[lxml.etree._Element] | [
"Parse",
"a",
"request",
"with",
"metadata",
"information"
] | python | train | 48.1875 |
ska-sa/spead2 | spead2/send/__init__.py | https://github.com/ska-sa/spead2/blob/cac95fd01d8debaa302d2691bd26da64b7828bc6/spead2/send/__init__.py#L126-L133 | def get_heap(self, *args, **kwargs):
"""Return a new heap which contains all the new items and item
descriptors since the last call. This is a convenience wrapper
around :meth:`add_to_heap`.
"""
heap = Heap(self._flavour)
self.add_to_heap(heap, *args, **kwargs)
re... | [
"def",
"get_heap",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"heap",
"=",
"Heap",
"(",
"self",
".",
"_flavour",
")",
"self",
".",
"add_to_heap",
"(",
"heap",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"heap"... | Return a new heap which contains all the new items and item
descriptors since the last call. This is a convenience wrapper
around :meth:`add_to_heap`. | [
"Return",
"a",
"new",
"heap",
"which",
"contains",
"all",
"the",
"new",
"items",
"and",
"item",
"descriptors",
"since",
"the",
"last",
"call",
".",
"This",
"is",
"a",
"convenience",
"wrapper",
"around",
":",
"meth",
":",
"add_to_heap",
"."
] | python | train | 40.25 |
sorgerlab/indra | indra/sources/trips/analyze_ekbs.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/analyze_ekbs.py#L137-L148 | def check_event_coverage(patterns, event_list):
"""Calculate the ratio of patterns that were extracted."""
proportions = []
for pattern_list in patterns:
proportion = 0
for pattern in pattern_list:
for node in pattern.nodes():
if node in event_list:
... | [
"def",
"check_event_coverage",
"(",
"patterns",
",",
"event_list",
")",
":",
"proportions",
"=",
"[",
"]",
"for",
"pattern_list",
"in",
"patterns",
":",
"proportion",
"=",
"0",
"for",
"pattern",
"in",
"pattern_list",
":",
"for",
"node",
"in",
"pattern",
".",... | Calculate the ratio of patterns that were extracted. | [
"Calculate",
"the",
"ratio",
"of",
"patterns",
"that",
"were",
"extracted",
"."
] | python | train | 36.666667 |
Tenchi2xh/Almonds | almonds/mandelbrot.py | https://github.com/Tenchi2xh/Almonds/blob/6b27024729f055f2cb5e14ae3ca3cb428ae054bc/almonds/mandelbrot.py#L30-L44 | def get_coords(x, y, params):
"""
Transforms the given coordinates from plane-space to Mandelbrot-space (real and imaginary).
:param x: X coordinate on the plane.
:param y: Y coordinate on the plane.
:param params: Current application parameters.
:type params: params.Params
:return: Tuple c... | [
"def",
"get_coords",
"(",
"x",
",",
"y",
",",
"params",
")",
":",
"n_x",
"=",
"x",
"*",
"2.0",
"/",
"params",
".",
"plane_w",
"*",
"params",
".",
"plane_ratio",
"-",
"1.0",
"n_y",
"=",
"y",
"*",
"2.0",
"/",
"params",
".",
"plane_h",
"-",
"1.0",
... | Transforms the given coordinates from plane-space to Mandelbrot-space (real and imaginary).
:param x: X coordinate on the plane.
:param y: Y coordinate on the plane.
:param params: Current application parameters.
:type params: params.Params
:return: Tuple containing the re-mapped coordinates in Man... | [
"Transforms",
"the",
"given",
"coordinates",
"from",
"plane",
"-",
"space",
"to",
"Mandelbrot",
"-",
"space",
"(",
"real",
"and",
"imaginary",
")",
"."
] | python | train | 36.866667 |
adrn/gala | gala/dynamics/_genfunc/solver.py | https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/solver.py#L10-L33 | def check_each_direction(n,angs,ifprint=True):
""" returns a list of the index of elements of n which do not have adequate
toy angle coverage. The criterion is that we must have at least one sample
in each Nyquist box when we project the toy angles along the vector n """
checks = np.array([])
P = np... | [
"def",
"check_each_direction",
"(",
"n",
",",
"angs",
",",
"ifprint",
"=",
"True",
")",
":",
"checks",
"=",
"np",
".",
"array",
"(",
"[",
"]",
")",
"P",
"=",
"np",
".",
"array",
"(",
"[",
"]",
")",
"if",
"(",
"ifprint",
")",
":",
"print",
"(",
... | returns a list of the index of elements of n which do not have adequate
toy angle coverage. The criterion is that we must have at least one sample
in each Nyquist box when we project the toy angles along the vector n | [
"returns",
"a",
"list",
"of",
"the",
"index",
"of",
"elements",
"of",
"n",
"which",
"do",
"not",
"have",
"adequate",
"toy",
"angle",
"coverage",
".",
"The",
"criterion",
"is",
"that",
"we",
"must",
"have",
"at",
"least",
"one",
"sample",
"in",
"each",
... | python | train | 42.5 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1109-L1141 | def node_vectors(node_id):
"""Get the vectors of a node.
You must specify the node id in the url.
You can pass direction (incoming/outgoing/all) and failed
(True/False/all).
"""
exp = Experiment(session)
# get the parameters
direction = request_parameter(parameter="direction", default="... | [
"def",
"node_vectors",
"(",
"node_id",
")",
":",
"exp",
"=",
"Experiment",
"(",
"session",
")",
"# get the parameters",
"direction",
"=",
"request_parameter",
"(",
"parameter",
"=",
"\"direction\"",
",",
"default",
"=",
"\"all\"",
")",
"failed",
"=",
"request_pa... | Get the vectors of a node.
You must specify the node id in the url.
You can pass direction (incoming/outgoing/all) and failed
(True/False/all). | [
"Get",
"the",
"vectors",
"of",
"a",
"node",
"."
] | python | train | 32.636364 |
Guake/guake | guake/prefs.py | https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1340-L1355 | def populate_keys_tree(self):
"""Reads the HOTKEYS global variable and insert all data in
the TreeStore used by the preferences window treeview.
"""
for group in HOTKEYS:
parent = self.store.append(None, [None, group['label'], None, None])
for item in group['keys'... | [
"def",
"populate_keys_tree",
"(",
"self",
")",
":",
"for",
"group",
"in",
"HOTKEYS",
":",
"parent",
"=",
"self",
".",
"store",
".",
"append",
"(",
"None",
",",
"[",
"None",
",",
"group",
"[",
"'label'",
"]",
",",
"None",
",",
"None",
"]",
")",
"for... | Reads the HOTKEYS global variable and insert all data in
the TreeStore used by the preferences window treeview. | [
"Reads",
"the",
"HOTKEYS",
"global",
"variable",
"and",
"insert",
"all",
"data",
"in",
"the",
"TreeStore",
"used",
"by",
"the",
"preferences",
"window",
"treeview",
"."
] | python | train | 55.875 |
spdx/tools-python | spdx/parsers/tagvalue.py | https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/tagvalue.py#L400-L409 | def p_file_contrib_1(self, p):
"""file_contrib : FILE_CONTRIB LINE"""
try:
if six.PY2:
value = p[2].decode(encoding='utf-8')
else:
value = p[2]
self.builder.add_file_contribution(self.document, value)
except OrderError:
... | [
"def",
"p_file_contrib_1",
"(",
"self",
",",
"p",
")",
":",
"try",
":",
"if",
"six",
".",
"PY2",
":",
"value",
"=",
"p",
"[",
"2",
"]",
".",
"decode",
"(",
"encoding",
"=",
"'utf-8'",
")",
"else",
":",
"value",
"=",
"p",
"[",
"2",
"]",
"self",
... | file_contrib : FILE_CONTRIB LINE | [
"file_contrib",
":",
"FILE_CONTRIB",
"LINE"
] | python | valid | 37.5 |
LuminosoInsight/luminoso-api-client-python | luminoso_api/v4_client.py | https://github.com/LuminosoInsight/luminoso-api-client-python/blob/3bedf2a454aee39214c11fbf556ead3eecc27881/luminoso_api/v4_client.py#L196-L214 | def _json_request(self, req_type, url, **kwargs):
"""
Make a request of the specified type and expect a JSON object in
response.
If the result has an 'error' value, raise a LuminosoAPIError with
its contents. Otherwise, return the contents of the 'result' value.
"""
... | [
"def",
"_json_request",
"(",
"self",
",",
"req_type",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"_request",
"(",
"req_type",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
"try",
":",
"json_response",
"=",
"response",
".... | Make a request of the specified type and expect a JSON object in
response.
If the result has an 'error' value, raise a LuminosoAPIError with
its contents. Otherwise, return the contents of the 'result' value. | [
"Make",
"a",
"request",
"of",
"the",
"specified",
"type",
"and",
"expect",
"a",
"JSON",
"object",
"in",
"response",
"."
] | python | test | 44.157895 |
log2timeline/plaso | plaso/storage/identifiers.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/storage/identifiers.py#L96-L105 | def CopyToString(self):
"""Copies the identifier to a string representation.
Returns:
str: unique identifier or None.
"""
if self.name is not None and self.row_identifier is not None:
return '{0:s}.{1:d}'.format(self.name, self.row_identifier)
return None | [
"def",
"CopyToString",
"(",
"self",
")",
":",
"if",
"self",
".",
"name",
"is",
"not",
"None",
"and",
"self",
".",
"row_identifier",
"is",
"not",
"None",
":",
"return",
"'{0:s}.{1:d}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"row_ide... | Copies the identifier to a string representation.
Returns:
str: unique identifier or None. | [
"Copies",
"the",
"identifier",
"to",
"a",
"string",
"representation",
"."
] | python | train | 28 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L21-L29 | def make_create_payload(**kwargs):
"""Create payload for upload/check-upload operations."""
payload = {}
# Add non-empty arguments
for k, v in six.iteritems(kwargs):
if v is not None:
payload[k] = v
return payload | [
"def",
"make_create_payload",
"(",
"*",
"*",
"kwargs",
")",
":",
"payload",
"=",
"{",
"}",
"# Add non-empty arguments",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"kwargs",
")",
":",
"if",
"v",
"is",
"not",
"None",
":",
"payload",
"[",
... | Create payload for upload/check-upload operations. | [
"Create",
"payload",
"for",
"upload",
"/",
"check",
"-",
"upload",
"operations",
"."
] | python | train | 27.333333 |
dslackw/slpkg | slpkg/graph.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/graph.py#L86-L96 | def graph_easy(self):
"""Draw ascii diagram. graph-easy perl module require
"""
if not os.path.isfile("/usr/bin/graph-easy"):
print("Require 'graph-easy': Install with 'slpkg -s sbo "
"graph-easy'")
self.remove_dot()
raise SystemExit()
... | [
"def",
"graph_easy",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"\"/usr/bin/graph-easy\"",
")",
":",
"print",
"(",
"\"Require 'graph-easy': Install with 'slpkg -s sbo \"",
"\"graph-easy'\"",
")",
"self",
".",
"remove_dot",
"(",
")",... | Draw ascii diagram. graph-easy perl module require | [
"Draw",
"ascii",
"diagram",
".",
"graph",
"-",
"easy",
"perl",
"module",
"require"
] | python | train | 39.363636 |
simonvh/genomepy | genomepy/plugin.py | https://github.com/simonvh/genomepy/blob/abace2366511dbe855fe1430b1f7d9ec4cbf6d29/genomepy/plugin.py#L30-L38 | def find_plugins():
"""Locate and initialize all available plugins.
"""
plugin_dir = os.path.dirname(os.path.realpath(__file__))
plugin_dir = os.path.join(plugin_dir, "plugins")
plugin_files = [x[:-3] for x in os.listdir(plugin_dir) if x.endswith(".py")]
sys.path.insert(0, plugin_dir)
for p... | [
"def",
"find_plugins",
"(",
")",
":",
"plugin_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"plugin_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"plugin_dir",
",",
"\"plugins\"",
... | Locate and initialize all available plugins. | [
"Locate",
"and",
"initialize",
"all",
"available",
"plugins",
"."
] | python | train | 40.111111 |
gwpy/gwpy | gwpy/table/filter.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/table/filter.py#L174-L191 | def parse_column_filters(*definitions):
"""Parse multiple compound column filter definitions
Examples
--------
>>> parse_column_filters('snr > 10', 'frequency < 1000')
[('snr', <function operator.gt>, 10.), ('frequency', <function operator.lt>, 1000.)]
>>> parse_column_filters('snr > 10 && freq... | [
"def",
"parse_column_filters",
"(",
"*",
"definitions",
")",
":",
"# noqa: E501",
"fltrs",
"=",
"[",
"]",
"for",
"def_",
"in",
"_flatten",
"(",
"definitions",
")",
":",
"if",
"is_filter_tuple",
"(",
"def_",
")",
":",
"fltrs",
".",
"append",
"(",
"def_",
... | Parse multiple compound column filter definitions
Examples
--------
>>> parse_column_filters('snr > 10', 'frequency < 1000')
[('snr', <function operator.gt>, 10.), ('frequency', <function operator.lt>, 1000.)]
>>> parse_column_filters('snr > 10 && frequency < 1000')
[('snr', <function operator.... | [
"Parse",
"multiple",
"compound",
"column",
"filter",
"definitions"
] | python | train | 38.666667 |
tobami/littlechef | littlechef/lib.py | https://github.com/tobami/littlechef/blob/aab8c94081b38100a69cc100bc4278ae7419c58e/littlechef/lib.py#L174-L191 | def get_nodes_with_recipe(recipe_name, environment=None):
"""Get all nodes which include a given recipe,
prefix-searches are also supported
"""
prefix_search = recipe_name.endswith("*")
if prefix_search:
recipe_name = recipe_name.rstrip("*")
for n in get_nodes(environment):
reci... | [
"def",
"get_nodes_with_recipe",
"(",
"recipe_name",
",",
"environment",
"=",
"None",
")",
":",
"prefix_search",
"=",
"recipe_name",
".",
"endswith",
"(",
"\"*\"",
")",
"if",
"prefix_search",
":",
"recipe_name",
"=",
"recipe_name",
".",
"rstrip",
"(",
"\"*\"",
... | Get all nodes which include a given recipe,
prefix-searches are also supported | [
"Get",
"all",
"nodes",
"which",
"include",
"a",
"given",
"recipe",
"prefix",
"-",
"searches",
"are",
"also",
"supported"
] | python | train | 35.777778 |
spotify/luigi | luigi/contrib/hive.py | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hive.py#L404-L411 | def path(self):
"""
Returns the path to this table in HDFS.
"""
location = self.client.table_location(self.table, self.database)
if not location:
raise Exception("Couldn't find location for table: {0}".format(str(self)))
return location | [
"def",
"path",
"(",
"self",
")",
":",
"location",
"=",
"self",
".",
"client",
".",
"table_location",
"(",
"self",
".",
"table",
",",
"self",
".",
"database",
")",
"if",
"not",
"location",
":",
"raise",
"Exception",
"(",
"\"Couldn't find location for table: {... | Returns the path to this table in HDFS. | [
"Returns",
"the",
"path",
"to",
"this",
"table",
"in",
"HDFS",
"."
] | python | train | 36.125 |
astropy/photutils | photutils/isophote/fitter.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/fitter.py#L41-L217 | def fit(self, conver=DEFAULT_CONVERGENCE, minit=DEFAULT_MINIT,
maxit=DEFAULT_MAXIT, fflag=DEFAULT_FFLAG, maxgerr=DEFAULT_MAXGERR,
going_inwards=False):
"""
Fit an elliptical isophote.
Parameters
----------
conver : float, optional
The main con... | [
"def",
"fit",
"(",
"self",
",",
"conver",
"=",
"DEFAULT_CONVERGENCE",
",",
"minit",
"=",
"DEFAULT_MINIT",
",",
"maxit",
"=",
"DEFAULT_MAXIT",
",",
"fflag",
"=",
"DEFAULT_FFLAG",
",",
"maxgerr",
"=",
"DEFAULT_MAXGERR",
",",
"going_inwards",
"=",
"False",
")",
... | Fit an elliptical isophote.
Parameters
----------
conver : float, optional
The main convergence criterion. Iterations stop when the
largest harmonic amplitude becomes smaller (in absolute
value) than ``conver`` times the harmonic fit rms. The
def... | [
"Fit",
"an",
"elliptical",
"isophote",
"."
] | python | train | 47.728814 |
davebridges/mousedb | mousedb/animal/views.py | https://github.com/davebridges/mousedb/blob/2a33f6d15d88b1540b05f7232b154fdbf8568580/mousedb/animal/views.py#L622-L627 | def get_context_data(self, **kwargs):
"""This add in the context of list_type and returns this as whatever the crosstype was."""
context = super(CrossTypeAnimalList, self).get_context_data(**kwargs)
context['list_type'] = self.kwargs['breeding_type']
return context | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"super",
"(",
"CrossTypeAnimalList",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"context",
"[",
"'list_type'",
"]",
"=",
"self",
".",... | This add in the context of list_type and returns this as whatever the crosstype was. | [
"This",
"add",
"in",
"the",
"context",
"of",
"list_type",
"and",
"returns",
"this",
"as",
"whatever",
"the",
"crosstype",
"was",
"."
] | python | train | 50.166667 |
nion-software/nionswift | nion/swift/Inspector.py | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/Inspector.py#L1211-L1217 | def __create_list_item_widget(self, ui, calibration_observable):
"""Called when an item (calibration_observable) is inserted into the list widget. Returns a widget."""
calibration_row = make_calibration_row_widget(ui, calibration_observable)
column = ui.create_column_widget()
column.add_... | [
"def",
"__create_list_item_widget",
"(",
"self",
",",
"ui",
",",
"calibration_observable",
")",
":",
"calibration_row",
"=",
"make_calibration_row_widget",
"(",
"ui",
",",
"calibration_observable",
")",
"column",
"=",
"ui",
".",
"create_column_widget",
"(",
")",
"co... | Called when an item (calibration_observable) is inserted into the list widget. Returns a widget. | [
"Called",
"when",
"an",
"item",
"(",
"calibration_observable",
")",
"is",
"inserted",
"into",
"the",
"list",
"widget",
".",
"Returns",
"a",
"widget",
"."
] | python | train | 54.571429 |
nyaruka/smartmin | smartmin/views.py | https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L867-L879 | def customize_form_field(self, name, field):
"""
Allows views to customize their form fields. By default, Smartmin replaces the plain textbox
date input with it's own DatePicker implementation.
"""
if isinstance(field, forms.fields.DateField) and isinstance(field.widget, forms.w... | [
"def",
"customize_form_field",
"(",
"self",
",",
"name",
",",
"field",
")",
":",
"if",
"isinstance",
"(",
"field",
",",
"forms",
".",
"fields",
".",
"DateField",
")",
"and",
"isinstance",
"(",
"field",
".",
"widget",
",",
"forms",
".",
"widgets",
".",
... | Allows views to customize their form fields. By default, Smartmin replaces the plain textbox
date input with it's own DatePicker implementation. | [
"Allows",
"views",
"to",
"customize",
"their",
"form",
"fields",
".",
"By",
"default",
"Smartmin",
"replaces",
"the",
"plain",
"textbox",
"date",
"input",
"with",
"it",
"s",
"own",
"DatePicker",
"implementation",
"."
] | python | train | 51.692308 |
tensorflow/tensor2tensor | tensor2tensor/models/research/transformer_revnet.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/transformer_revnet.py#L73-L133 | def transformer_revnet_encoder(encoder_input,
encoder_self_attention_bias,
hparams,
name="encoder"):
"""A stack of transformer layers.
Args:
encoder_input: a Tensor
encoder_self_attention_bias: bias Tensor for self... | [
"def",
"transformer_revnet_encoder",
"(",
"encoder_input",
",",
"encoder_self_attention_bias",
",",
"hparams",
",",
"name",
"=",
"\"encoder\"",
")",
":",
"def",
"f",
"(",
"x",
",",
"side_input",
")",
":",
"\"\"\"f(x) for reversible layer, self-attention layer.\"\"\"",
"... | A stack of transformer layers.
Args:
encoder_input: a Tensor
encoder_self_attention_bias: bias Tensor for self-attention
(see common_attention.attention_bias())
hparams: hyperparameters for model
name: a string
Returns:
y: a Tensors | [
"A",
"stack",
"of",
"transformer",
"layers",
"."
] | python | train | 32.311475 |
markovmodel/msmtools | msmtools/estimation/sparse/connectivity.py | https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/estimation/sparse/connectivity.py#L155-L175 | def is_connected(C, directed=True):
r"""Return true, if the input count matrix is completely connected.
Effectively checking if the number of connected components equals one.
Parameters
----------
C : scipy.sparse matrix or numpy ndarray
Count matrix specifying edge weights.
directed : ... | [
"def",
"is_connected",
"(",
"C",
",",
"directed",
"=",
"True",
")",
":",
"nc",
"=",
"csgraph",
".",
"connected_components",
"(",
"C",
",",
"directed",
"=",
"directed",
",",
"connection",
"=",
"'strong'",
",",
"return_labels",
"=",
"False",
")",
"return",
... | r"""Return true, if the input count matrix is completely connected.
Effectively checking if the number of connected components equals one.
Parameters
----------
C : scipy.sparse matrix or numpy ndarray
Count matrix specifying edge weights.
directed : bool, optional
Whether to compute... | [
"r",
"Return",
"true",
"if",
"the",
"input",
"count",
"matrix",
"is",
"completely",
"connected",
".",
"Effectively",
"checking",
"if",
"the",
"number",
"of",
"connected",
"components",
"equals",
"one",
"."
] | python | train | 32.47619 |
nicolargo/glances | glances/outputs/glances_bottle.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L143-L196 | def _route(self):
"""Define route."""
# REST API
self._app.route('/api/%s/config' % self.API_VERSION, method="GET",
callback=self._api_config)
self._app.route('/api/%s/config/<item>' % self.API_VERSION, method="GET",
callback=self._api_conf... | [
"def",
"_route",
"(",
"self",
")",
":",
"# REST API",
"self",
".",
"_app",
".",
"route",
"(",
"'/api/%s/config'",
"%",
"self",
".",
"API_VERSION",
",",
"method",
"=",
"\"GET\"",
",",
"callback",
"=",
"self",
".",
"_api_config",
")",
"self",
".",
"_app",
... | Define route. | [
"Define",
"route",
"."
] | python | train | 58.592593 |
DocNow/twarc | utils/network.py | https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/utils/network.py#L72-L91 | def add(from_user, from_id, to_user, to_id, type):
"adds a relation to the graph"
if options.users and to_user:
G.add_node(from_user, screen_name=from_user)
G.add_node(to_user, screen_name=to_user)
if G.has_edge(from_user, to_user):
weight = G[from_user][to_user]['we... | [
"def",
"add",
"(",
"from_user",
",",
"from_id",
",",
"to_user",
",",
"to_id",
",",
"type",
")",
":",
"if",
"options",
".",
"users",
"and",
"to_user",
":",
"G",
".",
"add_node",
"(",
"from_user",
",",
"screen_name",
"=",
"from_user",
")",
"G",
".",
"a... | adds a relation to the graph | [
"adds",
"a",
"relation",
"to",
"the",
"graph"
] | python | train | 33.75 |
pyvisa/pyvisa-py | pyvisa-py/highlevel.py | https://github.com/pyvisa/pyvisa-py/blob/dfbd509409675b59d71bb741cd72c5f256efd4cd/pyvisa-py/highlevel.py#L198-L211 | def clear(self, session):
"""Clears a device.
Corresponds to viClear function of the VISA library.
:param session: Unique logical identifier to a session.
:return: return value of the library call.
:rtype: :class:`pyvisa.constants.StatusCode`
"""
try:
... | [
"def",
"clear",
"(",
"self",
",",
"session",
")",
":",
"try",
":",
"sess",
"=",
"self",
".",
"sessions",
"[",
"session",
"]",
"except",
"KeyError",
":",
"return",
"constants",
".",
"StatusCode",
".",
"error_invalid_object",
"return",
"sess",
".",
"clear",
... | Clears a device.
Corresponds to viClear function of the VISA library.
:param session: Unique logical identifier to a session.
:return: return value of the library call.
:rtype: :class:`pyvisa.constants.StatusCode` | [
"Clears",
"a",
"device",
"."
] | python | train | 32.285714 |
chrisspen/burlap | burlap/dj.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/dj.py#L736-L770 | def manage_async(self, command='', name='process', site=ALL, exclude_sites='', end_message='', recipients=''):
"""
Starts a Django management command in a screen.
Parameters:
command :- all arguments passed to `./manage` as a single string
site :- the site to run the c... | [
"def",
"manage_async",
"(",
"self",
",",
"command",
"=",
"''",
",",
"name",
"=",
"'process'",
",",
"site",
"=",
"ALL",
",",
"exclude_sites",
"=",
"''",
",",
"end_message",
"=",
"''",
",",
"recipients",
"=",
"''",
")",
":",
"exclude_sites",
"=",
"exclud... | Starts a Django management command in a screen.
Parameters:
command :- all arguments passed to `./manage` as a single string
site :- the site to run the command for (default is all)
Designed to be ran like:
fab <role> dj.manage_async:"some_management_command --fo... | [
"Starts",
"a",
"Django",
"management",
"command",
"in",
"a",
"screen",
"."
] | python | valid | 41.514286 |
Becksteinlab/GromacsWrapper | gromacs/setup.py | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/setup.py#L171-L219 | def topology(struct=None, protein='protein',
top='system.top', dirname='top',
posres="posres.itp",
ff="oplsaa", water="tip4p",
**pdb2gmx_args):
"""Build Gromacs topology files from pdb.
:Keywords:
*struct*
input structure (**required**)
... | [
"def",
"topology",
"(",
"struct",
"=",
"None",
",",
"protein",
"=",
"'protein'",
",",
"top",
"=",
"'system.top'",
",",
"dirname",
"=",
"'top'",
",",
"posres",
"=",
"\"posres.itp\"",
",",
"ff",
"=",
"\"oplsaa\"",
",",
"water",
"=",
"\"tip4p\"",
",",
"*",
... | Build Gromacs topology files from pdb.
:Keywords:
*struct*
input structure (**required**)
*protein*
name of the output files
*top*
name of the topology file
*dirname*
directory in which the new topology will be stored
*ff*
fo... | [
"Build",
"Gromacs",
"topology",
"files",
"from",
"pdb",
"."
] | python | valid | 34.428571 |
pandas-dev/pandas | pandas/core/indexing.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L2193-L2212 | def _get_list_axis(self, key, axis=None):
"""
Return Series values by list or array of integers
Parameters
----------
key : list-like positional indexer
axis : int (can only be zero)
Returns
-------
Series object
"""
if axis is No... | [
"def",
"_get_list_axis",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"try",
":",
"return",
"self",
".",
"obj",
".",
"_take",
"(",
"key",
",",
"axis",
... | Return Series values by list or array of integers
Parameters
----------
key : list-like positional indexer
axis : int (can only be zero)
Returns
-------
Series object | [
"Return",
"Series",
"values",
"by",
"list",
"or",
"array",
"of",
"integers"
] | python | train | 27.5 |
apache/incubator-mxnet | python/mxnet/profiler.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/profiler.py#L165-L178 | def pause(profile_process='worker'):
"""Pause profiling.
Parameters
----------
profile_process : string
whether to profile kvstore `server` or `worker`.
server can only be profiled when kvstore is of type dist.
if this is not passed, defaults to `worker`
"""
profile_proc... | [
"def",
"pause",
"(",
"profile_process",
"=",
"'worker'",
")",
":",
"profile_process2int",
"=",
"{",
"'worker'",
":",
"0",
",",
"'server'",
":",
"1",
"}",
"check_call",
"(",
"_LIB",
".",
"MXProcessProfilePause",
"(",
"int",
"(",
"1",
")",
",",
"profile_proc... | Pause profiling.
Parameters
----------
profile_process : string
whether to profile kvstore `server` or `worker`.
server can only be profiled when kvstore is of type dist.
if this is not passed, defaults to `worker` | [
"Pause",
"profiling",
"."
] | python | train | 38.642857 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L366-L377 | def decode_signature(sigb64):
"""
Decode a signature into r, s
"""
sig_bin = base64.b64decode(sigb64)
if len(sig_bin) != 64:
raise ValueError("Invalid base64 signature")
sig_hex = sig_bin.encode('hex')
sig_r = int(sig_hex[:64], 16)
sig_s = int(sig_hex[64:], 16)
return sig_r,... | [
"def",
"decode_signature",
"(",
"sigb64",
")",
":",
"sig_bin",
"=",
"base64",
".",
"b64decode",
"(",
"sigb64",
")",
"if",
"len",
"(",
"sig_bin",
")",
"!=",
"64",
":",
"raise",
"ValueError",
"(",
"\"Invalid base64 signature\"",
")",
"sig_hex",
"=",
"sig_bin",... | Decode a signature into r, s | [
"Decode",
"a",
"signature",
"into",
"r",
"s"
] | python | train | 26.25 |
onicagroup/runway | runway/commands/runway_command.py | https://github.com/onicagroup/runway/blob/3f3549ec3bf6e39b9f27d9738a1847f3a4369e7f/runway/commands/runway_command.py#L76-L83 | def path_only_contains_dirs(self, path):
"""Return boolean on whether a path only contains directories."""
pathlistdir = os.listdir(path)
if pathlistdir == []:
return True
if any(os.path.isfile(os.path.join(path, i)) for i in pathlistdir):
return False
ret... | [
"def",
"path_only_contains_dirs",
"(",
"self",
",",
"path",
")",
":",
"pathlistdir",
"=",
"os",
".",
"listdir",
"(",
"path",
")",
"if",
"pathlistdir",
"==",
"[",
"]",
":",
"return",
"True",
"if",
"any",
"(",
"os",
".",
"path",
".",
"isfile",
"(",
"os... | Return boolean on whether a path only contains directories. | [
"Return",
"boolean",
"on",
"whether",
"a",
"path",
"only",
"contains",
"directories",
"."
] | python | train | 49.25 |
pyviz/imagen | imagen/patternfn.py | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patternfn.py#L201-L259 | def arc_by_radian(x, y, height, radian_range, thickness, gaussian_width):
"""
Radial arc with Gaussian fall-off after the solid ring-shaped
region with the given thickness, with shape specified by the
(start,end) radian_range.
"""
# Create a circular ring (copied from the ring function)
rad... | [
"def",
"arc_by_radian",
"(",
"x",
",",
"y",
",",
"height",
",",
"radian_range",
",",
"thickness",
",",
"gaussian_width",
")",
":",
"# Create a circular ring (copied from the ring function)",
"radius",
"=",
"height",
"/",
"2.0",
"half_thickness",
"=",
"thickness",
"/... | Radial arc with Gaussian fall-off after the solid ring-shaped
region with the given thickness, with shape specified by the
(start,end) radian_range. | [
"Radial",
"arc",
"with",
"Gaussian",
"fall",
"-",
"off",
"after",
"the",
"solid",
"ring",
"-",
"shaped",
"region",
"with",
"the",
"given",
"thickness",
"with",
"shape",
"specified",
"by",
"the",
"(",
"start",
"end",
")",
"radian_range",
"."
] | python | train | 45.745763 |
apache/spark | python/pyspark/sql/functions.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L778-L794 | def log(arg1, arg2=None):
"""Returns the first argument-based logarithm of the second argument.
If there is only one argument, then this takes the natural logarithm of the argument.
>>> df.select(log(10.0, df.age).alias('ten')).rdd.map(lambda l: str(l.ten)[:7]).collect()
['0.30102', '0.69897']
>>... | [
"def",
"log",
"(",
"arg1",
",",
"arg2",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"arg2",
"is",
"None",
":",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"log",
"(",
"_to_java_column",
"(",
"arg1",
... | Returns the first argument-based logarithm of the second argument.
If there is only one argument, then this takes the natural logarithm of the argument.
>>> df.select(log(10.0, df.age).alias('ten')).rdd.map(lambda l: str(l.ten)[:7]).collect()
['0.30102', '0.69897']
>>> df.select(log(df.age).alias('e'... | [
"Returns",
"the",
"first",
"argument",
"-",
"based",
"logarithm",
"of",
"the",
"second",
"argument",
"."
] | python | train | 37.352941 |
hirmeos/entity-fishing-client-python | nerd/nerd_client.py | https://github.com/hirmeos/entity-fishing-client-python/blob/cd5c6e10c6c4e653669e11d735d5773766986bda/nerd/nerd_client.py#L357-L375 | def get_concept(self, conceptId, lang='en'):
""" Fetch the concept from the Knowledge base
Args:
id (str): The concept id to be fetched, it can be Wikipedia
page id or Wikiedata id.
Returns:
dict, int: A dict containing the concept information; an inte... | [
"def",
"get_concept",
"(",
"self",
",",
"conceptId",
",",
"lang",
"=",
"'en'",
")",
":",
"url",
"=",
"urljoin",
"(",
"self",
".",
"concept_service",
"+",
"'/'",
",",
"conceptId",
")",
"res",
",",
"status_code",
"=",
"self",
".",
"get",
"(",
"url",
",... | Fetch the concept from the Knowledge base
Args:
id (str): The concept id to be fetched, it can be Wikipedia
page id or Wikiedata id.
Returns:
dict, int: A dict containing the concept information; an integer
representing the response code. | [
"Fetch",
"the",
"concept",
"from",
"the",
"Knowledge",
"base"
] | python | test | 32.578947 |
sci-bots/pygtkhelpers | pygtkhelpers/ui/widgets.py | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/widgets.py#L179-L184 | def _attr_sort_func(model, iter1, iter2, attribute):
"""Internal helper
"""
attr1 = getattr(model[iter1][0], attribute, None)
attr2 = getattr(model[iter2][0], attribute, None)
return cmp(attr1, attr2) | [
"def",
"_attr_sort_func",
"(",
"model",
",",
"iter1",
",",
"iter2",
",",
"attribute",
")",
":",
"attr1",
"=",
"getattr",
"(",
"model",
"[",
"iter1",
"]",
"[",
"0",
"]",
",",
"attribute",
",",
"None",
")",
"attr2",
"=",
"getattr",
"(",
"model",
"[",
... | Internal helper | [
"Internal",
"helper"
] | python | train | 35.833333 |
apache/spark | python/pyspark/rdd.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L1025-L1039 | def min(self, key=None):
"""
Find the minimum item in this RDD.
:param key: A function used to generate key for comparing
>>> rdd = sc.parallelize([2.0, 5.0, 43.0, 10.0])
>>> rdd.min()
2.0
>>> rdd.min(key=str)
10.0
"""
if key is None:
... | [
"def",
"min",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"return",
"self",
".",
"reduce",
"(",
"min",
")",
"return",
"self",
".",
"reduce",
"(",
"lambda",
"a",
",",
"b",
":",
"min",
"(",
"a",
",",
"b",
","... | Find the minimum item in this RDD.
:param key: A function used to generate key for comparing
>>> rdd = sc.parallelize([2.0, 5.0, 43.0, 10.0])
>>> rdd.min()
2.0
>>> rdd.min(key=str)
10.0 | [
"Find",
"the",
"minimum",
"item",
"in",
"this",
"RDD",
"."
] | python | train | 26.533333 |
RusticiSoftware/TinCanPython | tincan/remote_lrs.py | https://github.com/RusticiSoftware/TinCanPython/blob/424eedaa6d19221efb1108edb915fc332abbb317/tincan/remote_lrs.py#L553-L566 | def delete_state(self, state):
"""Delete a specified state from the LRS
:param state: State document to be deleted
:type state: :class:`tincan.documents.state_document.StateDocument`
:return: LRS Response object
:rtype: :class:`tincan.lrs_response.LRSResponse`
"""
... | [
"def",
"delete_state",
"(",
"self",
",",
"state",
")",
":",
"return",
"self",
".",
"_delete_state",
"(",
"activity",
"=",
"state",
".",
"activity",
",",
"agent",
"=",
"state",
".",
"agent",
",",
"state_id",
"=",
"state",
".",
"id",
",",
"etag",
"=",
... | Delete a specified state from the LRS
:param state: State document to be deleted
:type state: :class:`tincan.documents.state_document.StateDocument`
:return: LRS Response object
:rtype: :class:`tincan.lrs_response.LRSResponse` | [
"Delete",
"a",
"specified",
"state",
"from",
"the",
"LRS"
] | python | train | 33.714286 |
scanny/python-pptx | pptx/text/text.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/text/text.py#L555-L560 | def runs(self):
"""
Immutable sequence of |_Run| objects corresponding to the runs in
this paragraph.
"""
return tuple(_Run(r, self) for r in self._element.r_lst) | [
"def",
"runs",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"_Run",
"(",
"r",
",",
"self",
")",
"for",
"r",
"in",
"self",
".",
"_element",
".",
"r_lst",
")"
] | Immutable sequence of |_Run| objects corresponding to the runs in
this paragraph. | [
"Immutable",
"sequence",
"of",
"|_Run|",
"objects",
"corresponding",
"to",
"the",
"runs",
"in",
"this",
"paragraph",
"."
] | python | train | 32.833333 |
globality-corp/microcosm-flask | microcosm_flask/fields/timestamp_field.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/fields/timestamp_field.py#L24-L35 | def _serialize(self, value, attr, obj):
"""
Serialize value as a timestamp, either as a Unix timestamp (in float second) or a UTC isoformat string.
"""
if value is None:
return None
if self.use_isoformat:
return datetime.utcfromtimestamp(value).isoformat... | [
"def",
"_serialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"obj",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"use_isoformat",
":",
"return",
"datetime",
".",
"utcfromtimestamp",
"(",
"value",
")",
".",
"isof... | Serialize value as a timestamp, either as a Unix timestamp (in float second) or a UTC isoformat string. | [
"Serialize",
"value",
"as",
"a",
"timestamp",
"either",
"as",
"a",
"Unix",
"timestamp",
"(",
"in",
"float",
"second",
")",
"or",
"a",
"UTC",
"isoformat",
"string",
"."
] | python | train | 29.166667 |
decryptus/sonicprobe | sonicprobe/libs/xys.py | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/xys.py#L382-L384 | def _add_parameterized_validator_internal(param_validator, base_tag):
"with builtin tag prefixing"
add_parameterized_validator(param_validator, base_tag, tag_prefix=u'!~~%s(' % param_validator.__name__) | [
"def",
"_add_parameterized_validator_internal",
"(",
"param_validator",
",",
"base_tag",
")",
":",
"add_parameterized_validator",
"(",
"param_validator",
",",
"base_tag",
",",
"tag_prefix",
"=",
"u'!~~%s('",
"%",
"param_validator",
".",
"__name__",
")"
] | with builtin tag prefixing | [
"with",
"builtin",
"tag",
"prefixing"
] | python | train | 69.333333 |
BernardFW/bernard | src/bernard/i18n/_formatter.py | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/_formatter.py#L87-L92 | def format_datetime(self, value, format_):
"""
Format the datetime using Babel
"""
date_ = make_datetime(value)
return dates.format_datetime(date_, format_, locale=self.lang) | [
"def",
"format_datetime",
"(",
"self",
",",
"value",
",",
"format_",
")",
":",
"date_",
"=",
"make_datetime",
"(",
"value",
")",
"return",
"dates",
".",
"format_datetime",
"(",
"date_",
",",
"format_",
",",
"locale",
"=",
"self",
".",
"lang",
")"
] | Format the datetime using Babel | [
"Format",
"the",
"datetime",
"using",
"Babel"
] | python | train | 34.833333 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.