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 |
|---|---|---|---|---|---|---|---|---|---|
lemieuxl/pyGenClean | pyGenClean/Ethnicity/find_outliers.py | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L620-L649 | def checkArgs(args):
"""Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is rai... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Checking the input files",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"args",
".",
"mds",
")",
":",
"msg",
"=",
"\"{}: no such file\"",
".",
"format",
"(",
"args",
".",
"mds",
")",
"raise",
"ProgramE... | Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | python | train | 30.066667 |
twilio/twilio-python | twilio/rest/preview/marketplace/available_add_on/available_add_on_extension.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/marketplace/available_add_on/available_add_on_extension.py#L179-L192 | def get_instance(self, payload):
"""
Build an instance of AvailableAddOnExtensionInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance
:rtype: twilio.rest... | [
"def",
"get_instance",
"(",
"self",
",",
"payload",
")",
":",
"return",
"AvailableAddOnExtensionInstance",
"(",
"self",
".",
"_version",
",",
"payload",
",",
"available_add_on_sid",
"=",
"self",
".",
"_solution",
"[",
"'available_add_on_sid'",
"]",
",",
")"
] | Build an instance of AvailableAddOnExtensionInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance
:rtype: twilio.rest.preview.marketplace.available_add_on.available_add_o... | [
"Build",
"an",
"instance",
"of",
"AvailableAddOnExtensionInstance"
] | python | train | 42.428571 |
materialsproject/pymatgen | pymatgen/io/abinit/tasks.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L4556-L4569 | def filesfile_string(self):
"""String with the list of files and prefixes needed to execute ABINIT."""
lines = []
app = lines.append
app(self.input_file.path) # 1) Path of the input file
app(self.output_file.path) # 2) Path of the output file
app(self.dd... | [
"def",
"filesfile_string",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"app",
"=",
"lines",
".",
"append",
"app",
"(",
"self",
".",
"input_file",
".",
"path",
")",
"# 1) Path of the input file",
"app",
"(",
"self",
".",
"output_file",
".",
"path",
")"... | String with the list of files and prefixes needed to execute ABINIT. | [
"String",
"with",
"the",
"list",
"of",
"files",
"and",
"prefixes",
"needed",
"to",
"execute",
"ABINIT",
"."
] | python | train | 55.428571 |
thunder-project/thunder | thunder/images/readers.py | https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/images/readers.py#L159-L221 | def frompath(path, accessor=None, ext=None, start=None, stop=None, recursive=False, npartitions=None, dims=None, dtype=None, labels=None, recount=False, engine=None, credentials=None):
"""
Load images from a path using the given accessor.
Supports both local and remote filesystems.
Parameters
----... | [
"def",
"frompath",
"(",
"path",
",",
"accessor",
"=",
"None",
",",
"ext",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"recursive",
"=",
"False",
",",
"npartitions",
"=",
"None",
",",
"dims",
"=",
"None",
",",
"dtype",
"="... | Load images from a path using the given accessor.
Supports both local and remote filesystems.
Parameters
----------
accessor : function
Apply to each item after loading to yield an image.
ext : str, optional, default=None
File extension.
npartitions : int, optional, default=N... | [
"Load",
"images",
"from",
"a",
"path",
"using",
"the",
"given",
"accessor",
"."
] | python | train | 34.571429 |
nschloe/matplotlib2tikz | matplotlib2tikz/save.py | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/save.py#L293-L309 | def _print_pgfplot_libs_message(data):
"""Prints message to screen indicating the use of PGFPlots and its
libraries."""
pgfplotslibs = ",".join(list(data["pgfplots libs"]))
tikzlibs = ",".join(list(data["tikz libs"]))
print(70 * "=")
print("Please add the following lines to your LaTeX preamble:... | [
"def",
"_print_pgfplot_libs_message",
"(",
"data",
")",
":",
"pgfplotslibs",
"=",
"\",\"",
".",
"join",
"(",
"list",
"(",
"data",
"[",
"\"pgfplots libs\"",
"]",
")",
")",
"tikzlibs",
"=",
"\",\"",
".",
"join",
"(",
"list",
"(",
"data",
"[",
"\"tikz libs\""... | Prints message to screen indicating the use of PGFPlots and its
libraries. | [
"Prints",
"message",
"to",
"screen",
"indicating",
"the",
"use",
"of",
"PGFPlots",
"and",
"its",
"libraries",
"."
] | python | train | 38 |
hawkular/hawkular-client-python | hawkular/alerts/triggers.py | https://github.com/hawkular/hawkular-client-python/blob/52371f9ebabbe310efee2a8ff8eb735ccc0654bb/hawkular/alerts/triggers.py#L234-L243 | def delete_group(self, group_id, keep_non_orphans=False, keep_orphans=False):
"""
Delete a group trigger
:param group_id: ID of the group trigger to delete
:param keep_non_orphans: if True converts the non-orphan member triggers to standard triggers
:param keep_orphans: if True ... | [
"def",
"delete_group",
"(",
"self",
",",
"group_id",
",",
"keep_non_orphans",
"=",
"False",
",",
"keep_orphans",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'keepNonOrphans'",
":",
"str",
"(",
"keep_non_orphans",
")",
".",
"lower",
"(",
")",
",",
"'keepOr... | Delete a group trigger
:param group_id: ID of the group trigger to delete
:param keep_non_orphans: if True converts the non-orphan member triggers to standard triggers
:param keep_orphans: if True converts the orphan member triggers to standard triggers | [
"Delete",
"a",
"group",
"trigger"
] | python | train | 57.7 |
sashahart/cookies | cookies.py | https://github.com/sashahart/cookies/blob/ab8185e06f221eaf65305f15e05852393723ac95/cookies.py#L502-L511 | def valid_path(value):
"Validate a cookie path ASCII string"
# Generate UnicodeDecodeError if path can't store as ASCII.
value.encode("ascii")
# Cookies without leading slash will likely be ignored, raise ASAP.
if not (value and value[0] == "/"):
return False
if not Definitions.PATH_RE.m... | [
"def",
"valid_path",
"(",
"value",
")",
":",
"# Generate UnicodeDecodeError if path can't store as ASCII.",
"value",
".",
"encode",
"(",
"\"ascii\"",
")",
"# Cookies without leading slash will likely be ignored, raise ASAP.",
"if",
"not",
"(",
"value",
"and",
"value",
"[",
... | Validate a cookie path ASCII string | [
"Validate",
"a",
"cookie",
"path",
"ASCII",
"string"
] | python | train | 36 |
konstantinstadler/country_converter | country_converter/country_converter.py | https://github.com/konstantinstadler/country_converter/blob/b78622dfa6700480df632fe061d6837b96f31b71/country_converter/country_converter.py#L639-L656 | def obsoleteas(self, to='name_short'):
"""
Return obsolete countries in the specified classification
Parameters
----------
to : str, optional
Output classification (valid str for an index of
country_data file), default: name_short
Returns
... | [
"def",
"obsoleteas",
"(",
"self",
",",
"to",
"=",
"'name_short'",
")",
":",
"if",
"isinstance",
"(",
"to",
",",
"str",
")",
":",
"to",
"=",
"[",
"to",
"]",
"return",
"self",
".",
"data",
"[",
"self",
".",
"data",
".",
"obsolete",
">",
"0",
"]",
... | Return obsolete countries in the specified classification
Parameters
----------
to : str, optional
Output classification (valid str for an index of
country_data file), default: name_short
Returns
-------
Pandas DataFrame | [
"Return",
"obsolete",
"countries",
"in",
"the",
"specified",
"classification"
] | python | train | 25.333333 |
dmlc/xgboost | python-package/xgboost/core.py | https://github.com/dmlc/xgboost/blob/253fdd8a42d5ec6b819788199584d27bf9ea6253/python-package/xgboost/core.py#L735-L745 | def set_group(self, group):
"""Set group size of DMatrix (used for ranking).
Parameters
----------
group : array like
Group size of each group
"""
_check_call(_LIB.XGDMatrixSetGroup(self.handle,
c_array(ctypes.c_uint... | [
"def",
"set_group",
"(",
"self",
",",
"group",
")",
":",
"_check_call",
"(",
"_LIB",
".",
"XGDMatrixSetGroup",
"(",
"self",
".",
"handle",
",",
"c_array",
"(",
"ctypes",
".",
"c_uint",
",",
"group",
")",
",",
"c_bst_ulong",
"(",
"len",
"(",
"group",
")... | Set group size of DMatrix (used for ranking).
Parameters
----------
group : array like
Group size of each group | [
"Set",
"group",
"size",
"of",
"DMatrix",
"(",
"used",
"for",
"ranking",
")",
"."
] | python | train | 35.272727 |
manns/pyspread | pyspread/src/lib/__csv.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/__csv.py#L402-L432 | def _get_csv_cells_gen(self, line):
"""Generator of values in a csv line"""
digest_types = self.digest_types
for j, value in enumerate(line):
if self.first_line:
digest_key = None
digest = lambda x: x.decode(self.encoding)
else:
... | [
"def",
"_get_csv_cells_gen",
"(",
"self",
",",
"line",
")",
":",
"digest_types",
"=",
"self",
".",
"digest_types",
"for",
"j",
",",
"value",
"in",
"enumerate",
"(",
"line",
")",
":",
"if",
"self",
".",
"first_line",
":",
"digest_key",
"=",
"None",
"diges... | Generator of values in a csv line | [
"Generator",
"of",
"values",
"in",
"a",
"csv",
"line"
] | python | train | 28.774194 |
gc3-uzh-ch/elasticluster | elasticluster/providers/ec2_boto.py | https://github.com/gc3-uzh-ch/elasticluster/blob/e6345633308c76de13b889417df572815aabe744/elasticluster/providers/ec2_boto.py#L463-L496 | def _load_instance(self, instance_id):
"""
Return instance with the given id.
For performance reasons, the instance ID is first searched for in the
collection of VM instances started by ElastiCluster
(`self._instances`), then in the list of all instances known to the
clo... | [
"def",
"_load_instance",
"(",
"self",
",",
"instance_id",
")",
":",
"# if instance is known, return it",
"if",
"instance_id",
"in",
"self",
".",
"_instances",
":",
"return",
"self",
".",
"_instances",
"[",
"instance_id",
"]",
"# else, check (cached) list from provider",... | Return instance with the given id.
For performance reasons, the instance ID is first searched for in the
collection of VM instances started by ElastiCluster
(`self._instances`), then in the list of all instances known to the
cloud provider at the time of the last update
(`self._... | [
"Return",
"instance",
"with",
"the",
"given",
"id",
"."
] | python | train | 41.764706 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/dokan.py#L367-L413 | def findFilesWithPattern(
self, fileName, searchPattern, fillFindData, dokanFileInfo
):
"""Find files in a certain path that match the search pattern.
:param fileName: path to search
:type fileName: ctypes.c_wchar_p
:param searchPattern: pattern to search for
:type s... | [
"def",
"findFilesWithPattern",
"(",
"self",
",",
"fileName",
",",
"searchPattern",
",",
"fillFindData",
",",
"dokanFileInfo",
")",
":",
"try",
":",
"ret",
"=",
"self",
".",
"operations",
"(",
"'findFilesWithPattern'",
",",
"fileName",
",",
"searchPattern",
")",
... | Find files in a certain path that match the search pattern.
:param fileName: path to search
:type fileName: ctypes.c_wchar_p
:param searchPattern: pattern to search for
:type searchPattern: ctypes.c_wchar_p
:param fillFindData: function pointer for populating search results
... | [
"Find",
"files",
"in",
"a",
"certain",
"path",
"that",
"match",
"the",
"search",
"pattern",
"."
] | python | train | 47.914894 |
mcieslik-mctp/papy | src/papy/core.py | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L563-L602 | def _code(self):
"""
(internal) generates imports, code and runtime calls to save a pipeline.
"""
icode, tcode = '', '' # imports, task code
icall, pcall = '', '' # imap calls, piper calls
tdone, idone = [], [] # task done, imap done
for piper in self:
... | [
"def",
"_code",
"(",
"self",
")",
":",
"icode",
",",
"tcode",
"=",
"''",
",",
"''",
"# imports, task code",
"icall",
",",
"pcall",
"=",
"''",
",",
"''",
"# imap calls, piper calls",
"tdone",
",",
"idone",
"=",
"[",
"]",
",",
"[",
"]",
"# task done, imap ... | (internal) generates imports, code and runtime calls to save a pipeline. | [
"(",
"internal",
")",
"generates",
"imports",
"code",
"and",
"runtime",
"calls",
"to",
"save",
"a",
"pipeline",
"."
] | python | train | 44.025 |
opendatateam/udata | udata/features/transfer/actions.py | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/features/transfer/actions.py#L19-L31 | def request_transfer(subject, recipient, comment):
'''Initiate a transfer request'''
TransferPermission(subject).test()
if recipient == (subject.organization or subject.owner):
raise ValueError(
'Recipient should be different than the current owner')
transfer = Transfer.objects.creat... | [
"def",
"request_transfer",
"(",
"subject",
",",
"recipient",
",",
"comment",
")",
":",
"TransferPermission",
"(",
"subject",
")",
".",
"test",
"(",
")",
"if",
"recipient",
"==",
"(",
"subject",
".",
"organization",
"or",
"subject",
".",
"owner",
")",
":",
... | Initiate a transfer request | [
"Initiate",
"a",
"transfer",
"request"
] | python | train | 35.923077 |
aouyar/PyMunin | pysysinfo/postgresql.py | https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/postgresql.py#L88-L101 | def _createStatsDict(self, headers, rows):
"""Utility method that returns database stats as a nested dictionary.
@param headers: List of columns in query result.
@param rows: List of rows in query result.
@return: Nested dictionary of values.
Fi... | [
"def",
"_createStatsDict",
"(",
"self",
",",
"headers",
",",
"rows",
")",
":",
"dbstats",
"=",
"{",
"}",
"for",
"row",
"in",
"rows",
":",
"dbstats",
"[",
"row",
"[",
"0",
"]",
"]",
"=",
"dict",
"(",
"zip",
"(",
"headers",
"[",
"1",
":",
"]",
",... | Utility method that returns database stats as a nested dictionary.
@param headers: List of columns in query result.
@param rows: List of rows in query result.
@return: Nested dictionary of values.
First key is the database name and the second key is the... | [
"Utility",
"method",
"that",
"returns",
"database",
"stats",
"as",
"a",
"nested",
"dictionary",
"."
] | python | train | 40.571429 |
gmr/queries | queries/pool.py | https://github.com/gmr/queries/blob/a68855013dc6aaf9ed7b6909a4701f8da8796a0a/queries/pool.py#L660-L669 | def size(cls, pid):
"""Return the number of connections in the pool
:param str pid: The pool id
:rtype int
"""
with cls._lock:
cls._ensure_pool_exists(pid)
return len(cls._pools[pid]) | [
"def",
"size",
"(",
"cls",
",",
"pid",
")",
":",
"with",
"cls",
".",
"_lock",
":",
"cls",
".",
"_ensure_pool_exists",
"(",
"pid",
")",
"return",
"len",
"(",
"cls",
".",
"_pools",
"[",
"pid",
"]",
")"
] | Return the number of connections in the pool
:param str pid: The pool id
:rtype int | [
"Return",
"the",
"number",
"of",
"connections",
"in",
"the",
"pool"
] | python | train | 24 |
twosigma/beakerx | beakerx/setupbase.py | https://github.com/twosigma/beakerx/blob/404de61ed627d9daaf6b77eb4859e7cb6f37413f/beakerx/setupbase.py#L155-L162 | def is_stale(target, source):
"""Test whether the target file/directory is stale based on the source
file/directory.
"""
if not os.path.exists(target):
return True
target_mtime = recursive_mtime(target) or 0
return compare_recursive_mtime(source, cutoff=target_mtime) | [
"def",
"is_stale",
"(",
"target",
",",
"source",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"target",
")",
":",
"return",
"True",
"target_mtime",
"=",
"recursive_mtime",
"(",
"target",
")",
"or",
"0",
"return",
"compare_recursive_mtime",... | Test whether the target file/directory is stale based on the source
file/directory. | [
"Test",
"whether",
"the",
"target",
"file",
"/",
"directory",
"is",
"stale",
"based",
"on",
"the",
"source",
"file",
"/",
"directory",
"."
] | python | train | 36.875 |
gem/oq-engine | openquake/risklib/riskmodels.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/riskmodels.py#L69-L79 | def build_vf_node(vf):
"""
Convert a VulnerabilityFunction object into a Node suitable
for XML conversion.
"""
nodes = [Node('imls', {'imt': vf.imt}, vf.imls),
Node('meanLRs', {}, vf.mean_loss_ratios),
Node('covLRs', {}, vf.covs)]
return Node(
'vulnerabilityFunc... | [
"def",
"build_vf_node",
"(",
"vf",
")",
":",
"nodes",
"=",
"[",
"Node",
"(",
"'imls'",
",",
"{",
"'imt'",
":",
"vf",
".",
"imt",
"}",
",",
"vf",
".",
"imls",
")",
",",
"Node",
"(",
"'meanLRs'",
",",
"{",
"}",
",",
"vf",
".",
"mean_loss_ratios",
... | Convert a VulnerabilityFunction object into a Node suitable
for XML conversion. | [
"Convert",
"a",
"VulnerabilityFunction",
"object",
"into",
"a",
"Node",
"suitable",
"for",
"XML",
"conversion",
"."
] | python | train | 34.727273 |
openstack/horizon | horizon/middleware/base.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/middleware/base.py#L166-L214 | def _process_response(self, request, response):
"""Convert HttpResponseRedirect to HttpResponse if request is via ajax.
This is to allow ajax request to redirect url.
"""
if request.is_ajax() and hasattr(request, 'horizon'):
queued_msgs = request.horizon['async_messages']
... | [
"def",
"_process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"request",
".",
"is_ajax",
"(",
")",
"and",
"hasattr",
"(",
"request",
",",
"'horizon'",
")",
":",
"queued_msgs",
"=",
"request",
".",
"horizon",
"[",
"'async_message... | Convert HttpResponseRedirect to HttpResponse if request is via ajax.
This is to allow ajax request to redirect url. | [
"Convert",
"HttpResponseRedirect",
"to",
"HttpResponse",
"if",
"request",
"is",
"via",
"ajax",
"."
] | python | train | 56.897959 |
xmikos/soapy_power | soapypower/__main__.py | https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/__main__.py#L83-L129 | def device_info(soapy_args=''):
"""Returns info about selected SoapySDR device"""
text = []
try:
device = simplesoapy.SoapyDevice(soapy_args)
text.append('Selected device: {}'.format(device.hardware))
text.append(' Available RX channels:')
text.append(' {}'.format(', '.jo... | [
"def",
"device_info",
"(",
"soapy_args",
"=",
"''",
")",
":",
"text",
"=",
"[",
"]",
"try",
":",
"device",
"=",
"simplesoapy",
".",
"SoapyDevice",
"(",
"soapy_args",
")",
"text",
".",
"append",
"(",
"'Selected device: {}'",
".",
"format",
"(",
"device",
... | Returns info about selected SoapySDR device | [
"Returns",
"info",
"about",
"selected",
"SoapySDR",
"device"
] | python | test | 49.489362 |
cidrblock/modelsettings | modelsettings/__init__.py | https://github.com/cidrblock/modelsettings/blob/09763c111fb38b3ba7a13cc95ca59e4393fe75ba/modelsettings/__init__.py#L230-L244 | def generate_command(self):
""" Generate a sample command
"""
example = []
example.append(f"{sys.argv[0]}")
for key in sorted(list(self.spec.keys())):
if self.spec[key]['type'] == list:
value = " ".join(self.spec[key].get('example', ''))
el... | [
"def",
"generate_command",
"(",
"self",
")",
":",
"example",
"=",
"[",
"]",
"example",
".",
"append",
"(",
"f\"{sys.argv[0]}\"",
")",
"for",
"key",
"in",
"sorted",
"(",
"list",
"(",
"self",
".",
"spec",
".",
"keys",
"(",
")",
")",
")",
":",
"if",
"... | Generate a sample command | [
"Generate",
"a",
"sample",
"command"
] | python | train | 41.333333 |
UDST/urbansim | urbansim/models/dcm.py | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L721-L728 | def alts_columns_used(self):
"""
Columns from the alternatives table that are used for filtering.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.alts_predict_filters),
util.columns_in_filters(self.alts_fit_filters)))) | [
"def",
"alts_columns_used",
"(",
"self",
")",
":",
"return",
"list",
"(",
"tz",
".",
"unique",
"(",
"tz",
".",
"concatv",
"(",
"util",
".",
"columns_in_filters",
"(",
"self",
".",
"alts_predict_filters",
")",
",",
"util",
".",
"columns_in_filters",
"(",
"s... | Columns from the alternatives table that are used for filtering. | [
"Columns",
"from",
"the",
"alternatives",
"table",
"that",
"are",
"used",
"for",
"filtering",
"."
] | python | train | 35.875 |
lemieuxl/pyGenClean | pyGenClean/RelatedSamples/find_related_samples.py | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/RelatedSamples/find_related_samples.py#L37-L109 | def main(argString=None):
"""The main function of this module.
:param argString: the options.
:type argString: list
Here are the steps for this function:
1. Prints the options.
2. Uses Plink to extract markers according to LD
(:py:func:`selectSNPsAccordingToLD`).
3. Checks if ther... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"logger",
".",
"info",
"(",
"\"Options used:\"",
")",
"for",
"key",
",",
"value",
"i... | The main function of this module.
:param argString: the options.
:type argString: list
Here are the steps for this function:
1. Prints the options.
2. Uses Plink to extract markers according to LD
(:py:func:`selectSNPsAccordingToLD`).
3. Checks if there is enough markers after pruning... | [
"The",
"main",
"function",
"of",
"this",
"module",
"."
] | python | train | 39.287671 |
edx/edx-organizations | organizations/data.py | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L238-L247 | def fetch_organization_courses(organization):
"""
Retrieves the set of courses currently linked to the specified organization
"""
organization_obj = serializers.deserialize_organization(organization)
queryset = internal.OrganizationCourse.objects.filter(
organization=organization_obj,
... | [
"def",
"fetch_organization_courses",
"(",
"organization",
")",
":",
"organization_obj",
"=",
"serializers",
".",
"deserialize_organization",
"(",
"organization",
")",
"queryset",
"=",
"internal",
".",
"OrganizationCourse",
".",
"objects",
".",
"filter",
"(",
"organiza... | Retrieves the set of courses currently linked to the specified organization | [
"Retrieves",
"the",
"set",
"of",
"courses",
"currently",
"linked",
"to",
"the",
"specified",
"organization"
] | python | valid | 46.4 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_maps_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_maps_ext.py#L80-L92 | def maps_get_rules_output_rules_groupname(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
maps_get_rules = ET.Element("maps_get_rules")
config = maps_get_rules
output = ET.SubElement(maps_get_rules, "output")
rules = ET.SubElement(output,... | [
"def",
"maps_get_rules_output_rules_groupname",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"maps_get_rules",
"=",
"ET",
".",
"Element",
"(",
"\"maps_get_rules\"",
")",
"config",
"=",
"maps_get_r... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 39.307692 |
saltstack/salt | salt/utils/environment.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/environment.py#L9-L65 | def get_module_environment(env=None, function=None):
'''
Get module optional environment.
To setup an environment option for a particular module,
add either pillar or config at the minion as follows:
system-environment:
modules:
pkg:
_:
LC_ALL: en_GB.UTF-8
... | [
"def",
"get_module_environment",
"(",
"env",
"=",
"None",
",",
"function",
"=",
"None",
")",
":",
"result",
"=",
"{",
"}",
"if",
"not",
"env",
":",
"env",
"=",
"{",
"}",
"for",
"env_src",
"in",
"[",
"env",
".",
"get",
"(",
"'__opts__'",
",",
"{",
... | Get module optional environment.
To setup an environment option for a particular module,
add either pillar or config at the minion as follows:
system-environment:
modules:
pkg:
_:
LC_ALL: en_GB.UTF-8
FOO: bar
install:
HELLO: world
... | [
"Get",
"module",
"optional",
"environment",
"."
] | python | train | 34.54386 |
DataBiosphere/toil | src/toil/batchSystems/parasol.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/batchSystems/parasol.py#L202-L222 | def killBatchJobs(self, jobIDs):
"""Kills the given jobs, represented as Job ids, then checks they are dead by checking
they are not in the list of issued jobs.
"""
while True:
for jobID in jobIDs:
if jobID in self.runningJobs:
self.running... | [
"def",
"killBatchJobs",
"(",
"self",
",",
"jobIDs",
")",
":",
"while",
"True",
":",
"for",
"jobID",
"in",
"jobIDs",
":",
"if",
"jobID",
"in",
"self",
".",
"runningJobs",
":",
"self",
".",
"runningJobs",
".",
"remove",
"(",
"jobID",
")",
"exitValue",
"=... | Kills the given jobs, represented as Job ids, then checks they are dead by checking
they are not in the list of issued jobs. | [
"Kills",
"the",
"given",
"jobs",
"represented",
"as",
"Job",
"ids",
"then",
"checks",
"they",
"are",
"dead",
"by",
"checking",
"they",
"are",
"not",
"in",
"the",
"list",
"of",
"issued",
"jobs",
"."
] | python | train | 53.190476 |
bcbio/bcbio-nextgen | bcbio/variation/damage.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/damage.py#L17-L44 | def run_filter(vrn_file, align_bam, ref_file, data, items):
"""Filter and annotate somatic VCFs with damage/bias artifacts on low frequency variants.
Moves damage estimation to INFO field, instead of leaving in FILTER.
"""
if not should_filter(items) or not vcfutils.vcf_has_variants(vrn_file):
... | [
"def",
"run_filter",
"(",
"vrn_file",
",",
"align_bam",
",",
"ref_file",
",",
"data",
",",
"items",
")",
":",
"if",
"not",
"should_filter",
"(",
"items",
")",
"or",
"not",
"vcfutils",
".",
"vcf_has_variants",
"(",
"vrn_file",
")",
":",
"return",
"data",
... | Filter and annotate somatic VCFs with damage/bias artifacts on low frequency variants.
Moves damage estimation to INFO field, instead of leaving in FILTER. | [
"Filter",
"and",
"annotate",
"somatic",
"VCFs",
"with",
"damage",
"/",
"bias",
"artifacts",
"on",
"low",
"frequency",
"variants",
"."
] | python | train | 62.535714 |
google/grr | grr/server/grr_response_server/data_store.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1399-L1427 | def FileHashIndexQuery(self, subject, target_prefix, limit=100):
"""Search the index for matches starting with target_prefix.
Args:
subject: The index to use. Should be a urn that points to the sha256
namespace.
target_prefix: The prefix to match against the index.
limit: Either a... | [
"def",
"FileHashIndexQuery",
"(",
"self",
",",
"subject",
",",
"target_prefix",
",",
"limit",
"=",
"100",
")",
":",
"if",
"isinstance",
"(",
"limit",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"start",
",",
"length",
"=",
"limit",
"# pylint: disable=... | Search the index for matches starting with target_prefix.
Args:
subject: The index to use. Should be a urn that points to the sha256
namespace.
target_prefix: The prefix to match against the index.
limit: Either a tuple of (start, limit) or a maximum number of results to
retu... | [
"Search",
"the",
"index",
"for",
"matches",
"starting",
"with",
"target_prefix",
"."
] | python | train | 32.034483 |
allenai/allennlp | allennlp/data/dataset.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset.py#L46-L69 | def get_padding_lengths(self) -> Dict[str, Dict[str, int]]:
"""
Gets the maximum padding lengths from all ``Instances`` in this batch. Each ``Instance``
has multiple ``Fields``, and each ``Field`` could have multiple things that need padding.
We look at all fields in all instances, and ... | [
"def",
"get_padding_lengths",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"int",
"]",
"]",
":",
"padding_lengths",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"int",
"]",
"]",
"=",
"defaultdict",
"(",
"dict"... | Gets the maximum padding lengths from all ``Instances`` in this batch. Each ``Instance``
has multiple ``Fields``, and each ``Field`` could have multiple things that need padding.
We look at all fields in all instances, and find the max values for each (field_name,
padding_key) pair, returning t... | [
"Gets",
"the",
"maximum",
"padding",
"lengths",
"from",
"all",
"Instances",
"in",
"this",
"batch",
".",
"Each",
"Instance",
"has",
"multiple",
"Fields",
"and",
"each",
"Field",
"could",
"have",
"multiple",
"things",
"that",
"need",
"padding",
".",
"We",
"loo... | python | train | 62.208333 |
materialsproject/pymatgen | pymatgen/phonon/bandstructure.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/phonon/bandstructure.py#L367-L392 | def get_equivalent_qpoints(self, index):
"""
Returns the list of qpoint indices equivalent (meaning they are the
same frac coords) to the given one.
Args:
index: the qpoint index
Returns:
a list of equivalent indices
TODO: now it uses the label ... | [
"def",
"get_equivalent_qpoints",
"(",
"self",
",",
"index",
")",
":",
"#if the qpoint has no label it can\"t have a repetition along the band",
"#structure line object",
"if",
"self",
".",
"qpoints",
"[",
"index",
"]",
".",
"label",
"is",
"None",
":",
"return",
"[",
"... | Returns the list of qpoint indices equivalent (meaning they are the
same frac coords) to the given one.
Args:
index: the qpoint index
Returns:
a list of equivalent indices
TODO: now it uses the label we might want to use coordinates instead
(in case the... | [
"Returns",
"the",
"list",
"of",
"qpoint",
"indices",
"equivalent",
"(",
"meaning",
"they",
"are",
"the",
"same",
"frac",
"coords",
")",
"to",
"the",
"given",
"one",
"."
] | python | train | 30.384615 |
gholt/swiftly | swiftly/filelikeiter.py | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/filelikeiter.py#L117-L137 | def readlines(self, sizehint=-1):
"""
readlines([size]) -> list of strings, each a line from the file.
Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines retur... | [
"def",
"readlines",
"(",
"self",
",",
"sizehint",
"=",
"-",
"1",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"ValueError",
"(",
"'I/O operation on closed file'",
")",
"lines",
"=",
"[",
"]",
"while",
"True",
":",
"line",
"=",
"self",
".",
"rea... | readlines([size]) -> list of strings, each a line from the file.
Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines returned. | [
"readlines",
"(",
"[",
"size",
"]",
")",
"-",
">",
"list",
"of",
"strings",
"each",
"a",
"line",
"from",
"the",
"file",
"."
] | python | test | 33.809524 |
santoshphilip/eppy | eppy/hvacbuilder.py | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L962-L970 | def _clean_listofcomponents(listofcomponents):
"""force it to be a list of tuples"""
def totuple(item):
"""return a tuple"""
if isinstance(item, (tuple, list)):
return item
else:
return (item, None)
return [totuple(item) for item in listofcomponents] | [
"def",
"_clean_listofcomponents",
"(",
"listofcomponents",
")",
":",
"def",
"totuple",
"(",
"item",
")",
":",
"\"\"\"return a tuple\"\"\"",
"if",
"isinstance",
"(",
"item",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"return",
"item",
"else",
":",
"return... | force it to be a list of tuples | [
"force",
"it",
"to",
"be",
"a",
"list",
"of",
"tuples"
] | python | train | 33.555556 |
MarcoFavorito/flloat | flloat/parser/pl.py | https://github.com/MarcoFavorito/flloat/blob/5e6de1bea444b68d46d288834031860a8b2f8c2d/flloat/parser/pl.py#L41-L44 | def t_ATOM(self, t):
r'[a-zA-Z_][a-zA-Z_0-9]*'
t.type = PLLexer.reserved.get(t.value, 'ATOM') # Check for reserved words
return t | [
"def",
"t_ATOM",
"(",
"self",
",",
"t",
")",
":",
"t",
".",
"type",
"=",
"PLLexer",
".",
"reserved",
".",
"get",
"(",
"t",
".",
"value",
",",
"'ATOM'",
")",
"# Check for reserved words",
"return",
"t"
] | r'[a-zA-Z_][a-zA-Z_0-9]* | [
"r",
"[",
"a",
"-",
"zA",
"-",
"Z_",
"]",
"[",
"a",
"-",
"zA",
"-",
"Z_0",
"-",
"9",
"]",
"*"
] | python | train | 37.75 |
pypa/pipenv | pipenv/vendor/distlib/_backport/tarfile.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L583-L602 | def _read(self, size):
"""Return size bytes from the stream.
"""
if self.comptype == "tar":
return self.__read(size)
c = len(self.dbuf)
while c < size:
buf = self.__read(self.bufsize)
if not buf:
break
try:
... | [
"def",
"_read",
"(",
"self",
",",
"size",
")",
":",
"if",
"self",
".",
"comptype",
"==",
"\"tar\"",
":",
"return",
"self",
".",
"__read",
"(",
"size",
")",
"c",
"=",
"len",
"(",
"self",
".",
"dbuf",
")",
"while",
"c",
"<",
"size",
":",
"buf",
"... | Return size bytes from the stream. | [
"Return",
"size",
"bytes",
"from",
"the",
"stream",
"."
] | python | train | 28.4 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L497-L560 | def file_put( blockchain_id, hostname, recipient_blockchain_ids, data_name, input_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Send a file to the given recipient, encrypted and signed with the
given blockchain ID.
Allow each recipient to receive the data on each of their hosts... | [
"def",
"file_put",
"(",
"blockchain_id",
",",
"hostname",
",",
"recipient_blockchain_ids",
",",
"data_name",
",",
"input_path",
",",
"passphrase",
"=",
"None",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"fd",
",",
"outpu... | Send a file to the given recipient, encrypted and signed with the
given blockchain ID.
Allow each recipient to receive the data on each of their hosts.
Return {'status': True} on success, and upload to cloud storage
Return {'error': ...} on error | [
"Send",
"a",
"file",
"to",
"the",
"given",
"recipient",
"encrypted",
"and",
"signed",
"with",
"the",
"given",
"blockchain",
"ID",
".",
"Allow",
"each",
"recipient",
"to",
"receive",
"the",
"data",
"on",
"each",
"of",
"their",
"hosts",
".",
"Return",
"{",
... | python | train | 42.9375 |
uktrade/directory-components | scripts/upgrade_header_footer.py | https://github.com/uktrade/directory-components/blob/305b3cfd590e170255503ae3c41aebcaa658af8e/scripts/upgrade_header_footer.py#L70-L79 | def replace_in_files(dirname, replace):
"""Replace current version with new version in requirements files."""
filepath = os.path.abspath(dirname / "requirements.in")
if os.path.isfile(filepath) and header_footer_exists(filepath):
replaced = re.sub(Utils.exp, replace, get_file_string(filepath))
... | [
"def",
"replace_in_files",
"(",
"dirname",
",",
"replace",
")",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"dirname",
"/",
"\"requirements.in\"",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filepath",
")",
"and",
"header_footer_ex... | Replace current version with new version in requirements files. | [
"Replace",
"current",
"version",
"with",
"new",
"version",
"in",
"requirements",
"files",
"."
] | python | train | 48.8 |
python-openxml/python-docx | docx/image/jpeg.py | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L220-L232 | def _next_non_ff_byte(self, start):
"""
Return an offset, byte 2-tuple for the next byte in *stream* that is
not '\xFF', starting with the byte at offset *start*. If the byte at
offset *start* is not '\xFF', *start* and the returned *offset* will
be the same.
"""
... | [
"def",
"_next_non_ff_byte",
"(",
"self",
",",
"start",
")",
":",
"self",
".",
"_stream",
".",
"seek",
"(",
"start",
")",
"byte_",
"=",
"self",
".",
"_read_byte",
"(",
")",
"while",
"byte_",
"==",
"b'\\xFF'",
":",
"byte_",
"=",
"self",
".",
"_read_byte"... | Return an offset, byte 2-tuple for the next byte in *stream* that is
not '\xFF', starting with the byte at offset *start*. If the byte at
offset *start* is not '\xFF', *start* and the returned *offset* will
be the same. | [
"Return",
"an",
"offset",
"byte",
"2",
"-",
"tuple",
"for",
"the",
"next",
"byte",
"in",
"*",
"stream",
"*",
"that",
"is",
"not",
"\\",
"xFF",
"starting",
"with",
"the",
"byte",
"at",
"offset",
"*",
"start",
"*",
".",
"If",
"the",
"byte",
"at",
"of... | python | train | 41.230769 |
openvax/pyensembl | pyensembl/download_cache.py | https://github.com/openvax/pyensembl/blob/4b995fb72e848206d6fbf11950cf30964cd9b3aa/pyensembl/download_cache.py#L30-L47 | def cache_subdirectory(
reference_name=None,
annotation_name=None,
annotation_version=None):
"""
Which cache subdirectory to use for a given annotation database
over a particular reference. All arguments can be omitted to just get
the base subdirectory for all pyensembl cached da... | [
"def",
"cache_subdirectory",
"(",
"reference_name",
"=",
"None",
",",
"annotation_name",
"=",
"None",
",",
"annotation_version",
"=",
"None",
")",
":",
"if",
"reference_name",
"is",
"None",
":",
"reference_name",
"=",
"\"\"",
"if",
"annotation_name",
"is",
"None... | Which cache subdirectory to use for a given annotation database
over a particular reference. All arguments can be omitted to just get
the base subdirectory for all pyensembl cached datasets. | [
"Which",
"cache",
"subdirectory",
"to",
"use",
"for",
"a",
"given",
"annotation",
"database",
"over",
"a",
"particular",
"reference",
".",
"All",
"arguments",
"can",
"be",
"omitted",
"to",
"just",
"get",
"the",
"base",
"subdirectory",
"for",
"all",
"pyensembl"... | python | train | 37.777778 |
pyca/pynacl | src/nacl/bindings/crypto_pwhash.py | https://github.com/pyca/pynacl/blob/0df0c2c7693fa5d316846111ce510702756f5feb/src/nacl/bindings/crypto_pwhash.py#L441-L467 | def crypto_pwhash_str_verify(passwd_hash, passwd):
"""
Verifies the ``passwd`` against a given password hash.
Returns True on success, raises InvalidkeyError on failure
:param passwd_hash: saved password hash
:type passwd_hash: bytes
:param passwd: password to be checked
:type passwd: bytes... | [
"def",
"crypto_pwhash_str_verify",
"(",
"passwd_hash",
",",
"passwd",
")",
":",
"ensure",
"(",
"isinstance",
"(",
"passwd_hash",
",",
"bytes",
")",
",",
"raising",
"=",
"TypeError",
")",
"ensure",
"(",
"isinstance",
"(",
"passwd",
",",
"bytes",
")",
",",
"... | Verifies the ``passwd`` against a given password hash.
Returns True on success, raises InvalidkeyError on failure
:param passwd_hash: saved password hash
:type passwd_hash: bytes
:param passwd: password to be checked
:type passwd: bytes
:return: success
:rtype: boolean | [
"Verifies",
"the",
"passwd",
"against",
"a",
"given",
"password",
"hash",
"."
] | python | train | 30.296296 |
camptocamp/marabunta | marabunta/model.py | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L155-L174 | def add_operation(self, operation_type, operation, mode=None):
"""Add an operation to the version
:param mode: Name of the mode in which the operation is executed
:type mode: str
:param operation_type: one of 'pre', 'post'
:type operation_type: str
:param operation: the ... | [
"def",
"add_operation",
"(",
"self",
",",
"operation_type",
",",
"operation",
",",
"mode",
"=",
"None",
")",
":",
"version_mode",
"=",
"self",
".",
"_get_version_mode",
"(",
"mode",
"=",
"mode",
")",
"if",
"operation_type",
"==",
"'pre'",
":",
"version_mode"... | Add an operation to the version
:param mode: Name of the mode in which the operation is executed
:type mode: str
:param operation_type: one of 'pre', 'post'
:type operation_type: str
:param operation: the operation to add
:type operation: :class:`marabunta.model.Operatio... | [
"Add",
"an",
"operation",
"to",
"the",
"version"
] | python | train | 39.05 |
CivicSpleen/ambry | ambry/bundle/bundle.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/bundle.py#L1737-L1842 | def ingest(self, sources=None, tables=None, stage=None, force=False, load_meta=False):
"""Ingest a set of sources, specified as source objects, source names, or destination tables.
If no stage is specified, execute the sources in groups by stage.
Note, however, that when this is called from run... | [
"def",
"ingest",
"(",
"self",
",",
"sources",
"=",
"None",
",",
"tables",
"=",
"None",
",",
"stage",
"=",
"None",
",",
"force",
"=",
"False",
",",
"load_meta",
"=",
"False",
")",
":",
"from",
"itertools",
"import",
"groupby",
"from",
"ambry",
".",
"b... | Ingest a set of sources, specified as source objects, source names, or destination tables.
If no stage is specified, execute the sources in groups by stage.
Note, however, that when this is called from run_stage, all of the sources have the same stage, so they
get grouped together. The result i... | [
"Ingest",
"a",
"set",
"of",
"sources",
"specified",
"as",
"source",
"objects",
"source",
"names",
"or",
"destination",
"tables",
".",
"If",
"no",
"stage",
"is",
"specified",
"execute",
"the",
"sources",
"in",
"groups",
"by",
"stage",
"."
] | python | train | 32.056604 |
allenai/allennlp | allennlp/nn/beam_search.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/beam_search.py#L44-L276 | def search(self,
start_predictions: torch.Tensor,
start_state: StateType,
step: StepFunctionType) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Given a starting state and a step function, apply beam search to find the
most likely target sequences.
... | [
"def",
"search",
"(",
"self",
",",
"start_predictions",
":",
"torch",
".",
"Tensor",
",",
"start_state",
":",
"StateType",
",",
"step",
":",
"StepFunctionType",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
"]",
":",
"batc... | Given a starting state and a step function, apply beam search to find the
most likely target sequences.
Notes
-----
If your step function returns ``-inf`` for some log probabilities
(like if you're using a masked log-softmax) then some of the "best"
sequences returned ma... | [
"Given",
"a",
"starting",
"state",
"and",
"a",
"step",
"function",
"apply",
"beam",
"search",
"to",
"find",
"the",
"most",
"likely",
"target",
"sequences",
"."
] | python | train | 50.643777 |
schapman1974/tinymongo | tinymongo/tinymongo.py | https://github.com/schapman1974/tinymongo/blob/993048059dc0aa789d879b69feb79a0f237a60b3/tinymongo/tinymongo.py#L157-L168 | def drop(self, **kwargs):
"""
Removes a collection from the database.
**kwargs only because of the optional "writeConcern" field, but does nothing in the TinyDB database.
:return: Returns True when successfully drops a collection. Returns False when collection to drop does not
ex... | [
"def",
"drop",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"table",
":",
"self",
".",
"parent",
".",
"tinydb",
".",
"purge_table",
"(",
"self",
".",
"tablename",
")",
"return",
"True",
"else",
":",
"return",
"False"
] | Removes a collection from the database.
**kwargs only because of the optional "writeConcern" field, but does nothing in the TinyDB database.
:return: Returns True when successfully drops a collection. Returns False when collection to drop does not
exist. | [
"Removes",
"a",
"collection",
"from",
"the",
"database",
".",
"**",
"kwargs",
"only",
"because",
"of",
"the",
"optional",
"writeConcern",
"field",
"but",
"does",
"nothing",
"in",
"the",
"TinyDB",
"database",
".",
":",
"return",
":",
"Returns",
"True",
"when"... | python | train | 39.166667 |
jwodder/doapi | doapi/domain.py | https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/domain.py#L102-L134 | def create_record(self, type, name, data, priority=None, port=None,
weight=None, **kwargs):
# pylint: disable=redefined-builtin
"""
Add a new DNS record to the domain
:param str type: the type of DNS record to add (``"A"``, ``"CNAME"``,
etc.)
:p... | [
"def",
"create_record",
"(",
"self",
",",
"type",
",",
"name",
",",
"data",
",",
"priority",
"=",
"None",
",",
"port",
"=",
"None",
",",
"weight",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=redefined-builtin",
"api",
"=",
"self",
... | Add a new DNS record to the domain
:param str type: the type of DNS record to add (``"A"``, ``"CNAME"``,
etc.)
:param str name: the name (hostname, alias, etc.) of the new record
:param str data: the value of the new record
:param int priority: the priority of the new record... | [
"Add",
"a",
"new",
"DNS",
"record",
"to",
"the",
"domain"
] | python | train | 40.121212 |
estnltk/estnltk | estnltk/syntax/utils.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/utils.py#L874-L916 | def build_trees_from_sentence( sentence, syntactic_relations, layer=LAYER_VISLCG3, \
sentence_id=0, **kwargs ):
''' Given a sentence ( a list of EstNLTK's word tokens ), and a list of
dependency syntactic relations ( output of normalise_alignments() ),
builds trees ( ... | [
"def",
"build_trees_from_sentence",
"(",
"sentence",
",",
"syntactic_relations",
",",
"layer",
"=",
"LAYER_VISLCG3",
",",
"sentence_id",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"trees_of_sentence",
"=",
"[",
"]",
"nodes",
"=",
"[",
"-",
"1",
"]",
"whi... | Given a sentence ( a list of EstNLTK's word tokens ), and a list of
dependency syntactic relations ( output of normalise_alignments() ),
builds trees ( estnltk.syntax.utils.Tree objects ) from the sentence,
and returns as a list of Trees (roots of trees).
Note that there is ... | [
"Given",
"a",
"sentence",
"(",
"a",
"list",
"of",
"EstNLTK",
"s",
"word",
"tokens",
")",
"and",
"a",
"list",
"of",
"dependency",
"syntactic",
"relations",
"(",
"output",
"of",
"normalise_alignments",
"()",
")",
"builds",
"trees",
"(",
"estnltk",
".",
"synt... | python | train | 51.72093 |
youversion/crony | crony/crony.py | https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L167-L207 | def setup_logging(self):
"""Setup python logging handler."""
date_format = '%Y-%m-%dT%H:%M:%S'
log_format = '%(asctime)s %(levelname)s: %(message)s'
if self.opts.verbose:
lvl = logging.DEBUG
else:
lvl = logging.INFO
# Requests is a bit chatty
... | [
"def",
"setup_logging",
"(",
"self",
")",
":",
"date_format",
"=",
"'%Y-%m-%dT%H:%M:%S'",
"log_format",
"=",
"'%(asctime)s %(levelname)s: %(message)s'",
"if",
"self",
".",
"opts",
".",
"verbose",
":",
"lvl",
"=",
"logging",
".",
"DEBUG",
"else",
":",
"lvl",
"=",... | Setup python logging handler. | [
"Setup",
"python",
"logging",
"handler",
"."
] | python | train | 35.853659 |
kallimachos/chios | chios/bolditalic/__init__.py | https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/bolditalic/__init__.py#L31-L49 | def css(app, env):
"""
Add bolditalic CSS.
:param app: Sphinx application context.
:param env: Sphinx environment context.
"""
srcdir = os.path.abspath(os.path.dirname(__file__))
cssfile = 'bolditalic.css'
csspath = os.path.join(srcdir, cssfile)
buildpath = os.path.join(app.outdir, ... | [
"def",
"css",
"(",
"app",
",",
"env",
")",
":",
"srcdir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"cssfile",
"=",
"'bolditalic.css'",
"csspath",
"=",
"os",
".",
"path",
".",
"join",... | Add bolditalic CSS.
:param app: Sphinx application context.
:param env: Sphinx environment context. | [
"Add",
"bolditalic",
"CSS",
"."
] | python | train | 26.473684 |
idlesign/django-sitetree | sitetree/sitetreeapp.py | https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L393-L415 | def resolve_tree_i18n_alias(self, alias):
"""Resolves internationalized tree alias.
Verifies whether a separate sitetree is available for currently active language.
If so, returns i18n alias. If not, returns the initial alias.
:param str|unicode alias:
:rtype: str|unicode
... | [
"def",
"resolve_tree_i18n_alias",
"(",
"self",
",",
"alias",
")",
":",
"if",
"alias",
"not",
"in",
"_I18N_TREES",
":",
"return",
"alias",
"current_language_code",
"=",
"self",
".",
"current_lang",
"i18n_tree_alias",
"=",
"'%s_%s'",
"%",
"(",
"alias",
",",
"cur... | Resolves internationalized tree alias.
Verifies whether a separate sitetree is available for currently active language.
If so, returns i18n alias. If not, returns the initial alias.
:param str|unicode alias:
:rtype: str|unicode | [
"Resolves",
"internationalized",
"tree",
"alias",
".",
"Verifies",
"whether",
"a",
"separate",
"sitetree",
"is",
"available",
"for",
"currently",
"active",
"language",
".",
"If",
"so",
"returns",
"i18n",
"alias",
".",
"If",
"not",
"returns",
"the",
"initial",
... | python | test | 36.695652 |
linkedin/pyexchange | pyexchange/base/calendar.py | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/base/calendar.py#L285-L297 | def remove_resources(self, resources):
"""
Removes resources from the event.
*resources* can be a list of email addresses or :class:`ExchangeEventAttendee` objects.
"""
resources_to_delete = self._build_resource_dictionary(resources)
for email in resources_to_delete.keys():
if email in s... | [
"def",
"remove_resources",
"(",
"self",
",",
"resources",
")",
":",
"resources_to_delete",
"=",
"self",
".",
"_build_resource_dictionary",
"(",
"resources",
")",
"for",
"email",
"in",
"resources_to_delete",
".",
"keys",
"(",
")",
":",
"if",
"email",
"in",
"sel... | Removes resources from the event.
*resources* can be a list of email addresses or :class:`ExchangeEventAttendee` objects. | [
"Removes",
"resources",
"from",
"the",
"event",
"."
] | python | train | 31.076923 |
rcarmo/pngcanvas | pngcanvas.py | https://github.com/rcarmo/pngcanvas/blob/e2eaa0d5ba353005b3b658f6ee453c1956340670/pngcanvas.py#L51-L55 | def gradient_list(start, end, steps):
"""Compute gradient colors"""
delta = [end[i] - start[i] for i in range(4)]
return [bytearray(start[j] + (delta[j] * i) // steps for j in range(4))
for i in range(steps + 1)] | [
"def",
"gradient_list",
"(",
"start",
",",
"end",
",",
"steps",
")",
":",
"delta",
"=",
"[",
"end",
"[",
"i",
"]",
"-",
"start",
"[",
"i",
"]",
"for",
"i",
"in",
"range",
"(",
"4",
")",
"]",
"return",
"[",
"bytearray",
"(",
"start",
"[",
"j",
... | Compute gradient colors | [
"Compute",
"gradient",
"colors"
] | python | train | 46.4 |
mdiener/grace | grace/py27/slimit/parser.py | https://github.com/mdiener/grace/blob/2dab13a2cf636da5da989904c5885166fc94d36d/grace/py27/slimit/parser.py#L880-L887 | def p_expr_noin(self, p):
"""expr_noin : assignment_expr_noin
| expr_noin COMMA assignment_expr_noin
"""
if len(p) == 2:
p[0] = p[1]
else:
p[0] = ast.Comma(left=p[1], right=p[3]) | [
"def",
"p_expr_noin",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"2",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"else",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Comma",
"(",
"left",
"=",
"p",
"[",
"1",
... | expr_noin : assignment_expr_noin
| expr_noin COMMA assignment_expr_noin | [
"expr_noin",
":",
"assignment_expr_noin",
"|",
"expr_noin",
"COMMA",
"assignment_expr_noin"
] | python | train | 31 |
rsgalloway/grit | grit/repo/local.py | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L290-L299 | def addItem(self, item, message=None):
"""add a new Item class object"""
if message is None:
message = 'Adding item %s' % item.path
try:
v = Version.new(repo=self)
v.addItem(item)
v.save(message)
except VersionError, e:
raise Re... | [
"def",
"addItem",
"(",
"self",
",",
"item",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
"is",
"None",
":",
"message",
"=",
"'Adding item %s'",
"%",
"item",
".",
"path",
"try",
":",
"v",
"=",
"Version",
".",
"new",
"(",
"repo",
"=",
"sel... | add a new Item class object | [
"add",
"a",
"new",
"Item",
"class",
"object"
] | python | train | 32.1 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/enrich.py | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/enrich.py#L198-L227 | def __convert_json_to_projects_map(self, json):
""" Convert JSON format to the projects map format
map[ds][repository] = project
If a repository is in several projects assign to leaf
Check that all JSON data is in the database
:param json: data with the projects to repositories ... | [
"def",
"__convert_json_to_projects_map",
"(",
"self",
",",
"json",
")",
":",
"ds_repo_to_prj",
"=",
"{",
"}",
"for",
"project",
"in",
"json",
":",
"for",
"ds",
"in",
"json",
"[",
"project",
"]",
":",
"if",
"ds",
"==",
"\"meta\"",
":",
"continue",
"# not ... | Convert JSON format to the projects map format
map[ds][repository] = project
If a repository is in several projects assign to leaf
Check that all JSON data is in the database
:param json: data with the projects to repositories mapping
:returns: the repositories to projects mappi... | [
"Convert",
"JSON",
"format",
"to",
"the",
"projects",
"map",
"format",
"map",
"[",
"ds",
"]",
"[",
"repository",
"]",
"=",
"project",
"If",
"a",
"repository",
"is",
"in",
"several",
"projects",
"assign",
"to",
"leaf",
"Check",
"that",
"all",
"JSON",
"dat... | python | train | 49.166667 |
jasonrbriggs/stomp.py | stomp/utils.py | https://github.com/jasonrbriggs/stomp.py/blob/643843c5fbf25fd24339dd0e69a9411c3d8b94c7/stomp/utils.py#L56-L66 | def default_create_thread(callback):
"""
Default thread creation - used to create threads when the client doesn't want to provide their
own thread creation.
:param function callback: the callback function provided to threading.Thread
"""
thread = threading.Thread(None, callback)
thread.daem... | [
"def",
"default_create_thread",
"(",
"callback",
")",
":",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"None",
",",
"callback",
")",
"thread",
".",
"daemon",
"=",
"True",
"# Don't let thread prevent termination",
"thread",
".",
"start",
"(",
")",
"return",
... | Default thread creation - used to create threads when the client doesn't want to provide their
own thread creation.
:param function callback: the callback function provided to threading.Thread | [
"Default",
"thread",
"creation",
"-",
"used",
"to",
"create",
"threads",
"when",
"the",
"client",
"doesn",
"t",
"want",
"to",
"provide",
"their",
"own",
"thread",
"creation",
"."
] | python | train | 36 |
elapouya/addicted3 | addicted/__init__.py | https://github.com/elapouya/addicted3/blob/888d7d0ce3b53b7f1a2f33c1e7f5aa80369e76de/addicted/__init__.py#L262-L290 | def update(self, *args, **kwargs):
""" update() method will *recursively* update nested dict:
>>> d=Dict({'a':{'b':{'c':3,'d':4},'h':4}})
>>> d.update({'a':{'b':{'c':'888'}}})
>>> d
{'a': {'b': {'c': '888', 'd': 4}, 'h': 4}}
please use update_dict() ... | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"arg",
"in",
"args",
":",
"if",
"not",
"arg",
":",
"continue",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"for",
"k",
",",
"v",
"in",
"arg",... | update() method will *recursively* update nested dict:
>>> d=Dict({'a':{'b':{'c':3,'d':4},'h':4}})
>>> d.update({'a':{'b':{'c':'888'}}})
>>> d
{'a': {'b': {'c': '888', 'd': 4}, 'h': 4}}
please use update_dict() if you do not want this behaviour | [
"update",
"()",
"method",
"will",
"*",
"recursively",
"*",
"update",
"nested",
"dict",
":"
] | python | train | 37.137931 |
saltstack/salt | salt/modules/xapi_virt.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L480-L532 | def vcpu_pin(vm_, vcpu, cpus):
'''
Set which CPUs a VCPU can use.
CLI Example:
.. code-block:: bash
salt 'foo' virt.vcpu_pin domU-id 2 1
salt 'foo' virt.vcpu_pin domU-id 2 2-6
'''
with _get_xapi_session() as xapi:
vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
if ... | [
"def",
"vcpu_pin",
"(",
"vm_",
",",
"vcpu",
",",
"cpus",
")",
":",
"with",
"_get_xapi_session",
"(",
")",
"as",
"xapi",
":",
"vm_uuid",
"=",
"_get_label_uuid",
"(",
"xapi",
",",
"'VM'",
",",
"vm_",
")",
"if",
"vm_uuid",
"is",
"False",
":",
"return",
... | Set which CPUs a VCPU can use.
CLI Example:
.. code-block:: bash
salt 'foo' virt.vcpu_pin domU-id 2 1
salt 'foo' virt.vcpu_pin domU-id 2 2-6 | [
"Set",
"which",
"CPUs",
"a",
"VCPU",
"can",
"use",
"."
] | python | train | 32.886792 |
ansible/tower-cli | tower_cli/resources/notification_template.py | https://github.com/ansible/tower-cli/blob/a2b151fed93c47725018d3034848cb3a1814bed7/tower_cli/resources/notification_template.py#L266-L333 | def modify(self, pk=None, create_on_missing=False, **kwargs):
"""Modify an existing notification template.
Not all required configuration-related fields (required according to
notification_type) should be provided.
Fields in the resource's `identity` tuple can be used in lieu of a
... | [
"def",
"modify",
"(",
"self",
",",
"pk",
"=",
"None",
",",
"create_on_missing",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Create the resource if needed.",
"if",
"pk",
"is",
"None",
"and",
"create_on_missing",
":",
"try",
":",
"self",
".",
"get",
... | Modify an existing notification template.
Not all required configuration-related fields (required according to
notification_type) should be provided.
Fields in the resource's `identity` tuple can be used in lieu of a
primary key for a lookup; in such a case, only other fields are
... | [
"Modify",
"an",
"existing",
"notification",
"template",
"."
] | python | valid | 49.088235 |
onelogin/python3-saml | src/onelogin/saml2/metadata.py | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/metadata.py#L195-L217 | def sign_metadata(metadata, key, cert, sign_algorithm=OneLogin_Saml2_Constants.RSA_SHA1, digest_algorithm=OneLogin_Saml2_Constants.SHA1):
"""
Signs the metadata with the key/cert provided
:param metadata: SAML Metadata XML
:type metadata: string
:param key: x509 key
:ty... | [
"def",
"sign_metadata",
"(",
"metadata",
",",
"key",
",",
"cert",
",",
"sign_algorithm",
"=",
"OneLogin_Saml2_Constants",
".",
"RSA_SHA1",
",",
"digest_algorithm",
"=",
"OneLogin_Saml2_Constants",
".",
"SHA1",
")",
":",
"return",
"OneLogin_Saml2_Utils",
".",
"add_si... | Signs the metadata with the key/cert provided
:param metadata: SAML Metadata XML
:type metadata: string
:param key: x509 key
:type key: string
:param cert: x509 cert
:type cert: string
:returns: Signed Metadata
:rtype: string
:param sign_algor... | [
"Signs",
"the",
"metadata",
"with",
"the",
"key",
"/",
"cert",
"provided"
] | python | train | 32.217391 |
glomex/gcdt | gcdt/iam.py | https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/iam.py#L80-L111 | def build_policy(self, name, statements, roles, is_managed_policy=False):
"""
Generate policy for IAM cloudformation template
:param name: Name of the policy
:param statements: The "rules" the policy should have
:param roles: The roles associated with this policy
:param i... | [
"def",
"build_policy",
"(",
"self",
",",
"name",
",",
"statements",
",",
"roles",
",",
"is_managed_policy",
"=",
"False",
")",
":",
"if",
"is_managed_policy",
":",
"policy",
"=",
"ManagedPolicy",
"(",
"self",
".",
"name_strip",
"(",
"name",
",",
"True",
")... | Generate policy for IAM cloudformation template
:param name: Name of the policy
:param statements: The "rules" the policy should have
:param roles: The roles associated with this policy
:param is_managed_policy: True if managed policy
:return: Ref to new policy | [
"Generate",
"policy",
"for",
"IAM",
"cloudformation",
"template",
":",
"param",
"name",
":",
"Name",
"of",
"the",
"policy",
":",
"param",
"statements",
":",
"The",
"rules",
"the",
"policy",
"should",
"have",
":",
"param",
"roles",
":",
"The",
"roles",
"ass... | python | train | 35 |
icometrix/dicom2nifti | dicom2nifti/common.py | https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L309-L318 | def set_fd_value(tag, value):
"""
Setters for data that also work with implicit transfersyntax
:param value: the value to set on the tag
:param tag: the tag to read
"""
if tag.VR == 'OB' or tag.VR == 'UN':
value = struct.pack('d', value)
tag.value = value | [
"def",
"set_fd_value",
"(",
"tag",
",",
"value",
")",
":",
"if",
"tag",
".",
"VR",
"==",
"'OB'",
"or",
"tag",
".",
"VR",
"==",
"'UN'",
":",
"value",
"=",
"struct",
".",
"pack",
"(",
"'d'",
",",
"value",
")",
"tag",
".",
"value",
"=",
"value"
] | Setters for data that also work with implicit transfersyntax
:param value: the value to set on the tag
:param tag: the tag to read | [
"Setters",
"for",
"data",
"that",
"also",
"work",
"with",
"implicit",
"transfersyntax"
] | python | train | 28.3 |
Esri/ArcREST | src/arcrest/manageags/administration.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L382-L397 | def services(self):
"""
Gets the services object which will provide the ArcGIS Server's
admin information about services and folders.
"""
if self._resources is None:
self.__init()
if "services" in self._resources:
url = self._url + "/services"
... | [
"def",
"services",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"if",
"\"services\"",
"in",
"self",
".",
"_resources",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/services\"",
"return",
... | Gets the services object which will provide the ArcGIS Server's
admin information about services and folders. | [
"Gets",
"the",
"services",
"object",
"which",
"will",
"provide",
"the",
"ArcGIS",
"Server",
"s",
"admin",
"information",
"about",
"services",
"and",
"folders",
"."
] | python | train | 40.5625 |
sidecars/python-quickbooks | quickbooks/client.py | https://github.com/sidecars/python-quickbooks/blob/4cb2b6da46423bad8b32b85d87f9a97b698144fd/quickbooks/client.py#L139-L146 | def disconnect_account(self):
"""
Disconnect current account from the application
:return:
"""
url = self.disconnect_url
result = self.get(url)
return result | [
"def",
"disconnect_account",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"disconnect_url",
"result",
"=",
"self",
".",
"get",
"(",
"url",
")",
"return",
"result"
] | Disconnect current account from the application
:return: | [
"Disconnect",
"current",
"account",
"from",
"the",
"application",
":",
"return",
":"
] | python | train | 25.75 |
Alignak-monitoring/alignak | alignak/objects/item.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L260-L287 | def copy(self):
"""
Get a copy of this item but with a new id
:return: copy of this object with a new id
:rtype: object
"""
# New dummy item with it's own running properties
copied_item = self.__class__({})
# Now, copy the properties
for prop in s... | [
"def",
"copy",
"(",
"self",
")",
":",
"# New dummy item with it's own running properties",
"copied_item",
"=",
"self",
".",
"__class__",
"(",
"{",
"}",
")",
"# Now, copy the properties",
"for",
"prop",
"in",
"self",
".",
"__class__",
".",
"properties",
":",
"if",
... | Get a copy of this item but with a new id
:return: copy of this object with a new id
:rtype: object | [
"Get",
"a",
"copy",
"of",
"this",
"item",
"but",
"with",
"a",
"new",
"id"
] | python | train | 32.142857 |
wummel/linkchecker | third_party/dnspython/dns/resolver.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/dnspython/dns/resolver.py#L367-L401 | def read_resolv_conf(self, f):
"""Process f as a file in the /etc/resolv.conf format. If f is
a string, it is used as the name of the file to open; otherwise it
is treated as the file itself."""
if isinstance(f, basestring):
try:
f = open(f, 'r')
... | [
"def",
"read_resolv_conf",
"(",
"self",
",",
"f",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"basestring",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"f",
",",
"'r'",
")",
"except",
"IOError",
":",
"# /etc/resolv.conf doesn't exist, can't be read, etc.",... | Process f as a file in the /etc/resolv.conf format. If f is
a string, it is used as the name of the file to open; otherwise it
is treated as the file itself. | [
"Process",
"f",
"as",
"a",
"file",
"in",
"the",
"/",
"etc",
"/",
"resolv",
".",
"conf",
"format",
".",
"If",
"f",
"is",
"a",
"string",
"it",
"is",
"used",
"as",
"the",
"name",
"of",
"the",
"file",
"to",
"open",
";",
"otherwise",
"it",
"is",
"trea... | python | train | 39.142857 |
wummel/linkchecker | linkcheck/cache/robots_txt.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/cache/robots_txt.py#L45-L49 | def allows_url (self, url_data):
"""Ask robots.txt allowance."""
roboturl = url_data.get_robots_txt_url()
with self.get_lock(roboturl):
return self._allows_url(url_data, roboturl) | [
"def",
"allows_url",
"(",
"self",
",",
"url_data",
")",
":",
"roboturl",
"=",
"url_data",
".",
"get_robots_txt_url",
"(",
")",
"with",
"self",
".",
"get_lock",
"(",
"roboturl",
")",
":",
"return",
"self",
".",
"_allows_url",
"(",
"url_data",
",",
"roboturl... | Ask robots.txt allowance. | [
"Ask",
"robots",
".",
"txt",
"allowance",
"."
] | python | train | 42.2 |
Esri/ArcREST | src/arcrest/geometryservice/geometryservice.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L249-L313 | def buffer(self,
geometries,
inSR,
distances,
units,
outSR=None,
bufferSR=None,
unionResults=True,
geodesic=True
):
"""
The buffer operation is performed on a geometr... | [
"def",
"buffer",
"(",
"self",
",",
"geometries",
",",
"inSR",
",",
"distances",
",",
"units",
",",
"outSR",
"=",
"None",
",",
"bufferSR",
"=",
"None",
",",
"unionResults",
"=",
"True",
",",
"geodesic",
"=",
"True",
")",
":",
"url",
"=",
"self",
".",
... | The buffer operation is performed on a geometry service resource
The result of this operation is buffered polygons at the
specified distances for the input geometry array. Options are
available to union buffers and to use geodesic distance.
Inputs:
geometries - ... | [
"The",
"buffer",
"operation",
"is",
"performed",
"on",
"a",
"geometry",
"service",
"resource",
"The",
"result",
"of",
"this",
"operation",
"is",
"buffered",
"polygons",
"at",
"the",
"specified",
"distances",
"for",
"the",
"input",
"geometry",
"array",
".",
"Op... | python | train | 46.4 |
clalancette/pycdlib | pycdlib/pycdlib.py | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L1434-L1464 | def _parse_path_table(self, ptr_size, extent):
# type: (int, int) -> Tuple[List[path_table_record.PathTableRecord], Dict[int, path_table_record.PathTableRecord]]
'''
An internal method to parse a path table on an ISO. For each path
table entry found, a Path Table Record object is create... | [
"def",
"_parse_path_table",
"(",
"self",
",",
"ptr_size",
",",
"extent",
")",
":",
"# type: (int, int) -> Tuple[List[path_table_record.PathTableRecord], Dict[int, path_table_record.PathTableRecord]]",
"self",
".",
"_seek_to_extent",
"(",
"extent",
")",
"data",
"=",
"self",
".... | An internal method to parse a path table on an ISO. For each path
table entry found, a Path Table Record object is created, and the
callback is called.
Parameters:
vd - The volume descriptor that these path table records correspond to.
extent - The extent at which this path t... | [
"An",
"internal",
"method",
"to",
"parse",
"a",
"path",
"table",
"on",
"an",
"ISO",
".",
"For",
"each",
"path",
"table",
"entry",
"found",
"a",
"Path",
"Table",
"Record",
"object",
"is",
"created",
"and",
"the",
"callback",
"is",
"called",
"."
] | python | train | 42.548387 |
BD2KGenomics/toil-scripts | src/toil_scripts/rnaseq_unc/rnaseq_unc_pipeline.py | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/rnaseq_unc/rnaseq_unc_pipeline.py#L438-L476 | def merge_fastqs(job, job_vars):
"""
Unzips input sample and concats the Read1 and Read2 groups together.
job_vars: tuple Tuple of dictionaries: input_args and ids
"""
input_args, ids = job_vars
work_dir = job.fileStore.getLocalTempDir()
cores = input_args['cpu_count']
single_end_re... | [
"def",
"merge_fastqs",
"(",
"job",
",",
"job_vars",
")",
":",
"input_args",
",",
"ids",
"=",
"job_vars",
"work_dir",
"=",
"job",
".",
"fileStore",
".",
"getLocalTempDir",
"(",
")",
"cores",
"=",
"input_args",
"[",
"'cpu_count'",
"]",
"single_end_reads",
"=",... | Unzips input sample and concats the Read1 and Read2 groups together.
job_vars: tuple Tuple of dictionaries: input_args and ids | [
"Unzips",
"input",
"sample",
"and",
"concats",
"the",
"Read1",
"and",
"Read2",
"groups",
"together",
"."
] | python | train | 46.641026 |
jadolg/rocketchat_API | rocketchat_API/rocketchat.py | https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L247-L249 | def chat_react(self, msg_id, emoji='smile', **kwargs):
"""Updates the text of the chat message."""
return self.__call_api_post('chat.react', messageId=msg_id, emoji=emoji, kwargs=kwargs) | [
"def",
"chat_react",
"(",
"self",
",",
"msg_id",
",",
"emoji",
"=",
"'smile'",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__call_api_post",
"(",
"'chat.react'",
",",
"messageId",
"=",
"msg_id",
",",
"emoji",
"=",
"emoji",
",",
"kwargs",
... | Updates the text of the chat message. | [
"Updates",
"the",
"text",
"of",
"the",
"chat",
"message",
"."
] | python | train | 66.666667 |
numenta/nupic | src/nupic/data/sorter.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/sorter.py#L41-L113 | def sort(filename, key, outputFile, fields=None, watermark=1024 * 1024 * 100):
"""Sort a potentially big file
filename - the input file (standard File format)
key - a list of field names to sort by
outputFile - the name of the output file
fields - a list of fields that should be included (all fields if None)... | [
"def",
"sort",
"(",
"filename",
",",
"key",
",",
"outputFile",
",",
"fields",
"=",
"None",
",",
"watermark",
"=",
"1024",
"*",
"1024",
"*",
"100",
")",
":",
"if",
"fields",
"is",
"not",
"None",
":",
"assert",
"set",
"(",
"key",
")",
".",
"issubset"... | Sort a potentially big file
filename - the input file (standard File format)
key - a list of field names to sort by
outputFile - the name of the output file
fields - a list of fields that should be included (all fields if None)
watermark - when available memory goes bellow the watermark create a new chunk
... | [
"Sort",
"a",
"potentially",
"big",
"file"
] | python | valid | 32.712329 |
ReFirmLabs/binwalk | src/binwalk/core/settings.py | https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L187-L201 | def _system_path(self, subdir, basename=''):
'''
Gets the full path to the 'subdir/basename' file in the system binwalk directory.
@subdir - Subdirectory inside the system binwalk directory.
@basename - File name inside the subdirectory.
Returns the full path to the 'subdir/b... | [
"def",
"_system_path",
"(",
"self",
",",
"subdir",
",",
"basename",
"=",
"''",
")",
":",
"try",
":",
"return",
"self",
".",
"_file_path",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"system_dir",
",",
"subdir",
")",
",",
"basename",
")",
... | Gets the full path to the 'subdir/basename' file in the system binwalk directory.
@subdir - Subdirectory inside the system binwalk directory.
@basename - File name inside the subdirectory.
Returns the full path to the 'subdir/basename' file. | [
"Gets",
"the",
"full",
"path",
"to",
"the",
"subdir",
"/",
"basename",
"file",
"in",
"the",
"system",
"binwalk",
"directory",
"."
] | python | train | 35.866667 |
BernardFW/bernard | src/bernard/engine/fsm.py | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L171-L203 | async def _find_trigger(self,
request: Request,
origin: Optional[Text]=None,
internal: bool=False) \
-> Tuple[
Optional[BaseTrigger],
Optional[Type[BaseState]],
Optional[bool],... | [
"async",
"def",
"_find_trigger",
"(",
"self",
",",
"request",
":",
"Request",
",",
"origin",
":",
"Optional",
"[",
"Text",
"]",
"=",
"None",
",",
"internal",
":",
"bool",
"=",
"False",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"BaseTrigger",
"]",
",",
... | Find the best trigger for this request, or go away. | [
"Find",
"the",
"best",
"trigger",
"for",
"this",
"request",
"or",
"go",
"away",
"."
] | python | train | 28.787879 |
lltk/lltk | lltk/scraping.py | https://github.com/lltk/lltk/blob/d171de55c1b97695fddedf4b02401ae27bf1d634/lltk/scraping.py#L262-L269 | def _first(self, tag):
''' Returns the first element with required POS-tag. '''
self.getelements()
for element in self.elements:
if tag in self.pos(element):
return element
return None | [
"def",
"_first",
"(",
"self",
",",
"tag",
")",
":",
"self",
".",
"getelements",
"(",
")",
"for",
"element",
"in",
"self",
".",
"elements",
":",
"if",
"tag",
"in",
"self",
".",
"pos",
"(",
"element",
")",
":",
"return",
"element",
"return",
"None"
] | Returns the first element with required POS-tag. | [
"Returns",
"the",
"first",
"element",
"with",
"required",
"POS",
"-",
"tag",
"."
] | python | train | 24.125 |
saltstack/salt | salt/states/boto_apigateway.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_apigateway.py#L1020-L1031 | def _get_desired_deployment_id(self):
'''
Helper method to return the deployment id matching the desired deployment label for
this Swagger object based on the given api_name, swagger_file
'''
deployments = __salt__['boto_apigateway.describe_api_deployments'](restApiId=self.restAp... | [
"def",
"_get_desired_deployment_id",
"(",
"self",
")",
":",
"deployments",
"=",
"__salt__",
"[",
"'boto_apigateway.describe_api_deployments'",
"]",
"(",
"restApiId",
"=",
"self",
".",
"restApiId",
",",
"*",
"*",
"self",
".",
"_common_aws_args",
")",
".",
"get",
... | Helper method to return the deployment id matching the desired deployment label for
this Swagger object based on the given api_name, swagger_file | [
"Helper",
"method",
"to",
"return",
"the",
"deployment",
"id",
"matching",
"the",
"desired",
"deployment",
"label",
"for",
"this",
"Swagger",
"object",
"based",
"on",
"the",
"given",
"api_name",
"swagger_file"
] | python | train | 53.75 |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/cursor.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/cursor.py#L254-L267 | def _clone(self, deepcopy=True):
"""Internal clone helper."""
clone = self._clone_base()
values_to_clone = ("spec", "projection", "skip", "limit",
"max_time_ms", "max_await_time_ms", "comment",
"max", "min", "ordering", "explain", "hint",
... | [
"def",
"_clone",
"(",
"self",
",",
"deepcopy",
"=",
"True",
")",
":",
"clone",
"=",
"self",
".",
"_clone_base",
"(",
")",
"values_to_clone",
"=",
"(",
"\"spec\"",
",",
"\"projection\"",
",",
"\"skip\"",
",",
"\"limit\"",
",",
"\"max_time_ms\"",
",",
"\"max... | Internal clone helper. | [
"Internal",
"clone",
"helper",
"."
] | python | train | 49.928571 |
rosenbrockc/fortpy | fortpy/utility.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/utility.py#L206-L214 | def XML(content, source=None):
"""Parses the XML text using the ET.XML function, but handling the ParseError in
a user-friendly way.
"""
try:
tree = ET.XML(content)
except ET.ParseError as err:
x_parse_error(err, content, source)
return tree | [
"def",
"XML",
"(",
"content",
",",
"source",
"=",
"None",
")",
":",
"try",
":",
"tree",
"=",
"ET",
".",
"XML",
"(",
"content",
")",
"except",
"ET",
".",
"ParseError",
"as",
"err",
":",
"x_parse_error",
"(",
"err",
",",
"content",
",",
"source",
")"... | Parses the XML text using the ET.XML function, but handling the ParseError in
a user-friendly way. | [
"Parses",
"the",
"XML",
"text",
"using",
"the",
"ET",
".",
"XML",
"function",
"but",
"handling",
"the",
"ParseError",
"in",
"a",
"user",
"-",
"friendly",
"way",
"."
] | python | train | 30.333333 |
PMBio/limix-backup | limix/mtSet/core/read_utils.py | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/core/read_utils.py#L4-L11 | def readBimFile(basefilename):
"""
Helper fuinction that reads bim files
"""
# read bim file
bim_fn = basefilename+'.bim'
rv = SP.loadtxt(bim_fn,delimiter='\t',usecols = (0,3),dtype=int)
return rv | [
"def",
"readBimFile",
"(",
"basefilename",
")",
":",
"# read bim file",
"bim_fn",
"=",
"basefilename",
"+",
"'.bim'",
"rv",
"=",
"SP",
".",
"loadtxt",
"(",
"bim_fn",
",",
"delimiter",
"=",
"'\\t'",
",",
"usecols",
"=",
"(",
"0",
",",
"3",
")",
",",
"dt... | Helper fuinction that reads bim files | [
"Helper",
"fuinction",
"that",
"reads",
"bim",
"files"
] | python | train | 27.125 |
aliyun/aliyun-log-python-sdk | aliyun/log/logclient.py | https://github.com/aliyun/aliyun-log-python-sdk/blob/ac383db0a16abf1e5ef7df36074374184b43516e/aliyun/log/logclient.py#L2038-L2082 | def update_consumer_group(self, project, logstore, consumer_group, timeout=None, in_order=None):
""" Update consumer group
:type project: string
:param project: project name
:type logstore: string
:param logstore: logstore name
:type consumer_group: string
... | [
"def",
"update_consumer_group",
"(",
"self",
",",
"project",
",",
"logstore",
",",
"consumer_group",
",",
"timeout",
"=",
"None",
",",
"in_order",
"=",
"None",
")",
":",
"if",
"in_order",
"is",
"None",
"and",
"timeout",
"is",
"None",
":",
"raise",
"ValueEr... | Update consumer group
:type project: string
:param project: project name
:type logstore: string
:param logstore: logstore name
:type consumer_group: string
:param consumer_group: consumer group name
:type timeout: int
:param timeout: timeou... | [
"Update",
"consumer",
"group",
":",
"type",
"project",
":",
"string",
":",
"param",
"project",
":",
"project",
"name",
":",
"type",
"logstore",
":",
"string",
":",
"param",
"logstore",
":",
"logstore",
"name",
":",
"type",
"consumer_group",
":",
"string",
... | python | train | 31.755556 |
gwww/elkm1 | elkm1_lib/panel.py | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/panel.py#L19-L28 | def sync(self):
"""Retrieve panel information from ElkM1"""
self._elk.add_handler('VN', self._vn_handler)
self._elk.add_handler('XK', self._xk_handler)
self._elk.add_handler('RP', self._rp_handler)
self._elk.add_handler('IE', self._elk.call_sync_handlers)
self._elk.add_ha... | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"_elk",
".",
"add_handler",
"(",
"'VN'",
",",
"self",
".",
"_vn_handler",
")",
"self",
".",
"_elk",
".",
"add_handler",
"(",
"'XK'",
",",
"self",
".",
"_xk_handler",
")",
"self",
".",
"_elk",
".",
... | Retrieve panel information from ElkM1 | [
"Retrieve",
"panel",
"information",
"from",
"ElkM1"
] | python | train | 44.8 |
onicagroup/runway | runway/commands/runway/gen_sample.py | https://github.com/onicagroup/runway/blob/3f3549ec3bf6e39b9f27d9738a1847f3a4369e7f/runway/commands/runway/gen_sample.py#L18-L25 | def generate_sample_module(module_dir):
"""Generate skeleton sample module."""
if os.path.isdir(module_dir):
LOGGER.error("Error generating sample module -- directory %s "
"already exists!",
module_dir)
sys.exit(1)
os.mkdir(module_dir) | [
"def",
"generate_sample_module",
"(",
"module_dir",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"module_dir",
")",
":",
"LOGGER",
".",
"error",
"(",
"\"Error generating sample module -- directory %s \"",
"\"already exists!\"",
",",
"module_dir",
")",
"sys"... | Generate skeleton sample module. | [
"Generate",
"skeleton",
"sample",
"module",
"."
] | python | train | 37.25 |
NyashniyVladya/MarkovTextGenerator | MarkovTextGenerator/markov_text_generator.py | https://github.com/NyashniyVladya/MarkovTextGenerator/blob/3d90e02a507939709773ef01c7ff3ec68b2b8d4b/MarkovTextGenerator/markov_text_generator.py#L382-L395 | def _parse_from_file(self, file_path):
"""
см. описание _parse_from_text.
Только на вход подаётся не текст, а путь к файлу.
"""
file_path = abspath(file_path)
if not isfile(file_path):
raise MarkovTextExcept("Передан не файл.")
with open(file_path, "rb... | [
"def",
"_parse_from_file",
"(",
"self",
",",
"file_path",
")",
":",
"file_path",
"=",
"abspath",
"(",
"file_path",
")",
"if",
"not",
"isfile",
"(",
"file_path",
")",
":",
"raise",
"MarkovTextExcept",
"(",
"\"Передан не файл.\")",
"",
"with",
"open",
"(",
"fi... | см. описание _parse_from_text.
Только на вход подаётся не текст, а путь к файлу. | [
"см",
".",
"описание",
"_parse_from_text",
".",
"Только",
"на",
"вход",
"подаётся",
"не",
"текст",
"а",
"путь",
"к",
"файлу",
"."
] | python | valid | 37.928571 |
PyPSA/PyPSA | examples/scigrid-de/add_load_gen_trafos_to_scigrid.py | https://github.com/PyPSA/PyPSA/blob/46954b1b3c21460550f7104681517065279a53b7/examples/scigrid-de/add_load_gen_trafos_to_scigrid.py#L636-L651 | def panel_capacity(panel):
"""
Returns the panel capacity in MW.
Parameters
----------
panel : string
Panel name, e.g. "Sunpower"
Returns
-------
capacity : float
In MW
"""
c = vresutils.reatlas.solarpanelconf_to_solar_panel_config_object(panel)
retu... | [
"def",
"panel_capacity",
"(",
"panel",
")",
":",
"c",
"=",
"vresutils",
".",
"reatlas",
".",
"solarpanelconf_to_solar_panel_config_object",
"(",
"panel",
")",
"return",
"c",
"[",
"'A'",
"]",
"+",
"c",
"[",
"'B'",
"]",
"*",
"1000",
"+",
"c",
"[",
"'C'",
... | Returns the panel capacity in MW.
Parameters
----------
panel : string
Panel name, e.g. "Sunpower"
Returns
-------
capacity : float
In MW | [
"Returns",
"the",
"panel",
"capacity",
"in",
"MW",
".",
"Parameters",
"----------",
"panel",
":",
"string",
"Panel",
"name",
"e",
".",
"g",
".",
"Sunpower",
"Returns",
"-------",
"capacity",
":",
"float",
"In",
"MW"
] | python | train | 22.125 |
cokelaer/spectrum | src/spectrum/window.py | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L824-L845 | def window_lanczos(N):
r"""Lanczos window also known as sinc window.
:param N: window length
.. math:: w(n) = sinc \left( \frac{2n}{N-1} - 1 \right)
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'lanczos')
.. seealso:: :... | [
"def",
"window_lanczos",
"(",
"N",
")",
":",
"if",
"N",
"==",
"1",
":",
"return",
"ones",
"(",
"1",
")",
"n",
"=",
"linspace",
"(",
"-",
"N",
"/",
"2.",
",",
"N",
"/",
"2.",
",",
"N",
")",
"win",
"=",
"sinc",
"(",
"2",
"*",
"n",
"/",
"(",... | r"""Lanczos window also known as sinc window.
:param N: window length
.. math:: w(n) = sinc \left( \frac{2n}{N-1} - 1 \right)
.. plot::
:width: 80%
:include-source:
from spectrum import window_visu
window_visu(64, 'lanczos')
.. seealso:: :func:`create_window`, :clas... | [
"r",
"Lanczos",
"window",
"also",
"known",
"as",
"sinc",
"window",
"."
] | python | valid | 20.772727 |
lizardsystem/tags2sdists | tags2sdists/checkoutdir.py | https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/checkoutdir.py#L102-L114 | def create_sdist(self, tag):
"""Create an sdist and return the full file path of the .tar.gz."""
logger.info("Making tempdir for %s with tag %s...",
self.package, tag)
self.wrapper.vcs.checkout_from_tag(tag)
# checkout_from_tag() chdirs to a temp directory that we nee... | [
"def",
"create_sdist",
"(",
"self",
",",
"tag",
")",
":",
"logger",
".",
"info",
"(",
"\"Making tempdir for %s with tag %s...\"",
",",
"self",
".",
"package",
",",
"tag",
")",
"self",
".",
"wrapper",
".",
"vcs",
".",
"checkout_from_tag",
"(",
"tag",
")",
"... | Create an sdist and return the full file path of the .tar.gz. | [
"Create",
"an",
"sdist",
"and",
"return",
"the",
"full",
"file",
"path",
"of",
"the",
".",
"tar",
".",
"gz",
"."
] | python | train | 49.692308 |
Varkal/chuda | chuda/shell.py | https://github.com/Varkal/chuda/blob/0d93b716dede35231c21be97bcc19a656655983f/chuda/shell.py#L131-L143 | def poll_output(self):
"""
Append lines from stdout to self.output.
Returns:
list: The lines added since last call
"""
if self.block:
return self.output
new_list = self.output[self.old_output_size:]
self.old_output_size += len(new_list)
... | [
"def",
"poll_output",
"(",
"self",
")",
":",
"if",
"self",
".",
"block",
":",
"return",
"self",
".",
"output",
"new_list",
"=",
"self",
".",
"output",
"[",
"self",
".",
"old_output_size",
":",
"]",
"self",
".",
"old_output_size",
"+=",
"len",
"(",
"new... | Append lines from stdout to self.output.
Returns:
list: The lines added since last call | [
"Append",
"lines",
"from",
"stdout",
"to",
"self",
".",
"output",
"."
] | python | train | 25.384615 |
lsst-sqre/lsst-projectmeta-kit | lsstprojectmeta/tex/normalizer.py | https://github.com/lsst-sqre/lsst-projectmeta-kit/blob/ac8d4ff65bb93d8fdeb1b46ae6eb5d7414f1ae14/lsstprojectmeta/tex/normalizer.py#L25-L39 | def remove_comments(tex_source):
"""Delete latex comments from TeX source.
Parameters
----------
tex_source : str
TeX source content.
Returns
-------
tex_source : str
TeX source without comments.
"""
# Expression via http://stackoverflow.com/a/13365453
return re... | [
"def",
"remove_comments",
"(",
"tex_source",
")",
":",
"# Expression via http://stackoverflow.com/a/13365453",
"return",
"re",
".",
"sub",
"(",
"r'(?<!\\\\)%.*$'",
",",
"r''",
",",
"tex_source",
",",
"flags",
"=",
"re",
".",
"M",
")"
] | Delete latex comments from TeX source.
Parameters
----------
tex_source : str
TeX source content.
Returns
-------
tex_source : str
TeX source without comments. | [
"Delete",
"latex",
"comments",
"from",
"TeX",
"source",
"."
] | python | valid | 23.666667 |
SiLab-Bonn/basil | basil/HL/FEI4AdapterCard.py | https://github.com/SiLab-Bonn/basil/blob/99052482d9334dd1f5598eb2d2fb4d5399a32291/basil/HL/FEI4AdapterCard.py#L45-L48 | def _setup_adc(self, flags):
'''Initialize ADC
'''
self._intf.write(self._base_addr + self.MAX_1239_ADD, array('B', pack('B', flags))) | [
"def",
"_setup_adc",
"(",
"self",
",",
"flags",
")",
":",
"self",
".",
"_intf",
".",
"write",
"(",
"self",
".",
"_base_addr",
"+",
"self",
".",
"MAX_1239_ADD",
",",
"array",
"(",
"'B'",
",",
"pack",
"(",
"'B'",
",",
"flags",
")",
")",
")"
] | Initialize ADC | [
"Initialize",
"ADC"
] | python | train | 38.75 |
paramiko/paramiko | paramiko/sftp_client.py | https://github.com/paramiko/paramiko/blob/cf7d49d66f3b1fbc8b0853518a54050182b3b5eb/paramiko/sftp_client.py#L900-L913 | def _adjust_cwd(self, path):
"""
Return an adjusted path if we're emulating a "current working
directory" for the server.
"""
path = b(path)
if self._cwd is None:
return path
if len(path) and path[0:1] == b_slash:
# absolute path
... | [
"def",
"_adjust_cwd",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"b",
"(",
"path",
")",
"if",
"self",
".",
"_cwd",
"is",
"None",
":",
"return",
"path",
"if",
"len",
"(",
"path",
")",
"and",
"path",
"[",
"0",
":",
"1",
"]",
"==",
"b_slash"... | Return an adjusted path if we're emulating a "current working
directory" for the server. | [
"Return",
"an",
"adjusted",
"path",
"if",
"we",
"re",
"emulating",
"a",
"current",
"working",
"directory",
"for",
"the",
"server",
"."
] | python | train | 30.785714 |
mrstephenneal/mysql-toolkit | mysql/toolkit/components/operations/alter.py | https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/components/operations/alter.py#L6-L19 | def rename(self, old_table, new_table):
"""
Rename a table.
You must have ALTER and DROP privileges for the original table,
and CREATE and INSERT privileges for the new table.
"""
try:
command = 'RENAME TABLE {0} TO {1}'.format(wrap(old_table), wrap(new_table... | [
"def",
"rename",
"(",
"self",
",",
"old_table",
",",
"new_table",
")",
":",
"try",
":",
"command",
"=",
"'RENAME TABLE {0} TO {1}'",
".",
"format",
"(",
"wrap",
"(",
"old_table",
")",
",",
"wrap",
"(",
"new_table",
")",
")",
"except",
":",
"command",
"="... | Rename a table.
You must have ALTER and DROP privileges for the original table,
and CREATE and INSERT privileges for the new table. | [
"Rename",
"a",
"table",
"."
] | python | train | 40.571429 |
saltstack/salt | salt/modules/win_task.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_task.py#L369-L399 | def list_folders(location='\\'):
r'''
List all folders located in a specific location in the task scheduler.
:param str location: A string value representing the folder from which you
want to list tasks. Default is '\\' which is the root for the task
scheduler (C:\Windows\System32\tasks).
... | [
"def",
"list_folders",
"(",
"location",
"=",
"'\\\\'",
")",
":",
"# Create the task service object",
"with",
"salt",
".",
"utils",
".",
"winapi",
".",
"Com",
"(",
")",
":",
"task_service",
"=",
"win32com",
".",
"client",
".",
"Dispatch",
"(",
"\"Schedule.Servi... | r'''
List all folders located in a specific location in the task scheduler.
:param str location: A string value representing the folder from which you
want to list tasks. Default is '\\' which is the root for the task
scheduler (C:\Windows\System32\tasks).
:return: Returns a list of folder... | [
"r",
"List",
"all",
"folders",
"located",
"in",
"a",
"specific",
"location",
"in",
"the",
"task",
"scheduler",
"."
] | python | train | 26.806452 |
PyCQA/pylint | pylint/lint.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/lint.py#L781-L785 | def disable_reporters(self):
"""disable all reporters"""
for _reporters in self._reports.values():
for report_id, _, _ in _reporters:
self.disable_report(report_id) | [
"def",
"disable_reporters",
"(",
"self",
")",
":",
"for",
"_reporters",
"in",
"self",
".",
"_reports",
".",
"values",
"(",
")",
":",
"for",
"report_id",
",",
"_",
",",
"_",
"in",
"_reporters",
":",
"self",
".",
"disable_report",
"(",
"report_id",
")"
] | disable all reporters | [
"disable",
"all",
"reporters"
] | python | test | 40.8 |
StackStorm/pybind | pybind/slxos/v17s_1_02/routing_system/interface/ve/ipv6/interface_ospfv3_conf/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/routing_system/interface/ve/ipv6/interface_ospfv3_conf/__init__.py#L368-L391 | def _set_network(self, v, load=False):
"""
Setter method for network, mapped from YANG variable /routing_system/interface/ve/ipv6/interface_ospfv3_conf/network (enumeration)
If this variable is read-only (config: false) in the
source YANG file, then _set_network is considered as a private
method. Ba... | [
"def",
"_set_network",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",... | Setter method for network, mapped from YANG variable /routing_system/interface/ve/ipv6/interface_ospfv3_conf/network (enumeration)
If this variable is read-only (config: false) in the
source YANG file, then _set_network is considered as a private
method. Backends looking to populate this variable should
... | [
"Setter",
"method",
"for",
"network",
"mapped",
"from",
"YANG",
"variable",
"/",
"routing_system",
"/",
"interface",
"/",
"ve",
"/",
"ipv6",
"/",
"interface_ospfv3_conf",
"/",
"network",
"(",
"enumeration",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"... | python | train | 88.541667 |
IdentityPython/pysaml2 | src/saml2/ident.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/ident.py#L49-L56 | def code_binary(item):
"""
Return a binary 'code' suitable for hashing.
"""
code_str = code(item)
if isinstance(code_str, six.string_types):
return code_str.encode('utf-8')
return code_str | [
"def",
"code_binary",
"(",
"item",
")",
":",
"code_str",
"=",
"code",
"(",
"item",
")",
"if",
"isinstance",
"(",
"code_str",
",",
"six",
".",
"string_types",
")",
":",
"return",
"code_str",
".",
"encode",
"(",
"'utf-8'",
")",
"return",
"code_str"
] | Return a binary 'code' suitable for hashing. | [
"Return",
"a",
"binary",
"code",
"suitable",
"for",
"hashing",
"."
] | python | train | 26.625 |
rackerlabs/simpl | simpl/git.py | https://github.com/rackerlabs/simpl/blob/60ed3336a931cd6a7a7246e60f26165d9dc7c99c/simpl/git.py#L125-L140 | def git_clone(target_dir, repo_location, branch_or_tag=None, verbose=True):
"""Clone repo at repo_location to target_dir and checkout branch_or_tag.
If branch_or_tag is not specified, the HEAD of the primary
branch of the cloned repo is checked out.
"""
target_dir = pipes.quote(target_dir)
comm... | [
"def",
"git_clone",
"(",
"target_dir",
",",
"repo_location",
",",
"branch_or_tag",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"target_dir",
"=",
"pipes",
".",
"quote",
"(",
"target_dir",
")",
"command",
"=",
"[",
"'git'",
",",
"'clone'",
"]",
"i... | Clone repo at repo_location to target_dir and checkout branch_or_tag.
If branch_or_tag is not specified, the HEAD of the primary
branch of the cloned repo is checked out. | [
"Clone",
"repo",
"at",
"repo_location",
"to",
"target_dir",
"and",
"checkout",
"branch_or_tag",
"."
] | python | train | 39.5 |
Microsoft/nni | src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py#L81-L124 | def create_new_layer(layer, n_dim):
''' create new layer for the graph
'''
input_shape = layer.output.shape
dense_deeper_classes = [StubDense, get_dropout_class(n_dim), StubReLU]
conv_deeper_classes = [get_conv_class(n_dim), get_batch_norm_class(n_dim), StubReLU]
if is_layer(layer, "ReLU"):
... | [
"def",
"create_new_layer",
"(",
"layer",
",",
"n_dim",
")",
":",
"input_shape",
"=",
"layer",
".",
"output",
".",
"shape",
"dense_deeper_classes",
"=",
"[",
"StubDense",
",",
"get_dropout_class",
"(",
"n_dim",
")",
",",
"StubReLU",
"]",
"conv_deeper_classes",
... | create new layer for the graph | [
"create",
"new",
"layer",
"for",
"the",
"graph"
] | python | train | 35.068182 |
bspaans/python-mingus | mingus/midi/sequencer.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/sequencer.py#L129-L145 | def play_Note(self, note, channel=1, velocity=100):
"""Play a Note object on a channel with a velocity[0-127].
You can either specify the velocity and channel here as arguments or
you can set the Note.velocity and Note.channel attributes, which
will take presedence over the function arg... | [
"def",
"play_Note",
"(",
"self",
",",
"note",
",",
"channel",
"=",
"1",
",",
"velocity",
"=",
"100",
")",
":",
"if",
"hasattr",
"(",
"note",
",",
"'velocity'",
")",
":",
"velocity",
"=",
"note",
".",
"velocity",
"if",
"hasattr",
"(",
"note",
",",
"... | Play a Note object on a channel with a velocity[0-127].
You can either specify the velocity and channel here as arguments or
you can set the Note.velocity and Note.channel attributes, which
will take presedence over the function arguments. | [
"Play",
"a",
"Note",
"object",
"on",
"a",
"channel",
"with",
"a",
"velocity",
"[",
"0",
"-",
"127",
"]",
"."
] | python | train | 48.705882 |
ales-erjavec/anyqt | AnyQt/_backport/_utils.py | https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/_backport/_utils.py#L4-L25 | def obsolete_rename(oldname, newfunc):
"""
Simple obsolete/removed method decorator
Parameters
----------
oldname : str
The name of the old obsolete name
newfunc : FunctionType
Replacement unbound member function.
"""
newname = newfunc.__name__
def __obsolete(*args, ... | [
"def",
"obsolete_rename",
"(",
"oldname",
",",
"newfunc",
")",
":",
"newname",
"=",
"newfunc",
".",
"__name__",
"def",
"__obsolete",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"{oldname} is obsolete and is removed in P... | Simple obsolete/removed method decorator
Parameters
----------
oldname : str
The name of the old obsolete name
newfunc : FunctionType
Replacement unbound member function. | [
"Simple",
"obsolete",
"/",
"removed",
"method",
"decorator"
] | python | train | 28.909091 |
glitchassassin/lackey | lackey/RegionMatching.py | https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/RegionMatching.py#L222-L231 | def setLocation(self, location):
""" Change the upper left-hand corner to a new ``Location``
Doesn't change width or height
"""
if not location or not isinstance(location, Location):
raise ValueError("setLocation expected a Location object")
self.x = location.x
... | [
"def",
"setLocation",
"(",
"self",
",",
"location",
")",
":",
"if",
"not",
"location",
"or",
"not",
"isinstance",
"(",
"location",
",",
"Location",
")",
":",
"raise",
"ValueError",
"(",
"\"setLocation expected a Location object\"",
")",
"self",
".",
"x",
"=",
... | Change the upper left-hand corner to a new ``Location``
Doesn't change width or height | [
"Change",
"the",
"upper",
"left",
"-",
"hand",
"corner",
"to",
"a",
"new",
"Location"
] | python | train | 35.3 |
ToucanToco/toucan-data-sdk | toucan_data_sdk/utils/helpers.py | https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/helpers.py#L25-L45 | def get_param_value_from_func_call(param_name, func, call_args, call_kwargs):
"""
Get the value of a function's parameter based on its signature
and the call's args and kwargs.
Example:
>>> def foo(a, b, c=3, d=4):
... pass
...
>>> # what would be the value of "c" whe... | [
"def",
"get_param_value_from_func_call",
"(",
"param_name",
",",
"func",
",",
"call_args",
",",
"call_kwargs",
")",
":",
"signature",
"=",
"inspect",
".",
"signature",
"(",
"func",
")",
"params_list",
"=",
"signature",
".",
"parameters",
".",
"keys",
"(",
")",... | Get the value of a function's parameter based on its signature
and the call's args and kwargs.
Example:
>>> def foo(a, b, c=3, d=4):
... pass
...
>>> # what would be the value of "c" when calling foo(1, b=2, c=33) ?
>>> get_param_value_from_func_call('c', foo, [1], {'... | [
"Get",
"the",
"value",
"of",
"a",
"function",
"s",
"parameter",
"based",
"on",
"its",
"signature",
"and",
"the",
"call",
"s",
"args",
"and",
"kwargs",
"."
] | python | test | 38.047619 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.