repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
karimbahgat/PyCRS | pycrs/parse.py | https://github.com/karimbahgat/PyCRS/blob/d6a8bb9c28787a25b4a1d59a7e4603db3221eaef/pycrs/parse.py#L24-L41 | def from_epsg_code(code):
"""
Load crs object from epsg code, via spatialreference.org.
Parses based on the proj4 representation.
Arguments:
- *code*: The EPSG code as an integer.
Returns:
- A CS instance of the indicated type.
"""
# must go online (or look up local table) to ge... | [
"def",
"from_epsg_code",
"(",
"code",
")",
":",
"# must go online (or look up local table) to get crs details",
"code",
"=",
"str",
"(",
"code",
")",
"proj4",
"=",
"utils",
".",
"crscode_to_string",
"(",
"\"epsg\"",
",",
"code",
",",
"\"proj4\"",
")",
"crs",
"=",
... | Load crs object from epsg code, via spatialreference.org.
Parses based on the proj4 representation.
Arguments:
- *code*: The EPSG code as an integer.
Returns:
- A CS instance of the indicated type. | [
"Load",
"crs",
"object",
"from",
"epsg",
"code",
"via",
"spatialreference",
".",
"org",
".",
"Parses",
"based",
"on",
"the",
"proj4",
"representation",
"."
] | python | test | 24.388889 |
zetaops/zengine | zengine/models/workflow_manager.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L111-L127 | def get_name(self):
"""
Tries to get WF name from 'process' or 'collobration' or 'pariticipant'
Returns:
str. WF name.
"""
paths = ['bpmn:process',
'bpmn:collaboration/bpmn:participant/',
'bpmn:collaboration',
]
... | [
"def",
"get_name",
"(",
"self",
")",
":",
"paths",
"=",
"[",
"'bpmn:process'",
",",
"'bpmn:collaboration/bpmn:participant/'",
",",
"'bpmn:collaboration'",
",",
"]",
"for",
"path",
"in",
"paths",
":",
"tag",
"=",
"self",
".",
"root",
".",
"find",
"(",
"path",... | Tries to get WF name from 'process' or 'collobration' or 'pariticipant'
Returns:
str. WF name. | [
"Tries",
"to",
"get",
"WF",
"name",
"from",
"process",
"or",
"collobration",
"or",
"pariticipant"
] | python | train | 30 |
knipknap/exscript | Exscript/util/mail.py | https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/util/mail.py#L462-L488 | def send(mail, server='localhost'):
"""
Sends the given mail.
:type mail: Mail
:param mail: The mail object.
:type server: string
:param server: The address of the mailserver.
"""
sender = mail.get_sender()
rcpt = mail.get_receipients()
session = smtplib.SMTP(server)
messa... | [
"def",
"send",
"(",
"mail",
",",
"server",
"=",
"'localhost'",
")",
":",
"sender",
"=",
"mail",
".",
"get_sender",
"(",
")",
"rcpt",
"=",
"mail",
".",
"get_receipients",
"(",
")",
"session",
"=",
"smtplib",
".",
"SMTP",
"(",
"server",
")",
"message",
... | Sends the given mail.
:type mail: Mail
:param mail: The mail object.
:type server: string
:param server: The address of the mailserver. | [
"Sends",
"the",
"given",
"mail",
"."
] | python | train | 31.555556 |
scarface-4711/denonavr | denonavr/denonavr.py | https://github.com/scarface-4711/denonavr/blob/59a136e27b43cb1d1e140cf67705087b3aa377cd/denonavr/denonavr.py#L1533-L1549 | def _play(self):
"""Send play command to receiver command via HTTP post."""
# Use pause command only for sources which support NETAUDIO
if self._input_func in self._netaudio_func_list:
body = {"cmd0": "PutNetAudioCommand/CurEnter",
"cmd1": "aspMainZone_WebUpdateSt... | [
"def",
"_play",
"(",
"self",
")",
":",
"# Use pause command only for sources which support NETAUDIO",
"if",
"self",
".",
"_input_func",
"in",
"self",
".",
"_netaudio_func_list",
":",
"body",
"=",
"{",
"\"cmd0\"",
":",
"\"PutNetAudioCommand/CurEnter\"",
",",
"\"cmd1\"",
... | Send play command to receiver command via HTTP post. | [
"Send",
"play",
"command",
"to",
"receiver",
"command",
"via",
"HTTP",
"post",
"."
] | python | train | 45.647059 |
bigchaindb/bigchaindb | bigchaindb/lib.py | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L352-L366 | def get_block_containing_tx(self, txid):
"""Retrieve the list of blocks (block ids) containing a
transaction with transaction id `txid`
Args:
txid (str): transaction id of the transaction to query
Returns:
Block id list (list(int))
"""
blocks ... | [
"def",
"get_block_containing_tx",
"(",
"self",
",",
"txid",
")",
":",
"blocks",
"=",
"list",
"(",
"backend",
".",
"query",
".",
"get_block_with_transaction",
"(",
"self",
".",
"connection",
",",
"txid",
")",
")",
"if",
"len",
"(",
"blocks",
")",
">",
"1"... | Retrieve the list of blocks (block ids) containing a
transaction with transaction id `txid`
Args:
txid (str): transaction id of the transaction to query
Returns:
Block id list (list(int)) | [
"Retrieve",
"the",
"list",
"of",
"blocks",
"(",
"block",
"ids",
")",
"containing",
"a",
"transaction",
"with",
"transaction",
"id",
"txid"
] | python | train | 36 |
chriso/gauged | gauged/structures/sparse_map.py | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/structures/sparse_map.py#L73-L77 | def append(self, position, array):
"""Append an array to the end of the map. The position
must be greater than any positions in the map"""
if not Gauged.map_append(self.ptr, position, array.ptr):
raise MemoryError | [
"def",
"append",
"(",
"self",
",",
"position",
",",
"array",
")",
":",
"if",
"not",
"Gauged",
".",
"map_append",
"(",
"self",
".",
"ptr",
",",
"position",
",",
"array",
".",
"ptr",
")",
":",
"raise",
"MemoryError"
] | Append an array to the end of the map. The position
must be greater than any positions in the map | [
"Append",
"an",
"array",
"to",
"the",
"end",
"of",
"the",
"map",
".",
"The",
"position",
"must",
"be",
"greater",
"than",
"any",
"positions",
"in",
"the",
"map"
] | python | train | 49 |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L3901-L3905 | def setWorkingPlayAreaSize(self, sizeX, sizeZ):
"""Sets the Play Area in the working copy."""
fn = self.function_table.setWorkingPlayAreaSize
fn(sizeX, sizeZ) | [
"def",
"setWorkingPlayAreaSize",
"(",
"self",
",",
"sizeX",
",",
"sizeZ",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"setWorkingPlayAreaSize",
"fn",
"(",
"sizeX",
",",
"sizeZ",
")"
] | Sets the Play Area in the working copy. | [
"Sets",
"the",
"Play",
"Area",
"in",
"the",
"working",
"copy",
"."
] | python | train | 35.8 |
FNNDSC/pfdicom | pfdicom/pfdicom.py | https://github.com/FNNDSC/pfdicom/blob/91a0426c514a3496cb2e0576481055a47afee8d8/pfdicom/pfdicom.py#L266-L348 | def DICOMfile_read(self, *args, **kwargs):
"""
Read a DICOM file and perform some initial
parsing of tags.
NB!
For thread safety, class member variables
should not be assigned since other threads
might override/change these variables in mid-
flight!
... | [
"def",
"DICOMfile_read",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"b_status",
"=",
"False",
"l_tags",
"=",
"[",
"]",
"l_tagsToUse",
"=",
"[",
"]",
"d_tagsInString",
"=",
"{",
"}",
"str_file",
"=",
"\"\"",
"d_DICOM",
"=",
"{",... | Read a DICOM file and perform some initial
parsing of tags.
NB!
For thread safety, class member variables
should not be assigned since other threads
might override/change these variables in mid-
flight! | [
"Read",
"a",
"DICOM",
"file",
"and",
"perform",
"some",
"initial",
"parsing",
"of",
"tags",
"."
] | python | train | 37.036145 |
nkmathew/yasi-sexp-indenter | yasi.py | https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L394-L407 | def tabify(text, options):
""" tabify(text : str, options : argparse.Namespace|str) -> str
>>> tabify(' (println "hello world")', '--tab=3')
'\t\t (println "hello world")'
Replace spaces with tabs
"""
opts = parse_options(options)
if opts.tab_size < 1:
return text
else... | [
"def",
"tabify",
"(",
"text",
",",
"options",
")",
":",
"opts",
"=",
"parse_options",
"(",
"options",
")",
"if",
"opts",
".",
"tab_size",
"<",
"1",
":",
"return",
"text",
"else",
":",
"tab_equiv",
"=",
"' '",
"*",
"opts",
".",
"tab_size",
"return",
"... | tabify(text : str, options : argparse.Namespace|str) -> str
>>> tabify(' (println "hello world")', '--tab=3')
'\t\t (println "hello world")'
Replace spaces with tabs | [
"tabify",
"(",
"text",
":",
"str",
"options",
":",
"argparse",
".",
"Namespace|str",
")",
"-",
">",
"str"
] | python | train | 28.071429 |
fogleman/pg | pg/glfw.py | https://github.com/fogleman/pg/blob/124ea3803c788b2c98c4f3a428e5d26842a67b58/pg/glfw.py#L84-L135 | def _glfw_get_version(filename):
'''
Queries and returns the library version tuple or None by using a
subprocess.
'''
version_checker_source = """
import sys
import ctypes
def get_version(library_handle):
'''
Queries and returns the library version tu... | [
"def",
"_glfw_get_version",
"(",
"filename",
")",
":",
"version_checker_source",
"=",
"\"\"\"\n import sys\n import ctypes\n\n def get_version(library_handle):\n '''\n Queries and returns the library version tuple or None.\n '''\n majo... | Queries and returns the library version tuple or None by using a
subprocess. | [
"Queries",
"and",
"returns",
"the",
"library",
"version",
"tuple",
"or",
"None",
"by",
"using",
"a",
"subprocess",
"."
] | python | train | 30.923077 |
inveniosoftware-contrib/invenio-classifier | invenio_classifier/reader.py | https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/reader.py#L914-L941 | def _get_regex_pattern(label):
"""Return a regular expression of the label.
This takes care of plural and different kinds of separators.
"""
parts = _split_by_punctuation.split(label)
for index, part in enumerate(parts):
if index % 2 == 0:
# Word
if not parts[index]... | [
"def",
"_get_regex_pattern",
"(",
"label",
")",
":",
"parts",
"=",
"_split_by_punctuation",
".",
"split",
"(",
"label",
")",
"for",
"index",
",",
"part",
"in",
"enumerate",
"(",
"parts",
")",
":",
"if",
"index",
"%",
"2",
"==",
"0",
":",
"# Word",
"if"... | Return a regular expression of the label.
This takes care of plural and different kinds of separators. | [
"Return",
"a",
"regular",
"expression",
"of",
"the",
"label",
"."
] | python | train | 33.964286 |
tarbell-project/tarbell | tarbell/cli.py | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L741-L751 | def _list_templates(settings):
"""
List templates from settings.
"""
for idx, option in enumerate(settings.config.get("project_templates"), start=1):
puts(" {0!s:5} {1!s:36}".format(
colored.yellow("[{0}]".format(idx)),
colored.cyan(option.get("name"))
))
... | [
"def",
"_list_templates",
"(",
"settings",
")",
":",
"for",
"idx",
",",
"option",
"in",
"enumerate",
"(",
"settings",
".",
"config",
".",
"get",
"(",
"\"project_templates\"",
")",
",",
"start",
"=",
"1",
")",
":",
"puts",
"(",
"\" {0!s:5} {1!s:36}\"",
"."... | List templates from settings. | [
"List",
"templates",
"from",
"settings",
"."
] | python | train | 35.454545 |
quantumlib/Cirq | dev_tools/auto_merge.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/auto_merge.py#L446-L460 | def delete_comment(repo: GithubRepository, comment_id: int) -> None:
"""
References:
https://developer.github.com/v3/issues/comments/#delete-a-comment
"""
url = ("https://api.github.com/repos/{}/{}/issues/comments/{}"
"?access_token={}".format(repo.organization,
... | [
"def",
"delete_comment",
"(",
"repo",
":",
"GithubRepository",
",",
"comment_id",
":",
"int",
")",
"->",
"None",
":",
"url",
"=",
"(",
"\"https://api.github.com/repos/{}/{}/issues/comments/{}\"",
"\"?access_token={}\"",
".",
"format",
"(",
"repo",
".",
"organization",... | References:
https://developer.github.com/v3/issues/comments/#delete-a-comment | [
"References",
":",
"https",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"issues",
"/",
"comments",
"/",
"#delete",
"-",
"a",
"-",
"comment"
] | python | train | 44.133333 |
MrYsLab/pymata-aio | pymata_aio/pymata3.py | https://github.com/MrYsLab/pymata-aio/blob/015081a4628b9d47dfe3f8d6c698ff903f107810/pymata_aio/pymata3.py#L623-L630 | def shutdown(self):
"""
Shutdown the application and exit
:returns: No return value
"""
task = asyncio.ensure_future(self.core.shutdown())
self.loop.run_until_complete(task) | [
"def",
"shutdown",
"(",
"self",
")",
":",
"task",
"=",
"asyncio",
".",
"ensure_future",
"(",
"self",
".",
"core",
".",
"shutdown",
"(",
")",
")",
"self",
".",
"loop",
".",
"run_until_complete",
"(",
"task",
")"
] | Shutdown the application and exit
:returns: No return value | [
"Shutdown",
"the",
"application",
"and",
"exit"
] | python | train | 26.875 |
trailofbits/manticore | manticore/core/smtlib/solver.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/solver.py#L93-L102 | def min(self, constraints, X: BitVec, M=10000):
"""
Iteratively finds the minimum value for a symbol within given constraints.
:param constraints: constraints that the expression must fulfil
:param X: a symbol or expression
:param M: maximum number of iterations allowed
... | [
"def",
"min",
"(",
"self",
",",
"constraints",
",",
"X",
":",
"BitVec",
",",
"M",
"=",
"10000",
")",
":",
"assert",
"isinstance",
"(",
"X",
",",
"BitVec",
")",
"return",
"self",
".",
"optimize",
"(",
"constraints",
",",
"X",
",",
"'minimize'",
",",
... | Iteratively finds the minimum value for a symbol within given constraints.
:param constraints: constraints that the expression must fulfil
:param X: a symbol or expression
:param M: maximum number of iterations allowed | [
"Iteratively",
"finds",
"the",
"minimum",
"value",
"for",
"a",
"symbol",
"within",
"given",
"constraints",
"."
] | python | valid | 41.1 |
openstack/quark | quark/drivers/ironic_driver.py | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/ironic_driver.py#L165-L211 | def select_ipam_strategy(self, network_id, network_strategy, **kwargs):
"""Return relevant IPAM strategy name.
:param network_id: neutron network id.
:param network_strategy: default strategy for the network.
NOTE(morgabra) This feels like a hack but I can't think of a better
i... | [
"def",
"select_ipam_strategy",
"(",
"self",
",",
"network_id",
",",
"network_strategy",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"info",
"(",
"\"Selecting IPAM strategy for network_id:%s \"",
"\"network_strategy:%s\"",
"%",
"(",
"network_id",
",",
"network_strat... | Return relevant IPAM strategy name.
:param network_id: neutron network id.
:param network_strategy: default strategy for the network.
NOTE(morgabra) This feels like a hack but I can't think of a better
idea. The root problem is we can now attach ports to networks with
a differe... | [
"Return",
"relevant",
"IPAM",
"strategy",
"name",
"."
] | python | valid | 43.978723 |
getpelican/pelican-plugins | events/events.py | https://github.com/getpelican/pelican-plugins/blob/cfc7a3f224f1743063b034561f89a6a712d13587/events/events.py#L159-L168 | def generate_events_list(generator):
"""Populate the event_list variable to be used in jinja templates"""
if not localized_events:
generator.context['events_list'] = sorted(events, reverse = True,
key=lambda ev: (ev.dtstart, ev.dtend))
else:
... | [
"def",
"generate_events_list",
"(",
"generator",
")",
":",
"if",
"not",
"localized_events",
":",
"generator",
".",
"context",
"[",
"'events_list'",
"]",
"=",
"sorted",
"(",
"events",
",",
"reverse",
"=",
"True",
",",
"key",
"=",
"lambda",
"ev",
":",
"(",
... | Populate the event_list variable to be used in jinja templates | [
"Populate",
"the",
"event_list",
"variable",
"to",
"be",
"used",
"in",
"jinja",
"templates"
] | python | train | 55.1 |
fhamborg/news-please | newsplease/crawler/commoncrawl_crawler.py | https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/crawler/commoncrawl_crawler.py#L33-L53 | def __setup(local_download_dir_warc, log_level):
"""
Setup
:return:
"""
if not os.path.exists(local_download_dir_warc):
os.makedirs(local_download_dir_warc)
# make loggers quite
configure_logging({"LOG_LEVEL": "ERROR"})
logging.getLogger('requests').setLevel(logging.CRITICAL)
... | [
"def",
"__setup",
"(",
"local_download_dir_warc",
",",
"log_level",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"local_download_dir_warc",
")",
":",
"os",
".",
"makedirs",
"(",
"local_download_dir_warc",
")",
"# make loggers quite",
"configure_lo... | Setup
:return: | [
"Setup",
":",
"return",
":"
] | python | train | 35.285714 |
kislyuk/aegea | aegea/packages/github3/repos/repo.py | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/repo.py#L340-L352 | def asset(self, id):
"""Returns a single Asset.
:param int id: (required), id of the asset
:returns: :class:`Asset <github3.repos.release.Asset>`
"""
data = None
if int(id) > 0:
url = self._build_url('releases', 'assets', str(id),
... | [
"def",
"asset",
"(",
"self",
",",
"id",
")",
":",
"data",
"=",
"None",
"if",
"int",
"(",
"id",
")",
">",
"0",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'releases'",
",",
"'assets'",
",",
"str",
"(",
"id",
")",
",",
"base_url",
"=",
"sel... | Returns a single Asset.
:param int id: (required), id of the asset
:returns: :class:`Asset <github3.repos.release.Asset>` | [
"Returns",
"a",
"single",
"Asset",
"."
] | python | train | 38.230769 |
hangyan/shaw | shaw/types/d.py | https://github.com/hangyan/shaw/blob/63d01d35e225ba4edb9c61edaf351e1bc0e8fd15/shaw/types/d.py#L63-L69 | def deepcp(data):
"""Use ujson to do deep_copy"""
import ujson
try:
return ujson.loads(ujson.dumps(data))
except Exception:
return copy.deepcopy(data) | [
"def",
"deepcp",
"(",
"data",
")",
":",
"import",
"ujson",
"try",
":",
"return",
"ujson",
".",
"loads",
"(",
"ujson",
".",
"dumps",
"(",
"data",
")",
")",
"except",
"Exception",
":",
"return",
"copy",
".",
"deepcopy",
"(",
"data",
")"
] | Use ujson to do deep_copy | [
"Use",
"ujson",
"to",
"do",
"deep_copy"
] | python | train | 25.142857 |
polyaxon/polyaxon-cli | polyaxon_cli/cli/build.py | https://github.com/polyaxon/polyaxon-cli/blob/a7f5eed74d4d909cad79059f3c21c58606881449/polyaxon_cli/cli/build.py#L217-L242 | def bookmark(ctx):
"""Bookmark build job.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon build bookmark
```
\b
```bash
$ polyaxon build -b 2 bookmark
```
"""
user, project_name, _build = get_build_or_local(ctx.obj.get('project'),... | [
"def",
"bookmark",
"(",
"ctx",
")",
":",
"user",
",",
"project_name",
",",
"_build",
"=",
"get_build_or_local",
"(",
"ctx",
".",
"obj",
".",
"get",
"(",
"'project'",
")",
",",
"ctx",
".",
"obj",
".",
"get",
"(",
"'build'",
")",
")",
"try",
":",
"Po... | Bookmark build job.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon build bookmark
```
\b
```bash
$ polyaxon build -b 2 bookmark
``` | [
"Bookmark",
"build",
"job",
"."
] | python | valid | 26.884615 |
pescadores/pescador | pescador/maps.py | https://github.com/pescadores/pescador/blob/786e2b5f882d13ea563769fbc7ad0a0a10c3553d/pescador/maps.py#L87-L117 | def tuples(stream, *keys):
"""Reformat data as tuples.
Parameters
----------
stream : iterable
Stream of data objects.
*keys : strings
Keys to use for ordering data.
Yields
------
items : tuple of np.ndarrays
Data object reformated as a tuple.
Raises
-... | [
"def",
"tuples",
"(",
"stream",
",",
"*",
"keys",
")",
":",
"if",
"not",
"keys",
":",
"raise",
"PescadorError",
"(",
"'Unable to generate tuples from '",
"'an empty item set'",
")",
"for",
"data",
"in",
"stream",
":",
"try",
":",
"yield",
"tuple",
"(",
"data... | Reformat data as tuples.
Parameters
----------
stream : iterable
Stream of data objects.
*keys : strings
Keys to use for ordering data.
Yields
------
items : tuple of np.ndarrays
Data object reformated as a tuple.
Raises
------
DataError
If the... | [
"Reformat",
"data",
"as",
"tuples",
"."
] | python | train | 24.645161 |
matthewdeanmartin/jiggle_version | jiggle_version/package_info_finder.py | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/package_info_finder.py#L229-L268 | def find_malformed_single_file_project(self): # type: () -> List[str]
"""
Take first non-setup.py python file. What a mess.
:return:
"""
files = [f for f in os.listdir(".") if os.path.isfile(f)]
candidates = []
# project misnamed & not in setup.py
for f... | [
"def",
"find_malformed_single_file_project",
"(",
"self",
")",
":",
"# type: () -> List[str]",
"files",
"=",
"[",
"f",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"\".\"",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"f",
")",
"]",
"candidates",
"=... | Take first non-setup.py python file. What a mess.
:return: | [
"Take",
"first",
"non",
"-",
"setup",
".",
"py",
"python",
"file",
".",
"What",
"a",
"mess",
".",
":",
"return",
":"
] | python | train | 32.325 |
sorgerlab/indra | indra/tools/reading/util/reporter.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/util/reporter.py#L31-L47 | def add_section(self, section_name):
"""Create a section of the report, to be headed by section_name
Text and images can be added by using the `section` argument of the
`add_text` and `add_image` methods. Sections can also be ordered by
using the `set_section_order` method.
By ... | [
"def",
"add_section",
"(",
"self",
",",
"section_name",
")",
":",
"self",
".",
"section_headings",
".",
"append",
"(",
"section_name",
")",
"if",
"section_name",
"in",
"self",
".",
"sections",
":",
"raise",
"ValueError",
"(",
"\"Section %s already exists.\"",
"%... | Create a section of the report, to be headed by section_name
Text and images can be added by using the `section` argument of the
`add_text` and `add_image` methods. Sections can also be ordered by
using the `set_section_order` method.
By default, text and images that have no section wi... | [
"Create",
"a",
"section",
"of",
"the",
"report",
"to",
"be",
"headed",
"by",
"section_name"
] | python | train | 45.411765 |
klahnakoski/pyLibrary | mo_threads/queues.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/queues.py#L111-L119 | def pop_message(self, till=None):
"""
RETURN TUPLE (message, payload) CALLER IS RESPONSIBLE FOR CALLING message.delete() WHEN DONE
DUMMY IMPLEMENTATION FOR DEBUGGING
"""
if till is not None and not isinstance(till, Signal):
Log.error("Expecting a signal")
ret... | [
"def",
"pop_message",
"(",
"self",
",",
"till",
"=",
"None",
")",
":",
"if",
"till",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"till",
",",
"Signal",
")",
":",
"Log",
".",
"error",
"(",
"\"Expecting a signal\"",
")",
"return",
"Null",
",",
... | RETURN TUPLE (message, payload) CALLER IS RESPONSIBLE FOR CALLING message.delete() WHEN DONE
DUMMY IMPLEMENTATION FOR DEBUGGING | [
"RETURN",
"TUPLE",
"(",
"message",
"payload",
")",
"CALLER",
"IS",
"RESPONSIBLE",
"FOR",
"CALLING",
"message",
".",
"delete",
"()",
"WHEN",
"DONE",
"DUMMY",
"IMPLEMENTATION",
"FOR",
"DEBUGGING"
] | python | train | 37.888889 |
numenta/nupic | src/nupic/support/__init__.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/__init__.py#L442-L478 | def aggregationDivide(dividend, divisor):
"""
Return the result from dividing two dicts that represent date and time.
Both dividend and divisor are dicts that contain one or more of the following
keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', seconds',
'milliseconds', 'microseconds'.
For ex... | [
"def",
"aggregationDivide",
"(",
"dividend",
",",
"divisor",
")",
":",
"# Convert each into microseconds",
"dividendMonthSec",
"=",
"aggregationToMonthsSeconds",
"(",
"dividend",
")",
"divisorMonthSec",
"=",
"aggregationToMonthsSeconds",
"(",
"divisor",
")",
"# It is a usag... | Return the result from dividing two dicts that represent date and time.
Both dividend and divisor are dicts that contain one or more of the following
keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', seconds',
'milliseconds', 'microseconds'.
For example:
::
aggregationDivide({'hours': 4}, ... | [
"Return",
"the",
"result",
"from",
"dividing",
"two",
"dicts",
"that",
"represent",
"date",
"and",
"time",
"."
] | python | valid | 35.702703 |
Tanganelli/CoAPthon3 | coapthon/reverse_proxy/coap.py | https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/reverse_proxy/coap.py#L130-L139 | def parse_config(self):
"""
Parse the xml file with remote servers and discover resources on each found server.
"""
tree = ElementTree.parse(self.file_xml)
root = tree.getroot()
for server in root.findall('server'):
destination = server.text
name =... | [
"def",
"parse_config",
"(",
"self",
")",
":",
"tree",
"=",
"ElementTree",
".",
"parse",
"(",
"self",
".",
"file_xml",
")",
"root",
"=",
"tree",
".",
"getroot",
"(",
")",
"for",
"server",
"in",
"root",
".",
"findall",
"(",
"'server'",
")",
":",
"desti... | Parse the xml file with remote servers and discover resources on each found server. | [
"Parse",
"the",
"xml",
"file",
"with",
"remote",
"servers",
"and",
"discover",
"resources",
"on",
"each",
"found",
"server",
"."
] | python | train | 38.2 |
capitalone/giraffez | giraffez/encrypt.py | https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/encrypt.py#L30-L41 | def create_key_file(path):
"""
Creates a new encryption key in the path provided and sets the file
permissions. Setting the file permissions currently does not work
on Windows platforms because of the differences in how file
permissions are read and modified.
"""
iv = "{}{}".format(os.urand... | [
"def",
"create_key_file",
"(",
"path",
")",
":",
"iv",
"=",
"\"{}{}\"",
".",
"format",
"(",
"os",
".",
"urandom",
"(",
"32",
")",
",",
"time",
".",
"time",
"(",
")",
")",
"new_key",
"=",
"generate_key",
"(",
"ensure_bytes",
"(",
"iv",
")",
")",
"wi... | Creates a new encryption key in the path provided and sets the file
permissions. Setting the file permissions currently does not work
on Windows platforms because of the differences in how file
permissions are read and modified. | [
"Creates",
"a",
"new",
"encryption",
"key",
"in",
"the",
"path",
"provided",
"and",
"sets",
"the",
"file",
"permissions",
".",
"Setting",
"the",
"file",
"permissions",
"currently",
"does",
"not",
"work",
"on",
"Windows",
"platforms",
"because",
"of",
"the",
... | python | test | 39.583333 |
Esri/ArcREST | src/arcrest/common/symbology.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/symbology.py#L150-L154 | def outlineColor(self, value):
"""gets/sets the outlineColor"""
if isinstance(value, Color) and \
not self._outline is None:
self._outline['color'] = value | [
"def",
"outlineColor",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Color",
")",
"and",
"not",
"self",
".",
"_outline",
"is",
"None",
":",
"self",
".",
"_outline",
"[",
"'color'",
"]",
"=",
"value"
] | gets/sets the outlineColor | [
"gets",
"/",
"sets",
"the",
"outlineColor"
] | python | train | 38 |
ellethee/argparseinator | argparseinator/__init__.py | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L599-L602 | def extend_with(func):
"""Extends with class or function"""
if not func.__name__ in ArgParseInator._plugins:
ArgParseInator._plugins[func.__name__] = func | [
"def",
"extend_with",
"(",
"func",
")",
":",
"if",
"not",
"func",
".",
"__name__",
"in",
"ArgParseInator",
".",
"_plugins",
":",
"ArgParseInator",
".",
"_plugins",
"[",
"func",
".",
"__name__",
"]",
"=",
"func"
] | Extends with class or function | [
"Extends",
"with",
"class",
"or",
"function"
] | python | train | 41.75 |
tcalmant/ipopo | pelix/remote/discovery/zookeeper.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/discovery/zookeeper.py#L170-L176 | def stop(self):
"""
Stops the connection
"""
self.__stop = True
self._queue.stop()
self._zk.stop() | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"__stop",
"=",
"True",
"self",
".",
"_queue",
".",
"stop",
"(",
")",
"self",
".",
"_zk",
".",
"stop",
"(",
")"
] | Stops the connection | [
"Stops",
"the",
"connection"
] | python | train | 20 |
Yelp/py_zipkin | py_zipkin/thrift/__init__.py | https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L24-L34 | def create_annotation(timestamp, value, host):
"""
Create a zipkin annotation object
:param timestamp: timestamp of when the annotation occured in microseconds
:param value: name of the annotation, such as 'sr'
:param host: zipkin endpoint object
:returns: zipkin annotation object
"""
... | [
"def",
"create_annotation",
"(",
"timestamp",
",",
"value",
",",
"host",
")",
":",
"return",
"zipkin_core",
".",
"Annotation",
"(",
"timestamp",
"=",
"timestamp",
",",
"value",
"=",
"value",
",",
"host",
"=",
"host",
")"
] | Create a zipkin annotation object
:param timestamp: timestamp of when the annotation occured in microseconds
:param value: name of the annotation, such as 'sr'
:param host: zipkin endpoint object
:returns: zipkin annotation object | [
"Create",
"a",
"zipkin",
"annotation",
"object"
] | python | test | 34.909091 |
openstack/horizon | horizon/tables/formset.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/formset.py#L110-L120 | def get_formset(self):
"""Provide the formset corresponding to this DataTable.
Use this to validate the formset and to get the submitted data back.
"""
if self._formset is None:
self._formset = self.formset_class(
self.request.POST or None,
in... | [
"def",
"get_formset",
"(",
"self",
")",
":",
"if",
"self",
".",
"_formset",
"is",
"None",
":",
"self",
".",
"_formset",
"=",
"self",
".",
"formset_class",
"(",
"self",
".",
"request",
".",
"POST",
"or",
"None",
",",
"initial",
"=",
"self",
".",
"_get... | Provide the formset corresponding to this DataTable.
Use this to validate the formset and to get the submitted data back. | [
"Provide",
"the",
"formset",
"corresponding",
"to",
"this",
"DataTable",
"."
] | python | train | 37.272727 |
acorg/dark-matter | dark/reads.py | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1374-L1394 | def summarizePosition(self, index):
"""
Compute residue counts at a specific sequence index.
@param index: an C{int} index into the sequence.
@return: A C{dict} with the count of too-short (excluded) sequences,
and a Counter instance giving the residue counts.
"""
... | [
"def",
"summarizePosition",
"(",
"self",
",",
"index",
")",
":",
"countAtPosition",
"=",
"Counter",
"(",
")",
"excludedCount",
"=",
"0",
"for",
"read",
"in",
"self",
":",
"try",
":",
"countAtPosition",
"[",
"read",
".",
"sequence",
"[",
"index",
"]",
"]"... | Compute residue counts at a specific sequence index.
@param index: an C{int} index into the sequence.
@return: A C{dict} with the count of too-short (excluded) sequences,
and a Counter instance giving the residue counts. | [
"Compute",
"residue",
"counts",
"at",
"a",
"specific",
"sequence",
"index",
"."
] | python | train | 30.809524 |
abusque/qng | qng/generator.py | https://github.com/abusque/qng/blob/93d2efd637b2a6bba7d3872fb9ff2bb3fc5c979d/qng/generator.py#L204-L222 | def _snakify_name(self, name):
"""Snakify a name string.
In this context, "to snakify" means to strip a name of all
diacritics, convert it to lower case, and replace any spaces
inside the name with hyphens.
This way the name is made "machine-friendly", and ready to be
c... | [
"def",
"_snakify_name",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_strip_diacritics",
"(",
"name",
")",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"name",
"=",
"name",
".",
"replace",
"(",
"' '",
",",
"'-'",
")",
"return",
"n... | Snakify a name string.
In this context, "to snakify" means to strip a name of all
diacritics, convert it to lower case, and replace any spaces
inside the name with hyphens.
This way the name is made "machine-friendly", and ready to be
combined with a second name component into ... | [
"Snakify",
"a",
"name",
"string",
"."
] | python | train | 31.789474 |
ceph/ceph-deploy | ceph_deploy/install.py | https://github.com/ceph/ceph-deploy/blob/86943fcc454cd4c99a86e3493e9e93a59c661fef/ceph_deploy/install.py#L445-L622 | def make(parser):
"""
Install Ceph packages on remote hosts.
"""
version = parser.add_mutually_exclusive_group()
# XXX deprecated in favor of release
version.add_argument(
'--stable',
nargs='?',
action=StoreVersion,
metavar='CODENAME',
help='[DEPRECATED]... | [
"def",
"make",
"(",
"parser",
")",
":",
"version",
"=",
"parser",
".",
"add_mutually_exclusive_group",
"(",
")",
"# XXX deprecated in favor of release",
"version",
".",
"add_argument",
"(",
"'--stable'",
",",
"nargs",
"=",
"'?'",
",",
"action",
"=",
"StoreVersion"... | Install Ceph packages on remote hosts. | [
"Install",
"Ceph",
"packages",
"on",
"remote",
"hosts",
"."
] | python | train | 23.174157 |
saltstack/salt | salt/utils/gitfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L467-L503 | def _get_envs_from_ref_paths(self, refs):
'''
Return the names of remote refs (stripped of the remote name) and tags
which are map to the branches and tags.
'''
def _check_ref(env_set, rname):
'''
Add the appropriate saltenv(s) to the set
'''
... | [
"def",
"_get_envs_from_ref_paths",
"(",
"self",
",",
"refs",
")",
":",
"def",
"_check_ref",
"(",
"env_set",
",",
"rname",
")",
":",
"'''\n Add the appropriate saltenv(s) to the set\n '''",
"if",
"rname",
"in",
"self",
".",
"saltenv_revmap",
":",
... | Return the names of remote refs (stripped of the remote name) and tags
which are map to the branches and tags. | [
"Return",
"the",
"names",
"of",
"remote",
"refs",
"(",
"stripped",
"of",
"the",
"remote",
"name",
")",
"and",
"tags",
"which",
"are",
"map",
"to",
"the",
"branches",
"and",
"tags",
"."
] | python | train | 37.594595 |
ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py#L2053-L2074 | def get_account_invitation(self, account_id, invitation_id, **kwargs): # noqa: E501
"""Details of a user invitation. # noqa: E501
An endpoint for retrieving the details of an active user invitation sent for a new or an existing user to join the account. **Example usage:** `curl https://api.us-east-... | [
"def",
"get_account_invitation",
"(",
"self",
",",
"account_id",
",",
"invitation_id",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'asynchronous'",
")",
":",
... | Details of a user invitation. # noqa: E501
An endpoint for retrieving the details of an active user invitation sent for a new or an existing user to join the account. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts/{account-id}/user-invitations/{invitation-id} -H 'Authorization: Bea... | [
"Details",
"of",
"a",
"user",
"invitation",
".",
"#",
"noqa",
":",
"E501"
] | python | train | 62.227273 |
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#L1139-L1169 | def get_path_contents(self, project, provider_name, service_endpoint_id=None, repository=None, commit_or_branch=None, path=None):
"""GetPathContents.
[Preview API] Gets the contents of a directory in the given source code repository.
:param str project: Project ID or project name
:param ... | [
"def",
"get_path_contents",
"(",
"self",
",",
"project",
",",
"provider_name",
",",
"service_endpoint_id",
"=",
"None",
",",
"repository",
"=",
"None",
",",
"commit_or_branch",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
... | GetPathContents.
[Preview API] Gets the contents of a directory in the given source code repository.
:param str project: Project ID or project name
:param str provider_name: The name of the source provider.
:param str service_endpoint_id: If specified, the ID of the service endpoint to q... | [
"GetPathContents",
".",
"[",
"Preview",
"API",
"]",
"Gets",
"the",
"contents",
"of",
"a",
"directory",
"in",
"the",
"given",
"source",
"code",
"repository",
".",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
... | python | train | 73.387097 |
mayfield/shellish | shellish/command/command.py | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/command.py#L135-L149 | def get_pager_spec(self):
""" Find the best pager settings for this command. If the user has
specified overrides in the INI config file we prefer those. """
self_config = self.get_config()
pagercmd = self_config.get('pager')
istty = self_config.getboolean('pager_istty')
... | [
"def",
"get_pager_spec",
"(",
"self",
")",
":",
"self_config",
"=",
"self",
".",
"get_config",
"(",
")",
"pagercmd",
"=",
"self_config",
".",
"get",
"(",
"'pager'",
")",
"istty",
"=",
"self_config",
".",
"getboolean",
"(",
"'pager_istty'",
")",
"core_config"... | Find the best pager settings for this command. If the user has
specified overrides in the INI config file we prefer those. | [
"Find",
"the",
"best",
"pager",
"settings",
"for",
"this",
"command",
".",
"If",
"the",
"user",
"has",
"specified",
"overrides",
"in",
"the",
"INI",
"config",
"file",
"we",
"prefer",
"those",
"."
] | python | train | 39 |
klmitch/policies | policies/policy.py | https://github.com/klmitch/policies/blob/edf26c5707a5a0cc8e9f59a209a64dee7f79b7a4/policies/policy.py#L467-L497 | def resolve(self, symbol):
"""
Resolve a symbol using the entrypoint group.
:param symbol: The symbol being resolved.
:returns: The value of that symbol. If the symbol cannot be
found, or if no entrypoint group was passed to the
constructor, will re... | [
"def",
"resolve",
"(",
"self",
",",
"symbol",
")",
":",
"# Search for a corresponding symbol",
"if",
"symbol",
"not",
"in",
"self",
".",
"_resolve_cache",
":",
"result",
"=",
"None",
"# Search through entrypoints only if we have a group",
"if",
"self",
".",
"_group",
... | Resolve a symbol using the entrypoint group.
:param symbol: The symbol being resolved.
:returns: The value of that symbol. If the symbol cannot be
found, or if no entrypoint group was passed to the
constructor, will return ``None``. | [
"Resolve",
"a",
"symbol",
"using",
"the",
"entrypoint",
"group",
"."
] | python | train | 33.806452 |
ralphje/imagemounter | imagemounter/unmounter.py | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L207-L214 | def unmount_loopbacks(self):
"""Unmounts all loopback devices as identified by :func:`find_loopbacks`"""
# re-index loopback devices
self._index_loopbacks()
for dev in self.find_loopbacks():
_util.check_output_(['losetup', '-d', dev]) | [
"def",
"unmount_loopbacks",
"(",
"self",
")",
":",
"# re-index loopback devices",
"self",
".",
"_index_loopbacks",
"(",
")",
"for",
"dev",
"in",
"self",
".",
"find_loopbacks",
"(",
")",
":",
"_util",
".",
"check_output_",
"(",
"[",
"'losetup'",
",",
"'-d'",
... | Unmounts all loopback devices as identified by :func:`find_loopbacks` | [
"Unmounts",
"all",
"loopback",
"devices",
"as",
"identified",
"by",
":",
"func",
":",
"find_loopbacks"
] | python | train | 34.125 |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/process.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/process.py#L446-L462 | def get_exit_code(self):
"""
@rtype: int
@return: Process exit code, or C{STILL_ACTIVE} if it's still alive.
@warning: If a process returns C{STILL_ACTIVE} as it's exit code,
you may not be able to determine if it's active or not with this
method. Use L{is_alive... | [
"def",
"get_exit_code",
"(",
"self",
")",
":",
"if",
"win32",
".",
"PROCESS_ALL_ACCESS",
"==",
"win32",
".",
"PROCESS_ALL_ACCESS_VISTA",
":",
"dwAccess",
"=",
"win32",
".",
"PROCESS_QUERY_LIMITED_INFORMATION",
"else",
":",
"dwAccess",
"=",
"win32",
".",
"PROCESS_Q... | @rtype: int
@return: Process exit code, or C{STILL_ACTIVE} if it's still alive.
@warning: If a process returns C{STILL_ACTIVE} as it's exit code,
you may not be able to determine if it's active or not with this
method. Use L{is_alive} to check if the process is still active.
... | [
"@rtype",
":",
"int",
"@return",
":",
"Process",
"exit",
"code",
"or",
"C",
"{",
"STILL_ACTIVE",
"}",
"if",
"it",
"s",
"still",
"alive",
"."
] | python | train | 47.823529 |
openstack/networking-cisco | networking_cisco/ml2_drivers/nexus/mech_cisco_nexus.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/ml2_drivers/nexus/mech_cisco_nexus.py#L1700-L1757 | def create_port_postcommit(self, context):
"""Create port non-database commit event."""
# No new events are handled until replay
# thread has put the switch in active state.
# If a switch is in active state, verify
# the switch is still in active state
# before accepting... | [
"def",
"create_port_postcommit",
"(",
"self",
",",
"context",
")",
":",
"# No new events are handled until replay",
"# thread has put the switch in active state.",
"# If a switch is in active state, verify",
"# the switch is still in active state",
"# before accepting this new event.",
"#"... | Create port non-database commit event. | [
"Create",
"port",
"non",
"-",
"database",
"commit",
"event",
"."
] | python | train | 43.827586 |
assemblerflow/flowcraft | flowcraft/generator/process_details.py | https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/generator/process_details.py#L110-L169 | def proc_collector(process_map, args, pipeline_string):
"""
Function that collects all processes available and stores a dictionary of
the required arguments of each process class to be passed to
procs_dict_parser
Parameters
----------
process_map: dict
The dictionary with the Proces... | [
"def",
"proc_collector",
"(",
"process_map",
",",
"args",
",",
"pipeline_string",
")",
":",
"arguments_list",
"=",
"[",
"]",
"# prints a detailed list of the process class arguments",
"if",
"args",
".",
"detailed_list",
":",
"# list of attributes to be passed to proc_collecto... | Function that collects all processes available and stores a dictionary of
the required arguments of each process class to be passed to
procs_dict_parser
Parameters
----------
process_map: dict
The dictionary with the Processes currently available in flowcraft
and their corresponding... | [
"Function",
"that",
"collects",
"all",
"processes",
"available",
"and",
"stores",
"a",
"dictionary",
"of",
"the",
"required",
"arguments",
"of",
"each",
"process",
"class",
"to",
"be",
"passed",
"to",
"procs_dict_parser"
] | python | test | 29.1 |
rochacbruno/dynaconf | dynaconf/loaders/redis_loader.py | https://github.com/rochacbruno/dynaconf/blob/5a7cc8f8252251cbdf4f4112965801f9dfe2831d/dynaconf/loaders/redis_loader.py#L63-L87 | def write(obj, data=None, **kwargs):
"""Write a value in to loader source
:param obj: settings object
:param data: vars to be stored
:param kwargs: vars to be stored
:return:
"""
if obj.REDIS_ENABLED_FOR_DYNACONF is False:
raise RuntimeError(
"Redis is not configured \n"... | [
"def",
"write",
"(",
"obj",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"obj",
".",
"REDIS_ENABLED_FOR_DYNACONF",
"is",
"False",
":",
"raise",
"RuntimeError",
"(",
"\"Redis is not configured \\n\"",
"\"export REDIS_ENABLED_FOR_DYNACONF=true\\n... | Write a value in to loader source
:param obj: settings object
:param data: vars to be stored
:param kwargs: vars to be stored
:return: | [
"Write",
"a",
"value",
"in",
"to",
"loader",
"source"
] | python | train | 32.16 |
google/grr | grr/client/grr_response_client/client_actions/file_finder_utils/uploading.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/file_finder_utils/uploading.py#L78-L95 | def _UploadChunk(self, chunk):
"""Uploads a single chunk to the transfer store flow.
Args:
chunk: A chunk to upload.
Returns:
A `BlobImageChunkDescriptor` object.
"""
blob = _CompressedDataBlob(chunk)
self._action.ChargeBytesToSession(len(chunk.data))
self._action.SendReply(bl... | [
"def",
"_UploadChunk",
"(",
"self",
",",
"chunk",
")",
":",
"blob",
"=",
"_CompressedDataBlob",
"(",
"chunk",
")",
"self",
".",
"_action",
".",
"ChargeBytesToSession",
"(",
"len",
"(",
"chunk",
".",
"data",
")",
")",
"self",
".",
"_action",
".",
"SendRep... | Uploads a single chunk to the transfer store flow.
Args:
chunk: A chunk to upload.
Returns:
A `BlobImageChunkDescriptor` object. | [
"Uploads",
"a",
"single",
"chunk",
"to",
"the",
"transfer",
"store",
"flow",
"."
] | python | train | 28.611111 |
linkedin/pyexchange | pyexchange/exchange2010/soap_request.py | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/exchange2010/soap_request.py#L62-L76 | def delete_field(field_uri):
"""
Helper function to request deletion of a field. This is necessary when you want to overwrite values instead of
appending.
<t:DeleteItemField>
<t:FieldURI FieldURI="calendar:Resources"/>
</t:DeleteItemField>
"""
root = T.DeleteItemField(
T.Fiel... | [
"def",
"delete_field",
"(",
"field_uri",
")",
":",
"root",
"=",
"T",
".",
"DeleteItemField",
"(",
"T",
".",
"FieldURI",
"(",
"FieldURI",
"=",
"field_uri",
")",
")",
"return",
"root"
] | Helper function to request deletion of a field. This is necessary when you want to overwrite values instead of
appending.
<t:DeleteItemField>
<t:FieldURI FieldURI="calendar:Resources"/>
</t:DeleteItemField> | [
"Helper",
"function",
"to",
"request",
"deletion",
"of",
"a",
"field",
".",
"This",
"is",
"necessary",
"when",
"you",
"want",
"to",
"overwrite",
"values",
"instead",
"of",
"appending",
"."
] | python | train | 23.266667 |
gem/oq-engine | openquake/hmtk/seismicity/max_magnitude/kijko_sellevol_bayes.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/max_magnitude/kijko_sellevol_bayes.py#L60-L84 | def check_config(config, data):
'''Check config file inputs
:param dict config:
Configuration settings for the function
'''
essential_keys = ['input_mmin', 'b-value', 'sigma-b']
for key in essential_keys:
if not key in config.keys():
raise ValueError('For KijkoSellevol... | [
"def",
"check_config",
"(",
"config",
",",
"data",
")",
":",
"essential_keys",
"=",
"[",
"'input_mmin'",
",",
"'b-value'",
",",
"'sigma-b'",
"]",
"for",
"key",
"in",
"essential_keys",
":",
"if",
"not",
"key",
"in",
"config",
".",
"keys",
"(",
")",
":",
... | Check config file inputs
:param dict config:
Configuration settings for the function | [
"Check",
"config",
"file",
"inputs"
] | python | train | 33.04 |
csurfer/rake-nltk | rake_nltk/rake.py | https://github.com/csurfer/rake-nltk/blob/e36116d6074c5ddfbc69bce4440f0342355ceb2e/rake_nltk/rake.py#L178-L192 | def _generate_phrases(self, sentences):
"""Method to generate contender phrases given the sentences of the text
document.
:param sentences: List of strings where each string represents a
sentence which forms the text.
:return: Set of string tuples where each tu... | [
"def",
"_generate_phrases",
"(",
"self",
",",
"sentences",
")",
":",
"phrase_list",
"=",
"set",
"(",
")",
"# Create contender phrases from sentences.",
"for",
"sentence",
"in",
"sentences",
":",
"word_list",
"=",
"[",
"word",
".",
"lower",
"(",
")",
"for",
"wo... | Method to generate contender phrases given the sentences of the text
document.
:param sentences: List of strings where each string represents a
sentence which forms the text.
:return: Set of string tuples where each tuple is a collection
of words formi... | [
"Method",
"to",
"generate",
"contender",
"phrases",
"given",
"the",
"sentences",
"of",
"the",
"text",
"document",
"."
] | python | train | 45.866667 |
metagriffin/fso | fso/filesystemoverlay.py | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L374-L379 | def _lexists(self, path):
'''IMPORTANT: expects `path` to already be deref()'erenced.'''
try:
return bool(self._lstat(path))
except os.error:
return False | [
"def",
"_lexists",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"return",
"bool",
"(",
"self",
".",
"_lstat",
"(",
"path",
")",
")",
"except",
"os",
".",
"error",
":",
"return",
"False"
] | IMPORTANT: expects `path` to already be deref()'erenced. | [
"IMPORTANT",
":",
"expects",
"path",
"to",
"already",
"be",
"deref",
"()",
"erenced",
"."
] | python | valid | 28.833333 |
jpscaletti/solution | solution/fields/color.py | https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/fields/color.py#L56-L71 | def normalize_hex(hex_color):
"""Transform a xxx hex color to xxxxxx.
"""
hex_color = hex_color.replace('#', '').lower()
length = len(hex_color)
if length in (6, 8):
return '#' + hex_color
if length not in (3, 4):
return None
strhex = u'#%s%s%s' % (
hex_color[0] * 2,
... | [
"def",
"normalize_hex",
"(",
"hex_color",
")",
":",
"hex_color",
"=",
"hex_color",
".",
"replace",
"(",
"'#'",
",",
"''",
")",
".",
"lower",
"(",
")",
"length",
"=",
"len",
"(",
"hex_color",
")",
"if",
"length",
"in",
"(",
"6",
",",
"8",
")",
":",
... | Transform a xxx hex color to xxxxxx. | [
"Transform",
"a",
"xxx",
"hex",
"color",
"to",
"xxxxxx",
"."
] | python | train | 26.8125 |
PyCQA/pylint | pylint/checkers/imports.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/imports.py#L930-L939 | def _filter_dependencies_graph(self, internal):
"""build the internal or the external depedency graph"""
graph = collections.defaultdict(set)
for importee, importers in self.stats["dependencies"].items():
for importer in importers:
package = self._module_pkg.get(impor... | [
"def",
"_filter_dependencies_graph",
"(",
"self",
",",
"internal",
")",
":",
"graph",
"=",
"collections",
".",
"defaultdict",
"(",
"set",
")",
"for",
"importee",
",",
"importers",
"in",
"self",
".",
"stats",
"[",
"\"dependencies\"",
"]",
".",
"items",
"(",
... | build the internal or the external depedency graph | [
"build",
"the",
"internal",
"or",
"the",
"external",
"depedency",
"graph"
] | python | test | 53 |
cloudera/impyla | impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py | https://github.com/cloudera/impyla/blob/547fa2ba3b6151e2a98b3544301471a643212dc3/impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py#L2119-L2127 | def get_table_meta(self, db_patterns, tbl_patterns, tbl_types):
"""
Parameters:
- db_patterns
- tbl_patterns
- tbl_types
"""
self.send_get_table_meta(db_patterns, tbl_patterns, tbl_types)
return self.recv_get_table_meta() | [
"def",
"get_table_meta",
"(",
"self",
",",
"db_patterns",
",",
"tbl_patterns",
",",
"tbl_types",
")",
":",
"self",
".",
"send_get_table_meta",
"(",
"db_patterns",
",",
"tbl_patterns",
",",
"tbl_types",
")",
"return",
"self",
".",
"recv_get_table_meta",
"(",
")"
... | Parameters:
- db_patterns
- tbl_patterns
- tbl_types | [
"Parameters",
":",
"-",
"db_patterns",
"-",
"tbl_patterns",
"-",
"tbl_types"
] | python | train | 27.555556 |
rgs1/zk_shell | zk_shell/xclient.py | https://github.com/rgs1/zk_shell/blob/bbf34fdfcf1f81100e2a5816fad8af6afc782a54/zk_shell/xclient.py#L147-L157 | def get(self, *args, **kwargs):
""" wraps the default get() and deals with encoding """
value, stat = super(XClient, self).get(*args, **kwargs)
try:
if value is not None:
value = value.decode(encoding="utf-8")
except UnicodeDecodeError:
pass
... | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"value",
",",
"stat",
"=",
"super",
"(",
"XClient",
",",
"self",
")",
".",
"get",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"try",
":",
"if",
"value",
"is",... | wraps the default get() and deals with encoding | [
"wraps",
"the",
"default",
"get",
"()",
"and",
"deals",
"with",
"encoding"
] | python | train | 30.363636 |
helixyte/everest | everest/views/base.py | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L219-L230 | def _get_response_body_mime_type(self):
"""
Returns the response body MIME type. This might differ from the
overall response mime type e.g. in ATOM responses where the body
MIME type is XML.
"""
mime_type = self._get_response_mime_type()
if mime_type is AtomMime:
... | [
"def",
"_get_response_body_mime_type",
"(",
"self",
")",
":",
"mime_type",
"=",
"self",
".",
"_get_response_mime_type",
"(",
")",
"if",
"mime_type",
"is",
"AtomMime",
":",
"# FIXME: This cements using XML as the representation to use in",
"# ATOM bodies (which is perhaps... | Returns the response body MIME type. This might differ from the
overall response mime type e.g. in ATOM responses where the body
MIME type is XML. | [
"Returns",
"the",
"response",
"body",
"MIME",
"type",
".",
"This",
"might",
"differ",
"from",
"the",
"overall",
"response",
"mime",
"type",
"e",
".",
"g",
".",
"in",
"ATOM",
"responses",
"where",
"the",
"body",
"MIME",
"type",
"is",
"XML",
"."
] | python | train | 42.666667 |
uogbuji/versa | tools/py/pipeline/core_actions.py | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L17-L64 | def link(origin=None, rel=None, value=None, attributes=None, source=None):
'''
Action function generator to create a link based on the context's current link, or on provided parameters
:param origin: IRI/string, or list of same; origins for the created relationships.
If None, the action context provide... | [
"def",
"link",
"(",
"origin",
"=",
"None",
",",
"rel",
"=",
"None",
",",
"value",
"=",
"None",
",",
"attributes",
"=",
"None",
",",
"source",
"=",
"None",
")",
":",
"attributes",
"=",
"attributes",
"or",
"{",
"}",
"#rel = I(iri.absolutize(rel, ctx.base))",... | Action function generator to create a link based on the context's current link, or on provided parameters
:param origin: IRI/string, or list of same; origins for the created relationships.
If None, the action context provides the parameter.
:param rel: IRI/string, or list of same; IDs for the created rela... | [
"Action",
"function",
"generator",
"to",
"create",
"a",
"link",
"based",
"on",
"the",
"context",
"s",
"current",
"link",
"or",
"on",
"provided",
"parameters"
] | python | train | 49.1875 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/mpl_plot/_mpl_to_vispy.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/mpl_plot/_mpl_to_vispy.py#L179-L198 | def show(block=False):
"""Show current figures using vispy
Parameters
----------
block : bool
If True, blocking mode will be used. If False, then non-blocking
/ interactive mode will be used.
Returns
-------
canvases : list
List of the vispy canvases that were creat... | [
"def",
"show",
"(",
"block",
"=",
"False",
")",
":",
"if",
"not",
"has_matplotlib",
"(",
")",
":",
"raise",
"ImportError",
"(",
"'Requires matplotlib version >= 1.2'",
")",
"cs",
"=",
"[",
"_mpl_to_vispy",
"(",
"plt",
".",
"figure",
"(",
"ii",
")",
")",
... | Show current figures using vispy
Parameters
----------
block : bool
If True, blocking mode will be used. If False, then non-blocking
/ interactive mode will be used.
Returns
-------
canvases : list
List of the vispy canvases that were created. | [
"Show",
"current",
"figures",
"using",
"vispy"
] | python | train | 27.1 |
pandas-dev/pandas | pandas/core/groupby/groupby.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1938-L1947 | def cumprod(self, axis=0, *args, **kwargs):
"""
Cumulative product for each group.
"""
nv.validate_groupby_func('cumprod', args, kwargs,
['numeric_only', 'skipna'])
if axis != 0:
return self.apply(lambda x: x.cumprod(axis=axis, **kwarg... | [
"def",
"cumprod",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_groupby_func",
"(",
"'cumprod'",
",",
"args",
",",
"kwargs",
",",
"[",
"'numeric_only'",
",",
"'skipna'",
"]",
")",
"if",
... | Cumulative product for each group. | [
"Cumulative",
"product",
"for",
"each",
"group",
"."
] | python | train | 37.4 |
DataONEorg/d1_python | dev_tools/src/d1_dev/src-cleanup.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/dev_tools/src/d1_dev/src-cleanup.py#L332-L340 | def _remove_init_all(r):
"""Remove any __all__ in __init__.py file."""
new_r = redbaron.NodeList()
for n in r.node_list:
if n.type == 'assignment' and n.target.value == '__all__':
pass
else:
new_r.append(n)
return new_r | [
"def",
"_remove_init_all",
"(",
"r",
")",
":",
"new_r",
"=",
"redbaron",
".",
"NodeList",
"(",
")",
"for",
"n",
"in",
"r",
".",
"node_list",
":",
"if",
"n",
".",
"type",
"==",
"'assignment'",
"and",
"n",
".",
"target",
".",
"value",
"==",
"'__all__'"... | Remove any __all__ in __init__.py file. | [
"Remove",
"any",
"__all__",
"in",
"__init__",
".",
"py",
"file",
"."
] | python | train | 29.666667 |
cltk/cltk | cltk/corpus/arabic/utils/pyarabic/araby.py | https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/corpus/arabic/utils/pyarabic/araby.py#L948-L992 | def shaddalike(partial, fully):
"""
If the two words has the same letters and the same harakats, this fuction return True.
The first word is partially vocalized, the second is fully
if the partially contians a shadda, it must be at the same place in the fully
@param partial: the partially vocaliz... | [
"def",
"shaddalike",
"(",
"partial",
",",
"fully",
")",
":",
"# المدخل ليس به شدة، لا داعي للبحث",
"if",
"not",
"has_shadda",
"(",
"partial",
")",
":",
"return",
"True",
"# المدخل به شدة، والنتيجة ليس بها شدة، خاطئ",
"elif",
"not",
"has_shadda",
"(",
"fully",
")",
"... | If the two words has the same letters and the same harakats, this fuction return True.
The first word is partially vocalized, the second is fully
if the partially contians a shadda, it must be at the same place in the fully
@param partial: the partially vocalized word
@type partial: unicode
@para... | [
"If",
"the",
"two",
"words",
"has",
"the",
"same",
"letters",
"and",
"the",
"same",
"harakats",
"this",
"fuction",
"return",
"True",
".",
"The",
"first",
"word",
"is",
"partially",
"vocalized",
"the",
"second",
"is",
"fully",
"if",
"the",
"partially",
"con... | python | train | 35.511111 |
phfaist/pylatexenc | pylatexenc/latexwalker.py | https://github.com/phfaist/pylatexenc/blob/0c1788d1349e749501e67a6fba54d79e6e0d54f6/pylatexenc/latexwalker.py#L1269-L1281 | def get_latex_expression(s, pos, **parse_flags):
"""
Reads a latex expression, e.g. macro argument. This may be a single char, an escape
sequence, or a expression placed in braces.
Returns a tuple `(<LatexNode instance>, pos, len)`. `pos` is the first char of the
expression, and `len` is its length... | [
"def",
"get_latex_expression",
"(",
"s",
",",
"pos",
",",
"*",
"*",
"parse_flags",
")",
":",
"return",
"LatexWalker",
"(",
"s",
",",
"*",
"*",
"parse_flags",
")",
".",
"get_latex_expression",
"(",
"pos",
"=",
"pos",
")"
] | Reads a latex expression, e.g. macro argument. This may be a single char, an escape
sequence, or a expression placed in braces.
Returns a tuple `(<LatexNode instance>, pos, len)`. `pos` is the first char of the
expression, and `len` is its length.
.. deprecated:: 1.0
Please use :py:meth:`LatexW... | [
"Reads",
"a",
"latex",
"expression",
"e",
".",
"g",
".",
"macro",
"argument",
".",
"This",
"may",
"be",
"a",
"single",
"char",
"an",
"escape",
"sequence",
"or",
"a",
"expression",
"placed",
"in",
"braces",
"."
] | python | test | 37.461538 |
tornadoweb/tornado | tornado/web.py | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1182-L1218 | def send_error(self, status_code: int = 500, **kwargs: Any) -> None:
"""Sends the given HTTP error code to the browser.
If `flush()` has already been called, it is not possible to send
an error, so this method will simply terminate the response.
If output has been written but not yet fl... | [
"def",
"send_error",
"(",
"self",
",",
"status_code",
":",
"int",
"=",
"500",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"_headers_written",
":",
"gen_log",
".",
"error",
"(",
"\"Cannot send error response after headers w... | Sends the given HTTP error code to the browser.
If `flush()` has already been called, it is not possible to send
an error, so this method will simply terminate the response.
If output has been written but not yet flushed, it will be discarded
and replaced with the error page.
O... | [
"Sends",
"the",
"given",
"HTTP",
"error",
"code",
"to",
"the",
"browser",
"."
] | python | train | 43.864865 |
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#L79-L88 | def add(self, original_index, operation):
"""Add an operation to this Run instance.
:Parameters:
- `original_index`: The original index of this operation
within a larger bulk operation.
- `operation`: The operation document.
"""
self.index_map.append(orig... | [
"def",
"add",
"(",
"self",
",",
"original_index",
",",
"operation",
")",
":",
"self",
".",
"index_map",
".",
"append",
"(",
"original_index",
")",
"self",
".",
"ops",
".",
"append",
"(",
"operation",
")"
] | Add an operation to this Run instance.
:Parameters:
- `original_index`: The original index of this operation
within a larger bulk operation.
- `operation`: The operation document. | [
"Add",
"an",
"operation",
"to",
"this",
"Run",
"instance",
"."
] | python | train | 35.7 |
apache/incubator-mxnet | example/ssd/evaluate/eval_voc.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/eval_voc.py#L30-L49 | def parse_voc_rec(filename):
"""
parse pascal voc record into a dictionary
:param filename: xml file path
:return: list of dict
"""
import xml.etree.ElementTree as ET
tree = ET.parse(filename)
objects = []
for obj in tree.findall('object'):
obj_dict = dict()
obj_dict[... | [
"def",
"parse_voc_rec",
"(",
"filename",
")",
":",
"import",
"xml",
".",
"etree",
".",
"ElementTree",
"as",
"ET",
"tree",
"=",
"ET",
".",
"parse",
"(",
"filename",
")",
"objects",
"=",
"[",
"]",
"for",
"obj",
"in",
"tree",
".",
"findall",
"(",
"'obje... | parse pascal voc record into a dictionary
:param filename: xml file path
:return: list of dict | [
"parse",
"pascal",
"voc",
"record",
"into",
"a",
"dictionary",
":",
"param",
"filename",
":",
"xml",
"file",
"path",
":",
"return",
":",
"list",
"of",
"dict"
] | python | train | 35.5 |
sporteasy/python-poeditor | poeditor/client.py | https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L200-L219 | def update_project(self, project_id, name=None, description=None,
reference_language=None):
"""
Updates project settings (name, description, reference language)
If optional parameters are not sent, their respective fields are not updated.
"""
kwargs = {}
... | [
"def",
"update_project",
"(",
"self",
",",
"project_id",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"reference_language",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"name",
"is",
"not",
"None",
":",
"kwargs",
"[",
"'name... | Updates project settings (name, description, reference language)
If optional parameters are not sent, their respective fields are not updated. | [
"Updates",
"project",
"settings",
"(",
"name",
"description",
"reference",
"language",
")",
"If",
"optional",
"parameters",
"are",
"not",
"sent",
"their",
"respective",
"fields",
"are",
"not",
"updated",
"."
] | python | train | 36.1 |
richardcornish/django-pygmentify | pygmentify/utils/pygmentify.py | https://github.com/richardcornish/django-pygmentify/blob/a2d3f6b3c3019d810d46f6ff6beb4e9f53190e7b/pygmentify/utils/pygmentify.py#L12-L33 | def bits_to_dict(bits):
"""Convert a Django template tag's kwargs into a dictionary of Python types.
The only necessary types are number, boolean, list, and string.
http://pygments.org/docs/formatters/#HtmlFormatter
from: ["style='monokai'", "cssclass='cssclass',", "boolean='true',", 'num=0,', "list='... | [
"def",
"bits_to_dict",
"(",
"bits",
")",
":",
"# Strip any trailing commas",
"cleaned_bits",
"=",
"[",
"bit",
"[",
":",
"-",
"1",
"]",
"if",
"bit",
".",
"endswith",
"(",
"','",
")",
"else",
"bit",
"for",
"bit",
"in",
"bits",
"]",
"# Create dictionary by sp... | Convert a Django template tag's kwargs into a dictionary of Python types.
The only necessary types are number, boolean, list, and string.
http://pygments.org/docs/formatters/#HtmlFormatter
from: ["style='monokai'", "cssclass='cssclass',", "boolean='true',", 'num=0,', "list='[]'"]
to: {'style': 'mono... | [
"Convert",
"a",
"Django",
"template",
"tag",
"s",
"kwargs",
"into",
"a",
"dictionary",
"of",
"Python",
"types",
"."
] | python | train | 40.272727 |
nicfit/nicfit.py | nicfit/command.py | https://github.com/nicfit/nicfit.py/blob/8313f8edbc5e7361ddad496d6d818324b5236c7a/nicfit/command.py#L118-L135 | def loadCommandMap(Class, subparsers=None, instantiate=True, **cmd_kwargs):
"""Instantiate each registered command to a dict mapping name/alias to
instance.
Due to aliases, the returned length may be greater there the number of
commands, but the unique instance count will match.
... | [
"def",
"loadCommandMap",
"(",
"Class",
",",
"subparsers",
"=",
"None",
",",
"instantiate",
"=",
"True",
",",
"*",
"*",
"cmd_kwargs",
")",
":",
"if",
"not",
"Class",
".",
"_registered_commands",
":",
"raise",
"ValueError",
"(",
"\"No commands have been registered... | Instantiate each registered command to a dict mapping name/alias to
instance.
Due to aliases, the returned length may be greater there the number of
commands, but the unique instance count will match. | [
"Instantiate",
"each",
"registered",
"command",
"to",
"a",
"dict",
"mapping",
"name",
"/",
"alias",
"to",
"instance",
"."
] | python | test | 42.611111 |
MIT-LCP/wfdb-python | wfdb/io/annotation.py | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L1057-L1168 | def wrann(record_name, extension, sample, symbol=None, subtype=None, chan=None,
num=None, aux_note=None, label_store=None, fs=None,
custom_labels=None, write_dir=''):
"""
Write a WFDB annotation file.
Specify at least the following:
- The record name of the WFDB record (record_name... | [
"def",
"wrann",
"(",
"record_name",
",",
"extension",
",",
"sample",
",",
"symbol",
"=",
"None",
",",
"subtype",
"=",
"None",
",",
"chan",
"=",
"None",
",",
"num",
"=",
"None",
",",
"aux_note",
"=",
"None",
",",
"label_store",
"=",
"None",
",",
"fs",... | Write a WFDB annotation file.
Specify at least the following:
- The record name of the WFDB record (record_name)
- The annotation file extension (extension)
- The annotation locations in samples relative to the beginning of
the record (sample)
- Either the numerical values used to store the ... | [
"Write",
"a",
"WFDB",
"annotation",
"file",
"."
] | python | train | 43.446429 |
pandas-dev/pandas | pandas/core/internals/managers.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/managers.py#L120-L131 | def make_empty(self, axes=None):
""" return an empty BlockManager with the items axis of len 0 """
if axes is None:
axes = [ensure_index([])] + [ensure_index(a)
for a in self.axes[1:]]
# preserve dtype if possible
if self.ndim == 1:
... | [
"def",
"make_empty",
"(",
"self",
",",
"axes",
"=",
"None",
")",
":",
"if",
"axes",
"is",
"None",
":",
"axes",
"=",
"[",
"ensure_index",
"(",
"[",
"]",
")",
"]",
"+",
"[",
"ensure_index",
"(",
"a",
")",
"for",
"a",
"in",
"self",
".",
"axes",
"[... | return an empty BlockManager with the items axis of len 0 | [
"return",
"an",
"empty",
"BlockManager",
"with",
"the",
"items",
"axis",
"of",
"len",
"0"
] | python | train | 37.25 |
SethMMorton/natsort | natsort/natsort.py | https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/natsort.py#L222-L267 | def natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
"""
Sorts an iterable naturally.
Parameters
----------
seq : iterable
The input to sort.
key : callable, optional
A key used to determine how to sort each element of the iterable.
It is **not** applied recursi... | [
"def",
"natsorted",
"(",
"seq",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
",",
"alg",
"=",
"ns",
".",
"DEFAULT",
")",
":",
"key",
"=",
"natsort_keygen",
"(",
"key",
",",
"alg",
")",
"return",
"sorted",
"(",
"seq",
",",
"reverse",
"=",
... | Sorts an iterable naturally.
Parameters
----------
seq : iterable
The input to sort.
key : callable, optional
A key used to determine how to sort each element of the iterable.
It is **not** applied recursively.
It should accept a single argument and return a single valu... | [
"Sorts",
"an",
"iterable",
"naturally",
"."
] | python | train | 29.456522 |
mozilla-services/axe-selenium-python | axe_selenium_python/axe.py | https://github.com/mozilla-services/axe-selenium-python/blob/475c9f4eb771587aea73897bee356284d0361d77/axe_selenium_python/axe.py#L96-L115 | def write_results(self, data, name=None):
"""
Write JSON to file with the specified name.
:param name: Path to the file to be written to. If no path is passed
a new JSON file "results.json" will be created in the
current working directory.
:para... | [
"def",
"write_results",
"(",
"self",
",",
"data",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"name",
")",
"else",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os"... | Write JSON to file with the specified name.
:param name: Path to the file to be written to. If no path is passed
a new JSON file "results.json" will be created in the
current working directory.
:param output: JSON object. | [
"Write",
"JSON",
"to",
"file",
"with",
"the",
"specified",
"name",
"."
] | python | train | 34.95 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/management/commands/audit-sync.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/audit-sync.py#L125-L138 | async def is_object_synced_to_cn(self, client, pid):
"""Check if object with {pid} has successfully synced to the CN.
CNRead.describe() is used as it's a light-weight HTTP HEAD request.
This assumes that the call is being made over a connection that has been
authenticated and has read ... | [
"async",
"def",
"is_object_synced_to_cn",
"(",
"self",
",",
"client",
",",
"pid",
")",
":",
"try",
":",
"await",
"client",
".",
"describe",
"(",
"pid",
")",
"except",
"d1_common",
".",
"types",
".",
"exceptions",
".",
"DataONEException",
":",
"return",
"Fa... | Check if object with {pid} has successfully synced to the CN.
CNRead.describe() is used as it's a light-weight HTTP HEAD request.
This assumes that the call is being made over a connection that has been
authenticated and has read or better access on the given object if it exists. | [
"Check",
"if",
"object",
"with",
"{",
"pid",
"}",
"has",
"successfully",
"synced",
"to",
"the",
"CN",
"."
] | python | train | 37.642857 |
JoelBender/bacpypes | samples/TCPClient.py | https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/samples/TCPClient.py#L107-L182 | def main():
"""
Main function, called when run as an application.
"""
global args, server_address
# parse the command line arguments
parser = ArgumentParser(description=__doc__)
parser.add_argument(
"host", nargs='?',
help="address of host (default %r)" % (SERVER_HOST,),
... | [
"def",
"main",
"(",
")",
":",
"global",
"args",
",",
"server_address",
"# parse the command line arguments",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"\"host\"",
",",
"nargs",
"=",
"'?'",
",",
... | Main function, called when run as an application. | [
"Main",
"function",
"called",
"when",
"run",
"as",
"an",
"application",
"."
] | python | train | 28.421053 |
mitsei/dlkit | dlkit/handcar/learning/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/sessions.py#L4264-L4274 | def get_root_objective_bank_ids(self, alias):
"""Gets the root objective bank Ids in this hierarchy.
return: (osid.id.IdList) - the root objective bank Ids
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
compliance: mandatory... | [
"def",
"get_root_objective_bank_ids",
"(",
"self",
",",
"alias",
")",
":",
"url_path",
"=",
"self",
".",
"_urls",
".",
"roots",
"(",
"alias",
")",
"return",
"self",
".",
"_get_request",
"(",
"url_path",
")"
] | Gets the root objective bank Ids in this hierarchy.
return: (osid.id.IdList) - the root objective bank Ids
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
compliance: mandatory - This method must be implemented. | [
"Gets",
"the",
"root",
"objective",
"bank",
"Ids",
"in",
"this",
"hierarchy",
"."
] | python | train | 40.363636 |
fedora-infra/fedmsg | fedmsg/utils.py | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/utils.py#L120-L136 | def load_class(location):
""" Take a string of the form 'fedmsg.consumers.ircbot:IRCBotConsumer'
and return the IRCBotConsumer class.
"""
mod_name, cls_name = location = location.strip().split(':')
tokens = mod_name.split('.')
fromlist = '[]'
if len(tokens) > 1:
fromlist = '.'.join(... | [
"def",
"load_class",
"(",
"location",
")",
":",
"mod_name",
",",
"cls_name",
"=",
"location",
"=",
"location",
".",
"strip",
"(",
")",
".",
"split",
"(",
"':'",
")",
"tokens",
"=",
"mod_name",
".",
"split",
"(",
"'.'",
")",
"fromlist",
"=",
"'[]'",
"... | Take a string of the form 'fedmsg.consumers.ircbot:IRCBotConsumer'
and return the IRCBotConsumer class. | [
"Take",
"a",
"string",
"of",
"the",
"form",
"fedmsg",
".",
"consumers",
".",
"ircbot",
":",
"IRCBotConsumer",
"and",
"return",
"the",
"IRCBotConsumer",
"class",
"."
] | python | train | 30.529412 |
pkgw/pwkit | pwkit/environments/casa/closures.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/closures.py#L753-L780 | def _process_sample (self, ap1, ap2, ap3, triple, tflags):
"""We have computed one independent phase closure triple in one timeslot.
"""
# Frequency-resolved:
np.divide (triple, np.abs (triple), triple)
phase = np.angle (triple)
self.ap_spec_stats_by_ddid[self.cur_ddid]... | [
"def",
"_process_sample",
"(",
"self",
",",
"ap1",
",",
"ap2",
",",
"ap3",
",",
"triple",
",",
"tflags",
")",
":",
"# Frequency-resolved:",
"np",
".",
"divide",
"(",
"triple",
",",
"np",
".",
"abs",
"(",
"triple",
")",
",",
"triple",
")",
"phase",
"=... | We have computed one independent phase closure triple in one timeslot. | [
"We",
"have",
"computed",
"one",
"independent",
"phase",
"closure",
"triple",
"in",
"one",
"timeslot",
"."
] | python | train | 47.642857 |
AustralianSynchrotron/lightflow | lightflow/models/datastore.py | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/datastore.py#L248-L270 | def get(self, key, default=None, *, section=DataStoreDocumentSection.Data):
""" Return the field specified by its key from the specified section.
This method access the specified section of the workflow document and returns the
value for the given key.
Args:
key (str): The ... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
",",
"*",
",",
"section",
"=",
"DataStoreDocumentSection",
".",
"Data",
")",
":",
"key_notation",
"=",
"'.'",
".",
"join",
"(",
"[",
"section",
",",
"key",
"]",
")",
"try",
":",
"r... | Return the field specified by its key from the specified section.
This method access the specified section of the workflow document and returns the
value for the given key.
Args:
key (str): The key pointing to the value that should be retrieved. It supports
MongoDB'... | [
"Return",
"the",
"field",
"specified",
"by",
"its",
"key",
"from",
"the",
"specified",
"section",
"."
] | python | train | 48 |
mottosso/be | be/vendor/requests/utils.py | https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L276-L285 | def add_dict_to_cookiejar(cj, cookie_dict):
"""Returns a CookieJar from a key/value dictionary.
:param cj: CookieJar to insert cookies into.
:param cookie_dict: Dict of key/values to insert into CookieJar.
"""
cj2 = cookiejar_from_dict(cookie_dict)
cj.update(cj2)
return cj | [
"def",
"add_dict_to_cookiejar",
"(",
"cj",
",",
"cookie_dict",
")",
":",
"cj2",
"=",
"cookiejar_from_dict",
"(",
"cookie_dict",
")",
"cj",
".",
"update",
"(",
"cj2",
")",
"return",
"cj"
] | Returns a CookieJar from a key/value dictionary.
:param cj: CookieJar to insert cookies into.
:param cookie_dict: Dict of key/values to insert into CookieJar. | [
"Returns",
"a",
"CookieJar",
"from",
"a",
"key",
"/",
"value",
"dictionary",
"."
] | python | train | 29.4 |
thanethomson/statik | statik/errors.py | https://github.com/thanethomson/statik/blob/56b1b5a2cb05a97afa81f428bfcefc833e935b8d/statik/errors.py#L87-L96 | def render(self, context=None):
"""Renders the error message, optionally using the given context (which, if specified,
will override the internal context)."""
ctx = context.render() if context else self.get_error_context().render()
return "%s: %s%s%s" % (
self.get_error_kind(... | [
"def",
"render",
"(",
"self",
",",
"context",
"=",
"None",
")",
":",
"ctx",
"=",
"context",
".",
"render",
"(",
")",
"if",
"context",
"else",
"self",
".",
"get_error_context",
"(",
")",
".",
"render",
"(",
")",
"return",
"\"%s: %s%s%s\"",
"%",
"(",
"... | Renders the error message, optionally using the given context (which, if specified,
will override the internal context). | [
"Renders",
"the",
"error",
"message",
"optionally",
"using",
"the",
"given",
"context",
"(",
"which",
"if",
"specified",
"will",
"override",
"the",
"internal",
"context",
")",
"."
] | python | train | 45.3 |
wandb/client | wandb/vendor/prompt_toolkit/terminal/vt100_output.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/terminal/vt100_output.py#L344-L368 | def _get_size(fileno):
# Thanks to fabric (fabfile.org), and
# http://sqizit.bartletts.id.au/2011/02/14/pseudo-terminals-in-python/
"""
Get the size of this pseudo terminal.
:param fileno: stdout.fileno()
:returns: A (rows, cols) tuple.
"""
# Inline imports, because these modules are no... | [
"def",
"_get_size",
"(",
"fileno",
")",
":",
"# Thanks to fabric (fabfile.org), and",
"# http://sqizit.bartletts.id.au/2011/02/14/pseudo-terminals-in-python/",
"# Inline imports, because these modules are not available on Windows.",
"# (This file is used by ConEmuOutput, which is used on Windows.)... | Get the size of this pseudo terminal.
:param fileno: stdout.fileno()
:returns: A (rows, cols) tuple. | [
"Get",
"the",
"size",
"of",
"this",
"pseudo",
"terminal",
"."
] | python | train | 35.32 |
stitchfix/pyxley | pyxley/charts/nvd3/pie_chart.py | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/nvd3/pie_chart.py#L57-L71 | def to_json(df, values):
"""Format output for the json response."""
records = []
if df.empty:
return {"data": []}
sum_ = float(np.sum([df[c].iloc[0] for c in values]))
for c in values:
records.append({
"label": values[c],
"... | [
"def",
"to_json",
"(",
"df",
",",
"values",
")",
":",
"records",
"=",
"[",
"]",
"if",
"df",
".",
"empty",
":",
"return",
"{",
"\"data\"",
":",
"[",
"]",
"}",
"sum_",
"=",
"float",
"(",
"np",
".",
"sum",
"(",
"[",
"df",
"[",
"c",
"]",
".",
"... | Format output for the json response. | [
"Format",
"output",
"for",
"the",
"json",
"response",
"."
] | python | train | 29.266667 |
CalebBell/fluids | fluids/geometry.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1804-L1841 | def set_chebyshev_approximators(self, deg_forward=50, deg_backwards=200):
r'''Method to derive and set coefficients for chebyshev polynomial
function approximation of the height-volume and volume-height
relationship.
A single set of chebyshev coefficients is used for t... | [
"def",
"set_chebyshev_approximators",
"(",
"self",
",",
"deg_forward",
"=",
"50",
",",
"deg_backwards",
"=",
"200",
")",
":",
"from",
"fluids",
".",
"optional",
".",
"pychebfun",
"import",
"Chebfun",
"to_fit",
"=",
"lambda",
"h",
":",
"self",
".",
"V_from_h"... | r'''Method to derive and set coefficients for chebyshev polynomial
function approximation of the height-volume and volume-height
relationship.
A single set of chebyshev coefficients is used for the entire height-
volume and volume-height relationships respectively.
... | [
"r",
"Method",
"to",
"derive",
"and",
"set",
"coefficients",
"for",
"chebyshev",
"polynomial",
"function",
"approximation",
"of",
"the",
"height",
"-",
"volume",
"and",
"volume",
"-",
"height",
"relationship",
".",
"A",
"single",
"set",
"of",
"chebyshev",
"coe... | python | train | 50.763158 |
bernieke/python-magento | magento/magento_api.py | https://github.com/bernieke/python-magento/blob/bfd23e233905b1b1491a7c07b9d833dfebd70456/magento/magento_api.py#L118-L127 | def keep_session_alive(self):
"""If the session expired, logs back in."""
try:
self.resources()
except xmlrpclib.Fault as fault:
if fault.faultCode == 5:
self.login()
else:
raise | [
"def",
"keep_session_alive",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"resources",
"(",
")",
"except",
"xmlrpclib",
".",
"Fault",
"as",
"fault",
":",
"if",
"fault",
".",
"faultCode",
"==",
"5",
":",
"self",
".",
"login",
"(",
")",
"else",
":",... | If the session expired, logs back in. | [
"If",
"the",
"session",
"expired",
"logs",
"back",
"in",
"."
] | python | train | 26.2 |
kata198/AdvancedHTMLParser | AdvancedHTMLParser/Parser.py | https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L940-L969 | def createElementsFromHTML(cls, html, encoding='utf-8'):
'''
createElementsFromHTML - Creates elements from provided html, and returns a list of the root-level elements
children of these root-level nodes are accessable via the usual means.
@param html <str> - Some html d... | [
"def",
"createElementsFromHTML",
"(",
"cls",
",",
"html",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"# TODO: If text is present outside a tag, it will be lost.",
"parser",
"=",
"cls",
"(",
"encoding",
"=",
"encoding",
")",
"parser",
".",
"parseStr",
"(",
"html",
... | createElementsFromHTML - Creates elements from provided html, and returns a list of the root-level elements
children of these root-level nodes are accessable via the usual means.
@param html <str> - Some html data
@param encoding <str> - Encoding to use for document
... | [
"createElementsFromHTML",
"-",
"Creates",
"elements",
"from",
"provided",
"html",
"and",
"returns",
"a",
"list",
"of",
"the",
"root",
"-",
"level",
"elements",
"children",
"of",
"these",
"root",
"-",
"level",
"nodes",
"are",
"accessable",
"via",
"the",
"usual"... | python | train | 35.466667 |
coghost/izen | izen/helper.py | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L670-L673 | def l_endian(v):
""" 小端序 """
w = struct.pack('<H', v)
return str(binascii.hexlify(w), encoding='gbk') | [
"def",
"l_endian",
"(",
"v",
")",
":",
"w",
"=",
"struct",
".",
"pack",
"(",
"'<H'",
",",
"v",
")",
"return",
"str",
"(",
"binascii",
".",
"hexlify",
"(",
"w",
")",
",",
"encoding",
"=",
"'gbk'",
")"
] | 小端序 | [
"小端序"
] | python | train | 27.5 |
coldfix/udiskie | udiskie/async_.py | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/async_.py#L82-L87 | def set_exception(self, exception):
"""Signal unsuccessful completion."""
was_handled = self._finish(self.errbacks, exception)
if not was_handled:
traceback.print_exception(
type(exception), exception, exception.__traceback__) | [
"def",
"set_exception",
"(",
"self",
",",
"exception",
")",
":",
"was_handled",
"=",
"self",
".",
"_finish",
"(",
"self",
".",
"errbacks",
",",
"exception",
")",
"if",
"not",
"was_handled",
":",
"traceback",
".",
"print_exception",
"(",
"type",
"(",
"excep... | Signal unsuccessful completion. | [
"Signal",
"unsuccessful",
"completion",
"."
] | python | train | 45.5 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L10698-L10723 | def set_position_target_global_int_send(self, time_boot_ms, target_system, target_component, coordinate_frame, type_mask, lat_int, lon_int, alt, vx, vy, vz, afx, afy, afz, yaw, yaw_rate, force_mavlink1=False):
'''
Sets a desired vehicle position, velocity, and/or acceleration in a
... | [
"def",
"set_position_target_global_int_send",
"(",
"self",
",",
"time_boot_ms",
",",
"target_system",
",",
"target_component",
",",
"coordinate_frame",
",",
"type_mask",
",",
"lat_int",
",",
"lon_int",
",",
"alt",
",",
"vx",
",",
"vy",
",",
"vz",
",",
"afx",
"... | Sets a desired vehicle position, velocity, and/or acceleration in a
global coordinate system (WGS84). Used by an external
controller to command the vehicle (manual controller
or other system).
time_boot_ms : Timestamp in milliseconds since sy... | [
"Sets",
"a",
"desired",
"vehicle",
"position",
"velocity",
"and",
"/",
"or",
"acceleration",
"in",
"a",
"global",
"coordinate",
"system",
"(",
"WGS84",
")",
".",
"Used",
"by",
"an",
"external",
"controller",
"to",
"command",
"the",
"vehicle",
"(",
"manual",
... | python | train | 116.192308 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_lldp_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_lldp_ext.py#L140-L156 | def get_lldp_neighbor_detail_output_lldp_neighbor_detail_remote_interface_mac(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_lldp_neighbor_detail = ET.Element("get_lldp_neighbor_detail")
config = get_lldp_neighbor_detail
output = ET.SubEleme... | [
"def",
"get_lldp_neighbor_detail_output_lldp_neighbor_detail_remote_interface_mac",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_lldp_neighbor_detail",
"=",
"ET",
".",
"Element",
"(",
"\"get_lldp_nei... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 59.764706 |
Diviyan-Kalainathan/CausalDiscoveryToolbox | cdt/generators/acyclic_graph_generator.py | https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/acyclic_graph_generator.py#L77-L97 | def init_variables(self, verbose=False):
"""Redefine the causes of the graph."""
for j in range(1, self.nodes):
nb_parents = np.random.randint(0, min([self.parents_max, j])+1)
for i in np.random.choice(range(0, j), nb_parents, replace=False):
self.adjacency_matrix... | [
"def",
"init_variables",
"(",
"self",
",",
"verbose",
"=",
"False",
")",
":",
"for",
"j",
"in",
"range",
"(",
"1",
",",
"self",
".",
"nodes",
")",
":",
"nb_parents",
"=",
"np",
".",
"random",
".",
"randint",
"(",
"0",
",",
"min",
"(",
"[",
"self"... | Redefine the causes of the graph. | [
"Redefine",
"the",
"causes",
"of",
"the",
"graph",
"."
] | python | valid | 44.142857 |
python-cmd2/cmd2 | cmd2/cmd2.py | https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/cmd2/cmd2.py#L1012-L1154 | def path_complete(self, text: str, line: str, begidx: int, endidx: int,
path_filter: Optional[Callable[[str], bool]] = None) -> List[str]:
"""Performs completion of local file system paths
:param text: the string prefix we are attempting to match (all returned matches must begin w... | [
"def",
"path_complete",
"(",
"self",
",",
"text",
":",
"str",
",",
"line",
":",
"str",
",",
"begidx",
":",
"int",
",",
"endidx",
":",
"int",
",",
"path_filter",
":",
"Optional",
"[",
"Callable",
"[",
"[",
"str",
"]",
",",
"bool",
"]",
"]",
"=",
"... | Performs completion of local file system paths
:param text: the string prefix we are attempting to match (all returned matches must begin with it)
:param line: the current input line with leading whitespace removed
:param begidx: the beginning index of the prefix text
:param endidx: the... | [
"Performs",
"completion",
"of",
"local",
"file",
"system",
"paths"
] | python | train | 41.307692 |
edx/edx-enterprise | integrated_channels/degreed/client.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/degreed/client.py#L190-L211 | def _create_session(self, scope):
"""
Instantiate a new session object for use in connecting with Degreed
"""
now = datetime.datetime.utcnow()
if self.session is None or self.expires_at is None or now >= self.expires_at:
# Create a new session with a valid token
... | [
"def",
"_create_session",
"(",
"self",
",",
"scope",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"if",
"self",
".",
"session",
"is",
"None",
"or",
"self",
".",
"expires_at",
"is",
"None",
"or",
"now",
">=",
"self",
"."... | Instantiate a new session object for use in connecting with Degreed | [
"Instantiate",
"a",
"new",
"session",
"object",
"for",
"use",
"in",
"connecting",
"with",
"Degreed"
] | python | valid | 46.636364 |
wq/django-natural-keys | natural_keys/models.py | https://github.com/wq/django-natural-keys/blob/f6bd6baf848e709ae9920b259a3ad1a6be8af615/natural_keys/models.py#L38-L70 | def get_by_natural_key(self, *args):
"""
Return the object corresponding to the provided natural key.
(This is a generic implementation of the standard Django function)
"""
kwargs = self.natural_key_kwargs(*args)
# Since kwargs already has __ lookups in it, we could ju... | [
"def",
"get_by_natural_key",
"(",
"self",
",",
"*",
"args",
")",
":",
"kwargs",
"=",
"self",
".",
"natural_key_kwargs",
"(",
"*",
"args",
")",
"# Since kwargs already has __ lookups in it, we could just do this:",
"# return self.get(**kwargs)",
"# But, we should call each rel... | Return the object corresponding to the provided natural key.
(This is a generic implementation of the standard Django function) | [
"Return",
"the",
"object",
"corresponding",
"to",
"the",
"provided",
"natural",
"key",
"."
] | python | train | 35.515152 |
crocs-muni/roca | roca/detect.py | https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L1808-L1840 | def process_apk(self, data, name):
"""
Processes Android application
:param data:
:param name:
:return:
"""
try:
from apk_parse.apk import APK
except Exception as e:
logger.warning('Could not import apk_parse, try running: pip insta... | [
"def",
"process_apk",
"(",
"self",
",",
"data",
",",
"name",
")",
":",
"try",
":",
"from",
"apk_parse",
".",
"apk",
"import",
"APK",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",
"warning",
"(",
"'Could not import apk_parse, try running: pip install apk_... | Processes Android application
:param data:
:param name:
:return: | [
"Processes",
"Android",
"application",
":",
"param",
"data",
":",
":",
"param",
"name",
":",
":",
"return",
":"
] | python | train | 34.818182 |
buriburisuri/sugartensor | sugartensor/sg_logging.py | https://github.com/buriburisuri/sugartensor/blob/d2c039954777c7fbe3eb0c2ae40c45c9854deb40/sugartensor/sg_logging.py#L142-L160 | def sg_summary_audio(tensor, sample_rate=16000, prefix=None, name=None):
r"""Register `tensor` to summary report as audio
Args:
tensor: A `Tensor` to log as audio
sample_rate : An int. Sample rate to report. Default is 16000.
prefix: A `string`. A prefix to display in the tensor board web UI.... | [
"def",
"sg_summary_audio",
"(",
"tensor",
",",
"sample_rate",
"=",
"16000",
",",
"prefix",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# defaults",
"prefix",
"=",
"''",
"if",
"prefix",
"is",
"None",
"else",
"prefix",
"+",
"'/'",
"# summary name",
"... | r"""Register `tensor` to summary report as audio
Args:
tensor: A `Tensor` to log as audio
sample_rate : An int. Sample rate to report. Default is 16000.
prefix: A `string`. A prefix to display in the tensor board web UI.
name: A `string`. A name to display in the tensor board web UI.
R... | [
"r",
"Register",
"tensor",
"to",
"summary",
"report",
"as",
"audio"
] | python | train | 36.631579 |
heuer/segno | segno/encoder.py | https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1511-L1527 | def is_mode_supported(mode, ver):
"""\
Returns if `mode` is supported by `version`.
Note: This function does not check if `version` is actually a valid
(Micro) QR Code version. Invalid versions like ``41`` may return an illegal
value.
:param int mode: Canonicalized mode.
:param int or None... | [
"def",
"is_mode_supported",
"(",
"mode",
",",
"ver",
")",
":",
"ver",
"=",
"None",
"if",
"ver",
">",
"0",
"else",
"ver",
"try",
":",
"return",
"ver",
"in",
"consts",
".",
"SUPPORTED_MODES",
"[",
"mode",
"]",
"except",
"KeyError",
":",
"raise",
"ModeErr... | \
Returns if `mode` is supported by `version`.
Note: This function does not check if `version` is actually a valid
(Micro) QR Code version. Invalid versions like ``41`` may return an illegal
value.
:param int mode: Canonicalized mode.
:param int or None ver: (Micro) QR Code version constant.
... | [
"\\",
"Returns",
"if",
"mode",
"is",
"supported",
"by",
"version",
"."
] | python | train | 31.941176 |
chaoss/grimoirelab-sigils | src/migration/utils.py | https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/utils.py#L40-L58 | def replace(pretty, old_str, new_str):
""" Replace strings giving some info on where
the replacement was done
"""
out_str = ''
line_number = 1
changes = 0
for line in pretty.splitlines(keepends=True):
new_line = line.replace(old_str, new_str)
if line.find(old_str) != -1:
... | [
"def",
"replace",
"(",
"pretty",
",",
"old_str",
",",
"new_str",
")",
":",
"out_str",
"=",
"''",
"line_number",
"=",
"1",
"changes",
"=",
"0",
"for",
"line",
"in",
"pretty",
".",
"splitlines",
"(",
"keepends",
"=",
"True",
")",
":",
"new_line",
"=",
... | Replace strings giving some info on where
the replacement was done | [
"Replace",
"strings",
"giving",
"some",
"info",
"on",
"where",
"the",
"replacement",
"was",
"done"
] | python | train | 30.736842 |
FNNDSC/med2image | med2image/message.py | https://github.com/FNNDSC/med2image/blob/638d5d230de47608af20f9764acf8e382c2bf2ff/med2image/message.py#L142-L157 | def socket_parse(self, astr_destination):
'''
Examines <astr_destination> and if of form <str1>:<str2> assumes
that <str1> is a host to send datagram comms to over port <str2>.
Returns True or False.
'''
t_socketInfo = astr_destination.partition(':')
if ... | [
"def",
"socket_parse",
"(",
"self",
",",
"astr_destination",
")",
":",
"t_socketInfo",
"=",
"astr_destination",
".",
"partition",
"(",
"':'",
")",
"if",
"len",
"(",
"t_socketInfo",
"[",
"1",
"]",
")",
":",
"self",
".",
"_b_isSocket",
"=",
"True",
"self",
... | Examines <astr_destination> and if of form <str1>:<str2> assumes
that <str1> is a host to send datagram comms to over port <str2>.
Returns True or False. | [
"Examines",
"<astr_destination",
">",
"and",
"if",
"of",
"form",
"<str1",
">",
":",
"<str2",
">",
"assumes",
"that",
"<str1",
">",
"is",
"a",
"host",
"to",
"send",
"datagram",
"comms",
"to",
"over",
"port",
"<str2",
">",
"."
] | python | train | 34.4375 |
timothydmorton/isochrones | isochrones/starmodel_old.py | https://github.com/timothydmorton/isochrones/blob/d84495573044c66db2fd6b959fe69e370757ea14/isochrones/starmodel_old.py#L1044-L1092 | def save_hdf(self, filename, path='', overwrite=False, append=False):
"""Saves object data to HDF file (only works if MCMC is run)
Samples are saved to /samples location under given path,
and object properties are also attached, so suitable for
re-loading via :func:`StarModel.load_hdf`.... | [
"def",
"save_hdf",
"(",
"self",
",",
"filename",
",",
"path",
"=",
"''",
",",
"overwrite",
"=",
"False",
",",
"append",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"store",
"=",
"pd",
".",
"HDFStore",
... | Saves object data to HDF file (only works if MCMC is run)
Samples are saved to /samples location under given path,
and object properties are also attached, so suitable for
re-loading via :func:`StarModel.load_hdf`.
:param filename:
Name of file to save to. Should b... | [
"Saves",
"object",
"data",
"to",
"HDF",
"file",
"(",
"only",
"works",
"if",
"MCMC",
"is",
"run",
")"
] | python | train | 34.285714 |
akfullfo/taskforce | taskforce/utils.py | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L221-L238 | def setproctitle(text):
"""
This is a wrapper for setproctitle.setproctitle(). The call sets
'text' as the new process title and returns the previous value.
The module is commonly not installed. If missing, nothing is changed,
and the call returns None.
The module is described here: https://... | [
"def",
"setproctitle",
"(",
"text",
")",
":",
"try",
":",
"import",
"setproctitle",
"except",
"Exception",
"as",
"e",
":",
"return",
"None",
"else",
":",
"# pragma: no cover",
"prev",
"=",
"setproctitle",
".",
"getproctitle",
"(",
")",
"setproctitle",
".",
"... | This is a wrapper for setproctitle.setproctitle(). The call sets
'text' as the new process title and returns the previous value.
The module is commonly not installed. If missing, nothing is changed,
and the call returns None.
The module is described here: https://pypi.python.org/pypi/setproctitle | [
"This",
"is",
"a",
"wrapper",
"for",
"setproctitle",
".",
"setproctitle",
"()",
".",
"The",
"call",
"sets",
"text",
"as",
"the",
"new",
"process",
"title",
"and",
"returns",
"the",
"previous",
"value",
"."
] | python | train | 35.666667 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.