hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
892130f637c39936630889e617696da695ecdecf | sunlongbo/chromium | chrome/installer/mac/universalizer.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _read_plist | <not_specific> | def _read_plist(path):
"""Reads a macOS property list, API compatibility adapter."""
with open(path, 'rb') as file:
try:
# New API, available since Python 3.4.
return plistlib.load(file)
except AttributeError:
# Old API, available (but deprecated) until Python... | Reads a macOS property list, API compatibility adapter. | Reads a macOS property list, API compatibility adapter. | [
"Reads",
"a",
"macOS",
"property",
"list",
"API",
"compatibility",
"adapter",
"."
] | def _read_plist(path):
with open(path, 'rb') as file:
try:
return plistlib.load(file)
except AttributeError:
return plistlib.readPlist(file) | [
"def",
"_read_plist",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"file",
":",
"try",
":",
"return",
"plistlib",
".",
"load",
"(",
"file",
")",
"except",
"AttributeError",
":",
"return",
"plistlib",
".",
"readPlist",
"("... | Reads a macOS property list, API compatibility adapter. | [
"Reads",
"a",
"macOS",
"property",
"list",
"API",
"compatibility",
"adapter",
"."
] | [
"\"\"\"Reads a macOS property list, API compatibility adapter.\"\"\"",
"# New API, available since Python 3.4.",
"# Old API, available (but deprecated) until Python 3.9."
] | [
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
892130f637c39936630889e617696da695ecdecf | sunlongbo/chromium | chrome/installer/mac/universalizer.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _write_plist | null | def _write_plist(value, path):
"""Writes a macOS property list, API compatibility adapter."""
with open(path, 'wb') as file:
try:
# New API, available since Python 3.4.
plistlib.dump(value, file)
except AttributeError:
# Old API, available (but deprecated) unt... | Writes a macOS property list, API compatibility adapter. | Writes a macOS property list, API compatibility adapter. | [
"Writes",
"a",
"macOS",
"property",
"list",
"API",
"compatibility",
"adapter",
"."
] | def _write_plist(value, path):
with open(path, 'wb') as file:
try:
plistlib.dump(value, file)
except AttributeError:
plistlib.writePlist(value, file) | [
"def",
"_write_plist",
"(",
"value",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'wb'",
")",
"as",
"file",
":",
"try",
":",
"plistlib",
".",
"dump",
"(",
"value",
",",
"file",
")",
"except",
"AttributeError",
":",
"plistlib",
".",
"writ... | Writes a macOS property list, API compatibility adapter. | [
"Writes",
"a",
"macOS",
"property",
"list",
"API",
"compatibility",
"adapter",
"."
] | [
"\"\"\"Writes a macOS property list, API compatibility adapter.\"\"\"",
"# New API, available since Python 3.4.",
"# Old API, available (but deprecated) until Python 3.9."
] | [
{
"param": "value",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": ... |
8943b9f6dce1d4b87c31fd22f49f6382ad7ba855 | sunlongbo/chromium | testing/buildbot/scripts/upload_test_result_artifacts_unittest.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | testUploadArtifactsMissingType | null | def testUploadArtifactsMissingType(self):
"""Tests that the type information is used for validation."""
data = {
'artifact_type_info': {
'log': 'text/plain'
},
'tests': {
'foo': {
'actual': 'PASS',
'expected': 'PASS',
'artifacts':... | Tests that the type information is used for validation. | Tests that the type information is used for validation. | [
"Tests",
"that",
"the",
"type",
"information",
"is",
"used",
"for",
"validation",
"."
] | def testUploadArtifactsMissingType(self):
data = {
'artifact_type_info': {
'log': 'text/plain'
},
'tests': {
'foo': {
'actual': 'PASS',
'expected': 'PASS',
'artifacts': {
'screenshot': 'foo.png',
}
... | [
"def",
"testUploadArtifactsMissingType",
"(",
"self",
")",
":",
"data",
"=",
"{",
"'artifact_type_info'",
":",
"{",
"'log'",
":",
"'text/plain'",
"}",
",",
"'tests'",
":",
"{",
"'foo'",
":",
"{",
"'actual'",
":",
"'PASS'",
",",
"'expected'",
":",
"'PASS'",
... | Tests that the type information is used for validation. | [
"Tests",
"that",
"the",
"type",
"information",
"is",
"used",
"for",
"validation",
"."
] | [
"\"\"\"Tests that the type information is used for validation.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8943b9f6dce1d4b87c31fd22f49f6382ad7ba855 | sunlongbo/chromium | testing/buildbot/scripts/upload_test_result_artifacts_unittest.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | testUploadArtifactsNoUpload | null | def testUploadArtifactsNoUpload(
self, copy_patch, rmtree_patch, mkd_patch, digest_patch):
"""Simple test; no artifacts, so data shouldn't change."""
mkd_patch.return_value = 'foo_dir'
data = {
'artifact_type_info': {
'log': 'text/plain'
},
'tests': {
'foo... | Simple test; no artifacts, so data shouldn't change. | Simple test; no artifacts, so data shouldn't change. | [
"Simple",
"test",
";",
"no",
"artifacts",
"so",
"data",
"shouldn",
"'",
"t",
"change",
"."
] | def testUploadArtifactsNoUpload(
self, copy_patch, rmtree_patch, mkd_patch, digest_patch):
mkd_patch.return_value = 'foo_dir'
data = {
'artifact_type_info': {
'log': 'text/plain'
},
'tests': {
'foo': {
'actual': 'PASS',
'expected': 'PAS... | [
"def",
"testUploadArtifactsNoUpload",
"(",
"self",
",",
"copy_patch",
",",
"rmtree_patch",
",",
"mkd_patch",
",",
"digest_patch",
")",
":",
"mkd_patch",
".",
"return_value",
"=",
"'foo_dir'",
"data",
"=",
"{",
"'artifact_type_info'",
":",
"{",
"'log'",
":",
"'te... | Simple test; no artifacts, so data shouldn't change. | [
"Simple",
"test",
";",
"no",
"artifacts",
"so",
"data",
"shouldn",
"'",
"t",
"change",
"."
] | [
"\"\"\"Simple test; no artifacts, so data shouldn't change.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "copy_patch",
"type": null
},
{
"param": "rmtree_patch",
"type": null
},
{
"param": "mkd_patch",
"type": null
},
{
"param": "digest_patch",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "copy_patch",
"type": null,
"docstring": null,
"docstring_toke... |
90bb0d696fc9c799296fdfb21c111d5de219cd5b | sunlongbo/chromium | content/test/gpu/gold_inexact_matching/local_minima_parameter_optimizer.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _ParametersAreGuaranteedToFail | <not_specific> | def _ParametersAreGuaranteedToFail(self, parameters):
"""Checks whether the given ParameterSet is guaranteed to fail.
A ParameterSet is guaranteed to fail if we have already tried and failed
with a similar ParameterSet that was more permissive. Specifically, if we
have tried and failed with a Parameter... | Checks whether the given ParameterSet is guaranteed to fail.
A ParameterSet is guaranteed to fail if we have already tried and failed
with a similar ParameterSet that was more permissive. Specifically, if we
have tried and failed with a ParameterSet with all but one parameters
matching, and the non-mat... | Checks whether the given ParameterSet is guaranteed to fail.
A ParameterSet is guaranteed to fail if we have already tried and failed
with a similar ParameterSet that was more permissive. Specifically, if we
have tried and failed with a ParameterSet with all but one parameters
matching, and the non-matching parameter w... | [
"Checks",
"whether",
"the",
"given",
"ParameterSet",
"is",
"guaranteed",
"to",
"fail",
".",
"A",
"ParameterSet",
"is",
"guaranteed",
"to",
"fail",
"if",
"we",
"have",
"already",
"tried",
"and",
"failed",
"with",
"a",
"similar",
"ParameterSet",
"that",
"was",
... | def _ParametersAreGuaranteedToFail(self, parameters):
permissive_max_diff = self._permissive_max_diff_map.get(
parameters.delta_threshold, {}).get(parameters.edge_threshold, -1)
if parameters.max_diff < permissive_max_diff:
return True
permissive_delta = self._permissive_delta_map.get(
... | [
"def",
"_ParametersAreGuaranteedToFail",
"(",
"self",
",",
"parameters",
")",
":",
"permissive_max_diff",
"=",
"self",
".",
"_permissive_max_diff_map",
".",
"get",
"(",
"parameters",
".",
"delta_threshold",
",",
"{",
"}",
")",
".",
"get",
"(",
"parameters",
".",... | Checks whether the given ParameterSet is guaranteed to fail. | [
"Checks",
"whether",
"the",
"given",
"ParameterSet",
"is",
"guaranteed",
"to",
"fail",
"."
] | [
"\"\"\"Checks whether the given ParameterSet is guaranteed to fail.\n\n A ParameterSet is guaranteed to fail if we have already tried and failed\n with a similar ParameterSet that was more permissive. Specifically, if we\n have tried and failed with a ParameterSet with all but one parameters\n matching,... | [
{
"param": "self",
"type": null
},
{
"param": "parameters",
"type": null
}
] | {
"returns": [
{
"docstring": "True if |parameters| is guaranteed to fail based on previously tried\nparameters, otherwise False.",
"docstring_tokens": [
"True",
"if",
"|parameters|",
"is",
"guaranteed",
"to",
"fail",
"based",
"on... |
90bb0d696fc9c799296fdfb21c111d5de219cd5b | sunlongbo/chromium | content/test/gpu/gold_inexact_matching/local_minima_parameter_optimizer.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _UpdateMostPermissiveFailedParameters | null | def _UpdateMostPermissiveFailedParameters(self, parameters):
"""Updates the array of most permissive failed parameters.
This is used in conjunction with _ParametersAreGuaranteedToFail to prune
ParameterSets without having to actually test them. Values are updated if
|parameters| shares two parameters w... | Updates the array of most permissive failed parameters.
This is used in conjunction with _ParametersAreGuaranteedToFail to prune
ParameterSets without having to actually test them. Values are updated if
|parameters| shares two parameters with a a previously failed ParameterSet,
but |parameters|' third ... | Updates the array of most permissive failed parameters.
This is used in conjunction with _ParametersAreGuaranteedToFail to prune
ParameterSets without having to actually test them. Values are updated if
|parameters| shares two parameters with a a previously failed ParameterSet,
but |parameters|' third parameter is more... | [
"Updates",
"the",
"array",
"of",
"most",
"permissive",
"failed",
"parameters",
".",
"This",
"is",
"used",
"in",
"conjunction",
"with",
"_ParametersAreGuaranteedToFail",
"to",
"prune",
"ParameterSets",
"without",
"having",
"to",
"actually",
"test",
"them",
".",
"Va... | def _UpdateMostPermissiveFailedParameters(self, parameters):
permissive_max_diff = self._permissive_max_diff_map.setdefault(
parameters.delta_threshold, {}).get(parameters.edge_threshold, -1)
permissive_max_diff = max(permissive_max_diff, parameters.max_diff)
self._permissive_max_diff_map[parameters... | [
"def",
"_UpdateMostPermissiveFailedParameters",
"(",
"self",
",",
"parameters",
")",
":",
"permissive_max_diff",
"=",
"self",
".",
"_permissive_max_diff_map",
".",
"setdefault",
"(",
"parameters",
".",
"delta_threshold",
",",
"{",
"}",
")",
".",
"get",
"(",
"param... | Updates the array of most permissive failed parameters. | [
"Updates",
"the",
"array",
"of",
"most",
"permissive",
"failed",
"parameters",
"."
] | [
"\"\"\"Updates the array of most permissive failed parameters.\n\n This is used in conjunction with _ParametersAreGuaranteedToFail to prune\n ParameterSets without having to actually test them. Values are updated if\n |parameters| shares two parameters with a a previously failed ParameterSet,\n but |par... | [
{
"param": "self",
"type": null
},
{
"param": "parameters",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parameters",
"type": null,
"docstring": "A ParameterSet to pull upd... |
0293a2cdb5fccc8feeb61c5a783a3014a4372190 | sunlongbo/chromium | tools/perf/core/results_processor/formatters/html_output.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ProcessHistogramDicts | <not_specific> | def ProcessHistogramDicts(histogram_dicts, options):
"""Convert histogram dicts to HTML and write output in output_dir."""
output_file = os.path.join(options.output_dir, OUTPUT_FILENAME)
open(output_file, 'a').close() # Create file if it doesn't exist.
with codecs.open(output_file, mode='r+', encoding='utf-8')... | Convert histogram dicts to HTML and write output in output_dir. | Convert histogram dicts to HTML and write output in output_dir. | [
"Convert",
"histogram",
"dicts",
"to",
"HTML",
"and",
"write",
"output",
"in",
"output_dir",
"."
] | def ProcessHistogramDicts(histogram_dicts, options):
output_file = os.path.join(options.output_dir, OUTPUT_FILENAME)
open(output_file, 'a').close()
with codecs.open(output_file, mode='r+', encoding='utf-8') as output_stream:
vulcanize_histograms_viewer.VulcanizeAndRenderHistogramsViewer(
histogram_d... | [
"def",
"ProcessHistogramDicts",
"(",
"histogram_dicts",
",",
"options",
")",
":",
"output_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"options",
".",
"output_dir",
",",
"OUTPUT_FILENAME",
")",
"open",
"(",
"output_file",
",",
"'a'",
")",
".",
"close",
... | Convert histogram dicts to HTML and write output in output_dir. | [
"Convert",
"histogram",
"dicts",
"to",
"HTML",
"and",
"write",
"output",
"in",
"output_dir",
"."
] | [
"\"\"\"Convert histogram dicts to HTML and write output in output_dir.\"\"\"",
"# Create file if it doesn't exist."
] | [
{
"param": "histogram_dicts",
"type": null
},
{
"param": "options",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "histogram_dicts",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "options",
"type": null,
"docstring": null,
"docstr... |
5c4f5177dcb14753dabe6f0c8fee57781202efba | sunlongbo/chromium | third_party/xcbproto/src/xcbgen/align.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | is_guaranteed_at | <not_specific> | def is_guaranteed_at(self, external_align):
'''
Assuming the given external_align, checks whether
self is fulfilled for all cases.
Returns True if yes, False otherwise.
'''
if self.align == 1 and self.offset == 0:
# alignment 1 with offset 0 is always fulfille... |
Assuming the given external_align, checks whether
self is fulfilled for all cases.
Returns True if yes, False otherwise.
| Assuming the given external_align, checks whether
self is fulfilled for all cases.
Returns True if yes, False otherwise. | [
"Assuming",
"the",
"given",
"external_align",
"checks",
"whether",
"self",
"is",
"fulfilled",
"for",
"all",
"cases",
".",
"Returns",
"True",
"if",
"yes",
"False",
"otherwise",
"."
] | def is_guaranteed_at(self, external_align):
if self.align == 1 and self.offset == 0:
return True
if external_align is None:
return False
if external_align.align < self.align:
return False
if external_align.align % self.align != 0:
return Fa... | [
"def",
"is_guaranteed_at",
"(",
"self",
",",
"external_align",
")",
":",
"if",
"self",
".",
"align",
"==",
"1",
"and",
"self",
".",
"offset",
"==",
"0",
":",
"return",
"True",
"if",
"external_align",
"is",
"None",
":",
"return",
"False",
"if",
"external_... | Assuming the given external_align, checks whether
self is fulfilled for all cases. | [
"Assuming",
"the",
"given",
"external_align",
"checks",
"whether",
"self",
"is",
"fulfilled",
"for",
"all",
"cases",
"."
] | [
"'''\n Assuming the given external_align, checks whether\n self is fulfilled for all cases.\n Returns True if yes, False otherwise.\n '''",
"# alignment 1 with offset 0 is always fulfilled",
"# there is no external align -> fail",
"# the external align guarantees less alignment -> ... | [
{
"param": "self",
"type": null
},
{
"param": "external_align",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "external_align",
"type": null,
"docstring": null,
"docstring_... |
5c52746538a24432480894079bdad7e4b2f6a008 | sunlongbo/chromium | build/apple/tweak_info_plist.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _GetOutput | <not_specific> | def _GetOutput(args):
"""Runs a subprocess and waits for termination. Returns (stdout, returncode)
of the process. stderr is attached to the parent."""
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
return stdout.decode('UTF-8'), proc.returncode | Runs a subprocess and waits for termination. Returns (stdout, returncode)
of the process. stderr is attached to the parent. | Runs a subprocess and waits for termination. Returns (stdout, returncode)
of the process. stderr is attached to the parent. | [
"Runs",
"a",
"subprocess",
"and",
"waits",
"for",
"termination",
".",
"Returns",
"(",
"stdout",
"returncode",
")",
"of",
"the",
"process",
".",
"stderr",
"is",
"attached",
"to",
"the",
"parent",
"."
] | def _GetOutput(args):
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
return stdout.decode('UTF-8'), proc.returncode | [
"def",
"_GetOutput",
"(",
"args",
")",
":",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"args",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"stdout",
",",
"_",
"=",
"proc",
".",
"communicate",
"(",
")",
"return",
"stdout",
".",
"decode",
"(... | Runs a subprocess and waits for termination. | [
"Runs",
"a",
"subprocess",
"and",
"waits",
"for",
"termination",
"."
] | [
"\"\"\"Runs a subprocess and waits for termination. Returns (stdout, returncode)\n of the process. stderr is attached to the parent.\"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5c52746538a24432480894079bdad7e4b2f6a008 | sunlongbo/chromium | build/apple/tweak_info_plist.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _AddVersionKeys | <not_specific> | def _AddVersionKeys(plist, version_format_for_key, version=None,
overrides=None):
"""Adds the product version number into the plist. Returns True on success and
False on error. The error will be printed to stderr."""
if not version:
# Pull in the Chrome version number.
VERSION_TOOL = o... | Adds the product version number into the plist. Returns True on success and
False on error. The error will be printed to stderr. | Adds the product version number into the plist. Returns True on success and
False on error. The error will be printed to stderr. | [
"Adds",
"the",
"product",
"version",
"number",
"into",
"the",
"plist",
".",
"Returns",
"True",
"on",
"success",
"and",
"False",
"on",
"error",
".",
"The",
"error",
"will",
"be",
"printed",
"to",
"stderr",
"."
] | def _AddVersionKeys(plist, version_format_for_key, version=None,
overrides=None):
if not version:
VERSION_TOOL = os.path.join(TOP, 'build/util/version.py')
VERSION_FILE = os.path.join(TOP, 'chrome/VERSION')
(stdout, retval) = _GetOutput([
VERSION_TOOL, '-f', VERSION_FILE, '-t',... | [
"def",
"_AddVersionKeys",
"(",
"plist",
",",
"version_format_for_key",
",",
"version",
"=",
"None",
",",
"overrides",
"=",
"None",
")",
":",
"if",
"not",
"version",
":",
"VERSION_TOOL",
"=",
"os",
".",
"path",
".",
"join",
"(",
"TOP",
",",
"'build/util/ver... | Adds the product version number into the plist. | [
"Adds",
"the",
"product",
"version",
"number",
"into",
"the",
"plist",
"."
] | [
"\"\"\"Adds the product version number into the plist. Returns True on success and\n False on error. The error will be printed to stderr.\"\"\"",
"# Pull in the Chrome version number.",
"# If the command finished with a non-zero return code, then report the",
"# error up.",
"# Parse the given version numbe... | [
{
"param": "plist",
"type": null
},
{
"param": "version_format_for_key",
"type": null
},
{
"param": "version",
"type": null
},
{
"param": "overrides",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "plist",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "version_format_for_key",
"type": null,
"docstring": null,
"d... |
5c52746538a24432480894079bdad7e4b2f6a008 | sunlongbo/chromium | build/apple/tweak_info_plist.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _DoSCMKeys | <not_specific> | def _DoSCMKeys(plist, add_keys):
"""Adds the SCM information, visible in about:version, to property list. If
|add_keys| is True, it will insert the keys, otherwise it will remove them."""
scm_revision = None
if add_keys:
# Pull in the Chrome revision number.
VERSION_TOOL = os.path.join(TOP, 'build/util/... | Adds the SCM information, visible in about:version, to property list. If
|add_keys| is True, it will insert the keys, otherwise it will remove them. | Adds the SCM information, visible in about:version, to property list. If
|add_keys| is True, it will insert the keys, otherwise it will remove them. | [
"Adds",
"the",
"SCM",
"information",
"visible",
"in",
"about",
":",
"version",
"to",
"property",
"list",
".",
"If",
"|add_keys|",
"is",
"True",
"it",
"will",
"insert",
"the",
"keys",
"otherwise",
"it",
"will",
"remove",
"them",
"."
] | def _DoSCMKeys(plist, add_keys):
scm_revision = None
if add_keys:
VERSION_TOOL = os.path.join(TOP, 'build/util/version.py')
LASTCHANGE_FILE = os.path.join(TOP, 'build/util/LASTCHANGE')
(stdout, retval) = _GetOutput(
[VERSION_TOOL, '-f', LASTCHANGE_FILE, '-t', '@LASTCHANGE@'])
if retval:
... | [
"def",
"_DoSCMKeys",
"(",
"plist",
",",
"add_keys",
")",
":",
"scm_revision",
"=",
"None",
"if",
"add_keys",
":",
"VERSION_TOOL",
"=",
"os",
".",
"path",
".",
"join",
"(",
"TOP",
",",
"'build/util/version.py'",
")",
"LASTCHANGE_FILE",
"=",
"os",
".",
"path... | Adds the SCM information, visible in about:version, to property list. | [
"Adds",
"the",
"SCM",
"information",
"visible",
"in",
"about",
":",
"version",
"to",
"property",
"list",
"."
] | [
"\"\"\"Adds the SCM information, visible in about:version, to property list. If\n |add_keys| is True, it will insert the keys, otherwise it will remove them.\"\"\"",
"# Pull in the Chrome revision number.",
"# See if the operation failed."
] | [
{
"param": "plist",
"type": null
},
{
"param": "add_keys",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "plist",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "add_keys",
"type": null,
"docstring": null,
"docstring_token... |
5c52746538a24432480894079bdad7e4b2f6a008 | sunlongbo/chromium | build/apple/tweak_info_plist.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _RemoveBreakpadKeys | null | def _RemoveBreakpadKeys(plist):
"""Removes any set Breakpad keys."""
_RemoveKeys(plist, 'BreakpadURL', 'BreakpadReportInterval', 'BreakpadProduct',
'BreakpadProductDisplay', 'BreakpadVersion',
'BreakpadSendAndExit', 'BreakpadSkipConfirm') | Removes any set Breakpad keys. | Removes any set Breakpad keys. | [
"Removes",
"any",
"set",
"Breakpad",
"keys",
"."
] | def _RemoveBreakpadKeys(plist):
_RemoveKeys(plist, 'BreakpadURL', 'BreakpadReportInterval', 'BreakpadProduct',
'BreakpadProductDisplay', 'BreakpadVersion',
'BreakpadSendAndExit', 'BreakpadSkipConfirm') | [
"def",
"_RemoveBreakpadKeys",
"(",
"plist",
")",
":",
"_RemoveKeys",
"(",
"plist",
",",
"'BreakpadURL'",
",",
"'BreakpadReportInterval'",
",",
"'BreakpadProduct'",
",",
"'BreakpadProductDisplay'",
",",
"'BreakpadVersion'",
",",
"'BreakpadSendAndExit'",
",",
"'BreakpadSkip... | Removes any set Breakpad keys. | [
"Removes",
"any",
"set",
"Breakpad",
"keys",
"."
] | [
"\"\"\"Removes any set Breakpad keys.\"\"\""
] | [
{
"param": "plist",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "plist",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5c52746538a24432480894079bdad7e4b2f6a008 | sunlongbo/chromium | build/apple/tweak_info_plist.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _RemoveKeystoneKeys | null | def _RemoveKeystoneKeys(plist):
"""Removes any set Keystone keys."""
_RemoveKeys(plist, 'KSVersion', 'KSProductID', 'KSUpdateURL')
tag_keys = ['KSChannelID']
for tag_suffix in _TagSuffixes():
tag_keys.append('KSChannelID' + tag_suffix)
_RemoveKeys(plist, *tag_keys) | Removes any set Keystone keys. | Removes any set Keystone keys. | [
"Removes",
"any",
"set",
"Keystone",
"keys",
"."
] | def _RemoveKeystoneKeys(plist):
_RemoveKeys(plist, 'KSVersion', 'KSProductID', 'KSUpdateURL')
tag_keys = ['KSChannelID']
for tag_suffix in _TagSuffixes():
tag_keys.append('KSChannelID' + tag_suffix)
_RemoveKeys(plist, *tag_keys) | [
"def",
"_RemoveKeystoneKeys",
"(",
"plist",
")",
":",
"_RemoveKeys",
"(",
"plist",
",",
"'KSVersion'",
",",
"'KSProductID'",
",",
"'KSUpdateURL'",
")",
"tag_keys",
"=",
"[",
"'KSChannelID'",
"]",
"for",
"tag_suffix",
"in",
"_TagSuffixes",
"(",
")",
":",
"tag_k... | Removes any set Keystone keys. | [
"Removes",
"any",
"set",
"Keystone",
"keys",
"."
] | [
"\"\"\"Removes any set Keystone keys.\"\"\""
] | [
{
"param": "plist",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "plist",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5c52746538a24432480894079bdad7e4b2f6a008 | sunlongbo/chromium | build/apple/tweak_info_plist.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _AddGTMKeys | null | def _AddGTMKeys(plist, platform):
"""Adds the GTM metadata keys. This must be called AFTER _AddVersionKeys()."""
plist['GTMUserAgentID'] = plist['CFBundleName']
if platform == 'ios':
plist['GTMUserAgentVersion'] = plist['CFBundleVersion']
else:
plist['GTMUserAgentVersion'] = plist['CFBundleShortVersionS... | Adds the GTM metadata keys. This must be called AFTER _AddVersionKeys(). | Adds the GTM metadata keys. This must be called AFTER _AddVersionKeys(). | [
"Adds",
"the",
"GTM",
"metadata",
"keys",
".",
"This",
"must",
"be",
"called",
"AFTER",
"_AddVersionKeys",
"()",
"."
] | def _AddGTMKeys(plist, platform):
plist['GTMUserAgentID'] = plist['CFBundleName']
if platform == 'ios':
plist['GTMUserAgentVersion'] = plist['CFBundleVersion']
else:
plist['GTMUserAgentVersion'] = plist['CFBundleShortVersionString'] | [
"def",
"_AddGTMKeys",
"(",
"plist",
",",
"platform",
")",
":",
"plist",
"[",
"'GTMUserAgentID'",
"]",
"=",
"plist",
"[",
"'CFBundleName'",
"]",
"if",
"platform",
"==",
"'ios'",
":",
"plist",
"[",
"'GTMUserAgentVersion'",
"]",
"=",
"plist",
"[",
"'CFBundleVer... | Adds the GTM metadata keys. | [
"Adds",
"the",
"GTM",
"metadata",
"keys",
"."
] | [
"\"\"\"Adds the GTM metadata keys. This must be called AFTER _AddVersionKeys().\"\"\""
] | [
{
"param": "plist",
"type": null
},
{
"param": "platform",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "plist",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "platform",
"type": null,
"docstring": null,
"docstring_token... |
5c60ee48adefa5644795aae079bcc7f5db7d1e6a | sunlongbo/chromium | chrome/browser/resources/discards/generate_graph_tab.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | strip_js_imports | <not_specific> | def strip_js_imports(js_contents):
"""The input JS may use imports for Closure compilation. These must be
stripped from the output since the resulting data: URL cannot use imports
within its webview."""
def not_an_import(line):
return not line.startswith('import ')
return '\n'.join(filter(not_an_import, j... | The input JS may use imports for Closure compilation. These must be
stripped from the output since the resulting data: URL cannot use imports
within its webview. | The input JS may use imports for Closure compilation. These must be
stripped from the output since the resulting data: URL cannot use imports
within its webview. | [
"The",
"input",
"JS",
"may",
"use",
"imports",
"for",
"Closure",
"compilation",
".",
"These",
"must",
"be",
"stripped",
"from",
"the",
"output",
"since",
"the",
"resulting",
"data",
":",
"URL",
"cannot",
"use",
"imports",
"within",
"its",
"webview",
"."
] | def strip_js_imports(js_contents):
def not_an_import(line):
return not line.startswith('import ')
return '\n'.join(filter(not_an_import, js_contents.splitlines())) | [
"def",
"strip_js_imports",
"(",
"js_contents",
")",
":",
"def",
"not_an_import",
"(",
"line",
")",
":",
"return",
"not",
"line",
".",
"startswith",
"(",
"'import '",
")",
"return",
"'\\n'",
".",
"join",
"(",
"filter",
"(",
"not_an_import",
",",
"js_contents"... | The input JS may use imports for Closure compilation. | [
"The",
"input",
"JS",
"may",
"use",
"imports",
"for",
"Closure",
"compilation",
"."
] | [
"\"\"\"The input JS may use imports for Closure compilation. These must be\n stripped from the output since the resulting data: URL cannot use imports\n within its webview.\"\"\""
] | [
{
"param": "js_contents",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "js_contents",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cf245b76743c8ea87f10f48efab09ed3602996b3 | sunlongbo/chromium | chrome/browser/resources/chromeos/accessibility/chromevox/tools/publish_webstore_extension.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | GetVersion | <not_specific> | def GetVersion():
'''Returns the chrome version string.'''
filename = os.path.join(_CHROME_SOURCE_DIR, 'chrome', 'VERSION')
values = version.FetchValues([filename])
return version.SubstTemplate('@MAJOR@.@MINOR@.@BUILD@.@PATCH@', values) | Returns the chrome version string. | Returns the chrome version string. | [
"Returns",
"the",
"chrome",
"version",
"string",
"."
] | def GetVersion():
filename = os.path.join(_CHROME_SOURCE_DIR, 'chrome', 'VERSION')
values = version.FetchValues([filename])
return version.SubstTemplate('@MAJOR@.@MINOR@.@BUILD@.@PATCH@', values) | [
"def",
"GetVersion",
"(",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_CHROME_SOURCE_DIR",
",",
"'chrome'",
",",
"'VERSION'",
")",
"values",
"=",
"version",
".",
"FetchValues",
"(",
"[",
"filename",
"]",
")",
"return",
"version",
"."... | Returns the chrome version string. | [
"Returns",
"the",
"chrome",
"version",
"string",
"."
] | [
"'''Returns the chrome version string.'''"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
cf245b76743c8ea87f10f48efab09ed3602996b3 | sunlongbo/chromium | chrome/browser/resources/chromeos/accessibility/chromevox/tools/publish_webstore_extension.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | MakeChromeVoxManifest | <not_specific> | def MakeChromeVoxManifest():
'''Create a manifest for the webstore.
Returns:
Temporary file with generated manifest.
'''
new_file = tempfile.NamedTemporaryFile(mode='w+a', bufsize=0)
in_file_name = os.path.join(_SCRIPT_DIR, os.path.pardir,
'manifest.json.jinja2')
context =... | Create a manifest for the webstore.
Returns:
Temporary file with generated manifest.
| Create a manifest for the webstore. | [
"Create",
"a",
"manifest",
"for",
"the",
"webstore",
"."
] | def MakeChromeVoxManifest():
new_file = tempfile.NamedTemporaryFile(mode='w+a', bufsize=0)
in_file_name = os.path.join(_SCRIPT_DIR, os.path.pardir,
'manifest.json.jinja2')
context = {
'is_guest_manifest': '0',
'is_js_compressed': '1',
'is_webstore': '1',
'set_... | [
"def",
"MakeChromeVoxManifest",
"(",
")",
":",
"new_file",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"mode",
"=",
"'w+a'",
",",
"bufsize",
"=",
"0",
")",
"in_file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_SCRIPT_DIR",
",",
"os",
".",
"pat... | Create a manifest for the webstore. | [
"Create",
"a",
"manifest",
"for",
"the",
"webstore",
"."
] | [
"'''Create a manifest for the webstore.\n\n Returns:\n Temporary file with generated manifest.\n '''"
] | [] | {
"returns": [
{
"docstring": "Temporary file with generated manifest.",
"docstring_tokens": [
"Temporary",
"file",
"with",
"generated",
"manifest",
"."
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"oth... |
b59490685d78ebde8ad346afa1e0d1e81a26c703 | sunlongbo/chromium | tools/android/modularization/owners/getowners.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _process_requested_path | Tuple[owners_data.RequestedPath, owners_data.PathData] | def _process_requested_path(
chromium_root: str, all_dir_metadata: Dict,
requested_path: owners_data.RequestedPath
) -> Tuple[owners_data.RequestedPath, owners_data.PathData]:
'''Gets the necessary information from the git repository.'''
owners_file = _find_owners_file(chromium_root, requested_path.path)
... | Gets the necessary information from the git repository. | Gets the necessary information from the git repository. | [
"Gets",
"the",
"necessary",
"information",
"from",
"the",
"git",
"repository",
"."
] | def _process_requested_path(
chromium_root: str, all_dir_metadata: Dict,
requested_path: owners_data.RequestedPath
) -> Tuple[owners_data.RequestedPath, owners_data.PathData]:
owners_file = _find_owners_file(chromium_root, requested_path.path)
owners = _build_owners_info(chromium_root, owners_file)
git_da... | [
"def",
"_process_requested_path",
"(",
"chromium_root",
":",
"str",
",",
"all_dir_metadata",
":",
"Dict",
",",
"requested_path",
":",
"owners_data",
".",
"RequestedPath",
")",
"->",
"Tuple",
"[",
"owners_data",
".",
"RequestedPath",
",",
"owners_data",
".",
"PathD... | Gets the necessary information from the git repository. | [
"Gets",
"the",
"necessary",
"information",
"from",
"the",
"git",
"repository",
"."
] | [
"'''Gets the necessary information from the git repository.'''"
] | [
{
"param": "chromium_root",
"type": "str"
},
{
"param": "all_dir_metadata",
"type": "Dict"
},
{
"param": "requested_path",
"type": "owners_data.RequestedPath"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chromium_root",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "all_dir_metadata",
"type": "Dict",
"docstring": null,
... |
b59490685d78ebde8ad346afa1e0d1e81a26c703 | sunlongbo/chromium | tools/android/modularization/owners/getowners.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _fetch_git_data | owners_data.GitData | def _fetch_git_data(chromium_root: str,
requested_path: owners_data.RequestedPath
) -> owners_data.GitData:
'''Fetches git data for a given directory for the last 182 days.
Includes # of commits, reverts, relands, authors, and reviewers.
'''
line_delimiter = '\ncommit '... | Fetches git data for a given directory for the last 182 days.
Includes # of commits, reverts, relands, authors, and reviewers.
| Fetches git data for a given directory for the last 182 days.
Includes # of commits, reverts, relands, authors, and reviewers. | [
"Fetches",
"git",
"data",
"for",
"a",
"given",
"directory",
"for",
"the",
"last",
"182",
"days",
".",
"Includes",
"#",
"of",
"commits",
"reverts",
"relands",
"authors",
"and",
"reviewers",
"."
] | def _fetch_git_data(chromium_root: str,
requested_path: owners_data.RequestedPath
) -> owners_data.GitData:
line_delimiter = '\ncommit '
author_search = r'^Author: (.*) <(.*)>'
date_search = r'Date: (.*)'
reviewer_search = r'^ Reviewed-by: (.*) <(.*)>'
revert_token... | [
"def",
"_fetch_git_data",
"(",
"chromium_root",
":",
"str",
",",
"requested_path",
":",
"owners_data",
".",
"RequestedPath",
")",
"->",
"owners_data",
".",
"GitData",
":",
"line_delimiter",
"=",
"'\\ncommit '",
"author_search",
"=",
"r'^Author: (.*) <(.*)>'",
"date_se... | Fetches git data for a given directory for the last 182 days. | [
"Fetches",
"git",
"data",
"for",
"a",
"given",
"directory",
"for",
"the",
"last",
"182",
"days",
"."
] | [
"'''Fetches git data for a given directory for the last 182 days.\n\n Includes # of commits, reverts, relands, authors, and reviewers.\n '''",
"# ignore flagged authors",
"# Minus tz offset."
] | [
{
"param": "chromium_root",
"type": "str"
},
{
"param": "requested_path",
"type": "owners_data.RequestedPath"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chromium_root",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "requested_path",
"type": "owners_data.RequestedPath",
"do... |
b59490685d78ebde8ad346afa1e0d1e81a26c703 | sunlongbo/chromium | tools/android/modularization/owners/getowners.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _find_owners_file | str | def _find_owners_file(chromium_root: str, filepath: str) -> str:
'''Returns the path to the OWNERS file for the given path (or up the tree).'''
if not filepath.startswith(os.path.join(chromium_root, '')):
filepath = os.path.join(chromium_root, filepath)
if os.path.isdir(filepath):
ofile = os.path.join(f... | Returns the path to the OWNERS file for the given path (or up the tree). | Returns the path to the OWNERS file for the given path (or up the tree). | [
"Returns",
"the",
"path",
"to",
"the",
"OWNERS",
"file",
"for",
"the",
"given",
"path",
"(",
"or",
"up",
"the",
"tree",
")",
"."
] | def _find_owners_file(chromium_root: str, filepath: str) -> str:
if not filepath.startswith(os.path.join(chromium_root, '')):
filepath = os.path.join(chromium_root, filepath)
if os.path.isdir(filepath):
ofile = os.path.join(filepath, 'OWNERS')
else:
if 'OWNERS' in os.path.basename(filepath):
ofi... | [
"def",
"_find_owners_file",
"(",
"chromium_root",
":",
"str",
",",
"filepath",
":",
"str",
")",
"->",
"str",
":",
"if",
"not",
"filepath",
".",
"startswith",
"(",
"os",
".",
"path",
".",
"join",
"(",
"chromium_root",
",",
"''",
")",
")",
":",
"filepath... | Returns the path to the OWNERS file for the given path (or up the tree). | [
"Returns",
"the",
"path",
"to",
"the",
"OWNERS",
"file",
"for",
"the",
"given",
"path",
"(",
"or",
"up",
"the",
"tree",
")",
"."
] | [
"'''Returns the path to the OWNERS file for the given path (or up the tree).'''"
] | [
{
"param": "chromium_root",
"type": "str"
},
{
"param": "filepath",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chromium_root",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filepath",
"type": "str",
"docstring": null,
"docst... |
b59490685d78ebde8ad346afa1e0d1e81a26c703 | sunlongbo/chromium | tools/android/modularization/owners/getowners.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _build_owners_info | owners_data.Owners | def _build_owners_info(chromium_root: str,
owners_filepath: str) -> owners_data.Owners:
'''Creates a synthetic representation of an OWNERS file.'''
if not owners_filepath: return None
assert owners_filepath.startswith(os.path.join(chromium_root, ''))
owners_file = owners_filepath[len(ch... | Creates a synthetic representation of an OWNERS file. | Creates a synthetic representation of an OWNERS file. | [
"Creates",
"a",
"synthetic",
"representation",
"of",
"an",
"OWNERS",
"file",
"."
] | def _build_owners_info(chromium_root: str,
owners_filepath: str) -> owners_data.Owners:
if not owners_filepath: return None
assert owners_filepath.startswith(os.path.join(chromium_root, ''))
owners_file = owners_filepath[len(chromium_root) + 1:]
if owners_file in owners_map:
return ow... | [
"def",
"_build_owners_info",
"(",
"chromium_root",
":",
"str",
",",
"owners_filepath",
":",
"str",
")",
"->",
"owners_data",
".",
"Owners",
":",
"if",
"not",
"owners_filepath",
":",
"return",
"None",
"assert",
"owners_filepath",
".",
"startswith",
"(",
"os",
"... | Creates a synthetic representation of an OWNERS file. | [
"Creates",
"a",
"synthetic",
"representation",
"of",
"an",
"OWNERS",
"file",
"."
] | [
"'''Creates a synthetic representation of an OWNERS file.'''",
"# Remove comments after the email"
] | [
{
"param": "chromium_root",
"type": "str"
},
{
"param": "owners_filepath",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chromium_root",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "owners_filepath",
"type": "str",
"docstring": null,
... |
b59490685d78ebde8ad346afa1e0d1e81a26c703 | sunlongbo/chromium | tools/android/modularization/owners/getowners.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _propagate_down_owner_variables | None | def _propagate_down_owner_variables(chromium_root: str,
owners: owners_data.Owners) -> None:
'''For a given Owners, make sure that parent OWNERS are propagated down.
Search in parent directories for OWNERS in case they do not exist
in the current representation.
'''
paren... | For a given Owners, make sure that parent OWNERS are propagated down.
Search in parent directories for OWNERS in case they do not exist
in the current representation.
| For a given Owners, make sure that parent OWNERS are propagated down.
Search in parent directories for OWNERS in case they do not exist
in the current representation. | [
"For",
"a",
"given",
"Owners",
"make",
"sure",
"that",
"parent",
"OWNERS",
"are",
"propagated",
"down",
".",
"Search",
"in",
"parent",
"directories",
"for",
"OWNERS",
"in",
"case",
"they",
"do",
"not",
"exist",
"in",
"the",
"current",
"representation",
"."
] | def _propagate_down_owner_variables(chromium_root: str,
owners: owners_data.Owners) -> None:
parent_owners = owners
visited = set()
while parent_owners:
if parent_owners.owners_file in visited:
return
if not owners.owners and parent_owners.owners:
owners.own... | [
"def",
"_propagate_down_owner_variables",
"(",
"chromium_root",
":",
"str",
",",
"owners",
":",
"owners_data",
".",
"Owners",
")",
"->",
"None",
":",
"parent_owners",
"=",
"owners",
"visited",
"=",
"set",
"(",
")",
"while",
"parent_owners",
":",
"if",
"parent_... | For a given Owners, make sure that parent OWNERS are propagated down. | [
"For",
"a",
"given",
"Owners",
"make",
"sure",
"that",
"parent",
"OWNERS",
"are",
"propagated",
"down",
"."
] | [
"'''For a given Owners, make sure that parent OWNERS are propagated down.\n\n Search in parent directories for OWNERS in case they do not exist\n in the current representation.\n '''"
] | [
{
"param": "chromium_root",
"type": "str"
},
{
"param": "owners",
"type": "owners_data.Owners"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chromium_root",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "owners",
"type": "owners_data.Owners",
"docstring": null,... |
b5be69239be9ccca35c7676b2def125686c914a0 | sunlongbo/chromium | tools/metrics/common/etree_util.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | GetTopLevelContent | <not_specific> | def GetTopLevelContent(file_content):
"""Returns a string of all the text in the xml file before the first tag."""
handler = _FirstTagFinder()
first_tag_line = 0
first_tag_column = 0
try:
xml.sax.parseString(file_content.encode('utf-8'), handler)
except _FirstTagFoundError:
# This is the expected c... | Returns a string of all the text in the xml file before the first tag. | Returns a string of all the text in the xml file before the first tag. | [
"Returns",
"a",
"string",
"of",
"all",
"the",
"text",
"in",
"the",
"xml",
"file",
"before",
"the",
"first",
"tag",
"."
] | def GetTopLevelContent(file_content):
handler = _FirstTagFinder()
first_tag_line = 0
first_tag_column = 0
try:
xml.sax.parseString(file_content.encode('utf-8'), handler)
except _FirstTagFoundError:
first_tag_line = handler.GetFirstTagLine()
first_tag_column = handler.GetFirstTagColumn()
if first... | [
"def",
"GetTopLevelContent",
"(",
"file_content",
")",
":",
"handler",
"=",
"_FirstTagFinder",
"(",
")",
"first_tag_line",
"=",
"0",
"first_tag_column",
"=",
"0",
"try",
":",
"xml",
".",
"sax",
".",
"parseString",
"(",
"file_content",
".",
"encode",
"(",
"'u... | Returns a string of all the text in the xml file before the first tag. | [
"Returns",
"a",
"string",
"of",
"all",
"the",
"text",
"in",
"the",
"xml",
"file",
"before",
"the",
"first",
"tag",
"."
] | [
"\"\"\"Returns a string of all the text in the xml file before the first tag.\"\"\"",
"# This is the expected case, it means a tag was found in the doc.",
"# |char| is now pointing at the final character before the opening tag '<'."
] | [
{
"param": "file_content",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_content",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b5be69239be9ccca35c7676b2def125686c914a0 | sunlongbo/chromium | tools/metrics/common/etree_util.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ParseXMLString | <not_specific> | def ParseXMLString(raw_xml):
"""Parses raw_xml and returns an ElementTree node that includes comments."""
if sys.version_info.major == 2:
return ET.fromstring(raw_xml.encode('utf-8'), _CommentedXMLParser())
else:
return ET.fromstring(
raw_xml, ET.XMLParser(target=ET.TreeBuilder(insert_comments=Tru... | Parses raw_xml and returns an ElementTree node that includes comments. | Parses raw_xml and returns an ElementTree node that includes comments. | [
"Parses",
"raw_xml",
"and",
"returns",
"an",
"ElementTree",
"node",
"that",
"includes",
"comments",
"."
] | def ParseXMLString(raw_xml):
if sys.version_info.major == 2:
return ET.fromstring(raw_xml.encode('utf-8'), _CommentedXMLParser())
else:
return ET.fromstring(
raw_xml, ET.XMLParser(target=ET.TreeBuilder(insert_comments=True))) | [
"def",
"ParseXMLString",
"(",
"raw_xml",
")",
":",
"if",
"sys",
".",
"version_info",
".",
"major",
"==",
"2",
":",
"return",
"ET",
".",
"fromstring",
"(",
"raw_xml",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"_CommentedXMLParser",
"(",
")",
")",
"else",
... | Parses raw_xml and returns an ElementTree node that includes comments. | [
"Parses",
"raw_xml",
"and",
"returns",
"an",
"ElementTree",
"node",
"that",
"includes",
"comments",
"."
] | [
"\"\"\"Parses raw_xml and returns an ElementTree node that includes comments.\"\"\""
] | [
{
"param": "raw_xml",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "raw_xml",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b5c00824b8bd368ee0b17ba7d9aba80dc47bdf00 | sunlongbo/chromium | chrome/browser/resources/vr/assets/PRESUBMIT.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | CheckVersionAndAssetParity | <not_specific> | def CheckVersionAndAssetParity(input_api, output_api):
"""Checks that
- the version was upraded if assets files were changed,
- the version was not downgraded,
- both the google_chrome and the chromium assets have the same files.
"""
sys.path.append(input_api.PresubmitLocalPath())
import parse_version
... | Checks that
- the version was upraded if assets files were changed,
- the version was not downgraded,
- both the google_chrome and the chromium assets have the same files.
| Checks that
the version was upraded if assets files were changed,
the version was not downgraded,
both the google_chrome and the chromium assets have the same files. | [
"Checks",
"that",
"the",
"version",
"was",
"upraded",
"if",
"assets",
"files",
"were",
"changed",
"the",
"version",
"was",
"not",
"downgraded",
"both",
"the",
"google_chrome",
"and",
"the",
"chromium",
"assets",
"have",
"the",
"same",
"files",
"."
] | def CheckVersionAndAssetParity(input_api, output_api):
sys.path.append(input_api.PresubmitLocalPath())
import parse_version
old_version = None
new_version = None
changed_assets = False
changed_version = False
changed_component_list = False
changed_asset_files = {'google_chrome': [], 'chromium': []}
fo... | [
"def",
"CheckVersionAndAssetParity",
"(",
"input_api",
",",
"output_api",
")",
":",
"sys",
".",
"path",
".",
"append",
"(",
"input_api",
".",
"PresubmitLocalPath",
"(",
")",
")",
"import",
"parse_version",
"old_version",
"=",
"None",
"new_version",
"=",
"None",
... | Checks that
the version was upraded if assets files were changed,
the version was not downgraded,
both the google_chrome and the chromium assets have the same files. | [
"Checks",
"that",
"the",
"version",
"was",
"upraded",
"if",
"assets",
"files",
"were",
"changed",
"the",
"version",
"was",
"not",
"downgraded",
"both",
"the",
"google_chrome",
"and",
"the",
"chromium",
"assets",
"have",
"the",
"same",
"files",
"."
] | [
"\"\"\"Checks that\n - the version was upraded if assets files were changed,\n - the version was not downgraded,\n - both the google_chrome and the chromium assets have the same files.\n \"\"\""
] | [
{
"param": "input_api",
"type": null
},
{
"param": "output_api",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_api",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_api",
"type": null,
"docstring": null,
"docstring... |
7a335fd692c6ae7237ca5ee0eb3e891fd7746f4a | sunlongbo/chromium | tools/autotest.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | BuildTestTargetsWithNinja | <not_specific> | def BuildTestTargetsWithNinja(out_dir, targets, dry_run):
"""Builds the specified targets with ninja"""
# Use autoninja from PATH to match version used for manual builds.
ninja_path = 'autoninja'
if sys.platform.startswith('win32'):
ninja_path += '.bat'
cmd = [ninja_path, '-C', out_dir] + targets
print(... | Builds the specified targets with ninja | Builds the specified targets with ninja | [
"Builds",
"the",
"specified",
"targets",
"with",
"ninja"
] | def BuildTestTargetsWithNinja(out_dir, targets, dry_run):
ninja_path = 'autoninja'
if sys.platform.startswith('win32'):
ninja_path += '.bat'
cmd = [ninja_path, '-C', out_dir] + targets
print('Building: ' + ' '.join(cmd))
if (dry_run):
return True
try:
subprocess.check_call(cmd)
except subproce... | [
"def",
"BuildTestTargetsWithNinja",
"(",
"out_dir",
",",
"targets",
",",
"dry_run",
")",
":",
"ninja_path",
"=",
"'autoninja'",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win32'",
")",
":",
"ninja_path",
"+=",
"'.bat'",
"cmd",
"=",
"[",
"ninja_p... | Builds the specified targets with ninja | [
"Builds",
"the",
"specified",
"targets",
"with",
"ninja"
] | [
"\"\"\"Builds the specified targets with ninja\"\"\"",
"# Use autoninja from PATH to match version used for manual builds."
] | [
{
"param": "out_dir",
"type": null
},
{
"param": "targets",
"type": null
},
{
"param": "dry_run",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "out_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "targets",
"type": null,
"docstring": null,
"docstring_toke... |
ec5ab136b10fe5b923a0f69a476f6e8cabab3237 | Kobzol/elsie | elsie/slides.py | [
"MIT"
] | Python | derive_style | null | def derive_style(self, old_style_name, new_style_name, **kwargs):
""" Copy an existing style under a new name and modify it. """
check_style(kwargs)
new_style = self._styles[old_style_name].copy()
new_style.update(kwargs)
self._styles[new_style_name] = new_style | Copy an existing style under a new name and modify it. | Copy an existing style under a new name and modify it. | [
"Copy",
"an",
"existing",
"style",
"under",
"a",
"new",
"name",
"and",
"modify",
"it",
"."
] | def derive_style(self, old_style_name, new_style_name, **kwargs):
check_style(kwargs)
new_style = self._styles[old_style_name].copy()
new_style.update(kwargs)
self._styles[new_style_name] = new_style | [
"def",
"derive_style",
"(",
"self",
",",
"old_style_name",
",",
"new_style_name",
",",
"**",
"kwargs",
")",
":",
"check_style",
"(",
"kwargs",
")",
"new_style",
"=",
"self",
".",
"_styles",
"[",
"old_style_name",
"]",
".",
"copy",
"(",
")",
"new_style",
".... | Copy an existing style under a new name and modify it. | [
"Copy",
"an",
"existing",
"style",
"under",
"a",
"new",
"name",
"and",
"modify",
"it",
"."
] | [
"\"\"\" Copy an existing style under a new name and modify it. \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "old_style_name",
"type": null
},
{
"param": "new_style_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "old_style_name",
"type": null,
"docstring": null,
"docstring_... |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | overlay | <not_specific> | def overlay(self, **kwargs):
""" Alias over 'box()' that creates a fixed box over the box """
kwargs.setdefault("x", 0)
kwargs.setdefault("y", 0)
kwargs.setdefault("width", "100%")
kwargs.setdefault("height", "100%")
return self.box(**kwargs) | Alias over 'box()' that creates a fixed box over the box | Alias over 'box()' that creates a fixed box over the box | [
"Alias",
"over",
"'",
"box",
"()",
"'",
"that",
"creates",
"a",
"fixed",
"box",
"over",
"the",
"box"
] | def overlay(self, **kwargs):
kwargs.setdefault("x", 0)
kwargs.setdefault("y", 0)
kwargs.setdefault("width", "100%")
kwargs.setdefault("height", "100%")
return self.box(**kwargs) | [
"def",
"overlay",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"\"x\"",
",",
"0",
")",
"kwargs",
".",
"setdefault",
"(",
"\"y\"",
",",
"0",
")",
"kwargs",
".",
"setdefault",
"(",
"\"width\"",
",",
"\"100%\"",
")",
"kw... | Alias over 'box()' that creates a fixed box over the box | [
"Alias",
"over",
"'",
"box",
"()",
"'",
"that",
"creates",
"a",
"fixed",
"box",
"over",
"the",
"box"
] | [
"\"\"\" Alias over 'box()' that creates a fixed box over the box \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | line_box | <not_specific> | def line_box(self, index, lines=1, **kwargs):
""" Create a box around a line of text.
'self' has to contain a text """
def compute_y():
if not self._text_lines:
raise Exception("line_box() called on box with no text")
line_height = self._text_height / ... | Create a box around a line of text.
'self' has to contain a text | Create a box around a line of text.
'self' has to contain a text | [
"Create",
"a",
"box",
"around",
"a",
"line",
"of",
"text",
".",
"'",
"self",
"'",
"has",
"to",
"contain",
"a",
"text"
] | def line_box(self, index, lines=1, **kwargs):
def compute_y():
if not self._text_lines:
raise Exception("line_box() called on box with no text")
line_height = self._text_height / self._text_lines
y = self._rect.y + (self._rect.height - self._text_height) / 2
... | [
"def",
"line_box",
"(",
"self",
",",
"index",
",",
"lines",
"=",
"1",
",",
"**",
"kwargs",
")",
":",
"def",
"compute_y",
"(",
")",
":",
"if",
"not",
"self",
".",
"_text_lines",
":",
"raise",
"Exception",
"(",
"\"line_box() called on box with no text\"",
")... | Create a box around a line of text. | [
"Create",
"a",
"box",
"around",
"a",
"line",
"of",
"text",
"."
] | [
"\"\"\" Create a box around a line of text.\n 'self' has to contain a text \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "index",
"type": null
},
{
"param": "lines",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": null,
"docstring": null,
"docstring_tokens": ... |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | rect | null | def rect(self,
color=None, bg_color=None,
stroke_width=1, stroke_dasharray=None,
rx=None, ry=None):
""" Draw a rect around the box """
def draw_rect(ctx, rect):
xml = ctx.xml
xml.element("rect")
xml.set("x", rect.x)
... | Draw a rect around the box | Draw a rect around the box | [
"Draw",
"a",
"rect",
"around",
"the",
"box"
] | def rect(self,
color=None, bg_color=None,
stroke_width=1, stroke_dasharray=None,
rx=None, ry=None):
def draw_rect(ctx, rect):
xml = ctx.xml
xml.element("rect")
xml.set("x", rect.x)
xml.set("y", rect.y)
xml.set("wi... | [
"def",
"rect",
"(",
"self",
",",
"color",
"=",
"None",
",",
"bg_color",
"=",
"None",
",",
"stroke_width",
"=",
"1",
",",
"stroke_dasharray",
"=",
"None",
",",
"rx",
"=",
"None",
",",
"ry",
"=",
"None",
")",
":",
"def",
"draw_rect",
"(",
"ctx",
",",... | Draw a rect around the box | [
"Draw",
"a",
"rect",
"around",
"the",
"box"
] | [
"\"\"\" Draw a rect around the box \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "color",
"type": null
},
{
"param": "bg_color",
"type": null
},
{
"param": "stroke_width",
"type": null
},
{
"param": "stroke_dasharray",
"type": null
},
{
"param": "rx",
"type": null
},
{
"para... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "color",
"type": null,
"docstring": null,
"docstring_tokens": ... |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | code | null | def code(self, language, text, tabsize=4, line_numbers=False, style=None):
""" Draw a code with syntax highlighting """
text = text.replace("\t", " " * tabsize)
if language:
parsed_text = highlight_code(text, language)
else:
parsed_text = parse_text(text, escape_... | Draw a code with syntax highlighting | Draw a code with syntax highlighting | [
"Draw",
"a",
"code",
"with",
"syntax",
"highlighting"
] | def code(self, language, text, tabsize=4, line_numbers=False, style=None):
text = text.replace("\t", " " * tabsize)
if language:
parsed_text = highlight_code(text, language)
else:
parsed_text = parse_text(text, escape_char=None)
if line_numbers:
parsed... | [
"def",
"code",
"(",
"self",
",",
"language",
",",
"text",
",",
"tabsize",
"=",
"4",
",",
"line_numbers",
"=",
"False",
",",
"style",
"=",
"None",
")",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"\"\\t\"",
",",
"\" \"",
"*",
"tabsize",
")",
"if"... | Draw a code with syntax highlighting | [
"Draw",
"a",
"code",
"with",
"syntax",
"highlighting"
] | [
"\"\"\" Draw a code with syntax highlighting \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "language",
"type": null
},
{
"param": "text",
"type": null
},
{
"param": "tabsize",
"type": null
},
{
"param": "line_numbers",
"type": null
},
{
"param": "style",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "language",
"type": null,
"docstring": null,
"docstring_tokens... |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | text | null | def text(self, text, style="default", escape_char="~"):
""" Draw a text
"style" can be string with the name of style or dict defining the style
"""
result_style = self._get_style(style)
parsed_text = parse_text(text, escape_char=escape_char)
self._text_helper(parsed_... | Draw a text
"style" can be string with the name of style or dict defining the style
| Draw a text
"style" can be string with the name of style or dict defining the style | [
"Draw",
"a",
"text",
"\"",
"style",
"\"",
"can",
"be",
"string",
"with",
"the",
"name",
"of",
"style",
"or",
"dict",
"defining",
"the",
"style"
] | def text(self, text, style="default", escape_char="~"):
result_style = self._get_style(style)
parsed_text = parse_text(text, escape_char=escape_char)
self._text_helper(parsed_text, result_style) | [
"def",
"text",
"(",
"self",
",",
"text",
",",
"style",
"=",
"\"default\"",
",",
"escape_char",
"=",
"\"~\"",
")",
":",
"result_style",
"=",
"self",
".",
"_get_style",
"(",
"style",
")",
"parsed_text",
"=",
"parse_text",
"(",
"text",
",",
"escape_char",
"... | Draw a text
"style" can be string with the name of style or dict defining the style | [
"Draw",
"a",
"text",
"\"",
"style",
"\"",
"can",
"be",
"string",
"with",
"the",
"name",
"of",
"style",
"or",
"dict",
"defining",
"the",
"style"
] | [
"\"\"\" Draw a text\n\n \"style\" can be string with the name of style or dict defining the style\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "text",
"type": null
},
{
"param": "style",
"type": null
},
{
"param": "escape_char",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [... |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | latex | null | def latex(self, text, scale=1.0, header=None, tail=None):
""" Renders LaTeX text into box. """
if header is None:
header = """
\\documentclass[varwidth,border=1pt]{standalone}
\\usepackage[utf8x]{inputenc}
\\usepackage{ucs}
\\usepackage{amsmath}
\\usepackage{amsfonts}
\\usepackage{amssymb}
... | Renders LaTeX text into box. | Renders LaTeX text into box. | [
"Renders",
"LaTeX",
"text",
"into",
"box",
"."
] | def latex(self, text, scale=1.0, header=None, tail=None):
if header is None:
header = """
\\documentclass[varwidth,border=1pt]{standalone}
\\usepackage[utf8x]{inputenc}
\\usepackage{ucs}
\\usepackage{amsmath}
\\usepackage{amsfonts}
\\usepackage{amssymb}
\\usepackage{graphicx}
\\begin{document}"""
... | [
"def",
"latex",
"(",
"self",
",",
"text",
",",
"scale",
"=",
"1.0",
",",
"header",
"=",
"None",
",",
"tail",
"=",
"None",
")",
":",
"if",
"header",
"is",
"None",
":",
"header",
"=",
"\"\"\"\n\\\\documentclass[varwidth,border=1pt]{standalone}\n\\\\usepackage[utf8... | Renders LaTeX text into box. | [
"Renders",
"LaTeX",
"text",
"into",
"box",
"."
] | [
"\"\"\" Renders LaTeX text into box. \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "text",
"type": null
},
{
"param": "scale",
"type": null
},
{
"param": "header",
"type": null
},
{
"param": "tail",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [... |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | new_style | null | def new_style(self, name, **kwargs):
""" Define a new style, it is an error if it already exists. """
if name in self._styles:
raise Exception("Style already exists")
check_style(kwargs)
self._styles[name] = kwargs | Define a new style, it is an error if it already exists. | Define a new style, it is an error if it already exists. | [
"Define",
"a",
"new",
"style",
"it",
"is",
"an",
"error",
"if",
"it",
"already",
"exists",
"."
] | def new_style(self, name, **kwargs):
if name in self._styles:
raise Exception("Style already exists")
check_style(kwargs)
self._styles[name] = kwargs | [
"def",
"new_style",
"(",
"self",
",",
"name",
",",
"**",
"kwargs",
")",
":",
"if",
"name",
"in",
"self",
".",
"_styles",
":",
"raise",
"Exception",
"(",
"\"Style already exists\"",
")",
"check_style",
"(",
"kwargs",
")",
"self",
".",
"_styles",
"[",
"nam... | Define a new style, it is an error if it already exists. | [
"Define",
"a",
"new",
"style",
"it",
"is",
"an",
"error",
"if",
"it",
"already",
"exists",
"."
] | [
"\"\"\" Define a new style, it is an error if it already exists. \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | update_style | null | def update_style(self, name, **kwargs):
""" Update a style, it is an error if style does not exists. """
check_style(kwargs)
new_style = self._styles[name].copy()
new_style.update(kwargs)
self._styles[name] = new_style | Update a style, it is an error if style does not exists. | Update a style, it is an error if style does not exists. | [
"Update",
"a",
"style",
"it",
"is",
"an",
"error",
"if",
"style",
"does",
"not",
"exists",
"."
] | def update_style(self, name, **kwargs):
check_style(kwargs)
new_style = self._styles[name].copy()
new_style.update(kwargs)
self._styles[name] = new_style | [
"def",
"update_style",
"(",
"self",
",",
"name",
",",
"**",
"kwargs",
")",
":",
"check_style",
"(",
"kwargs",
")",
"new_style",
"=",
"self",
".",
"_styles",
"[",
"name",
"]",
".",
"copy",
"(",
")",
"new_style",
".",
"update",
"(",
"kwargs",
")",
"sel... | Update a style, it is an error if style does not exists. | [
"Update",
"a",
"style",
"it",
"is",
"an",
"error",
"if",
"style",
"does",
"not",
"exists",
"."
] | [
"\"\"\" Update a style, it is an error if style does not exists. \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | x | <not_specific> | def x(self, value):
""" Create position on x-axis relative to the box """
value = PosValue.parse(value)
return LazyValue(
lambda: value.compute(self._rect.x, self._rect.width, 0)) | Create position on x-axis relative to the box | Create position on x-axis relative to the box | [
"Create",
"position",
"on",
"x",
"-",
"axis",
"relative",
"to",
"the",
"box"
] | def x(self, value):
value = PosValue.parse(value)
return LazyValue(
lambda: value.compute(self._rect.x, self._rect.width, 0)) | [
"def",
"x",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"PosValue",
".",
"parse",
"(",
"value",
")",
"return",
"LazyValue",
"(",
"lambda",
":",
"value",
".",
"compute",
"(",
"self",
".",
"_rect",
".",
"x",
",",
"self",
".",
"_rect",
".",
"... | Create position on x-axis relative to the box | [
"Create",
"position",
"on",
"x",
"-",
"axis",
"relative",
"to",
"the",
"box"
] | [
"\"\"\" Create position on x-axis relative to the box \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": ... |
8cd03d1d882a1cc68e92421cab4ff27372314347 | Kobzol/elsie | elsie/box.py | [
"MIT"
] | Python | y | <not_specific> | def y(self, value):
""" Create position on y-axis relative to the box """
value = PosValue.parse(value)
return LazyValue(
lambda: value.compute(self._rect.y, self._rect.height, 0)) | Create position on y-axis relative to the box | Create position on y-axis relative to the box | [
"Create",
"position",
"on",
"y",
"-",
"axis",
"relative",
"to",
"the",
"box"
] | def y(self, value):
value = PosValue.parse(value)
return LazyValue(
lambda: value.compute(self._rect.y, self._rect.height, 0)) | [
"def",
"y",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"PosValue",
".",
"parse",
"(",
"value",
")",
"return",
"LazyValue",
"(",
"lambda",
":",
"value",
".",
"compute",
"(",
"self",
".",
"_rect",
".",
"y",
",",
"self",
".",
"_rect",
".",
"... | Create position on y-axis relative to the box | [
"Create",
"position",
"on",
"y",
"-",
"axis",
"relative",
"to",
"the",
"box"
] | [
"\"\"\" Create position on y-axis relative to the box \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": ... |
0aeb33059915b0c767ae6aab1c5b7d221f6fc335 | Rastii/SlackJira | slack_jira/cmdline/runner.py | [
"MIT"
] | Python | _logging_config | null | def _logging_config(config_parser, disable_existing_loggers=False):
"""
Helper that allows us to use an existing ConfigParser object to load logging
configurations instead of a filename.
Note: this code is essentially copy pasta from `logging.config.fileConfig` except
we skip loading the file.
... |
Helper that allows us to use an existing ConfigParser object to load logging
configurations instead of a filename.
Note: this code is essentially copy pasta from `logging.config.fileConfig` except
we skip loading the file.
| Helper that allows us to use an existing ConfigParser object to load logging
configurations instead of a filename.
this code is essentially copy pasta from `logging.config.fileConfig` except
we skip loading the file. | [
"Helper",
"that",
"allows",
"us",
"to",
"use",
"an",
"existing",
"ConfigParser",
"object",
"to",
"load",
"logging",
"configurations",
"instead",
"of",
"a",
"filename",
".",
"this",
"code",
"is",
"essentially",
"copy",
"pasta",
"from",
"`",
"logging",
".",
"c... | def _logging_config(config_parser, disable_existing_loggers=False):
formatters = logging.config._create_formatters(config_parser)
logging._acquireLock()
try:
logging._handlers.clear()
del logging._handlerList[:]
handlers = logging.config._install_handlers(config_parser, formatters)
... | [
"def",
"_logging_config",
"(",
"config_parser",
",",
"disable_existing_loggers",
"=",
"False",
")",
":",
"formatters",
"=",
"logging",
".",
"config",
".",
"_create_formatters",
"(",
"config_parser",
")",
"logging",
".",
"_acquireLock",
"(",
")",
"try",
":",
"log... | Helper that allows us to use an existing ConfigParser object to load logging
configurations instead of a filename. | [
"Helper",
"that",
"allows",
"us",
"to",
"use",
"an",
"existing",
"ConfigParser",
"object",
"to",
"load",
"logging",
"configurations",
"instead",
"of",
"a",
"filename",
"."
] | [
"\"\"\"\n Helper that allows us to use an existing ConfigParser object to load logging\n configurations instead of a filename.\n\n Note: this code is essentially copy pasta from `logging.config.fileConfig` except\n we skip loading the file.\n \"\"\"",
"# critical section",
"# Handlers add themsel... | [
{
"param": "config_parser",
"type": null
},
{
"param": "disable_existing_loggers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "config_parser",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "disable_existing_loggers",
"type": null,
"docstring": null... |
806eb12d2142e13b743e66c899fac42f8eaa2750 | Rastii/SlackJira | slack_jira/resources.py | [
"MIT"
] | Python | __get_attr_helper | <not_specific> | def __get_attr_helper(self, object, field, default=None):
"""
Helper method is needed to call hasattr first and then calling getattr
with a default value.
The __getattr__ method is supposed to handle a default case, but it
seems like it is not written properly (yet) :-(
... |
Helper method is needed to call hasattr first and then calling getattr
with a default value.
The __getattr__ method is supposed to handle a default case, but it
seems like it is not written properly (yet) :-(
| Helper method is needed to call hasattr first and then calling getattr
with a default value.
The __getattr__ method is supposed to handle a default case, but it
seems like it is not written properly (yet) :-( | [
"Helper",
"method",
"is",
"needed",
"to",
"call",
"hasattr",
"first",
"and",
"then",
"calling",
"getattr",
"with",
"a",
"default",
"value",
".",
"The",
"__getattr__",
"method",
"is",
"supposed",
"to",
"handle",
"a",
"default",
"case",
"but",
"it",
"seems",
... | def __get_attr_helper(self, object, field, default=None):
if hasattr(object, field):
return getattr(object, field)
return default | [
"def",
"__get_attr_helper",
"(",
"self",
",",
"object",
",",
"field",
",",
"default",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"object",
",",
"field",
")",
":",
"return",
"getattr",
"(",
"object",
",",
"field",
")",
"return",
"default"
] | Helper method is needed to call hasattr first and then calling getattr
with a default value. | [
"Helper",
"method",
"is",
"needed",
"to",
"call",
"hasattr",
"first",
"and",
"then",
"calling",
"getattr",
"with",
"a",
"default",
"value",
"."
] | [
"\"\"\"\n Helper method is needed to call hasattr first and then calling getattr\n with a default value.\n\n The __getattr__ method is supposed to handle a default case, but it\n seems like it is not written properly (yet) :-(\n \"\"\"",
"# TODO: Make PR to fix this ^ bug"
] | [
{
"param": "self",
"type": null
},
{
"param": "object",
"type": null
},
{
"param": "field",
"type": null
},
{
"param": "default",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "object",
"type": null,
"docstring": null,
"docstring_tokens":... |
806eb12d2142e13b743e66c899fac42f8eaa2750 | Rastii/SlackJira | slack_jira/resources.py | [
"MIT"
] | Python | from_config | <not_specific> | def from_config(conf, jira_section=JIRA_SECTION):
"""
Instantiates a JiraSlack object from a ConfigParser object.
The ConfigParser must be extracted from a config that looks like the following:
[jira]
server = The JIRA server location
access_token = The OAUTH access toke... |
Instantiates a JiraSlack object from a ConfigParser object.
The ConfigParser must be extracted from a config that looks like the following:
[jira]
server = The JIRA server location
access_token = The OAUTH access token (obtained by doing the OAUTH dance)
access_token_se... | Instantiates a JiraSlack object from a ConfigParser object.
Additional documentation can be found in `settings.template.ini` | [
"Instantiates",
"a",
"JiraSlack",
"object",
"from",
"a",
"ConfigParser",
"object",
".",
"Additional",
"documentation",
"can",
"be",
"found",
"in",
"`",
"settings",
".",
"template",
".",
"ini",
"`"
] | def from_config(conf, jira_section=JIRA_SECTION):
oauth_dict = {
k: get_config_value(conf, jira_section, k)
for k in ("access_token", "access_token_secret", "consumer_key")
}
key_cert_file_path = get_config_value(conf, jira_section, "key_cert_path")
try:
... | [
"def",
"from_config",
"(",
"conf",
",",
"jira_section",
"=",
"JIRA_SECTION",
")",
":",
"oauth_dict",
"=",
"{",
"k",
":",
"get_config_value",
"(",
"conf",
",",
"jira_section",
",",
"k",
")",
"for",
"k",
"in",
"(",
"\"access_token\"",
",",
"\"access_token_secr... | Instantiates a JiraSlack object from a ConfigParser object. | [
"Instantiates",
"a",
"JiraSlack",
"object",
"from",
"a",
"ConfigParser",
"object",
"."
] | [
"\"\"\"\n Instantiates a JiraSlack object from a ConfigParser object.\n\n The ConfigParser must be extracted from a config that looks like the following:\n [jira]\n server = The JIRA server location\n access_token = The OAUTH access token (obtained by doing the OAUTH dance)\n ... | [
{
"param": "conf",
"type": null
},
{
"param": "jira_section",
"type": null
}
] | {
"returns": [
{
"docstring": "An instantiated SlackJira from the config parser.",
"docstring_tokens": [
"An",
"instantiated",
"SlackJira",
"from",
"the",
"config",
"parser",
"."
],
"type": "SlackJira"
}
],
"raises": [... |
806eb12d2142e13b743e66c899fac42f8eaa2750 | Rastii/SlackJira | slack_jira/resources.py | [
"MIT"
] | Python | load_into_settings_module | null | def load_into_settings_module(self, settings_module):
"""
Loads the appropriate settings into the module specified.
We need to load the settings into the setting module because we cannot inject the
settings into the actual bot object... :(
Perhaps a PR will be created to allow ... |
Loads the appropriate settings into the module specified.
We need to load the settings into the setting module because we cannot inject the
settings into the actual bot object... :(
Perhaps a PR will be created to allow that...
:param settings_module: The settings module
... | Loads the appropriate settings into the module specified.
We need to load the settings into the setting module because we cannot inject the
settings into the actual bot object...
Perhaps a PR will be created to allow that | [
"Loads",
"the",
"appropriate",
"settings",
"into",
"the",
"module",
"specified",
".",
"We",
"need",
"to",
"load",
"the",
"settings",
"into",
"the",
"setting",
"module",
"because",
"we",
"cannot",
"inject",
"the",
"settings",
"into",
"the",
"actual",
"bot",
"... | def load_into_settings_module(self, settings_module):
if self._api_token:
settings_module.API_TOKEN = self._api_token
if self._bot_emoji:
settings_module.BOT_EMOJI = self._bot_emoji
if self._bot_icon:
settings_module.BOT_ICON = self._bot_icon
if self._... | [
"def",
"load_into_settings_module",
"(",
"self",
",",
"settings_module",
")",
":",
"if",
"self",
".",
"_api_token",
":",
"settings_module",
".",
"API_TOKEN",
"=",
"self",
".",
"_api_token",
"if",
"self",
".",
"_bot_emoji",
":",
"settings_module",
".",
"BOT_EMOJI... | Loads the appropriate settings into the module specified. | [
"Loads",
"the",
"appropriate",
"settings",
"into",
"the",
"module",
"specified",
"."
] | [
"\"\"\"\n Loads the appropriate settings into the module specified.\n\n We need to load the settings into the setting module because we cannot inject the\n settings into the actual bot object... :(\n\n Perhaps a PR will be created to allow that...\n\n :param settings_module: The s... | [
{
"param": "self",
"type": null
},
{
"param": "settings_module",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "settings_module",
"type": null,
"docstring": "The settings module",... |
806eb12d2142e13b743e66c899fac42f8eaa2750 | Rastii/SlackJira | slack_jira/resources.py | [
"MIT"
] | Python | from_config | <not_specific> | def from_config(conf, section="slackbot"):
"""
Loads the slack options from a ConfigParser object.
:param conf: ConfigParser object with slackbot settings
:type conf: ConfigParser.ConfigParser
:param section: The section to extract settings from. Defaults to "slackbot"
... |
Loads the slack options from a ConfigParser object.
:param conf: ConfigParser object with slackbot settings
:type conf: ConfigParser.ConfigParser
:param section: The section to extract settings from. Defaults to "slackbot"
:type section: str
:rtype: SlackBotConfig
... | Loads the slack options from a ConfigParser object. | [
"Loads",
"the",
"slack",
"options",
"from",
"a",
"ConfigParser",
"object",
"."
] | def from_config(conf, section="slackbot"):
get_conf = functools.partial(get_config_value, conf, section)
conf_slackbot_plugins = get_conf("slackbot_plugins")
plugins = [p.strip() for p in conf_slackbot_plugins.split(",")]
return SlackBotConfig(
api_token=get_conf("api_token")... | [
"def",
"from_config",
"(",
"conf",
",",
"section",
"=",
"\"slackbot\"",
")",
":",
"get_conf",
"=",
"functools",
".",
"partial",
"(",
"get_config_value",
",",
"conf",
",",
"section",
")",
"conf_slackbot_plugins",
"=",
"get_conf",
"(",
"\"slackbot_plugins\"",
")",... | Loads the slack options from a ConfigParser object. | [
"Loads",
"the",
"slack",
"options",
"from",
"a",
"ConfigParser",
"object",
"."
] | [
"\"\"\"\n Loads the slack options from a ConfigParser object.\n\n :param conf: ConfigParser object with slackbot settings\n :type conf: ConfigParser.ConfigParser\n :param section: The section to extract settings from. Defaults to \"slackbot\"\n :type section: str\n\n :rtyp... | [
{
"param": "conf",
"type": null
},
{
"param": "section",
"type": null
}
] | {
"returns": [
{
"docstring": "A loaded SlackBotConfig object with the options parsed from the configparser.",
"docstring_tokens": [
"A",
"loaded",
"SlackBotConfig",
"object",
"with",
"the",
"options",
"parsed",
"from",
"t... |
2c97f8e2bdebb03ebf21a60a2d0f25469c162150 | misson3/mobile-away | toggltrack.py | [
"MIT"
] | Python | startTimeEntry | <not_specific> | def startTimeEntry(requests, desc, pid, wid, auth):
"""
desc: description for the entry
pid: project id
wid: workspace id
"""
headers = {
'Content-Type': 'application/json',
'Authorization': auth
}
data = '{"time_entry":{"description":"' + desc + '",'
data += '"pid"... |
desc: description for the entry
pid: project id
wid: workspace id
| description for the entry
pid: project id
wid: workspace id | [
"description",
"for",
"the",
"entry",
"pid",
":",
"project",
"id",
"wid",
":",
"workspace",
"id"
] | def startTimeEntry(requests, desc, pid, wid, auth):
headers = {
'Content-Type': 'application/json',
'Authorization': auth
}
data = '{"time_entry":{"description":"' + desc + '",'
data += '"pid":' + pid + ','
data += '"wid":' + wid + ','
data += '"created_with":"curl"}' + '}'
p... | [
"def",
"startTimeEntry",
"(",
"requests",
",",
"desc",
",",
"pid",
",",
"wid",
",",
"auth",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
",",
"'Authorization'",
":",
"auth",
"}",
"data",
"=",
"'{\"time_entry\":{\"description\":\"'"... | desc: description for the entry
pid: project id
wid: workspace id | [
"desc",
":",
"description",
"for",
"the",
"entry",
"pid",
":",
"project",
"id",
"wid",
":",
"workspace",
"id"
] | [
"\"\"\"\n desc: description for the entry\n pid: project id\n wid: workspace id\n \"\"\"",
"# response = requests.post(uri,",
"# headers=headers, data=data,",
"# auth=(auth, 'api_token'))"
] | [
{
"param": "requests",
"type": null
},
{
"param": "desc",
"type": null
},
{
"param": "pid",
"type": null
},
{
"param": "wid",
"type": null
},
{
"param": "auth",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "requests",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "desc",
"type": null,
"docstring": null,
"docstring_tokens... |
2c97f8e2bdebb03ebf21a60a2d0f25469c162150 | misson3/mobile-away | toggltrack.py | [
"MIT"
] | Python | stopTimeEntry | null | def stopTimeEntry(requests, entry_id, auth):
"""
stop is easier. just include entry_id in the uri
"""
headers = {
'Content-Type': 'application/json',
'Authorization': auth,
'Content-length': "0"
}
uri = 'https://api.track.toggl.com/api/v8/time_entries/'
uri += str(e... |
stop is easier. just include entry_id in the uri
| stop is easier. just include entry_id in the uri | [
"stop",
"is",
"easier",
".",
"just",
"include",
"entry_id",
"in",
"the",
"uri"
] | def stopTimeEntry(requests, entry_id, auth):
headers = {
'Content-Type': 'application/json',
'Authorization': auth,
'Content-length': "0"
}
uri = 'https://api.track.toggl.com/api/v8/time_entries/'
uri += str(entry_id) + '/stop'
print()
print('[debug] header')
print(he... | [
"def",
"stopTimeEntry",
"(",
"requests",
",",
"entry_id",
",",
"auth",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
",",
"'Authorization'",
":",
"auth",
",",
"'Content-length'",
":",
"\"0\"",
"}",
"uri",
"=",
"'https://api.track.to... | stop is easier. | [
"stop",
"is",
"easier",
"."
] | [
"\"\"\"\n stop is easier. just include entry_id in the uri\n \"\"\"",
"# response = requests.put(uri,",
"# headers=headers,",
"# auth=(auth, 'api_token'))"
] | [
{
"param": "requests",
"type": null
},
{
"param": "entry_id",
"type": null
},
{
"param": "auth",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "requests",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "entry_id",
"type": null,
"docstring": null,
"docstring_to... |
138bfbd8bb4d93045ee1d0d9f22de64b1abb65f3 | misson3/mobile-away | code.py | [
"MIT"
] | Python | switchDisplayMode | null | def switchDisplayMode(mode):
'''
hide show labels for different modes
'''
if mode == 'waiting':
funhouse.set_text("", lb_time_away)
funhouse.set_text("", lb_min)
funhouse.set_text("", lb_away_min1)
funhouse.set_text("", lb_away_min2)
funhouse.set_text("", lb_away_... |
hide show labels for different modes
| hide show labels for different modes | [
"hide",
"show",
"labels",
"for",
"different",
"modes"
] | def switchDisplayMode(mode):
if mode == 'waiting':
funhouse.set_text("", lb_time_away)
funhouse.set_text("", lb_min)
funhouse.set_text("", lb_away_min1)
funhouse.set_text("", lb_away_min2)
funhouse.set_text("", lb_away_min3)
funhouse.set_text("WAITING...", lb_waiting)... | [
"def",
"switchDisplayMode",
"(",
"mode",
")",
":",
"if",
"mode",
"==",
"'waiting'",
":",
"funhouse",
".",
"set_text",
"(",
"\"\"",
",",
"lb_time_away",
")",
"funhouse",
".",
"set_text",
"(",
"\"\"",
",",
"lb_min",
")",
"funhouse",
".",
"set_text",
"(",
"... | hide show labels for different modes | [
"hide",
"show",
"labels",
"for",
"different",
"modes"
] | [
"'''\n hide show labels for different modes\n '''"
] | [
{
"param": "mode",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mode",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
138bfbd8bb4d93045ee1d0d9f22de64b1abb65f3 | misson3/mobile-away | code.py | [
"MIT"
] | Python | showDuration | null | def showDuration(num, color):
"""
control text_color and text position based on the digits
set_text_color method is available, but there is no
set_text_position...
so 3 labels are prepared and select one of them with digits of the number.
non use labels are invisible with blank text
"""
... |
control text_color and text position based on the digits
set_text_color method is available, but there is no
set_text_position...
so 3 labels are prepared and select one of them with digits of the number.
non use labels are invisible with blank text
| control text_color and text position based on the digits
set_text_color method is available, but there is no
set_text_position
so 3 labels are prepared and select one of them with digits of the number.
non use labels are invisible with blank text | [
"control",
"text_color",
"and",
"text",
"position",
"based",
"on",
"the",
"digits",
"set_text_color",
"method",
"is",
"available",
"but",
"there",
"is",
"no",
"set_text_position",
"so",
"3",
"labels",
"are",
"prepared",
"and",
"select",
"one",
"of",
"them",
"w... | def showDuration(num, color):
labels = [lb_away_min1, lb_away_min2, lb_away_min3]
if num < 10:
digits = 1
elif num < 100:
digits = 2
else:
digits = 3
for i in range(3):
if digits == i + 1:
funhouse.set_text(num, labels[i])
funhouse.set_text_col... | [
"def",
"showDuration",
"(",
"num",
",",
"color",
")",
":",
"labels",
"=",
"[",
"lb_away_min1",
",",
"lb_away_min2",
",",
"lb_away_min3",
"]",
"if",
"num",
"<",
"10",
":",
"digits",
"=",
"1",
"elif",
"num",
"<",
"100",
":",
"digits",
"=",
"2",
"else",... | control text_color and text position based on the digits
set_text_color method is available, but there is no
set_text_position...
so 3 labels are prepared and select one of them with digits of the number. | [
"control",
"text_color",
"and",
"text",
"position",
"based",
"on",
"the",
"digits",
"set_text_color",
"method",
"is",
"available",
"but",
"there",
"is",
"no",
"set_text_position",
"...",
"so",
"3",
"labels",
"are",
"prepared",
"and",
"select",
"one",
"of",
"th... | [
"\"\"\"\n control text_color and text position based on the digits\n set_text_color method is available, but there is no\n set_text_position...\n so 3 labels are prepared and select one of them with digits of the number.\n non use labels are invisible with blank text\n \"\"\""
] | [
{
"param": "num",
"type": null
},
{
"param": "color",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "num",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "color",
"type": null,
"docstring": null,
"docstring_tokens": [... |
138bfbd8bb4d93045ee1d0d9f22de64b1abb65f3 | misson3/mobile-away | code.py | [
"MIT"
] | Python | durationToPoints | <not_specific> | def durationToPoints(duration):
"""
less than 15 is not considered 'away'.
"""
if duration < 15:
points = 0
else:
points = duration
return points |
less than 15 is not considered 'away'.
| less than 15 is not considered 'away'. | [
"less",
"than",
"15",
"is",
"not",
"considered",
"'",
"away",
"'",
"."
] | def durationToPoints(duration):
if duration < 15:
points = 0
else:
points = duration
return points | [
"def",
"durationToPoints",
"(",
"duration",
")",
":",
"if",
"duration",
"<",
"15",
":",
"points",
"=",
"0",
"else",
":",
"points",
"=",
"duration",
"return",
"points"
] | less than 15 is not considered 'away'. | [
"less",
"than",
"15",
"is",
"not",
"considered",
"'",
"away",
"'",
"."
] | [
"\"\"\"\n less than 15 is not considered 'away'.\n \"\"\""
] | [
{
"param": "duration",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "duration",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
138bfbd8bb4d93045ee1d0d9f22de64b1abb65f3 | misson3/mobile-away | code.py | [
"MIT"
] | Python | adjustBeforeKeyTimePoints | <not_specific> | def adjustBeforeKeyTimePoints(local_time, *hs):
"""
check if local_time is 5 min be fore h in hs
if so, get current time from internet and set it to local_time
Use 24 for 0am
"""
print('[debug] adjustBeforeKeyTimePoints():', local_time)
# if it does not hit, no addjustment is done
lc_h =... |
check if local_time is 5 min be fore h in hs
if so, get current time from internet and set it to local_time
Use 24 for 0am
| check if local_time is 5 min be fore h in hs
if so, get current time from internet and set it to local_time
Use 24 for 0am | [
"check",
"if",
"local_time",
"is",
"5",
"min",
"be",
"fore",
"h",
"in",
"hs",
"if",
"so",
"get",
"current",
"time",
"from",
"internet",
"and",
"set",
"it",
"to",
"local_time",
"Use",
"24",
"for",
"0am"
] | def adjustBeforeKeyTimePoints(local_time, *hs):
print('[debug] adjustBeforeKeyTimePoints():', local_time)
lc_h = local_time.hour
lc_m = local_time.minute
adjusted = False
for h in hs:
if (lc_h, lc_m) == (h - 1, 55):
local_time = getCurrentTime()
adjusted = True
... | [
"def",
"adjustBeforeKeyTimePoints",
"(",
"local_time",
",",
"*",
"hs",
")",
":",
"print",
"(",
"'[debug] adjustBeforeKeyTimePoints():'",
",",
"local_time",
")",
"lc_h",
"=",
"local_time",
".",
"hour",
"lc_m",
"=",
"local_time",
".",
"minute",
"adjusted",
"=",
"F... | check if local_time is 5 min be fore h in hs
if so, get current time from internet and set it to local_time
Use 24 for 0am | [
"check",
"if",
"local_time",
"is",
"5",
"min",
"be",
"fore",
"h",
"in",
"hs",
"if",
"so",
"get",
"current",
"time",
"from",
"internet",
"and",
"set",
"it",
"to",
"local_time",
"Use",
"24",
"for",
"0am"
] | [
"\"\"\"\n check if local_time is 5 min be fore h in hs\n if so, get current time from internet and set it to local_time\n Use 24 for 0am\n \"\"\"",
"# if it does not hit, no addjustment is done",
"# print('[debug]', (lc_h, lc_m), 'is not', (h, 55))"
] | [
{
"param": "local_time",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "local_time",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
138bfbd8bb4d93045ee1d0d9f22de64b1abb65f3 | misson3/mobile-away | code.py | [
"MIT"
] | Python | sendMsgTo3B1 | <not_specific> | def sendMsgTo3B1(msg, lang, requests):
"""
ask google home to announce
node-red is working on 3Bp1
"""
host = secrets['raspi_announcement']
# lang = 'en-US' # only ja for now.
myData = {'message': msg, 'language': lang}
print('[debug sendMsgTo3B1()] posting:', msg)
res = requests.po... |
ask google home to announce
node-red is working on 3Bp1
| ask google home to announce
node-red is working on 3Bp1 | [
"ask",
"google",
"home",
"to",
"announce",
"node",
"-",
"red",
"is",
"working",
"on",
"3Bp1"
] | def sendMsgTo3B1(msg, lang, requests):
host = secrets['raspi_announcement']
myData = {'message': msg, 'language': lang}
print('[debug sendMsgTo3B1()] posting:', msg)
res = requests.post(host, data=myData)
print('[debug sendMsgTo3B1()] response.status_code:', res.status_code)
return 'sending mess... | [
"def",
"sendMsgTo3B1",
"(",
"msg",
",",
"lang",
",",
"requests",
")",
":",
"host",
"=",
"secrets",
"[",
"'raspi_announcement'",
"]",
"myData",
"=",
"{",
"'message'",
":",
"msg",
",",
"'language'",
":",
"lang",
"}",
"print",
"(",
"'[debug sendMsgTo3B1()] post... | ask google home to announce
node-red is working on 3Bp1 | [
"ask",
"google",
"home",
"to",
"announce",
"node",
"-",
"red",
"is",
"working",
"on",
"3Bp1"
] | [
"\"\"\"\n ask google home to announce\n node-red is working on 3Bp1\n \"\"\"",
"# lang = 'en-US' # only ja for now."
] | [
{
"param": "msg",
"type": null
},
{
"param": "lang",
"type": null
},
{
"param": "requests",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "msg",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lang",
"type": null,
"docstring": null,
"docstring_tokens": []... |
59c89c96188e5af3b8ed1c663e2ff2be0a3d0cb5 | misson3/mobile-away | dbAccess.py | [
"MIT"
] | Python | postTimeEntryTo3B1 | null | def postTimeEntryTo3B1(points, bonus, duration, requests):
"""
post
points, bonus and duration to flask server on 3B1
"""
data = {
'points': points,
'bonus': bonus,
'duration': duration
}
response = requests.post(URL_entry, json=data)
print('postTimeEntryTo3B1() s... |
post
points, bonus and duration to flask server on 3B1
| post
points, bonus and duration to flask server on 3B1 | [
"post",
"points",
"bonus",
"and",
"duration",
"to",
"flask",
"server",
"on",
"3B1"
] | def postTimeEntryTo3B1(points, bonus, duration, requests):
data = {
'points': points,
'bonus': bonus,
'duration': duration
}
response = requests.post(URL_entry, json=data)
print('postTimeEntryTo3B1() status code:', response.status_code) | [
"def",
"postTimeEntryTo3B1",
"(",
"points",
",",
"bonus",
",",
"duration",
",",
"requests",
")",
":",
"data",
"=",
"{",
"'points'",
":",
"points",
",",
"'bonus'",
":",
"bonus",
",",
"'duration'",
":",
"duration",
"}",
"response",
"=",
"requests",
".",
"p... | post
points, bonus and duration to flask server on 3B1 | [
"post",
"points",
"bonus",
"and",
"duration",
"to",
"flask",
"server",
"on",
"3B1"
] | [
"\"\"\"\n post\n points, bonus and duration to flask server on 3B1\n \"\"\""
] | [
{
"param": "points",
"type": null
},
{
"param": "bonus",
"type": null
},
{
"param": "duration",
"type": null
},
{
"param": "requests",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "points",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bonus",
"type": null,
"docstring": null,
"docstring_tokens"... |
5384d6ac3d5e38978988031f9f576737a540961e | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/classifier.py | [
"MIT"
] | Python | predict | <not_specific> | def predict(self, feature_data):
""" process the given feature_data using the classifier model, and smooth
the output. It returns a tuple containing (prediction, probability, label) """
start_time = time.time()
output = self.model.transform(feature_data)
now = time.time... | process the given feature_data using the classifier model, and smooth
the output. It returns a tuple containing (prediction, probability, label) | process the given feature_data using the classifier model, and smooth
the output. It returns a tuple containing (prediction, probability, label) | [
"process",
"the",
"given",
"feature_data",
"using",
"the",
"classifier",
"model",
"and",
"smooth",
"the",
"output",
".",
"It",
"returns",
"a",
"tuple",
"containing",
"(",
"prediction",
"probability",
"label",
")"
] | def predict(self, feature_data):
start_time = time.time()
output = self.model.transform(feature_data)
now = time.time()
diff = now - start_time
self.total_time += diff
self.count += 1
if self.logfile:
self.logfile.write("{}\n".format(",".join([str(x) f... | [
"def",
"predict",
"(",
"self",
",",
"feature_data",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"output",
"=",
"self",
".",
"model",
".",
"transform",
"(",
"feature_data",
")",
"now",
"=",
"time",
".",
"time",
"(",
")",
"diff",
"=",
... | process the given feature_data using the classifier model, and smooth
the output. | [
"process",
"the",
"given",
"feature_data",
"using",
"the",
"classifier",
"model",
"and",
"smooth",
"the",
"output",
"."
] | [
"\"\"\" process the given feature_data using the classifier model, and smooth\n the output. It returns a tuple containing (prediction, probability, label) \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "feature_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "feature_data",
"type": null,
"docstring": null,
"docstring_to... |
5384d6ac3d5e38978988031f9f576737a540961e | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/classifier.py | [
"MIT"
] | Python | _smooth | <not_specific> | def _smooth(self, predictions):
""" smooth the predictions over a time delay window """
now = time.time()
# if we get more than 1 second delay then reset our state
if self.start_time is None or now > self.start_time + 1:
self.start_time = now
self.items = []
... | smooth the predictions over a time delay window | smooth the predictions over a time delay window | [
"smooth",
"the",
"predictions",
"over",
"a",
"time",
"delay",
"window"
] | def _smooth(self, predictions):
now = time.time()
if self.start_time is None or now > self.start_time + 1:
self.start_time = now
self.items = []
new_items = [x for x in self.items if x[0] + self.smoothing_delay >= now ]
new_items += [ (now, predictions) ]
... | [
"def",
"_smooth",
"(",
"self",
",",
"predictions",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"self",
".",
"start_time",
"is",
"None",
"or",
"now",
">",
"self",
".",
"start_time",
"+",
"1",
":",
"self",
".",
"start_time",
"=",
"now"... | smooth the predictions over a time delay window | [
"smooth",
"the",
"predictions",
"over",
"a",
"time",
"delay",
"window"
] | [
"\"\"\" smooth the predictions over a time delay window \"\"\"",
"# if we get more than 1 second delay then reset our state",
"# trim to our delay window",
"# add our new item",
"# compute summed probabilities over this new sliding window"
] | [
{
"param": "self",
"type": null
},
{
"param": "predictions",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "predictions",
"type": null,
"docstring": null,
"docstring_tok... |
b1f6ea22287531001e4584cc20f0ce48ee0f063d | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/train_classifier.py | [
"MIT"
] | Python | export | null | def export(self, name, device):
""" Export the model to the ONNX file format """
self.init_hidden()
dummy_input = Variable(torch.randn(1, 1, self.input_dim))
if device:
dummy_input = dummy_input.to(device)
torch.onnx.export(self, dummy_input, name, verbose=True) | Export the model to the ONNX file format | Export the model to the ONNX file format | [
"Export",
"the",
"model",
"to",
"the",
"ONNX",
"file",
"format"
] | def export(self, name, device):
self.init_hidden()
dummy_input = Variable(torch.randn(1, 1, self.input_dim))
if device:
dummy_input = dummy_input.to(device)
torch.onnx.export(self, dummy_input, name, verbose=True) | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"device",
")",
":",
"self",
".",
"init_hidden",
"(",
")",
"dummy_input",
"=",
"Variable",
"(",
"torch",
".",
"randn",
"(",
"1",
",",
"1",
",",
"self",
".",
"input_dim",
")",
")",
"if",
"device",
":",
... | Export the model to the ONNX file format | [
"Export",
"the",
"model",
"to",
"the",
"ONNX",
"file",
"format"
] | [
"\"\"\" Export the model to the ONNX file format \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "device",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
b1f6ea22287531001e4584cc20f0ce48ee0f063d | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/train_classifier.py | [
"MIT"
] | Python | batch_accuracy | <not_specific> | def batch_accuracy(self, scores, labels):
""" Compute the training accuracy of the results of a single mini-batch """
batch_size = scores.shape[0]
passed = 0
for i in range(batch_size):
expected = labels[i]
actual = scores[i].argmax()
if expected == ac... | Compute the training accuracy of the results of a single mini-batch | Compute the training accuracy of the results of a single mini-batch | [
"Compute",
"the",
"training",
"accuracy",
"of",
"the",
"results",
"of",
"a",
"single",
"mini",
"-",
"batch"
] | def batch_accuracy(self, scores, labels):
batch_size = scores.shape[0]
passed = 0
for i in range(batch_size):
expected = labels[i]
actual = scores[i].argmax()
if expected == actual:
passed += 1
return (float(passed) * 100.0 / float(batc... | [
"def",
"batch_accuracy",
"(",
"self",
",",
"scores",
",",
"labels",
")",
":",
"batch_size",
"=",
"scores",
".",
"shape",
"[",
"0",
"]",
"passed",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"batch_size",
")",
":",
"expected",
"=",
"labels",
"[",
"i",
... | Compute the training accuracy of the results of a single mini-batch | [
"Compute",
"the",
"training",
"accuracy",
"of",
"the",
"results",
"of",
"a",
"single",
"mini",
"-",
"batch"
] | [
"\"\"\" Compute the training accuracy of the results of a single mini-batch \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "scores",
"type": null
},
{
"param": "labels",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "scores",
"type": null,
"docstring": null,
"docstring_tokens":... |
b1f6ea22287531001e4584cc20f0ce48ee0f063d | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/train_classifier.py | [
"MIT"
] | Python | fit | null | def fit(self, training_data, validation_data, batch_size=64, num_epochs=30, learning_rate=0.001, weight_decay=0, device=None):
"""
Perform the training. This is not called "train" because the base class already defines
that method with a different meaning. The base class "train" method puts th... |
Perform the training. This is not called "train" because the base class already defines
that method with a different meaning. The base class "train" method puts the Module into
"training mode".
| Perform the training. This is not called "train" because the base class already defines
that method with a different meaning. The base class "train" method puts the Module into
"training mode". | [
"Perform",
"the",
"training",
".",
"This",
"is",
"not",
"called",
"\"",
"train",
"\"",
"because",
"the",
"base",
"class",
"already",
"defines",
"that",
"method",
"with",
"a",
"different",
"meaning",
".",
"The",
"base",
"class",
"\"",
"train",
"\"",
"method... | def fit(self, training_data, validation_data, batch_size=64, num_epochs=30, learning_rate=0.001, weight_decay=0, device=None):
print("Training keyword spotter using {} rows of featurized training input...".format(training_data.num_rows))
start = time.time()
loss_function = nn.NLLLoss()
o... | [
"def",
"fit",
"(",
"self",
",",
"training_data",
",",
"validation_data",
",",
"batch_size",
"=",
"64",
",",
"num_epochs",
"=",
"30",
",",
"learning_rate",
"=",
"0.001",
",",
"weight_decay",
"=",
"0",
",",
"device",
"=",
"None",
")",
":",
"print",
"(",
... | Perform the training. | [
"Perform",
"the",
"training",
"."
] | [
"\"\"\"\n Perform the training. This is not called \"train\" because the base class already defines\n that method with a different meaning. The base class \"train\" method puts the Module into\n \"training mode\".\n \"\"\"",
"#optimizer = optim.Adam(model.parameters(), lr=0.0001)",
... | [
{
"param": "self",
"type": null
},
{
"param": "training_data",
"type": null
},
{
"param": "validation_data",
"type": null
},
{
"param": "batch_size",
"type": null
},
{
"param": "num_epochs",
"type": null
},
{
"param": "learning_rate",
"type": null
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "training_data",
"type": null,
"docstring": null,
"docstring_t... |
b1f6ea22287531001e4584cc20f0ce48ee0f063d | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/train_classifier.py | [
"MIT"
] | Python | evaluate | <not_specific> | def evaluate(self, test_data, batch_size, device=None):
"""
Evaluate the given test data and print the pass rate
"""
self.eval()
passed = 0
total = 0
self.zero_grad()
with torch.no_grad():
for i_batch, (audio, labels) in enumerate(test_... |
Evaluate the given test data and print the pass rate
| Evaluate the given test data and print the pass rate | [
"Evaluate",
"the",
"given",
"test",
"data",
"and",
"print",
"the",
"pass",
"rate"
] | def evaluate(self, test_data, batch_size, device=None):
self.eval()
passed = 0
total = 0
self.zero_grad()
with torch.no_grad():
for i_batch, (audio, labels) in enumerate(test_data.get_data_loader(batch_size)):
batch_size = audio.shape[0]
... | [
"def",
"evaluate",
"(",
"self",
",",
"test_data",
",",
"batch_size",
",",
"device",
"=",
"None",
")",
":",
"self",
".",
"eval",
"(",
")",
"passed",
"=",
"0",
"total",
"=",
"0",
"self",
".",
"zero_grad",
"(",
")",
"with",
"torch",
".",
"no_grad",
"(... | Evaluate the given test data and print the pass rate | [
"Evaluate",
"the",
"given",
"test",
"data",
"and",
"print",
"the",
"pass",
"rate"
] | [
"\"\"\"\n Evaluate the given test data and print the pass rate\n \"\"\"",
"# GRU wants seq,batch,feature"
] | [
{
"param": "self",
"type": null
},
{
"param": "test_data",
"type": null
},
{
"param": "batch_size",
"type": null
},
{
"param": "device",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "test_data",
"type": null,
"docstring": null,
"docstring_token... |
b1f6ea22287531001e4584cc20f0ce48ee0f063d | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/train_classifier.py | [
"MIT"
] | Python | forward | <not_specific> | def forward(self, input):
""" Perform the forward processing of the given input and return the prediction """
# input is shape: [seq,batch,feature]
gru_out, self.hidden1 = self.gru1(input, self.hidden1)
gru_out, self.hidden2 = self.gru2(gru_out, self.hidden2)
keyword_space = self... | Perform the forward processing of the given input and return the prediction | Perform the forward processing of the given input and return the prediction | [
"Perform",
"the",
"forward",
"processing",
"of",
"the",
"given",
"input",
"and",
"return",
"the",
"prediction"
] | def forward(self, input):
gru_out, self.hidden1 = self.gru1(input, self.hidden1)
gru_out, self.hidden2 = self.gru2(gru_out, self.hidden2)
keyword_space = self.hidden2keyword(gru_out)
result = F.log_softmax(keyword_space, dim=2)
result = result.mean(dim=0)
return result | [
"def",
"forward",
"(",
"self",
",",
"input",
")",
":",
"gru_out",
",",
"self",
".",
"hidden1",
"=",
"self",
".",
"gru1",
"(",
"input",
",",
"self",
".",
"hidden1",
")",
"gru_out",
",",
"self",
".",
"hidden2",
"=",
"self",
".",
"gru2",
"(",
"gru_out... | Perform the forward processing of the given input and return the prediction | [
"Perform",
"the",
"forward",
"processing",
"of",
"the",
"given",
"input",
"and",
"return",
"the",
"prediction"
] | [
"\"\"\" Perform the forward processing of the given input and return the prediction \"\"\"",
"# input is shape: [seq,batch,feature]",
"# return the mean across the sequence length to produce the ",
"# best prediction of which word exists in that sequence.",
"# we can do that because we know each window_size... | [
{
"param": "self",
"type": null
},
{
"param": "input",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input",
"type": null,
"docstring": null,
"docstring_tokens": ... |
b1f6ea22287531001e4584cc20f0ce48ee0f063d | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/train_classifier.py | [
"MIT"
] | Python | forward | <not_specific> | def forward(self, input):
""" Perform the forward processing of the given input and return the prediction """
# input is shape: [seq,batch,feature]
lstm_out, self.hidden1 = self.lstm1(input, self.hidden1)
lstm_out, self.hidden2 = self.lstm2(lstm_out, self.hidden2)
keyword_space =... | Perform the forward processing of the given input and return the prediction | Perform the forward processing of the given input and return the prediction | [
"Perform",
"the",
"forward",
"processing",
"of",
"the",
"given",
"input",
"and",
"return",
"the",
"prediction"
] | def forward(self, input):
lstm_out, self.hidden1 = self.lstm1(input, self.hidden1)
lstm_out, self.hidden2 = self.lstm2(lstm_out, self.hidden2)
keyword_space = self.hidden2keyword(lstm_out)
result = F.log_softmax(keyword_space, dim=2)
result = result.mean(dim=0)
return r... | [
"def",
"forward",
"(",
"self",
",",
"input",
")",
":",
"lstm_out",
",",
"self",
".",
"hidden1",
"=",
"self",
".",
"lstm1",
"(",
"input",
",",
"self",
".",
"hidden1",
")",
"lstm_out",
",",
"self",
".",
"hidden2",
"=",
"self",
".",
"lstm2",
"(",
"lst... | Perform the forward processing of the given input and return the prediction | [
"Perform",
"the",
"forward",
"processing",
"of",
"the",
"given",
"input",
"and",
"return",
"the",
"prediction"
] | [
"\"\"\" Perform the forward processing of the given input and return the prediction \"\"\"",
"# input is shape: [seq,batch,feature]",
"# return the mean across the sequence length to produce the ",
"# best prediction of which word exists in that sequence.",
"# we can do that because we know each window_size... | [
{
"param": "self",
"type": null
},
{
"param": "input",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input",
"type": null,
"docstring": null,
"docstring_tokens": ... |
b1f6ea22287531001e4584cc20f0ce48ee0f063d | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/train_classifier.py | [
"MIT"
] | Python | to_long_vector | <not_specific> | def to_long_vector(self):
""" convert the expected labels to a list of integer indexes into the array of keywords """
result = np.zeros((self.num_rows, self.num_keywords), dtype=np.float32)
indexer = [ (0 if x == "<null>" else self.keywords.index(x)) for x in self.label_names ]
return np... | convert the expected labels to a list of integer indexes into the array of keywords | convert the expected labels to a list of integer indexes into the array of keywords | [
"convert",
"the",
"expected",
"labels",
"to",
"a",
"list",
"of",
"integer",
"indexes",
"into",
"the",
"array",
"of",
"keywords"
] | def to_long_vector(self):
result = np.zeros((self.num_rows, self.num_keywords), dtype=np.float32)
indexer = [ (0 if x == "<null>" else self.keywords.index(x)) for x in self.label_names ]
return np.array(indexer, dtype=np.longlong) | [
"def",
"to_long_vector",
"(",
"self",
")",
":",
"result",
"=",
"np",
".",
"zeros",
"(",
"(",
"self",
".",
"num_rows",
",",
"self",
".",
"num_keywords",
")",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"indexer",
"=",
"[",
"(",
"0",
"if",
"x",
"... | convert the expected labels to a list of integer indexes into the array of keywords | [
"convert",
"the",
"expected",
"labels",
"to",
"a",
"list",
"of",
"integer",
"indexes",
"into",
"the",
"array",
"of",
"keywords"
] | [
"\"\"\" convert the expected labels to a list of integer indexes into the array of keywords \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | load_settings | null | def load_settings(self):
""" load the previously saved settings from disk, if any """
self.settings = {}
if os.path.isfile(self.settings_file_name):
with open(self.settings_file_name, "r") as f:
self.settings = json.load(f) | load the previously saved settings from disk, if any | load the previously saved settings from disk, if any | [
"load",
"the",
"previously",
"saved",
"settings",
"from",
"disk",
"if",
"any"
] | def load_settings(self):
self.settings = {}
if os.path.isfile(self.settings_file_name):
with open(self.settings_file_name, "r") as f:
self.settings = json.load(f) | [
"def",
"load_settings",
"(",
"self",
")",
":",
"self",
".",
"settings",
"=",
"{",
"}",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"settings_file_name",
")",
":",
"with",
"open",
"(",
"self",
".",
"settings_file_name",
",",
"\"r\"",
")",
... | load the previously saved settings from disk, if any | [
"load",
"the",
"previously",
"saved",
"settings",
"from",
"disk",
"if",
"any"
] | [
"\"\"\" load the previously saved settings from disk, if any \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | save_settings | null | def save_settings(self):
""" save the current settings to disk """
settings_dir = os.path.dirname(self.settings_file_name)
if not os.path.isdir(settings_dir):
os.makedirs(settings_dir)
with open(self.settings_file_name, "w") as f:
f.write(json.dumps(self.settings)... | save the current settings to disk | save the current settings to disk | [
"save",
"the",
"current",
"settings",
"to",
"disk"
] | def save_settings(self):
settings_dir = os.path.dirname(self.settings_file_name)
if not os.path.isdir(settings_dir):
os.makedirs(settings_dir)
with open(self.settings_file_name, "w") as f:
f.write(json.dumps(self.settings)) | [
"def",
"save_settings",
"(",
"self",
")",
":",
"settings_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"settings_file_name",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"settings_dir",
")",
":",
"os",
".",
"makedirs",
"(",... | save the current settings to disk | [
"save",
"the",
"current",
"settings",
"to",
"disk"
] | [
"\"\"\" save the current settings to disk \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | load_featurizer_model | null | def load_featurizer_model(self, featurizer_model):
""" load the given compiled ELL featurizer for use in processing subsequent audio input """
if featurizer_model:
self.featurizer = featurizer.AudioTransform(featurizer_model, 40)
self.setup_spectrogram_image()
... | load the given compiled ELL featurizer for use in processing subsequent audio input | load the given compiled ELL featurizer for use in processing subsequent audio input | [
"load",
"the",
"given",
"compiled",
"ELL",
"featurizer",
"for",
"use",
"in",
"processing",
"subsequent",
"audio",
"input"
] | def load_featurizer_model(self, featurizer_model):
if featurizer_model:
self.featurizer = featurizer.AudioTransform(featurizer_model, 40)
self.setup_spectrogram_image()
self.show_output("Feature input size: {}, output size: {}".format(
self.featurizer.input_si... | [
"def",
"load_featurizer_model",
"(",
"self",
",",
"featurizer_model",
")",
":",
"if",
"featurizer_model",
":",
"self",
".",
"featurizer",
"=",
"featurizer",
".",
"AudioTransform",
"(",
"featurizer_model",
",",
"40",
")",
"self",
".",
"setup_spectrogram_image",
"("... | load the given compiled ELL featurizer for use in processing subsequent audio input | [
"load",
"the",
"given",
"compiled",
"ELL",
"featurizer",
"for",
"use",
"in",
"processing",
"subsequent",
"audio",
"input"
] | [
"\"\"\" load the given compiled ELL featurizer for use in processing subsequent audio input \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "featurizer_model",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "featurizer_model",
"type": null,
"docstring": null,
"docstrin... |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | load_classifier | null | def load_classifier(self, classifier_path):
""" load the given compiled ELL classifier for use in processing subsequent audio input """
if classifier_path:
self.classifier = classifier.AudioClassifier(classifier_path, self.categories, self.threshold)
self.show_output("Classifier ... | load the given compiled ELL classifier for use in processing subsequent audio input | load the given compiled ELL classifier for use in processing subsequent audio input | [
"load",
"the",
"given",
"compiled",
"ELL",
"classifier",
"for",
"use",
"in",
"processing",
"subsequent",
"audio",
"input"
] | def load_classifier(self, classifier_path):
if classifier_path:
self.classifier = classifier.AudioClassifier(classifier_path, self.categories, self.threshold)
self.show_output("Classifier input size: {}, output size: {}".format(
self.classifier.input_size,
... | [
"def",
"load_classifier",
"(",
"self",
",",
"classifier_path",
")",
":",
"if",
"classifier_path",
":",
"self",
".",
"classifier",
"=",
"classifier",
".",
"AudioClassifier",
"(",
"classifier_path",
",",
"self",
".",
"categories",
",",
"self",
".",
"threshold",
... | load the given compiled ELL classifier for use in processing subsequent audio input | [
"load",
"the",
"given",
"compiled",
"ELL",
"classifier",
"for",
"use",
"in",
"processing",
"subsequent",
"audio",
"input"
] | [
"\"\"\" load the given compiled ELL classifier for use in processing subsequent audio input \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "classifier_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "classifier_path",
"type": null,
"docstring": null,
"docstring... |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | init_data | null | def init_data(self):
""" initialize the spectrogram_image_data and classifier_feature_data based on the newly loaded model info """
if self.featurizer:
dim = (self.featurizer.output_size, self.max_spectrogram_width)
self.spectrogram_image_data = np.zeros(dim, dtype=float)
... | initialize the spectrogram_image_data and classifier_feature_data based on the newly loaded model info | initialize the spectrogram_image_data and classifier_feature_data based on the newly loaded model info | [
"initialize",
"the",
"spectrogram_image_data",
"and",
"classifier_feature_data",
"based",
"on",
"the",
"newly",
"loaded",
"model",
"info"
] | def init_data(self):
if self.featurizer:
dim = (self.featurizer.output_size, self.max_spectrogram_width)
self.spectrogram_image_data = np.zeros(dim, dtype=float)
if self.spectrogram_image is not None:
self.spectrogram_image.set_data(self.spectrogram_image_da... | [
"def",
"init_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"featurizer",
":",
"dim",
"=",
"(",
"self",
".",
"featurizer",
".",
"output_size",
",",
"self",
".",
"max_spectrogram_width",
")",
"self",
".",
"spectrogram_image_data",
"=",
"np",
".",
"zeros",... | initialize the spectrogram_image_data and classifier_feature_data based on the newly loaded model info | [
"initialize",
"the",
"spectrogram_image_data",
"and",
"classifier_feature_data",
"based",
"on",
"the",
"newly",
"loaded",
"model",
"info"
] | [
"\"\"\" initialize the spectrogram_image_data and classifier_feature_data based on the newly loaded model info \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | accumulate_feature | null | def accumulate_feature(self, feature_data):
""" accumulate the feature data and pass feature data to classifier """
if self.classifier and self.show_classifier_output:
self.classifier_feature_data = np.vstack((self.classifier_feature_data,
feature_data))[-self.num_classifier... | accumulate the feature data and pass feature data to classifier | accumulate the feature data and pass feature data to classifier | [
"accumulate",
"the",
"feature",
"data",
"and",
"pass",
"feature",
"data",
"to",
"classifier"
] | def accumulate_feature(self, feature_data):
if self.classifier and self.show_classifier_output:
self.classifier_feature_data = np.vstack((self.classifier_feature_data,
feature_data))[-self.num_classifier_features:,:]
self.evaluate_classifier() | [
"def",
"accumulate_feature",
"(",
"self",
",",
"feature_data",
")",
":",
"if",
"self",
".",
"classifier",
"and",
"self",
".",
"show_classifier_output",
":",
"self",
".",
"classifier_feature_data",
"=",
"np",
".",
"vstack",
"(",
"(",
"self",
".",
"classifier_fe... | accumulate the feature data and pass feature data to classifier | [
"accumulate",
"the",
"feature",
"data",
"and",
"pass",
"feature",
"data",
"to",
"classifier"
] | [
"\"\"\" accumulate the feature data and pass feature data to classifier \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "feature_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "feature_data",
"type": null,
"docstring": null,
"docstring_to... |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | accumulate_spectrogram_image | null | def accumulate_spectrogram_image(self, feature_data):
""" accumulate the feature data into the spectrogram image """
image_data = self.spectrogram_image_data
feature_data = np.reshape(feature_data, [-1,1])
new_image = np.hstack((image_data, feature_data))[:,-image_data.shape[1]:]
... | accumulate the feature data into the spectrogram image | accumulate the feature data into the spectrogram image | [
"accumulate",
"the",
"feature",
"data",
"into",
"the",
"spectrogram",
"image"
] | def accumulate_spectrogram_image(self, feature_data):
image_data = self.spectrogram_image_data
feature_data = np.reshape(feature_data, [-1,1])
new_image = np.hstack((image_data, feature_data))[:,-image_data.shape[1]:]
image_data[:,:] = new_image | [
"def",
"accumulate_spectrogram_image",
"(",
"self",
",",
"feature_data",
")",
":",
"image_data",
"=",
"self",
".",
"spectrogram_image_data",
"feature_data",
"=",
"np",
".",
"reshape",
"(",
"feature_data",
",",
"[",
"-",
"1",
",",
"1",
"]",
")",
"new_image",
... | accumulate the feature data into the spectrogram image | [
"accumulate",
"the",
"feature",
"data",
"into",
"the",
"spectrogram",
"image"
] | [
"\"\"\" accumulate the feature data into the spectrogram image \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "feature_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "feature_data",
"type": null,
"docstring": null,
"docstring_to... |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | process_output | null | def process_output(self):
""" show output that was queued by background thread """
self.lock.acquire()
messages = self.message_queue
self.message_queue = []
self.lock.release()
for msg in messages:
self.show_output(msg) | show output that was queued by background thread | show output that was queued by background thread | [
"show",
"output",
"that",
"was",
"queued",
"by",
"background",
"thread"
] | def process_output(self):
self.lock.acquire()
messages = self.message_queue
self.message_queue = []
self.lock.release()
for msg in messages:
self.show_output(msg) | [
"def",
"process_output",
"(",
"self",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"messages",
"=",
"self",
".",
"message_queue",
"self",
".",
"message_queue",
"=",
"[",
"]",
"self",
".",
"lock",
".",
"release",
"(",
")",
"for",
"msg",
"i... | show output that was queued by background thread | [
"show",
"output",
"that",
"was",
"queued",
"by",
"background",
"thread"
] | [
"\"\"\" show output that was queued by background thread \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | show_output | <not_specific> | def show_output(self, message):
""" show output message, or queue it if we are on a background thread """
if self.main_thread != get_ident():
self.message_queue += [message]
return
for line in str(message).split('\n'):
self.output_text.insert(END, "{}\n".form... | show output message, or queue it if we are on a background thread | show output message, or queue it if we are on a background thread | [
"show",
"output",
"message",
"or",
"queue",
"it",
"if",
"we",
"are",
"on",
"a",
"background",
"thread"
] | def show_output(self, message):
if self.main_thread != get_ident():
self.message_queue += [message]
return
for line in str(message).split('\n'):
self.output_text.insert(END, "{}\n".format(line))
self.output_text.see("end")
self.after(self.output_clear... | [
"def",
"show_output",
"(",
"self",
",",
"message",
")",
":",
"if",
"self",
".",
"main_thread",
"!=",
"get_ident",
"(",
")",
":",
"self",
".",
"message_queue",
"+=",
"[",
"message",
"]",
"return",
"for",
"line",
"in",
"str",
"(",
"message",
")",
".",
... | show output message, or queue it if we are on a background thread | [
"show",
"output",
"message",
"or",
"queue",
"it",
"if",
"we",
"are",
"on",
"a",
"background",
"thread"
] | [
"\"\"\" show output message, or queue it if we are on a background thread \"\"\"",
"# scroll to end"
] | [
{
"param": "self",
"type": null
},
{
"param": "message",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens"... |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | evaluate_classifier | null | def evaluate_classifier(self):
""" run the classifier model on the current feature data and show the prediction, if any """
if self.evaluate_classifier and self.classifier and self.classifier_feature_data is not None:
prediction, probability, label = self.classifier.predict(self.classifier_f... | run the classifier model on the current feature data and show the prediction, if any | run the classifier model on the current feature data and show the prediction, if any | [
"run",
"the",
"classifier",
"model",
"on",
"the",
"current",
"feature",
"data",
"and",
"show",
"the",
"prediction",
"if",
"any"
] | def evaluate_classifier(self):
if self.evaluate_classifier and self.classifier and self.classifier_feature_data is not None:
prediction, probability, label = self.classifier.predict(self.classifier_feature_data.ravel())
if prediction is not None:
percent = int(100*probabi... | [
"def",
"evaluate_classifier",
"(",
"self",
")",
":",
"if",
"self",
".",
"evaluate_classifier",
"and",
"self",
".",
"classifier",
"and",
"self",
".",
"classifier_feature_data",
"is",
"not",
"None",
":",
"prediction",
",",
"probability",
",",
"label",
"=",
"self... | run the classifier model on the current feature data and show the prediction, if any | [
"run",
"the",
"classifier",
"model",
"on",
"the",
"current",
"feature",
"data",
"and",
"show",
"the",
"prediction",
"if",
"any"
] | [
"\"\"\" run the classifier model on the current feature data and show the prediction, if any \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | start_playing | <not_specific> | def start_playing(self, filename):
""" Play a wav file, and classify the audio. Note we use a background thread to read the
wav file and we setup a UI animation function to draw the sliding spectrogram image, this way
the UI update doesn't interfere with the smoothness of the audio playback """
... | Play a wav file, and classify the audio. Note we use a background thread to read the
wav file and we setup a UI animation function to draw the sliding spectrogram image, this way
the UI update doesn't interfere with the smoothness of the audio playback | Play a wav file, and classify the audio. Note we use a background thread to read the
wav file and we setup a UI animation function to draw the sliding spectrogram image, this way
the UI update doesn't interfere with the smoothness of the audio playback | [
"Play",
"a",
"wav",
"file",
"and",
"classify",
"the",
"audio",
".",
"Note",
"we",
"use",
"a",
"background",
"thread",
"to",
"read",
"the",
"wav",
"file",
"and",
"we",
"setup",
"a",
"UI",
"animation",
"function",
"to",
"draw",
"the",
"sliding",
"spectrogr... | def start_playing(self, filename):
if self.speaker is None:
self.speaker = speaker.Speaker()
self.stop()
self.reading_input = False
self.wav_file = wav_reader.WavReader(self.sample_rate, self.channels)
self.wav_file.open(filename, self.featurizer.input_size, self.spea... | [
"def",
"start_playing",
"(",
"self",
",",
"filename",
")",
":",
"if",
"self",
".",
"speaker",
"is",
"None",
":",
"self",
".",
"speaker",
"=",
"speaker",
".",
"Speaker",
"(",
")",
"self",
".",
"stop",
"(",
")",
"self",
".",
"reading_input",
"=",
"Fals... | Play a wav file, and classify the audio. | [
"Play",
"a",
"wav",
"file",
"and",
"classify",
"the",
"audio",
"."
] | [
"\"\"\" Play a wav file, and classify the audio. Note we use a background thread to read the\n wav file and we setup a UI animation function to draw the sliding spectrogram image, this way\n the UI update doesn't interfere with the smoothness of the audio playback \"\"\"",
"# Start animation timer f... | [
{
"param": "self",
"type": null
},
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens... |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | start_recording | <not_specific> | def start_recording(self):
""" Start recording audio from the microphone nd classify the audio. Note we use a background thread to
process the audio and we setup a UI animation function to draw the sliding spectrogram image, this way
the UI update doesn't interfere with the smoothness of the mi... | Start recording audio from the microphone nd classify the audio. Note we use a background thread to
process the audio and we setup a UI animation function to draw the sliding spectrogram image, this way
the UI update doesn't interfere with the smoothness of the microphone readings | Start recording audio from the microphone nd classify the audio. Note we use a background thread to
process the audio and we setup a UI animation function to draw the sliding spectrogram image, this way
the UI update doesn't interfere with the smoothness of the microphone readings | [
"Start",
"recording",
"audio",
"from",
"the",
"microphone",
"nd",
"classify",
"the",
"audio",
".",
"Note",
"we",
"use",
"a",
"background",
"thread",
"to",
"process",
"the",
"audio",
"and",
"we",
"setup",
"a",
"UI",
"animation",
"function",
"to",
"draw",
"t... | def start_recording(self):
self.stop()
input_channel = None
if self.serial_port:
import serial_reader
self.serial = serial_reader.SerialReader(0.001)
self.serial.open(self.featurizer.input_size, self.serial_port)
input_channel = self.serial
... | [
"def",
"start_recording",
"(",
"self",
")",
":",
"self",
".",
"stop",
"(",
")",
"input_channel",
"=",
"None",
"if",
"self",
".",
"serial_port",
":",
"import",
"serial_reader",
"self",
".",
"serial",
"=",
"serial_reader",
".",
"SerialReader",
"(",
"0.001",
... | Start recording audio from the microphone nd classify the audio. | [
"Start",
"recording",
"audio",
"from",
"the",
"microphone",
"nd",
"classify",
"the",
"audio",
"."
] | [
"\"\"\" Start recording audio from the microphone nd classify the audio. Note we use a background thread to \n process the audio and we setup a UI animation function to draw the sliding spectrogram image, this way\n the UI update doesn't interfere with the smoothness of the microphone readings \"\"\""... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | on_read_features | null | def on_read_features(self):
""" this is the background thread entry point. So we read the feature data in a loop
and pass it to the classifier """
try:
while self.reading_input and self.featurizer:
feature_data = self.featurizer.read()
... | this is the background thread entry point. So we read the feature data in a loop
and pass it to the classifier | this is the background thread entry point. So we read the feature data in a loop
and pass it to the classifier | [
"this",
"is",
"the",
"background",
"thread",
"entry",
"point",
".",
"So",
"we",
"read",
"the",
"feature",
"data",
"in",
"a",
"loop",
"and",
"pass",
"it",
"to",
"the",
"classifier"
] | def on_read_features(self):
try:
while self.reading_input and self.featurizer:
feature_data = self.featurizer.read()
if feature_data is None:
break
else:
... | [
"def",
"on_read_features",
"(",
"self",
")",
":",
"try",
":",
"while",
"self",
".",
"reading_input",
"and",
"self",
".",
"featurizer",
":",
"feature_data",
"=",
"self",
".",
"featurizer",
".",
"read",
"(",
")",
"if",
"feature_data",
"is",
"None",
":",
"b... | this is the background thread entry point. | [
"this",
"is",
"the",
"background",
"thread",
"entry",
"point",
"."
] | [
"\"\"\" this is the background thread entry point. So we read the feature data in a loop\n and pass it to the classifier \"\"\"",
"# eof"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | on_stop | null | def on_stop(self):
""" called when user clicks the Stop button """
self.reading_input = False
if self.wav_file:
self.wav_file.close()
self.wav_file = None
if self.read_input_thread:
self.read_input_thread.join()
self.read_input_thread = Non... | called when user clicks the Stop button | called when user clicks the Stop button | [
"called",
"when",
"user",
"clicks",
"the",
"Stop",
"button"
] | def on_stop(self):
self.reading_input = False
if self.wav_file:
self.wav_file.close()
self.wav_file = None
if self.read_input_thread:
self.read_input_thread.join()
self.read_input_thread = None
self.stop() | [
"def",
"on_stop",
"(",
"self",
")",
":",
"self",
".",
"reading_input",
"=",
"False",
"if",
"self",
".",
"wav_file",
":",
"self",
".",
"wav_file",
".",
"close",
"(",
")",
"self",
".",
"wav_file",
"=",
"None",
"if",
"self",
".",
"read_input_thread",
":",... | called when user clicks the Stop button | [
"called",
"when",
"user",
"clicks",
"the",
"Stop",
"button"
] | [
"\"\"\" called when user clicks the Stop button \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | init_ui | null | def init_ui(self):
""" setup the GUI for the app """
self.master.title("Test")
self.pack(fill=BOTH, expand=True)
# Input section
input_frame = LabelFrame(self, text="Input")
input_frame.bind("-", self.on_minus_key)
input_frame.bind("+", self.on_plus_key)
... | setup the GUI for the app | setup the GUI for the app | [
"setup",
"the",
"GUI",
"for",
"the",
"app"
] | def init_ui(self):
self.master.title("Test")
self.pack(fill=BOTH, expand=True)
input_frame = LabelFrame(self, text="Input")
input_frame.bind("-", self.on_minus_key)
input_frame.bind("+", self.on_plus_key)
input_frame.pack(fill=X)
self.play_button = Button(input_fr... | [
"def",
"init_ui",
"(",
"self",
")",
":",
"self",
".",
"master",
".",
"title",
"(",
"\"Test\"",
")",
"self",
".",
"pack",
"(",
"fill",
"=",
"BOTH",
",",
"expand",
"=",
"True",
")",
"input_frame",
"=",
"LabelFrame",
"(",
"self",
",",
"text",
"=",
"\"... | setup the GUI for the app | [
"setup",
"the",
"GUI",
"for",
"the",
"app"
] | [
"\"\"\" setup the GUI for the app \"\"\"",
"# Input section",
"# Feature section",
"# Classifier section",
"# Output section"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91d8f3375e133d09eb84c0544b6fa3989f4d91d0 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/view_audio.py | [
"MIT"
] | Python | main | null | def main(featurizer_model=None, classifier=None, sample_rate=None, channels=None, input_device=None, categories=None,
image_width=80, threshold=None, wav_file=None, clear=5, serial=None):
""" Main function to create root UI and AudioDemo object, then run the main UI loop """
root = tk.Tk()
root.geo... | Main function to create root UI and AudioDemo object, then run the main UI loop | Main function to create root UI and AudioDemo object, then run the main UI loop | [
"Main",
"function",
"to",
"create",
"root",
"UI",
"and",
"AudioDemo",
"object",
"then",
"run",
"the",
"main",
"UI",
"loop"
] | def main(featurizer_model=None, classifier=None, sample_rate=None, channels=None, input_device=None, categories=None,
image_width=80, threshold=None, wav_file=None, clear=5, serial=None):
root = tk.Tk()
root.geometry("800x800")
app = AudioDemo(featurizer_model, classifier, sample_rate, channels, in... | [
"def",
"main",
"(",
"featurizer_model",
"=",
"None",
",",
"classifier",
"=",
"None",
",",
"sample_rate",
"=",
"None",
",",
"channels",
"=",
"None",
",",
"input_device",
"=",
"None",
",",
"categories",
"=",
"None",
",",
"image_width",
"=",
"80",
",",
"thr... | Main function to create root UI and AudioDemo object, then run the main UI loop | [
"Main",
"function",
"to",
"create",
"root",
"UI",
"and",
"AudioDemo",
"object",
"then",
"run",
"the",
"main",
"UI",
"loop"
] | [
"\"\"\" Main function to create root UI and AudioDemo object, then run the main UI loop \"\"\""
] | [
{
"param": "featurizer_model",
"type": null
},
{
"param": "classifier",
"type": null
},
{
"param": "sample_rate",
"type": null
},
{
"param": "channels",
"type": null
},
{
"param": "input_device",
"type": null
},
{
"param": "categories",
"type": nul... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "featurizer_model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "classifier",
"type": null,
"docstring": null,
"do... |
1925ddfc1ae9f8651c9d70533aab88b27110d133 | harshmittal2210/ELL | tools/importers/onnx/onnx_to_ell.py | [
"MIT"
] | Python | convert_onnx_to_ell | <not_specific> | def convert_onnx_to_ell(path, step_interval_msec=None, lag_threshold_msec=None):
"""
convert the importer model into a ELL model, optionally a steppable model if step_interval_msec
and lag_threshold_msec are provided.
"""
_logger.info("Pre-processing... ")
converter = convert.OnnxConverter()
... |
convert the importer model into a ELL model, optionally a steppable model if step_interval_msec
and lag_threshold_msec are provided.
| convert the importer model into a ELL model, optionally a steppable model if step_interval_msec
and lag_threshold_msec are provided. | [
"convert",
"the",
"importer",
"model",
"into",
"a",
"ELL",
"model",
"optionally",
"a",
"steppable",
"model",
"if",
"step_interval_msec",
"and",
"lag_threshold_msec",
"are",
"provided",
"."
] | def convert_onnx_to_ell(path, step_interval_msec=None, lag_threshold_msec=None):
_logger.info("Pre-processing... ")
converter = convert.OnnxConverter()
importer_model = converter.load_model(path)
_logger.info("\n Done pre-processing.")
try:
importer_engine = common.importer.ImporterEngine(st... | [
"def",
"convert_onnx_to_ell",
"(",
"path",
",",
"step_interval_msec",
"=",
"None",
",",
"lag_threshold_msec",
"=",
"None",
")",
":",
"_logger",
".",
"info",
"(",
"\"Pre-processing... \"",
")",
"converter",
"=",
"convert",
".",
"OnnxConverter",
"(",
")",
"importe... | convert the importer model into a ELL model, optionally a steppable model if step_interval_msec
and lag_threshold_msec are provided. | [
"convert",
"the",
"importer",
"model",
"into",
"a",
"ELL",
"model",
"optionally",
"a",
"steppable",
"model",
"if",
"step_interval_msec",
"and",
"lag_threshold_msec",
"are",
"provided",
"."
] | [
"\"\"\"\n convert the importer model into a ELL model, optionally a steppable model if step_interval_msec\n and lag_threshold_msec are provided.\n \"\"\""
] | [
{
"param": "path",
"type": null
},
{
"param": "step_interval_msec",
"type": null
},
{
"param": "lag_threshold_msec",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "step_interval_msec",
"type": null,
"docstring": null,
"docstr... |
6fbc1f35a14e5ce47bb64096b828db2a9d3005ae | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/wav_reader.py | [
"MIT"
] | Python | open | null | def open(self, filename, buffer_size, speaker=None):
""" open a wav file for reading
buffersize Number of audio samples to return on each read() call
speaker Optional output speaker to send converted audio to so you can hear it.
"""
self.speaker = speaker
# open a... | open a wav file for reading
buffersize Number of audio samples to return on each read() call
speaker Optional output speaker to send converted audio to so you can hear it.
| open a wav file for reading
buffersize Number of audio samples to return on each read() call
speaker Optional output speaker to send converted audio to so you can hear it. | [
"open",
"a",
"wav",
"file",
"for",
"reading",
"buffersize",
"Number",
"of",
"audio",
"samples",
"to",
"return",
"on",
"each",
"read",
"()",
"call",
"speaker",
"Optional",
"output",
"speaker",
"to",
"send",
"converted",
"audio",
"to",
"so",
"you",
"can",
"h... | def open(self, filename, buffer_size, speaker=None):
self.speaker = speaker
self.wav_file = wave.open(filename, "rb")
self.cvstate = None
self.read_size = int(buffer_size)
self.actual_channels = self.wav_file.getnchannels()
self.actual_rate = self.wav_file.getframerate()
... | [
"def",
"open",
"(",
"self",
",",
"filename",
",",
"buffer_size",
",",
"speaker",
"=",
"None",
")",
":",
"self",
".",
"speaker",
"=",
"speaker",
"self",
".",
"wav_file",
"=",
"wave",
".",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"self",
".",
"cvst... | open a wav file for reading
buffersize Number of audio samples to return on each read() call
speaker Optional output speaker to send converted audio to so you can hear it. | [
"open",
"a",
"wav",
"file",
"for",
"reading",
"buffersize",
"Number",
"of",
"audio",
"samples",
"to",
"return",
"on",
"each",
"read",
"()",
"call",
"speaker",
"Optional",
"output",
"speaker",
"to",
"send",
"converted",
"audio",
"to",
"so",
"you",
"can",
"h... | [
"\"\"\" open a wav file for reading \n buffersize Number of audio samples to return on each read() call\n speaker Optional output speaker to send converted audio to so you can hear it.\n \"\"\"",
"# open a stream on the audio input file.",
"# assumes signed integer used in raw audio,... | [
{
"param": "self",
"type": null
},
{
"param": "filename",
"type": null
},
{
"param": "buffer_size",
"type": null
},
{
"param": "speaker",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens... |
6fbc1f35a14e5ce47bb64096b828db2a9d3005ae | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/wav_reader.py | [
"MIT"
] | Python | read | <not_specific> | def read(self):
""" Reads the next chunk of audio (returns buffer_size provided to open)
It returns the data converted to floating point numbers between -1 and 1, scaled by the range of
values possible for the given audio format.
"""
if self.wav_file is None:
return ... | Reads the next chunk of audio (returns buffer_size provided to open)
It returns the data converted to floating point numbers between -1 and 1, scaled by the range of
values possible for the given audio format.
| Reads the next chunk of audio (returns buffer_size provided to open)
It returns the data converted to floating point numbers between -1 and 1, scaled by the range of
values possible for the given audio format. | [
"Reads",
"the",
"next",
"chunk",
"of",
"audio",
"(",
"returns",
"buffer_size",
"provided",
"to",
"open",
")",
"It",
"returns",
"the",
"data",
"converted",
"to",
"floating",
"point",
"numbers",
"between",
"-",
"1",
"and",
"1",
"scaled",
"by",
"the",
"range"... | def read(self):
if self.wav_file is None:
return None
data = self.wav_file.readframes(self.buffer_size)
if len(data) == 0:
return None
if self.actual_channels != self.requested_channels:
if self.requested_channels == 1:
data = audioo... | [
"def",
"read",
"(",
"self",
")",
":",
"if",
"self",
".",
"wav_file",
"is",
"None",
":",
"return",
"None",
"data",
"=",
"self",
".",
"wav_file",
".",
"readframes",
"(",
"self",
".",
"buffer_size",
")",
"if",
"len",
"(",
"data",
")",
"==",
"0",
":",
... | Reads the next chunk of audio (returns buffer_size provided to open)
It returns the data converted to floating point numbers between -1 and 1, scaled by the range of
values possible for the given audio format. | [
"Reads",
"the",
"next",
"chunk",
"of",
"audio",
"(",
"returns",
"buffer_size",
"provided",
"to",
"open",
")",
"It",
"returns",
"the",
"data",
"converted",
"to",
"floating",
"point",
"numbers",
"between",
"-",
"1",
"and",
"1",
"scaled",
"by",
"the",
"range"... | [
"\"\"\" Reads the next chunk of audio (returns buffer_size provided to open)\n It returns the data converted to floating point numbers between -1 and 1, scaled by the range of\n values possible for the given audio format.\n \"\"\"",
"# convert the audio to the desired recording rate",
"# pa... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
40a5f18ff5616dfd5ecb1b390f5a61ba16a418ce | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/compute_ell_model.py | [
"MIT"
] | Python | transform | <not_specific> | def transform(self, x):
""" call the ell model with input array 'x' and return the output as numpy array """
# Turn the input into something the model can read
in_vec = np.array(x).astype(np.float32).ravel()
# Send the input to the predict function and return the prediction result
... | call the ell model with input array 'x' and return the output as numpy array | call the ell model with input array 'x' and return the output as numpy array | [
"call",
"the",
"ell",
"model",
"with",
"input",
"array",
"'",
"x",
"'",
"and",
"return",
"the",
"output",
"as",
"numpy",
"array"
] | def transform(self, x):
in_vec = np.array(x).astype(np.float32).ravel()
return np.array(self.map.Compute(in_vec, dtype=np.float32)) | [
"def",
"transform",
"(",
"self",
",",
"x",
")",
":",
"in_vec",
"=",
"np",
".",
"array",
"(",
"x",
")",
".",
"astype",
"(",
"np",
".",
"float32",
")",
".",
"ravel",
"(",
")",
"return",
"np",
".",
"array",
"(",
"self",
".",
"map",
".",
"Compute",... | call the ell model with input array 'x' and return the output as numpy array | [
"call",
"the",
"ell",
"model",
"with",
"input",
"array",
"'",
"x",
"'",
"and",
"return",
"the",
"output",
"as",
"numpy",
"array"
] | [
"\"\"\" call the ell model with input array 'x' and return the output as numpy array \"\"\"",
"# Turn the input into something the model can read",
"# Send the input to the predict function and return the prediction result"
] | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
c0019ef1604fec1c8dd70dd188e78fa966b2b7ee | harshmittal2210/ELL | tools/importers/onnx/lib/onnx_converters.py | [
"MIT"
] | Python | _convertAttributeProto | <not_specific> | def _convertAttributeProto(onnx_arg): # type: (AttributeProto) -> AttributeValue
"""
Convert an ONNX AttributeProto into an appropriate Python object
for the type.
NB: Tensor attribute gets returned as numpy array
"""
if onnx_arg.HasField('f'):
return onnx_ar... |
Convert an ONNX AttributeProto into an appropriate Python object
for the type.
NB: Tensor attribute gets returned as numpy array
| Convert an ONNX AttributeProto into an appropriate Python object
for the type.
NB: Tensor attribute gets returned as numpy array | [
"Convert",
"an",
"ONNX",
"AttributeProto",
"into",
"an",
"appropriate",
"Python",
"object",
"for",
"the",
"type",
".",
"NB",
":",
"Tensor",
"attribute",
"gets",
"returned",
"as",
"numpy",
"array"
] | def _convertAttributeProto(onnx_arg):
if onnx_arg.HasField('f'):
return onnx_arg.f
elif onnx_arg.HasField('i'):
return onnx_arg.i
elif onnx_arg.HasField('s'):
return onnx_arg.s
elif onnx_arg.HasField('t'):
return numpy_helper.to_array(onn... | [
"def",
"_convertAttributeProto",
"(",
"onnx_arg",
")",
":",
"if",
"onnx_arg",
".",
"HasField",
"(",
"'f'",
")",
":",
"return",
"onnx_arg",
".",
"f",
"elif",
"onnx_arg",
".",
"HasField",
"(",
"'i'",
")",
":",
"return",
"onnx_arg",
".",
"i",
"elif",
"onnx_... | Convert an ONNX AttributeProto into an appropriate Python object
for the type. | [
"Convert",
"an",
"ONNX",
"AttributeProto",
"into",
"an",
"appropriate",
"Python",
"object",
"for",
"the",
"type",
"."
] | [
"# type: (AttributeProto) -> AttributeValue",
"\"\"\"\n Convert an ONNX AttributeProto into an appropriate Python object\n for the type.\n NB: Tensor attribute gets returned as numpy array\n \"\"\""
] | [
{
"param": "onnx_arg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "onnx_arg",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c0019ef1604fec1c8dd70dd188e78fa966b2b7ee | harshmittal2210/ELL | tools/importers/onnx/lib/onnx_converters.py | [
"MIT"
] | Python | load_model | <not_specific> | def load_model(self, path):
""" Return a list of ONNX nodes """
self.model = common.importer.ImporterModel()
graph = self._load_onnx(path)
#self.nodes = utils.ONNX(self.graph).parse_onnx_model()
input_tensors = {
t.name: numpy_helper.to_array(t) for t in graph.init... | Return a list of ONNX nodes | Return a list of ONNX nodes | [
"Return",
"a",
"list",
"of",
"ONNX",
"nodes"
] | def load_model(self, path):
self.model = common.importer.ImporterModel()
graph = self._load_onnx(path)
input_tensors = {
t.name: numpy_helper.to_array(t) for t in graph.initializer
}
for id in input_tensors:
self.add_tensor(id, input_tensors[id])
f... | [
"def",
"load_model",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"model",
"=",
"common",
".",
"importer",
".",
"ImporterModel",
"(",
")",
"graph",
"=",
"self",
".",
"_load_onnx",
"(",
"path",
")",
"input_tensors",
"=",
"{",
"t",
".",
"name",
":"... | Return a list of ONNX nodes | [
"Return",
"a",
"list",
"of",
"ONNX",
"nodes"
] | [
"\"\"\" Return a list of ONNX nodes \"\"\"",
"#self.nodes = utils.ONNX(self.graph).parse_onnx_model()",
"# add input_node first",
"# we need to visit the nodes in order such that all \"inputs\" to each node are",
"# processed before this node is processed... fortunately the onnx graph.node",
"# list is a... | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [... |
9f84a29019ef3ea677fd24bb46ae8968aa551856 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/model_editor.py | [
"MIT"
] | Python | add_vad | <not_specific> | def add_vad(self, rnn, sample_rate, window_size, tau_up, tau_down, large_input, gain_att, threshold_up, threshold_down, level_threshold):
"""
Add a VoiceActivityDetectorNode as the "resetTrigger" input to the given RNN, LSTM or GRU node.
"""
frame_duration = float(window_size) / float(sa... |
Add a VoiceActivityDetectorNode as the "resetTrigger" input to the given RNN, LSTM or GRU node.
| Add a VoiceActivityDetectorNode as the "resetTrigger" input to the given RNN, LSTM or GRU node. | [
"Add",
"a",
"VoiceActivityDetectorNode",
"as",
"the",
"\"",
"resetTrigger",
"\"",
"input",
"to",
"the",
"given",
"RNN",
"LSTM",
"or",
"GRU",
"node",
"."
] | def add_vad(self, rnn, sample_rate, window_size, tau_up, tau_down, large_input, gain_att, threshold_up, threshold_down, level_threshold):
frame_duration = float(window_size) / float(sample_rate)
reset_port = rnn.GetInputPort("resetTrigger")
name = reset_port.GetParentNodes().Get().GetRuntimeType... | [
"def",
"add_vad",
"(",
"self",
",",
"rnn",
",",
"sample_rate",
",",
"window_size",
",",
"tau_up",
",",
"tau_down",
",",
"large_input",
",",
"gain_att",
",",
"threshold_up",
",",
"threshold_down",
",",
"level_threshold",
")",
":",
"frame_duration",
"=",
"float"... | Add a VoiceActivityDetectorNode as the "resetTrigger" input to the given RNN, LSTM or GRU node. | [
"Add",
"a",
"VoiceActivityDetectorNode",
"as",
"the",
"\"",
"resetTrigger",
"\"",
"input",
"to",
"the",
"given",
"RNN",
"LSTM",
"or",
"GRU",
"node",
"."
] | [
"\"\"\"\n Add a VoiceActivityDetectorNode as the \"resetTrigger\" input to the given RNN, LSTM or GRU node.\n \"\"\"",
"# replace dummy trigger with VAD node",
"# make the vad node the \"resetTrigger\" input of this rnn node"
] | [
{
"param": "self",
"type": null
},
{
"param": "rnn",
"type": null
},
{
"param": "sample_rate",
"type": null
},
{
"param": "window_size",
"type": null
},
{
"param": "tau_up",
"type": null
},
{
"param": "tau_down",
"type": null
},
{
"param": ... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rnn",
"type": null,
"docstring": null,
"docstring_tokens": []... |
9f84a29019ef3ea677fd24bb46ae8968aa551856 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/model_editor.py | [
"MIT"
] | Python | find_rnns | <not_specific> | def find_rnns(self):
""" Find any RNN, LSTM or GRU nodes in the model """
result = []
iter = self.model.GetNodes()
while iter.IsValid():
node = iter.Get()
name = node.GetRuntimeTypeName()
if "RNN" in name or "GRU" in name or "LSTM" in name:
... | Find any RNN, LSTM or GRU nodes in the model | Find any RNN, LSTM or GRU nodes in the model | [
"Find",
"any",
"RNN",
"LSTM",
"or",
"GRU",
"nodes",
"in",
"the",
"model"
] | def find_rnns(self):
result = []
iter = self.model.GetNodes()
while iter.IsValid():
node = iter.Get()
name = node.GetRuntimeTypeName()
if "RNN" in name or "GRU" in name or "LSTM" in name:
result += [ node ]
iter.Next()
retu... | [
"def",
"find_rnns",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"iter",
"=",
"self",
".",
"model",
".",
"GetNodes",
"(",
")",
"while",
"iter",
".",
"IsValid",
"(",
")",
":",
"node",
"=",
"iter",
".",
"Get",
"(",
")",
"name",
"=",
"node",
".... | Find any RNN, LSTM or GRU nodes in the model | [
"Find",
"any",
"RNN",
"LSTM",
"or",
"GRU",
"nodes",
"in",
"the",
"model"
] | [
"\"\"\" Find any RNN, LSTM or GRU nodes in the model \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9f84a29019ef3ea677fd24bb46ae8968aa551856 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/model_editor.py | [
"MIT"
] | Python | add_sink_node | <not_specific> | def add_sink_node(self, node, functionName):
"""
Add a SinkNode so you can get a callback with the output of the given node id.
"""
if self.find_sink_node(node):
print("node '{}' already has a SinkNode".format(node.GetRuntimeTypeName()))
return False
outpu... |
Add a SinkNode so you can get a callback with the output of the given node id.
| Add a SinkNode so you can get a callback with the output of the given node id. | [
"Add",
"a",
"SinkNode",
"so",
"you",
"can",
"get",
"a",
"callback",
"with",
"the",
"output",
"of",
"the",
"given",
"node",
"id",
"."
] | def add_sink_node(self, node, functionName):
if self.find_sink_node(node):
print("node '{}' already has a SinkNode".format(node.GetRuntimeTypeName()))
return False
output_port = node.GetOutputPort("output")
size = list(output_port.GetMemoryLayout().size)
while len... | [
"def",
"add_sink_node",
"(",
"self",
",",
"node",
",",
"functionName",
")",
":",
"if",
"self",
".",
"find_sink_node",
"(",
"node",
")",
":",
"print",
"(",
"\"node '{}' already has a SinkNode\"",
".",
"format",
"(",
"node",
".",
"GetRuntimeTypeName",
"(",
")",
... | Add a SinkNode so you can get a callback with the output of the given node id. | [
"Add",
"a",
"SinkNode",
"so",
"you",
"can",
"get",
"a",
"callback",
"with",
"the",
"output",
"of",
"the",
"given",
"node",
"id",
"."
] | [
"\"\"\"\n Add a SinkNode so you can get a callback with the output of the given node id.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": null
},
{
"param": "functionName",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": null,
"docstring": null,
"docstring_tokens": [... |
9f84a29019ef3ea677fd24bb46ae8968aa551856 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/model_editor.py | [
"MIT"
] | Python | attach_sink | <not_specific> | def attach_sink(self, nameExpr, functionName):
"""
Process the given ELL model and insert SinkNode to monitor output of the given node
"""
iter = self.model.GetNodes()
changed = False
found = False
while iter.IsValid():
node = iter.Get()
if... |
Process the given ELL model and insert SinkNode to monitor output of the given node
| Process the given ELL model and insert SinkNode to monitor output of the given node | [
"Process",
"the",
"given",
"ELL",
"model",
"and",
"insert",
"SinkNode",
"to",
"monitor",
"output",
"of",
"the",
"given",
"node"
] | def attach_sink(self, nameExpr, functionName):
iter = self.model.GetNodes()
changed = False
found = False
while iter.IsValid():
node = iter.Get()
if nameExpr in node.GetRuntimeTypeName():
found = True
changed |= self.add_sink_node(n... | [
"def",
"attach_sink",
"(",
"self",
",",
"nameExpr",
",",
"functionName",
")",
":",
"iter",
"=",
"self",
".",
"model",
".",
"GetNodes",
"(",
")",
"changed",
"=",
"False",
"found",
"=",
"False",
"while",
"iter",
".",
"IsValid",
"(",
")",
":",
"node",
"... | Process the given ELL model and insert SinkNode to monitor output of the given node | [
"Process",
"the",
"given",
"ELL",
"model",
"and",
"insert",
"SinkNode",
"to",
"monitor",
"output",
"of",
"the",
"given",
"node"
] | [
"\"\"\"\n Process the given ELL model and insert SinkNode to monitor output of the given node\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "nameExpr",
"type": null
},
{
"param": "functionName",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nameExpr",
"type": null,
"docstring": null,
"docstring_tokens... |
3d995ea985ac6a7255c68a54ae0a96cbff1ce128 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/make_training_list.py | [
"MIT"
] | Python | make_training_list | <not_specific> | def make_training_list(wav_files, max_files_per_directory):
"""
Create a training list file given the directory where the wav files are organized into subdirectories,
with one subdirectory per keyword to be recognized. This training list will exclude any files
already referenced by the 'testing_list.tx... |
Create a training list file given the directory where the wav files are organized into subdirectories,
with one subdirectory per keyword to be recognized. This training list will exclude any files
already referenced by the 'testing_list.txt' or 'validation_list.txt'
| Create a training list file given the directory where the wav files are organized into subdirectories,
with one subdirectory per keyword to be recognized. This training list will exclude any files
already referenced by the 'testing_list.txt' or 'validation_list.txt' | [
"Create",
"a",
"training",
"list",
"file",
"given",
"the",
"directory",
"where",
"the",
"wav",
"files",
"are",
"organized",
"into",
"subdirectories",
"with",
"one",
"subdirectory",
"per",
"keyword",
"to",
"be",
"recognized",
".",
"This",
"training",
"list",
"w... | def make_training_list(wav_files, max_files_per_directory):
if not os.path.isdir(wav_files):
print("wav_file directory not found")
return
ignore_list = load_list_file(os.path.join(wav_files, "testing_list.txt"))
ignore_list += load_list_file(os.path.join(wav_files, "validation_list.txt")) ... | [
"def",
"make_training_list",
"(",
"wav_files",
",",
"max_files_per_directory",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"wav_files",
")",
":",
"print",
"(",
"\"wav_file directory not found\"",
")",
"return",
"ignore_list",
"=",
"load_list_file"... | Create a training list file given the directory where the wav files are organized into subdirectories,
with one subdirectory per keyword to be recognized. | [
"Create",
"a",
"training",
"list",
"file",
"given",
"the",
"directory",
"where",
"the",
"wav",
"files",
"are",
"organized",
"into",
"subdirectories",
"with",
"one",
"subdirectory",
"per",
"keyword",
"to",
"be",
"recognized",
"."
] | [
"\"\"\"\n Create a training list file given the directory where the wav files are organized into subdirectories,\n with one subdirectory per keyword to be recognized. This training list will exclude any files\n already referenced by the 'testing_list.txt' or 'validation_list.txt'\n \"\"\"",
"# write ... | [
{
"param": "wav_files",
"type": null
},
{
"param": "max_files_per_directory",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "wav_files",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_files_per_directory",
"type": null,
"docstring": null,
... |
622e2831894e033d88225d47a8ff71214f42a57e | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/make_dataset.py | [
"MIT"
] | Python | parse_list_file | <not_specific> | def parse_list_file(list_file):
"""
Load the list file which contains 'dir/filename' format on each line
We sort these into one set per directory, the directory name then becomes the supervised
training label we want the model to learn.
"""
data_root = os.path.dirname(list_file)
with open(l... |
Load the list file which contains 'dir/filename' format on each line
We sort these into one set per directory, the directory name then becomes the supervised
training label we want the model to learn.
| Load the list file which contains 'dir/filename' format on each line
We sort these into one set per directory, the directory name then becomes the supervised
training label we want the model to learn. | [
"Load",
"the",
"list",
"file",
"which",
"contains",
"'",
"dir",
"/",
"filename",
"'",
"format",
"on",
"each",
"line",
"We",
"sort",
"these",
"into",
"one",
"set",
"per",
"directory",
"the",
"directory",
"name",
"then",
"becomes",
"the",
"supervised",
"trai... | def parse_list_file(list_file):
data_root = os.path.dirname(list_file)
with open(list_file, "r") as fp:
full_list = [e.strip() for e in fp.readlines()]
entries_to_visit = {}
for e in full_list:
label, file_name = os.path.split(e)
folder = os.path.abspath(os.path.join(data_root, l... | [
"def",
"parse_list_file",
"(",
"list_file",
")",
":",
"data_root",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"list_file",
")",
"with",
"open",
"(",
"list_file",
",",
"\"r\"",
")",
"as",
"fp",
":",
"full_list",
"=",
"[",
"e",
".",
"strip",
"(",
")"... | Load the list file which contains 'dir/filename' format on each line
We sort these into one set per directory, the directory name then becomes the supervised
training label we want the model to learn. | [
"Load",
"the",
"list",
"file",
"which",
"contains",
"'",
"dir",
"/",
"filename",
"'",
"format",
"on",
"each",
"line",
"We",
"sort",
"these",
"into",
"one",
"set",
"per",
"directory",
"the",
"directory",
"name",
"then",
"becomes",
"the",
"supervised",
"trai... | [
"\"\"\" \n Load the list file which contains 'dir/filename' format on each line\n We sort these into one set per directory, the directory name then becomes the supervised\n training label we want the model to learn.\n \"\"\"",
"# group the list by folders"
] | [
{
"param": "list_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
622e2831894e033d88225d47a8ff71214f42a57e | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/make_dataset.py | [
"MIT"
] | Python | sliding_window_frame | null | def sliding_window_frame(source, window_size, shift_amount):
""" General windowing and merging generator that concatenates & shifts samples through a sliding window frame """
# Source is a container or generator that returns numpy vectors
# We buffer them and return arrays of length window_size, shifted by ... | General windowing and merging generator that concatenates & shifts samples through a sliding window frame | General windowing and merging generator that concatenates & shifts samples through a sliding window frame | [
"General",
"windowing",
"and",
"merging",
"generator",
"that",
"concatenates",
"&",
"shifts",
"samples",
"through",
"a",
"sliding",
"window",
"frame"
] | def sliding_window_frame(source, window_size, shift_amount):
buffer = None
for new_samples in source:
if np.isscalar(new_samples):
new_samples = (new_samples,)
if buffer is None:
buffer = new_samples
else:
buffer = np.concatenate((buffer, new_samples))... | [
"def",
"sliding_window_frame",
"(",
"source",
",",
"window_size",
",",
"shift_amount",
")",
":",
"buffer",
"=",
"None",
"for",
"new_samples",
"in",
"source",
":",
"if",
"np",
".",
"isscalar",
"(",
"new_samples",
")",
":",
"new_samples",
"=",
"(",
"new_sample... | General windowing and merging generator that concatenates & shifts samples through a sliding window frame | [
"General",
"windowing",
"and",
"merging",
"generator",
"that",
"concatenates",
"&",
"shifts",
"samples",
"through",
"a",
"sliding",
"window",
"frame"
] | [
"\"\"\" General windowing and merging generator that concatenates & shifts samples through a sliding window frame \"\"\"",
"# Source is a container or generator that returns numpy vectors",
"# We buffer them and return arrays of length window_size, shifted by shift_amount ",
"# if new_samples is a scalar, tur... | [
{
"param": "source",
"type": null
},
{
"param": "window_size",
"type": null
},
{
"param": "shift_amount",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "window_size",
"type": null,
"docstring": null,
"docstring_t... |
622e2831894e033d88225d47a8ff71214f42a57e | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/training/make_dataset.py | [
"MIT"
] | Python | make_dataset | null | def make_dataset(list_file, featurizer_path, sample_rate, window_size, shift):
"""
Create a dataset given the input list file, a featurizer, the desired .wav sample rate,
classifier window_size and window shift amount. The dataset is saved to the same file name
with .npz extension.
"""
transfo... |
Create a dataset given the input list file, a featurizer, the desired .wav sample rate,
classifier window_size and window shift amount. The dataset is saved to the same file name
with .npz extension.
| Create a dataset given the input list file, a featurizer, the desired .wav sample rate,
classifier window_size and window shift amount. The dataset is saved to the same file name
with .npz extension. | [
"Create",
"a",
"dataset",
"given",
"the",
"input",
"list",
"file",
"a",
"featurizer",
"the",
"desired",
".",
"wav",
"sample",
"rate",
"classifier",
"window_size",
"and",
"window",
"shift",
"amount",
".",
"The",
"dataset",
"is",
"saved",
"to",
"the",
"same",
... | def make_dataset(list_file, featurizer_path, sample_rate, window_size, shift):
transform = featurizer.AudioTransform(featurizer_path, 0)
input_size = transform.input_size
output_shape = transform.model.output_shape
output_size = output_shape.Size()
feature_size = output_shape.Size()
feature_shap... | [
"def",
"make_dataset",
"(",
"list_file",
",",
"featurizer_path",
",",
"sample_rate",
",",
"window_size",
",",
"shift",
")",
":",
"transform",
"=",
"featurizer",
".",
"AudioTransform",
"(",
"featurizer_path",
",",
"0",
")",
"input_size",
"=",
"transform",
".",
... | Create a dataset given the input list file, a featurizer, the desired .wav sample rate,
classifier window_size and window shift amount. | [
"Create",
"a",
"dataset",
"given",
"the",
"input",
"list",
"file",
"a",
"featurizer",
"the",
"desired",
".",
"wav",
"sample",
"rate",
"classifier",
"window_size",
"and",
"window",
"shift",
"amount",
"."
] | [
"\"\"\"\n Create a dataset given the input list file, a featurizer, the desired .wav sample rate,\n classifier window_size and window shift amount. The dataset is saved to the same file name\n with .npz extension.\n \"\"\""
] | [
{
"param": "list_file",
"type": null
},
{
"param": "featurizer_path",
"type": null
},
{
"param": "sample_rate",
"type": null
},
{
"param": "window_size",
"type": null
},
{
"param": "shift",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "featurizer_path",
"type": null,
"docstring": null,
"docs... |
e39de049055b0d13fabb13d0a1900859daf95ed9 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/microphone.py | [
"MIT"
] | Python | open | null | def open(self, sample_size, sample_rate, num_channels, input_device=None):
""" Open the microphone so it returns chunks of audio samples of the given sample_size
where audio is converted to the expected sample_rate and num_channels
and then scaled to floating point numbers between -1 and 1.
... | Open the microphone so it returns chunks of audio samples of the given sample_size
where audio is converted to the expected sample_rate and num_channels
and then scaled to floating point numbers between -1 and 1.
sample_size - number of samples to return from read method
audio_... | Open the microphone so it returns chunks of audio samples of the given sample_size
where audio is converted to the expected sample_rate and num_channels
and then scaled to floating point numbers between -1 and 1.
number of samples to return from read method
audio_scale_factor - audio is converted to floating point usi... | [
"Open",
"the",
"microphone",
"so",
"it",
"returns",
"chunks",
"of",
"audio",
"samples",
"of",
"the",
"given",
"sample_size",
"where",
"audio",
"is",
"converted",
"to",
"the",
"expected",
"sample_rate",
"and",
"num_channels",
"and",
"then",
"scaled",
"to",
"flo... | def open(self, sample_size, sample_rate, num_channels, input_device=None):
self.sample_rate = sample_rate
self.sample_size = sample_size
self.num_channels = num_channels
self.audio_format = pyaudio.paInt16
self.cvstate = None
if input_device:
info = self.audio... | [
"def",
"open",
"(",
"self",
",",
"sample_size",
",",
"sample_rate",
",",
"num_channels",
",",
"input_device",
"=",
"None",
")",
":",
"self",
".",
"sample_rate",
"=",
"sample_rate",
"self",
".",
"sample_size",
"=",
"sample_size",
"self",
".",
"num_channels",
... | Open the microphone so it returns chunks of audio samples of the given sample_size
where audio is converted to the expected sample_rate and num_channels
and then scaled to floating point numbers between -1 and 1. | [
"Open",
"the",
"microphone",
"so",
"it",
"returns",
"chunks",
"of",
"audio",
"samples",
"of",
"the",
"given",
"sample_size",
"where",
"audio",
"is",
"converted",
"to",
"the",
"expected",
"sample_rate",
"and",
"num_channels",
"and",
"then",
"scaled",
"to",
"flo... | [
"\"\"\" Open the microphone so it returns chunks of audio samples of the given sample_size\n where audio is converted to the expected sample_rate and num_channels\n and then scaled to floating point numbers between -1 and 1.\n \n sample_size - number of samples to return from read method... | [
{
"param": "self",
"type": null
},
{
"param": "sample_size",
"type": null
},
{
"param": "sample_rate",
"type": null
},
{
"param": "num_channels",
"type": null
},
{
"param": "input_device",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sample_size",
"type": null,
"docstring": null,
"docstring_tok... |
e39de049055b0d13fabb13d0a1900859daf95ed9 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/microphone.py | [
"MIT"
] | Python | read | <not_specific> | def read(self):
""" Read the next audio chunk. This method blocks until the audio is available """
while not self.closed:
# block until microphone data is ready...
result = None
self.cv.acquire()
try:
wh... | Read the next audio chunk. This method blocks until the audio is available | Read the next audio chunk. This method blocks until the audio is available | [
"Read",
"the",
"next",
"audio",
"chunk",
".",
"This",
"method",
"blocks",
"until",
"the",
"audio",
"is",
"available"
] | def read(self):
while not self.closed:
result = None
self.cv.acquire()
try:
while len(self.read_buffer) == 0:
if self.closed:
return None
self.cv.wait(0.1) ... | [
"def",
"read",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"closed",
":",
"result",
"=",
"None",
"self",
".",
"cv",
".",
"acquire",
"(",
")",
"try",
":",
"while",
"len",
"(",
"self",
".",
"read_buffer",
")",
"==",
"0",
":",
"if",
"self",
... | Read the next audio chunk. | [
"Read",
"the",
"next",
"audio",
"chunk",
"."
] | [
"\"\"\" Read the next audio chunk. This method blocks until the audio is available \"\"\"",
"# block until microphone data is ready... ",
"# convert int16 data to scaled floats",
"# pad the last record with zeros so it is valid input also.",
"# just truncate it, might be off by 1 due to rounding err... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e39de049055b0d13fabb13d0a1900859daf95ed9 | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/microphone.py | [
"MIT"
] | Python | monitor_input | null | def monitor_input(self, stream):
""" monitor stdin since our read call is blocking, this way user can type 'x' to quit """
try:
while not self.closed:
out = stream.readline()
if out:
msg = out.rstrip('\n')
if msg == "exi... | monitor stdin since our read call is blocking, this way user can type 'x' to quit | monitor stdin since our read call is blocking, this way user can type 'x' to quit | [
"monitor",
"stdin",
"since",
"our",
"read",
"call",
"is",
"blocking",
"this",
"way",
"user",
"can",
"type",
"'",
"x",
"'",
"to",
"quit"
] | def monitor_input(self, stream):
try:
while not self.closed:
out = stream.readline()
if out:
msg = out.rstrip('\n')
if msg == "exit" or msg == "quit" or msg == "x":
print("closing ... | [
"def",
"monitor_input",
"(",
"self",
",",
"stream",
")",
":",
"try",
":",
"while",
"not",
"self",
".",
"closed",
":",
"out",
"=",
"stream",
".",
"readline",
"(",
")",
"if",
"out",
":",
"msg",
"=",
"out",
".",
"rstrip",
"(",
"'\\n'",
")",
"if",
"m... | monitor stdin since our read call is blocking, this way user can type 'x' to quit | [
"monitor",
"stdin",
"since",
"our",
"read",
"call",
"is",
"blocking",
"this",
"way",
"user",
"can",
"type",
"'",
"x",
"'",
"to",
"quit"
] | [
"\"\"\" monitor stdin since our read call is blocking, this way user can type 'x' to quit \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "stream",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stream",
"type": null,
"docstring": null,
"docstring_tokens":... |
e0800918e7aa775c5c84581731065e51218cb73e | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/featurizer.py | [
"MIT"
] | Python | open | null | def open(self, audio_source):
""" Open the featurizer using given audio source """
self.audio_source = audio_source
self.frame_count = 0
self.total_time = 0
self.reset() | Open the featurizer using given audio source | Open the featurizer using given audio source | [
"Open",
"the",
"featurizer",
"using",
"given",
"audio",
"source"
] | def open(self, audio_source):
self.audio_source = audio_source
self.frame_count = 0
self.total_time = 0
self.reset() | [
"def",
"open",
"(",
"self",
",",
"audio_source",
")",
":",
"self",
".",
"audio_source",
"=",
"audio_source",
"self",
".",
"frame_count",
"=",
"0",
"self",
".",
"total_time",
"=",
"0",
"self",
".",
"reset",
"(",
")"
] | Open the featurizer using given audio source | [
"Open",
"the",
"featurizer",
"using",
"given",
"audio",
"source"
] | [
"\"\"\" Open the featurizer using given audio source \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "audio_source",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "audio_source",
"type": null,
"docstring": null,
"docstring_to... |
e0800918e7aa775c5c84581731065e51218cb73e | harshmittal2210/ELL | tools/utilities/pythonlibs/audio/featurizer.py | [
"MIT"
] | Python | read | <not_specific> | def read(self):
""" Read the next output from the featurizer """
data = self.audio_source.read()
if data is None:
self.eof = True
if self.output_window_size != 0 and self.frame_count % self.output_window_size != 0:
# keep returning zeros until we fill the ... | Read the next output from the featurizer | Read the next output from the featurizer | [
"Read",
"the",
"next",
"output",
"from",
"the",
"featurizer"
] | def read(self):
data = self.audio_source.read()
if data is None:
self.eof = True
if self.output_window_size != 0 and self.frame_count % self.output_window_size != 0:
self.frame_count += 1
return np.zeros((self.output_size))
return None
... | [
"def",
"read",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"audio_source",
".",
"read",
"(",
")",
"if",
"data",
"is",
"None",
":",
"self",
".",
"eof",
"=",
"True",
"if",
"self",
".",
"output_window_size",
"!=",
"0",
"and",
"self",
".",
"frame_... | Read the next output from the featurizer | [
"Read",
"the",
"next",
"output",
"from",
"the",
"featurizer"
] | [
"\"\"\" Read the next output from the featurizer \"\"\"",
"# keep returning zeros until we fill the window size"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5370b47c2d92cb2c967c9a703506c5bd9bc84ea3 | mahlettaye/Lidar_3DEM | scripts/input_dataframe.py | [
"MIT"
] | Python | generate_point_dataframe | <not_specific> | def generate_point_dataframe(self):
"""
Computes the Elevations in a raster tif file
Parameters
---------
tif_file: str : filename/location of a tif image
CRS: str : crs value for the given tif image
Returns
-------
DataFrame... |
Computes the Elevations in a raster tif file
Parameters
---------
tif_file: str : filename/location of a tif image
CRS: str : crs value for the given tif image
Returns
-------
DataFrame
| Computes the Elevations in a raster tif file
Parameters
str : filename/location of a tif image
CRS: str : crs value for the given tif image
Returns
| [
"Computes",
"the",
"Elevations",
"in",
"a",
"raster",
"tif",
"file",
"Parameters",
"str",
":",
"filename",
"/",
"location",
"of",
"a",
"tif",
"image",
"CRS",
":",
"str",
":",
"crs",
"value",
"for",
"the",
"given",
"tif",
"image",
"Returns"
] | def generate_point_dataframe(self):
grid_raster = self.file_name
try:
grid = gr.from_file(grid_raster)
except Exception as e:
user_logger.info("Error in reading fiele"+e)
single_df = grid.to_pandas()
columns =['row','col' ]
single_df = pd.DataFrame... | [
"def",
"generate_point_dataframe",
"(",
"self",
")",
":",
"grid_raster",
"=",
"self",
".",
"file_name",
"try",
":",
"grid",
"=",
"gr",
".",
"from_file",
"(",
"grid_raster",
")",
"except",
"Exception",
"as",
"e",
":",
"user_logger",
".",
"info",
"(",
"\"Err... | Computes the Elevations in a raster tif file
Parameters | [
"Computes",
"the",
"Elevations",
"in",
"a",
"raster",
"tif",
"file",
"Parameters"
] | [
"\"\"\"\n Computes the Elevations in a raster tif file\n \n Parameters\n ---------\n \n tif_file: str : filename/location of a tif image\n CRS: str : crs value for the given tif image\n \n Returns\n -------\n DataFrame\n \"\"\"",
"#Co... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4e2dc015bde3abd6ad08bea1209a73d6fc0df68a | kiminh/uncertainty-baselines | baselines/cifar/utils.py | [
"Apache-2.0"
] | Python | load_input_fn | <not_specific> | def load_input_fn(split,
batch_size,
name,
use_bfloat16,
normalize=True,
drop_remainder=True,
repeat=False,
proportion=1.0,
data_dir=None):
"""Loads CIFAR dataset for trainin... | Loads CIFAR dataset for training or testing.
Args:
split: tfds.Split.
batch_size: The global batch size to use.
name: A string indicates whether it is cifar10 or cifar100.
use_bfloat16: data type, bfloat16 precision or float32.
normalize: Whether to apply mean-std normalization on features.
d... | Loads CIFAR dataset for training or testing. | [
"Loads",
"CIFAR",
"dataset",
"for",
"training",
"or",
"testing",
"."
] | def load_input_fn(split,
batch_size,
name,
use_bfloat16,
normalize=True,
drop_remainder=True,
repeat=False,
proportion=1.0,
data_dir=None):
if use_bfloat16:
dtype = tf.bf... | [
"def",
"load_input_fn",
"(",
"split",
",",
"batch_size",
",",
"name",
",",
"use_bfloat16",
",",
"normalize",
"=",
"True",
",",
"drop_remainder",
"=",
"True",
",",
"repeat",
"=",
"False",
",",
"proportion",
"=",
"1.0",
",",
"data_dir",
"=",
"None",
")",
"... | Loads CIFAR dataset for training or testing. | [
"Loads",
"CIFAR",
"dataset",
"for",
"training",
"or",
"testing",
"."
] | [
"\"\"\"Loads CIFAR dataset for training or testing.\n\n Args:\n split: tfds.Split.\n batch_size: The global batch size to use.\n name: A string indicates whether it is cifar10 or cifar100.\n use_bfloat16: data type, bfloat16 precision or float32.\n normalize: Whether to apply mean-std normalization ... | [
{
"param": "split",
"type": null
},
{
"param": "batch_size",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "use_bfloat16",
"type": null
},
{
"param": "normalize",
"type": null
},
{
"param": "drop_remainder",
"type": null
},
{
... | {
"returns": [
{
"docstring": "Input function which returns a locally-sharded dataset batch.",
"docstring_tokens": [
"Input",
"function",
"which",
"returns",
"a",
"locally",
"-",
"sharded",
"dataset",
"batch",
"."
... |
4e2dc015bde3abd6ad08bea1209a73d6fc0df68a | kiminh/uncertainty-baselines | baselines/cifar/utils.py | [
"Apache-2.0"
] | Python | input_fn | <not_specific> | def input_fn(ctx=None):
"""Returns a locally sharded (i.e., per-core) dataset batch."""
if proportion == 1.0:
dataset = tfds.load(
name, split=split, data_dir=data_dir, as_supervised=True)
else:
new_name = '{}:3.*.*'.format(name)
if split == tfds.Split.TRAIN:
# use round ... | Returns a locally sharded (i.e., per-core) dataset batch. | Returns a locally sharded dataset batch. | [
"Returns",
"a",
"locally",
"sharded",
"dataset",
"batch",
"."
] | def input_fn(ctx=None):
if proportion == 1.0:
dataset = tfds.load(
name, split=split, data_dir=data_dir, as_supervised=True)
else:
new_name = '{}:3.*.*'.format(name)
if split == tfds.Split.TRAIN:
new_split = 'train[:{}%]'.format(round(100 * proportion))
elif split == tf... | [
"def",
"input_fn",
"(",
"ctx",
"=",
"None",
")",
":",
"if",
"proportion",
"==",
"1.0",
":",
"dataset",
"=",
"tfds",
".",
"load",
"(",
"name",
",",
"split",
"=",
"split",
",",
"data_dir",
"=",
"data_dir",
",",
"as_supervised",
"=",
"True",
")",
"else"... | Returns a locally sharded (i.e., per-core) dataset batch. | [
"Returns",
"a",
"locally",
"sharded",
"(",
"i",
".",
"e",
".",
"per",
"-",
"core",
")",
"dataset",
"batch",
"."
] | [
"\"\"\"Returns a locally sharded (i.e., per-core) dataset batch.\"\"\"",
"# use round instead of floor to resolve bug when e.g. using",
"# proportion = 1 - 0.8 = 0.19999999"
] | [
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f14289d6b956b314dfc07e74ac8b980fc3466085 | baidu/Quanlse | Quanlse/ErrorMitigation/ZNE/Extrapolation.py | [
"Apache-2.0"
] | Python | extrapolate | float | def extrapolate(rescalingCoes: Iterable,
expectations: Iterable,
type: str = 'richardson',
order: int = None,
a0: float = None,
sysFunc: bool = True) -> float:
r"""
Return the zero-noise extrapolation result (when the rescaling coef... | r"""
Return the zero-noise extrapolation result (when the rescaling coefficient is zero) using different
extrapolation strategies.
:math:`\left\{\lambda_j, E_j \right\}_{1}^m \rightarrow\lim_{\lambda \to 0} E(\lambda)`
:param rescalingCoes: Iterable, shape (m,).
a series of rescaling coeffici... | r"""
Return the zero-noise extrapolation result (when the rescaling coefficient is zero) using different
extrapolation strategies. | [
"r",
"\"",
"\"",
"\"",
"Return",
"the",
"zero",
"-",
"noise",
"extrapolation",
"result",
"(",
"when",
"the",
"rescaling",
"coefficient",
"is",
"zero",
")",
"using",
"different",
"extrapolation",
"strategies",
"."
] | def extrapolate(rescalingCoes: Iterable,
expectations: Iterable,
type: str = 'richardson',
order: int = None,
a0: float = None,
sysFunc: bool = True) -> float:
typeOptional = ['linear', 'polynomial', 'richardson', 'poly-exponential', 'e... | [
"def",
"extrapolate",
"(",
"rescalingCoes",
":",
"Iterable",
",",
"expectations",
":",
"Iterable",
",",
"type",
":",
"str",
"=",
"'richardson'",
",",
"order",
":",
"int",
"=",
"None",
",",
"a0",
":",
"float",
"=",
"None",
",",
"sysFunc",
":",
"bool",
"... | r"""
Return the zero-noise extrapolation result (when the rescaling coefficient is zero) using different
extrapolation strategies. | [
"r",
"\"",
"\"",
"\"",
"Return",
"the",
"zero",
"-",
"noise",
"extrapolation",
"result",
"(",
"when",
"the",
"rescaling",
"coefficient",
"is",
"zero",
")",
"using",
"different",
"extrapolation",
"strategies",
"."
] | [
"r\"\"\"\n Return the zero-noise extrapolation result (when the rescaling coefficient is zero) using different\n extrapolation strategies.\n\n\n :math:`\\left\\{\\lambda_j, E_j \\right\\}_{1}^m \\rightarrow\\lim_{\\lambda \\to 0} E(\\lambda)`\n\n :param rescalingCoes: Iterable, shape (m,).\n a se... | [
{
"param": "rescalingCoes",
"type": "Iterable"
},
{
"param": "expectations",
"type": "Iterable"
},
{
"param": "type",
"type": "str"
},
{
"param": "order",
"type": "int"
},
{
"param": "a0",
"type": "float"
},
{
"param": "sysFunc",
"type": "bool"
}... | {
"returns": [
{
"docstring": "value of expectation when the rescaling coefficient is zero\nReferences\n\n[1] Giurgica-Tiron, T., et al.",
"docstring_tokens": [
"value",
"of",
"expectation",
"when",
"the",
"rescaling",
"coefficient",
"is"... |
f14289d6b956b314dfc07e74ac8b980fc3466085 | baidu/Quanlse | Quanlse/ErrorMitigation/ZNE/Extrapolation.py | [
"Apache-2.0"
] | Python | linearRegression | <not_specific> | def linearRegression(x, y):
r"""
Linear regression method. Fit the given data points to the following linear model:
:math:`y = \beta_0 + \beta_1 x`
:param x: a list of independent variables
:param y: a list of dependent variables
:return: An array of coefficients: :math:`\beta_0` (intercep... | r"""
Linear regression method. Fit the given data points to the following linear model:
:math:`y = \beta_0 + \beta_1 x`
:param x: a list of independent variables
:param y: a list of dependent variables
:return: An array of coefficients: :math:`\beta_0` (intercept) and :math:`\beta_1` (slope)
... | r"""
Linear regression method. Fit the given data points to the following linear model. | [
"r",
"\"",
"\"",
"\"",
"Linear",
"regression",
"method",
".",
"Fit",
"the",
"given",
"data",
"points",
"to",
"the",
"following",
"linear",
"model",
"."
] | def linearRegression(x, y):
x = np.array(x).ravel()
y = np.array(y).ravel()
m = len(x)
xAvg = np.mean(x)
yAvg = np.mean(y)
Sxx = np.sum(x ** 2) - m * xAvg ** 2
Sxy = np.sum(x * y) - m * xAvg * yAvg
return np.array([yAvg - xAvg * Sxy / Sxx, Sxy / Sxx]) | [
"def",
"linearRegression",
"(",
"x",
",",
"y",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
".",
"ravel",
"(",
")",
"y",
"=",
"np",
".",
"array",
"(",
"y",
")",
".",
"ravel",
"(",
")",
"m",
"=",
"len",
"(",
"x",
")",
"xAvg",
"="... | r"""
Linear regression method. | [
"r",
"\"",
"\"",
"\"",
"Linear",
"regression",
"method",
"."
] | [
"r\"\"\"\n Linear regression method. Fit the given data points to the following linear model:\n\n :math:`y = \\beta_0 + \\beta_1 x`\n\n :param x: a list of independent variables\n :param y: a list of dependent variables\n :return: An array of coefficients: :math:`\\beta_0` (intercept) and :math:`... | [
{
"param": "x",
"type": null
},
{
"param": "y",
"type": null
}
] | {
"returns": [
{
"docstring": "An array of coefficients: :math:`\\beta_0` (intercept) and :math:`\\beta_1` (slope)",
"docstring_tokens": [
"An",
"array",
"of",
"coefficients",
":",
":",
"math",
":",
"`",
"\\",
"bet... |
f14289d6b956b314dfc07e74ac8b980fc3466085 | baidu/Quanlse | Quanlse/ErrorMitigation/ZNE/Extrapolation.py | [
"Apache-2.0"
] | Python | polyRegression | <not_specific> | def polyRegression(x: list, y: list, d: int):
r"""
Polynomial regression method to the d-th order. Fit the given data points to the following linear model:
:math:`y = \sum_{i=0}^d a_i x^i`
:param x: a list of independent variables
:param y: a list of dependent variables
:param d: the polynomia... | r"""
Polynomial regression method to the d-th order. Fit the given data points to the following linear model:
:math:`y = \sum_{i=0}^d a_i x^i`
:param x: a list of independent variables
:param y: a list of dependent variables
:param d: the polynomial regression order
:return: an array of polyno... | r"""
Polynomial regression method to the d-th order. Fit the given data points to the following linear model. | [
"r",
"\"",
"\"",
"\"",
"Polynomial",
"regression",
"method",
"to",
"the",
"d",
"-",
"th",
"order",
".",
"Fit",
"the",
"given",
"data",
"points",
"to",
"the",
"following",
"linear",
"model",
"."
] | def polyRegression(x: list, y: list, d: int):
x = np.array(x).ravel()
y = np.array(y).ravel()
X = []
for k in range(d + 1):
X.append(np.expand_dims(x, axis=1))
X = np.concatenate(X, axis=1)
return np.dot(np.dot(np.linalg.pinv(np.dot(X.T, X)), X.T), y) | [
"def",
"polyRegression",
"(",
"x",
":",
"list",
",",
"y",
":",
"list",
",",
"d",
":",
"int",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
".",
"ravel",
"(",
")",
"y",
"=",
"np",
".",
"array",
"(",
"y",
")",
".",
"ravel",
"(",
")... | r"""
Polynomial regression method to the d-th order. | [
"r",
"\"",
"\"",
"\"",
"Polynomial",
"regression",
"method",
"to",
"the",
"d",
"-",
"th",
"order",
"."
] | [
"r\"\"\"\n Polynomial regression method to the d-th order. Fit the given data points to the following linear model:\n\n :math:`y = \\sum_{i=0}^d a_i x^i`\n\n :param x: a list of independent variables\n :param y: a list of dependent variables\n :param d: the polynomial regression order\n :return: a... | [
{
"param": "x",
"type": "list"
},
{
"param": "y",
"type": "list"
},
{
"param": "d",
"type": "int"
}
] | {
"returns": [
{
"docstring": "an array of polynomial regression coefficients :math:`[a_0, a_1, \\cdots, a_d]`",
"docstring_tokens": [
"an",
"array",
"of",
"polynomial",
"regression",
"coefficients",
":",
"math",
":",
"`",... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.