repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
inveniosoftware/invenio-previewer | invenio_previewer/extensions/mistune.py | render | def render(file):
"""Render HTML from Markdown file content."""
with file.open() as fp:
encoding = detect_encoding(fp, default='utf-8')
result = mistune.markdown(fp.read().decode(encoding))
return result | python | def render(file):
"""Render HTML from Markdown file content."""
with file.open() as fp:
encoding = detect_encoding(fp, default='utf-8')
result = mistune.markdown(fp.read().decode(encoding))
return result | [
"def",
"render",
"(",
"file",
")",
":",
"with",
"file",
".",
"open",
"(",
")",
"as",
"fp",
":",
"encoding",
"=",
"detect_encoding",
"(",
"fp",
",",
"default",
"=",
"'utf-8'",
")",
"result",
"=",
"mistune",
".",
"markdown",
"(",
"fp",
".",
"read",
"... | Render HTML from Markdown file content. | [
"Render",
"HTML",
"from",
"Markdown",
"file",
"content",
"."
] | train | https://github.com/inveniosoftware/invenio-previewer/blob/558fd22e0f29cc8cd7a6999abd4febcf6b248c49/invenio_previewer/extensions/mistune.py#L21-L26 |
paylogic/halogen | halogen/validators.py | Length.validate | def validate(self, value):
"""Validate the length of a list.
:param value: List of values.
:raises: :class:`halogen.exception.ValidationError` exception when length of the list is less than
minimum or greater than maximum.
"""
try:
length = len(value)
... | python | def validate(self, value):
"""Validate the length of a list.
:param value: List of values.
:raises: :class:`halogen.exception.ValidationError` exception when length of the list is less than
minimum or greater than maximum.
"""
try:
length = len(value)
... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"length",
"=",
"len",
"(",
"value",
")",
"except",
"TypeError",
":",
"length",
"=",
"0",
"if",
"self",
".",
"min_length",
"is",
"not",
"None",
":",
"min_length",
"=",
"self",
".",
... | Validate the length of a list.
:param value: List of values.
:raises: :class:`halogen.exception.ValidationError` exception when length of the list is less than
minimum or greater than maximum. | [
"Validate",
"the",
"length",
"of",
"a",
"list",
"."
] | train | https://github.com/paylogic/halogen/blob/2dec0a67c506d02d1f51915fa7163f59764a0bde/halogen/validators.py#L92-L113 |
paylogic/halogen | halogen/validators.py | Range.validate | def validate(self, value):
"""Validate value.
:param value: Value which should be validated.
:raises: :class:`halogen.exception.ValidationError` exception when either if value less than min in case when
min is not None or if value greater than max in case when max is not None.
... | python | def validate(self, value):
"""Validate value.
:param value: Value which should be validated.
:raises: :class:`halogen.exception.ValidationError` exception when either if value less than min in case when
min is not None or if value greater than max in case when max is not None.
... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"min",
"is",
"not",
"None",
":",
"min_value",
"=",
"self",
".",
"min",
"(",
")",
"if",
"callable",
"(",
"self",
".",
"min",
")",
"else",
"self",
".",
"min",
"if",
"value",... | Validate value.
:param value: Value which should be validated.
:raises: :class:`halogen.exception.ValidationError` exception when either if value less than min in case when
min is not None or if value greater than max in case when max is not None. | [
"Validate",
"value",
"."
] | train | https://github.com/paylogic/halogen/blob/2dec0a67c506d02d1f51915fa7163f59764a0bde/halogen/validators.py#L143-L159 |
dhondta/tinyscript | tinyscript/parser.py | __get_calls_from_parser | def __get_calls_from_parser(proxy_parser, real_parser):
"""
This actually executes the calls registered in the ProxyArgumentParser.
:param proxy_parser: ProxyArgumentParser instance
:param real_parser: ArgumentParser instance
"""
__parsers[proxy_parser] = real_parser
for method, safe, args... | python | def __get_calls_from_parser(proxy_parser, real_parser):
"""
This actually executes the calls registered in the ProxyArgumentParser.
:param proxy_parser: ProxyArgumentParser instance
:param real_parser: ArgumentParser instance
"""
__parsers[proxy_parser] = real_parser
for method, safe, args... | [
"def",
"__get_calls_from_parser",
"(",
"proxy_parser",
",",
"real_parser",
")",
":",
"__parsers",
"[",
"proxy_parser",
"]",
"=",
"real_parser",
"for",
"method",
",",
"safe",
",",
"args",
",",
"kwargs",
",",
"proxy_subparser",
"in",
"proxy_parser",
".",
"calls",
... | This actually executes the calls registered in the ProxyArgumentParser.
:param proxy_parser: ProxyArgumentParser instance
:param real_parser: ArgumentParser instance | [
"This",
"actually",
"executes",
"the",
"calls",
"registered",
"in",
"the",
"ProxyArgumentParser",
"."
] | train | https://github.com/dhondta/tinyscript/blob/624a0718db698899e7bc3ba6ac694baed251e81d/tinyscript/parser.py#L28-L41 |
dhondta/tinyscript | tinyscript/parser.py | __proxy_to_real_parser | def __proxy_to_real_parser(value):
"""
This recursively converts ProxyArgumentParser instances to actual parsers.
Use case: defining subparsers with a parent
>>> [...]
>>> parser.add_argument(...) # argument common to all subparsers
>>> subparsers = parser.add_subparsers()
>>> subp... | python | def __proxy_to_real_parser(value):
"""
This recursively converts ProxyArgumentParser instances to actual parsers.
Use case: defining subparsers with a parent
>>> [...]
>>> parser.add_argument(...) # argument common to all subparsers
>>> subparsers = parser.add_subparsers()
>>> subp... | [
"def",
"__proxy_to_real_parser",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"ProxyArgumentParser",
")",
":",
"return",
"__parsers",
"[",
"value",
"]",
"elif",
"any",
"(",
"isinstance",
"(",
"value",
",",
"t",
")",
"for",
"t",
"in",
"[... | This recursively converts ProxyArgumentParser instances to actual parsers.
Use case: defining subparsers with a parent
>>> [...]
>>> parser.add_argument(...) # argument common to all subparsers
>>> subparsers = parser.add_subparsers()
>>> subparsers.add_parser(..., parents=[parent])
... | [
"This",
"recursively",
"converts",
"ProxyArgumentParser",
"instances",
"to",
"actual",
"parsers",
"."
] | train | https://github.com/dhondta/tinyscript/blob/624a0718db698899e7bc3ba6ac694baed251e81d/tinyscript/parser.py#L44-L66 |
dhondta/tinyscript | tinyscript/parser.py | initialize | def initialize(glob,
sudo=False,
multi_level_debug=False,
add_config=False,
add_demo=False,
add_interact=False,
add_step=False,
add_time=False,
add_version=False,
add_wizard=False,
... | python | def initialize(glob,
sudo=False,
multi_level_debug=False,
add_config=False,
add_demo=False,
add_interact=False,
add_step=False,
add_time=False,
add_version=False,
add_wizard=False,
... | [
"def",
"initialize",
"(",
"glob",
",",
"sudo",
"=",
"False",
",",
"multi_level_debug",
"=",
"False",
",",
"add_config",
"=",
"False",
",",
"add_demo",
"=",
"False",
",",
"add_interact",
"=",
"False",
",",
"add_step",
"=",
"False",
",",
"add_time",
"=",
"... | Initialization function ; sets up the arguments for the parser and creates a
logger to be inserted in the input dictionary of global variables from the
calling script.
:param glob: globals() instance from the calling script
:param sudo: if True, require sudo credentials and ... | [
"Initialization",
"function",
";",
"sets",
"up",
"the",
"arguments",
"for",
"the",
"parser",
"and",
"creates",
"a",
"logger",
"to",
"be",
"inserted",
"in",
"the",
"input",
"dictionary",
"of",
"global",
"variables",
"from",
"the",
"calling",
"script",
"."
] | train | https://github.com/dhondta/tinyscript/blob/624a0718db698899e7bc3ba6ac694baed251e81d/tinyscript/parser.py#L78-L302 |
dhondta/tinyscript | tinyscript/parser.py | validate | def validate(glob, *arg_checks):
"""
Function for validating group of arguments ; each argument is represented as
a 4-tuple like follows:
(argument_name, fail_condition, error_message, default)
- argument_name: the name of the argument like entered in add_argument()
- fail_conditi... | python | def validate(glob, *arg_checks):
"""
Function for validating group of arguments ; each argument is represented as
a 4-tuple like follows:
(argument_name, fail_condition, error_message, default)
- argument_name: the name of the argument like entered in add_argument()
- fail_conditi... | [
"def",
"validate",
"(",
"glob",
",",
"*",
"arg_checks",
")",
":",
"locals",
"(",
")",
".",
"update",
"(",
"glob",
")",
"# allows to import user-defined objects from glob",
"# into the local scope",
"if",
"glob",
"[",
"'args'",
"]",
"is",
"None",
"or",
"glob",
... | Function for validating group of arguments ; each argument is represented as
a 4-tuple like follows:
(argument_name, fail_condition, error_message, default)
- argument_name: the name of the argument like entered in add_argument()
- fail_condition: condition in Python code with the argumen... | [
"Function",
"for",
"validating",
"group",
"of",
"arguments",
";",
"each",
"argument",
"is",
"represented",
"as",
"a",
"4",
"-",
"tuple",
"like",
"follows",
":"
] | train | https://github.com/dhondta/tinyscript/blob/624a0718db698899e7bc3ba6ac694baed251e81d/tinyscript/parser.py#L305-L348 |
LCAV/pylocus | pylocus/basics.py | mse | def mse(x, xhat):
""" Calcualte mse between vector or matrix x and xhat """
buf_ = x - xhat
np.square(buf_, out=buf_) # square in-place
sum_ = np.sum(buf_)
sum_ /= x.size # divide in-place
return sum_ | python | def mse(x, xhat):
""" Calcualte mse between vector or matrix x and xhat """
buf_ = x - xhat
np.square(buf_, out=buf_) # square in-place
sum_ = np.sum(buf_)
sum_ /= x.size # divide in-place
return sum_ | [
"def",
"mse",
"(",
"x",
",",
"xhat",
")",
":",
"buf_",
"=",
"x",
"-",
"xhat",
"np",
".",
"square",
"(",
"buf_",
",",
"out",
"=",
"buf_",
")",
"# square in-place",
"sum_",
"=",
"np",
".",
"sum",
"(",
"buf_",
")",
"sum_",
"/=",
"x",
".",
"size",
... | Calcualte mse between vector or matrix x and xhat | [
"Calcualte",
"mse",
"between",
"vector",
"or",
"matrix",
"x",
"and",
"xhat"
] | train | https://github.com/LCAV/pylocus/blob/c56a38c251d8a435caf4641a8ae6027ecba2c8c6/pylocus/basics.py#L6-L12 |
LCAV/pylocus | pylocus/basics.py | low_rank_approximation | def low_rank_approximation(A, r):
""" Returns approximation of A of rank r in least-squares sense."""
try:
u, s, v = np.linalg.svd(A, full_matrices=False)
except np.linalg.LinAlgError as e:
print('Matrix:', A)
print('Matrix rank:', np.linalg.matrix_rank(A))
raise
Ar = np... | python | def low_rank_approximation(A, r):
""" Returns approximation of A of rank r in least-squares sense."""
try:
u, s, v = np.linalg.svd(A, full_matrices=False)
except np.linalg.LinAlgError as e:
print('Matrix:', A)
print('Matrix rank:', np.linalg.matrix_rank(A))
raise
Ar = np... | [
"def",
"low_rank_approximation",
"(",
"A",
",",
"r",
")",
":",
"try",
":",
"u",
",",
"s",
",",
"v",
"=",
"np",
".",
"linalg",
".",
"svd",
"(",
"A",
",",
"full_matrices",
"=",
"False",
")",
"except",
"np",
".",
"linalg",
".",
"LinAlgError",
"as",
... | Returns approximation of A of rank r in least-squares sense. | [
"Returns",
"approximation",
"of",
"A",
"of",
"rank",
"r",
"in",
"least",
"-",
"squares",
"sense",
"."
] | train | https://github.com/LCAV/pylocus/blob/c56a38c251d8a435caf4641a8ae6027ecba2c8c6/pylocus/basics.py#L28-L44 |
LCAV/pylocus | pylocus/basics.py | eigendecomp | def eigendecomp(G, d):
"""
Computes sorted eigendecomposition of G.
:param G: Matrix
:param d: rank
:return factor: vector of square root d of eigenvalues (biggest to smallest).
:return u: matrix with colums equal to the normalized eigenvectors corresponding to sorted eigenvalues.
"""
... | python | def eigendecomp(G, d):
"""
Computes sorted eigendecomposition of G.
:param G: Matrix
:param d: rank
:return factor: vector of square root d of eigenvalues (biggest to smallest).
:return u: matrix with colums equal to the normalized eigenvectors corresponding to sorted eigenvalues.
"""
... | [
"def",
"eigendecomp",
"(",
"G",
",",
"d",
")",
":",
"N",
"=",
"G",
".",
"shape",
"[",
"0",
"]",
"lamda",
",",
"u",
"=",
"np",
".",
"linalg",
".",
"eig",
"(",
"G",
")",
"# test decomposition of G.",
"#G_hat = np.dot(np.dot(u, np.diag(lamda)), u.T)",
"#asser... | Computes sorted eigendecomposition of G.
:param G: Matrix
:param d: rank
:return factor: vector of square root d of eigenvalues (biggest to smallest).
:return u: matrix with colums equal to the normalized eigenvectors corresponding to sorted eigenvalues. | [
"Computes",
"sorted",
"eigendecomposition",
"of",
"G",
"."
] | train | https://github.com/LCAV/pylocus/blob/c56a38c251d8a435caf4641a8ae6027ecba2c8c6/pylocus/basics.py#L62-L89 |
LCAV/pylocus | pylocus/basics.py | projection | def projection(x, A, b):
""" Returns the vector xhat closest to x in 2-norm, satisfying A.xhat =b.
:param x: vector
:param A, b: matrix and array characterizing the constraints on x (A.x = b)
:return x_hat: optimum angle vector, minimizing cost.
:return cost: least square error of xhat, x
:re... | python | def projection(x, A, b):
""" Returns the vector xhat closest to x in 2-norm, satisfying A.xhat =b.
:param x: vector
:param A, b: matrix and array characterizing the constraints on x (A.x = b)
:return x_hat: optimum angle vector, minimizing cost.
:return cost: least square error of xhat, x
:re... | [
"def",
"projection",
"(",
"x",
",",
"A",
",",
"b",
")",
":",
"A_pseudoinv",
"=",
"pseudo_inverse",
"(",
"A",
")",
"tmp_",
"=",
"A",
".",
"dot",
"(",
"x",
")",
"tmp_",
"-=",
"b",
"x_hat",
"=",
"A_pseudoinv",
".",
"dot",
"(",
"tmp_",
")",
"np",
"... | Returns the vector xhat closest to x in 2-norm, satisfying A.xhat =b.
:param x: vector
:param A, b: matrix and array characterizing the constraints on x (A.x = b)
:return x_hat: optimum angle vector, minimizing cost.
:return cost: least square error of xhat, x
:return constraints_error: mse of co... | [
"Returns",
"the",
"vector",
"xhat",
"closest",
"to",
"x",
"in",
"2",
"-",
"norm",
"satisfying",
"A",
".",
"xhat",
"=",
"b",
"."
] | train | https://github.com/LCAV/pylocus/blob/c56a38c251d8a435caf4641a8ae6027ecba2c8c6/pylocus/basics.py#L143-L163 |
agoragames/chai | chai/comparators.py | build_comparators | def build_comparators(*values_or_types):
'''
All of the comparators that can be used for arguments.
'''
comparators = []
for item in values_or_types:
if isinstance(item, Comparator):
comparators.append(item)
elif isinstance(item, type):
# If you are passing ar... | python | def build_comparators(*values_or_types):
'''
All of the comparators that can be used for arguments.
'''
comparators = []
for item in values_or_types:
if isinstance(item, Comparator):
comparators.append(item)
elif isinstance(item, type):
# If you are passing ar... | [
"def",
"build_comparators",
"(",
"*",
"values_or_types",
")",
":",
"comparators",
"=",
"[",
"]",
"for",
"item",
"in",
"values_or_types",
":",
"if",
"isinstance",
"(",
"item",
",",
"Comparator",
")",
":",
"comparators",
".",
"append",
"(",
"item",
")",
"eli... | All of the comparators that can be used for arguments. | [
"All",
"of",
"the",
"comparators",
"that",
"can",
"be",
"used",
"for",
"arguments",
"."
] | train | https://github.com/agoragames/chai/blob/8148d7b7754226b0d1cabfc2af10cd912612abdc/chai/comparators.py#L9-L23 |
toumorokoshi/transmute-core | ubuild.py | changelog | def changelog(build):
""" create a changelog """
build.packages.install("gitchangelog")
changelog_text = subprocess.check_output(["gitchangelog", "HEAD...v0.2.9"])
with open(os.path.join(build.root, "CHANGELOG"), "wb+") as fh:
fh.write(changelog_text) | python | def changelog(build):
""" create a changelog """
build.packages.install("gitchangelog")
changelog_text = subprocess.check_output(["gitchangelog", "HEAD...v0.2.9"])
with open(os.path.join(build.root, "CHANGELOG"), "wb+") as fh:
fh.write(changelog_text) | [
"def",
"changelog",
"(",
"build",
")",
":",
"build",
".",
"packages",
".",
"install",
"(",
"\"gitchangelog\"",
")",
"changelog_text",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"gitchangelog\"",
",",
"\"HEAD...v0.2.9\"",
"]",
")",
"with",
"open",
"(",... | create a changelog | [
"create",
"a",
"changelog"
] | train | https://github.com/toumorokoshi/transmute-core/blob/a2c26625d5d8bab37e00038f9d615a26167fc7f4/ubuild.py#L50-L55 |
agoragames/chai | chai/expectation.py | Expectation.args | def args(self, *args, **kwargs):
"""
Creates a ArgumentsExpectationRule and adds it to the expectation
"""
self._any_args = False
self._arguments_rule.set_args(*args, **kwargs)
return self | python | def args(self, *args, **kwargs):
"""
Creates a ArgumentsExpectationRule and adds it to the expectation
"""
self._any_args = False
self._arguments_rule.set_args(*args, **kwargs)
return self | [
"def",
"args",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_any_args",
"=",
"False",
"self",
".",
"_arguments_rule",
".",
"set_args",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self"
] | Creates a ArgumentsExpectationRule and adds it to the expectation | [
"Creates",
"a",
"ArgumentsExpectationRule",
"and",
"adds",
"it",
"to",
"the",
"expectation"
] | train | https://github.com/agoragames/chai/blob/8148d7b7754226b0d1cabfc2af10cd912612abdc/chai/expectation.py#L139-L145 |
agoragames/chai | chai/expectation.py | Expectation.return_value | def return_value(self):
"""
Returns the value for this expectation or raises the proper exception.
"""
if self._raises:
# Handle exceptions
if inspect.isclass(self._raises):
raise self._raises()
else:
raise self._raises
... | python | def return_value(self):
"""
Returns the value for this expectation or raises the proper exception.
"""
if self._raises:
# Handle exceptions
if inspect.isclass(self._raises):
raise self._raises()
else:
raise self._raises
... | [
"def",
"return_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"_raises",
":",
"# Handle exceptions",
"if",
"inspect",
".",
"isclass",
"(",
"self",
".",
"_raises",
")",
":",
"raise",
"self",
".",
"_raises",
"(",
")",
"else",
":",
"raise",
"self",
"."... | Returns the value for this expectation or raises the proper exception. | [
"Returns",
"the",
"value",
"for",
"this",
"expectation",
"or",
"raises",
"the",
"proper",
"exception",
"."
] | train | https://github.com/agoragames/chai/blob/8148d7b7754226b0d1cabfc2af10cd912612abdc/chai/expectation.py#L226-L241 |
agoragames/chai | chai/expectation.py | Expectation.match | def match(self, *args, **kwargs):
"""
Check the if these args match this expectation.
"""
return self._any_args or \
self._arguments_rule.validate(*args, **kwargs) | python | def match(self, *args, **kwargs):
"""
Check the if these args match this expectation.
"""
return self._any_args or \
self._arguments_rule.validate(*args, **kwargs) | [
"def",
"match",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_any_args",
"or",
"self",
".",
"_arguments_rule",
".",
"validate",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Check the if these args match this expectation. | [
"Check",
"the",
"if",
"these",
"args",
"match",
"this",
"expectation",
"."
] | train | https://github.com/agoragames/chai/blob/8148d7b7754226b0d1cabfc2af10cd912612abdc/chai/expectation.py#L265-L270 |
inveniosoftware/invenio-previewer | invenio_previewer/ext.py | _InvenioPreviewerState.record_file_factory | def record_file_factory(self):
"""Load default record file factory."""
try:
get_distribution('invenio-records-files')
from invenio_records_files.utils import record_file_factory
default = record_file_factory
except DistributionNotFound:
def default... | python | def record_file_factory(self):
"""Load default record file factory."""
try:
get_distribution('invenio-records-files')
from invenio_records_files.utils import record_file_factory
default = record_file_factory
except DistributionNotFound:
def default... | [
"def",
"record_file_factory",
"(",
"self",
")",
":",
"try",
":",
"get_distribution",
"(",
"'invenio-records-files'",
")",
"from",
"invenio_records_files",
".",
"utils",
"import",
"record_file_factory",
"default",
"=",
"record_file_factory",
"except",
"DistributionNotFound... | Load default record file factory. | [
"Load",
"default",
"record",
"file",
"factory",
"."
] | train | https://github.com/inveniosoftware/invenio-previewer/blob/558fd22e0f29cc8cd7a6999abd4febcf6b248c49/invenio_previewer/ext.py#L57-L71 |
inveniosoftware/invenio-previewer | invenio_previewer/ext.py | _InvenioPreviewerState.register_previewer | def register_previewer(self, name, previewer):
"""Register a previewer in the system."""
if name in self.previewers:
assert name not in self.previewers, \
"Previewer with same name already registered"
self.previewers[name] = previewer
if hasattr(previewer, 'pr... | python | def register_previewer(self, name, previewer):
"""Register a previewer in the system."""
if name in self.previewers:
assert name not in self.previewers, \
"Previewer with same name already registered"
self.previewers[name] = previewer
if hasattr(previewer, 'pr... | [
"def",
"register_previewer",
"(",
"self",
",",
"name",
",",
"previewer",
")",
":",
"if",
"name",
"in",
"self",
".",
"previewers",
":",
"assert",
"name",
"not",
"in",
"self",
".",
"previewers",
",",
"\"Previewer with same name already registered\"",
"self",
".",
... | Register a previewer in the system. | [
"Register",
"a",
"previewer",
"in",
"the",
"system",
"."
] | train | https://github.com/inveniosoftware/invenio-previewer/blob/558fd22e0f29cc8cd7a6999abd4febcf6b248c49/invenio_previewer/ext.py#L81-L89 |
inveniosoftware/invenio-previewer | invenio_previewer/ext.py | _InvenioPreviewerState.iter_previewers | def iter_previewers(self, previewers=None):
"""Get previewers ordered by PREVIEWER_PREVIEWERS_ORDER."""
if self.entry_point_group is not None:
self.load_entry_point_group(self.entry_point_group)
self.entry_point_group = None
previewers = previewers or \
self.... | python | def iter_previewers(self, previewers=None):
"""Get previewers ordered by PREVIEWER_PREVIEWERS_ORDER."""
if self.entry_point_group is not None:
self.load_entry_point_group(self.entry_point_group)
self.entry_point_group = None
previewers = previewers or \
self.... | [
"def",
"iter_previewers",
"(",
"self",
",",
"previewers",
"=",
"None",
")",
":",
"if",
"self",
".",
"entry_point_group",
"is",
"not",
"None",
":",
"self",
".",
"load_entry_point_group",
"(",
"self",
".",
"entry_point_group",
")",
"self",
".",
"entry_point_grou... | Get previewers ordered by PREVIEWER_PREVIEWERS_ORDER. | [
"Get",
"previewers",
"ordered",
"by",
"PREVIEWER_PREVIEWERS_ORDER",
"."
] | train | https://github.com/inveniosoftware/invenio-previewer/blob/558fd22e0f29cc8cd7a6999abd4febcf6b248c49/invenio_previewer/ext.py#L96-L107 |
inveniosoftware/invenio-previewer | invenio_previewer/ext.py | InvenioPreviewer.init_app | def init_app(self, app, entry_point_group='invenio_previewer.previewers'):
"""Flask application initialization."""
self.init_config(app)
app.register_blueprint(blueprint)
state = _InvenioPreviewerState(
app,
entry_point_group=entry_point_group)
app.extensi... | python | def init_app(self, app, entry_point_group='invenio_previewer.previewers'):
"""Flask application initialization."""
self.init_config(app)
app.register_blueprint(blueprint)
state = _InvenioPreviewerState(
app,
entry_point_group=entry_point_group)
app.extensi... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"entry_point_group",
"=",
"'invenio_previewer.previewers'",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"app",
".",
"register_blueprint",
"(",
"blueprint",
")",
"state",
"=",
"_InvenioPreviewerState",
"... | Flask application initialization. | [
"Flask",
"application",
"initialization",
"."
] | train | https://github.com/inveniosoftware/invenio-previewer/blob/558fd22e0f29cc8cd7a6999abd4febcf6b248c49/invenio_previewer/ext.py#L118-L126 |
d0ugal/python-rfxcom | rfxcom/protocol/humidity.py | Humidity.parse | def parse(self, data):
"""Parse a 9 bytes packet in the Humidity format and return a
dictionary containing the data extracted. An example of a return value
would be:
.. code-block:: python
{
'id': "0x2EB2",
'packet_length': 8,
... | python | def parse(self, data):
"""Parse a 9 bytes packet in the Humidity format and return a
dictionary containing the data extracted. An example of a return value
would be:
.. code-block:: python
{
'id': "0x2EB2",
'packet_length': 8,
... | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"validate_packet",
"(",
"data",
")",
"id_",
"=",
"self",
".",
"dump_hex",
"(",
"data",
"[",
"4",
":",
"6",
"]",
")",
"# channel = data[5] TBC",
"humidity",
"=",
"data",
"[",
"6",
"]",
... | Parse a 9 bytes packet in the Humidity format and return a
dictionary containing the data extracted. An example of a return value
would be:
.. code-block:: python
{
'id': "0x2EB2",
'packet_length': 8,
'packet_type': 81,
... | [
"Parse",
"a",
"9",
"bytes",
"packet",
"in",
"the",
"Humidity",
"format",
"and",
"return",
"a",
"dictionary",
"containing",
"the",
"data",
"extracted",
".",
"An",
"example",
"of",
"a",
"return",
"value",
"would",
"be",
":"
] | train | https://github.com/d0ugal/python-rfxcom/blob/2eb87f85e5f5a04d00f32f25e0f010edfefbde0d/rfxcom/protocol/humidity.py#L41-L88 |
howl-anderson/MicroTokenizer | MicroTokenizer/tokenizer_loader.py | TokenizerLoader.create_tokenizer | def create_tokenizer(self, name, config=dict()):
"""Create a pipeline component from a factory.
name (unicode): Factory name to look up in `Language.factories`.
config (dict): Configuration parameters to initialise component.
RETURNS (callable): Pipeline component.
"""
i... | python | def create_tokenizer(self, name, config=dict()):
"""Create a pipeline component from a factory.
name (unicode): Factory name to look up in `Language.factories`.
config (dict): Configuration parameters to initialise component.
RETURNS (callable): Pipeline component.
"""
i... | [
"def",
"create_tokenizer",
"(",
"self",
",",
"name",
",",
"config",
"=",
"dict",
"(",
")",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"factories",
":",
"raise",
"KeyError",
"(",
"Errors",
".",
"E002",
".",
"format",
"(",
"name",
"=",
"name",
... | Create a pipeline component from a factory.
name (unicode): Factory name to look up in `Language.factories`.
config (dict): Configuration parameters to initialise component.
RETURNS (callable): Pipeline component. | [
"Create",
"a",
"pipeline",
"component",
"from",
"a",
"factory",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/tokenizer_loader.py#L44-L54 |
howl-anderson/MicroTokenizer | MicroTokenizer/errors.py | add_codes | def add_codes(err_cls):
"""Add error codes to string messages via class attribute names."""
class ErrorsWithCodes(object):
def __getattribute__(self, code):
msg = getattr(err_cls, code)
return '[{code}] {msg}'.format(code=code, msg=msg)
return ErrorsWithCodes() | python | def add_codes(err_cls):
"""Add error codes to string messages via class attribute names."""
class ErrorsWithCodes(object):
def __getattribute__(self, code):
msg = getattr(err_cls, code)
return '[{code}] {msg}'.format(code=code, msg=msg)
return ErrorsWithCodes() | [
"def",
"add_codes",
"(",
"err_cls",
")",
":",
"class",
"ErrorsWithCodes",
"(",
"object",
")",
":",
"def",
"__getattribute__",
"(",
"self",
",",
"code",
")",
":",
"msg",
"=",
"getattr",
"(",
"err_cls",
",",
"code",
")",
"return",
"'[{code}] {msg}'",
".",
... | Add error codes to string messages via class attribute names. | [
"Add",
"error",
"codes",
"to",
"string",
"messages",
"via",
"class",
"attribute",
"names",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/errors.py#L9-L15 |
howl-anderson/MicroTokenizer | MicroTokenizer/errors.py | _warn | def _warn(message, warn_type='user'):
"""
message (unicode): The message to display.
category (Warning): The Warning to show.
"""
w_id = message.split('[', 1)[1].split(']', 1)[0] # get ID from string
if warn_type in SPACY_WARNING_TYPES and w_id not in SPACY_WARNING_IGNORE:
category = WA... | python | def _warn(message, warn_type='user'):
"""
message (unicode): The message to display.
category (Warning): The Warning to show.
"""
w_id = message.split('[', 1)[1].split(']', 1)[0] # get ID from string
if warn_type in SPACY_WARNING_TYPES and w_id not in SPACY_WARNING_IGNORE:
category = WA... | [
"def",
"_warn",
"(",
"message",
",",
"warn_type",
"=",
"'user'",
")",
":",
"w_id",
"=",
"message",
".",
"split",
"(",
"'['",
",",
"1",
")",
"[",
"1",
"]",
".",
"split",
"(",
"']'",
",",
"1",
")",
"[",
"0",
"]",
"# get ID from string",
"if",
"warn... | message (unicode): The message to display.
category (Warning): The Warning to show. | [
"message",
"(",
"unicode",
")",
":",
"The",
"message",
"to",
"display",
".",
"category",
"(",
"Warning",
")",
":",
"The",
"Warning",
"to",
"show",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/errors.py#L314-L326 |
howl-anderson/MicroTokenizer | MicroTokenizer/cli_command/download.py | download | def download(model=None, direct=False, *pip_args):
"""
Download compatible model from default download path using pip. Model
can be shortcut, model name or, if --direct flag is set, full model name
with version.
"""
if model is None:
model = about.__default_corpus__
if direct:
... | python | def download(model=None, direct=False, *pip_args):
"""
Download compatible model from default download path using pip. Model
can be shortcut, model name or, if --direct flag is set, full model name
with version.
"""
if model is None:
model = about.__default_corpus__
if direct:
... | [
"def",
"download",
"(",
"model",
"=",
"None",
",",
"direct",
"=",
"False",
",",
"*",
"pip_args",
")",
":",
"if",
"model",
"is",
"None",
":",
"model",
"=",
"about",
".",
"__default_corpus__",
"if",
"direct",
":",
"dl",
"=",
"download_model",
"(",
"'{m}/... | Download compatible model from default download path using pip. Model
can be shortcut, model name or, if --direct flag is set, full model name
with version. | [
"Download",
"compatible",
"model",
"from",
"default",
"download",
"path",
"using",
"pip",
".",
"Model",
"can",
"be",
"shortcut",
"model",
"name",
"or",
"if",
"--",
"direct",
"flag",
"is",
"set",
"full",
"model",
"name",
"with",
"version",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/cli_command/download.py#L22-L53 |
howl-anderson/MicroTokenizer | MicroTokenizer/cli_command/link.py | link | def link(origin, link_name, force=False, model_path=None):
"""
Create a symlink for models within the spacy/data directory. Accepts
either the name of a pip package, or the local path to the model data
directory. Linking models allows loading them via spacy.load(link_name).
"""
if util.is_packag... | python | def link(origin, link_name, force=False, model_path=None):
"""
Create a symlink for models within the spacy/data directory. Accepts
either the name of a pip package, or the local path to the model data
directory. Linking models allows loading them via spacy.load(link_name).
"""
if util.is_packag... | [
"def",
"link",
"(",
"origin",
",",
"link_name",
",",
"force",
"=",
"False",
",",
"model_path",
"=",
"None",
")",
":",
"if",
"util",
".",
"is_package",
"(",
"origin",
")",
":",
"model_path",
"=",
"util",
".",
"get_package_path",
"(",
"origin",
")",
"els... | Create a symlink for models within the spacy/data directory. Accepts
either the name of a pip package, or the local path to the model data
directory. Linking models allows loading them via spacy.load(link_name). | [
"Create",
"a",
"symlink",
"for",
"models",
"within",
"the",
"spacy",
"/",
"data",
"directory",
".",
"Accepts",
"either",
"the",
"name",
"of",
"a",
"pip",
"package",
"or",
"the",
"local",
"path",
"to",
"the",
"model",
"data",
"directory",
".",
"Linking",
... | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/cli_command/link.py#L17-L53 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | load_model_from_path | def load_model_from_path(model_path, meta=False, **overrides):
"""Load a model from a data directory path. Creates Language class with
pipeline from meta.json and then calls from_disk() with path."""
from .tokenizer_loader import TokenizerLoader
if not meta:
meta = get_model_meta(model_path)
... | python | def load_model_from_path(model_path, meta=False, **overrides):
"""Load a model from a data directory path. Creates Language class with
pipeline from meta.json and then calls from_disk() with path."""
from .tokenizer_loader import TokenizerLoader
if not meta:
meta = get_model_meta(model_path)
... | [
"def",
"load_model_from_path",
"(",
"model_path",
",",
"meta",
"=",
"False",
",",
"*",
"*",
"overrides",
")",
":",
"from",
".",
"tokenizer_loader",
"import",
"TokenizerLoader",
"if",
"not",
"meta",
":",
"meta",
"=",
"get_model_meta",
"(",
"model_path",
")",
... | Load a model from a data directory path. Creates Language class with
pipeline from meta.json and then calls from_disk() with path. | [
"Load",
"a",
"model",
"from",
"a",
"data",
"directory",
"path",
".",
"Creates",
"Language",
"class",
"with",
"pipeline",
"from",
"meta",
".",
"json",
"and",
"then",
"calls",
"from_disk",
"()",
"with",
"path",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L101-L120 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | is_package | def is_package(name):
"""Check if string maps to a package installed via pip.
name (unicode): Name of package.
RETURNS (bool): True if installed package, False if not.
"""
name = name.lower() # compare package name against lowercase name
packages = pkg_resources.working_set.by_key.keys()
f... | python | def is_package(name):
"""Check if string maps to a package installed via pip.
name (unicode): Name of package.
RETURNS (bool): True if installed package, False if not.
"""
name = name.lower() # compare package name against lowercase name
packages = pkg_resources.working_set.by_key.keys()
f... | [
"def",
"is_package",
"(",
"name",
")",
":",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"# compare package name against lowercase name",
"packages",
"=",
"pkg_resources",
".",
"working_set",
".",
"by_key",
".",
"keys",
"(",
")",
"for",
"package",
"in",
"packa... | Check if string maps to a package installed via pip.
name (unicode): Name of package.
RETURNS (bool): True if installed package, False if not. | [
"Check",
"if",
"string",
"maps",
"to",
"a",
"package",
"installed",
"via",
"pip",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L159-L170 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | decaying | def decaying(start, stop, decay):
"""Yield an infinite series of linearly decaying values."""
def clip(value):
return max(value, stop) if (start > stop) else min(value, stop)
nr_upd = 1.
while True:
yield clip(start * 1./(1. + decay * nr_upd))
nr_upd += 1 | python | def decaying(start, stop, decay):
"""Yield an infinite series of linearly decaying values."""
def clip(value):
return max(value, stop) if (start > stop) else min(value, stop)
nr_upd = 1.
while True:
yield clip(start * 1./(1. + decay * nr_upd))
nr_upd += 1 | [
"def",
"decaying",
"(",
"start",
",",
"stop",
",",
"decay",
")",
":",
"def",
"clip",
"(",
"value",
")",
":",
"return",
"max",
"(",
"value",
",",
"stop",
")",
"if",
"(",
"start",
">",
"stop",
")",
"else",
"min",
"(",
"value",
",",
"stop",
")",
"... | Yield an infinite series of linearly decaying values. | [
"Yield",
"an",
"infinite",
"series",
"of",
"linearly",
"decaying",
"values",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L272-L279 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | read_json | def read_json(location):
"""Open and load JSON from file.
location (Path): Path to JSON file.
RETURNS (dict): Loaded JSON content.
"""
location = ensure_path(location)
with location.open('r', encoding='utf8') as f:
return ujson.load(f) | python | def read_json(location):
"""Open and load JSON from file.
location (Path): Path to JSON file.
RETURNS (dict): Loaded JSON content.
"""
location = ensure_path(location)
with location.open('r', encoding='utf8') as f:
return ujson.load(f) | [
"def",
"read_json",
"(",
"location",
")",
":",
"location",
"=",
"ensure_path",
"(",
"location",
")",
"with",
"location",
".",
"open",
"(",
"'r'",
",",
"encoding",
"=",
"'utf8'",
")",
"as",
"f",
":",
"return",
"ujson",
".",
"load",
"(",
"f",
")"
] | Open and load JSON from file.
location (Path): Path to JSON file.
RETURNS (dict): Loaded JSON content. | [
"Open",
"and",
"load",
"JSON",
"from",
"file",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L311-L319 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | get_raw_input | def get_raw_input(description, default=False):
"""Get user input from the command line via raw_input / input.
description (unicode): Text to display before prompt.
default (unicode or False/None): Default value to display with prompt.
RETURNS (unicode): User input.
"""
additional = ' (default: ... | python | def get_raw_input(description, default=False):
"""Get user input from the command line via raw_input / input.
description (unicode): Text to display before prompt.
default (unicode or False/None): Default value to display with prompt.
RETURNS (unicode): User input.
"""
additional = ' (default: ... | [
"def",
"get_raw_input",
"(",
"description",
",",
"default",
"=",
"False",
")",
":",
"additional",
"=",
"' (default: %s)'",
"%",
"default",
"if",
"default",
"else",
"''",
"prompt",
"=",
"' %s%s: '",
"%",
"(",
"description",
",",
"additional",
")",
"user_inpu... | Get user input from the command line via raw_input / input.
description (unicode): Text to display before prompt.
default (unicode or False/None): Default value to display with prompt.
RETURNS (unicode): User input. | [
"Get",
"user",
"input",
"from",
"the",
"command",
"line",
"via",
"raw_input",
"/",
"input",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L322-L332 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | print_table | def print_table(data, title=None):
"""Print data in table format.
data (dict or list of tuples): Label/value pairs.
title (unicode or None): Title, will be printed above.
"""
if isinstance(data, dict):
data = list(data.items())
tpl_row = ' {:<15}' * len(data[0])
table = '\n'.join... | python | def print_table(data, title=None):
"""Print data in table format.
data (dict or list of tuples): Label/value pairs.
title (unicode or None): Title, will be printed above.
"""
if isinstance(data, dict):
data = list(data.items())
tpl_row = ' {:<15}' * len(data[0])
table = '\n'.join... | [
"def",
"print_table",
"(",
"data",
",",
"title",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"data",
"=",
"list",
"(",
"data",
".",
"items",
"(",
")",
")",
"tpl_row",
"=",
"' {:<15}'",
"*",
"len",
"(",
"data",
... | Print data in table format.
data (dict or list of tuples): Label/value pairs.
title (unicode or None): Title, will be printed above. | [
"Print",
"data",
"in",
"table",
"format",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L355-L367 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | print_markdown | def print_markdown(data, title=None):
"""Print data in GitHub-flavoured Markdown format for issues etc.
data (dict or list of tuples): Label/value pairs.
title (unicode or None): Title, will be rendered as headline 2.
"""
def excl_value(value):
# contains path, i.e. personal info
re... | python | def print_markdown(data, title=None):
"""Print data in GitHub-flavoured Markdown format for issues etc.
data (dict or list of tuples): Label/value pairs.
title (unicode or None): Title, will be rendered as headline 2.
"""
def excl_value(value):
# contains path, i.e. personal info
re... | [
"def",
"print_markdown",
"(",
"data",
",",
"title",
"=",
"None",
")",
":",
"def",
"excl_value",
"(",
"value",
")",
":",
"# contains path, i.e. personal info",
"return",
"isinstance",
"(",
"value",
",",
"basestring_",
")",
"and",
"Path",
"(",
"value",
")",
".... | Print data in GitHub-flavoured Markdown format for issues etc.
data (dict or list of tuples): Label/value pairs.
title (unicode or None): Title, will be rendered as headline 2. | [
"Print",
"data",
"in",
"GitHub",
"-",
"flavoured",
"Markdown",
"format",
"for",
"issues",
"etc",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L370-L386 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | prints | def prints(*texts, **kwargs):
"""Print formatted message (manual ANSI escape sequences to avoid
dependency)
*texts (unicode): Texts to print. Each argument is rendered as paragraph.
**kwargs: 'title' becomes coloured headline. exits=True performs sys exit.
"""
exits = kwargs.get('exits', None)
... | python | def prints(*texts, **kwargs):
"""Print formatted message (manual ANSI escape sequences to avoid
dependency)
*texts (unicode): Texts to print. Each argument is rendered as paragraph.
**kwargs: 'title' becomes coloured headline. exits=True performs sys exit.
"""
exits = kwargs.get('exits', None)
... | [
"def",
"prints",
"(",
"*",
"texts",
",",
"*",
"*",
"kwargs",
")",
":",
"exits",
"=",
"kwargs",
".",
"get",
"(",
"'exits'",
",",
"None",
")",
"title",
"=",
"kwargs",
".",
"get",
"(",
"'title'",
",",
"None",
")",
"title",
"=",
"'\\033[93m{}\\033[0m\\n'... | Print formatted message (manual ANSI escape sequences to avoid
dependency)
*texts (unicode): Texts to print. Each argument is rendered as paragraph.
**kwargs: 'title' becomes coloured headline. exits=True performs sys exit. | [
"Print",
"formatted",
"message",
"(",
"manual",
"ANSI",
"escape",
"sequences",
"to",
"avoid",
"dependency",
")"
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L389-L402 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | _wrap | def _wrap(text, wrap_max=80, indent=4):
"""Wrap text at given width using textwrap module.
text (unicode): Text to wrap. If it's a Path, it's converted to string.
wrap_max (int): Maximum line length (indent is deducted).
indent (int): Number of spaces for indentation.
RETURNS (unicode): Wrapped tex... | python | def _wrap(text, wrap_max=80, indent=4):
"""Wrap text at given width using textwrap module.
text (unicode): Text to wrap. If it's a Path, it's converted to string.
wrap_max (int): Maximum line length (indent is deducted).
indent (int): Number of spaces for indentation.
RETURNS (unicode): Wrapped tex... | [
"def",
"_wrap",
"(",
"text",
",",
"wrap_max",
"=",
"80",
",",
"indent",
"=",
"4",
")",
":",
"indent",
"=",
"indent",
"*",
"' '",
"wrap_width",
"=",
"wrap_max",
"-",
"len",
"(",
"indent",
")",
"if",
"isinstance",
"(",
"text",
",",
"Path",
")",
":",
... | Wrap text at given width using textwrap module.
text (unicode): Text to wrap. If it's a Path, it's converted to string.
wrap_max (int): Maximum line length (indent is deducted).
indent (int): Number of spaces for indentation.
RETURNS (unicode): Wrapped text. | [
"Wrap",
"text",
"at",
"given",
"width",
"using",
"textwrap",
"module",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L405-L419 |
howl-anderson/MicroTokenizer | MicroTokenizer/util.py | escape_html | def escape_html(text):
"""Replace <, >, &, " with their HTML encoded representation. Intended to
prevent HTML errors in rendered displaCy markup.
text (unicode): The original text.
RETURNS (unicode): Equivalent text to be safely used within HTML.
"""
text = text.replace('&', '&')
text =... | python | def escape_html(text):
"""Replace <, >, &, " with their HTML encoded representation. Intended to
prevent HTML errors in rendered displaCy markup.
text (unicode): The original text.
RETURNS (unicode): Equivalent text to be safely used within HTML.
"""
text = text.replace('&', '&')
text =... | [
"def",
"escape_html",
"(",
"text",
")",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"'&'",
",",
"'&'",
")",
"text",
"=",
"text",
".",
"replace",
"(",
"'<'",
",",
"'<'",
")",
"text",
"=",
"text",
".",
"replace",
"(",
"'>'",
",",
"'>'",
... | Replace <, >, &, " with their HTML encoded representation. Intended to
prevent HTML errors in rendered displaCy markup.
text (unicode): The original text.
RETURNS (unicode): Equivalent text to be safely used within HTML. | [
"Replace",
"<",
">",
"&",
"with",
"their",
"HTML",
"encoded",
"representation",
".",
"Intended",
"to",
"prevent",
"HTML",
"errors",
"in",
"rendered",
"displaCy",
"markup",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/util.py#L433-L444 |
howl-anderson/MicroTokenizer | MicroTokenizer/compat.py | normalize_string_keys | def normalize_string_keys(old):
"""Given a dictionary, make sure keys are unicode strings, not bytes."""
new = {}
for key, value in old.items():
if isinstance(key, bytes_):
new[key.decode('utf8')] = value
else:
new[key] = value
return new | python | def normalize_string_keys(old):
"""Given a dictionary, make sure keys are unicode strings, not bytes."""
new = {}
for key, value in old.items():
if isinstance(key, bytes_):
new[key.decode('utf8')] = value
else:
new[key] = value
return new | [
"def",
"normalize_string_keys",
"(",
"old",
")",
":",
"new",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"old",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"bytes_",
")",
":",
"new",
"[",
"key",
".",
"decode",
"(",
"'ut... | Given a dictionary, make sure keys are unicode strings, not bytes. | [
"Given",
"a",
"dictionary",
"make",
"sure",
"keys",
"are",
"unicode",
"strings",
"not",
"bytes",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/compat.py#L78-L86 |
howl-anderson/MicroTokenizer | MicroTokenizer/compat.py | locale_escape | def locale_escape(string, errors='replace'):
'''
Mangle non-supported characters, for savages with ascii terminals.
'''
encoding = locale.getpreferredencoding()
string = string.encode(encoding, errors).decode('utf8')
return string | python | def locale_escape(string, errors='replace'):
'''
Mangle non-supported characters, for savages with ascii terminals.
'''
encoding = locale.getpreferredencoding()
string = string.encode(encoding, errors).decode('utf8')
return string | [
"def",
"locale_escape",
"(",
"string",
",",
"errors",
"=",
"'replace'",
")",
":",
"encoding",
"=",
"locale",
".",
"getpreferredencoding",
"(",
")",
"string",
"=",
"string",
".",
"encode",
"(",
"encoding",
",",
"errors",
")",
".",
"decode",
"(",
"'utf8'",
... | Mangle non-supported characters, for savages with ascii terminals. | [
"Mangle",
"non",
"-",
"supported",
"characters",
"for",
"savages",
"with",
"ascii",
"terminals",
"."
] | train | https://github.com/howl-anderson/MicroTokenizer/blob/41bbe9c31d202b4f751ad5201d343ad1123b42b5/MicroTokenizer/compat.py#L102-L108 |
aparrish/pronouncingpy | pronouncing/__init__.py | parse_cmu | def parse_cmu(cmufh):
"""Parses an incoming file handle as a CMU pronouncing dictionary file.
(Most end-users of this module won't need to call this function explicitly,
as it's called internally by the :func:`init_cmu` function.)
:param cmufh: a filehandle with CMUdict-formatted data
:returns: a ... | python | def parse_cmu(cmufh):
"""Parses an incoming file handle as a CMU pronouncing dictionary file.
(Most end-users of this module won't need to call this function explicitly,
as it's called internally by the :func:`init_cmu` function.)
:param cmufh: a filehandle with CMUdict-formatted data
:returns: a ... | [
"def",
"parse_cmu",
"(",
"cmufh",
")",
":",
"pronunciations",
"=",
"list",
"(",
")",
"for",
"line",
"in",
"cmufh",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"if",
"line",
".",
"startswith",
"(",
"';'",
")... | Parses an incoming file handle as a CMU pronouncing dictionary file.
(Most end-users of this module won't need to call this function explicitly,
as it's called internally by the :func:`init_cmu` function.)
:param cmufh: a filehandle with CMUdict-formatted data
:returns: a list of 2-tuples pairing a wo... | [
"Parses",
"an",
"incoming",
"file",
"handle",
"as",
"a",
"CMU",
"pronouncing",
"dictionary",
"file",
"."
] | train | https://github.com/aparrish/pronouncingpy/blob/09467fa9407d7d87cb0998ee3cb09db4dcc9571a/pronouncing/__init__.py#L17-L33 |
aparrish/pronouncingpy | pronouncing/__init__.py | init_cmu | def init_cmu(filehandle=None):
"""Initialize the module's pronunciation data.
This function is called automatically the first time you attempt to use
another function in the library that requires loading the pronunciation
data from disk. You can call this function manually to control when and
how t... | python | def init_cmu(filehandle=None):
"""Initialize the module's pronunciation data.
This function is called automatically the first time you attempt to use
another function in the library that requires loading the pronunciation
data from disk. You can call this function manually to control when and
how t... | [
"def",
"init_cmu",
"(",
"filehandle",
"=",
"None",
")",
":",
"global",
"pronunciations",
",",
"lookup",
",",
"rhyme_lookup",
"if",
"pronunciations",
"is",
"None",
":",
"if",
"filehandle",
"is",
"None",
":",
"filehandle",
"=",
"cmudict",
".",
"dict_stream",
"... | Initialize the module's pronunciation data.
This function is called automatically the first time you attempt to use
another function in the library that requires loading the pronunciation
data from disk. You can call this function manually to control when and
how the pronunciation data is loaded (e.g.,... | [
"Initialize",
"the",
"module",
"s",
"pronunciation",
"data",
"."
] | train | https://github.com/aparrish/pronouncingpy/blob/09467fa9407d7d87cb0998ee3cb09db4dcc9571a/pronouncing/__init__.py#L36-L61 |
aparrish/pronouncingpy | pronouncing/__init__.py | rhyming_part | def rhyming_part(phones):
"""Get the "rhyming part" of a string with CMUdict phones.
"Rhyming part" here means everything from the vowel in the stressed
syllable nearest the end of the word up to the end of the word.
.. doctest::
>>> import pronouncing
>>> phones = pronouncing.phones_... | python | def rhyming_part(phones):
"""Get the "rhyming part" of a string with CMUdict phones.
"Rhyming part" here means everything from the vowel in the stressed
syllable nearest the end of the word up to the end of the word.
.. doctest::
>>> import pronouncing
>>> phones = pronouncing.phones_... | [
"def",
"rhyming_part",
"(",
"phones",
")",
":",
"phones_list",
"=",
"phones",
".",
"split",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"phones_list",
")",
"-",
"1",
",",
"0",
",",
"-",
"1",
")",
":",
"if",
"phones_list",
"[",
"i",
"]",... | Get the "rhyming part" of a string with CMUdict phones.
"Rhyming part" here means everything from the vowel in the stressed
syllable nearest the end of the word up to the end of the word.
.. doctest::
>>> import pronouncing
>>> phones = pronouncing.phones_for_word("purple")
>>> pr... | [
"Get",
"the",
"rhyming",
"part",
"of",
"a",
"string",
"with",
"CMUdict",
"phones",
"."
] | train | https://github.com/aparrish/pronouncingpy/blob/09467fa9407d7d87cb0998ee3cb09db4dcc9571a/pronouncing/__init__.py#L135-L155 |
aparrish/pronouncingpy | pronouncing/__init__.py | search | def search(pattern):
"""Get words whose pronunciation matches a regular expression.
This function Searches the CMU dictionary for pronunciations matching a
given regular expression. (Word boundary anchors are automatically added
before and after the pattern.)
.. doctest::
>>> import prono... | python | def search(pattern):
"""Get words whose pronunciation matches a regular expression.
This function Searches the CMU dictionary for pronunciations matching a
given regular expression. (Word boundary anchors are automatically added
before and after the pattern.)
.. doctest::
>>> import prono... | [
"def",
"search",
"(",
"pattern",
")",
":",
"init_cmu",
"(",
")",
"regexp",
"=",
"re",
".",
"compile",
"(",
"r\"\\b\"",
"+",
"pattern",
"+",
"r\"\\b\"",
")",
"return",
"[",
"word",
"for",
"word",
",",
"phones",
"in",
"pronunciations",
"if",
"regexp",
".... | Get words whose pronunciation matches a regular expression.
This function Searches the CMU dictionary for pronunciations matching a
given regular expression. (Word boundary anchors are automatically added
before and after the pattern.)
.. doctest::
>>> import pronouncing
>>> 'interpol... | [
"Get",
"words",
"whose",
"pronunciation",
"matches",
"a",
"regular",
"expression",
"."
] | train | https://github.com/aparrish/pronouncingpy/blob/09467fa9407d7d87cb0998ee3cb09db4dcc9571a/pronouncing/__init__.py#L158-L178 |
aparrish/pronouncingpy | pronouncing/__init__.py | search_stresses | def search_stresses(pattern):
"""Get words whose stress pattern matches a regular expression.
This function is a special case of :func:`search` that searches only the
stress patterns of each pronunciation in the dictionary. You can get
stress patterns for a word using the :func:`stresses_for_word` func... | python | def search_stresses(pattern):
"""Get words whose stress pattern matches a regular expression.
This function is a special case of :func:`search` that searches only the
stress patterns of each pronunciation in the dictionary. You can get
stress patterns for a word using the :func:`stresses_for_word` func... | [
"def",
"search_stresses",
"(",
"pattern",
")",
":",
"init_cmu",
"(",
")",
"regexp",
"=",
"re",
".",
"compile",
"(",
"pattern",
")",
"return",
"[",
"word",
"for",
"word",
",",
"phones",
"in",
"pronunciations",
"if",
"regexp",
".",
"search",
"(",
"stresses... | Get words whose stress pattern matches a regular expression.
This function is a special case of :func:`search` that searches only the
stress patterns of each pronunciation in the dictionary. You can get
stress patterns for a word using the :func:`stresses_for_word` function.
.. doctest::
>>> ... | [
"Get",
"words",
"whose",
"stress",
"pattern",
"matches",
"a",
"regular",
"expression",
"."
] | train | https://github.com/aparrish/pronouncingpy/blob/09467fa9407d7d87cb0998ee3cb09db4dcc9571a/pronouncing/__init__.py#L181-L201 |
aparrish/pronouncingpy | pronouncing/__init__.py | rhymes | def rhymes(word):
"""Get words rhyming with a given word.
This function may return an empty list if no rhyming words are found in
the dictionary, or if the word you pass to the function is itself not
found in the dictionary.
.. doctest::
>>> import pronouncing
>>> pronouncing.rhym... | python | def rhymes(word):
"""Get words rhyming with a given word.
This function may return an empty list if no rhyming words are found in
the dictionary, or if the word you pass to the function is itself not
found in the dictionary.
.. doctest::
>>> import pronouncing
>>> pronouncing.rhym... | [
"def",
"rhymes",
"(",
"word",
")",
":",
"phones",
"=",
"phones_for_word",
"(",
"word",
")",
"combined_rhymes",
"=",
"[",
"]",
"if",
"phones",
":",
"for",
"element",
"in",
"phones",
":",
"combined_rhymes",
".",
"append",
"(",
"[",
"w",
"for",
"w",
"in",... | Get words rhyming with a given word.
This function may return an empty list if no rhyming words are found in
the dictionary, or if the word you pass to the function is itself not
found in the dictionary.
.. doctest::
>>> import pronouncing
>>> pronouncing.rhymes("conditioner")
... | [
"Get",
"words",
"rhyming",
"with",
"a",
"given",
"word",
"."
] | train | https://github.com/aparrish/pronouncingpy/blob/09467fa9407d7d87cb0998ee3cb09db4dcc9571a/pronouncing/__init__.py#L204-L230 |
OSSOS/MOP | src/ossos/core/ossos/gui/views/imageview.py | ImageViewManager.set_ds9 | def set_ds9(self, level="PREF"):
"""
Set the default values on the ds9 display.
"""
self.set_zoom()
ds9_settings = config.read("DS9."+level)
for key in ds9_settings.keys():
value = ds9_settings[key]
cmd = key.replace("_", " ")
self.ds9.... | python | def set_ds9(self, level="PREF"):
"""
Set the default values on the ds9 display.
"""
self.set_zoom()
ds9_settings = config.read("DS9."+level)
for key in ds9_settings.keys():
value = ds9_settings[key]
cmd = key.replace("_", " ")
self.ds9.... | [
"def",
"set_ds9",
"(",
"self",
",",
"level",
"=",
"\"PREF\"",
")",
":",
"self",
".",
"set_zoom",
"(",
")",
"ds9_settings",
"=",
"config",
".",
"read",
"(",
"\"DS9.\"",
"+",
"level",
")",
"for",
"key",
"in",
"ds9_settings",
".",
"keys",
"(",
")",
":",... | Set the default values on the ds9 display. | [
"Set",
"the",
"default",
"values",
"on",
"the",
"ds9",
"display",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/gui/views/imageview.py#L29-L38 |
OSSOS/MOP | src/ossos/core/ossos/cadc.py | cfht_megacam_tap_query | def cfht_megacam_tap_query(ra_deg=180.0, dec_deg=0.0, width=1, height=1, date=None):
"""Do a query of the CADC Megacam table.
Get all observations inside the box (right now it turns width/height into a radius, should not do this).
@rtype : Table
@param ra_deg: center of search region, in degrees
@... | python | def cfht_megacam_tap_query(ra_deg=180.0, dec_deg=0.0, width=1, height=1, date=None):
"""Do a query of the CADC Megacam table.
Get all observations inside the box (right now it turns width/height into a radius, should not do this).
@rtype : Table
@param ra_deg: center of search region, in degrees
@... | [
"def",
"cfht_megacam_tap_query",
"(",
"ra_deg",
"=",
"180.0",
",",
"dec_deg",
"=",
"0.0",
",",
"width",
"=",
"1",
",",
"height",
"=",
"1",
",",
"date",
"=",
"None",
")",
":",
"radius",
"=",
"min",
"(",
"90",
",",
"max",
"(",
"width",
",",
"height",... | Do a query of the CADC Megacam table.
Get all observations inside the box (right now it turns width/height into a radius, should not do this).
@rtype : Table
@param ra_deg: center of search region, in degrees
@param dec_deg: center of search region in degrees
@param width: width of search region i... | [
"Do",
"a",
"query",
"of",
"the",
"CADC",
"Megacam",
"table",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/cadc.py#L11-L55 |
JohnVinyard/zounds | zounds/spectral/tfrepresentation.py | FrequencyDimension.validate | def validate(self, size):
"""
Ensure that the size of the dimension matches the number of bands in the
scale
Raises:
ValueError: when the dimension size and number of bands don't match
"""
msg = 'scale and array size must match, ' \
'but were s... | python | def validate(self, size):
"""
Ensure that the size of the dimension matches the number of bands in the
scale
Raises:
ValueError: when the dimension size and number of bands don't match
"""
msg = 'scale and array size must match, ' \
'but were s... | [
"def",
"validate",
"(",
"self",
",",
"size",
")",
":",
"msg",
"=",
"'scale and array size must match, '",
"'but were scale: {self.scale.n_bands}, array size: {size}'",
"if",
"size",
"!=",
"len",
"(",
"self",
".",
"scale",
")",
":",
"raise",
"ValueError",
"(",
"msg"... | Ensure that the size of the dimension matches the number of bands in the
scale
Raises:
ValueError: when the dimension size and number of bands don't match | [
"Ensure",
"that",
"the",
"size",
"of",
"the",
"dimension",
"matches",
"the",
"number",
"of",
"bands",
"in",
"the",
"scale"
] | train | https://github.com/JohnVinyard/zounds/blob/337b3f98753d09eaab1c72dcd37bb852a3fa5ac6/zounds/spectral/tfrepresentation.py#L57-L69 |
JohnVinyard/zounds | zounds/basic/audiograph.py | resampled | def resampled(
chunksize_bytes=DEFAULT_CHUNK_SIZE,
resample_to=SR44100(),
store_resampled=False):
"""
Create a basic processing pipeline that can resample all incoming audio
to a normalized sampling rate for downstream processing, and store a
convenient, compressed version for pl... | python | def resampled(
chunksize_bytes=DEFAULT_CHUNK_SIZE,
resample_to=SR44100(),
store_resampled=False):
"""
Create a basic processing pipeline that can resample all incoming audio
to a normalized sampling rate for downstream processing, and store a
convenient, compressed version for pl... | [
"def",
"resampled",
"(",
"chunksize_bytes",
"=",
"DEFAULT_CHUNK_SIZE",
",",
"resample_to",
"=",
"SR44100",
"(",
")",
",",
"store_resampled",
"=",
"False",
")",
":",
"class",
"Resampled",
"(",
"BaseModel",
")",
":",
"meta",
"=",
"JSONFeature",
"(",
"MetaData",
... | Create a basic processing pipeline that can resample all incoming audio
to a normalized sampling rate for downstream processing, and store a
convenient, compressed version for playback
:param chunksize_bytes: The number of bytes from the raw stream to process
at once
:param resample_to: The new, no... | [
"Create",
"a",
"basic",
"processing",
"pipeline",
"that",
"can",
"resample",
"all",
"incoming",
"audio",
"to",
"a",
"normalized",
"sampling",
"rate",
"for",
"downstream",
"processing",
"and",
"store",
"a",
"convenient",
"compressed",
"version",
"for",
"playback"
] | train | https://github.com/JohnVinyard/zounds/blob/337b3f98753d09eaab1c72dcd37bb852a3fa5ac6/zounds/basic/audiograph.py#L22-L65 |
JohnVinyard/zounds | zounds/basic/audiograph.py | audio_graph | def audio_graph(
chunksize_bytes=DEFAULT_CHUNK_SIZE,
resample_to=SR44100(),
store_fft=False):
"""
Produce a base class suitable as a starting point for many audio processing
pipelines. This class resamples all audio to a common sampling rate, and
produces a bark band spectrogram... | python | def audio_graph(
chunksize_bytes=DEFAULT_CHUNK_SIZE,
resample_to=SR44100(),
store_fft=False):
"""
Produce a base class suitable as a starting point for many audio processing
pipelines. This class resamples all audio to a common sampling rate, and
produces a bark band spectrogram... | [
"def",
"audio_graph",
"(",
"chunksize_bytes",
"=",
"DEFAULT_CHUNK_SIZE",
",",
"resample_to",
"=",
"SR44100",
"(",
")",
",",
"store_fft",
"=",
"False",
")",
":",
"band",
"=",
"FrequencyBand",
"(",
"20",
",",
"resample_to",
".",
"nyquist",
")",
"class",
"Audio... | Produce a base class suitable as a starting point for many audio processing
pipelines. This class resamples all audio to a common sampling rate, and
produces a bark band spectrogram from overlapping short-time fourier
transform frames. It also compresses the audio into ogg vorbis format for
compact st... | [
"Produce",
"a",
"base",
"class",
"suitable",
"as",
"a",
"starting",
"point",
"for",
"many",
"audio",
"processing",
"pipelines",
".",
"This",
"class",
"resamples",
"all",
"audio",
"to",
"a",
"common",
"sampling",
"rate",
"and",
"produces",
"a",
"bark",
"band"... | train | https://github.com/JohnVinyard/zounds/blob/337b3f98753d09eaab1c72dcd37bb852a3fa5ac6/zounds/basic/audiograph.py#L179-L260 |
JohnVinyard/zounds | zounds/basic/audiograph.py | with_onsets | def with_onsets(fft_feature):
"""
Produce a mixin class that extracts onsets
:param fft_feature: The short-time fourier transform feature
:return: A mixin class that extracts onsets
"""
class Onsets(BaseModel):
onset_prep = ArrayWithUnitsFeature(
SlidingWindow,
n... | python | def with_onsets(fft_feature):
"""
Produce a mixin class that extracts onsets
:param fft_feature: The short-time fourier transform feature
:return: A mixin class that extracts onsets
"""
class Onsets(BaseModel):
onset_prep = ArrayWithUnitsFeature(
SlidingWindow,
n... | [
"def",
"with_onsets",
"(",
"fft_feature",
")",
":",
"class",
"Onsets",
"(",
"BaseModel",
")",
":",
"onset_prep",
"=",
"ArrayWithUnitsFeature",
"(",
"SlidingWindow",
",",
"needs",
"=",
"fft_feature",
",",
"wscheme",
"=",
"HalfLapped",
"(",
")",
"*",
"Stride",
... | Produce a mixin class that extracts onsets
:param fft_feature: The short-time fourier transform feature
:return: A mixin class that extracts onsets | [
"Produce",
"a",
"mixin",
"class",
"that",
"extracts",
"onsets",
":",
"param",
"fft_feature",
":",
"The",
"short",
"-",
"time",
"fourier",
"transform",
"feature",
":",
"return",
":",
"A",
"mixin",
"class",
"that",
"extracts",
"onsets"
] | train | https://github.com/JohnVinyard/zounds/blob/337b3f98753d09eaab1c72dcd37bb852a3fa5ac6/zounds/basic/audiograph.py#L263-L295 |
OSSOS/MOP | src/ossos/plotting/scripts/sky_location_plots.py | keplerian_sheared_field_locations | def keplerian_sheared_field_locations(ax, kbos, date, ras, decs, names, elongation=False, plot=False):
"""
Shift fields from the discovery set to the requested date by the average motion of L7 kbos in the discovery field.
:param ras:
:param decs:
:param plot:
:param ax:
:param kbos: precompu... | python | def keplerian_sheared_field_locations(ax, kbos, date, ras, decs, names, elongation=False, plot=False):
"""
Shift fields from the discovery set to the requested date by the average motion of L7 kbos in the discovery field.
:param ras:
:param decs:
:param plot:
:param ax:
:param kbos: precompu... | [
"def",
"keplerian_sheared_field_locations",
"(",
"ax",
",",
"kbos",
",",
"date",
",",
"ras",
",",
"decs",
",",
"names",
",",
"elongation",
"=",
"False",
",",
"plot",
"=",
"False",
")",
":",
"seps",
"=",
"{",
"'dra'",
":",
"0.",
",",
"'ddec'",
":",
"0... | Shift fields from the discovery set to the requested date by the average motion of L7 kbos in the discovery field.
:param ras:
:param decs:
:param plot:
:param ax:
:param kbos: precomputed at the discovery date for that block. e.g. Oct new moon for 13B
:param date:
:param names:
:param e... | [
"Shift",
"fields",
"from",
"the",
"discovery",
"set",
"to",
"the",
"requested",
"date",
"by",
"the",
"average",
"motion",
"of",
"L7",
"kbos",
"in",
"the",
"discovery",
"field",
".",
":",
"param",
"ras",
":",
":",
"param",
"decs",
":",
":",
"param",
"pl... | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/plotting/scripts/sky_location_plots.py#L322-L365 |
OSSOS/MOP | src/ossos/plotting/scripts/sky_location_plots.py | field_elongation | def field_elongation(ra, dec, date):
"""
For a given field, calculate the solar elongation at the given date.
:param ra: field's right ascension. unit="h" format="RAh:RAm:RAs"
:param dec: field's declination. degrees
:param date: date at which to calculate elongation
:return: elongation from t... | python | def field_elongation(ra, dec, date):
"""
For a given field, calculate the solar elongation at the given date.
:param ra: field's right ascension. unit="h" format="RAh:RAm:RAs"
:param dec: field's declination. degrees
:param date: date at which to calculate elongation
:return: elongation from t... | [
"def",
"field_elongation",
"(",
"ra",
",",
"dec",
",",
"date",
")",
":",
"sun",
"=",
"ephem",
".",
"Sun",
"(",
")",
"sun",
".",
"compute",
"(",
"date",
")",
"sep",
"=",
"ephem",
".",
"separation",
"(",
"(",
"ra",
",",
"dec",
")",
",",
"sun",
")... | For a given field, calculate the solar elongation at the given date.
:param ra: field's right ascension. unit="h" format="RAh:RAm:RAs"
:param dec: field's declination. degrees
:param date: date at which to calculate elongation
:return: elongation from the Sun in degrees | [
"For",
"a",
"given",
"field",
"calculate",
"the",
"solar",
"elongation",
"at",
"the",
"given",
"date",
".",
":",
"param",
"ra",
":",
"field",
"s",
"right",
"ascension",
".",
"unit",
"=",
"h",
"format",
"=",
"RAh",
":",
"RAm",
":",
"RAs",
":",
"param"... | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/plotting/scripts/sky_location_plots.py#L368-L381 |
playpauseandstop/rororo | rororo/timedelta.py | str_to_timedelta | def str_to_timedelta(value: str,
fmt: str = None) -> Optional[datetime.timedelta]:
"""
Convert string value to timedelta instance according to the given format.
If format not set function tries to load timedelta using default
``TIMEDELTA_FORMAT`` and then both of magic "full" forma... | python | def str_to_timedelta(value: str,
fmt: str = None) -> Optional[datetime.timedelta]:
"""
Convert string value to timedelta instance according to the given format.
If format not set function tries to load timedelta using default
``TIMEDELTA_FORMAT`` and then both of magic "full" forma... | [
"def",
"str_to_timedelta",
"(",
"value",
":",
"str",
",",
"fmt",
":",
"str",
"=",
"None",
")",
"->",
"Optional",
"[",
"datetime",
".",
"timedelta",
"]",
":",
"def",
"timedelta_kwargs",
"(",
"data",
":",
"DictStrInt",
")",
"->",
"DictStrInt",
":",
"\"\"\"... | Convert string value to timedelta instance according to the given format.
If format not set function tries to load timedelta using default
``TIMEDELTA_FORMAT`` and then both of magic "full" formats.
You should also specify list of formats and function tries to convert
to timedelta using each of format... | [
"Convert",
"string",
"value",
"to",
"timedelta",
"instance",
"according",
"to",
"the",
"given",
"format",
"."
] | train | https://github.com/playpauseandstop/rororo/blob/28a04e8028c29647941e727116335e9d6fd64c27/rororo/timedelta.py#L66-L152 |
playpauseandstop/rororo | rororo/timedelta.py | timedelta_average | def timedelta_average(*values: datetime.timedelta) -> datetime.timedelta:
r"""Compute the arithmetic mean for timedeltas list.
:param \*values: Timedelta instances to process.
"""
if isinstance(values[0], (list, tuple)):
values = values[0]
return sum(values, datetime.timedelta()) // len(val... | python | def timedelta_average(*values: datetime.timedelta) -> datetime.timedelta:
r"""Compute the arithmetic mean for timedeltas list.
:param \*values: Timedelta instances to process.
"""
if isinstance(values[0], (list, tuple)):
values = values[0]
return sum(values, datetime.timedelta()) // len(val... | [
"def",
"timedelta_average",
"(",
"*",
"values",
":",
"datetime",
".",
"timedelta",
")",
"->",
"datetime",
".",
"timedelta",
":",
"if",
"isinstance",
"(",
"values",
"[",
"0",
"]",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"values",
"=",
"values",
... | r"""Compute the arithmetic mean for timedeltas list.
:param \*values: Timedelta instances to process. | [
"r",
"Compute",
"the",
"arithmetic",
"mean",
"for",
"timedeltas",
"list",
"."
] | train | https://github.com/playpauseandstop/rororo/blob/28a04e8028c29647941e727116335e9d6fd64c27/rororo/timedelta.py#L155-L162 |
playpauseandstop/rororo | rororo/timedelta.py | timedelta_div | def timedelta_div(first: datetime.timedelta,
second: datetime.timedelta) -> Optional[float]:
"""Implement divison for timedelta instances.
:param first: First timedelta instance.
:param second: Second timedelta instance.
"""
first_seconds = timedelta_seconds(first)
second_seco... | python | def timedelta_div(first: datetime.timedelta,
second: datetime.timedelta) -> Optional[float]:
"""Implement divison for timedelta instances.
:param first: First timedelta instance.
:param second: Second timedelta instance.
"""
first_seconds = timedelta_seconds(first)
second_seco... | [
"def",
"timedelta_div",
"(",
"first",
":",
"datetime",
".",
"timedelta",
",",
"second",
":",
"datetime",
".",
"timedelta",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"first_seconds",
"=",
"timedelta_seconds",
"(",
"first",
")",
"second_seconds",
"=",
"ti... | Implement divison for timedelta instances.
:param first: First timedelta instance.
:param second: Second timedelta instance. | [
"Implement",
"divison",
"for",
"timedelta",
"instances",
"."
] | train | https://github.com/playpauseandstop/rororo/blob/28a04e8028c29647941e727116335e9d6fd64c27/rororo/timedelta.py#L165-L178 |
playpauseandstop/rororo | rororo/timedelta.py | timedelta_seconds | def timedelta_seconds(value: datetime.timedelta) -> int:
"""Return full number of seconds from timedelta.
By default, Python returns only one day seconds, not all timedelta seconds.
:param value: Timedelta instance.
"""
return SECONDS_PER_DAY * value.days + value.seconds | python | def timedelta_seconds(value: datetime.timedelta) -> int:
"""Return full number of seconds from timedelta.
By default, Python returns only one day seconds, not all timedelta seconds.
:param value: Timedelta instance.
"""
return SECONDS_PER_DAY * value.days + value.seconds | [
"def",
"timedelta_seconds",
"(",
"value",
":",
"datetime",
".",
"timedelta",
")",
"->",
"int",
":",
"return",
"SECONDS_PER_DAY",
"*",
"value",
".",
"days",
"+",
"value",
".",
"seconds"
] | Return full number of seconds from timedelta.
By default, Python returns only one day seconds, not all timedelta seconds.
:param value: Timedelta instance. | [
"Return",
"full",
"number",
"of",
"seconds",
"from",
"timedelta",
"."
] | train | https://github.com/playpauseandstop/rororo/blob/28a04e8028c29647941e727116335e9d6fd64c27/rororo/timedelta.py#L181-L188 |
playpauseandstop/rororo | rororo/timedelta.py | timedelta_to_str | def timedelta_to_str(value: datetime.timedelta, fmt: str = None) -> str:
"""Display the timedelta formatted according to the given string.
You should use global setting ``TIMEDELTA_FORMAT`` to specify default
format to this function there (like ``DATE_FORMAT`` for builtin ``date``
template filter).
... | python | def timedelta_to_str(value: datetime.timedelta, fmt: str = None) -> str:
"""Display the timedelta formatted according to the given string.
You should use global setting ``TIMEDELTA_FORMAT`` to specify default
format to this function there (like ``DATE_FORMAT`` for builtin ``date``
template filter).
... | [
"def",
"timedelta_to_str",
"(",
"value",
":",
"datetime",
".",
"timedelta",
",",
"fmt",
":",
"str",
"=",
"None",
")",
"->",
"str",
":",
"# Only ``datetime.timedelta`` instances allowed for this function",
"if",
"not",
"isinstance",
"(",
"value",
",",
"datetime",
"... | Display the timedelta formatted according to the given string.
You should use global setting ``TIMEDELTA_FORMAT`` to specify default
format to this function there (like ``DATE_FORMAT`` for builtin ``date``
template filter).
Default value for ``TIMEDELTA_FORMAT`` is ``'G:i'``.
Format uses the same... | [
"Display",
"the",
"timedelta",
"formatted",
"according",
"to",
"the",
"given",
"string",
"."
] | train | https://github.com/playpauseandstop/rororo/blob/28a04e8028c29647941e727116335e9d6fd64c27/rororo/timedelta.py#L191-L438 |
OSSOS/MOP | src/ossos/core/ossos/pipeline.py | align | def align(expnums, ccd, version='s', dry_run=False):
"""Create a 'shifts' file that transforms the space/flux/time scale of all images to the first image.
This function relies on the .fwhm, .trans.jmp, .phot and .zeropoint.used files for inputs.
The scaling we are computing here is for use in planting sour... | python | def align(expnums, ccd, version='s', dry_run=False):
"""Create a 'shifts' file that transforms the space/flux/time scale of all images to the first image.
This function relies on the .fwhm, .trans.jmp, .phot and .zeropoint.used files for inputs.
The scaling we are computing here is for use in planting sour... | [
"def",
"align",
"(",
"expnums",
",",
"ccd",
",",
"version",
"=",
"'s'",
",",
"dry_run",
"=",
"False",
")",
":",
"# Get the images and supporting files that we need from the VOSpace area",
"# get_image and get_file check if the image/file is already on disk.",
"# re-computed fluxe... | Create a 'shifts' file that transforms the space/flux/time scale of all images to the first image.
This function relies on the .fwhm, .trans.jmp, .phot and .zeropoint.used files for inputs.
The scaling we are computing here is for use in planting sources into the image at the same sky/flux locations
while ... | [
"Create",
"a",
"shifts",
"file",
"that",
"transforms",
"the",
"space",
"/",
"flux",
"/",
"time",
"scale",
"of",
"all",
"images",
"to",
"the",
"first",
"image",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/pipeline.py#L21-L149 |
OSSOS/MOP | src/ossos/core/ossos/plant.py | Range.dist | def dist(self):
"""
How should the values in range be sampled, uniformly or via some function.
:return:
"""
if self.func is None:
return random.uniform(self.min, self.max)
if self._dist is None:
x = numpy.arange(self.min, self.max, (self.max-self.m... | python | def dist(self):
"""
How should the values in range be sampled, uniformly or via some function.
:return:
"""
if self.func is None:
return random.uniform(self.min, self.max)
if self._dist is None:
x = numpy.arange(self.min, self.max, (self.max-self.m... | [
"def",
"dist",
"(",
"self",
")",
":",
"if",
"self",
".",
"func",
"is",
"None",
":",
"return",
"random",
".",
"uniform",
"(",
"self",
".",
"min",
",",
"self",
".",
"max",
")",
"if",
"self",
".",
"_dist",
"is",
"None",
":",
"x",
"=",
"numpy",
"."... | How should the values in range be sampled, uniformly or via some function.
:return: | [
"How",
"should",
"the",
"values",
"in",
"range",
"be",
"sampled",
"uniformly",
"or",
"via",
"some",
"function",
".",
":",
"return",
":"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/plant.py#L57-L70 |
OSSOS/MOP | src/ossos/core/ossos/plant.py | KBOGenerator.next | def next(self):
"""
:return: a set of values that can be used for an planted object builder.
"""
# x y mag pix rate angle ''/h rate id
# 912.48 991.06 22.01 57.32 -45.23 10.60 0
self._n -= 1
if self._n... | python | def next(self):
"""
:return: a set of values that can be used for an planted object builder.
"""
# x y mag pix rate angle ''/h rate id
# 912.48 991.06 22.01 57.32 -45.23 10.60 0
self._n -= 1
if self._n... | [
"def",
"next",
"(",
"self",
")",
":",
"# x y mag pix rate angle ''/h rate id",
"# 912.48 991.06 22.01 57.32 -45.23 10.60 0",
"self",
".",
"_n",
"-=",
"1",
"if",
"self",
".",
"_n",
"<",
"0",
":",
"raise",
"StopIt... | :return: a set of values that can be used for an planted object builder. | [
":",
"return",
":",
"a",
"set",
"of",
"values",
"that",
"can",
"be",
"used",
"for",
"an",
"planted",
"object",
"builder",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/plant.py#L114-L124 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.send_command | def send_command(self, cmd, params=None, raw=False):
'''
Send command to foscam.
'''
paramstr = ''
if params:
paramstr = urlencode(params)
paramstr = '&' + paramstr if paramstr else ''
cmdurl = 'http://%s/cgi-bin/CGIProxy.fcgi?usr=%s&pwd=%s&cmd=%s%... | python | def send_command(self, cmd, params=None, raw=False):
'''
Send command to foscam.
'''
paramstr = ''
if params:
paramstr = urlencode(params)
paramstr = '&' + paramstr if paramstr else ''
cmdurl = 'http://%s/cgi-bin/CGIProxy.fcgi?usr=%s&pwd=%s&cmd=%s%... | [
"def",
"send_command",
"(",
"self",
",",
"cmd",
",",
"params",
"=",
"None",
",",
"raw",
"=",
"False",
")",
":",
"paramstr",
"=",
"''",
"if",
"params",
":",
"paramstr",
"=",
"urlencode",
"(",
"params",
")",
"paramstr",
"=",
"'&'",
"+",
"paramstr",
"if... | Send command to foscam. | [
"Send",
"command",
"to",
"foscam",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L74-L122 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.execute_command | def execute_command(self, cmd, params=None, callback=None, raw=False):
'''
Execute a command and return a parsed response.
'''
def execute_with_callbacks(cmd, params=None, callback=None, raw=False):
code, params = self.send_command(cmd, params, raw)
if callback:
... | python | def execute_command(self, cmd, params=None, callback=None, raw=False):
'''
Execute a command and return a parsed response.
'''
def execute_with_callbacks(cmd, params=None, callback=None, raw=False):
code, params = self.send_command(cmd, params, raw)
if callback:
... | [
"def",
"execute_command",
"(",
"self",
",",
"cmd",
",",
"params",
"=",
"None",
",",
"callback",
"=",
"None",
",",
"raw",
"=",
"False",
")",
":",
"def",
"execute_with_callbacks",
"(",
"cmd",
",",
"params",
"=",
"None",
",",
"callback",
"=",
"None",
",",... | Execute a command and return a parsed response. | [
"Execute",
"a",
"command",
"and",
"return",
"a",
"parsed",
"response",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L124-L140 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_ip_info | def set_ip_info(self, is_dhcp, ip='', gate='', mask='',
dns1='', dns2='', callback=None):
'''
isDHCP: 0(False), 1(True)
System will reboot automatically to take effect after call this CGI command.
'''
params = {'isDHCP': is_dhcp,
... | python | def set_ip_info(self, is_dhcp, ip='', gate='', mask='',
dns1='', dns2='', callback=None):
'''
isDHCP: 0(False), 1(True)
System will reboot automatically to take effect after call this CGI command.
'''
params = {'isDHCP': is_dhcp,
... | [
"def",
"set_ip_info",
"(",
"self",
",",
"is_dhcp",
",",
"ip",
"=",
"''",
",",
"gate",
"=",
"''",
",",
"mask",
"=",
"''",
",",
"dns1",
"=",
"''",
",",
"dns2",
"=",
"''",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'isDHCP'",
":"... | isDHCP: 0(False), 1(True)
System will reboot automatically to take effect after call this CGI command. | [
"isDHCP",
":",
"0",
"(",
"False",
")",
"1",
"(",
"True",
")",
"System",
"will",
"reboot",
"automatically",
"to",
"take",
"effect",
"after",
"call",
"this",
"CGI",
"command",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L150-L164 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_port_info | def set_port_info(self, webport, mediaport, httpsport,
onvifport, callback=None):
'''
Set http port and media port of camera.
'''
params = {'webPort' : webport,
'mediaPort' : mediaport,
'httpsPort' : httpsport,
... | python | def set_port_info(self, webport, mediaport, httpsport,
onvifport, callback=None):
'''
Set http port and media port of camera.
'''
params = {'webPort' : webport,
'mediaPort' : mediaport,
'httpsPort' : httpsport,
... | [
"def",
"set_port_info",
"(",
"self",
",",
"webport",
",",
"mediaport",
",",
"httpsport",
",",
"onvifport",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'webPort'",
":",
"webport",
",",
"'mediaPort'",
":",
"mediaport",
",",
"'httpsPort'",
":... | Set http port and media port of camera. | [
"Set",
"http",
"port",
"and",
"media",
"port",
"of",
"camera",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L172-L182 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.get_wifi_list | def get_wifi_list(self, startno, callback=None):
'''
Get the aps around after refreshWifiList.
Note: Only 10 aps will be returned one time.
'''
params = {'startNo': startno}
return self.execute_command('getWifiList', params, callback=callback) | python | def get_wifi_list(self, startno, callback=None):
'''
Get the aps around after refreshWifiList.
Note: Only 10 aps will be returned one time.
'''
params = {'startNo': startno}
return self.execute_command('getWifiList', params, callback=callback) | [
"def",
"get_wifi_list",
"(",
"self",
",",
"startno",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'startNo'",
":",
"startno",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'getWifiList'",
",",
"params",
",",
"callback",
"=",
"callbac... | Get the aps around after refreshWifiList.
Note: Only 10 aps will be returned one time. | [
"Get",
"the",
"aps",
"around",
"after",
"refreshWifiList",
".",
"Note",
":",
"Only",
"10",
"aps",
"will",
"be",
"returned",
"one",
"time",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L192-L198 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_wifi_setting | def set_wifi_setting(self, ssid, psk, isenable, isusewifi, nettype,
encryptype, authmode, keyformat, defaultkey,
key1='', key2='', key3='', key4='',
key1len=64, key2len=64, key3len=64, key4len=64,
callback=No... | python | def set_wifi_setting(self, ssid, psk, isenable, isusewifi, nettype,
encryptype, authmode, keyformat, defaultkey,
key1='', key2='', key3='', key4='',
key1len=64, key2len=64, key3len=64, key4len=64,
callback=No... | [
"def",
"set_wifi_setting",
"(",
"self",
",",
"ssid",
",",
"psk",
",",
"isenable",
",",
"isusewifi",
",",
"nettype",
",",
"encryptype",
",",
"authmode",
",",
"keyformat",
",",
"defaultkey",
",",
"key1",
"=",
"''",
",",
"key2",
"=",
"''",
",",
"key3",
"=... | Set wifi config.
Camera will not connect to AP unless you enject your cable. | [
"Set",
"wifi",
"config",
".",
"Camera",
"will",
"not",
"connect",
"to",
"AP",
"unless",
"you",
"enject",
"your",
"cable",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L200-L227 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_upnp_config | def set_upnp_config(self, isenable, callback=None):
'''
Set UPnP config
'''
params = {'isEnable': isenable}
return self.execute_command('setUPnPConfig', params, callback=callback) | python | def set_upnp_config(self, isenable, callback=None):
'''
Set UPnP config
'''
params = {'isEnable': isenable}
return self.execute_command('setUPnPConfig', params, callback=callback) | [
"def",
"set_upnp_config",
"(",
"self",
",",
"isenable",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'isEnable'",
":",
"isenable",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'setUPnPConfig'",
",",
"params",
",",
"callback",
"=",
"... | Set UPnP config | [
"Set",
"UPnP",
"config"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L241-L246 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_ddns_config | def set_ddns_config(self, isenable, hostname, ddnsserver,
user, password, callback=None):
'''
Set DDNS config.
'''
params = {'isEnable': isenable,
'hostName': hostname,
'ddnsServer': ddnsserver,
... | python | def set_ddns_config(self, isenable, hostname, ddnsserver,
user, password, callback=None):
'''
Set DDNS config.
'''
params = {'isEnable': isenable,
'hostName': hostname,
'ddnsServer': ddnsserver,
... | [
"def",
"set_ddns_config",
"(",
"self",
",",
"isenable",
",",
"hostname",
",",
"ddnsserver",
",",
"user",
",",
"password",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'isEnable'",
":",
"isenable",
",",
"'hostName'",
":",
"hostname",
",",
... | Set DDNS config. | [
"Set",
"DDNS",
"config",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L254-L265 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_sub_video_stream_type | def set_sub_video_stream_type(self, format, callback=None):
'''
Set the stream fromat of sub stream.
Supported format: (1) H264 : 0
(2) MotionJpeg 1
'''
params = {'format': format}
return self.execute_command('setSubVideoStreamType',
... | python | def set_sub_video_stream_type(self, format, callback=None):
'''
Set the stream fromat of sub stream.
Supported format: (1) H264 : 0
(2) MotionJpeg 1
'''
params = {'format': format}
return self.execute_command('setSubVideoStreamType',
... | [
"def",
"set_sub_video_stream_type",
"(",
"self",
",",
"format",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'format'",
":",
"format",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'setSubVideoStreamType'",
",",
"params",
",",
"callback"... | Set the stream fromat of sub stream.
Supported format: (1) H264 : 0
(2) MotionJpeg 1 | [
"Set",
"the",
"stream",
"fromat",
"of",
"sub",
"stream",
".",
"Supported",
"format",
":",
"(",
"1",
")",
"H264",
":",
"0",
"(",
"2",
")",
"MotionJpeg",
"1"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L276-L284 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_sub_stream_format | def set_sub_stream_format(self, format, callback=None):
'''
Set the stream fromat of sub stream????
'''
params = {'format': format}
return self.execute_command('setSubStreamFormat',
params, callback=callback) | python | def set_sub_stream_format(self, format, callback=None):
'''
Set the stream fromat of sub stream????
'''
params = {'format': format}
return self.execute_command('setSubStreamFormat',
params, callback=callback) | [
"def",
"set_sub_stream_format",
"(",
"self",
",",
"format",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'format'",
":",
"format",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'setSubStreamFormat'",
",",
"params",
",",
"callback",
"="... | Set the stream fromat of sub stream???? | [
"Set",
"the",
"stream",
"fromat",
"of",
"sub",
"stream????"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L286-L292 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_main_video_stream_type | def set_main_video_stream_type(self, streamtype, callback=None):
'''
Set the stream type of main stream
'''
params = {'streamType': streamtype}
return self.execute_command('setMainVideoStreamType',
params, callback=callback) | python | def set_main_video_stream_type(self, streamtype, callback=None):
'''
Set the stream type of main stream
'''
params = {'streamType': streamtype}
return self.execute_command('setMainVideoStreamType',
params, callback=callback) | [
"def",
"set_main_video_stream_type",
"(",
"self",
",",
"streamtype",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'streamType'",
":",
"streamtype",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'setMainVideoStreamType'",
",",
"params",
","... | Set the stream type of main stream | [
"Set",
"the",
"stream",
"type",
"of",
"main",
"stream"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L300-L306 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_video_stream_param | def set_video_stream_param(self, streamtype, resolution, bitrate,
framerate, gop, isvbr, callback=None):
'''
Set the video stream param of stream N
streamtype(0~3): Stream N.
resolution(0~4): 0 720P,
1 VGA(640*480),
2 VGA(640*... | python | def set_video_stream_param(self, streamtype, resolution, bitrate,
framerate, gop, isvbr, callback=None):
'''
Set the video stream param of stream N
streamtype(0~3): Stream N.
resolution(0~4): 0 720P,
1 VGA(640*480),
2 VGA(640*... | [
"def",
"set_video_stream_param",
"(",
"self",
",",
"streamtype",
",",
"resolution",
",",
"bitrate",
",",
"framerate",
",",
"gop",
",",
"isvbr",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'streamType'",
":",
"streamtype",
",",
"'resolution'"... | Set the video stream param of stream N
streamtype(0~3): Stream N.
resolution(0~4): 0 720P,
1 VGA(640*480),
2 VGA(640*360),
3 QVGA(320*240),
4 QVGA(320*180).
bitrate: Bit rate of stream type N(2048... | [
"Set",
"the",
"video",
"stream",
"param",
"of",
"stream",
"N",
"streamtype",
"(",
"0~3",
")",
":",
"Stream",
"N",
".",
"resolution",
"(",
"0~4",
")",
":",
"0",
"720P",
"1",
"VGA",
"(",
"640",
"*",
"480",
")",
"2",
"VGA",
"(",
"640",
"*",
"360",
... | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L314-L338 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.mirror_video | def mirror_video(self, is_mirror, callback=None):
'''
Mirror video
``is_mirror``: 0 not mirror, 1 mirror
'''
params = {'isMirror': is_mirror}
return self.execute_command('mirrorVideo', params, callback=callback) | python | def mirror_video(self, is_mirror, callback=None):
'''
Mirror video
``is_mirror``: 0 not mirror, 1 mirror
'''
params = {'isMirror': is_mirror}
return self.execute_command('mirrorVideo', params, callback=callback) | [
"def",
"mirror_video",
"(",
"self",
",",
"is_mirror",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'isMirror'",
":",
"is_mirror",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'mirrorVideo'",
",",
"params",
",",
"callback",
"=",
"cal... | Mirror video
``is_mirror``: 0 not mirror, 1 mirror | [
"Mirror",
"video",
"is_mirror",
":",
"0",
"not",
"mirror",
"1",
"mirror"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L340-L346 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.flip_video | def flip_video(self, is_flip, callback=None):
'''
Flip video
``is_flip``: 0 Not flip, 1 Flip
'''
params = {'isFlip': is_flip }
return self.execute_command('flipVideo', params, callback=callback) | python | def flip_video(self, is_flip, callback=None):
'''
Flip video
``is_flip``: 0 Not flip, 1 Flip
'''
params = {'isFlip': is_flip }
return self.execute_command('flipVideo', params, callback=callback) | [
"def",
"flip_video",
"(",
"self",
",",
"is_flip",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'isFlip'",
":",
"is_flip",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'flipVideo'",
",",
"params",
",",
"callback",
"=",
"callback",
... | Flip video
``is_flip``: 0 Not flip, 1 Flip | [
"Flip",
"video",
"is_flip",
":",
"0",
"Not",
"flip",
"1",
"Flip"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L348-L354 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.change_user_name | def change_user_name(self, usrname, newusrname, callback=None):
'''
Change user name.
'''
params = {'usrName': usrname,
'newUsrName': newusrname,
}
return self.execute_command('changeUserName', params, callback=callback) | python | def change_user_name(self, usrname, newusrname, callback=None):
'''
Change user name.
'''
params = {'usrName': usrname,
'newUsrName': newusrname,
}
return self.execute_command('changeUserName', params, callback=callback) | [
"def",
"change_user_name",
"(",
"self",
",",
"usrname",
",",
"newusrname",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'usrName'",
":",
"usrname",
",",
"'newUsrName'",
":",
"newusrname",
",",
"}",
"return",
"self",
".",
"execute_command",
... | Change user name. | [
"Change",
"user",
"name",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L363-L370 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.change_password | def change_password(self, usrname, oldpwd, newpwd, callback=None):
'''
Change password.
'''
params = {'usrName': usrname,
'oldPwd' : oldpwd,
'newPwd' : newpwd,
}
return self.execute_command('changePassword',
... | python | def change_password(self, usrname, oldpwd, newpwd, callback=None):
'''
Change password.
'''
params = {'usrName': usrname,
'oldPwd' : oldpwd,
'newPwd' : newpwd,
}
return self.execute_command('changePassword',
... | [
"def",
"change_password",
"(",
"self",
",",
"usrname",
",",
"oldpwd",
",",
"newpwd",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'usrName'",
":",
"usrname",
",",
"'oldPwd'",
":",
"oldpwd",
",",
"'newPwd'",
":",
"newpwd",
",",
"}",
"ret... | Change password. | [
"Change",
"password",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L372-L381 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_system_time | def set_system_time(self, time_source, ntp_server, date_format,
time_format, time_zone, is_dst, dst, year,
mon, day, hour, minute, sec, callback=None):
'''
Set systeim time
'''
if ntp_server not in ['time.nist.gov',
... | python | def set_system_time(self, time_source, ntp_server, date_format,
time_format, time_zone, is_dst, dst, year,
mon, day, hour, minute, sec, callback=None):
'''
Set systeim time
'''
if ntp_server not in ['time.nist.gov',
... | [
"def",
"set_system_time",
"(",
"self",
",",
"time_source",
",",
"ntp_server",
",",
"date_format",
",",
"time_format",
",",
"time_zone",
",",
"is_dst",
",",
"dst",
",",
"year",
",",
"mon",
",",
"day",
",",
"hour",
",",
"minute",
",",
"sec",
",",
"callback... | Set systeim time | [
"Set",
"systeim",
"time"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L385-L413 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_dev_name | def set_dev_name(self, devname, callback=None):
'''
Set camera name
'''
params = {'devName': devname.encode('gbk')}
return self.execute_command('setDevName', params, callback=callback) | python | def set_dev_name(self, devname, callback=None):
'''
Set camera name
'''
params = {'devName': devname.encode('gbk')}
return self.execute_command('setDevName', params, callback=callback) | [
"def",
"set_dev_name",
"(",
"self",
",",
"devname",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'devName'",
":",
"devname",
".",
"encode",
"(",
"'gbk'",
")",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'setDevName'",
",",
"param... | Set camera name | [
"Set",
"camera",
"name"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L427-L432 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_infra_led_config | def set_infra_led_config(self, mode, callback=None):
'''
Set Infrared LED configuration
cmd: setInfraLedConfig
mode(0,1): 0=Auto mode, 1=Manual mode
'''
params = {'mode': mode}
return self.execute_command('setInfraLedConfig', params, callback=callback) | python | def set_infra_led_config(self, mode, callback=None):
'''
Set Infrared LED configuration
cmd: setInfraLedConfig
mode(0,1): 0=Auto mode, 1=Manual mode
'''
params = {'mode': mode}
return self.execute_command('setInfraLedConfig', params, callback=callback) | [
"def",
"set_infra_led_config",
"(",
"self",
",",
"mode",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'mode'",
":",
"mode",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'setInfraLedConfig'",
",",
"params",
",",
"callback",
"=",
"cal... | Set Infrared LED configuration
cmd: setInfraLedConfig
mode(0,1): 0=Auto mode, 1=Manual mode | [
"Set",
"Infrared",
"LED",
"configuration",
"cmd",
":",
"setInfraLedConfig",
"mode",
"(",
"0",
"1",
")",
":",
"0",
"=",
"Auto",
"mode",
"1",
"=",
"Manual",
"mode"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L476-L483 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.ptz_goto_preset | def ptz_goto_preset(self, name, callback=None):
'''
Move to preset.
'''
params = {'name': name}
return self.execute_command('ptzGotoPresetPoint', params, callback=callback) | python | def ptz_goto_preset(self, name, callback=None):
'''
Move to preset.
'''
params = {'name': name}
return self.execute_command('ptzGotoPresetPoint', params, callback=callback) | [
"def",
"ptz_goto_preset",
"(",
"self",
",",
"name",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'name'",
":",
"name",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'ptzGotoPresetPoint'",
",",
"params",
",",
"callback",
"=",
"callbac... | Move to preset. | [
"Move",
"to",
"preset",
"."
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L560-L565 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_motion_detection | def set_motion_detection(self, enabled=1):
'''
Get the current config and set the motion detection on or off
'''
result, current_config = self.get_motion_detect_config()
if result != FOSCAM_SUCCESS:
return result
current_config['isEnable'] = enabled
se... | python | def set_motion_detection(self, enabled=1):
'''
Get the current config and set the motion detection on or off
'''
result, current_config = self.get_motion_detect_config()
if result != FOSCAM_SUCCESS:
return result
current_config['isEnable'] = enabled
se... | [
"def",
"set_motion_detection",
"(",
"self",
",",
"enabled",
"=",
"1",
")",
":",
"result",
",",
"current_config",
"=",
"self",
".",
"get_motion_detect_config",
"(",
")",
"if",
"result",
"!=",
"FOSCAM_SUCCESS",
":",
"return",
"result",
"current_config",
"[",
"'i... | Get the current config and set the motion detection on or off | [
"Get",
"the",
"current",
"config",
"and",
"set",
"the",
"motion",
"detection",
"on",
"or",
"off"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L618-L627 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_motion_detection1 | def set_motion_detection1(self, enabled=1):
'''
Get the current config and set the motion detection on or off
'''
result, current_config = self.get_motion_detect_config1()
if result != FOSCAM_SUCCESS:
return result
current_config['isEnable'] = enabled
... | python | def set_motion_detection1(self, enabled=1):
'''
Get the current config and set the motion detection on or off
'''
result, current_config = self.get_motion_detect_config1()
if result != FOSCAM_SUCCESS:
return result
current_config['isEnable'] = enabled
... | [
"def",
"set_motion_detection1",
"(",
"self",
",",
"enabled",
"=",
"1",
")",
":",
"result",
",",
"current_config",
"=",
"self",
".",
"get_motion_detect_config1",
"(",
")",
"if",
"result",
"!=",
"FOSCAM_SUCCESS",
":",
"return",
"result",
"current_config",
"[",
"... | Get the current config and set the motion detection on or off | [
"Get",
"the",
"current",
"config",
"and",
"set",
"the",
"motion",
"detection",
"on",
"or",
"off"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L656-L664 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_alarm_record_config | def set_alarm_record_config(self, is_enable_prerecord=1,
prerecord_secs=5, alarm_record_secs=300, callback=None):
'''
Set alarm record config
Return: set result(0-success, -1-error)
'''
params = {'isEnablePreRecord': is_enable_prerecord,
... | python | def set_alarm_record_config(self, is_enable_prerecord=1,
prerecord_secs=5, alarm_record_secs=300, callback=None):
'''
Set alarm record config
Return: set result(0-success, -1-error)
'''
params = {'isEnablePreRecord': is_enable_prerecord,
... | [
"def",
"set_alarm_record_config",
"(",
"self",
",",
"is_enable_prerecord",
"=",
"1",
",",
"prerecord_secs",
"=",
"5",
",",
"alarm_record_secs",
"=",
"300",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'isEnablePreRecord'",
":",
"is_enable_prereco... | Set alarm record config
Return: set result(0-success, -1-error) | [
"Set",
"alarm",
"record",
"config",
"Return",
":",
"set",
"result",
"(",
"0",
"-",
"success",
"-",
"1",
"-",
"error",
")"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L685-L695 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_local_alarm_record_config | def set_local_alarm_record_config(self, is_enable_local_alarm_record = 1,
local_alarm_record_secs = 30, callback=None):
'''
Set local alarm-record config
`is_enable_local_alarm_record`: 0 disable, 1 enable
'''
params = {'isEnableLocalAlarmRec... | python | def set_local_alarm_record_config(self, is_enable_local_alarm_record = 1,
local_alarm_record_secs = 30, callback=None):
'''
Set local alarm-record config
`is_enable_local_alarm_record`: 0 disable, 1 enable
'''
params = {'isEnableLocalAlarmRec... | [
"def",
"set_local_alarm_record_config",
"(",
"self",
",",
"is_enable_local_alarm_record",
"=",
"1",
",",
"local_alarm_record_secs",
"=",
"30",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'isEnableLocalAlarmRecord'",
":",
"is_enable_local_alarm_record",
... | Set local alarm-record config
`is_enable_local_alarm_record`: 0 disable, 1 enable | [
"Set",
"local",
"alarm",
"-",
"record",
"config",
"is_enable_local_alarm_record",
":",
"0",
"disable",
"1",
"enable"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L703-L711 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_h264_frm_ref_mode | def set_h264_frm_ref_mode(self, mode=1, callback=None):
'''
Set frame shipping reference mode of H264 encode stream.
params:
`mode`: see docstr of meth::get_h264_frm_ref_mode
'''
params = {'mode': mode}
return self.execute_command('setH264FrmRefMode', params, ... | python | def set_h264_frm_ref_mode(self, mode=1, callback=None):
'''
Set frame shipping reference mode of H264 encode stream.
params:
`mode`: see docstr of meth::get_h264_frm_ref_mode
'''
params = {'mode': mode}
return self.execute_command('setH264FrmRefMode', params, ... | [
"def",
"set_h264_frm_ref_mode",
"(",
"self",
",",
"mode",
"=",
"1",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'mode'",
":",
"mode",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'setH264FrmRefMode'",
",",
"params",
",",
"callback"... | Set frame shipping reference mode of H264 encode stream.
params:
`mode`: see docstr of meth::get_h264_frm_ref_mode | [
"Set",
"frame",
"shipping",
"reference",
"mode",
"of",
"H264",
"encode",
"stream",
".",
"params",
":",
"mode",
":",
"see",
"docstr",
"of",
"meth",
"::",
"get_h264_frm_ref_mode"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L722-L729 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_schedule_record_config | def set_schedule_record_config(self, is_enable, record_level,
space_full_mode, is_enable_audio,
schedule0 = 0, schedule1 = 0, schedule2 = 0,
schedule3 = 0, schedule4 = 0, schedule5 = 0,
... | python | def set_schedule_record_config(self, is_enable, record_level,
space_full_mode, is_enable_audio,
schedule0 = 0, schedule1 = 0, schedule2 = 0,
schedule3 = 0, schedule4 = 0, schedule5 = 0,
... | [
"def",
"set_schedule_record_config",
"(",
"self",
",",
"is_enable",
",",
"record_level",
",",
"space_full_mode",
",",
"is_enable_audio",
",",
"schedule0",
"=",
"0",
",",
"schedule1",
"=",
"0",
",",
"schedule2",
"=",
"0",
",",
"schedule3",
"=",
"0",
",",
"sch... | Set schedule record config.
cmd: setScheduleRecordConfig
args: See docstring of meth::get_schedule_record_config | [
"Set",
"schedule",
"record",
"config",
".",
"cmd",
":",
"setScheduleRecordConfig",
"args",
":",
"See",
"docstring",
"of",
"meth",
"::",
"get_schedule_record_config"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L744-L767 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.set_record_path | def set_record_path(self, path, callback=None):
'''
Set Record path: sd/ftp
cmd: setRecordPath
param:
path: (0,SD), (2, FTP)
'''
params = {'Path': path}
return self.execute_command('setRecordPath', params, callback=callback) | python | def set_record_path(self, path, callback=None):
'''
Set Record path: sd/ftp
cmd: setRecordPath
param:
path: (0,SD), (2, FTP)
'''
params = {'Path': path}
return self.execute_command('setRecordPath', params, callback=callback) | [
"def",
"set_record_path",
"(",
"self",
",",
"path",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'Path'",
":",
"path",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'setRecordPath'",
",",
"params",
",",
"callback",
"=",
"callback",
... | Set Record path: sd/ftp
cmd: setRecordPath
param:
path: (0,SD), (2, FTP) | [
"Set",
"Record",
"path",
":",
"sd",
"/",
"ftp",
"cmd",
":",
"setRecordPath",
"param",
":",
"path",
":",
"(",
"0",
"SD",
")",
"(",
"2",
"FTP",
")"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L780-L788 |
viswa-swami/python-foscam | libpyfoscam/foscam.py | FoscamCamera.get_log | def get_log(self, offset, count=10, callback=None):
'''
Retrieve log records from camera.
cmd: getLog
param:
offset: log offset for first record
count: number of records to return
'''
params = {'offset': offset, 'count': count}
return self.ex... | python | def get_log(self, offset, count=10, callback=None):
'''
Retrieve log records from camera.
cmd: getLog
param:
offset: log offset for first record
count: number of records to return
'''
params = {'offset': offset, 'count': count}
return self.ex... | [
"def",
"get_log",
"(",
"self",
",",
"offset",
",",
"count",
"=",
"10",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'offset'",
":",
"offset",
",",
"'count'",
":",
"count",
"}",
"return",
"self",
".",
"execute_command",
"(",
"'getLog'",
... | Retrieve log records from camera.
cmd: getLog
param:
offset: log offset for first record
count: number of records to return | [
"Retrieve",
"log",
"records",
"from",
"camera",
".",
"cmd",
":",
"getLog",
"param",
":",
"offset",
":",
"log",
"offset",
"for",
"first",
"record",
"count",
":",
"number",
"of",
"records",
"to",
"return"
] | train | https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L815-L824 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | get_apcor | def get_apcor(expnum, ccd, version='p', prefix=None):
"""
retrieve the aperture correction for this exposure
@param expnum:
@param ccd:
@param version:
@param prefix:
@return:
"""
uri = get_uri(expnum, ccd, ext=APCOR_EXT, version=version, prefix=prefix)
apcor_file_name = tempfile... | python | def get_apcor(expnum, ccd, version='p', prefix=None):
"""
retrieve the aperture correction for this exposure
@param expnum:
@param ccd:
@param version:
@param prefix:
@return:
"""
uri = get_uri(expnum, ccd, ext=APCOR_EXT, version=version, prefix=prefix)
apcor_file_name = tempfile... | [
"def",
"get_apcor",
"(",
"expnum",
",",
"ccd",
",",
"version",
"=",
"'p'",
",",
"prefix",
"=",
"None",
")",
":",
"uri",
"=",
"get_uri",
"(",
"expnum",
",",
"ccd",
",",
"ext",
"=",
"APCOR_EXT",
",",
"version",
"=",
"version",
",",
"prefix",
"=",
"pr... | retrieve the aperture correction for this exposure
@param expnum:
@param ccd:
@param version:
@param prefix:
@return: | [
"retrieve",
"the",
"aperture",
"correction",
"for",
"this",
"exposure"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L108-L121 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | cone_search | def cone_search(ra, dec, dra=0.01, ddec=0.01, mjdate=None, calibration_level=2, use_ssos=True,
collection='CFHTMEGAPIPE'):
"""Do a QUERY on the TAP service for all observations that are part of OSSOS (*P05/*P016)
where taken after mjd and have calibration 'observable'.
@param ra: RA center ... | python | def cone_search(ra, dec, dra=0.01, ddec=0.01, mjdate=None, calibration_level=2, use_ssos=True,
collection='CFHTMEGAPIPE'):
"""Do a QUERY on the TAP service for all observations that are part of OSSOS (*P05/*P016)
where taken after mjd and have calibration 'observable'.
@param ra: RA center ... | [
"def",
"cone_search",
"(",
"ra",
",",
"dec",
",",
"dra",
"=",
"0.01",
",",
"ddec",
"=",
"0.01",
",",
"mjdate",
"=",
"None",
",",
"calibration_level",
"=",
"2",
",",
"use_ssos",
"=",
"True",
",",
"collection",
"=",
"'CFHTMEGAPIPE'",
")",
":",
"if",
"u... | Do a QUERY on the TAP service for all observations that are part of OSSOS (*P05/*P016)
where taken after mjd and have calibration 'observable'.
@param ra: RA center of search cont
@type ra: Quantity
@param dec: float degrees
@type dec: Quantity
@param dra: float degrees
@type dra: Quantity
... | [
"Do",
"a",
"QUERY",
"on",
"the",
"TAP",
"service",
"for",
"all",
"observations",
"that",
"are",
"part",
"of",
"OSSOS",
"(",
"*",
"P05",
"/",
"*",
"P016",
")",
"where",
"taken",
"after",
"mjd",
"and",
"have",
"calibration",
"observable",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L138-L212 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | populate | def populate(dataset_name, data_web_service_url=DATA_WEB_SERVICE + "CFHT"):
"""Given a dataset_name created the desired dbimages directories
and links to the raw data files stored at CADC.
@param dataset_name: the name of the CFHT dataset to make a link to.
@param data_web_servica_url: the URL of the da... | python | def populate(dataset_name, data_web_service_url=DATA_WEB_SERVICE + "CFHT"):
"""Given a dataset_name created the desired dbimages directories
and links to the raw data files stored at CADC.
@param dataset_name: the name of the CFHT dataset to make a link to.
@param data_web_servica_url: the URL of the da... | [
"def",
"populate",
"(",
"dataset_name",
",",
"data_web_service_url",
"=",
"DATA_WEB_SERVICE",
"+",
"\"CFHT\"",
")",
":",
"data_dest",
"=",
"get_uri",
"(",
"dataset_name",
",",
"version",
"=",
"'o'",
",",
"ext",
"=",
"FITS_EXT",
")",
"data_source",
"=",
"\"%s/%... | Given a dataset_name created the desired dbimages directories
and links to the raw data files stored at CADC.
@param dataset_name: the name of the CFHT dataset to make a link to.
@param data_web_servica_url: the URL of the data web service run by CADC. | [
"Given",
"a",
"dataset_name",
"created",
"the",
"desired",
"dbimages",
"directories",
"and",
"links",
"to",
"the",
"raw",
"data",
"files",
"stored",
"at",
"CADC",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L215-L257 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | get_cands_uri | def get_cands_uri(field, ccd, version='p', ext='measure3.cands.astrom', prefix=None,
block=None):
"""
return the nominal URI for a candidate file.
@param field: the OSSOS field name
@param ccd: which CCD are the candidates on
@param version: either the 'p', or 's' (scrambled) ... | python | def get_cands_uri(field, ccd, version='p', ext='measure3.cands.astrom', prefix=None,
block=None):
"""
return the nominal URI for a candidate file.
@param field: the OSSOS field name
@param ccd: which CCD are the candidates on
@param version: either the 'p', or 's' (scrambled) ... | [
"def",
"get_cands_uri",
"(",
"field",
",",
"ccd",
",",
"version",
"=",
"'p'",
",",
"ext",
"=",
"'measure3.cands.astrom'",
",",
"prefix",
"=",
"None",
",",
"block",
"=",
"None",
")",
":",
"if",
"prefix",
"is",
"None",
":",
"prefix",
"=",
"\"\"",
"if",
... | return the nominal URI for a candidate file.
@param field: the OSSOS field name
@param ccd: which CCD are the candidates on
@param version: either the 'p', or 's' (scrambled) candidates.
@param ext: Perhaps we'll change this one day.
@param prefix: if this is a 'fake' dataset then add 'fk'
@par... | [
"return",
"the",
"nominal",
"URI",
"for",
"a",
"candidate",
"file",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L260-L289 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | get_uri | def get_uri(expnum, ccd=None,
version='p', ext=FITS_EXT,
subdir=None, prefix=None):
"""
Build the uri for an OSSOS image stored in the dbimages
containerNode.
:rtype : basestring
expnum: CFHT exposure number
ccd: CCD in the mosaic [0-35]
version: one of p,s,o etc.
... | python | def get_uri(expnum, ccd=None,
version='p', ext=FITS_EXT,
subdir=None, prefix=None):
"""
Build the uri for an OSSOS image stored in the dbimages
containerNode.
:rtype : basestring
expnum: CFHT exposure number
ccd: CCD in the mosaic [0-35]
version: one of p,s,o etc.
... | [
"def",
"get_uri",
"(",
"expnum",
",",
"ccd",
"=",
"None",
",",
"version",
"=",
"'p'",
",",
"ext",
"=",
"FITS_EXT",
",",
"subdir",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"subdir",
"is",
"None",
":",
"subdir",
"=",
"str",
"(",
"ex... | Build the uri for an OSSOS image stored in the dbimages
containerNode.
:rtype : basestring
expnum: CFHT exposure number
ccd: CCD in the mosaic [0-35]
version: one of p,s,o etc.
dbimages: dbimages containerNode.
@type subdir: str
@param expnum: int
@param ccd:
@param version:
... | [
"Build",
"the",
"uri",
"for",
"an",
"OSSOS",
"image",
"stored",
"in",
"the",
"dbimages",
"containerNode",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L292-L340 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | get_tag | def get_tag(expnum, key):
"""given a key, return the vospace tag value.
@param expnum: Number of the CFHT exposure that a tag value is needed for
@param key: The process tag (such as mkpsf_00) that is being looked up.
@return: the value of the tag
@rtype: str
"""
uri = tag_uri(key)
for... | python | def get_tag(expnum, key):
"""given a key, return the vospace tag value.
@param expnum: Number of the CFHT exposure that a tag value is needed for
@param key: The process tag (such as mkpsf_00) that is being looked up.
@return: the value of the tag
@rtype: str
"""
uri = tag_uri(key)
for... | [
"def",
"get_tag",
"(",
"expnum",
",",
"key",
")",
":",
"uri",
"=",
"tag_uri",
"(",
"key",
")",
"force",
"=",
"uri",
"not",
"in",
"get_tags",
"(",
"expnum",
")",
"value",
"=",
"get_tags",
"(",
"expnum",
",",
"force",
"=",
"force",
")",
".",
"get",
... | given a key, return the vospace tag value.
@param expnum: Number of the CFHT exposure that a tag value is needed for
@param key: The process tag (such as mkpsf_00) that is being looked up.
@return: the value of the tag
@rtype: str | [
"given",
"a",
"key",
"return",
"the",
"vospace",
"tag",
"value",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L413-L425 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | get_process_tag | def get_process_tag(program, ccd, version='p'):
"""
make a process tag have a suffix indicating which ccd its for.
@param program: Name of the process that a tag is built for.
@param ccd: the CCD number that this process ran on.
@param version: The version of the exposure (s, p, o) that the process ... | python | def get_process_tag(program, ccd, version='p'):
"""
make a process tag have a suffix indicating which ccd its for.
@param program: Name of the process that a tag is built for.
@param ccd: the CCD number that this process ran on.
@param version: The version of the exposure (s, p, o) that the process ... | [
"def",
"get_process_tag",
"(",
"program",
",",
"ccd",
",",
"version",
"=",
"'p'",
")",
":",
"return",
"\"%s_%s%s\"",
"%",
"(",
"program",
",",
"str",
"(",
"version",
")",
",",
"str",
"(",
"ccd",
")",
".",
"zfill",
"(",
"2",
")",
")"
] | make a process tag have a suffix indicating which ccd its for.
@param program: Name of the process that a tag is built for.
@param ccd: the CCD number that this process ran on.
@param version: The version of the exposure (s, p, o) that the process ran on.
@return: The string that represents the processi... | [
"make",
"a",
"process",
"tag",
"have",
"a",
"suffix",
"indicating",
"which",
"ccd",
"its",
"for",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L428-L436 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | get_status | def get_status(task, prefix, expnum, version, ccd, return_message=False):
"""
Report back status of the given program by looking up the associated VOSpace annotation.
@param task: name of the process or task that will be checked.
@param prefix: prefix of the file that was processed (often fk or None)
... | python | def get_status(task, prefix, expnum, version, ccd, return_message=False):
"""
Report back status of the given program by looking up the associated VOSpace annotation.
@param task: name of the process or task that will be checked.
@param prefix: prefix of the file that was processed (often fk or None)
... | [
"def",
"get_status",
"(",
"task",
",",
"prefix",
",",
"expnum",
",",
"version",
",",
"ccd",
",",
"return_message",
"=",
"False",
")",
":",
"key",
"=",
"get_process_tag",
"(",
"prefix",
"+",
"task",
",",
"ccd",
",",
"version",
")",
"status",
"=",
"get_t... | Report back status of the given program by looking up the associated VOSpace annotation.
@param task: name of the process or task that will be checked.
@param prefix: prefix of the file that was processed (often fk or None)
@param expnum: which exposure number (or base filename)
@param version: which ... | [
"Report",
"back",
"status",
"of",
"the",
"given",
"program",
"by",
"looking",
"up",
"the",
"associated",
"VOSpace",
"annotation",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L571-L589 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | set_status | def set_status(task, prefix, expnum, version, ccd, status):
"""
set the processing status of the given program.
@param task: name of the processing task
@param prefix: was there a prefix on the exposure number processed?
@param expnum: exposure number processed.
@param version: which version of ... | python | def set_status(task, prefix, expnum, version, ccd, status):
"""
set the processing status of the given program.
@param task: name of the processing task
@param prefix: was there a prefix on the exposure number processed?
@param expnum: exposure number processed.
@param version: which version of ... | [
"def",
"set_status",
"(",
"task",
",",
"prefix",
",",
"expnum",
",",
"version",
",",
"ccd",
",",
"status",
")",
":",
"return",
"set_tag",
"(",
"expnum",
",",
"get_process_tag",
"(",
"prefix",
"+",
"task",
",",
"ccd",
",",
"version",
")",
",",
"status",... | set the processing status of the given program.
@param task: name of the processing task
@param prefix: was there a prefix on the exposure number processed?
@param expnum: exposure number processed.
@param version: which version of the exposure? (p, s, o)
@param ccd: the number of the CCD processing... | [
"set",
"the",
"processing",
"status",
"of",
"the",
"given",
"program",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L592-L603 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | _cutout_expnum | def _cutout_expnum(observation, sky_coord, radius):
"""
Get a cutout from an exposure based on the RA/DEC location.
@param observation: The Observation object that contains the expusre number information.
@type observation: Observation
@param sky_coord: which RA/DEC is needed,
@type sky_coord: ... | python | def _cutout_expnum(observation, sky_coord, radius):
"""
Get a cutout from an exposure based on the RA/DEC location.
@param observation: The Observation object that contains the expusre number information.
@type observation: Observation
@param sky_coord: which RA/DEC is needed,
@type sky_coord: ... | [
"def",
"_cutout_expnum",
"(",
"observation",
",",
"sky_coord",
",",
"radius",
")",
":",
"uri",
"=",
"observation",
".",
"get_image_uri",
"(",
")",
"cutout_filehandle",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
"disposition_filename",
"=",
"client",
"... | Get a cutout from an exposure based on the RA/DEC location.
@param observation: The Observation object that contains the expusre number information.
@type observation: Observation
@param sky_coord: which RA/DEC is needed,
@type sky_coord: SkyCoord
@param radius:
@type radius: Quantity
@retu... | [
"Get",
"a",
"cutout",
"from",
"an",
"exposure",
"based",
"on",
"the",
"RA",
"/",
"DEC",
"location",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L629-L701 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | frame2expnum | def frame2expnum(frameid):
"""Given a standard OSSOS frameid return the expnum, version and ccdnum as a dictionary."""
result = {}
parts = re.search('(?P<expnum>\d{7})(?P<type>\S)(?P<ccd>\d\d)', frameid)
assert parts is not None
result['expnum'] = parts.group('expnum')
result['ccd'] = parts.grou... | python | def frame2expnum(frameid):
"""Given a standard OSSOS frameid return the expnum, version and ccdnum as a dictionary."""
result = {}
parts = re.search('(?P<expnum>\d{7})(?P<type>\S)(?P<ccd>\d\d)', frameid)
assert parts is not None
result['expnum'] = parts.group('expnum')
result['ccd'] = parts.grou... | [
"def",
"frame2expnum",
"(",
"frameid",
")",
":",
"result",
"=",
"{",
"}",
"parts",
"=",
"re",
".",
"search",
"(",
"'(?P<expnum>\\d{7})(?P<type>\\S)(?P<ccd>\\d\\d)'",
",",
"frameid",
")",
"assert",
"parts",
"is",
"not",
"None",
"result",
"[",
"'expnum'",
"]",
... | Given a standard OSSOS frameid return the expnum, version and ccdnum as a dictionary. | [
"Given",
"a",
"standard",
"OSSOS",
"frameid",
"return",
"the",
"expnum",
"version",
"and",
"ccdnum",
"as",
"a",
"dictionary",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L806-L814 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | get_image | def get_image(expnum, ccd=None, version='p', ext=FITS_EXT,
subdir=None, prefix=None, cutout=None, return_file=True, flip_image=True):
"""Get a FITS file for this expnum/ccd from VOSpace.
@param cutout: (str)
@param return_file: return an filename (True) or HDUList (False)
@param expnum:... | python | def get_image(expnum, ccd=None, version='p', ext=FITS_EXT,
subdir=None, prefix=None, cutout=None, return_file=True, flip_image=True):
"""Get a FITS file for this expnum/ccd from VOSpace.
@param cutout: (str)
@param return_file: return an filename (True) or HDUList (False)
@param expnum:... | [
"def",
"get_image",
"(",
"expnum",
",",
"ccd",
"=",
"None",
",",
"version",
"=",
"'p'",
",",
"ext",
"=",
"FITS_EXT",
",",
"subdir",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"cutout",
"=",
"None",
",",
"return_file",
"=",
"True",
",",
"flip_image... | Get a FITS file for this expnum/ccd from VOSpace.
@param cutout: (str)
@param return_file: return an filename (True) or HDUList (False)
@param expnum: CFHT exposure number (int)
@param ccd: @param ccd:
@param version: [p, s, o] (char)
@param ext:
@param subdir:
@param prefix:
... | [
"Get",
"a",
"FITS",
"file",
"for",
"this",
"expnum",
"/",
"ccd",
"from",
"VOSpace",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L821-L943 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.