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 |
|---|---|---|---|---|---|---|---|---|---|---|
edelooff/sqlalchemy-json | sqlalchemy_json/track.py | TrackedObject.convert_items | def convert_items(self, items):
"""Generator like `convert_iterable`, but for 2-tuple iterators."""
return ((key, self.convert(value, self)) for key, value in items) | python | def convert_items(self, items):
"""Generator like `convert_iterable`, but for 2-tuple iterators."""
return ((key, self.convert(value, self)) for key, value in items) | [
"def",
"convert_items",
"(",
"self",
",",
"items",
")",
":",
"return",
"(",
"(",
"key",
",",
"self",
".",
"convert",
"(",
"value",
",",
"self",
")",
")",
"for",
"key",
",",
"value",
"in",
"items",
")"
] | Generator like `convert_iterable`, but for 2-tuple iterators. | [
"Generator",
"like",
"convert_iterable",
"but",
"for",
"2",
"-",
"tuple",
"iterators",
"."
] | train | https://github.com/edelooff/sqlalchemy-json/blob/4e5df0d61dc09ed9a52e24ab291a1f1e14aa95cc/sqlalchemy_json/track.py#L77-L79 |
edelooff/sqlalchemy-json | sqlalchemy_json/track.py | TrackedObject.convert_mapping | def convert_mapping(self, mapping):
"""Convenience method to track either a dict or a 2-tuple iterator."""
if isinstance(mapping, dict):
return self.convert_items(iteritems(mapping))
return self.convert_items(mapping) | python | def convert_mapping(self, mapping):
"""Convenience method to track either a dict or a 2-tuple iterator."""
if isinstance(mapping, dict):
return self.convert_items(iteritems(mapping))
return self.convert_items(mapping) | [
"def",
"convert_mapping",
"(",
"self",
",",
"mapping",
")",
":",
"if",
"isinstance",
"(",
"mapping",
",",
"dict",
")",
":",
"return",
"self",
".",
"convert_items",
"(",
"iteritems",
"(",
"mapping",
")",
")",
"return",
"self",
".",
"convert_items",
"(",
"... | Convenience method to track either a dict or a 2-tuple iterator. | [
"Convenience",
"method",
"to",
"track",
"either",
"a",
"dict",
"or",
"a",
"2",
"-",
"tuple",
"iterator",
"."
] | train | https://github.com/edelooff/sqlalchemy-json/blob/4e5df0d61dc09ed9a52e24ab291a1f1e14aa95cc/sqlalchemy_json/track.py#L81-L85 |
praekelt/django-preferences | preferences/admin.py | PreferencesAdmin.changelist_view | def changelist_view(self, request, extra_context=None):
"""
If we only have a single preference object redirect to it,
otherwise display listing.
"""
model = self.model
if model.objects.all().count() > 1:
return super(PreferencesAdmin, self).changelist_view(re... | python | def changelist_view(self, request, extra_context=None):
"""
If we only have a single preference object redirect to it,
otherwise display listing.
"""
model = self.model
if model.objects.all().count() > 1:
return super(PreferencesAdmin, self).changelist_view(re... | [
"def",
"changelist_view",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"model",
"=",
"self",
".",
"model",
"if",
"model",
".",
"objects",
".",
"all",
"(",
")",
".",
"count",
"(",
")",
">",
"1",
":",
"return",
"super",
"... | If we only have a single preference object redirect to it,
otherwise display listing. | [
"If",
"we",
"only",
"have",
"a",
"single",
"preference",
"object",
"redirect",
"to",
"it",
"otherwise",
"display",
"listing",
"."
] | train | https://github.com/praekelt/django-preferences/blob/724f23da45449e96feb5179cb34e3d380cf151a1/preferences/admin.py#L13-L30 |
voyages-sncf-technologies/nexus_uploader | setup.py | md2rst | def md2rst(md_lines):
'Only converts headers'
lvl2header_char = {1: '=', 2: '-', 3: '~'}
for md_line in md_lines:
if md_line.startswith('#'):
header_indent, header_text = md_line.split(' ', 1)
yield header_text
header_char = lvl2header_char[len(header_indent)]
... | python | def md2rst(md_lines):
'Only converts headers'
lvl2header_char = {1: '=', 2: '-', 3: '~'}
for md_line in md_lines:
if md_line.startswith('#'):
header_indent, header_text = md_line.split(' ', 1)
yield header_text
header_char = lvl2header_char[len(header_indent)]
... | [
"def",
"md2rst",
"(",
"md_lines",
")",
":",
"lvl2header_char",
"=",
"{",
"1",
":",
"'='",
",",
"2",
":",
"'-'",
",",
"3",
":",
"'~'",
"}",
"for",
"md_line",
"in",
"md_lines",
":",
"if",
"md_line",
".",
"startswith",
"(",
"'#'",
")",
":",
"header_in... | Only converts headers | [
"Only",
"converts",
"headers"
] | train | https://github.com/voyages-sncf-technologies/nexus_uploader/blob/dca654f9080264b1dcaabfc2fd19f26b1c4f59fe/setup.py#L24-L34 |
voyages-sncf-technologies/nexus_uploader | nexus_uploader/utils.py | aslist | def aslist(generator):
'Function decorator to transform a generator into a list'
def wrapper(*args, **kwargs):
return list(generator(*args, **kwargs))
return wrapper | python | def aslist(generator):
'Function decorator to transform a generator into a list'
def wrapper(*args, **kwargs):
return list(generator(*args, **kwargs))
return wrapper | [
"def",
"aslist",
"(",
"generator",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"list",
"(",
"generator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")",
"return",
"wrapper"
] | Function decorator to transform a generator into a list | [
"Function",
"decorator",
"to",
"transform",
"a",
"generator",
"into",
"a",
"list"
] | train | https://github.com/voyages-sncf-technologies/nexus_uploader/blob/dca654f9080264b1dcaabfc2fd19f26b1c4f59fe/nexus_uploader/utils.py#L17-L21 |
voyages-sncf-technologies/nexus_uploader | nexus_uploader/pypi.py | get_package_release_from_pypi | def get_package_release_from_pypi(pkg_name, version, pypi_json_api_url, allowed_classifiers):
"""
No classifier-based selection of Python packages is currently implemented: for now we don't fetch any .whl or .egg
Eventually, we should select the best release available, based on the classifier & PEP 425: htt... | python | def get_package_release_from_pypi(pkg_name, version, pypi_json_api_url, allowed_classifiers):
"""
No classifier-based selection of Python packages is currently implemented: for now we don't fetch any .whl or .egg
Eventually, we should select the best release available, based on the classifier & PEP 425: htt... | [
"def",
"get_package_release_from_pypi",
"(",
"pkg_name",
",",
"version",
",",
"pypi_json_api_url",
",",
"allowed_classifiers",
")",
":",
"matching_releases",
"=",
"get_package_releases_matching_version",
"(",
"pkg_name",
",",
"version",
",",
"pypi_json_api_url",
")",
"src... | No classifier-based selection of Python packages is currently implemented: for now we don't fetch any .whl or .egg
Eventually, we should select the best release available, based on the classifier & PEP 425: https://www.python.org/dev/peps/pep-0425/
E.g. a wheel when available but NOT for tornado 4.3 for example... | [
"No",
"classifier",
"-",
"based",
"selection",
"of",
"Python",
"packages",
"is",
"currently",
"implemented",
":",
"for",
"now",
"we",
"don",
"t",
"fetch",
"any",
".",
"whl",
"or",
".",
"egg",
"Eventually",
"we",
"should",
"select",
"the",
"best",
"release"... | train | https://github.com/voyages-sncf-technologies/nexus_uploader/blob/dca654f9080264b1dcaabfc2fd19f26b1c4f59fe/nexus_uploader/pypi.py#L27-L40 |
voyages-sncf-technologies/nexus_uploader | nexus_uploader/pypi.py | extract_classifier_and_extension | def extract_classifier_and_extension(pkg_name, filename):
"""
Returns a PEP425-compliant classifier (or 'py2.py3-none-any' if it cannot be extracted),
and the file extension
TODO: return a classifier 3-members namedtuple instead of a single string
"""
basename, _, extension = filename.rpartition... | python | def extract_classifier_and_extension(pkg_name, filename):
"""
Returns a PEP425-compliant classifier (or 'py2.py3-none-any' if it cannot be extracted),
and the file extension
TODO: return a classifier 3-members namedtuple instead of a single string
"""
basename, _, extension = filename.rpartition... | [
"def",
"extract_classifier_and_extension",
"(",
"pkg_name",
",",
"filename",
")",
":",
"basename",
",",
"_",
",",
"extension",
"=",
"filename",
".",
"rpartition",
"(",
"'.'",
")",
"if",
"extension",
"==",
"'gz'",
"and",
"filename",
".",
"endswith",
"(",
"'.t... | Returns a PEP425-compliant classifier (or 'py2.py3-none-any' if it cannot be extracted),
and the file extension
TODO: return a classifier 3-members namedtuple instead of a single string | [
"Returns",
"a",
"PEP425",
"-",
"compliant",
"classifier",
"(",
"or",
"py2",
".",
"py3",
"-",
"none",
"-",
"any",
"if",
"it",
"cannot",
"be",
"extracted",
")",
"and",
"the",
"file",
"extension",
"TODO",
":",
"return",
"a",
"classifier",
"3",
"-",
"membe... | train | https://github.com/voyages-sncf-technologies/nexus_uploader/blob/dca654f9080264b1dcaabfc2fd19f26b1c4f59fe/nexus_uploader/pypi.py#L62-L80 |
edelooff/sqlalchemy-json | sqlalchemy_json/__init__.py | NestedMutable.coerce | def coerce(cls, key, value):
"""Convert plain dictionary to NestedMutable."""
if value is None:
return value
if isinstance(value, cls):
return value
if isinstance(value, dict):
return NestedMutableDict.coerce(key, value)
if isinstance(value, li... | python | def coerce(cls, key, value):
"""Convert plain dictionary to NestedMutable."""
if value is None:
return value
if isinstance(value, cls):
return value
if isinstance(value, dict):
return NestedMutableDict.coerce(key, value)
if isinstance(value, li... | [
"def",
"coerce",
"(",
"cls",
",",
"key",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"value",
"if",
"isinstance",
"(",
"value",
",",
"cls",
")",
":",
"return",
"value",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":"... | Convert plain dictionary to NestedMutable. | [
"Convert",
"plain",
"dictionary",
"to",
"NestedMutable",
"."
] | train | https://github.com/edelooff/sqlalchemy-json/blob/4e5df0d61dc09ed9a52e24ab291a1f1e14aa95cc/sqlalchemy_json/__init__.py#L36-L46 |
shoeffner/cvloop | tools/create_functions_ipynb.py | is_mod_function | def is_mod_function(mod, fun):
"""Checks if a function in a module was declared in that module.
http://stackoverflow.com/a/1107150/3004221
Args:
mod: the module
fun: the function
"""
return inspect.isfunction(fun) and inspect.getmodule(fun) == mod | python | def is_mod_function(mod, fun):
"""Checks if a function in a module was declared in that module.
http://stackoverflow.com/a/1107150/3004221
Args:
mod: the module
fun: the function
"""
return inspect.isfunction(fun) and inspect.getmodule(fun) == mod | [
"def",
"is_mod_function",
"(",
"mod",
",",
"fun",
")",
":",
"return",
"inspect",
".",
"isfunction",
"(",
"fun",
")",
"and",
"inspect",
".",
"getmodule",
"(",
"fun",
")",
"==",
"mod"
] | Checks if a function in a module was declared in that module.
http://stackoverflow.com/a/1107150/3004221
Args:
mod: the module
fun: the function | [
"Checks",
"if",
"a",
"function",
"in",
"a",
"module",
"was",
"declared",
"in",
"that",
"module",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/create_functions_ipynb.py#L15-L24 |
shoeffner/cvloop | tools/create_functions_ipynb.py | is_mod_class | def is_mod_class(mod, cls):
"""Checks if a class in a module was declared in that module.
Args:
mod: the module
cls: the class
"""
return inspect.isclass(cls) and inspect.getmodule(cls) == mod | python | def is_mod_class(mod, cls):
"""Checks if a class in a module was declared in that module.
Args:
mod: the module
cls: the class
"""
return inspect.isclass(cls) and inspect.getmodule(cls) == mod | [
"def",
"is_mod_class",
"(",
"mod",
",",
"cls",
")",
":",
"return",
"inspect",
".",
"isclass",
"(",
"cls",
")",
"and",
"inspect",
".",
"getmodule",
"(",
"cls",
")",
"==",
"mod"
] | Checks if a class in a module was declared in that module.
Args:
mod: the module
cls: the class | [
"Checks",
"if",
"a",
"class",
"in",
"a",
"module",
"was",
"declared",
"in",
"that",
"module",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/create_functions_ipynb.py#L27-L34 |
shoeffner/cvloop | tools/create_functions_ipynb.py | list_functions | def list_functions(mod_name):
"""Lists all functions declared in a module.
http://stackoverflow.com/a/1107150/3004221
Args:
mod_name: the module name
Returns:
A list of functions declared in that module.
"""
mod = sys.modules[mod_name]
return [func.__name__ for func in mod.... | python | def list_functions(mod_name):
"""Lists all functions declared in a module.
http://stackoverflow.com/a/1107150/3004221
Args:
mod_name: the module name
Returns:
A list of functions declared in that module.
"""
mod = sys.modules[mod_name]
return [func.__name__ for func in mod.... | [
"def",
"list_functions",
"(",
"mod_name",
")",
":",
"mod",
"=",
"sys",
".",
"modules",
"[",
"mod_name",
"]",
"return",
"[",
"func",
".",
"__name__",
"for",
"func",
"in",
"mod",
".",
"__dict__",
".",
"values",
"(",
")",
"if",
"is_mod_function",
"(",
"mo... | Lists all functions declared in a module.
http://stackoverflow.com/a/1107150/3004221
Args:
mod_name: the module name
Returns:
A list of functions declared in that module. | [
"Lists",
"all",
"functions",
"declared",
"in",
"a",
"module",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/create_functions_ipynb.py#L37-L49 |
shoeffner/cvloop | tools/create_functions_ipynb.py | list_classes | def list_classes(mod_name):
"""Lists all classes declared in a module.
Args:
mod_name: the module name
Returns:
A list of functions declared in that module.
"""
mod = sys.modules[mod_name]
return [cls.__name__ for cls in mod.__dict__.values()
if is_mod_class(mod, cls... | python | def list_classes(mod_name):
"""Lists all classes declared in a module.
Args:
mod_name: the module name
Returns:
A list of functions declared in that module.
"""
mod = sys.modules[mod_name]
return [cls.__name__ for cls in mod.__dict__.values()
if is_mod_class(mod, cls... | [
"def",
"list_classes",
"(",
"mod_name",
")",
":",
"mod",
"=",
"sys",
".",
"modules",
"[",
"mod_name",
"]",
"return",
"[",
"cls",
".",
"__name__",
"for",
"cls",
"in",
"mod",
".",
"__dict__",
".",
"values",
"(",
")",
"if",
"is_mod_class",
"(",
"mod",
"... | Lists all classes declared in a module.
Args:
mod_name: the module name
Returns:
A list of functions declared in that module. | [
"Lists",
"all",
"classes",
"declared",
"in",
"a",
"module",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/create_functions_ipynb.py#L52-L62 |
shoeffner/cvloop | tools/create_functions_ipynb.py | get_linenumbers | def get_linenumbers(functions, module, searchstr='def {}(image):\n'):
"""Returns a dictionary which maps function names to line numbers.
Args:
functions: a list of function names
module: the module to look the functions up
searchstr: the string to search for
Returns:
A di... | python | def get_linenumbers(functions, module, searchstr='def {}(image):\n'):
"""Returns a dictionary which maps function names to line numbers.
Args:
functions: a list of function names
module: the module to look the functions up
searchstr: the string to search for
Returns:
A di... | [
"def",
"get_linenumbers",
"(",
"functions",
",",
"module",
",",
"searchstr",
"=",
"'def {}(image):\\n'",
")",
":",
"lines",
"=",
"inspect",
".",
"getsourcelines",
"(",
"module",
")",
"[",
"0",
"]",
"line_numbers",
"=",
"{",
"}",
"for",
"function",
"in",
"f... | Returns a dictionary which maps function names to line numbers.
Args:
functions: a list of function names
module: the module to look the functions up
searchstr: the string to search for
Returns:
A dictionary with functions as keys and their line numbers as values. | [
"Returns",
"a",
"dictionary",
"which",
"maps",
"function",
"names",
"to",
"line",
"numbers",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/create_functions_ipynb.py#L65-L84 |
shoeffner/cvloop | tools/create_functions_ipynb.py | format_doc | def format_doc(fun):
"""Formats the documentation in a nicer way and for notebook cells."""
SEPARATOR = '============================='
func = cvloop.functions.__dict__[fun]
doc_lines = ['{}'.format(l).strip() for l in func.__doc__.split('\n')]
if hasattr(func, '__init__'):
doc_lines.append... | python | def format_doc(fun):
"""Formats the documentation in a nicer way and for notebook cells."""
SEPARATOR = '============================='
func = cvloop.functions.__dict__[fun]
doc_lines = ['{}'.format(l).strip() for l in func.__doc__.split('\n')]
if hasattr(func, '__init__'):
doc_lines.append... | [
"def",
"format_doc",
"(",
"fun",
")",
":",
"SEPARATOR",
"=",
"'============================='",
"func",
"=",
"cvloop",
".",
"functions",
".",
"__dict__",
"[",
"fun",
"]",
"doc_lines",
"=",
"[",
"'{}'",
".",
"format",
"(",
"l",
")",
".",
"strip",
"(",
")"... | Formats the documentation in a nicer way and for notebook cells. | [
"Formats",
"the",
"documentation",
"in",
"a",
"nicer",
"way",
"and",
"for",
"notebook",
"cells",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/create_functions_ipynb.py#L87-L121 |
shoeffner/cvloop | tools/create_functions_ipynb.py | main | def main():
"""Main function creates the cvloop.functions example notebook."""
notebook = {
'cells': [
{
'cell_type': 'markdown',
'metadata': {},
'source': [
'# cvloop functions\n\n',
'This notebook shows... | python | def main():
"""Main function creates the cvloop.functions example notebook."""
notebook = {
'cells': [
{
'cell_type': 'markdown',
'metadata': {},
'source': [
'# cvloop functions\n\n',
'This notebook shows... | [
"def",
"main",
"(",
")",
":",
"notebook",
"=",
"{",
"'cells'",
":",
"[",
"{",
"'cell_type'",
":",
"'markdown'",
",",
"'metadata'",
":",
"{",
"}",
",",
"'source'",
":",
"[",
"'# cvloop functions\\n\\n'",
",",
"'This notebook shows an overview over all cvloop '",
... | Main function creates the cvloop.functions example notebook. | [
"Main",
"function",
"creates",
"the",
"cvloop",
".",
"functions",
"example",
"notebook",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/create_functions_ipynb.py#L161-L212 |
shoeffner/cvloop | cvloop/cvloop.py | prepare_axes | def prepare_axes(axes, title, size, cmap=None):
"""Prepares an axes object for clean plotting.
Removes x and y axes labels and ticks, sets the aspect ratio to be
equal, uses the size to determine the drawing area and fills the image
with random colors as visual feedback.
Creates an AxesImage to be... | python | def prepare_axes(axes, title, size, cmap=None):
"""Prepares an axes object for clean plotting.
Removes x and y axes labels and ticks, sets the aspect ratio to be
equal, uses the size to determine the drawing area and fills the image
with random colors as visual feedback.
Creates an AxesImage to be... | [
"def",
"prepare_axes",
"(",
"axes",
",",
"title",
",",
"size",
",",
"cmap",
"=",
"None",
")",
":",
"if",
"axes",
"is",
"None",
":",
"return",
"None",
"# prepare axis itself",
"axes",
".",
"set_xlim",
"(",
"[",
"0",
",",
"size",
"[",
"1",
"]",
"]",
... | Prepares an axes object for clean plotting.
Removes x and y axes labels and ticks, sets the aspect ratio to be
equal, uses the size to determine the drawing area and fills the image
with random colors as visual feedback.
Creates an AxesImage to be shown inside the axes object and sets the
needed p... | [
"Prepares",
"an",
"axes",
"object",
"for",
"clean",
"plotting",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L29-L67 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop.connect_event_handlers | def connect_event_handlers(self):
"""Connects event handlers to the figure."""
self.figure.canvas.mpl_connect('close_event', self.evt_release)
self.figure.canvas.mpl_connect('pause_event', self.evt_toggle_pause) | python | def connect_event_handlers(self):
"""Connects event handlers to the figure."""
self.figure.canvas.mpl_connect('close_event', self.evt_release)
self.figure.canvas.mpl_connect('pause_event', self.evt_toggle_pause) | [
"def",
"connect_event_handlers",
"(",
"self",
")",
":",
"self",
".",
"figure",
".",
"canvas",
".",
"mpl_connect",
"(",
"'close_event'",
",",
"self",
".",
"evt_release",
")",
"self",
".",
"figure",
".",
"canvas",
".",
"mpl_connect",
"(",
"'pause_event'",
",",... | Connects event handlers to the figure. | [
"Connects",
"event",
"handlers",
"to",
"the",
"figure",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L237-L240 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop.evt_toggle_pause | def evt_toggle_pause(self, *args): # pylint: disable=unused-argument
"""Pauses and resumes the video source."""
if self.event_source._timer is None: # noqa: e501 pylint: disable=protected-access
self.event_source.start()
else:
self.event_source.stop() | python | def evt_toggle_pause(self, *args): # pylint: disable=unused-argument
"""Pauses and resumes the video source."""
if self.event_source._timer is None: # noqa: e501 pylint: disable=protected-access
self.event_source.start()
else:
self.event_source.stop() | [
"def",
"evt_toggle_pause",
"(",
"self",
",",
"*",
"args",
")",
":",
"# pylint: disable=unused-argument",
"if",
"self",
".",
"event_source",
".",
"_timer",
"is",
"None",
":",
"# noqa: e501 pylint: disable=protected-access",
"self",
".",
"event_source",
".",
"start",
... | Pauses and resumes the video source. | [
"Pauses",
"and",
"resumes",
"the",
"video",
"source",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L249-L254 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop.print_info | def print_info(self, capture):
"""Prints information about the unprocessed image.
Reads one frame from the source to determine image colors, dimensions
and data types.
Args:
capture: the source to read from.
"""
self.frame_offset += 1
ret, frame = ca... | python | def print_info(self, capture):
"""Prints information about the unprocessed image.
Reads one frame from the source to determine image colors, dimensions
and data types.
Args:
capture: the source to read from.
"""
self.frame_offset += 1
ret, frame = ca... | [
"def",
"print_info",
"(",
"self",
",",
"capture",
")",
":",
"self",
".",
"frame_offset",
"+=",
"1",
"ret",
",",
"frame",
"=",
"capture",
".",
"read",
"(",
")",
"if",
"ret",
":",
"print",
"(",
"'Capture Information'",
")",
"print",
"(",
"'\\tDimensions (H... | Prints information about the unprocessed image.
Reads one frame from the source to determine image colors, dimensions
and data types.
Args:
capture: the source to read from. | [
"Prints",
"information",
"about",
"the",
"unprocessed",
"image",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L256-L276 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop.determine_size | def determine_size(self, capture):
"""Determines the height and width of the image source.
If no dimensions are available, this method defaults to a resolution of
640x480, thus returns (480, 640).
If capture has a get method it is assumed to understand
`cv2.CAP_PROP_FRAME_WIDTH`... | python | def determine_size(self, capture):
"""Determines the height and width of the image source.
If no dimensions are available, this method defaults to a resolution of
640x480, thus returns (480, 640).
If capture has a get method it is assumed to understand
`cv2.CAP_PROP_FRAME_WIDTH`... | [
"def",
"determine_size",
"(",
"self",
",",
"capture",
")",
":",
"width",
"=",
"640",
"height",
"=",
"480",
"if",
"capture",
"and",
"hasattr",
"(",
"capture",
",",
"'get'",
")",
":",
"width",
"=",
"capture",
".",
"get",
"(",
"cv2",
".",
"CAP_PROP_FRAME_... | Determines the height and width of the image source.
If no dimensions are available, this method defaults to a resolution of
640x480, thus returns (480, 640).
If capture has a get method it is assumed to understand
`cv2.CAP_PROP_FRAME_WIDTH` and `cv2.CAP_PROP_FRAME_HEIGHT` to get the
... | [
"Determines",
"the",
"height",
"and",
"width",
"of",
"the",
"image",
"source",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L278-L305 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop._init_draw | def _init_draw(self):
"""Initializes the drawing of the frames by setting the images to
random colors.
This function is called by TimedAnimation.
"""
if self.original is not None:
self.original.set_data(np.random.random((10, 10, 3)))
self.processed.set_data(n... | python | def _init_draw(self):
"""Initializes the drawing of the frames by setting the images to
random colors.
This function is called by TimedAnimation.
"""
if self.original is not None:
self.original.set_data(np.random.random((10, 10, 3)))
self.processed.set_data(n... | [
"def",
"_init_draw",
"(",
"self",
")",
":",
"if",
"self",
".",
"original",
"is",
"not",
"None",
":",
"self",
".",
"original",
".",
"set_data",
"(",
"np",
".",
"random",
".",
"random",
"(",
"(",
"10",
",",
"10",
",",
"3",
")",
")",
")",
"self",
... | Initializes the drawing of the frames by setting the images to
random colors.
This function is called by TimedAnimation. | [
"Initializes",
"the",
"drawing",
"of",
"the",
"frames",
"by",
"setting",
"the",
"images",
"to",
"random",
"colors",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L320-L328 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop.read_frame | def read_frame(self):
"""Reads a frame and converts the color if needed.
In case no frame is available, i.e. self.capture.read() returns False
as the first return value, the event_source of the TimedAnimation is
stopped, and if possible the capture source released.
Returns:
... | python | def read_frame(self):
"""Reads a frame and converts the color if needed.
In case no frame is available, i.e. self.capture.read() returns False
as the first return value, the event_source of the TimedAnimation is
stopped, and if possible the capture source released.
Returns:
... | [
"def",
"read_frame",
"(",
"self",
")",
":",
"ret",
",",
"frame",
"=",
"self",
".",
"capture",
".",
"read",
"(",
")",
"if",
"not",
"ret",
":",
"self",
".",
"event_source",
".",
"stop",
"(",
")",
"try",
":",
"self",
".",
"capture",
".",
"release",
... | Reads a frame and converts the color if needed.
In case no frame is available, i.e. self.capture.read() returns False
as the first return value, the event_source of the TimedAnimation is
stopped, and if possible the capture source released.
Returns:
None if stopped, otherwi... | [
"Reads",
"a",
"frame",
"and",
"converts",
"the",
"color",
"if",
"needed",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L330-L351 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop.annotate | def annotate(self, framedata):
"""Annotates the processed axis with given annotations for
the provided framedata.
Args:
framedata: The current frame number.
"""
for artist in self.annotation_artists:
artist.remove()
self.annotation_artists = []
... | python | def annotate(self, framedata):
"""Annotates the processed axis with given annotations for
the provided framedata.
Args:
framedata: The current frame number.
"""
for artist in self.annotation_artists:
artist.remove()
self.annotation_artists = []
... | [
"def",
"annotate",
"(",
"self",
",",
"framedata",
")",
":",
"for",
"artist",
"in",
"self",
".",
"annotation_artists",
":",
"artist",
".",
"remove",
"(",
")",
"self",
".",
"annotation_artists",
"=",
"[",
"]",
"for",
"annotation",
"in",
"self",
".",
"annot... | Annotates the processed axis with given annotations for
the provided framedata.
Args:
framedata: The current frame number. | [
"Annotates",
"the",
"processed",
"axis",
"with",
"given",
"annotations",
"for",
"the",
"provided",
"framedata",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L364-L403 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop._draw_frame | def _draw_frame(self, framedata):
"""Reads, processes and draws the frames.
If needed for color maps, conversions to gray scale are performed. In
case the images are no color images and no custom color maps are
defined, the colormap `gray` is applied.
This function is called by... | python | def _draw_frame(self, framedata):
"""Reads, processes and draws the frames.
If needed for color maps, conversions to gray scale are performed. In
case the images are no color images and no custom color maps are
defined, the colormap `gray` is applied.
This function is called by... | [
"def",
"_draw_frame",
"(",
"self",
",",
"framedata",
")",
":",
"original",
"=",
"self",
".",
"read_frame",
"(",
")",
"if",
"original",
"is",
"None",
":",
"self",
".",
"update_info",
"(",
"self",
".",
"info_string",
"(",
"message",
"=",
"'Finished.'",
","... | Reads, processes and draws the frames.
If needed for color maps, conversions to gray scale are performed. In
case the images are no color images and no custom color maps are
defined, the colormap `gray` is applied.
This function is called by TimedAnimation.
Args:
f... | [
"Reads",
"processes",
"and",
"draws",
"the",
"frames",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L405-L444 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop.update_info | def update_info(self, custom=None):
"""Updates the figure's suptitle.
Calls self.info_string() unless custom is provided.
Args:
custom: Overwrite it with this string, unless None.
"""
self.figure.suptitle(self.info_string() if custom is None else custom) | python | def update_info(self, custom=None):
"""Updates the figure's suptitle.
Calls self.info_string() unless custom is provided.
Args:
custom: Overwrite it with this string, unless None.
"""
self.figure.suptitle(self.info_string() if custom is None else custom) | [
"def",
"update_info",
"(",
"self",
",",
"custom",
"=",
"None",
")",
":",
"self",
".",
"figure",
".",
"suptitle",
"(",
"self",
".",
"info_string",
"(",
")",
"if",
"custom",
"is",
"None",
"else",
"custom",
")"
] | Updates the figure's suptitle.
Calls self.info_string() unless custom is provided.
Args:
custom: Overwrite it with this string, unless None. | [
"Updates",
"the",
"figure",
"s",
"suptitle",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L446-L454 |
shoeffner/cvloop | cvloop/cvloop.py | cvloop.info_string | def info_string(self, size=None, message='', frame=-1):
"""Returns information about the stream.
Generates a string containing size, frame number, and info messages.
Omits unnecessary information (e.g. empty messages and frame -1).
This method is primarily used to update the suptitle o... | python | def info_string(self, size=None, message='', frame=-1):
"""Returns information about the stream.
Generates a string containing size, frame number, and info messages.
Omits unnecessary information (e.g. empty messages and frame -1).
This method is primarily used to update the suptitle o... | [
"def",
"info_string",
"(",
"self",
",",
"size",
"=",
"None",
",",
"message",
"=",
"''",
",",
"frame",
"=",
"-",
"1",
")",
":",
"info",
"=",
"[",
"]",
"if",
"size",
"is",
"not",
"None",
":",
"info",
".",
"append",
"(",
"'Size: {1}x{0}'",
".",
"for... | Returns information about the stream.
Generates a string containing size, frame number, and info messages.
Omits unnecessary information (e.g. empty messages and frame -1).
This method is primarily used to update the suptitle of the plot
figure.
Returns:
An info st... | [
"Returns",
"information",
"about",
"the",
"stream",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L456-L477 |
shoeffner/cvloop | tools/sanitize_ipynb.py | main | def main():
"""Sanitizes the loaded *.ipynb."""
with open(sys.argv[1], 'r') as nbfile:
notebook = json.load(nbfile)
# remove kernelspec (venvs)
try:
del notebook['metadata']['kernelspec']
except KeyError:
pass
# remove outputs and metadata, set execution counts to None
... | python | def main():
"""Sanitizes the loaded *.ipynb."""
with open(sys.argv[1], 'r') as nbfile:
notebook = json.load(nbfile)
# remove kernelspec (venvs)
try:
del notebook['metadata']['kernelspec']
except KeyError:
pass
# remove outputs and metadata, set execution counts to None
... | [
"def",
"main",
"(",
")",
":",
"with",
"open",
"(",
"sys",
".",
"argv",
"[",
"1",
"]",
",",
"'r'",
")",
"as",
"nbfile",
":",
"notebook",
"=",
"json",
".",
"load",
"(",
"nbfile",
")",
"# remove kernelspec (venvs)",
"try",
":",
"del",
"notebook",
"[",
... | Sanitizes the loaded *.ipynb. | [
"Sanitizes",
"the",
"loaded",
"*",
".",
"ipynb",
"."
] | train | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/sanitize_ipynb.py#L8-L30 |
icoxfog417/pykintone | pykintone/comment_api.py | CommentAPI.create | def create(self, comment, mentions=()):
"""
create comment
:param comment:
:param mentions: list of pair of code and type("USER", "GROUP", and so on)
:return:
"""
data = {
"app": self.app_id,
"record": self.record_id,
"comment"... | python | def create(self, comment, mentions=()):
"""
create comment
:param comment:
:param mentions: list of pair of code and type("USER", "GROUP", and so on)
:return:
"""
data = {
"app": self.app_id,
"record": self.record_id,
"comment"... | [
"def",
"create",
"(",
"self",
",",
"comment",
",",
"mentions",
"=",
"(",
")",
")",
":",
"data",
"=",
"{",
"\"app\"",
":",
"self",
".",
"app_id",
",",
"\"record\"",
":",
"self",
".",
"record_id",
",",
"\"comment\"",
":",
"{",
"\"text\"",
":",
"comment... | create comment
:param comment:
:param mentions: list of pair of code and type("USER", "GROUP", and so on)
:return: | [
"create",
"comment",
":",
"param",
"comment",
":",
":",
"param",
"mentions",
":",
"list",
"of",
"pair",
"of",
"code",
"and",
"type",
"(",
"USER",
"GROUP",
"and",
"so",
"on",
")",
":",
"return",
":"
] | train | https://github.com/icoxfog417/pykintone/blob/756609fc956fc784325d58cc01473a67a640654c/pykintone/comment_api.py#L42-L76 |
uber-archive/h1-python | h1/lazy_listing.py | _consume | def _consume(iterator, n=None):
"""Advance the iterator n-steps ahead. If n is none, consume entirely."""
# Use functions that consume iterators at C speed.
if n is None:
# feed the entire iterator into a zero-length deque
collections.deque(iterator, maxlen=0)
else:
# advance to ... | python | def _consume(iterator, n=None):
"""Advance the iterator n-steps ahead. If n is none, consume entirely."""
# Use functions that consume iterators at C speed.
if n is None:
# feed the entire iterator into a zero-length deque
collections.deque(iterator, maxlen=0)
else:
# advance to ... | [
"def",
"_consume",
"(",
"iterator",
",",
"n",
"=",
"None",
")",
":",
"# Use functions that consume iterators at C speed.",
"if",
"n",
"is",
"None",
":",
"# feed the entire iterator into a zero-length deque",
"collections",
".",
"deque",
"(",
"iterator",
",",
"maxlen",
... | Advance the iterator n-steps ahead. If n is none, consume entirely. | [
"Advance",
"the",
"iterator",
"n",
"-",
"steps",
"ahead",
".",
"If",
"n",
"is",
"none",
"consume",
"entirely",
"."
] | train | https://github.com/uber-archive/h1-python/blob/c91aec6a26887e453106af39e96ec6d5c7b00c9d/h1/lazy_listing.py#L31-L39 |
uber-archive/h1-python | h1/lazy_listing.py | _slice_required_len | def _slice_required_len(slice_obj):
"""
Calculate how many items must be in the collection to satisfy this slice
returns `None` for slices may vary based on the length of the underlying collection
such as `lst[-1]` or `lst[::]`
"""
if slice_obj.step and slice_obj.step != 1:
return None
... | python | def _slice_required_len(slice_obj):
"""
Calculate how many items must be in the collection to satisfy this slice
returns `None` for slices may vary based on the length of the underlying collection
such as `lst[-1]` or `lst[::]`
"""
if slice_obj.step and slice_obj.step != 1:
return None
... | [
"def",
"_slice_required_len",
"(",
"slice_obj",
")",
":",
"if",
"slice_obj",
".",
"step",
"and",
"slice_obj",
".",
"step",
"!=",
"1",
":",
"return",
"None",
"# (None, None, *) requires the entire list",
"if",
"slice_obj",
".",
"start",
"is",
"None",
"and",
"slic... | Calculate how many items must be in the collection to satisfy this slice
returns `None` for slices may vary based on the length of the underlying collection
such as `lst[-1]` or `lst[::]` | [
"Calculate",
"how",
"many",
"items",
"must",
"be",
"in",
"the",
"collection",
"to",
"satisfy",
"this",
"slice"
] | train | https://github.com/uber-archive/h1-python/blob/c91aec6a26887e453106af39e96ec6d5c7b00c9d/h1/lazy_listing.py#L42-L65 |
dslackw/colored | colored/colored.py | stylize | def stylize(text, styles, reset=True):
"""conveniently styles your text as and resets ANSI codes at its end."""
terminator = attr("reset") if reset else ""
return "{}{}{}".format("".join(styles), text, terminator) | python | def stylize(text, styles, reset=True):
"""conveniently styles your text as and resets ANSI codes at its end."""
terminator = attr("reset") if reset else ""
return "{}{}{}".format("".join(styles), text, terminator) | [
"def",
"stylize",
"(",
"text",
",",
"styles",
",",
"reset",
"=",
"True",
")",
":",
"terminator",
"=",
"attr",
"(",
"\"reset\"",
")",
"if",
"reset",
"else",
"\"\"",
"return",
"\"{}{}{}\"",
".",
"format",
"(",
"\"\"",
".",
"join",
"(",
"styles",
")",
"... | conveniently styles your text as and resets ANSI codes at its end. | [
"conveniently",
"styles",
"your",
"text",
"as",
"and",
"resets",
"ANSI",
"codes",
"at",
"its",
"end",
"."
] | train | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L389-L392 |
dslackw/colored | colored/colored.py | stylize_interactive | def stylize_interactive(text, styles, reset=True):
"""stylize() variant that adds C0 control codes (SOH/STX) for readline
safety."""
# problem: readline includes bare ANSI codes in width calculations.
# solution: wrap nonprinting codes in SOH/STX when necessary.
# see: https://github.com/dslackw/col... | python | def stylize_interactive(text, styles, reset=True):
"""stylize() variant that adds C0 control codes (SOH/STX) for readline
safety."""
# problem: readline includes bare ANSI codes in width calculations.
# solution: wrap nonprinting codes in SOH/STX when necessary.
# see: https://github.com/dslackw/col... | [
"def",
"stylize_interactive",
"(",
"text",
",",
"styles",
",",
"reset",
"=",
"True",
")",
":",
"# problem: readline includes bare ANSI codes in width calculations.",
"# solution: wrap nonprinting codes in SOH/STX when necessary.",
"# see: https://github.com/dslackw/colored/issues/5",
"... | stylize() variant that adds C0 control codes (SOH/STX) for readline
safety. | [
"stylize",
"()",
"variant",
"that",
"adds",
"C0",
"control",
"codes",
"(",
"SOH",
"/",
"STX",
")",
"for",
"readline",
"safety",
"."
] | train | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L402-L409 |
dslackw/colored | colored/colored.py | colored.attribute | def attribute(self):
"""Set or reset attributes"""
paint = {
"bold": self.ESC + "1" + self.END,
1: self.ESC + "1" + self.END,
"dim": self.ESC + "2" + self.END,
2: self.ESC + "2" + self.END,
"underlined": self.ESC + "4" + self.END,
... | python | def attribute(self):
"""Set or reset attributes"""
paint = {
"bold": self.ESC + "1" + self.END,
1: self.ESC + "1" + self.END,
"dim": self.ESC + "2" + self.END,
2: self.ESC + "2" + self.END,
"underlined": self.ESC + "4" + self.END,
... | [
"def",
"attribute",
"(",
"self",
")",
":",
"paint",
"=",
"{",
"\"bold\"",
":",
"self",
".",
"ESC",
"+",
"\"1\"",
"+",
"self",
".",
"END",
",",
"1",
":",
"self",
".",
"ESC",
"+",
"\"1\"",
"+",
"self",
".",
"END",
",",
"\"dim\"",
":",
"self",
"."... | Set or reset attributes | [
"Set",
"or",
"reset",
"attributes"
] | train | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L312-L343 |
dslackw/colored | colored/colored.py | colored.foreground | def foreground(self):
"""Print 256 foreground colors"""
code = self.ESC + "38;5;"
if str(self.color).isdigit():
self.reverse_dict()
color = self.reserve_paint[str(self.color)]
return code + self.paint[color] + self.END
elif self.color.startswith("#"):
... | python | def foreground(self):
"""Print 256 foreground colors"""
code = self.ESC + "38;5;"
if str(self.color).isdigit():
self.reverse_dict()
color = self.reserve_paint[str(self.color)]
return code + self.paint[color] + self.END
elif self.color.startswith("#"):
... | [
"def",
"foreground",
"(",
"self",
")",
":",
"code",
"=",
"self",
".",
"ESC",
"+",
"\"38;5;\"",
"if",
"str",
"(",
"self",
".",
"color",
")",
".",
"isdigit",
"(",
")",
":",
"self",
".",
"reverse_dict",
"(",
")",
"color",
"=",
"self",
".",
"reserve_pa... | Print 256 foreground colors | [
"Print",
"256",
"foreground",
"colors"
] | train | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L345-L355 |
dslackw/colored | colored/colored.py | colored.reverse_dict | def reverse_dict(self):
"""reverse dictionary"""
self.reserve_paint = dict(zip(self.paint.values(), self.paint.keys())) | python | def reverse_dict(self):
"""reverse dictionary"""
self.reserve_paint = dict(zip(self.paint.values(), self.paint.keys())) | [
"def",
"reverse_dict",
"(",
"self",
")",
":",
"self",
".",
"reserve_paint",
"=",
"dict",
"(",
"zip",
"(",
"self",
".",
"paint",
".",
"values",
"(",
")",
",",
"self",
".",
"paint",
".",
"keys",
"(",
")",
")",
")"
] | reverse dictionary | [
"reverse",
"dictionary"
] | train | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L369-L371 |
adafruit/Adafruit_CircuitPython_OneWire | adafruit_onewire/bus.py | OneWireBus.reset | def reset(self, required=False):
"""
Perform a reset and check for presence pulse.
:param bool required: require presence pulse
"""
reset = self._ow.reset()
if required and reset:
raise OneWireError("No presence pulse found. Check devices and wiring.")
... | python | def reset(self, required=False):
"""
Perform a reset and check for presence pulse.
:param bool required: require presence pulse
"""
reset = self._ow.reset()
if required and reset:
raise OneWireError("No presence pulse found. Check devices and wiring.")
... | [
"def",
"reset",
"(",
"self",
",",
"required",
"=",
"False",
")",
":",
"reset",
"=",
"self",
".",
"_ow",
".",
"reset",
"(",
")",
"if",
"required",
"and",
"reset",
":",
"raise",
"OneWireError",
"(",
"\"No presence pulse found. Check devices and wiring.\"",
")",
... | Perform a reset and check for presence pulse.
:param bool required: require presence pulse | [
"Perform",
"a",
"reset",
"and",
"check",
"for",
"presence",
"pulse",
"."
] | train | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L97-L106 |
adafruit/Adafruit_CircuitPython_OneWire | adafruit_onewire/bus.py | OneWireBus.readinto | def readinto(self, buf, *, start=0, end=None):
"""
Read into ``buf`` from the device. The number of bytes read will be the
length of ``buf``.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buf[start:end]``. This will not cause an allocation like
... | python | def readinto(self, buf, *, start=0, end=None):
"""
Read into ``buf`` from the device. The number of bytes read will be the
length of ``buf``.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buf[start:end]``. This will not cause an allocation like
... | [
"def",
"readinto",
"(",
"self",
",",
"buf",
",",
"*",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"if",
"end",
"is",
"None",
":",
"end",
"=",
"len",
"(",
"buf",
")",
"for",
"i",
"in",
"range",
"(",
"start",
",",
"end",
")",
"... | Read into ``buf`` from the device. The number of bytes read will be the
length of ``buf``.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buf[start:end]``. This will not cause an allocation like
``buf[start:end]`` will so it saves memory.
:param byt... | [
"Read",
"into",
"buf",
"from",
"the",
"device",
".",
"The",
"number",
"of",
"bytes",
"read",
"will",
"be",
"the",
"length",
"of",
"buf",
"."
] | train | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L108-L124 |
adafruit/Adafruit_CircuitPython_OneWire | adafruit_onewire/bus.py | OneWireBus.write | def write(self, buf, *, start=0, end=None):
"""
Write the bytes from ``buf`` to the device.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buffer[start:end]``. This will not cause an allocation like
``buffer[start:end]`` will so it saves memory.
... | python | def write(self, buf, *, start=0, end=None):
"""
Write the bytes from ``buf`` to the device.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buffer[start:end]``. This will not cause an allocation like
``buffer[start:end]`` will so it saves memory.
... | [
"def",
"write",
"(",
"self",
",",
"buf",
",",
"*",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"if",
"end",
"is",
"None",
":",
"end",
"=",
"len",
"(",
"buf",
")",
"for",
"i",
"in",
"range",
"(",
"start",
",",
"end",
")",
":",... | Write the bytes from ``buf`` to the device.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buffer[start:end]``. This will not cause an allocation like
``buffer[start:end]`` will so it saves memory.
:param bytearray buf: buffer containing the bytes to write
... | [
"Write",
"the",
"bytes",
"from",
"buf",
"to",
"the",
"device",
"."
] | train | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L126-L141 |
adafruit/Adafruit_CircuitPython_OneWire | adafruit_onewire/bus.py | OneWireBus.scan | def scan(self):
"""Scan for devices on the bus and return a list of addresses."""
devices = []
diff = 65
rom = False
count = 0
for _ in range(0xff):
rom, diff = self._search_rom(rom, diff)
if rom:
count += 1
if count... | python | def scan(self):
"""Scan for devices on the bus and return a list of addresses."""
devices = []
diff = 65
rom = False
count = 0
for _ in range(0xff):
rom, diff = self._search_rom(rom, diff)
if rom:
count += 1
if count... | [
"def",
"scan",
"(",
"self",
")",
":",
"devices",
"=",
"[",
"]",
"diff",
"=",
"65",
"rom",
"=",
"False",
"count",
"=",
"0",
"for",
"_",
"in",
"range",
"(",
"0xff",
")",
":",
"rom",
",",
"diff",
"=",
"self",
".",
"_search_rom",
"(",
"rom",
",",
... | Scan for devices on the bus and return a list of addresses. | [
"Scan",
"for",
"devices",
"on",
"the",
"bus",
"and",
"return",
"a",
"list",
"of",
"addresses",
"."
] | train | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L143-L160 |
adafruit/Adafruit_CircuitPython_OneWire | adafruit_onewire/bus.py | OneWireBus.crc8 | def crc8(data):
"""
Perform the 1-Wire CRC check on the provided data.
:param bytearray data: 8 byte array representing 64 bit ROM code
"""
crc = 0
for byte in data:
crc ^= byte
for _ in range(8):
if crc & 0x01:
... | python | def crc8(data):
"""
Perform the 1-Wire CRC check on the provided data.
:param bytearray data: 8 byte array representing 64 bit ROM code
"""
crc = 0
for byte in data:
crc ^= byte
for _ in range(8):
if crc & 0x01:
... | [
"def",
"crc8",
"(",
"data",
")",
":",
"crc",
"=",
"0",
"for",
"byte",
"in",
"data",
":",
"crc",
"^=",
"byte",
"for",
"_",
"in",
"range",
"(",
"8",
")",
":",
"if",
"crc",
"&",
"0x01",
":",
"crc",
"=",
"(",
"crc",
">>",
"1",
")",
"^",
"0x8C",... | Perform the 1-Wire CRC check on the provided data.
:param bytearray data: 8 byte array representing 64 bit ROM code | [
"Perform",
"the",
"1",
"-",
"Wire",
"CRC",
"check",
"on",
"the",
"provided",
"data",
"."
] | train | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L202-L218 |
icoxfog417/pykintone | pykintone/structure.py | kintoneStructure._deserialize | def _deserialize(cls, json_body, get_value_and_type):
"""
deserialize json to model
:param json_body: json data
:param get_value_and_type: function(f: json_field) -> value, field_type_string(see FieldType)
:return:
"""
instance = cls()
is_set = False
... | python | def _deserialize(cls, json_body, get_value_and_type):
"""
deserialize json to model
:param json_body: json data
:param get_value_and_type: function(f: json_field) -> value, field_type_string(see FieldType)
:return:
"""
instance = cls()
is_set = False
... | [
"def",
"_deserialize",
"(",
"cls",
",",
"json_body",
",",
"get_value_and_type",
")",
":",
"instance",
"=",
"cls",
"(",
")",
"is_set",
"=",
"False",
"properties",
"=",
"cls",
".",
"_get_property_names",
"(",
"instance",
")",
"def",
"get_property_detail",
"(",
... | deserialize json to model
:param json_body: json data
:param get_value_and_type: function(f: json_field) -> value, field_type_string(see FieldType)
:return: | [
"deserialize",
"json",
"to",
"model",
":",
"param",
"json_body",
":",
"json",
"data",
":",
"param",
"get_value_and_type",
":",
"function",
"(",
"f",
":",
"json_field",
")",
"-",
">",
"value",
"field_type_string",
"(",
"see",
"FieldType",
")",
":",
"return",
... | train | https://github.com/icoxfog417/pykintone/blob/756609fc956fc784325d58cc01473a67a640654c/pykintone/structure.py#L35-L62 |
icoxfog417/pykintone | pykintone/structure.py | kintoneStructure._serialize | def _serialize(self, convert_to_key_and_value, ignore_missing=False):
"""
serialize model object to dictionary
:param convert_to_key_and_value: function(field_name, value, property_detail) -> key, value
:return:
"""
serialized = {}
properties = self._get_property... | python | def _serialize(self, convert_to_key_and_value, ignore_missing=False):
"""
serialize model object to dictionary
:param convert_to_key_and_value: function(field_name, value, property_detail) -> key, value
:return:
"""
serialized = {}
properties = self._get_property... | [
"def",
"_serialize",
"(",
"self",
",",
"convert_to_key_and_value",
",",
"ignore_missing",
"=",
"False",
")",
":",
"serialized",
"=",
"{",
"}",
"properties",
"=",
"self",
".",
"_get_property_names",
"(",
"self",
")",
"def",
"get_property_detail",
"(",
"name",
"... | serialize model object to dictionary
:param convert_to_key_and_value: function(field_name, value, property_detail) -> key, value
:return: | [
"serialize",
"model",
"object",
"to",
"dictionary",
":",
"param",
"convert_to_key_and_value",
":",
"function",
"(",
"field_name",
"value",
"property_detail",
")",
"-",
">",
"key",
"value",
":",
"return",
":"
] | train | https://github.com/icoxfog417/pykintone/blob/756609fc956fc784325d58cc01473a67a640654c/pykintone/structure.py#L126-L152 |
adafruit/Adafruit_CircuitPython_OneWire | adafruit_onewire/device.py | OneWireDevice.readinto | def readinto(self, buf, *, start=0, end=None):
"""
Read into ``buf`` from the device. The number of bytes read will be the
length of ``buf``.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buf[start:end]``. This will not cause an allocation like
... | python | def readinto(self, buf, *, start=0, end=None):
"""
Read into ``buf`` from the device. The number of bytes read will be the
length of ``buf``.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buf[start:end]``. This will not cause an allocation like
... | [
"def",
"readinto",
"(",
"self",
",",
"buf",
",",
"*",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"self",
".",
"_bus",
".",
"readinto",
"(",
"buf",
",",
"start",
"=",
"start",
",",
"end",
"=",
"end",
")",
"if",
"start",
"==",
"... | Read into ``buf`` from the device. The number of bytes read will be the
length of ``buf``.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buf[start:end]``. This will not cause an allocation like
``buf[start:end]`` will so it saves memory.
:param byt... | [
"Read",
"into",
"buf",
"from",
"the",
"device",
".",
"The",
"number",
"of",
"bytes",
"read",
"will",
"be",
"the",
"length",
"of",
"buf",
"."
] | train | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/device.py#L50-L66 |
adafruit/Adafruit_CircuitPython_OneWire | adafruit_onewire/device.py | OneWireDevice.write | def write(self, buf, *, start=0, end=None):
"""
Write the bytes from ``buf`` to the device.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buffer[start:end]``. This will not cause an allocation like
``buffer[start:end]`` will so it saves memory.
... | python | def write(self, buf, *, start=0, end=None):
"""
Write the bytes from ``buf`` to the device.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buffer[start:end]``. This will not cause an allocation like
``buffer[start:end]`` will so it saves memory.
... | [
"def",
"write",
"(",
"self",
",",
"buf",
",",
"*",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"return",
"self",
".",
"_bus",
".",
"write",
"(",
"buf",
",",
"start",
"=",
"start",
",",
"end",
"=",
"end",
")"
] | Write the bytes from ``buf`` to the device.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buffer[start:end]``. This will not cause an allocation like
``buffer[start:end]`` will so it saves memory.
:param bytearray buf: buffer containing the bytes to write
... | [
"Write",
"the",
"bytes",
"from",
"buf",
"to",
"the",
"device",
"."
] | train | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/device.py#L68-L80 |
praekelt/django-preferences | preferences/models.py | preferences_class_prepared | def preferences_class_prepared(sender, *args, **kwargs):
"""
Adds various preferences members to preferences.preferences,
thus enabling easy access from code.
"""
cls = sender
if issubclass(cls, Preferences):
# Add singleton manager to subclasses.
cls.add_to_class('singleton', Si... | python | def preferences_class_prepared(sender, *args, **kwargs):
"""
Adds various preferences members to preferences.preferences,
thus enabling easy access from code.
"""
cls = sender
if issubclass(cls, Preferences):
# Add singleton manager to subclasses.
cls.add_to_class('singleton', Si... | [
"def",
"preferences_class_prepared",
"(",
"sender",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cls",
"=",
"sender",
"if",
"issubclass",
"(",
"cls",
",",
"Preferences",
")",
":",
"# Add singleton manager to subclasses.",
"cls",
".",
"add_to_class",
"... | Adds various preferences members to preferences.preferences,
thus enabling easy access from code. | [
"Adds",
"various",
"preferences",
"members",
"to",
"preferences",
".",
"preferences",
"thus",
"enabling",
"easy",
"access",
"from",
"code",
"."
] | train | https://github.com/praekelt/django-preferences/blob/724f23da45449e96feb5179cb34e3d380cf151a1/preferences/models.py#L30-L40 |
praekelt/django-preferences | preferences/models.py | site_cleanup | def site_cleanup(sender, action, instance, **kwargs):
"""
Make sure there is only a single preferences object per site.
So remove sites from pre-existing preferences objects.
"""
if action == 'post_add':
if isinstance(instance, Preferences) \
and hasattr(instance.__class__, 'obje... | python | def site_cleanup(sender, action, instance, **kwargs):
"""
Make sure there is only a single preferences object per site.
So remove sites from pre-existing preferences objects.
"""
if action == 'post_add':
if isinstance(instance, Preferences) \
and hasattr(instance.__class__, 'obje... | [
"def",
"site_cleanup",
"(",
"sender",
",",
"action",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"action",
"==",
"'post_add'",
":",
"if",
"isinstance",
"(",
"instance",
",",
"Preferences",
")",
"and",
"hasattr",
"(",
"instance",
".",
"__cla... | Make sure there is only a single preferences object per site.
So remove sites from pre-existing preferences objects. | [
"Make",
"sure",
"there",
"is",
"only",
"a",
"single",
"preferences",
"object",
"per",
"site",
".",
"So",
"remove",
"sites",
"from",
"pre",
"-",
"existing",
"preferences",
"objects",
"."
] | train | https://github.com/praekelt/django-preferences/blob/724f23da45449e96feb5179cb34e3d380cf151a1/preferences/models.py#L44-L59 |
praekelt/django-preferences | preferences/managers.py | SingletonManager.get_queryset | def get_queryset(self):
"""
Return the first preferences object for the current site.
If preferences do not exist create it.
"""
queryset = super(SingletonManager, self).get_queryset()
# Get current site
current_site = None
if getattr(settings, 'SITE_ID'... | python | def get_queryset(self):
"""
Return the first preferences object for the current site.
If preferences do not exist create it.
"""
queryset = super(SingletonManager, self).get_queryset()
# Get current site
current_site = None
if getattr(settings, 'SITE_ID'... | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"queryset",
"=",
"super",
"(",
"SingletonManager",
",",
"self",
")",
".",
"get_queryset",
"(",
")",
"# Get current site",
"current_site",
"=",
"None",
"if",
"getattr",
"(",
"settings",
",",
"'SITE_ID'",
",",
"Non... | Return the first preferences object for the current site.
If preferences do not exist create it. | [
"Return",
"the",
"first",
"preferences",
"object",
"for",
"the",
"current",
"site",
".",
"If",
"preferences",
"do",
"not",
"exist",
"create",
"it",
"."
] | train | https://github.com/praekelt/django-preferences/blob/724f23da45449e96feb5179cb34e3d380cf151a1/preferences/managers.py#L10-L33 |
lsbardel/python-stdnet | stdnet/utils/encoders.py | Encoder.load_iterable | def load_iterable(self, iterable, session=None):
'''Load an ``iterable``.
By default it returns a generator of data loaded via the
:meth:`loads` method.
:param iterable: an iterable over data to load.
:param session: Optional :class:`stdnet.odm.Session`.
:return: an ite... | python | def load_iterable(self, iterable, session=None):
'''Load an ``iterable``.
By default it returns a generator of data loaded via the
:meth:`loads` method.
:param iterable: an iterable over data to load.
:param session: Optional :class:`stdnet.odm.Session`.
:return: an ite... | [
"def",
"load_iterable",
"(",
"self",
",",
"iterable",
",",
"session",
"=",
"None",
")",
":",
"data",
"=",
"[",
"]",
"load",
"=",
"self",
".",
"loads",
"for",
"v",
"in",
"iterable",
":",
"data",
".",
"append",
"(",
"load",
"(",
"v",
")",
")",
"ret... | Load an ``iterable``.
By default it returns a generator of data loaded via the
:meth:`loads` method.
:param iterable: an iterable over data to load.
:param session: Optional :class:`stdnet.odm.Session`.
:return: an iterable over decoded data. | [
"Load",
"an",
"iterable",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/encoders.py#L67-L81 |
lsbardel/python-stdnet | stdnet/apps/searchengine/__init__.py | SearchEngine.search_model | def search_model(self, q, text, lookup=None):
'''Implements :meth:`stdnet.odm.SearchEngine.search_model`.
It return a new :class:`stdnet.odm.QueryElem` instance from
the input :class:`Query` and the *text* to search.'''
words = self.words_from_text(text, for_search=True)
if not words:
... | python | def search_model(self, q, text, lookup=None):
'''Implements :meth:`stdnet.odm.SearchEngine.search_model`.
It return a new :class:`stdnet.odm.QueryElem` instance from
the input :class:`Query` and the *text* to search.'''
words = self.words_from_text(text, for_search=True)
if not words:
... | [
"def",
"search_model",
"(",
"self",
",",
"q",
",",
"text",
",",
"lookup",
"=",
"None",
")",
":",
"words",
"=",
"self",
".",
"words_from_text",
"(",
"text",
",",
"for_search",
"=",
"True",
")",
"if",
"not",
"words",
":",
"return",
"q",
"qs",
"=",
"s... | Implements :meth:`stdnet.odm.SearchEngine.search_model`.
It return a new :class:`stdnet.odm.QueryElem` instance from
the input :class:`Query` and the *text* to search. | [
"Implements",
":",
"meth",
":",
"stdnet",
".",
"odm",
".",
"SearchEngine",
".",
"search_model",
".",
"It",
"return",
"a",
"new",
":",
"class",
":",
"stdnet",
".",
"odm",
".",
"QueryElem",
"instance",
"from",
"the",
"input",
":",
"class",
":",
"Query",
... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/__init__.py#L164-L173 |
lsbardel/python-stdnet | stdnet/apps/searchengine/__init__.py | SearchEngine._search | def _search(self, words, include=None, exclude=None, lookup=None):
'''Full text search. Return a list of queries to intersect.'''
lookup = lookup or 'contains'
query = self.router.worditem.query()
if include:
query = query.filter(model_type__in=include)
if exclu... | python | def _search(self, words, include=None, exclude=None, lookup=None):
'''Full text search. Return a list of queries to intersect.'''
lookup = lookup or 'contains'
query = self.router.worditem.query()
if include:
query = query.filter(model_type__in=include)
if exclu... | [
"def",
"_search",
"(",
"self",
",",
"words",
",",
"include",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"lookup",
"=",
"None",
")",
":",
"lookup",
"=",
"lookup",
"or",
"'contains'",
"query",
"=",
"self",
".",
"router",
".",
"worditem",
".",
"quer... | Full text search. Return a list of queries to intersect. | [
"Full",
"text",
"search",
".",
"Return",
"a",
"list",
"of",
"queries",
"to",
"intersect",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/__init__.py#L207-L227 |
lsbardel/python-stdnet | stdnet/backends/redisb/client/__init__.py | redis_client | def redis_client(address=None, connection_pool=None, timeout=None,
parser=None, **kwargs):
'''Get a new redis client.
:param address: a ``host``, ``port`` tuple.
:param connection_pool: optional connection pool.
:param timeout: socket timeout.
:param timeout: socket timeout.
''... | python | def redis_client(address=None, connection_pool=None, timeout=None,
parser=None, **kwargs):
'''Get a new redis client.
:param address: a ``host``, ``port`` tuple.
:param connection_pool: optional connection pool.
:param timeout: socket timeout.
:param timeout: socket timeout.
''... | [
"def",
"redis_client",
"(",
"address",
"=",
"None",
",",
"connection_pool",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"parser",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"connection_pool",
":",
"if",
"timeout",
"==",
"0",
":",
... | Get a new redis client.
:param address: a ``host``, ``port`` tuple.
:param connection_pool: optional connection pool.
:param timeout: socket timeout.
:param timeout: socket timeout. | [
"Get",
"a",
"new",
"redis",
"client",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/__init__.py#L16-L35 |
lsbardel/python-stdnet | stdnet/utils/py2py3.py | to_bytes | def to_bytes(s, encoding=None, errors='strict'):
"""Returns a bytestring version of 's',
encoded as specified in 'encoding'."""
encoding = encoding or 'utf-8'
if isinstance(s, bytes):
if encoding != 'utf-8':
return s.decode('utf-8', errors).encode(encoding, errors)
else:
... | python | def to_bytes(s, encoding=None, errors='strict'):
"""Returns a bytestring version of 's',
encoded as specified in 'encoding'."""
encoding = encoding or 'utf-8'
if isinstance(s, bytes):
if encoding != 'utf-8':
return s.decode('utf-8', errors).encode(encoding, errors)
else:
... | [
"def",
"to_bytes",
"(",
"s",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"encoding",
"=",
"encoding",
"or",
"'utf-8'",
"if",
"isinstance",
"(",
"s",
",",
"bytes",
")",
":",
"if",
"encoding",
"!=",
"'utf-8'",
":",
"return",
... | Returns a bytestring version of 's',
encoded as specified in 'encoding'. | [
"Returns",
"a",
"bytestring",
"version",
"of",
"s",
"encoded",
"as",
"specified",
"in",
"encoding",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/py2py3.py#L80-L91 |
lsbardel/python-stdnet | stdnet/utils/py2py3.py | to_string | def to_string(s, encoding=None, errors='strict'):
"""Inverse of to_bytes"""
encoding = encoding or 'utf-8'
if isinstance(s, bytes):
return s.decode(encoding, errors)
if not is_string(s):
s = string_type(s)
return s | python | def to_string(s, encoding=None, errors='strict'):
"""Inverse of to_bytes"""
encoding = encoding or 'utf-8'
if isinstance(s, bytes):
return s.decode(encoding, errors)
if not is_string(s):
s = string_type(s)
return s | [
"def",
"to_string",
"(",
"s",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"encoding",
"=",
"encoding",
"or",
"'utf-8'",
"if",
"isinstance",
"(",
"s",
",",
"bytes",
")",
":",
"return",
"s",
".",
"decode",
"(",
"encoding",
"... | Inverse of to_bytes | [
"Inverse",
"of",
"to_bytes"
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/py2py3.py#L94-L101 |
lsbardel/python-stdnet | stdnet/utils/jsontools.py | date_decimal_hook | def date_decimal_hook(dct):
'''The default JSON decoder hook. It is the inverse of
:class:`stdnet.utils.jsontools.JSONDateDecimalEncoder`.'''
if '__datetime__' in dct:
return todatetime(dct['__datetime__'])
elif '__date__' in dct:
return todatetime(dct['__date__']).date()
elif '__decimal... | python | def date_decimal_hook(dct):
'''The default JSON decoder hook. It is the inverse of
:class:`stdnet.utils.jsontools.JSONDateDecimalEncoder`.'''
if '__datetime__' in dct:
return todatetime(dct['__datetime__'])
elif '__date__' in dct:
return todatetime(dct['__date__']).date()
elif '__decimal... | [
"def",
"date_decimal_hook",
"(",
"dct",
")",
":",
"if",
"'__datetime__'",
"in",
"dct",
":",
"return",
"todatetime",
"(",
"dct",
"[",
"'__datetime__'",
"]",
")",
"elif",
"'__date__'",
"in",
"dct",
":",
"return",
"todatetime",
"(",
"dct",
"[",
"'__date__'",
... | The default JSON decoder hook. It is the inverse of
:class:`stdnet.utils.jsontools.JSONDateDecimalEncoder`. | [
"The",
"default",
"JSON",
"decoder",
"hook",
".",
"It",
"is",
"the",
"inverse",
"of",
":",
"class",
":",
"stdnet",
".",
"utils",
".",
"jsontools",
".",
"JSONDateDecimalEncoder",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L81-L91 |
lsbardel/python-stdnet | stdnet/utils/jsontools.py | flat_to_nested | def flat_to_nested(data, instance=None, attname=None,
separator=None, loads=None):
'''Convert a flat representation of a dictionary to
a nested representation. Fields in the flat representation are separated
by the *splitter* parameters.
:parameter data: a flat dictionary of key value pairs.
:pa... | python | def flat_to_nested(data, instance=None, attname=None,
separator=None, loads=None):
'''Convert a flat representation of a dictionary to
a nested representation. Fields in the flat representation are separated
by the *splitter* parameters.
:parameter data: a flat dictionary of key value pairs.
:pa... | [
"def",
"flat_to_nested",
"(",
"data",
",",
"instance",
"=",
"None",
",",
"attname",
"=",
"None",
",",
"separator",
"=",
"None",
",",
"loads",
"=",
"None",
")",
":",
"separator",
"=",
"separator",
"or",
"JSPLITTER",
"val",
"=",
"{",
"}",
"flat_vals",
"=... | Convert a flat representation of a dictionary to
a nested representation. Fields in the flat representation are separated
by the *splitter* parameters.
:parameter data: a flat dictionary of key value pairs.
:parameter instance: optional instance of a model.
:parameter attribute: optional attribute of a model.
:paramet... | [
"Convert",
"a",
"flat",
"representation",
"of",
"a",
"dictionary",
"to",
"a",
"nested",
"representation",
".",
"Fields",
"in",
"the",
"flat",
"representation",
"are",
"separated",
"by",
"the",
"*",
"splitter",
"*",
"parameters",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L98-L154 |
lsbardel/python-stdnet | stdnet/utils/jsontools.py | dict_flat_generator | def dict_flat_generator(value, attname=None, splitter=JSPLITTER,
dumps=None, prefix=None, error=ValueError,
recursive=True):
'''Convert a nested dictionary into a flat dictionary representation'''
if not isinstance(value, dict) or not recursive:
if not pre... | python | def dict_flat_generator(value, attname=None, splitter=JSPLITTER,
dumps=None, prefix=None, error=ValueError,
recursive=True):
'''Convert a nested dictionary into a flat dictionary representation'''
if not isinstance(value, dict) or not recursive:
if not pre... | [
"def",
"dict_flat_generator",
"(",
"value",
",",
"attname",
"=",
"None",
",",
"splitter",
"=",
"JSPLITTER",
",",
"dumps",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"error",
"=",
"ValueError",
",",
"recursive",
"=",
"True",
")",
":",
"if",
"not",
"i... | Convert a nested dictionary into a flat dictionary representation | [
"Convert",
"a",
"nested",
"dictionary",
"into",
"a",
"flat",
"dictionary",
"representation"
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L157-L178 |
lsbardel/python-stdnet | stdnet/utils/jsontools.py | addmul_number_dicts | def addmul_number_dicts(series):
'''Multiply dictionaries by a numeric values and add them together.
:parameter series: a tuple of two elements tuples. Each serie is of the form::
(weight,dictionary)
where ``weight`` is a number and ``dictionary`` is a dictionary with
numeric values.
:parameter s... | python | def addmul_number_dicts(series):
'''Multiply dictionaries by a numeric values and add them together.
:parameter series: a tuple of two elements tuples. Each serie is of the form::
(weight,dictionary)
where ``weight`` is a number and ``dictionary`` is a dictionary with
numeric values.
:parameter s... | [
"def",
"addmul_number_dicts",
"(",
"series",
")",
":",
"if",
"not",
"series",
":",
"return",
"vtype",
"=",
"value_type",
"(",
"(",
"s",
"[",
"1",
"]",
"for",
"s",
"in",
"series",
")",
")",
"if",
"vtype",
"==",
"1",
":",
"return",
"sum",
"(",
"(",
... | Multiply dictionaries by a numeric values and add them together.
:parameter series: a tuple of two elements tuples. Each serie is of the form::
(weight,dictionary)
where ``weight`` is a number and ``dictionary`` is a dictionary with
numeric values.
:parameter skip: optional list of field names to ski... | [
"Multiply",
"dictionaries",
"by",
"a",
"numeric",
"values",
"and",
"add",
"them",
"together",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L201-L229 |
rodluger/everest | everest/missions/k2/pbs.py | Download | def Download(campaign=0, queue='build', email=None, walltime=8, **kwargs):
'''
Submits a cluster job to the build queue to download all TPFs for a given
campaign.
:param int campaign: The `K2` campaign to run
:param str queue: The name of the queue to submit to. Default `build`
:param str email... | python | def Download(campaign=0, queue='build', email=None, walltime=8, **kwargs):
'''
Submits a cluster job to the build queue to download all TPFs for a given
campaign.
:param int campaign: The `K2` campaign to run
:param str queue: The name of the queue to submit to. Default `build`
:param str email... | [
"def",
"Download",
"(",
"campaign",
"=",
"0",
",",
"queue",
"=",
"'build'",
",",
"email",
"=",
"None",
",",
"walltime",
"=",
"8",
",",
"*",
"*",
"kwargs",
")",
":",
"# Figure out the subcampaign",
"if",
"type",
"(",
"campaign",
")",
"is",
"int",
":",
... | Submits a cluster job to the build queue to download all TPFs for a given
campaign.
:param int campaign: The `K2` campaign to run
:param str queue: The name of the queue to submit to. Default `build`
:param str email: The email to send job status notifications to. \
Default `None`
:param... | [
"Submits",
"a",
"cluster",
"job",
"to",
"the",
"build",
"queue",
"to",
"download",
"all",
"TPFs",
"for",
"a",
"given",
"campaign",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L34-L75 |
rodluger/everest | everest/missions/k2/pbs.py | _Download | def _Download(campaign, subcampaign):
'''
Download all stars from a given campaign. This is
called from ``missions/k2/download.pbs``
'''
# Are we doing a subcampaign?
if subcampaign != -1:
campaign = campaign + 0.1 * subcampaign
# Get all star IDs for this campaign
stars = [s[0... | python | def _Download(campaign, subcampaign):
'''
Download all stars from a given campaign. This is
called from ``missions/k2/download.pbs``
'''
# Are we doing a subcampaign?
if subcampaign != -1:
campaign = campaign + 0.1 * subcampaign
# Get all star IDs for this campaign
stars = [s[0... | [
"def",
"_Download",
"(",
"campaign",
",",
"subcampaign",
")",
":",
"# Are we doing a subcampaign?",
"if",
"subcampaign",
"!=",
"-",
"1",
":",
"campaign",
"=",
"campaign",
"+",
"0.1",
"*",
"subcampaign",
"# Get all star IDs for this campaign",
"stars",
"=",
"[",
"s... | Download all stars from a given campaign. This is
called from ``missions/k2/download.pbs`` | [
"Download",
"all",
"stars",
"from",
"a",
"given",
"campaign",
".",
"This",
"is",
"called",
"from",
"missions",
"/",
"k2",
"/",
"download",
".",
"pbs"
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L78-L111 |
rodluger/everest | everest/missions/k2/pbs.py | Run | def Run(campaign=0, EPIC=None, nodes=5, ppn=12, walltime=100,
mpn=None, email=None, queue=None, **kwargs):
'''
Submits a cluster job to compute and plot data for all targets
in a given campaign.
:param campaign: The K2 campaign number. If this is an :py:class:`int`, \
returns all tar... | python | def Run(campaign=0, EPIC=None, nodes=5, ppn=12, walltime=100,
mpn=None, email=None, queue=None, **kwargs):
'''
Submits a cluster job to compute and plot data for all targets
in a given campaign.
:param campaign: The K2 campaign number. If this is an :py:class:`int`, \
returns all tar... | [
"def",
"Run",
"(",
"campaign",
"=",
"0",
",",
"EPIC",
"=",
"None",
",",
"nodes",
"=",
"5",
",",
"ppn",
"=",
"12",
",",
"walltime",
"=",
"100",
",",
"mpn",
"=",
"None",
",",
"email",
"=",
"None",
",",
"queue",
"=",
"None",
",",
"*",
"*",
"kwar... | Submits a cluster job to compute and plot data for all targets
in a given campaign.
:param campaign: The K2 campaign number. If this is an :py:class:`int`, \
returns all targets in that campaign. If a :py:class:`float` \
in the form `X.Y`, runs the `Y^th` decile of campaign `X`.
:para... | [
"Submits",
"a",
"cluster",
"job",
"to",
"compute",
"and",
"plot",
"data",
"for",
"all",
"targets",
"in",
"a",
"given",
"campaign",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L114-L198 |
rodluger/everest | everest/missions/k2/pbs.py | _Publish | def _Publish(campaign, subcampaign, strkwargs):
'''
The actual function that publishes a given campaign; this must
be called from ``missions/k2/publish.pbs``.
'''
# Get kwargs from string
kwargs = pickle.loads(strkwargs.replace('%%%', '\n').encode('utf-8'))
# Check the cadence
cadence... | python | def _Publish(campaign, subcampaign, strkwargs):
'''
The actual function that publishes a given campaign; this must
be called from ``missions/k2/publish.pbs``.
'''
# Get kwargs from string
kwargs = pickle.loads(strkwargs.replace('%%%', '\n').encode('utf-8'))
# Check the cadence
cadence... | [
"def",
"_Publish",
"(",
"campaign",
",",
"subcampaign",
",",
"strkwargs",
")",
":",
"# Get kwargs from string",
"kwargs",
"=",
"pickle",
".",
"loads",
"(",
"strkwargs",
".",
"replace",
"(",
"'%%%'",
",",
"'\\n'",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")... | The actual function that publishes a given campaign; this must
be called from ``missions/k2/publish.pbs``. | [
"The",
"actual",
"function",
"that",
"publishes",
"a",
"given",
"campaign",
";",
"this",
"must",
"be",
"called",
"from",
"missions",
"/",
"k2",
"/",
"publish",
".",
"pbs",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L322-L350 |
rodluger/everest | everest/missions/k2/pbs.py | Status | def Status(season=range(18), model='nPLD', purge=False, injection=False,
cadence='lc', **kwargs):
'''
Shows the progress of the de-trending runs for the specified campaign(s).
'''
# Mission compatibility
campaign = season
# Injection?
if injection:
return InjectionStatu... | python | def Status(season=range(18), model='nPLD', purge=False, injection=False,
cadence='lc', **kwargs):
'''
Shows the progress of the de-trending runs for the specified campaign(s).
'''
# Mission compatibility
campaign = season
# Injection?
if injection:
return InjectionStatu... | [
"def",
"Status",
"(",
"season",
"=",
"range",
"(",
"18",
")",
",",
"model",
"=",
"'nPLD'",
",",
"purge",
"=",
"False",
",",
"injection",
"=",
"False",
",",
"cadence",
"=",
"'lc'",
",",
"*",
"*",
"kwargs",
")",
":",
"# Mission compatibility",
"campaign"... | Shows the progress of the de-trending runs for the specified campaign(s). | [
"Shows",
"the",
"progress",
"of",
"the",
"de",
"-",
"trending",
"runs",
"for",
"the",
"specified",
"campaign",
"(",
"s",
")",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L353-L468 |
rodluger/everest | everest/missions/k2/pbs.py | InjectionStatus | def InjectionStatus(campaign=range(18), model='nPLD', purge=False,
depths=[0.01, 0.001, 0.0001], **kwargs):
'''
Shows the progress of the injection de-trending runs for
the specified campaign(s).
'''
if not hasattr(campaign, '__len__'):
if type(campaign) is int:
... | python | def InjectionStatus(campaign=range(18), model='nPLD', purge=False,
depths=[0.01, 0.001, 0.0001], **kwargs):
'''
Shows the progress of the injection de-trending runs for
the specified campaign(s).
'''
if not hasattr(campaign, '__len__'):
if type(campaign) is int:
... | [
"def",
"InjectionStatus",
"(",
"campaign",
"=",
"range",
"(",
"18",
")",
",",
"model",
"=",
"'nPLD'",
",",
"purge",
"=",
"False",
",",
"depths",
"=",
"[",
"0.01",
",",
"0.001",
",",
"0.0001",
"]",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"... | Shows the progress of the injection de-trending runs for
the specified campaign(s). | [
"Shows",
"the",
"progress",
"of",
"the",
"injection",
"de",
"-",
"trending",
"runs",
"for",
"the",
"specified",
"campaign",
"(",
"s",
")",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L471-L533 |
rodluger/everest | everest/missions/k2/pbs.py | EverestModel | def EverestModel(ID, model='nPLD', publish=False, csv=False, **kwargs):
'''
A wrapper around an :py:obj:`everest` model for PBS runs.
'''
if model != 'Inject':
from ... import detrender
# HACK: We need to explicitly mask short cadence planets
if kwargs.get('cadence', 'lc') == ... | python | def EverestModel(ID, model='nPLD', publish=False, csv=False, **kwargs):
'''
A wrapper around an :py:obj:`everest` model for PBS runs.
'''
if model != 'Inject':
from ... import detrender
# HACK: We need to explicitly mask short cadence planets
if kwargs.get('cadence', 'lc') == ... | [
"def",
"EverestModel",
"(",
"ID",
",",
"model",
"=",
"'nPLD'",
",",
"publish",
"=",
"False",
",",
"csv",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"model",
"!=",
"'Inject'",
":",
"from",
".",
".",
".",
"import",
"detrender",
"# HACK: We ... | A wrapper around an :py:obj:`everest` model for PBS runs. | [
"A",
"wrapper",
"around",
"an",
":",
"py",
":",
"obj",
":",
"everest",
"model",
"for",
"PBS",
"runs",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L536-L570 |
rodluger/everest | everest/fits.py | PrimaryHDU | def PrimaryHDU(model):
'''
Construct the primary HDU file containing basic header info.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=0)
if 'KEPMAG' not in [c[0] for c in cards]:
cards.append(('KEPMAG', model.mag, 'Kepler magnitude'))
# Add EVEREST info
... | python | def PrimaryHDU(model):
'''
Construct the primary HDU file containing basic header info.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=0)
if 'KEPMAG' not in [c[0] for c in cards]:
cards.append(('KEPMAG', model.mag, 'Kepler magnitude'))
# Add EVEREST info
... | [
"def",
"PrimaryHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"0",
")",
"if",
"'KEPMAG'",
"not",
"in",
"[",
"c",
"[",
"0",
"]",
"for",
"c",
"... | Construct the primary HDU file containing basic header info. | [
"Construct",
"the",
"primary",
"HDU",
"file",
"containing",
"basic",
"header",
"info",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L35-L60 |
rodluger/everest | everest/fits.py | LightcurveHDU | def LightcurveHDU(model):
'''
Construct the data HDU file containing the arrays and the observing info.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=1)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* E... | python | def LightcurveHDU(model):
'''
Construct the data HDU file containing the arrays and the observing info.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=1)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* E... | [
"def",
"LightcurveHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"1",
")",
"# Add EVEREST info",
"cards",
".",
"append",
"(",
"(",
"'COMMENT'",
",",
... | Construct the data HDU file containing the arrays and the observing info. | [
"Construct",
"the",
"data",
"HDU",
"file",
"containing",
"the",
"arrays",
"and",
"the",
"observing",
"info",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L63-L226 |
rodluger/everest | everest/fits.py | PixelsHDU | def PixelsHDU(model):
'''
Construct the HDU containing the pixel-level light curve.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=2)
# Add EVEREST info
cards = []
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVERES... | python | def PixelsHDU(model):
'''
Construct the HDU containing the pixel-level light curve.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=2)
# Add EVEREST info
cards = []
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVERES... | [
"def",
"PixelsHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"2",
")",
"# Add EVEREST info",
"cards",
"=",
"[",
"]",
"cards",
".",
"append",
"(",
... | Construct the HDU containing the pixel-level light curve. | [
"Construct",
"the",
"HDU",
"containing",
"the",
"pixel",
"-",
"level",
"light",
"curve",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L229-L265 |
rodluger/everest | everest/fits.py | ApertureHDU | def ApertureHDU(model):
'''
Construct the HDU containing the aperture used to de-trend.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=3)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST INFO ... | python | def ApertureHDU(model):
'''
Construct the HDU containing the aperture used to de-trend.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=3)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST INFO ... | [
"def",
"ApertureHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"3",
")",
"# Add EVEREST info",
"cards",
".",
"append",
"(",
"(",
"'COMMENT'",
",",
... | Construct the HDU containing the aperture used to de-trend. | [
"Construct",
"the",
"HDU",
"containing",
"the",
"aperture",
"used",
"to",
"de",
"-",
"trend",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L268-L292 |
rodluger/everest | everest/fits.py | ImagesHDU | def ImagesHDU(model):
'''
Construct the HDU containing sample postage stamp images of the target.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=4)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST... | python | def ImagesHDU(model):
'''
Construct the HDU containing sample postage stamp images of the target.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=4)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST... | [
"def",
"ImagesHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"4",
")",
"# Add EVEREST info",
"cards",
".",
"append",
"(",
"(",
"'COMMENT'",
",",
"'... | Construct the HDU containing sample postage stamp images of the target. | [
"Construct",
"the",
"HDU",
"containing",
"sample",
"postage",
"stamp",
"images",
"of",
"the",
"target",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L295-L329 |
rodluger/everest | everest/fits.py | HiResHDU | def HiResHDU(model):
'''
Construct the HDU containing the hi res image of the target.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=5)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST INFO *'... | python | def HiResHDU(model):
'''
Construct the HDU containing the hi res image of the target.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=5)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST INFO *'... | [
"def",
"HiResHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"5",
")",
"# Add EVEREST info",
"cards",
".",
"append",
"(",
"(",
"'COMMENT'",
",",
"'*... | Construct the HDU containing the hi res image of the target. | [
"Construct",
"the",
"HDU",
"containing",
"the",
"hi",
"res",
"image",
"of",
"the",
"target",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L332-L359 |
rodluger/everest | everest/fits.py | MakeFITS | def MakeFITS(model, fitsfile=None):
'''
Generate a FITS file for a given :py:mod:`everest` run.
:param model: An :py:mod:`everest` model instance
'''
# Get the fits file name
if fitsfile is None:
outfile = os.path.join(model.dir, model._mission.FITSFile(
model.ID, model.se... | python | def MakeFITS(model, fitsfile=None):
'''
Generate a FITS file for a given :py:mod:`everest` run.
:param model: An :py:mod:`everest` model instance
'''
# Get the fits file name
if fitsfile is None:
outfile = os.path.join(model.dir, model._mission.FITSFile(
model.ID, model.se... | [
"def",
"MakeFITS",
"(",
"model",
",",
"fitsfile",
"=",
"None",
")",
":",
"# Get the fits file name",
"if",
"fitsfile",
"is",
"None",
":",
"outfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"model",
".",
"dir",
",",
"model",
".",
"_mission",
".",
"FIT... | Generate a FITS file for a given :py:mod:`everest` run.
:param model: An :py:mod:`everest` model instance | [
"Generate",
"a",
"FITS",
"file",
"for",
"a",
"given",
":",
"py",
":",
"mod",
":",
"everest",
"run",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L362-L398 |
lsbardel/python-stdnet | stdnet/odm/utils.py | get_serializer | def get_serializer(name, **options):
'''Retrieve a serializer register as *name*. If the serializer is not
available a ``ValueError`` exception will raise.
A common usage pattern::
qs = MyModel.objects.query().sort_by('id')
s = odm.get_serializer('json')
s.dump(qs)
'''
if name in _serializ... | python | def get_serializer(name, **options):
'''Retrieve a serializer register as *name*. If the serializer is not
available a ``ValueError`` exception will raise.
A common usage pattern::
qs = MyModel.objects.query().sort_by('id')
s = odm.get_serializer('json')
s.dump(qs)
'''
if name in _serializ... | [
"def",
"get_serializer",
"(",
"name",
",",
"*",
"*",
"options",
")",
":",
"if",
"name",
"in",
"_serializers",
":",
"serializer",
"=",
"_serializers",
"[",
"name",
"]",
"return",
"serializer",
"(",
"*",
"*",
"options",
")",
"else",
":",
"raise",
"ValueErr... | Retrieve a serializer register as *name*. If the serializer is not
available a ``ValueError`` exception will raise.
A common usage pattern::
qs = MyModel.objects.query().sort_by('id')
s = odm.get_serializer('json')
s.dump(qs) | [
"Retrieve",
"a",
"serializer",
"register",
"as",
"*",
"name",
"*",
".",
"If",
"the",
"serializer",
"is",
"not",
"available",
"a",
"ValueError",
"exception",
"will",
"raise",
".",
"A",
"common",
"usage",
"pattern",
"::",
"qs",
"=",
"MyModel",
".",
"objects"... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/utils.py#L34-L47 |
lsbardel/python-stdnet | stdnet/odm/utils.py | register_serializer | def register_serializer(name, serializer):
'''\
Register a new serializer to the library.
:parameter name: serializer name (it can override existing serializers).
:parameter serializer: an instance or a derived class of a
:class:`stdnet.odm.Serializer` class or a callable.
'''
if not isclass(serial... | python | def register_serializer(name, serializer):
'''\
Register a new serializer to the library.
:parameter name: serializer name (it can override existing serializers).
:parameter serializer: an instance or a derived class of a
:class:`stdnet.odm.Serializer` class or a callable.
'''
if not isclass(serial... | [
"def",
"register_serializer",
"(",
"name",
",",
"serializer",
")",
":",
"if",
"not",
"isclass",
"(",
"serializer",
")",
":",
"serializer",
"=",
"serializer",
".",
"__class__",
"_serializers",
"[",
"name",
"]",
"=",
"serializer"
] | \
Register a new serializer to the library.
:parameter name: serializer name (it can override existing serializers).
:parameter serializer: an instance or a derived class of a
:class:`stdnet.odm.Serializer` class or a callable. | [
"\\",
"Register",
"a",
"new",
"serializer",
"to",
"the",
"library",
".",
":",
"parameter",
"name",
":",
"serializer",
"name",
"(",
"it",
"can",
"override",
"existing",
"serializers",
")",
".",
":",
"parameter",
"serializer",
":",
"an",
"instance",
"or",
"a... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/utils.py#L50-L60 |
rodluger/everest | everest/masksolve.py | MaskSolve | def MaskSolve(A, b, w=5, progress=True, niter=None):
'''
Finds the solution `x` to the linear problem
A x = b
for all contiguous `w`-sized masks applied to
the rows and columns of `A` and to the entries
of `b`.
Returns an array `X` of shape `(N - w + 1, N - w)`,
where t... | python | def MaskSolve(A, b, w=5, progress=True, niter=None):
'''
Finds the solution `x` to the linear problem
A x = b
for all contiguous `w`-sized masks applied to
the rows and columns of `A` and to the entries
of `b`.
Returns an array `X` of shape `(N - w + 1, N - w)`,
where t... | [
"def",
"MaskSolve",
"(",
"A",
",",
"b",
",",
"w",
"=",
"5",
",",
"progress",
"=",
"True",
",",
"niter",
"=",
"None",
")",
":",
"# Ensure we have choldate installed\r",
"if",
"cholupdate",
"is",
"None",
":",
"log",
".",
"info",
"(",
"\"Running the slow vers... | Finds the solution `x` to the linear problem
A x = b
for all contiguous `w`-sized masks applied to
the rows and columns of `A` and to the entries
of `b`.
Returns an array `X` of shape `(N - w + 1, N - w)`,
where the `nth` row is the solution to the equation
A[![n,n+w)]... | [
"Finds",
"the",
"solution",
"x",
"to",
"the",
"linear",
"problem",
"A",
"x",
"=",
"b",
"for",
"all",
"contiguous",
"w",
"-",
"sized",
"masks",
"applied",
"to",
"the",
"rows",
"and",
"columns",
"of",
"A",
"and",
"to",
"the",
"entries",
"of",
"b",
".",... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/masksolve.py#L25-L102 |
rodluger/everest | everest/masksolve.py | MaskSolveSlow | def MaskSolveSlow(A, b, w=5, progress=True, niter=None):
'''
Identical to `MaskSolve`, but computes the solution
the brute-force way.
'''
# Number of data points
N = b.shape[0]
# How many iterations? Default is to go through
# the entire dataset
if niter is None:
... | python | def MaskSolveSlow(A, b, w=5, progress=True, niter=None):
'''
Identical to `MaskSolve`, but computes the solution
the brute-force way.
'''
# Number of data points
N = b.shape[0]
# How many iterations? Default is to go through
# the entire dataset
if niter is None:
... | [
"def",
"MaskSolveSlow",
"(",
"A",
",",
"b",
",",
"w",
"=",
"5",
",",
"progress",
"=",
"True",
",",
"niter",
"=",
"None",
")",
":",
"# Number of data points\r",
"N",
"=",
"b",
".",
"shape",
"[",
"0",
"]",
"# How many iterations? Default is to go through\r",
... | Identical to `MaskSolve`, but computes the solution
the brute-force way. | [
"Identical",
"to",
"MaskSolve",
"but",
"computes",
"the",
"solution",
"the",
"brute",
"-",
"force",
"way",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/masksolve.py#L105-L132 |
rodluger/everest | everest/basecamp.py | Overfitting.unmasked | def unmasked(self, depth=0.01):
"""Return the unmasked overfitting metric for a given transit depth."""
return 1 - (np.hstack(self._O2) +
np.hstack(self._O3) / depth) / np.hstack(self._O1) | python | def unmasked(self, depth=0.01):
"""Return the unmasked overfitting metric for a given transit depth."""
return 1 - (np.hstack(self._O2) +
np.hstack(self._O3) / depth) / np.hstack(self._O1) | [
"def",
"unmasked",
"(",
"self",
",",
"depth",
"=",
"0.01",
")",
":",
"return",
"1",
"-",
"(",
"np",
".",
"hstack",
"(",
"self",
".",
"_O2",
")",
"+",
"np",
".",
"hstack",
"(",
"self",
".",
"_O3",
")",
"/",
"depth",
")",
"/",
"np",
".",
"hstac... | Return the unmasked overfitting metric for a given transit depth. | [
"Return",
"the",
"unmasked",
"overfitting",
"metric",
"for",
"a",
"given",
"transit",
"depth",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L52-L55 |
rodluger/everest | everest/basecamp.py | Overfitting.show | def show(self):
"""Show the overfitting PDF summary."""
try:
if platform.system().lower().startswith('darwin'):
subprocess.call(['open', self.pdf])
elif os.name == 'nt':
os.startfile(self.pdf)
elif os.name == 'posix':
su... | python | def show(self):
"""Show the overfitting PDF summary."""
try:
if platform.system().lower().startswith('darwin'):
subprocess.call(['open', self.pdf])
elif os.name == 'nt':
os.startfile(self.pdf)
elif os.name == 'posix':
su... | [
"def",
"show",
"(",
"self",
")",
":",
"try",
":",
"if",
"platform",
".",
"system",
"(",
")",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'darwin'",
")",
":",
"subprocess",
".",
"call",
"(",
"[",
"'open'",
",",
"self",
".",
"pdf",
"]",
")",
... | Show the overfitting PDF summary. | [
"Show",
"the",
"overfitting",
"PDF",
"summary",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L57-L70 |
rodluger/everest | everest/basecamp.py | Basecamp.season | def season(self):
"""
Return the current observing season.
For *K2*, this is the observing campaign, while for *Kepler*,
it is the current quarter.
"""
try:
self._season
except AttributeError:
self._season = self._mission.Season(self.ID)
... | python | def season(self):
"""
Return the current observing season.
For *K2*, this is the observing campaign, while for *Kepler*,
it is the current quarter.
"""
try:
self._season
except AttributeError:
self._season = self._mission.Season(self.ID)
... | [
"def",
"season",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_season",
"except",
"AttributeError",
":",
"self",
".",
"_season",
"=",
"self",
".",
"_mission",
".",
"Season",
"(",
"self",
".",
"ID",
")",
"if",
"hasattr",
"(",
"self",
".",
"_season... | Return the current observing season.
For *K2*, this is the observing campaign, while for *Kepler*,
it is the current quarter. | [
"Return",
"the",
"current",
"observing",
"season",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L129-L145 |
rodluger/everest | everest/basecamp.py | Basecamp.fcor | def fcor(self):
'''
The CBV-corrected de-trended flux.
'''
if self.XCBV is None:
return None
else:
return self.flux - self._mission.FitCBVs(self) | python | def fcor(self):
'''
The CBV-corrected de-trended flux.
'''
if self.XCBV is None:
return None
else:
return self.flux - self._mission.FitCBVs(self) | [
"def",
"fcor",
"(",
"self",
")",
":",
"if",
"self",
".",
"XCBV",
"is",
"None",
":",
"return",
"None",
"else",
":",
"return",
"self",
".",
"flux",
"-",
"self",
".",
"_mission",
".",
"FitCBVs",
"(",
"self",
")"
] | The CBV-corrected de-trended flux. | [
"The",
"CBV",
"-",
"corrected",
"de",
"-",
"trended",
"flux",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L174-L183 |
rodluger/everest | everest/basecamp.py | Basecamp.mask | def mask(self):
'''
The array of indices to be masked. This is the union of the sets of
outliers, bad (flagged) cadences, transit cadences, and :py:obj:`NaN`
cadences.
'''
return np.array(list(set(np.concatenate([self.outmask, self.badmask,
self.... | python | def mask(self):
'''
The array of indices to be masked. This is the union of the sets of
outliers, bad (flagged) cadences, transit cadences, and :py:obj:`NaN`
cadences.
'''
return np.array(list(set(np.concatenate([self.outmask, self.badmask,
self.... | [
"def",
"mask",
"(",
"self",
")",
":",
"return",
"np",
".",
"array",
"(",
"list",
"(",
"set",
"(",
"np",
".",
"concatenate",
"(",
"[",
"self",
".",
"outmask",
",",
"self",
".",
"badmask",
",",
"self",
".",
"transitmask",
",",
"self",
".",
"nanmask",... | The array of indices to be masked. This is the union of the sets of
outliers, bad (flagged) cadences, transit cadences, and :py:obj:`NaN`
cadences. | [
"The",
"array",
"of",
"indices",
"to",
"be",
"masked",
".",
"This",
"is",
"the",
"union",
"of",
"the",
"sets",
"of",
"outliers",
"bad",
"(",
"flagged",
")",
"cadences",
"transit",
"cadences",
"and",
":",
"py",
":",
"obj",
":",
"NaN",
"cadences",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L232-L241 |
rodluger/everest | everest/basecamp.py | Basecamp.X | def X(self, i, j=slice(None, None, None)):
'''
Computes the design matrix at the given *PLD* order and the given
indices. The columns are the *PLD* vectors for the target at the
corresponding order, computed as the product of the fractional pixel
flux of all sets of :py:obj:`n` p... | python | def X(self, i, j=slice(None, None, None)):
'''
Computes the design matrix at the given *PLD* order and the given
indices. The columns are the *PLD* vectors for the target at the
corresponding order, computed as the product of the fractional pixel
flux of all sets of :py:obj:`n` p... | [
"def",
"X",
"(",
"self",
",",
"i",
",",
"j",
"=",
"slice",
"(",
"None",
",",
"None",
",",
"None",
")",
")",
":",
"X1",
"=",
"self",
".",
"fpix",
"[",
"j",
"]",
"/",
"self",
".",
"norm",
"[",
"j",
"]",
".",
"reshape",
"(",
"-",
"1",
",",
... | Computes the design matrix at the given *PLD* order and the given
indices. The columns are the *PLD* vectors for the target at the
corresponding order, computed as the product of the fractional pixel
flux of all sets of :py:obj:`n` pixels, where :py:obj:`n` is the *PLD*
order. | [
"Computes",
"the",
"design",
"matrix",
"at",
"the",
"given",
"*",
"PLD",
"*",
"order",
"and",
"the",
"given",
"indices",
".",
"The",
"columns",
"are",
"the",
"*",
"PLD",
"*",
"vectors",
"for",
"the",
"target",
"at",
"the",
"corresponding",
"order",
"comp... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L312-L327 |
rodluger/everest | everest/basecamp.py | Basecamp.plot_info | def plot_info(self, dvs):
'''
Plots miscellaneous de-trending information on the data
validation summary figure.
:param dvs: A :py:class:`dvs.DVS` figure instance
'''
axl, axc, axr = dvs.title()
axc.annotate("%s %d" % (self._mission.IDSTRING, self.ID),
... | python | def plot_info(self, dvs):
'''
Plots miscellaneous de-trending information on the data
validation summary figure.
:param dvs: A :py:class:`dvs.DVS` figure instance
'''
axl, axc, axr = dvs.title()
axc.annotate("%s %d" % (self._mission.IDSTRING, self.ID),
... | [
"def",
"plot_info",
"(",
"self",
",",
"dvs",
")",
":",
"axl",
",",
"axc",
",",
"axr",
"=",
"dvs",
".",
"title",
"(",
")",
"axc",
".",
"annotate",
"(",
"\"%s %d\"",
"%",
"(",
"self",
".",
"_mission",
".",
"IDSTRING",
",",
"self",
".",
"ID",
")",
... | Plots miscellaneous de-trending information on the data
validation summary figure.
:param dvs: A :py:class:`dvs.DVS` figure instance | [
"Plots",
"miscellaneous",
"de",
"-",
"trending",
"information",
"on",
"the",
"data",
"validation",
"summary",
"figure",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L329-L372 |
rodluger/everest | everest/basecamp.py | Basecamp.compute | def compute(self):
'''
Compute the model for the current value of lambda.
'''
# Is there a transit model?
if self.transit_model is not None:
return self.compute_joint()
log.info('Computing the model...')
# Loop over all chunks
model = [None... | python | def compute(self):
'''
Compute the model for the current value of lambda.
'''
# Is there a transit model?
if self.transit_model is not None:
return self.compute_joint()
log.info('Computing the model...')
# Loop over all chunks
model = [None... | [
"def",
"compute",
"(",
"self",
")",
":",
"# Is there a transit model?",
"if",
"self",
".",
"transit_model",
"is",
"not",
"None",
":",
"return",
"self",
".",
"compute_joint",
"(",
")",
"log",
".",
"info",
"(",
"'Computing the model...'",
")",
"# Loop over all chu... | Compute the model for the current value of lambda. | [
"Compute",
"the",
"model",
"for",
"the",
"current",
"value",
"of",
"lambda",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L374-L460 |
rodluger/everest | everest/basecamp.py | Basecamp.compute_joint | def compute_joint(self):
'''
Compute the model in a single step, allowing for a light curve-wide
transit model. This is a bit more expensive to compute.
'''
# Init
log.info('Computing the joint model...')
A = [None for b in self.breakpoints]
B = [None fo... | python | def compute_joint(self):
'''
Compute the model in a single step, allowing for a light curve-wide
transit model. This is a bit more expensive to compute.
'''
# Init
log.info('Computing the joint model...')
A = [None for b in self.breakpoints]
B = [None fo... | [
"def",
"compute_joint",
"(",
"self",
")",
":",
"# Init",
"log",
".",
"info",
"(",
"'Computing the joint model...'",
")",
"A",
"=",
"[",
"None",
"for",
"b",
"in",
"self",
".",
"breakpoints",
"]",
"B",
"=",
"[",
"None",
"for",
"b",
"in",
"self",
".",
"... | Compute the model in a single step, allowing for a light curve-wide
transit model. This is a bit more expensive to compute. | [
"Compute",
"the",
"model",
"in",
"a",
"single",
"step",
"allowing",
"for",
"a",
"light",
"curve",
"-",
"wide",
"transit",
"model",
".",
"This",
"is",
"a",
"bit",
"more",
"expensive",
"to",
"compute",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L462-L585 |
rodluger/everest | everest/basecamp.py | Basecamp.apply_mask | def apply_mask(self, x=None):
'''
Returns the outlier mask, an array of indices corresponding to the
non-outliers.
:param numpy.ndarray x: If specified, returns the masked version of \
:py:obj:`x` instead. Default :py:obj:`None`
'''
if x is None:
... | python | def apply_mask(self, x=None):
'''
Returns the outlier mask, an array of indices corresponding to the
non-outliers.
:param numpy.ndarray x: If specified, returns the masked version of \
:py:obj:`x` instead. Default :py:obj:`None`
'''
if x is None:
... | [
"def",
"apply_mask",
"(",
"self",
",",
"x",
"=",
"None",
")",
":",
"if",
"x",
"is",
"None",
":",
"return",
"np",
".",
"delete",
"(",
"np",
".",
"arange",
"(",
"len",
"(",
"self",
".",
"time",
")",
")",
",",
"self",
".",
"mask",
")",
"else",
"... | Returns the outlier mask, an array of indices corresponding to the
non-outliers.
:param numpy.ndarray x: If specified, returns the masked version of \
:py:obj:`x` instead. Default :py:obj:`None` | [
"Returns",
"the",
"outlier",
"mask",
"an",
"array",
"of",
"indices",
"corresponding",
"to",
"the",
"non",
"-",
"outliers",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L587-L600 |
rodluger/everest | everest/basecamp.py | Basecamp.get_chunk | def get_chunk(self, b, x=None, pad=True):
'''
Returns the indices corresponding to a given light curve chunk.
:param int b: The index of the chunk to return
:param numpy.ndarray x: If specified, applies the mask to array \
:py:obj:`x`. Default :py:obj:`None`
'''
... | python | def get_chunk(self, b, x=None, pad=True):
'''
Returns the indices corresponding to a given light curve chunk.
:param int b: The index of the chunk to return
:param numpy.ndarray x: If specified, applies the mask to array \
:py:obj:`x`. Default :py:obj:`None`
'''
... | [
"def",
"get_chunk",
"(",
"self",
",",
"b",
",",
"x",
"=",
"None",
",",
"pad",
"=",
"True",
")",
":",
"M",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"self",
".",
"time",
")",
")",
"if",
"b",
">",
"0",
":",
"res",
"=",
"M",
"[",
"(",
"M",
... | Returns the indices corresponding to a given light curve chunk.
:param int b: The index of the chunk to return
:param numpy.ndarray x: If specified, applies the mask to array \
:py:obj:`x`. Default :py:obj:`None` | [
"Returns",
"the",
"indices",
"corresponding",
"to",
"a",
"given",
"light",
"curve",
"chunk",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L602-L621 |
rodluger/everest | everest/basecamp.py | Basecamp.get_weights | def get_weights(self):
'''
Computes the PLD weights vector :py:obj:`w`.
..warning :: Deprecated and not thoroughly tested.
'''
log.info("Computing PLD weights...")
# Loop over all chunks
weights = [None for i in range(len(self.breakpoints))]
for b, brk... | python | def get_weights(self):
'''
Computes the PLD weights vector :py:obj:`w`.
..warning :: Deprecated and not thoroughly tested.
'''
log.info("Computing PLD weights...")
# Loop over all chunks
weights = [None for i in range(len(self.breakpoints))]
for b, brk... | [
"def",
"get_weights",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Computing PLD weights...\"",
")",
"# Loop over all chunks",
"weights",
"=",
"[",
"None",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"breakpoints",
")",
")",
"]",
"for",
... | Computes the PLD weights vector :py:obj:`w`.
..warning :: Deprecated and not thoroughly tested. | [
"Computes",
"the",
"PLD",
"weights",
"vector",
":",
"py",
":",
"obj",
":",
"w",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L643-L683 |
rodluger/everest | everest/basecamp.py | Basecamp.get_cdpp_arr | def get_cdpp_arr(self, flux=None):
'''
Returns the CDPP value in *ppm* for each of the
chunks in the light curve.
'''
if flux is None:
flux = self.flux
return np.array([self._mission.CDPP(flux[self.get_masked_chunk(b)],
cadence=self.c... | python | def get_cdpp_arr(self, flux=None):
'''
Returns the CDPP value in *ppm* for each of the
chunks in the light curve.
'''
if flux is None:
flux = self.flux
return np.array([self._mission.CDPP(flux[self.get_masked_chunk(b)],
cadence=self.c... | [
"def",
"get_cdpp_arr",
"(",
"self",
",",
"flux",
"=",
"None",
")",
":",
"if",
"flux",
"is",
"None",
":",
"flux",
"=",
"self",
".",
"flux",
"return",
"np",
".",
"array",
"(",
"[",
"self",
".",
"_mission",
".",
"CDPP",
"(",
"flux",
"[",
"self",
"."... | Returns the CDPP value in *ppm* for each of the
chunks in the light curve. | [
"Returns",
"the",
"CDPP",
"value",
"in",
"*",
"ppm",
"*",
"for",
"each",
"of",
"the",
"chunks",
"in",
"the",
"light",
"curve",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L685-L696 |
rodluger/everest | everest/basecamp.py | Basecamp.get_cdpp | def get_cdpp(self, flux=None):
'''
Returns the scalar CDPP for the light curve.
'''
if flux is None:
flux = self.flux
return self._mission.CDPP(self.apply_mask(flux), cadence=self.cadence) | python | def get_cdpp(self, flux=None):
'''
Returns the scalar CDPP for the light curve.
'''
if flux is None:
flux = self.flux
return self._mission.CDPP(self.apply_mask(flux), cadence=self.cadence) | [
"def",
"get_cdpp",
"(",
"self",
",",
"flux",
"=",
"None",
")",
":",
"if",
"flux",
"is",
"None",
":",
"flux",
"=",
"self",
".",
"flux",
"return",
"self",
".",
"_mission",
".",
"CDPP",
"(",
"self",
".",
"apply_mask",
"(",
"flux",
")",
",",
"cadence",... | Returns the scalar CDPP for the light curve. | [
"Returns",
"the",
"scalar",
"CDPP",
"for",
"the",
"light",
"curve",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L698-L706 |
rodluger/everest | everest/basecamp.py | Basecamp.plot_aperture | def plot_aperture(self, axes, labelsize=8):
'''
Plots the aperture and the pixel images at the beginning, middle,
and end of the time series. Also plots a high resolution image of
the target, if available.
'''
log.info('Plotting the aperture...')
# Get colormap... | python | def plot_aperture(self, axes, labelsize=8):
'''
Plots the aperture and the pixel images at the beginning, middle,
and end of the time series. Also plots a high resolution image of
the target, if available.
'''
log.info('Plotting the aperture...')
# Get colormap... | [
"def",
"plot_aperture",
"(",
"self",
",",
"axes",
",",
"labelsize",
"=",
"8",
")",
":",
"log",
".",
"info",
"(",
"'Plotting the aperture...'",
")",
"# Get colormap",
"plasma",
"=",
"pl",
".",
"get_cmap",
"(",
"'plasma'",
")",
"plasma",
".",
"set_bad",
"(",... | Plots the aperture and the pixel images at the beginning, middle,
and end of the time series. Also plots a high resolution image of
the target, if available. | [
"Plots",
"the",
"aperture",
"and",
"the",
"pixel",
"images",
"at",
"the",
"beginning",
"middle",
"and",
"end",
"of",
"the",
"time",
"series",
".",
"Also",
"plots",
"a",
"high",
"resolution",
"image",
"of",
"the",
"target",
"if",
"available",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L708-L779 |
rodluger/everest | everest/basecamp.py | Basecamp.overfit | def overfit(self, tau=None, plot=True, clobber=False, w=9, **kwargs):
r"""
Compute the masked & unmasked overfitting metrics for the light curve.
This routine injects a transit model given by `tau` at every cadence
in the light curve and recovers the transit depth when (1) leaving
... | python | def overfit(self, tau=None, plot=True, clobber=False, w=9, **kwargs):
r"""
Compute the masked & unmasked overfitting metrics for the light curve.
This routine injects a transit model given by `tau` at every cadence
in the light curve and recovers the transit depth when (1) leaving
... | [
"def",
"overfit",
"(",
"self",
",",
"tau",
"=",
"None",
",",
"plot",
"=",
"True",
",",
"clobber",
"=",
"False",
",",
"w",
"=",
"9",
",",
"*",
"*",
"kwargs",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"dir",
",",... | r"""
Compute the masked & unmasked overfitting metrics for the light curve.
This routine injects a transit model given by `tau` at every cadence
in the light curve and recovers the transit depth when (1) leaving
the transit unmasked and (2) masking the transit prior to performing
... | [
"r",
"Compute",
"the",
"masked",
"&",
"unmasked",
"overfitting",
"metrics",
"for",
"the",
"light",
"curve",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L814-L1075 |
rodluger/everest | everest/basecamp.py | Basecamp.lnlike | def lnlike(self, model, refactor=False, pos_tol=2.5, neg_tol=50.,
full_output=False):
r"""
Return the likelihood of the astrophysical model `model`.
Returns the likelihood of `model` marginalized over the PLD model.
:param ndarray model: A vector of the same shape as `se... | python | def lnlike(self, model, refactor=False, pos_tol=2.5, neg_tol=50.,
full_output=False):
r"""
Return the likelihood of the astrophysical model `model`.
Returns the likelihood of `model` marginalized over the PLD model.
:param ndarray model: A vector of the same shape as `se... | [
"def",
"lnlike",
"(",
"self",
",",
"model",
",",
"refactor",
"=",
"False",
",",
"pos_tol",
"=",
"2.5",
",",
"neg_tol",
"=",
"50.",
",",
"full_output",
"=",
"False",
")",
":",
"lnl",
"=",
"0",
"# Re-factorize the Cholesky decomposition?",
"try",
":",
"self"... | r"""
Return the likelihood of the astrophysical model `model`.
Returns the likelihood of `model` marginalized over the PLD model.
:param ndarray model: A vector of the same shape as `self.time` \
corresponding to the astrophysical model.
:param bool refactor: Re-compute ... | [
"r",
"Return",
"the",
"likelihood",
"of",
"the",
"astrophysical",
"model",
"model",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L1077-L1178 |
rodluger/everest | everest/inject.py | Inject | def Inject(ID, inj_model='nPLD', t0=None, per=None, dur=0.1, depth=0.001,
mask=False, trn_win=5, poly_order=3, make_fits=False, **kwargs):
'''
Run one of the :py:obj:`everest` models with injected transits and attempt
to recover the transit depth at the end with a simple linear regression
wit... | python | def Inject(ID, inj_model='nPLD', t0=None, per=None, dur=0.1, depth=0.001,
mask=False, trn_win=5, poly_order=3, make_fits=False, **kwargs):
'''
Run one of the :py:obj:`everest` models with injected transits and attempt
to recover the transit depth at the end with a simple linear regression
wit... | [
"def",
"Inject",
"(",
"ID",
",",
"inj_model",
"=",
"'nPLD'",
",",
"t0",
"=",
"None",
",",
"per",
"=",
"None",
",",
"dur",
"=",
"0.1",
",",
"depth",
"=",
"0.001",
",",
"mask",
"=",
"False",
",",
"trn_win",
"=",
"5",
",",
"poly_order",
"=",
"3",
... | Run one of the :py:obj:`everest` models with injected transits and attempt
to recover the transit depth at the end with a simple linear regression
with a polynomial baseline. The depth is stored in the
:py:obj:`inject` attribute of the model (a dictionary) as
:py:obj:`rec_depth`. A control injection is ... | [
"Run",
"one",
"of",
"the",
":",
"py",
":",
"obj",
":",
"everest",
"models",
"with",
"injected",
"transits",
"and",
"attempt",
"to",
"recover",
"the",
"transit",
"depth",
"at",
"the",
"end",
"with",
"a",
"simple",
"linear",
"regression",
"with",
"a",
"pol... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/inject.py#L28-L334 |
lsbardel/python-stdnet | stdnet/apps/searchengine/models.py | WordItem.object | def object(self, session):
'''Instance of :attr:`model_type` with id :attr:`object_id`.'''
if not hasattr(self, '_object'):
pkname = self.model_type._meta.pkname()
query = session.query(self.model_type).filter(**{pkname:
... | python | def object(self, session):
'''Instance of :attr:`model_type` with id :attr:`object_id`.'''
if not hasattr(self, '_object'):
pkname = self.model_type._meta.pkname()
query = session.query(self.model_type).filter(**{pkname:
... | [
"def",
"object",
"(",
"self",
",",
"session",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_object'",
")",
":",
"pkname",
"=",
"self",
".",
"model_type",
".",
"_meta",
".",
"pkname",
"(",
")",
"query",
"=",
"session",
".",
"query",
"(",
"s... | Instance of :attr:`model_type` with id :attr:`object_id`. | [
"Instance",
"of",
":",
"attr",
":",
"model_type",
"with",
"id",
":",
"attr",
":",
"object_id",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/models.py#L36-L44 |
rodluger/everest | everest/missions/tess/tess.py | GetData | def GetData(ID, season = None, cadence = 'lc', clobber = False, delete_raw = False,
aperture_name = None, saturated_aperture_name = None,
max_pixels = None, download_only = False, saturation_tolerance = None,
bad_bits = None, **kwargs):
'''
Returns a :py:obj:`DataContainer` ins... | python | def GetData(ID, season = None, cadence = 'lc', clobber = False, delete_raw = False,
aperture_name = None, saturated_aperture_name = None,
max_pixels = None, download_only = False, saturation_tolerance = None,
bad_bits = None, **kwargs):
'''
Returns a :py:obj:`DataContainer` ins... | [
"def",
"GetData",
"(",
"ID",
",",
"season",
"=",
"None",
",",
"cadence",
"=",
"'lc'",
",",
"clobber",
"=",
"False",
",",
"delete_raw",
"=",
"False",
",",
"aperture_name",
"=",
"None",
",",
"saturated_aperture_name",
"=",
"None",
",",
"max_pixels",
"=",
"... | Returns a :py:obj:`DataContainer` instance with the raw data for the target.
:param int ID: The target ID number
:param int season: The observing season. Default :py:obj:`None`
:param str cadence: The light curve cadence. Default `lc`
:param bool clobber: Overwrite existing files? Default :py:obj:`False`
:... | [
"Returns",
"a",
":",
"py",
":",
"obj",
":",
"DataContainer",
"instance",
"with",
"the",
"raw",
"data",
"for",
"the",
"target",
".",
":",
"param",
"int",
"ID",
":",
"The",
"target",
"ID",
"number",
":",
"param",
"int",
"season",
":",
"The",
"observing",... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/tess/tess.py#L65-L90 |
rodluger/everest | everest/missions/tess/tess.py | GetNeighbors | def GetNeighbors(ID, model = None, neighbors = None, mag_range = None,
cdpp_range = None, aperture_name = None,
cadence = 'lc', **kwargs):
'''
Return `neighbors` random bright stars on the same module as `EPIC`.
:param int ID: The target ID number
:param str model: The :py... | python | def GetNeighbors(ID, model = None, neighbors = None, mag_range = None,
cdpp_range = None, aperture_name = None,
cadence = 'lc', **kwargs):
'''
Return `neighbors` random bright stars on the same module as `EPIC`.
:param int ID: The target ID number
:param str model: The :py... | [
"def",
"GetNeighbors",
"(",
"ID",
",",
"model",
"=",
"None",
",",
"neighbors",
"=",
"None",
",",
"mag_range",
"=",
"None",
",",
"cdpp_range",
"=",
"None",
",",
"aperture_name",
"=",
"None",
",",
"cadence",
"=",
"'lc'",
",",
"*",
"*",
"kwargs",
")",
"... | Return `neighbors` random bright stars on the same module as `EPIC`.
:param int ID: The target ID number
:param str model: The :py:obj:`everest` model name. Only used when imposing CDPP bounds. Default :py:obj:`None`
:param int neighbors: Number of neighbors to return. Default None
:param str aperture_name: ... | [
"Return",
"neighbors",
"random",
"bright",
"stars",
"on",
"the",
"same",
"module",
"as",
"EPIC",
".",
":",
"param",
"int",
"ID",
":",
"The",
"target",
"ID",
"number",
":",
"param",
"str",
"model",
":",
"The",
":",
"py",
":",
"obj",
":",
"everest",
"m... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/tess/tess.py#L92-L109 |
rodluger/everest | everest/missions/k2/pipelines.py | get | def get(ID, pipeline='everest2', campaign=None):
'''
Returns the `time` and `flux` for a given EPIC `ID` and
a given `pipeline` name.
'''
log.info('Downloading %s light curve for %d...' % (pipeline, ID))
# Dev version hack
if EVEREST_DEV:
if pipeline.lower() == 'everest2' or pipel... | python | def get(ID, pipeline='everest2', campaign=None):
'''
Returns the `time` and `flux` for a given EPIC `ID` and
a given `pipeline` name.
'''
log.info('Downloading %s light curve for %d...' % (pipeline, ID))
# Dev version hack
if EVEREST_DEV:
if pipeline.lower() == 'everest2' or pipel... | [
"def",
"get",
"(",
"ID",
",",
"pipeline",
"=",
"'everest2'",
",",
"campaign",
"=",
"None",
")",
":",
"log",
".",
"info",
"(",
"'Downloading %s light curve for %d...'",
"%",
"(",
"pipeline",
",",
"ID",
")",
")",
"# Dev version hack",
"if",
"EVEREST_DEV",
":",... | Returns the `time` and `flux` for a given EPIC `ID` and
a given `pipeline` name. | [
"Returns",
"the",
"time",
"and",
"flux",
"for",
"a",
"given",
"EPIC",
"ID",
"and",
"a",
"given",
"pipeline",
"name",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L39-L88 |
rodluger/everest | everest/missions/k2/pipelines.py | plot | def plot(ID, pipeline='everest2', show=True, campaign=None):
'''
Plots the de-trended flux for the given EPIC `ID` and for
the specified `pipeline`.
'''
# Get the data
time, flux = get(ID, pipeline=pipeline, campaign=campaign)
# Remove nans
mask = np.where(np.isnan(flux))[0]
time ... | python | def plot(ID, pipeline='everest2', show=True, campaign=None):
'''
Plots the de-trended flux for the given EPIC `ID` and for
the specified `pipeline`.
'''
# Get the data
time, flux = get(ID, pipeline=pipeline, campaign=campaign)
# Remove nans
mask = np.where(np.isnan(flux))[0]
time ... | [
"def",
"plot",
"(",
"ID",
",",
"pipeline",
"=",
"'everest2'",
",",
"show",
"=",
"True",
",",
"campaign",
"=",
"None",
")",
":",
"# Get the data",
"time",
",",
"flux",
"=",
"get",
"(",
"ID",
",",
"pipeline",
"=",
"pipeline",
",",
"campaign",
"=",
"cam... | Plots the de-trended flux for the given EPIC `ID` and for
the specified `pipeline`. | [
"Plots",
"the",
"de",
"-",
"trended",
"flux",
"for",
"the",
"given",
"EPIC",
"ID",
"and",
"for",
"the",
"specified",
"pipeline",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L91-L134 |
rodluger/everest | everest/missions/k2/pipelines.py | get_cdpp | def get_cdpp(campaign, pipeline='everest2'):
'''
Computes the CDPP for a given `campaign` and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
'''
# Imports
from .k2 import CDPP
from .utils import GetK2Campaign
# Check pipeline
assert pipeline.lower()... | python | def get_cdpp(campaign, pipeline='everest2'):
'''
Computes the CDPP for a given `campaign` and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
'''
# Imports
from .k2 import CDPP
from .utils import GetK2Campaign
# Check pipeline
assert pipeline.lower()... | [
"def",
"get_cdpp",
"(",
"campaign",
",",
"pipeline",
"=",
"'everest2'",
")",
":",
"# Imports",
"from",
".",
"k2",
"import",
"CDPP",
"from",
".",
"utils",
"import",
"GetK2Campaign",
"# Check pipeline",
"assert",
"pipeline",
".",
"lower",
"(",
")",
"in",
"Pipe... | Computes the CDPP for a given `campaign` and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/". | [
"Computes",
"the",
"CDPP",
"for",
"a",
"given",
"campaign",
"and",
"a",
"given",
"pipeline",
".",
"Stores",
"the",
"results",
"in",
"a",
"file",
"under",
"/",
"missions",
"/",
"k2",
"/",
"tables",
"/",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L137-L193 |
rodluger/everest | everest/missions/k2/pipelines.py | get_outliers | def get_outliers(campaign, pipeline='everest2', sigma=5):
'''
Computes the number of outliers for a given `campaign`
and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
:param int sigma: The sigma level at which to clip outliers. Default 5
'''
# Imports
... | python | def get_outliers(campaign, pipeline='everest2', sigma=5):
'''
Computes the number of outliers for a given `campaign`
and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
:param int sigma: The sigma level at which to clip outliers. Default 5
'''
# Imports
... | [
"def",
"get_outliers",
"(",
"campaign",
",",
"pipeline",
"=",
"'everest2'",
",",
"sigma",
"=",
"5",
")",
":",
"# Imports",
"from",
".",
"utils",
"import",
"GetK2Campaign",
"client",
"=",
"k2plr",
".",
"API",
"(",
")",
"# Check pipeline",
"assert",
"pipeline"... | Computes the number of outliers for a given `campaign`
and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
:param int sigma: The sigma level at which to clip outliers. Default 5 | [
"Computes",
"the",
"number",
"of",
"outliers",
"for",
"a",
"given",
"campaign",
"and",
"a",
"given",
"pipeline",
".",
"Stores",
"the",
"results",
"in",
"a",
"file",
"under",
"/",
"missions",
"/",
"k2",
"/",
"tables",
"/",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L196-L308 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.