repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
ns1/ns1-python | ns1/ipam.py | https://github.com/ns1/ns1-python/blob/f3e1d90a3b76a1bd18f855f2c622a8a49d4b585e/ns1/ipam.py#L179-L221 | def load(self, callback=None, errback=None, reload=False):
"""
Load address data from the API.
"""
if not reload and self.data:
raise AddressException('Address already loaded')
def success(result, *args):
self.data = result
self.id = result['i... | [
"def",
"load",
"(",
"self",
",",
"callback",
"=",
"None",
",",
"errback",
"=",
"None",
",",
"reload",
"=",
"False",
")",
":",
"if",
"not",
"reload",
"and",
"self",
".",
"data",
":",
"raise",
"AddressException",
"(",
"'Address already loaded'",
")",
"def"... | Load address data from the API. | [
"Load",
"address",
"data",
"from",
"the",
"API",
"."
] | python | train |
mdiener/grace | grace/py27/pyjsdoc.py | https://github.com/mdiener/grace/blob/2dab13a2cf636da5da989904c5885166fc94d36d/grace/py27/pyjsdoc.py#L525-L536 | def translate_links(self, text, in_comment=None):
"""
Turn all @link tags in `text` into HTML anchor tags.
`in_comment` is the `CommentDoc` that contains the text, for
relative method lookups.
"""
def replace_link(matchobj):
ref = matchobj.group(1)
... | [
"def",
"translate_links",
"(",
"self",
",",
"text",
",",
"in_comment",
"=",
"None",
")",
":",
"def",
"replace_link",
"(",
"matchobj",
")",
":",
"ref",
"=",
"matchobj",
".",
"group",
"(",
"1",
")",
"return",
"'<a href = \"%s\">%s</a>'",
"%",
"(",
"self",
... | Turn all @link tags in `text` into HTML anchor tags.
`in_comment` is the `CommentDoc` that contains the text, for
relative method lookups. | [
"Turn",
"all",
"@link",
"tags",
"in",
"text",
"into",
"HTML",
"anchor",
"tags",
"."
] | python | train |
bwohlberg/sporco | sporco/admm/rpca.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/rpca.py#L191-L199 | def obfn_fvar(self):
"""Variable to be evaluated in computing regularisation term,
depending on 'fEvalX' option value.
"""
if self.opt['fEvalX']:
return self.X
else:
return self.cnst_c() - self.cnst_B(self.Y) | [
"def",
"obfn_fvar",
"(",
"self",
")",
":",
"if",
"self",
".",
"opt",
"[",
"'fEvalX'",
"]",
":",
"return",
"self",
".",
"X",
"else",
":",
"return",
"self",
".",
"cnst_c",
"(",
")",
"-",
"self",
".",
"cnst_B",
"(",
"self",
".",
"Y",
")"
] | Variable to be evaluated in computing regularisation term,
depending on 'fEvalX' option value. | [
"Variable",
"to",
"be",
"evaluated",
"in",
"computing",
"regularisation",
"term",
"depending",
"on",
"fEvalX",
"option",
"value",
"."
] | python | train |
OzymandiasTheGreat/python-libinput | libinput/device.py | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/device.py#L1814-L1832 | def size(self):
"""The physical size of a device in mm, where meaningful.
This property is only valid on devices with the required data, i.e.
tablets, touchpads and touchscreens. For other devices this property
raises :exc:`AssertionError`.
Returns:
(float, float): (Width, Height) in mm.
Raises:
Ass... | [
"def",
"size",
"(",
"self",
")",
":",
"width",
"=",
"c_double",
"(",
"0",
")",
"height",
"=",
"c_double",
"(",
"0",
")",
"rc",
"=",
"self",
".",
"_libinput",
".",
"libinput_device_get_size",
"(",
"self",
".",
"_handle",
",",
"byref",
"(",
"width",
")... | The physical size of a device in mm, where meaningful.
This property is only valid on devices with the required data, i.e.
tablets, touchpads and touchscreens. For other devices this property
raises :exc:`AssertionError`.
Returns:
(float, float): (Width, Height) in mm.
Raises:
AssertionError | [
"The",
"physical",
"size",
"of",
"a",
"device",
"in",
"mm",
"where",
"meaningful",
"."
] | python | train |
Microsoft/nni | tools/nni_annotation/__init__.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/__init__.py#L77-L107 | def expand_annotations(src_dir, dst_dir):
"""Expand annotations in user code.
Return dst_dir if annotation detected; return src_dir if not.
src_dir: directory path of user code (str)
dst_dir: directory to place generated files (str)
"""
if src_dir[-1] == slash:
src_dir = src_dir[:-1]
... | [
"def",
"expand_annotations",
"(",
"src_dir",
",",
"dst_dir",
")",
":",
"if",
"src_dir",
"[",
"-",
"1",
"]",
"==",
"slash",
":",
"src_dir",
"=",
"src_dir",
"[",
":",
"-",
"1",
"]",
"if",
"dst_dir",
"[",
"-",
"1",
"]",
"==",
"slash",
":",
"dst_dir",
... | Expand annotations in user code.
Return dst_dir if annotation detected; return src_dir if not.
src_dir: directory path of user code (str)
dst_dir: directory to place generated files (str) | [
"Expand",
"annotations",
"in",
"user",
"code",
".",
"Return",
"dst_dir",
"if",
"annotation",
"detected",
";",
"return",
"src_dir",
"if",
"not",
".",
"src_dir",
":",
"directory",
"path",
"of",
"user",
"code",
"(",
"str",
")",
"dst_dir",
":",
"directory",
"t... | python | train |
mitsei/dlkit | dlkit/records/assessment/qti/extended_text_interaction.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/qti/extended_text_interaction.py#L106-L111 | def set_max_strings(self, max_strings):
"""stub"""
if not self.my_osid_object_form._is_valid_integer(
max_strings, self.get_max_strings_metadata()):
raise InvalidArgument('maxStrings')
self.my_osid_object_form._my_map['maxStrings'] = max_strings | [
"def",
"set_max_strings",
"(",
"self",
",",
"max_strings",
")",
":",
"if",
"not",
"self",
".",
"my_osid_object_form",
".",
"_is_valid_integer",
"(",
"max_strings",
",",
"self",
".",
"get_max_strings_metadata",
"(",
")",
")",
":",
"raise",
"InvalidArgument",
"(",... | stub | [
"stub"
] | python | train |
nerdvegas/rez | src/rez/backport/zipfile.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/backport/zipfile.py#L979-L1000 | def _writecheck(self, zinfo):
"""Check for errors before writing a file to the archive."""
if zinfo.filename in self.NameToInfo:
if self.debug: # Warning for duplicate names
print "Duplicate name:", zinfo.filename
if self.mode not in ("w", "a"):
raise... | [
"def",
"_writecheck",
"(",
"self",
",",
"zinfo",
")",
":",
"if",
"zinfo",
".",
"filename",
"in",
"self",
".",
"NameToInfo",
":",
"if",
"self",
".",
"debug",
":",
"# Warning for duplicate names",
"print",
"\"Duplicate name:\"",
",",
"zinfo",
".",
"filename",
... | Check for errors before writing a file to the archive. | [
"Check",
"for",
"errors",
"before",
"writing",
"a",
"file",
"to",
"the",
"archive",
"."
] | python | train |
proycon/flat | flat/views.py | https://github.com/proycon/flat/blob/f14eea61edcae8656dadccd9a43481ff7e710ffb/flat/views.py#L123-L177 | def initdoc(request, namespace, docid, mode, template, context=None, configuration=None):
"""Initialise a document (not invoked directly)"""
perspective = request.GET.get('perspective','document')
if context is None: context = {}
if 'configuration' in request.session:
configuration = request.ses... | [
"def",
"initdoc",
"(",
"request",
",",
"namespace",
",",
"docid",
",",
"mode",
",",
"template",
",",
"context",
"=",
"None",
",",
"configuration",
"=",
"None",
")",
":",
"perspective",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'perspective'",
",",
... | Initialise a document (not invoked directly) | [
"Initialise",
"a",
"document",
"(",
"not",
"invoked",
"directly",
")"
] | python | train |
expfactory/expfactory | expfactory/database/filesystem.py | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L56-L66 | def generate_subid(self, token=None):
'''assumes a flat (file system) database, organized by experiment id, and
subject id, with data (json) organized by subject identifier
'''
# Not headless auto-increments
if not token:
token = str(uuid.uuid4())
# Headless doesn't use any folder_... | [
"def",
"generate_subid",
"(",
"self",
",",
"token",
"=",
"None",
")",
":",
"# Not headless auto-increments",
"if",
"not",
"token",
":",
"token",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"# Headless doesn't use any folder_id, just generated token folder"... | assumes a flat (file system) database, organized by experiment id, and
subject id, with data (json) organized by subject identifier | [
"assumes",
"a",
"flat",
"(",
"file",
"system",
")",
"database",
"organized",
"by",
"experiment",
"id",
"and",
"subject",
"id",
"with",
"data",
"(",
"json",
")",
"organized",
"by",
"subject",
"identifier"
] | python | train |
s1s5/django_busybody | django_busybody/views.py | https://github.com/s1s5/django_busybody/blob/5c6fd89824224f1de1be79ccd9a149f025af1b8f/django_busybody/views.py#L155-L161 | def form_valid(self, forms):
"""
If the form is valid, save the associated model.
"""
for key, form in forms.items():
setattr(self, '{}_object'.format(key), form.save())
return super(MultipleModelFormMixin, self).form_valid(forms) | [
"def",
"form_valid",
"(",
"self",
",",
"forms",
")",
":",
"for",
"key",
",",
"form",
"in",
"forms",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"'{}_object'",
".",
"format",
"(",
"key",
")",
",",
"form",
".",
"save",
"(",
")",
")",
... | If the form is valid, save the associated model. | [
"If",
"the",
"form",
"is",
"valid",
"save",
"the",
"associated",
"model",
"."
] | python | train |
twisted/axiom | axiom/store.py | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L1731-L1779 | def batchInsert(self, itemType, itemAttributes, dataRows):
"""
Create multiple items in the store without loading
corresponding Python objects into memory.
the items' C{stored} callback will not be called.
Example::
myData = [(37, u"Fred", u"Wichita"),
... | [
"def",
"batchInsert",
"(",
"self",
",",
"itemType",
",",
"itemAttributes",
",",
"dataRows",
")",
":",
"class",
"FakeItem",
":",
"pass",
"_NEEDS_DEFAULT",
"=",
"object",
"(",
")",
"# token for lookup failure",
"fakeOSelf",
"=",
"FakeItem",
"(",
")",
"fakeOSelf",
... | Create multiple items in the store without loading
corresponding Python objects into memory.
the items' C{stored} callback will not be called.
Example::
myData = [(37, u"Fred", u"Wichita"),
(28, u"Jim", u"Fresno"),
(43, u"Betty", u"Du... | [
"Create",
"multiple",
"items",
"in",
"the",
"store",
"without",
"loading",
"corresponding",
"Python",
"objects",
"into",
"memory",
"."
] | python | train |
sorgerlab/indra | rest_api/api.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/rest_api/api.py#L187-L196 | def biopax_process_pc_pathsfromto():
"""Process PathwayCommons paths from-to genes, return INDRA Statements."""
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
source = body.get('source')
target = body.get('target')
... | [
"def",
"biopax_process_pc_pathsfromto",
"(",
")",
":",
"if",
"request",
".",
"method",
"==",
"'OPTIONS'",
":",
"return",
"{",
"}",
"response",
"=",
"request",
".",
"body",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"body",
"=",
"json",
... | Process PathwayCommons paths from-to genes, return INDRA Statements. | [
"Process",
"PathwayCommons",
"paths",
"from",
"-",
"to",
"genes",
"return",
"INDRA",
"Statements",
"."
] | python | train |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/AnyValueArray.py | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/AnyValueArray.py#L248-L259 | def get_as_float_with_default(self, index, default_value):
"""
Converts array element into a float or returns default value if conversion is not possible.
:param index: an index of element to get.
:param default_value: the default value
:return: float value ot the element or d... | [
"def",
"get_as_float_with_default",
"(",
"self",
",",
"index",
",",
"default_value",
")",
":",
"value",
"=",
"self",
"[",
"index",
"]",
"return",
"FloatConverter",
".",
"to_float_with_default",
"(",
"value",
",",
"default_value",
")"
] | Converts array element into a float or returns default value if conversion is not possible.
:param index: an index of element to get.
:param default_value: the default value
:return: float value ot the element or default value if conversion is not supported. | [
"Converts",
"array",
"element",
"into",
"a",
"float",
"or",
"returns",
"default",
"value",
"if",
"conversion",
"is",
"not",
"possible",
"."
] | python | train |
sundarnagarajan/py25519 | setupext/__init__.py | https://github.com/sundarnagarajan/py25519/blob/3756331d1b6ff1f797b8f23567c4ac490bd07680/setupext/__init__.py#L116-L184 | def run_in_order(l, show_output=True, show_err=True, ignore_err=False,
args=(), **kwargs):
'''
Processes each element of l in order:
if it is a string: execute it as a shell command
elif it is a callable, call it with *args, **kwargs
l-->list: Each elem is either a string (... | [
"def",
"run_in_order",
"(",
"l",
",",
"show_output",
"=",
"True",
",",
"show_err",
"=",
"True",
",",
"ignore_err",
"=",
"False",
",",
"args",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set defaults",
"if",
"show_output",
"is",
"None",
":",
... | Processes each element of l in order:
if it is a string: execute it as a shell command
elif it is a callable, call it with *args, **kwargs
l-->list: Each elem is either a string (shell command) or callable
Any other type is ignored
show_output-->boolean: Show stdout of shell comma... | [
"Processes",
"each",
"element",
"of",
"l",
"in",
"order",
":",
"if",
"it",
"is",
"a",
"string",
":",
"execute",
"it",
"as",
"a",
"shell",
"command",
"elif",
"it",
"is",
"a",
"callable",
"call",
"it",
"with",
"*",
"args",
"**",
"kwargs"
] | python | train |
davgeo/clear | clear/database.py | https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/database.py#L184-L194 | def _PurgeTable(self, tableName):
"""
Deletes all rows from given table without dropping table.
Parameters
----------
tableName : string
Name of table.
"""
goodlogging.Log.Info("DB", "Deleting all entries from table {0}".format(tableName), verbosity=self.logVerbosity)
self._Ac... | [
"def",
"_PurgeTable",
"(",
"self",
",",
"tableName",
")",
":",
"goodlogging",
".",
"Log",
".",
"Info",
"(",
"\"DB\"",
",",
"\"Deleting all entries from table {0}\"",
".",
"format",
"(",
"tableName",
")",
",",
"verbosity",
"=",
"self",
".",
"logVerbosity",
")",... | Deletes all rows from given table without dropping table.
Parameters
----------
tableName : string
Name of table. | [
"Deletes",
"all",
"rows",
"from",
"given",
"table",
"without",
"dropping",
"table",
"."
] | python | train |
blockstack/blockstack-core | blockstack/blockstackd.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2746-L2755 | def verify_database(trusted_consensus_hash, consensus_block_height, untrusted_working_dir, trusted_working_dir, start_block=None, expected_snapshots={}):
"""
Verify that a database is consistent with a
known-good consensus hash.
Return True if valid.
Return False if not
"""
db = BlockstackDB... | [
"def",
"verify_database",
"(",
"trusted_consensus_hash",
",",
"consensus_block_height",
",",
"untrusted_working_dir",
",",
"trusted_working_dir",
",",
"start_block",
"=",
"None",
",",
"expected_snapshots",
"=",
"{",
"}",
")",
":",
"db",
"=",
"BlockstackDB",
".",
"ge... | Verify that a database is consistent with a
known-good consensus hash.
Return True if valid.
Return False if not | [
"Verify",
"that",
"a",
"database",
"is",
"consistent",
"with",
"a",
"known",
"-",
"good",
"consensus",
"hash",
".",
"Return",
"True",
"if",
"valid",
".",
"Return",
"False",
"if",
"not"
] | python | train |
Anaconda-Platform/anaconda-client | binstar_client/mixins/channels.py | https://github.com/Anaconda-Platform/anaconda-client/blob/b276f0572744c73c184a8b43a897cfa7fc1dc523/binstar_client/mixins/channels.py#L22-L30 | def show_channel(self, channel, owner):
'''List the channels for owner
If owner is none, the currently logged in user is used
'''
url = '%s/channels/%s/%s' % (self.domain, owner, channel)
res = self.session.get(url)
self._check_response(res, [200])
return res.jso... | [
"def",
"show_channel",
"(",
"self",
",",
"channel",
",",
"owner",
")",
":",
"url",
"=",
"'%s/channels/%s/%s'",
"%",
"(",
"self",
".",
"domain",
",",
"owner",
",",
"channel",
")",
"res",
"=",
"self",
".",
"session",
".",
"get",
"(",
"url",
")",
"self"... | List the channels for owner
If owner is none, the currently logged in user is used | [
"List",
"the",
"channels",
"for",
"owner",
"If",
"owner",
"is",
"none",
"the",
"currently",
"logged",
"in",
"user",
"is",
"used"
] | python | train |
grabbles/grabbit | grabbit/utils.py | https://github.com/grabbles/grabbit/blob/83ff93df36019eaaee9d4e31f816a518e46cae07/grabbit/utils.py#L34-L37 | def listify(obj, ignore=(list, tuple, type(None))):
''' Wraps all non-list or tuple objects in a list; provides a simple way
to accept flexible arguments. '''
return obj if isinstance(obj, ignore) else [obj] | [
"def",
"listify",
"(",
"obj",
",",
"ignore",
"=",
"(",
"list",
",",
"tuple",
",",
"type",
"(",
"None",
")",
")",
")",
":",
"return",
"obj",
"if",
"isinstance",
"(",
"obj",
",",
"ignore",
")",
"else",
"[",
"obj",
"]"
] | Wraps all non-list or tuple objects in a list; provides a simple way
to accept flexible arguments. | [
"Wraps",
"all",
"non",
"-",
"list",
"or",
"tuple",
"objects",
"in",
"a",
"list",
";",
"provides",
"a",
"simple",
"way",
"to",
"accept",
"flexible",
"arguments",
"."
] | python | train |
CI-WATER/gsshapy | gsshapy/orm/snw.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/snw.py#L211-L244 | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Orographic Gage File Read from File Method
"""
# Set file extension property
self.fileExtension = extension
# Open file and parse into HmetRecords
... | [
"def",
"_read",
"(",
"self",
",",
"directory",
",",
"filename",
",",
"session",
",",
"path",
",",
"name",
",",
"extension",
",",
"spatial",
",",
"spatialReferenceID",
",",
"replaceParamFile",
")",
":",
"# Set file extension property",
"self",
".",
"fileExtension... | Orographic Gage File Read from File Method | [
"Orographic",
"Gage",
"File",
"Read",
"from",
"File",
"Method"
] | python | train |
odlgroup/odl | odl/solvers/functional/default_functionals.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/solvers/functional/default_functionals.py#L1424-L1461 | def gradient(self):
"""Gradient operator of the functional.
The gradient is not defined in points where one or more components
are less than or equal to 0.
"""
functional = self
class KLCrossEntropyGradient(Operator):
"""The gradient operator of this functi... | [
"def",
"gradient",
"(",
"self",
")",
":",
"functional",
"=",
"self",
"class",
"KLCrossEntropyGradient",
"(",
"Operator",
")",
":",
"\"\"\"The gradient operator of this functional.\"\"\"",
"def",
"__init__",
"(",
"self",
")",
":",
"\"\"\"Initialize a new instance.\"\"\"",
... | Gradient operator of the functional.
The gradient is not defined in points where one or more components
are less than or equal to 0. | [
"Gradient",
"operator",
"of",
"the",
"functional",
"."
] | python | train |
singularityhub/singularity-python | singularity/analysis/reproduce/levels.py | https://github.com/singularityhub/singularity-python/blob/498c3433724b332f7493fec632d8daf479f47b82/singularity/analysis/reproduce/levels.py#L34-L61 | def get_custom_level(regexp=None,description=None,skip_files=None,include_files=None):
'''get_custom_level will generate a custom level for the user,
based on a regular expression. If used outside the context of tarsum, the user
can generate their own named and described filters.
:param regexp: must be... | [
"def",
"get_custom_level",
"(",
"regexp",
"=",
"None",
",",
"description",
"=",
"None",
",",
"skip_files",
"=",
"None",
",",
"include_files",
"=",
"None",
")",
":",
"if",
"regexp",
"==",
"None",
":",
"regexp",
"=",
"\".\"",
"if",
"description",
"is",
"No... | get_custom_level will generate a custom level for the user,
based on a regular expression. If used outside the context of tarsum, the user
can generate their own named and described filters.
:param regexp: must be defined, the file filter regular expression
:param description: optional description | [
"get_custom_level",
"will",
"generate",
"a",
"custom",
"level",
"for",
"the",
"user",
"based",
"on",
"a",
"regular",
"expression",
".",
"If",
"used",
"outside",
"the",
"context",
"of",
"tarsum",
"the",
"user",
"can",
"generate",
"their",
"own",
"named",
"and... | python | train |
ansible/ansible-runner | ansible_runner/runner_config.py | https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner_config.py#L290-L365 | def generate_ansible_command(self):
"""
Given that the ``RunnerConfig`` preparation methods have been run to gather the inputs this method
will generate the ``ansible`` or ``ansible-playbook`` command that will be used by the
:py:class:`ansible_runner.runner.Runner` object to start the p... | [
"def",
"generate_ansible_command",
"(",
"self",
")",
":",
"if",
"self",
".",
"binary",
"is",
"not",
"None",
":",
"base_command",
"=",
"self",
".",
"binary",
"self",
".",
"execution_mode",
"=",
"ExecutionMode",
".",
"RAW",
"elif",
"self",
".",
"module",
"is... | Given that the ``RunnerConfig`` preparation methods have been run to gather the inputs this method
will generate the ``ansible`` or ``ansible-playbook`` command that will be used by the
:py:class:`ansible_runner.runner.Runner` object to start the process | [
"Given",
"that",
"the",
"RunnerConfig",
"preparation",
"methods",
"have",
"been",
"run",
"to",
"gather",
"the",
"inputs",
"this",
"method",
"will",
"generate",
"the",
"ansible",
"or",
"ansible",
"-",
"playbook",
"command",
"that",
"will",
"be",
"used",
"by",
... | python | train |
scivision/pymap3d | pymap3d/sidereal.py | https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/sidereal.py#L58-L97 | def juliandate(time: datetime) -> float:
"""
Python datetime to Julian time
from D.Vallado Fundamentals of Astrodynamics and Applications p.187
and J. Meeus Astronomical Algorithms 1991 Eqn. 7.1 pg. 61
Parameters
----------
time : datetime.datetime
time to convert
Results
... | [
"def",
"juliandate",
"(",
"time",
":",
"datetime",
")",
"->",
"float",
":",
"times",
"=",
"np",
".",
"atleast_1d",
"(",
"time",
")",
"assert",
"times",
".",
"ndim",
"==",
"1",
"jd",
"=",
"np",
".",
"empty",
"(",
"times",
".",
"size",
")",
"for",
... | Python datetime to Julian time
from D.Vallado Fundamentals of Astrodynamics and Applications p.187
and J. Meeus Astronomical Algorithms 1991 Eqn. 7.1 pg. 61
Parameters
----------
time : datetime.datetime
time to convert
Results
-------
jd : float
Julian date | [
"Python",
"datetime",
"to",
"Julian",
"time"
] | python | train |
cltl/KafNafParserPy | KafNafParserPy/header_data.py | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/header_data.py#L372-L381 | def set_endTimestamp(self,etimestamp=None):
"""
Set the end timestamp of the linguistic processor, set to None for the current time
@type etimestamp: string
@param etimestamp: version of the linguistic processor
"""
if etimestamp is None:
import time
... | [
"def",
"set_endTimestamp",
"(",
"self",
",",
"etimestamp",
"=",
"None",
")",
":",
"if",
"etimestamp",
"is",
"None",
":",
"import",
"time",
"etimestamp",
"=",
"time",
".",
"strftime",
"(",
"'%Y-%m-%dT%H:%M:%S%Z'",
")",
"self",
".",
"node",
".",
"set",
"(",
... | Set the end timestamp of the linguistic processor, set to None for the current time
@type etimestamp: string
@param etimestamp: version of the linguistic processor | [
"Set",
"the",
"end",
"timestamp",
"of",
"the",
"linguistic",
"processor",
"set",
"to",
"None",
"for",
"the",
"current",
"time"
] | python | train |
jaredLunde/redis_structures | redis_structures/__init__.py | https://github.com/jaredLunde/redis_structures/blob/b9cce5f5c85db5e12c292633ff8d04e3ae053294/redis_structures/__init__.py#L1511-L1526 | def iter(self, start=0, count=1000):
""" @start: #int cursor start position
@stop: #int cursor stop position
@count: #int buffer limit
-> yields all of the items in the list
"""
cursor = '0'
_loads = self._loads
stop = start + count
wh... | [
"def",
"iter",
"(",
"self",
",",
"start",
"=",
"0",
",",
"count",
"=",
"1000",
")",
":",
"cursor",
"=",
"'0'",
"_loads",
"=",
"self",
".",
"_loads",
"stop",
"=",
"start",
"+",
"count",
"while",
"cursor",
":",
"cursor",
"=",
"self",
".",
"_client",
... | @start: #int cursor start position
@stop: #int cursor stop position
@count: #int buffer limit
-> yields all of the items in the list | [
"@start",
":",
"#int",
"cursor",
"start",
"position",
"@stop",
":",
"#int",
"cursor",
"stop",
"position",
"@count",
":",
"#int",
"buffer",
"limit"
] | python | train |
tomnor/channelpack | channelpack/pack.py | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L431-L472 | def add_condition(self, conkey, cond):
"""Add a condition, one of the addable ones.
conkey: str
One of 'cond', startcond' or 'stopcond'. 'start' or 'stop'
is accepted as shorts for 'startcond' or 'stopcond'. If the
conkey is given with an explicit number (like 'stopc... | [
"def",
"add_condition",
"(",
"self",
",",
"conkey",
",",
"cond",
")",
":",
"# Audit:",
"if",
"conkey",
"==",
"'start'",
"or",
"conkey",
"==",
"'stop'",
":",
"conkey",
"+=",
"'cond'",
"if",
"not",
"any",
"(",
"conkey",
".",
"startswith",
"(",
"addable",
... | Add a condition, one of the addable ones.
conkey: str
One of 'cond', startcond' or 'stopcond'. 'start' or 'stop'
is accepted as shorts for 'startcond' or 'stopcond'. If the
conkey is given with an explicit number (like 'stopcond3')
and already exist, it will be o... | [
"Add",
"a",
"condition",
"one",
"of",
"the",
"addable",
"ones",
"."
] | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/build/build_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/build/build_client.py#L1493-L1526 | def get_status_badge(self, project, definition, branch_name=None, stage_name=None, job_name=None, configuration=None, label=None):
"""GetStatusBadge.
[Preview API] <p>Gets the build status for a definition, optionally scoped to a specific branch, stage, job, and configuration.</p> <p>If there are more t... | [
"def",
"get_status_badge",
"(",
"self",
",",
"project",
",",
"definition",
",",
"branch_name",
"=",
"None",
",",
"stage_name",
"=",
"None",
",",
"job_name",
"=",
"None",
",",
"configuration",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"route_values"... | GetStatusBadge.
[Preview API] <p>Gets the build status for a definition, optionally scoped to a specific branch, stage, job, and configuration.</p> <p>If there are more than one, then it is required to pass in a stageName value when specifying a jobName, and the same rule then applies for both if passing a conf... | [
"GetStatusBadge",
".",
"[",
"Preview",
"API",
"]",
"<p",
">",
"Gets",
"the",
"build",
"status",
"for",
"a",
"definition",
"optionally",
"scoped",
"to",
"a",
"specific",
"branch",
"stage",
"job",
"and",
"configuration",
".",
"<",
"/",
"p",
">",
"<p",
">",... | python | train |
seleniumbase/SeleniumBase | seleniumbase/fixtures/js_utils.py | https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/js_utils.py#L14-L40 | def wait_for_ready_state_complete(driver, timeout=settings.EXTREME_TIMEOUT):
"""
The DOM (Document Object Model) has a property called "readyState".
When the value of this becomes "complete", page resources are considered
fully loaded (although AJAX and other loads might still be happening).
This me... | [
"def",
"wait_for_ready_state_complete",
"(",
"driver",
",",
"timeout",
"=",
"settings",
".",
"EXTREME_TIMEOUT",
")",
":",
"start_ms",
"=",
"time",
".",
"time",
"(",
")",
"*",
"1000.0",
"stop_ms",
"=",
"start_ms",
"+",
"(",
"timeout",
"*",
"1000.0",
")",
"f... | The DOM (Document Object Model) has a property called "readyState".
When the value of this becomes "complete", page resources are considered
fully loaded (although AJAX and other loads might still be happening).
This method will wait until document.readyState == "complete". | [
"The",
"DOM",
"(",
"Document",
"Object",
"Model",
")",
"has",
"a",
"property",
"called",
"readyState",
".",
"When",
"the",
"value",
"of",
"this",
"becomes",
"complete",
"page",
"resources",
"are",
"considered",
"fully",
"loaded",
"(",
"although",
"AJAX",
"an... | python | train |
EmbodiedCognition/py-c3d | c3d.py | https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L136-L171 | def read(self, handle):
'''Read and parse binary header data from a file handle.
This method reads exactly 512 bytes from the beginning of the given file
handle.
Parameters
----------
handle : file handle
The given handle will be reset to 0 using `seek` and ... | [
"def",
"read",
"(",
"self",
",",
"handle",
")",
":",
"handle",
".",
"seek",
"(",
"0",
")",
"(",
"self",
".",
"parameter_block",
",",
"magic",
",",
"self",
".",
"point_count",
",",
"self",
".",
"analog_count",
",",
"self",
".",
"first_frame",
",",
"se... | Read and parse binary header data from a file handle.
This method reads exactly 512 bytes from the beginning of the given file
handle.
Parameters
----------
handle : file handle
The given handle will be reset to 0 using `seek` and then 512 bytes
will be ... | [
"Read",
"and",
"parse",
"binary",
"header",
"data",
"from",
"a",
"file",
"handle",
"."
] | python | train |
jfilter/text-classification-keras | texcla/corpus.py | https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/corpus.py#L25-L40 | def read_pos_neg_data(path, folder, limit):
"""returns array with positive and negative examples"""
training_pos_path = os.path.join(path, folder, 'pos')
training_neg_path = os.path.join(path, folder, 'neg')
X_pos = read_folder(training_pos_path)
X_neg = read_folder(training_neg_path)
if limit... | [
"def",
"read_pos_neg_data",
"(",
"path",
",",
"folder",
",",
"limit",
")",
":",
"training_pos_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"folder",
",",
"'pos'",
")",
"training_neg_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pat... | returns array with positive and negative examples | [
"returns",
"array",
"with",
"positive",
"and",
"negative",
"examples"
] | python | train |
CyberZHG/keras-word-char-embd | keras_wc_embd/word_char_embd.py | https://github.com/CyberZHG/keras-word-char-embd/blob/cca6ddff01b6264dd0d12613bb9ed308e1367b8c/keras_wc_embd/word_char_embd.py#L84-L198 | def get_embedding_layer(word_dict_len,
char_dict_len,
max_word_len,
word_embd_dim=300,
char_embd_dim=30,
char_hidden_dim=150,
char_hidden_layer_type='lstm',
... | [
"def",
"get_embedding_layer",
"(",
"word_dict_len",
",",
"char_dict_len",
",",
"max_word_len",
",",
"word_embd_dim",
"=",
"300",
",",
"char_embd_dim",
"=",
"30",
",",
"char_hidden_dim",
"=",
"150",
",",
"char_hidden_layer_type",
"=",
"'lstm'",
",",
"word_embd_weight... | Get the merged embedding layer.
:param word_dict_len: The number of words in the dictionary including the ones mapped to 0 or 1.
:param char_dict_len: The number of characters in the dictionary including the ones mapped to 0 or 1.
:param max_word_len: The maximum allowed length of word.
:param word_emb... | [
"Get",
"the",
"merged",
"embedding",
"layer",
"."
] | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/settings/settings_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/settings/settings_client.py#L122-L142 | def set_entries_for_scope(self, entries, user_scope, scope_name, scope_value):
"""SetEntriesForScope.
[Preview API] Set the specified entries for the given named scope
:param {object} entries: The entries to set
:param str user_scope: User-Scope at which to set the values. Should be "me"... | [
"def",
"set_entries_for_scope",
"(",
"self",
",",
"entries",
",",
"user_scope",
",",
"scope_name",
",",
"scope_value",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"user_scope",
"is",
"not",
"None",
":",
"route_values",
"[",
"'userScope'",
"]",
"=",
"self"... | SetEntriesForScope.
[Preview API] Set the specified entries for the given named scope
:param {object} entries: The entries to set
:param str user_scope: User-Scope at which to set the values. Should be "me" for the current user or "host" for all users.
:param str scope_name: Scope at whi... | [
"SetEntriesForScope",
".",
"[",
"Preview",
"API",
"]",
"Set",
"the",
"specified",
"entries",
"for",
"the",
"given",
"named",
"scope",
":",
"param",
"{",
"object",
"}",
"entries",
":",
"The",
"entries",
"to",
"set",
":",
"param",
"str",
"user_scope",
":",
... | python | train |
jobovy/galpy | galpy/orbit/RZOrbit.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/orbit/RZOrbit.py#L215-L259 | def Jacobi(self,*args,**kwargs):
"""
NAME:
Jacobi
PURPOSE:
calculate the Jacobi integral of the motion
INPUT:
t - (optional) time at which to get the radius
OmegaP= pattern speed of rotating frame (scalar)
pot= potential instance or ... | [
"def",
"Jacobi",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"'OmegaP'",
"in",
"kwargs",
"or",
"kwargs",
"[",
"'OmegaP'",
"]",
"is",
"None",
":",
"OmegaP",
"=",
"1.",
"if",
"not",
"'pot'",
"in",
"kwargs",
"or",
... | NAME:
Jacobi
PURPOSE:
calculate the Jacobi integral of the motion
INPUT:
t - (optional) time at which to get the radius
OmegaP= pattern speed of rotating frame (scalar)
pot= potential instance or list of such instances
OUTPUT:
Jac... | [
"NAME",
":",
"Jacobi",
"PURPOSE",
":",
"calculate",
"the",
"Jacobi",
"integral",
"of",
"the",
"motion",
"INPUT",
":",
"t",
"-",
"(",
"optional",
")",
"time",
"at",
"which",
"to",
"get",
"the",
"radius",
"OmegaP",
"=",
"pattern",
"speed",
"of",
"rotating"... | python | train |
visualfabriq/bquery | bquery/benchmarks/bench_groupby.py | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/benchmarks/bench_groupby.py#L29-L39 | def ctime(message=None):
"Counts the time spent in some context"
global t_elapsed
t_elapsed = 0.0
print('\n')
t = time.time()
yield
if message:
print(message + ": ", end='')
t_elapsed = time.time() - t
print(round(t_elapsed, 4), "sec") | [
"def",
"ctime",
"(",
"message",
"=",
"None",
")",
":",
"global",
"t_elapsed",
"t_elapsed",
"=",
"0.0",
"print",
"(",
"'\\n'",
")",
"t",
"=",
"time",
".",
"time",
"(",
")",
"yield",
"if",
"message",
":",
"print",
"(",
"message",
"+",
"\": \"",
",",
... | Counts the time spent in some context | [
"Counts",
"the",
"time",
"spent",
"in",
"some",
"context"
] | python | train |
andreasjansson/head-in-the-clouds | headintheclouds/dependencies/PyDbLite/PyDbLite_conversions.py | https://github.com/andreasjansson/head-in-the-clouds/blob/32c1d00d01036834dc94368e7f38b0afd3f7a82f/headintheclouds/dependencies/PyDbLite/PyDbLite_conversions.py#L28-L106 | def fromCSV(csvfile,out=None,fieldnames=None,fmtparams=None,conv_func={},
empty_to_None=[]):
"""Conversion from CSV to PyDbLite
csvfile : name of the CSV file in the file system
out : path for the new PyDbLite base in the file system
fieldnames : list of field names. If set to None, the fie... | [
"def",
"fromCSV",
"(",
"csvfile",
",",
"out",
"=",
"None",
",",
"fieldnames",
"=",
"None",
",",
"fmtparams",
"=",
"None",
",",
"conv_func",
"=",
"{",
"}",
",",
"empty_to_None",
"=",
"[",
"]",
")",
":",
"import",
"csv",
"import",
"time",
"import",
"da... | Conversion from CSV to PyDbLite
csvfile : name of the CSV file in the file system
out : path for the new PyDbLite base in the file system
fieldnames : list of field names. If set to None, the field names must
be present in the first line of the CSV file
fmtparams : the format paramete... | [
"Conversion",
"from",
"CSV",
"to",
"PyDbLite",
"csvfile",
":",
"name",
"of",
"the",
"CSV",
"file",
"in",
"the",
"file",
"system",
"out",
":",
"path",
"for",
"the",
"new",
"PyDbLite",
"base",
"in",
"the",
"file",
"system",
"fieldnames",
":",
"list",
"of",... | python | train |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/bulk.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/bulk.py#L334-L384 | def execute_no_results(self, sock_info, generator):
"""Execute all operations, returning no results (w=0).
"""
# Cannot have both unacknowledged write and bypass document validation.
if self.bypass_doc_val and sock_info.max_wire_version >= 4:
raise OperationFailure("Cannot se... | [
"def",
"execute_no_results",
"(",
"self",
",",
"sock_info",
",",
"generator",
")",
":",
"# Cannot have both unacknowledged write and bypass document validation.",
"if",
"self",
".",
"bypass_doc_val",
"and",
"sock_info",
".",
"max_wire_version",
">=",
"4",
":",
"raise",
... | Execute all operations, returning no results (w=0). | [
"Execute",
"all",
"operations",
"returning",
"no",
"results",
"(",
"w",
"=",
"0",
")",
"."
] | python | train |
briancappello/flask-unchained | flask_unchained/bundles/security/services/security_utils_service.py | https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/bundles/security/services/security_utils_service.py#L96-L111 | def use_double_hash(self, password_hash=None):
"""
Return a bool indicating whether a password should be hashed twice.
"""
single_hash = current_app.config.SECURITY_PASSWORD_SINGLE_HASH
if single_hash and self.security.password_salt:
raise RuntimeError('You may not sp... | [
"def",
"use_double_hash",
"(",
"self",
",",
"password_hash",
"=",
"None",
")",
":",
"single_hash",
"=",
"current_app",
".",
"config",
".",
"SECURITY_PASSWORD_SINGLE_HASH",
"if",
"single_hash",
"and",
"self",
".",
"security",
".",
"password_salt",
":",
"raise",
"... | Return a bool indicating whether a password should be hashed twice. | [
"Return",
"a",
"bool",
"indicating",
"whether",
"a",
"password",
"should",
"be",
"hashed",
"twice",
"."
] | python | train |
ktdreyer/txbugzilla | txbugzilla/__init__.py | https://github.com/ktdreyer/txbugzilla/blob/ccfc6667ce9d696b08b468b25c813cc2b68d30d6/txbugzilla/__init__.py#L149-L157 | def _parse_bugs_callback(self, value):
"""
Fires when we get bug information back from the XML-RPC server.
param value: dict of data from XML-RPC server. The "bugs" dict element
contains a list of bugs.
returns: ``list`` of ``AttrDict``
"""
return li... | [
"def",
"_parse_bugs_callback",
"(",
"self",
",",
"value",
")",
":",
"return",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"self",
".",
"_parse_bug",
"(",
"x",
")",
",",
"value",
"[",
"'bugs'",
"]",
")",
")"
] | Fires when we get bug information back from the XML-RPC server.
param value: dict of data from XML-RPC server. The "bugs" dict element
contains a list of bugs.
returns: ``list`` of ``AttrDict`` | [
"Fires",
"when",
"we",
"get",
"bug",
"information",
"back",
"from",
"the",
"XML",
"-",
"RPC",
"server",
"."
] | python | train |
pallets/werkzeug | src/werkzeug/http.py | https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/http.py#L897-L915 | def dump_age(age=None):
"""Formats the duration as a base-10 integer.
:param age: should be an integer number of seconds,
a :class:`datetime.timedelta` object, or,
if the age is unknown, `None` (default).
"""
if age is None:
return
if isinstance(age, timedelt... | [
"def",
"dump_age",
"(",
"age",
"=",
"None",
")",
":",
"if",
"age",
"is",
"None",
":",
"return",
"if",
"isinstance",
"(",
"age",
",",
"timedelta",
")",
":",
"# do the equivalent of Python 2.7's timedelta.total_seconds(),",
"# but disregarding fractional seconds",
"age"... | Formats the duration as a base-10 integer.
:param age: should be an integer number of seconds,
a :class:`datetime.timedelta` object, or,
if the age is unknown, `None` (default). | [
"Formats",
"the",
"duration",
"as",
"a",
"base",
"-",
"10",
"integer",
"."
] | python | train |
tanghaibao/goatools | goatools/godag/relationship_str.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/relationship_str.py#L74-L77 | def str_relationships_rev(self, goobj):
"""Get a string representing the presence of absence of relationships. Ex: pr.."""
rel_cur = goobj.relationship_rev
return "".join([self.rev2chr[r] if r in rel_cur else '.' for r in self.rels]) | [
"def",
"str_relationships_rev",
"(",
"self",
",",
"goobj",
")",
":",
"rel_cur",
"=",
"goobj",
".",
"relationship_rev",
"return",
"\"\"",
".",
"join",
"(",
"[",
"self",
".",
"rev2chr",
"[",
"r",
"]",
"if",
"r",
"in",
"rel_cur",
"else",
"'.'",
"for",
"r"... | Get a string representing the presence of absence of relationships. Ex: pr.. | [
"Get",
"a",
"string",
"representing",
"the",
"presence",
"of",
"absence",
"of",
"relationships",
".",
"Ex",
":",
"pr",
".."
] | python | train |
bitesofcode/projex | projex/addon.py | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/addon.py#L132-L141 | def registerAddonModule(cls, module):
"""
Registers a module to use to import addon subclasses from.
:param module | <str> || <module>
"""
prop = '_{0}__addon_modules'.format(cls.__name__)
mods = getattr(cls, prop, set())
mods.add(module)
set... | [
"def",
"registerAddonModule",
"(",
"cls",
",",
"module",
")",
":",
"prop",
"=",
"'_{0}__addon_modules'",
".",
"format",
"(",
"cls",
".",
"__name__",
")",
"mods",
"=",
"getattr",
"(",
"cls",
",",
"prop",
",",
"set",
"(",
")",
")",
"mods",
".",
"add",
... | Registers a module to use to import addon subclasses from.
:param module | <str> || <module> | [
"Registers",
"a",
"module",
"to",
"use",
"to",
"import",
"addon",
"subclasses",
"from",
".",
":",
"param",
"module",
"|",
"<str",
">",
"||",
"<module",
">"
] | python | train |
arista-eosplus/pyeapi | pyeapi/api/users.py | https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/api/users.py#L230-L252 | def set_privilege(self, name, value=None):
"""Configures the user privilege value in EOS
Args:
name (str): The name of the user to craete
value (int): The privilege value to assign to the user. Valid
values are in the range of 0 to 15
Returns:
... | [
"def",
"set_privilege",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"cmd",
"=",
"'username %s'",
"%",
"name",
"if",
"value",
"is",
"not",
"None",
":",
"if",
"not",
"isprivilege",
"(",
"value",
")",
":",
"raise",
"TypeError",
"(",
"... | Configures the user privilege value in EOS
Args:
name (str): The name of the user to craete
value (int): The privilege value to assign to the user. Valid
values are in the range of 0 to 15
Returns:
True if the operation was successful otherwise Fal... | [
"Configures",
"the",
"user",
"privilege",
"value",
"in",
"EOS"
] | python | train |
kennethreitz/omnijson | omnijson/packages/simplejson/__init__.py | https://github.com/kennethreitz/omnijson/blob/a5890a51a59ad76f78a61f5bf91fa86b784cf694/omnijson/packages/simplejson/__init__.py#L276-L329 | def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, object_pairs_hook=None,
use_decimal=False, **kw):
"""Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
a JSON document) to a Python object.
*encoding* determ... | [
"def",
"load",
"(",
"fp",
",",
"encoding",
"=",
"None",
",",
"cls",
"=",
"None",
",",
"object_hook",
"=",
"None",
",",
"parse_float",
"=",
"None",
",",
"parse_int",
"=",
"None",
",",
"parse_constant",
"=",
"None",
",",
"object_pairs_hook",
"=",
"None",
... | Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
a JSON document) to a Python object.
*encoding* determines the encoding used to interpret any
:class:`str` objects decoded by this instance (``'utf-8'`` by
default). It has no effect when decoding :class:`unicode` objects.
N... | [
"Deserialize",
"fp",
"(",
"a",
".",
"read",
"()",
"-",
"supporting",
"file",
"-",
"like",
"object",
"containing",
"a",
"JSON",
"document",
")",
"to",
"a",
"Python",
"object",
"."
] | python | train |
tensorflow/tensorboard | tensorboard/plugins/debugger/interactive_debugger_server_lib.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/debugger/interactive_debugger_server_lib.py#L48-L52 | def _extract_device_name_from_event(event):
"""Extract device name from a tf.Event proto carrying tensor value."""
plugin_data_content = json.loads(
tf.compat.as_str(event.summary.value[0].metadata.plugin_data.content))
return plugin_data_content['device'] | [
"def",
"_extract_device_name_from_event",
"(",
"event",
")",
":",
"plugin_data_content",
"=",
"json",
".",
"loads",
"(",
"tf",
".",
"compat",
".",
"as_str",
"(",
"event",
".",
"summary",
".",
"value",
"[",
"0",
"]",
".",
"metadata",
".",
"plugin_data",
"."... | Extract device name from a tf.Event proto carrying tensor value. | [
"Extract",
"device",
"name",
"from",
"a",
"tf",
".",
"Event",
"proto",
"carrying",
"tensor",
"value",
"."
] | python | train |
senaite/senaite.core | bika/lims/subscribers/auditlog.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/subscribers/auditlog.py#L27-L54 | def ObjectTransitionedEventHandler(obj, event):
"""Object has been transitioned to an new state
"""
# only snapshot supported objects
if not supports_snapshots(obj):
return
# default transition entry
entry = {
"modified": DateTime().ISO(),
"action": event.action,
}
... | [
"def",
"ObjectTransitionedEventHandler",
"(",
"obj",
",",
"event",
")",
":",
"# only snapshot supported objects",
"if",
"not",
"supports_snapshots",
"(",
"obj",
")",
":",
"return",
"# default transition entry",
"entry",
"=",
"{",
"\"modified\"",
":",
"DateTime",
"(",
... | Object has been transitioned to an new state | [
"Object",
"has",
"been",
"transitioned",
"to",
"an",
"new",
"state"
] | python | train |
huggingface/pytorch-pretrained-BERT | pytorch_pretrained_bert/tokenization.py | https://github.com/huggingface/pytorch-pretrained-BERT/blob/b832d5bb8a6dfc5965015b828e577677eace601e/pytorch_pretrained_bert/tokenization.py#L269-L280 | def _tokenize_chinese_chars(self, text):
"""Adds whitespace around any CJK character."""
output = []
for char in text:
cp = ord(char)
if self._is_chinese_char(cp):
output.append(" ")
output.append(char)
output.append(" ")
... | [
"def",
"_tokenize_chinese_chars",
"(",
"self",
",",
"text",
")",
":",
"output",
"=",
"[",
"]",
"for",
"char",
"in",
"text",
":",
"cp",
"=",
"ord",
"(",
"char",
")",
"if",
"self",
".",
"_is_chinese_char",
"(",
"cp",
")",
":",
"output",
".",
"append",
... | Adds whitespace around any CJK character. | [
"Adds",
"whitespace",
"around",
"any",
"CJK",
"character",
"."
] | python | train |
google/grr | grr/core/grr_response_core/lib/parsers/ie_history.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/ie_history.py#L93-L135 | def _GetRecord(self, offset, record_size):
"""Retrieve a single record from the file.
Args:
offset: offset from start of input_dat where header starts
record_size: length of the header according to file (untrusted)
Returns:
A dict containing a single browser history record.
"""
r... | [
"def",
"_GetRecord",
"(",
"self",
",",
"offset",
",",
"record_size",
")",
":",
"record_header",
"=",
"\"<4sLQQL\"",
"get4",
"=",
"lambda",
"x",
":",
"struct",
".",
"unpack",
"(",
"\"<L\"",
",",
"self",
".",
"input_dat",
"[",
"x",
":",
"x",
"+",
"4",
... | Retrieve a single record from the file.
Args:
offset: offset from start of input_dat where header starts
record_size: length of the header according to file (untrusted)
Returns:
A dict containing a single browser history record. | [
"Retrieve",
"a",
"single",
"record",
"from",
"the",
"file",
"."
] | python | train |
crocs-muni/roca | roca/detect.py | https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L170-L183 | def add_res(acc, elem):
"""
Adds results to the accumulator
:param acc:
:param elem:
:return:
"""
if not isinstance(elem, list):
elem = [elem]
if acc is None:
acc = []
for x in elem:
acc.append(x)
return acc | [
"def",
"add_res",
"(",
"acc",
",",
"elem",
")",
":",
"if",
"not",
"isinstance",
"(",
"elem",
",",
"list",
")",
":",
"elem",
"=",
"[",
"elem",
"]",
"if",
"acc",
"is",
"None",
":",
"acc",
"=",
"[",
"]",
"for",
"x",
"in",
"elem",
":",
"acc",
"."... | Adds results to the accumulator
:param acc:
:param elem:
:return: | [
"Adds",
"results",
"to",
"the",
"accumulator",
":",
"param",
"acc",
":",
":",
"param",
"elem",
":",
":",
"return",
":"
] | python | train |
PMEAL/OpenPNM | openpnm/algorithms/MixedInvasionPercolation.py | https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/algorithms/MixedInvasionPercolation.py#L64-L140 | def setup(self,
phase=None,
pore_entry_pressure='pore.entry_pressure',
throat_entry_pressure='throat.entry_pressure',
snap_off='',
invade_isolated_Ts=False,
late_pore_filling='',
late_throat_filling='',
coope... | [
"def",
"setup",
"(",
"self",
",",
"phase",
"=",
"None",
",",
"pore_entry_pressure",
"=",
"'pore.entry_pressure'",
",",
"throat_entry_pressure",
"=",
"'throat.entry_pressure'",
",",
"snap_off",
"=",
"''",
",",
"invade_isolated_Ts",
"=",
"False",
",",
"late_pore_filli... | r"""
Used to specify necessary arguments to the simulation. This method is
useful for resetting the algorithm or applying more explicit control.
Parameters
----------
phase : OpenPNM Phase object
The Phase object containing the physical properties of the invading
... | [
"r",
"Used",
"to",
"specify",
"necessary",
"arguments",
"to",
"the",
"simulation",
".",
"This",
"method",
"is",
"useful",
"for",
"resetting",
"the",
"algorithm",
"or",
"applying",
"more",
"explicit",
"control",
"."
] | python | train |
dmlc/xgboost | python-package/xgboost/core.py | https://github.com/dmlc/xgboost/blob/253fdd8a42d5ec6b819788199584d27bf9ea6253/python-package/xgboost/core.py#L498-L527 | def _init_from_dt(self, data, nthread):
"""
Initialize data from a datatable Frame.
"""
ptrs = (ctypes.c_void_p * data.ncols)()
if hasattr(data, "internal") and hasattr(data.internal, "column"):
# datatable>0.8.0
for icol in range(data.ncols):
... | [
"def",
"_init_from_dt",
"(",
"self",
",",
"data",
",",
"nthread",
")",
":",
"ptrs",
"=",
"(",
"ctypes",
".",
"c_void_p",
"*",
"data",
".",
"ncols",
")",
"(",
")",
"if",
"hasattr",
"(",
"data",
",",
"\"internal\"",
")",
"and",
"hasattr",
"(",
"data",
... | Initialize data from a datatable Frame. | [
"Initialize",
"data",
"from",
"a",
"datatable",
"Frame",
"."
] | python | train |
christian-oudard/htmltreediff | htmltreediff/diff_core.py | https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/diff_core.py#L224-L228 | def match_indices(match):
"""Yield index tuples (old_index, new_index) for each place in the match."""
a, b, size = match
for i in range(size):
yield a + i, b + i | [
"def",
"match_indices",
"(",
"match",
")",
":",
"a",
",",
"b",
",",
"size",
"=",
"match",
"for",
"i",
"in",
"range",
"(",
"size",
")",
":",
"yield",
"a",
"+",
"i",
",",
"b",
"+",
"i"
] | Yield index tuples (old_index, new_index) for each place in the match. | [
"Yield",
"index",
"tuples",
"(",
"old_index",
"new_index",
")",
"for",
"each",
"place",
"in",
"the",
"match",
"."
] | python | train |
pandas-dev/pandas | pandas/core/arrays/_ranges.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/_ranges.py#L149-L187 | def _generate_range_overflow_safe_signed(endpoint, periods, stride, side):
"""
A special case for _generate_range_overflow_safe where `periods * stride`
can be calculated without overflowing int64 bounds.
"""
assert side in ['start', 'end']
if side == 'end':
stride *= -1
with np.err... | [
"def",
"_generate_range_overflow_safe_signed",
"(",
"endpoint",
",",
"periods",
",",
"stride",
",",
"side",
")",
":",
"assert",
"side",
"in",
"[",
"'start'",
",",
"'end'",
"]",
"if",
"side",
"==",
"'end'",
":",
"stride",
"*=",
"-",
"1",
"with",
"np",
"."... | A special case for _generate_range_overflow_safe where `periods * stride`
can be calculated without overflowing int64 bounds. | [
"A",
"special",
"case",
"for",
"_generate_range_overflow_safe",
"where",
"periods",
"*",
"stride",
"can",
"be",
"calculated",
"without",
"overflowing",
"int64",
"bounds",
"."
] | python | train |
dhermes/bezier | src/bezier/_algebraic_intersection.py | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1304-L1358 | def poly_to_power_basis(bezier_coeffs):
"""Convert a B |eacute| zier curve to polynomial in power basis.
.. note::
This assumes, but does not verify, that the "B |eacute| zier
degree" matches the true degree of the curve. Callers can
guarantee this by calling :func:`.full_reduce`.
Ar... | [
"def",
"poly_to_power_basis",
"(",
"bezier_coeffs",
")",
":",
"num_coeffs",
",",
"=",
"bezier_coeffs",
".",
"shape",
"if",
"num_coeffs",
"==",
"1",
":",
"return",
"bezier_coeffs",
"elif",
"num_coeffs",
"==",
"2",
":",
"# C0 (1 - s) + C1 s = C0 + (C1 - C0) s",
"coeff... | Convert a B |eacute| zier curve to polynomial in power basis.
.. note::
This assumes, but does not verify, that the "B |eacute| zier
degree" matches the true degree of the curve. Callers can
guarantee this by calling :func:`.full_reduce`.
Args:
bezier_coeffs (numpy.ndarray): A 1D... | [
"Convert",
"a",
"B",
"|eacute|",
"zier",
"curve",
"to",
"polynomial",
"in",
"power",
"basis",
"."
] | python | train |
python-diamond/Diamond | src/diamond/handler/multigraphite.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/multigraphite.py#L36-L52 | def get_default_config_help(self):
"""
Returns the help text for the configuration options for this handler
"""
config = super(MultiGraphiteHandler, self).get_default_config_help()
config.update({
'host': 'Hostname, Hostname, Hostname',
'port': 'Port',
... | [
"def",
"get_default_config_help",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"MultiGraphiteHandler",
",",
"self",
")",
".",
"get_default_config_help",
"(",
")",
"config",
".",
"update",
"(",
"{",
"'host'",
":",
"'Hostname, Hostname, Hostname'",
",",
"'p... | Returns the help text for the configuration options for this handler | [
"Returns",
"the",
"help",
"text",
"for",
"the",
"configuration",
"options",
"for",
"this",
"handler"
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/rnc_text.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_text.py#L300-L310 | def get_bool_relative(strings: Sequence[str],
prefix1: str,
delta: int,
prefix2: str,
ignoreleadingcolon: bool = False) -> Optional[bool]:
"""
Fetches a boolean parameter via :func:`get_string_relative`.
"""
return g... | [
"def",
"get_bool_relative",
"(",
"strings",
":",
"Sequence",
"[",
"str",
"]",
",",
"prefix1",
":",
"str",
",",
"delta",
":",
"int",
",",
"prefix2",
":",
"str",
",",
"ignoreleadingcolon",
":",
"bool",
"=",
"False",
")",
"->",
"Optional",
"[",
"bool",
"]... | Fetches a boolean parameter via :func:`get_string_relative`. | [
"Fetches",
"a",
"boolean",
"parameter",
"via",
":",
"func",
":",
"get_string_relative",
"."
] | python | train |
pydanny/simplicity | simplicity.py | https://github.com/pydanny/simplicity/blob/aef4ce39b0965b8d333c67c9d6ec5baecee9c617/simplicity.py#L31-L92 | def rst_to_json(text):
""" I convert Restructured Text with field lists into Dictionaries!
TODO: Convert to text node approach.
"""
records = []
last_type = None
key = None
data = {}
directive = False
lines = text.splitlines()
for index, line in enumerate(lines):
#... | [
"def",
"rst_to_json",
"(",
"text",
")",
":",
"records",
"=",
"[",
"]",
"last_type",
"=",
"None",
"key",
"=",
"None",
"data",
"=",
"{",
"}",
"directive",
"=",
"False",
"lines",
"=",
"text",
".",
"splitlines",
"(",
")",
"for",
"index",
",",
"line",
"... | I convert Restructured Text with field lists into Dictionaries!
TODO: Convert to text node approach. | [
"I",
"convert",
"Restructured",
"Text",
"with",
"field",
"lists",
"into",
"Dictionaries!"
] | python | train |
mosesschwartz/scrypture | scrypture/scrypture.py | https://github.com/mosesschwartz/scrypture/blob/d51eb0c9835a5122a655078268185ce8ab9ec86a/scrypture/scrypture.py#L241-L254 | def order_by_header(table, headers):
'''Convert a list of dicts to a list or OrderedDicts ordered by headers'''
ordered_table = []
for row in table:
# Tricky list comprehension got tricky when needing special handling
# Lets do this the simplest way we can:
row = {k:v for k,v in row.... | [
"def",
"order_by_header",
"(",
"table",
",",
"headers",
")",
":",
"ordered_table",
"=",
"[",
"]",
"for",
"row",
"in",
"table",
":",
"# Tricky list comprehension got tricky when needing special handling",
"# Lets do this the simplest way we can:",
"row",
"=",
"{",
"k",
"... | Convert a list of dicts to a list or OrderedDicts ordered by headers | [
"Convert",
"a",
"list",
"of",
"dicts",
"to",
"a",
"list",
"or",
"OrderedDicts",
"ordered",
"by",
"headers"
] | python | train |
Alignak-monitoring/alignak | alignak/external_command.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L1806-L1824 | def del_host_comment(self, comment_id):
"""Delete a host comment
Format of the line that triggers function call::
DEL_HOST_COMMENT;<comment_id>
:param comment_id: comment id to delete
:type comment_id: int
:return: None
"""
for item in self.daemon.hosts:... | [
"def",
"del_host_comment",
"(",
"self",
",",
"comment_id",
")",
":",
"for",
"item",
"in",
"self",
".",
"daemon",
".",
"hosts",
":",
"if",
"comment_id",
"in",
"item",
".",
"comments",
":",
"item",
".",
"del_comment",
"(",
"comment_id",
")",
"self",
".",
... | Delete a host comment
Format of the line that triggers function call::
DEL_HOST_COMMENT;<comment_id>
:param comment_id: comment id to delete
:type comment_id: int
:return: None | [
"Delete",
"a",
"host",
"comment",
"Format",
"of",
"the",
"line",
"that",
"triggers",
"function",
"call",
"::"
] | python | train |
NaturalHistoryMuseum/pylibdmtx | pylibdmtx/wrapper.py | https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/wrapper.py#L46-L59 | def libdmtx_function(fname, restype, *args):
"""Returns a foreign function exported by `libdmtx`.
Args:
fname (:obj:`str`): Name of the exported function as string.
restype (:obj:): Return type - one of the `ctypes` primitive C data
types.
*args: Arguments - a sequence of `ctype... | [
"def",
"libdmtx_function",
"(",
"fname",
",",
"restype",
",",
"*",
"args",
")",
":",
"prototype",
"=",
"CFUNCTYPE",
"(",
"restype",
",",
"*",
"args",
")",
"return",
"prototype",
"(",
"(",
"fname",
",",
"load_libdmtx",
"(",
")",
")",
")"
] | Returns a foreign function exported by `libdmtx`.
Args:
fname (:obj:`str`): Name of the exported function as string.
restype (:obj:): Return type - one of the `ctypes` primitive C data
types.
*args: Arguments - a sequence of `ctypes` primitive C data types.
Returns:
cdd... | [
"Returns",
"a",
"foreign",
"function",
"exported",
"by",
"libdmtx",
"."
] | python | train |
gplepage/lsqfit | src/lsqfit/__init__.py | https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1658-L1665 | def _unpack_gvars(g):
""" Unpack collection of GVars to BufferDict or numpy array. """
if g is not None:
g = _gvar.gvar(g)
if not hasattr(g, 'flat'):
# must be a scalar (ie, not an array and not a dictionary)
g = numpy.asarray(g)
return g | [
"def",
"_unpack_gvars",
"(",
"g",
")",
":",
"if",
"g",
"is",
"not",
"None",
":",
"g",
"=",
"_gvar",
".",
"gvar",
"(",
"g",
")",
"if",
"not",
"hasattr",
"(",
"g",
",",
"'flat'",
")",
":",
"# must be a scalar (ie, not an array and not a dictionary)",
"g",
... | Unpack collection of GVars to BufferDict or numpy array. | [
"Unpack",
"collection",
"of",
"GVars",
"to",
"BufferDict",
"or",
"numpy",
"array",
"."
] | python | train |
briancappello/flask-unchained | flask_unchained/unchained.py | https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/unchained.py#L550-L578 | def template_global(self,
arg: Optional[Callable] = None,
*,
name: Optional[str] = None,
pass_context: bool = False,
inject: Optional[Union[bool, Iterable[str]]] = None,
safe: ... | [
"def",
"template_global",
"(",
"self",
",",
"arg",
":",
"Optional",
"[",
"Callable",
"]",
"=",
"None",
",",
"*",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"pass_context",
":",
"bool",
"=",
"False",
",",
"inject",
":",
"Optional... | Decorator to mark a function as a Jinja template global (tag).
:param name: The name of the tag, if different from the function name.
:param pass_context: Whether or not to pass the template context into the tag.
If ``True``, the first argument must be the context.
:param inject: Wh... | [
"Decorator",
"to",
"mark",
"a",
"function",
"as",
"a",
"Jinja",
"template",
"global",
"(",
"tag",
")",
"."
] | python | train |
GGiecold/Cluster_Ensembles | src/Cluster_Ensembles/Cluster_Ensembles.py | https://github.com/GGiecold/Cluster_Ensembles/blob/d1b1ce9f541fc937ac7c677e964520e0e9163dc7/src/Cluster_Ensembles/Cluster_Ensembles.py#L218-L237 | def load_hypergraph_adjacency(hdf5_file_name):
"""
Parameters
----------
hdf5_file_name : file handle or string
Returns
-------
hypergraph_adjacency : compressed sparse row matrix
"""
with tables.open_file(hdf5_file_name, 'r+') as fileh:
pars = []
for par i... | [
"def",
"load_hypergraph_adjacency",
"(",
"hdf5_file_name",
")",
":",
"with",
"tables",
".",
"open_file",
"(",
"hdf5_file_name",
",",
"'r+'",
")",
"as",
"fileh",
":",
"pars",
"=",
"[",
"]",
"for",
"par",
"in",
"(",
"'data'",
",",
"'indices'",
",",
"'indptr'... | Parameters
----------
hdf5_file_name : file handle or string
Returns
-------
hypergraph_adjacency : compressed sparse row matrix | [
"Parameters",
"----------",
"hdf5_file_name",
":",
"file",
"handle",
"or",
"string",
"Returns",
"-------",
"hypergraph_adjacency",
":",
"compressed",
"sparse",
"row",
"matrix"
] | python | train |
knipknap/exscript | Exscript/account.py | https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/account.py#L508-L518 | def get_account_from_name(self, name):
"""
Returns the account with the given name.
:type name: string
:param name: The name of the account.
"""
for account in self.accounts:
if account.get_name() == name:
return account
return None | [
"def",
"get_account_from_name",
"(",
"self",
",",
"name",
")",
":",
"for",
"account",
"in",
"self",
".",
"accounts",
":",
"if",
"account",
".",
"get_name",
"(",
")",
"==",
"name",
":",
"return",
"account",
"return",
"None"
] | Returns the account with the given name.
:type name: string
:param name: The name of the account. | [
"Returns",
"the",
"account",
"with",
"the",
"given",
"name",
"."
] | python | train |
mogproject/mog-commons-python | src/mog_commons/collection.py | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/collection.py#L14-L17 | def get_single_key(d):
"""Get a key from a dict which contains just one item."""
assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
return next(six.iterkeys(d)) | [
"def",
"get_single_key",
"(",
"d",
")",
":",
"assert",
"len",
"(",
"d",
")",
"==",
"1",
",",
"'Single-item dict must have just one item, not %d.'",
"%",
"len",
"(",
"d",
")",
"return",
"next",
"(",
"six",
".",
"iterkeys",
"(",
"d",
")",
")"
] | Get a key from a dict which contains just one item. | [
"Get",
"a",
"key",
"from",
"a",
"dict",
"which",
"contains",
"just",
"one",
"item",
"."
] | python | train |
evhub/coconut | coconut/compiler/compiler.py | https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/compiler.py#L1084-L1086 | def repl_proc(self, inputstring, log=True, **kwargs):
"""Process using replprocs."""
return self.apply_procs(self.replprocs, kwargs, inputstring, log=log) | [
"def",
"repl_proc",
"(",
"self",
",",
"inputstring",
",",
"log",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"apply_procs",
"(",
"self",
".",
"replprocs",
",",
"kwargs",
",",
"inputstring",
",",
"log",
"=",
"log",
")"
] | Process using replprocs. | [
"Process",
"using",
"replprocs",
"."
] | python | train |
cackharot/suds-py3 | suds/bindings/multiref.py | https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/bindings/multiref.py#L95-L109 | def build_catalog(self, body):
"""
Create the I{catalog} of multiref nodes by id and the list of
non-multiref nodes.
@param body: A soap envelope body node.
@type body: L{Element}
"""
for child in body.children:
if self.soaproot(child):
... | [
"def",
"build_catalog",
"(",
"self",
",",
"body",
")",
":",
"for",
"child",
"in",
"body",
".",
"children",
":",
"if",
"self",
".",
"soaproot",
"(",
"child",
")",
":",
"self",
".",
"nodes",
".",
"append",
"(",
"child",
")",
"id",
"=",
"child",
".",
... | Create the I{catalog} of multiref nodes by id and the list of
non-multiref nodes.
@param body: A soap envelope body node.
@type body: L{Element} | [
"Create",
"the",
"I",
"{",
"catalog",
"}",
"of",
"multiref",
"nodes",
"by",
"id",
"and",
"the",
"list",
"of",
"non",
"-",
"multiref",
"nodes",
"."
] | python | train |
lambdamusic/Ontospy | ontospy/core/ontospy.py | https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/ontospy.py#L953-L966 | def ontologyClassTree(self):
"""
Returns a dict representing the ontology tree
Top level = {0:[top classes]}
Multi inheritance is represented explicitly
"""
treedict = {}
if self.all_classes:
treedict[0] = self.toplayer_classes
for element ... | [
"def",
"ontologyClassTree",
"(",
"self",
")",
":",
"treedict",
"=",
"{",
"}",
"if",
"self",
".",
"all_classes",
":",
"treedict",
"[",
"0",
"]",
"=",
"self",
".",
"toplayer_classes",
"for",
"element",
"in",
"self",
".",
"all_classes",
":",
"if",
"element"... | Returns a dict representing the ontology tree
Top level = {0:[top classes]}
Multi inheritance is represented explicitly | [
"Returns",
"a",
"dict",
"representing",
"the",
"ontology",
"tree",
"Top",
"level",
"=",
"{",
"0",
":",
"[",
"top",
"classes",
"]",
"}",
"Multi",
"inheritance",
"is",
"represented",
"explicitly"
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/widgets/grid.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/grid.py#L165-L193 | def resize_widget(self, widget, row_span, col_span):
"""Resize a widget in the grid to new dimensions.
Parameters
----------
widget : Widget
The widget to resize
row_span : int
The number of rows to be occupied by this widget.
col_span : int
... | [
"def",
"resize_widget",
"(",
"self",
",",
"widget",
",",
"row_span",
",",
"col_span",
")",
":",
"row",
"=",
"None",
"col",
"=",
"None",
"for",
"(",
"r",
",",
"c",
",",
"rspan",
",",
"cspan",
",",
"w",
")",
"in",
"self",
".",
"_grid_widgets",
".",
... | Resize a widget in the grid to new dimensions.
Parameters
----------
widget : Widget
The widget to resize
row_span : int
The number of rows to be occupied by this widget.
col_span : int
The number of columns to be occupied by this widget. | [
"Resize",
"a",
"widget",
"in",
"the",
"grid",
"to",
"new",
"dimensions",
"."
] | python | train |
secdev/scapy | scapy/contrib/diameter.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/diameter.py#L4811-L4816 | def DiamReq(cmd, **fields):
"""Craft Diameter request commands"""
upfields, name = getCmdParams(cmd, True, **fields)
p = DiamG(**upfields)
p.name = name
return p | [
"def",
"DiamReq",
"(",
"cmd",
",",
"*",
"*",
"fields",
")",
":",
"upfields",
",",
"name",
"=",
"getCmdParams",
"(",
"cmd",
",",
"True",
",",
"*",
"*",
"fields",
")",
"p",
"=",
"DiamG",
"(",
"*",
"*",
"upfields",
")",
"p",
".",
"name",
"=",
"nam... | Craft Diameter request commands | [
"Craft",
"Diameter",
"request",
"commands"
] | python | train |
idlesign/django-sitegate | sitegate/flows_base.py | https://github.com/idlesign/django-sitegate/blob/0e58de91605071833d75a7c21f2d0de2f2e3c896/sitegate/flows_base.py#L57-L71 | def update_request(self, request, form):
"""Updates Request object with flows forms."""
forms_key = '%s_forms' % self.flow_type
# Use ordered forms dict in case _formNode wants to fetch the first defined.
flow_dict = OrderedDict()
try:
flow_dict = request.sitegate[fo... | [
"def",
"update_request",
"(",
"self",
",",
"request",
",",
"form",
")",
":",
"forms_key",
"=",
"'%s_forms'",
"%",
"self",
".",
"flow_type",
"# Use ordered forms dict in case _formNode wants to fetch the first defined.",
"flow_dict",
"=",
"OrderedDict",
"(",
")",
"try",
... | Updates Request object with flows forms. | [
"Updates",
"Request",
"object",
"with",
"flows",
"forms",
"."
] | python | train |
mattjj/pylds | pylds/laplace.py | https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L39-L51 | def grad_local_log_likelihood(self, x):
"""
return d/dxt log p(yt | xt) evaluated at xt
Optionally override this in base classes
"""
T, D = self.T, self.D_latent
assert x.shape == (T, D)
gfun = grad(self.local_log_likelihood)
g = np.zeros((T, D))
... | [
"def",
"grad_local_log_likelihood",
"(",
"self",
",",
"x",
")",
":",
"T",
",",
"D",
"=",
"self",
".",
"T",
",",
"self",
".",
"D_latent",
"assert",
"x",
".",
"shape",
"==",
"(",
"T",
",",
"D",
")",
"gfun",
"=",
"grad",
"(",
"self",
".",
"local_log... | return d/dxt log p(yt | xt) evaluated at xt
Optionally override this in base classes | [
"return",
"d",
"/",
"dxt",
"log",
"p",
"(",
"yt",
"|",
"xt",
")",
"evaluated",
"at",
"xt",
"Optionally",
"override",
"this",
"in",
"base",
"classes"
] | python | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_format.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_format.py#L710-L781 | def _MergeMessageField(self, tokenizer, message, field):
"""Merges a single scalar field into a message.
Args:
tokenizer: A tokenizer to parse the field value.
message: The message of which field is a member.
field: The descriptor of the field to be merged.
Raises:
ParseError: In c... | [
"def",
"_MergeMessageField",
"(",
"self",
",",
"tokenizer",
",",
"message",
",",
"field",
")",
":",
"is_map_entry",
"=",
"_IsMapEntry",
"(",
"field",
")",
"if",
"tokenizer",
".",
"TryConsume",
"(",
"'<'",
")",
":",
"end_token",
"=",
"'>'",
"else",
":",
"... | Merges a single scalar field into a message.
Args:
tokenizer: A tokenizer to parse the field value.
message: The message of which field is a member.
field: The descriptor of the field to be merged.
Raises:
ParseError: In case of text parsing problems. | [
"Merges",
"a",
"single",
"scalar",
"field",
"into",
"a",
"message",
"."
] | python | train |
chrlie/shorten | shorten/base.py | https://github.com/chrlie/shorten/blob/fb762a199979aefaa28c88fa035e88ea8ce4d639/shorten/base.py#L149-L161 | def next_formatted_pair(self):
"""\
Returns a :class:`FormattedPair <shorten.store.FormattedPair>` containing
attributes `key`, `token`, `formatted_key` and `formatted_token`.
Calling this method will always consume a key and token.
"""
key = self.key_gen.next()
token = self... | [
"def",
"next_formatted_pair",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"key_gen",
".",
"next",
"(",
")",
"token",
"=",
"self",
".",
"token_gen",
".",
"create_token",
"(",
"key",
")",
"fkey",
"=",
"self",
".",
"formatter",
".",
"format_key",
"(",... | \
Returns a :class:`FormattedPair <shorten.store.FormattedPair>` containing
attributes `key`, `token`, `formatted_key` and `formatted_token`.
Calling this method will always consume a key and token. | [
"\\",
"Returns",
"a",
":",
"class",
":",
"FormattedPair",
"<shorten",
".",
"store",
".",
"FormattedPair",
">",
"containing",
"attributes",
"key",
"token",
"formatted_key",
"and",
"formatted_token",
".",
"Calling",
"this",
"method",
"will",
"always",
"consume",
"... | python | train |
vtkiorg/vtki | vtki/utilities.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L44-L50 | def cell_scalar(mesh, name):
""" Returns cell scalars of a vtk object """
vtkarr = mesh.GetCellData().GetArray(name)
if vtkarr:
if isinstance(vtkarr, vtk.vtkBitArray):
vtkarr = vtk_bit_array_to_char(vtkarr)
return vtk_to_numpy(vtkarr) | [
"def",
"cell_scalar",
"(",
"mesh",
",",
"name",
")",
":",
"vtkarr",
"=",
"mesh",
".",
"GetCellData",
"(",
")",
".",
"GetArray",
"(",
"name",
")",
"if",
"vtkarr",
":",
"if",
"isinstance",
"(",
"vtkarr",
",",
"vtk",
".",
"vtkBitArray",
")",
":",
"vtkar... | Returns cell scalars of a vtk object | [
"Returns",
"cell",
"scalars",
"of",
"a",
"vtk",
"object"
] | python | train |
mitsei/dlkit | dlkit/records/assessment/qti/inline_choice_records.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/qti/inline_choice_records.py#L926-L967 | def _init_metadata(self):
"""stub"""
self._inline_regions_metadata = {
'element_id': Id(self.my_osid_object_form._authority,
self.my_osid_object_form._namespace,
'inline_regions'),
'element_label': 'set of inline regions',... | [
"def",
"_init_metadata",
"(",
"self",
")",
":",
"self",
".",
"_inline_regions_metadata",
"=",
"{",
"'element_id'",
":",
"Id",
"(",
"self",
".",
"my_osid_object_form",
".",
"_authority",
",",
"self",
".",
"my_osid_object_form",
".",
"_namespace",
",",
"'inline_re... | stub | [
"stub"
] | python | train |
DeepHorizons/iarm | iarm/arm_instructions/memory.py | https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L260-L279 | def LDRSB(self, params):
"""
LDRSB Ra, [Rb, Rc]
Load a byte from memory, sign extend, and put into Ra
Ra, Rb, and Rc must be low registers
"""
# TODO LDRSB cant use immediates
Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params)
... | [
"def",
"LDRSB",
"(",
"self",
",",
"params",
")",
":",
"# TODO LDRSB cant use immediates",
"Ra",
",",
"Rb",
",",
"Rc",
"=",
"self",
".",
"get_three_parameters",
"(",
"self",
".",
"THREE_PARAMETER_WITH_BRACKETS",
",",
"params",
")",
"self",
".",
"check_arguments",... | LDRSB Ra, [Rb, Rc]
Load a byte from memory, sign extend, and put into Ra
Ra, Rb, and Rc must be low registers | [
"LDRSB",
"Ra",
"[",
"Rb",
"Rc",
"]"
] | python | train |
kejbaly2/metrique | metrique/result.py | https://github.com/kejbaly2/metrique/blob/a10b076097441b7dde687949139f702f5c1e1b35/metrique/result.py#L395-L427 | def last_chain(self):
'''
Leaves only the last chain for each object.
Chain is a series of consecutive versions where
`_end` of one is `_start` of another.
'''
cols = self.columns.tolist()
i_oid = cols.index('_oid')
i_start = cols.index('_start')
... | [
"def",
"last_chain",
"(",
"self",
")",
":",
"cols",
"=",
"self",
".",
"columns",
".",
"tolist",
"(",
")",
"i_oid",
"=",
"cols",
".",
"index",
"(",
"'_oid'",
")",
"i_start",
"=",
"cols",
".",
"index",
"(",
"'_start'",
")",
"i_end",
"=",
"cols",
".",... | Leaves only the last chain for each object.
Chain is a series of consecutive versions where
`_end` of one is `_start` of another. | [
"Leaves",
"only",
"the",
"last",
"chain",
"for",
"each",
"object",
"."
] | python | train |
nesaro/pydsl | pydsl/extract.py | https://github.com/nesaro/pydsl/blob/00b4fffd72036b80335e1a44a888fac57917ab41/pydsl/extract.py#L44-L74 | def extract_alphabet(alphabet, inputdata, fixed_start = False):
"""
Receives a sequence and an alphabet,
returns a list of PositionTokens with all of the parts of the sequence that
are a subset of the alphabet
"""
if not inputdata:
return []
base_alphabet = alphabet.alphabet
l... | [
"def",
"extract_alphabet",
"(",
"alphabet",
",",
"inputdata",
",",
"fixed_start",
"=",
"False",
")",
":",
"if",
"not",
"inputdata",
":",
"return",
"[",
"]",
"base_alphabet",
"=",
"alphabet",
".",
"alphabet",
"lexer",
"=",
"lexer_factory",
"(",
"alphabet",
",... | Receives a sequence and an alphabet,
returns a list of PositionTokens with all of the parts of the sequence that
are a subset of the alphabet | [
"Receives",
"a",
"sequence",
"and",
"an",
"alphabet",
"returns",
"a",
"list",
"of",
"PositionTokens",
"with",
"all",
"of",
"the",
"parts",
"of",
"the",
"sequence",
"that",
"are",
"a",
"subset",
"of",
"the",
"alphabet"
] | python | train |
Miserlou/Zappa | zappa/cli.py | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1068-L1100 | def tail(self, since, filter_pattern, limit=10000, keep_open=True, colorize=True, http=False, non_http=False, force_colorize=False):
"""
Tail this function's logs.
if keep_open, do so repeatedly, printing any new logs
"""
try:
since_stamp = string_to_timestamp(since... | [
"def",
"tail",
"(",
"self",
",",
"since",
",",
"filter_pattern",
",",
"limit",
"=",
"10000",
",",
"keep_open",
"=",
"True",
",",
"colorize",
"=",
"True",
",",
"http",
"=",
"False",
",",
"non_http",
"=",
"False",
",",
"force_colorize",
"=",
"False",
")"... | Tail this function's logs.
if keep_open, do so repeatedly, printing any new logs | [
"Tail",
"this",
"function",
"s",
"logs",
"."
] | python | train |
saltstack/salt | salt/sdb/cache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/sdb/cache.py#L66-L73 | def set_(key, value, service=None, profile=None): # pylint: disable=W0613
'''
Set a key/value pair in the cache service
'''
key, profile = _parse_key(key, profile)
cache = salt.cache.Cache(__opts__)
cache.store(profile['bank'], key, value)
return get(key, service, profile) | [
"def",
"set_",
"(",
"key",
",",
"value",
",",
"service",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"# pylint: disable=W0613",
"key",
",",
"profile",
"=",
"_parse_key",
"(",
"key",
",",
"profile",
")",
"cache",
"=",
"salt",
".",
"cache",
".",
... | Set a key/value pair in the cache service | [
"Set",
"a",
"key",
"/",
"value",
"pair",
"in",
"the",
"cache",
"service"
] | python | train |
sprockets/sprockets.mixins.amqp | sprockets/mixins/amqp/__init__.py | https://github.com/sprockets/sprockets.mixins.amqp/blob/de22b85aec1315bc01e47774637098c34525692b/sprockets/mixins/amqp/__init__.py#L390-L401 | def close(self):
"""Cleanly shutdown the connection to RabbitMQ
:raises: sprockets.mixins.amqp.ConnectionStateError
"""
if not self.closable:
LOGGER.warning('Closed called while %s', self.state_description)
raise ConnectionStateError(self.state_description)
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"closable",
":",
"LOGGER",
".",
"warning",
"(",
"'Closed called while %s'",
",",
"self",
".",
"state_description",
")",
"raise",
"ConnectionStateError",
"(",
"self",
".",
"state_description",
")"... | Cleanly shutdown the connection to RabbitMQ
:raises: sprockets.mixins.amqp.ConnectionStateError | [
"Cleanly",
"shutdown",
"the",
"connection",
"to",
"RabbitMQ"
] | python | train |
dw/mitogen | ansible_mitogen/runner.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/ansible_mitogen/runner.py#L231-L241 | def reopen_readonly(fp):
"""
Replace the file descriptor belonging to the file object `fp` with one
open on the same file (`fp.name`), but opened with :py:data:`os.O_RDONLY`.
This enables temporary files to be executed on Linux, which usually throws
``ETXTBUSY`` if any writeable handle exists pointi... | [
"def",
"reopen_readonly",
"(",
"fp",
")",
":",
"fd",
"=",
"os",
".",
"open",
"(",
"fp",
".",
"name",
",",
"os",
".",
"O_RDONLY",
")",
"os",
".",
"dup2",
"(",
"fd",
",",
"fp",
".",
"fileno",
"(",
")",
")",
"os",
".",
"close",
"(",
"fd",
")"
] | Replace the file descriptor belonging to the file object `fp` with one
open on the same file (`fp.name`), but opened with :py:data:`os.O_RDONLY`.
This enables temporary files to be executed on Linux, which usually throws
``ETXTBUSY`` if any writeable handle exists pointing to a file passed to
`execve()`... | [
"Replace",
"the",
"file",
"descriptor",
"belonging",
"to",
"the",
"file",
"object",
"fp",
"with",
"one",
"open",
"on",
"the",
"same",
"file",
"(",
"fp",
".",
"name",
")",
"but",
"opened",
"with",
":",
"py",
":",
"data",
":",
"os",
".",
"O_RDONLY",
".... | python | train |
buildbot/buildbot | master/buildbot/process/users/users.py | https://github.com/buildbot/buildbot/blob/5df3cfae6d760557d99156633c32b1822a1e130c/master/buildbot/process/users/users.py#L155-L169 | def encrypt(passwd):
"""
Encrypts the incoming password after adding some salt to store
it in the database.
@param passwd: password portion of user credentials
@type passwd: string
@returns: encrypted/salted string
"""
m = sha1()
salt = hexlify(os.urandom(salt_len))
m.update(un... | [
"def",
"encrypt",
"(",
"passwd",
")",
":",
"m",
"=",
"sha1",
"(",
")",
"salt",
"=",
"hexlify",
"(",
"os",
".",
"urandom",
"(",
"salt_len",
")",
")",
"m",
".",
"update",
"(",
"unicode2bytes",
"(",
"passwd",
")",
"+",
"salt",
")",
"crypted",
"=",
"... | Encrypts the incoming password after adding some salt to store
it in the database.
@param passwd: password portion of user credentials
@type passwd: string
@returns: encrypted/salted string | [
"Encrypts",
"the",
"incoming",
"password",
"after",
"adding",
"some",
"salt",
"to",
"store",
"it",
"in",
"the",
"database",
"."
] | python | train |
odlgroup/odl | odl/phantom/misc_phantoms.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/phantom/misc_phantoms.py#L19-L45 | def submarine(space, smooth=True, taper=20.0):
"""Return a 'submarine' phantom consisting in an ellipsoid and a box.
Parameters
----------
space : `DiscreteLp`
Discretized space in which the phantom is supposed to be created.
smooth : bool, optional
If ``True``, the boundaries are s... | [
"def",
"submarine",
"(",
"space",
",",
"smooth",
"=",
"True",
",",
"taper",
"=",
"20.0",
")",
":",
"if",
"space",
".",
"ndim",
"==",
"2",
":",
"if",
"smooth",
":",
"return",
"_submarine_2d_smooth",
"(",
"space",
",",
"taper",
")",
"else",
":",
"retur... | Return a 'submarine' phantom consisting in an ellipsoid and a box.
Parameters
----------
space : `DiscreteLp`
Discretized space in which the phantom is supposed to be created.
smooth : bool, optional
If ``True``, the boundaries are smoothed out. Otherwise, the
function steps fro... | [
"Return",
"a",
"submarine",
"phantom",
"consisting",
"in",
"an",
"ellipsoid",
"and",
"a",
"box",
"."
] | python | train |
saltstack/salt | salt/modules/keystone.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/keystone.py#L751-L781 | def project_get(project_id=None, name=None, profile=None, **connection_args):
'''
Return a specific projects (keystone project-get)
Overrides keystone tenant-get form api V2.
For keystone api V3 only.
.. versionadded:: 2016.11.0
project_id
The project id.
name
The project ... | [
"def",
"project_get",
"(",
"project_id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"*",
"*",
"connection_args",
")",
":",
"auth",
"(",
"profile",
",",
"*",
"*",
"connection_args",
")",
"if",
"_OS_IDENTITY_API_VERSION",
">",
... | Return a specific projects (keystone project-get)
Overrides keystone tenant-get form api V2.
For keystone api V3 only.
.. versionadded:: 2016.11.0
project_id
The project id.
name
The project name.
profile
Configuration profile - if configuration for multiple openstack... | [
"Return",
"a",
"specific",
"projects",
"(",
"keystone",
"project",
"-",
"get",
")",
"Overrides",
"keystone",
"tenant",
"-",
"get",
"form",
"api",
"V2",
".",
"For",
"keystone",
"api",
"V3",
"only",
"."
] | python | train |
mattja/nsim | nsim/analyses1/freq.py | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L213-L241 | def cwt(ts, freqs=np.logspace(0, 2), wavelet=cwtmorlet, plot=True):
"""Continuous wavelet transform
Note the full results can use a huge amount of memory at 64-bit precision
Args:
ts: Timeseries of m variables, shape (n, m). Assumed constant timestep.
freqs: list of frequencies (in Hz) to use f... | [
"def",
"cwt",
"(",
"ts",
",",
"freqs",
"=",
"np",
".",
"logspace",
"(",
"0",
",",
"2",
")",
",",
"wavelet",
"=",
"cwtmorlet",
",",
"plot",
"=",
"True",
")",
":",
"orig_ndim",
"=",
"ts",
".",
"ndim",
"if",
"ts",
".",
"ndim",
"is",
"1",
":",
"t... | Continuous wavelet transform
Note the full results can use a huge amount of memory at 64-bit precision
Args:
ts: Timeseries of m variables, shape (n, m). Assumed constant timestep.
freqs: list of frequencies (in Hz) to use for the tranform.
(default is 50 frequency bins logarithmic from 1H... | [
"Continuous",
"wavelet",
"transform",
"Note",
"the",
"full",
"results",
"can",
"use",
"a",
"huge",
"amount",
"of",
"memory",
"at",
"64",
"-",
"bit",
"precision"
] | python | train |
basecrm/basecrm-python | basecrm/services.py | https://github.com/basecrm/basecrm-python/blob/7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6/basecrm/services.py#L777-L790 | def list(self, **params):
"""
Retrieve all sources
Returns all lead sources available to the user according to the parameters provided
:calls: ``get /lead_sources``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style... | [
"def",
"list",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"_",
",",
"_",
",",
"lead_sources",
"=",
"self",
".",
"http_client",
".",
"get",
"(",
"\"/lead_sources\"",
",",
"params",
"=",
"params",
")",
"return",
"lead_sources"
] | Retrieve all sources
Returns all lead sources available to the user according to the parameters provided
:calls: ``get /lead_sources``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of LeadSou... | [
"Retrieve",
"all",
"sources"
] | python | train |
polyaxon/polyaxon | polyaxon/libs/statics.py | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/libs/statics.py#L4-L17 | def get_asset_url(module: str, path: str) -> str:
"""Return a static asset URL (located within Polyaxon's static files).
Example:
```python
>>> get_asset_url('polyaxon', 'dist/global.css')
... "/_static/74d127b78dc7daf2c51f/polyaxon/dist/global.css"
```
"""
return '{}/{}... | [
"def",
"get_asset_url",
"(",
"module",
":",
"str",
",",
"path",
":",
"str",
")",
"->",
"str",
":",
"return",
"'{}/{}/{}'",
".",
"format",
"(",
"settings",
".",
"STATIC_URL",
".",
"rstrip",
"(",
"'/'",
")",
",",
"module",
",",
"path",
".",
"lstrip",
"... | Return a static asset URL (located within Polyaxon's static files).
Example:
```python
>>> get_asset_url('polyaxon', 'dist/global.css')
... "/_static/74d127b78dc7daf2c51f/polyaxon/dist/global.css"
``` | [
"Return",
"a",
"static",
"asset",
"URL",
"(",
"located",
"within",
"Polyaxon",
"s",
"static",
"files",
")",
"."
] | python | train |
frawau/aiolifx | aiolifx/aiolifx.py | https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L796-L831 | def set_power(self, value,callb=None,duration=0,rapid=False):
"""Convenience method to set the power status of the device
This method will send a SetPower message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
... | [
"def",
"set_power",
"(",
"self",
",",
"value",
",",
"callb",
"=",
"None",
",",
"duration",
"=",
"0",
",",
"rapid",
"=",
"False",
")",
":",
"on",
"=",
"[",
"True",
",",
"1",
",",
"\"on\"",
"]",
"off",
"=",
"[",
"False",
",",
"0",
",",
"\"off\"",... | Convenience method to set the power status of the device
This method will send a SetPower message to the device, and request callb be executed
when an ACK is received. The default callback will simply cache the value.
:param value: The new state
:type value: str/bool/int
... | [
"Convenience",
"method",
"to",
"set",
"the",
"power",
"status",
"of",
"the",
"device"
] | python | train |
tensorflow/probability | tensorflow_probability/python/distributions/linear_gaussian_ssm.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L44-L69 | def _check_equal_shape(name,
static_shape,
dynamic_shape,
static_target_shape,
dynamic_target_shape=None):
"""Check that source and target shape match, statically if possible."""
static_target_shape = tf.TensorShape(static_... | [
"def",
"_check_equal_shape",
"(",
"name",
",",
"static_shape",
",",
"dynamic_shape",
",",
"static_target_shape",
",",
"dynamic_target_shape",
"=",
"None",
")",
":",
"static_target_shape",
"=",
"tf",
".",
"TensorShape",
"(",
"static_target_shape",
")",
"if",
"tensors... | Check that source and target shape match, statically if possible. | [
"Check",
"that",
"source",
"and",
"target",
"shape",
"match",
"statically",
"if",
"possible",
"."
] | python | test |
OzymandiasTheGreat/python-libinput | libinput/device.py | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/device.py#L1892-L1908 | def has_button(self, button):
"""Check if this device has a given button.
Args:
button (int): Button to check for, see ``input.h`` for button
definitions.
Returns:
bool: :obj:`True` if the device has this button, :obj:`False` if
it does not.
Raises:
AssertionError
"""
rc = self._libinput.l... | [
"def",
"has_button",
"(",
"self",
",",
"button",
")",
":",
"rc",
"=",
"self",
".",
"_libinput",
".",
"libinput_device_pointer_has_button",
"(",
"self",
".",
"_handle",
",",
"button",
")",
"assert",
"rc",
">=",
"0",
",",
"'This device is not a pointer device'",
... | Check if this device has a given button.
Args:
button (int): Button to check for, see ``input.h`` for button
definitions.
Returns:
bool: :obj:`True` if the device has this button, :obj:`False` if
it does not.
Raises:
AssertionError | [
"Check",
"if",
"this",
"device",
"has",
"a",
"given",
"button",
"."
] | python | train |
ctuning/ck | ck/kernel.py | https://github.com/ctuning/ck/blob/7e009814e975f8742790d3106340088a46223714/ck/kernel.py#L4958-L5001 | def browser(i):
"""
Input: {
(template) - use this web template
(repo_uoa) -
(module_uoa) -
(data_uoa) - view a given entry
(extra_url) - extra URL
}
Output: {
return - return code = 0, if succes... | [
"def",
"browser",
"(",
"i",
")",
":",
"# Check if ck-web is installed",
"r",
"=",
"find",
"(",
"{",
"'module_uoa'",
":",
"'module'",
",",
"'data_uoa'",
":",
"'wfe'",
"}",
")",
"if",
"r",
"[",
"'return'",
"]",
">",
"0",
":",
"if",
"r",
"[",
"'return'",
... | Input: {
(template) - use this web template
(repo_uoa) -
(module_uoa) -
(data_uoa) - view a given entry
(extra_url) - extra URL
}
Output: {
return - return code = 0, if successful
... | [
"Input",
":",
"{",
"(",
"template",
")",
"-",
"use",
"this",
"web",
"template",
"(",
"repo_uoa",
")",
"-",
"(",
"module_uoa",
")",
"-",
"(",
"data_uoa",
")",
"-",
"view",
"a",
"given",
"entry",
"(",
"extra_url",
")",
"-",
"extra",
"URL",
"}"
] | python | train |
ecometrica/grandfatherson | grandfatherson/__init__.py | https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/__init__.py#L178-L192 | def to_delete(datetimes,
years=0, months=0, weeks=0, days=0,
hours=0, minutes=0, seconds=0,
firstweekday=SATURDAY, now=None):
"""
Return a set of datetimes that should be deleted, out of ``datetimes``.
See ``to_keep`` for a description of arguments.
"""
dat... | [
"def",
"to_delete",
"(",
"datetimes",
",",
"years",
"=",
"0",
",",
"months",
"=",
"0",
",",
"weeks",
"=",
"0",
",",
"days",
"=",
"0",
",",
"hours",
"=",
"0",
",",
"minutes",
"=",
"0",
",",
"seconds",
"=",
"0",
",",
"firstweekday",
"=",
"SATURDAY"... | Return a set of datetimes that should be deleted, out of ``datetimes``.
See ``to_keep`` for a description of arguments. | [
"Return",
"a",
"set",
"of",
"datetimes",
"that",
"should",
"be",
"deleted",
"out",
"of",
"datetimes",
"."
] | python | test |
O365/python-o365 | O365/mailbox.py | https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/mailbox.py#L304-L332 | def refresh_folder(self, update_parent_if_changed=False):
""" Re-download folder data
Inbox Folder will be unable to download its own data (no folder_id)
:param bool update_parent_if_changed: updates self.parent with new
parent Folder if changed
:return: Refreshed or Not
... | [
"def",
"refresh_folder",
"(",
"self",
",",
"update_parent_if_changed",
"=",
"False",
")",
":",
"folder_id",
"=",
"getattr",
"(",
"self",
",",
"'folder_id'",
",",
"None",
")",
"if",
"self",
".",
"root",
"or",
"folder_id",
"is",
"None",
":",
"return",
"False... | Re-download folder data
Inbox Folder will be unable to download its own data (no folder_id)
:param bool update_parent_if_changed: updates self.parent with new
parent Folder if changed
:return: Refreshed or Not
:rtype: bool | [
"Re",
"-",
"download",
"folder",
"data",
"Inbox",
"Folder",
"will",
"be",
"unable",
"to",
"download",
"its",
"own",
"data",
"(",
"no",
"folder_id",
")"
] | python | train |
storax/upme | src/upme/main.py | https://github.com/storax/upme/blob/41c2d91f922691e31ff940f33b755d2cb64dfef8/src/upme/main.py#L84-L92 | def restart():
"""Restart the application the same way it was started
:returns: None
:rtype: None
:raises: SystemExit
"""
python = sys.executable
os.execl(python, python, * sys.argv) | [
"def",
"restart",
"(",
")",
":",
"python",
"=",
"sys",
".",
"executable",
"os",
".",
"execl",
"(",
"python",
",",
"python",
",",
"*",
"sys",
".",
"argv",
")"
] | Restart the application the same way it was started
:returns: None
:rtype: None
:raises: SystemExit | [
"Restart",
"the",
"application",
"the",
"same",
"way",
"it",
"was",
"started"
] | python | train |
jupyterhub/kubespawner | kubespawner/objects.py | https://github.com/jupyterhub/kubespawner/blob/46a4b109c5e657a4c3d5bfa8ea4731ec6564ea13/kubespawner/objects.py#L393-L433 | def make_pvc(
name,
storage_class,
access_modes,
storage,
labels=None,
annotations=None,
):
"""
Make a k8s pvc specification for running a user notebook.
Parameters
----------
name:
Name of persistent volume claim. Must be unique within the namespace the object is
... | [
"def",
"make_pvc",
"(",
"name",
",",
"storage_class",
",",
"access_modes",
",",
"storage",
",",
"labels",
"=",
"None",
",",
"annotations",
"=",
"None",
",",
")",
":",
"pvc",
"=",
"V1PersistentVolumeClaim",
"(",
")",
"pvc",
".",
"kind",
"=",
"\"PersistentVo... | Make a k8s pvc specification for running a user notebook.
Parameters
----------
name:
Name of persistent volume claim. Must be unique within the namespace the object is
going to be created in. Must be a valid DNS label.
storage_class:
String of the name of the k8s Storage Class ... | [
"Make",
"a",
"k8s",
"pvc",
"specification",
"for",
"running",
"a",
"user",
"notebook",
"."
] | python | train |
scottgigante/tasklogger | tasklogger/logger.py | https://github.com/scottgigante/tasklogger/blob/06a263715d2db0653615c17b2df14b8272967b8d/tasklogger/logger.py#L64-L96 | def set_level(self, level=1):
"""Set the logging level
Parameters
----------
level : `int` or `bool` (optional, default: 1)
If False or 0, prints WARNING and higher messages.
If True or 1, prints INFO and higher messages.
If 2 or higher, prints all me... | [
"def",
"set_level",
"(",
"self",
",",
"level",
"=",
"1",
")",
":",
"if",
"level",
"is",
"True",
"or",
"level",
"==",
"1",
":",
"level",
"=",
"logging",
".",
"INFO",
"level_name",
"=",
"\"INFO\"",
"elif",
"level",
"is",
"False",
"or",
"level",
"<=",
... | Set the logging level
Parameters
----------
level : `int` or `bool` (optional, default: 1)
If False or 0, prints WARNING and higher messages.
If True or 1, prints INFO and higher messages.
If 2 or higher, prints all messages. | [
"Set",
"the",
"logging",
"level"
] | python | train |
acrazing/dbapi | dbapi/Group.py | https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L275-L285 | def list_liked_topics(self, user_alias=None, start=0):
"""
喜欢过的话题
:param user_alias: 指定用户,默认当前
:param start: 翻页
:return: 带下一页的列表
"""
user_alias = user_alias or self.api.user_alias
xml = self.api.xml(API_GROUP_LIST_USER_LIKED_TOPICS % user_alias, p... | [
"def",
"list_liked_topics",
"(",
"self",
",",
"user_alias",
"=",
"None",
",",
"start",
"=",
"0",
")",
":",
"user_alias",
"=",
"user_alias",
"or",
"self",
".",
"api",
".",
"user_alias",
"xml",
"=",
"self",
".",
"api",
".",
"xml",
"(",
"API_GROUP_LIST_USER... | 喜欢过的话题
:param user_alias: 指定用户,默认当前
:param start: 翻页
:return: 带下一页的列表 | [
"喜欢过的话题",
":",
"param",
"user_alias",
":",
"指定用户,默认当前",
":",
"param",
"start",
":",
"翻页",
":",
"return",
":",
"带下一页的列表"
] | python | train |
EconForge/dolo | dolo/compiler/function_compiler_sympy.py | https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/compiler/function_compiler_sympy.py#L63-L190 | def compile_higher_order_function(eqs, syms, params, order=2, funname='anonymous',
return_code=False, compile=False):
'''From a list of equations and variables, define a multivariate functions with higher order derivatives.'''
from dolang.symbolic import stringify, stringify_symbol
vars = [s[0] for s ... | [
"def",
"compile_higher_order_function",
"(",
"eqs",
",",
"syms",
",",
"params",
",",
"order",
"=",
"2",
",",
"funname",
"=",
"'anonymous'",
",",
"return_code",
"=",
"False",
",",
"compile",
"=",
"False",
")",
":",
"from",
"dolang",
".",
"symbolic",
"import... | From a list of equations and variables, define a multivariate functions with higher order derivatives. | [
"From",
"a",
"list",
"of",
"equations",
"and",
"variables",
"define",
"a",
"multivariate",
"functions",
"with",
"higher",
"order",
"derivatives",
"."
] | python | train |
johnbywater/eventsourcing | eventsourcing/contrib/suffixtrees/domain/model/suffixtree.py | https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/suffixtrees/domain/model/suffixtree.py#L334-L346 | def register_new_edge(edge_id, first_char_index, last_char_index, source_node_id, dest_node_id):
"""Factory method, registers new edge.
"""
event = Edge.Created(
originator_id=edge_id,
first_char_index=first_char_index,
last_char_index=last_char_index,
source_node_id=source_n... | [
"def",
"register_new_edge",
"(",
"edge_id",
",",
"first_char_index",
",",
"last_char_index",
",",
"source_node_id",
",",
"dest_node_id",
")",
":",
"event",
"=",
"Edge",
".",
"Created",
"(",
"originator_id",
"=",
"edge_id",
",",
"first_char_index",
"=",
"first_char... | Factory method, registers new edge. | [
"Factory",
"method",
"registers",
"new",
"edge",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.