repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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",
"."
] | 3ddd311e9b679d16c8fd36779931380374de343c | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L364-L403 | train |
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",
"."
] | 3ddd311e9b679d16c8fd36779931380374de343c | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L405-L444 | train |
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",
"."
] | 3ddd311e9b679d16c8fd36779931380374de343c | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L446-L454 | train |
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",
"."
] | 3ddd311e9b679d16c8fd36779931380374de343c | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/cvloop/cvloop.py#L456-L477 | train |
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",
"."
] | 3ddd311e9b679d16c8fd36779931380374de343c | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/sanitize_ipynb.py#L8-L30 | train |
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",
":"
] | 756609fc956fc784325d58cc01473a67a640654c | https://github.com/icoxfog417/pykintone/blob/756609fc956fc784325d58cc01473a67a640654c/pykintone/comment_api.py#L42-L76 | train |
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",
"."
] | c91aec6a26887e453106af39e96ec6d5c7b00c9d | https://github.com/uber-archive/h1-python/blob/c91aec6a26887e453106af39e96ec6d5c7b00c9d/h1/lazy_listing.py#L31-L39 | train |
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"
] | c91aec6a26887e453106af39e96ec6d5c7b00c9d | https://github.com/uber-archive/h1-python/blob/c91aec6a26887e453106af39e96ec6d5c7b00c9d/h1/lazy_listing.py#L42-L65 | train |
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",
"."
] | 064172b36bd5e456c60581c7fbf77060ca7829ba | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L389-L392 | train |
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",
"."
] | 064172b36bd5e456c60581c7fbf77060ca7829ba | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L402-L409 | train |
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"
] | 064172b36bd5e456c60581c7fbf77060ca7829ba | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L312-L343 | train |
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"
] | 064172b36bd5e456c60581c7fbf77060ca7829ba | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L345-L355 | train |
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"
] | 064172b36bd5e456c60581c7fbf77060ca7829ba | https://github.com/dslackw/colored/blob/064172b36bd5e456c60581c7fbf77060ca7829ba/colored/colored.py#L369-L371 | train |
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",
"."
] | 113ca99b9087f7031f0b46a963472ad106520f9b | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L97-L106 | train |
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",
"."
] | 113ca99b9087f7031f0b46a963472ad106520f9b | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L108-L124 | train |
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",
"."
] | 113ca99b9087f7031f0b46a963472ad106520f9b | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L126-L141 | train |
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",
"."
] | 113ca99b9087f7031f0b46a963472ad106520f9b | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L143-L160 | train |
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",
"."
] | 113ca99b9087f7031f0b46a963472ad106520f9b | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L202-L218 | train |
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",
... | 756609fc956fc784325d58cc01473a67a640654c | https://github.com/icoxfog417/pykintone/blob/756609fc956fc784325d58cc01473a67a640654c/pykintone/structure.py#L35-L62 | train |
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",
":"
] | 756609fc956fc784325d58cc01473a67a640654c | https://github.com/icoxfog417/pykintone/blob/756609fc956fc784325d58cc01473a67a640654c/pykintone/structure.py#L126-L152 | train |
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",
"."
] | 113ca99b9087f7031f0b46a963472ad106520f9b | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/device.py#L50-L66 | train |
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",
"."
] | 113ca99b9087f7031f0b46a963472ad106520f9b | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/device.py#L68-L80 | train |
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",
"."
] | 724f23da45449e96feb5179cb34e3d380cf151a1 | https://github.com/praekelt/django-preferences/blob/724f23da45449e96feb5179cb34e3d380cf151a1/preferences/models.py#L30-L40 | train |
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",
"."
] | 724f23da45449e96feb5179cb34e3d380cf151a1 | https://github.com/praekelt/django-preferences/blob/724f23da45449e96feb5179cb34e3d380cf151a1/preferences/models.py#L44-L59 | train |
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",
"."
] | 724f23da45449e96feb5179cb34e3d380cf151a1 | https://github.com/praekelt/django-preferences/blob/724f23da45449e96feb5179cb34e3d380cf151a1/preferences/managers.py#L10-L33 | train |
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",
"."
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/encoders.py#L67-L81 | train |
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",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/__init__.py#L164-L173 | train |
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",
"."
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/__init__.py#L207-L227 | train |
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",
"."
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/__init__.py#L16-L35 | train |
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",
"."
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/py2py3.py#L80-L91 | train |
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"
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/py2py3.py#L94-L101 | train |
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",
"."
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L81-L91 | train |
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",
"."
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L98-L154 | train |
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"
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L157-L178 | train |
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",
"."
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L201-L229 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L34-L75 | train |
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"
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L78-L111 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L114-L198 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L322-L350 | train |
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",
")",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L353-L468 | train |
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",
")",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L471-L533 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L536-L570 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L35-L60 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L63-L226 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L229-L265 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L268-L292 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L295-L329 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L332-L359 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L362-L398 | train |
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"... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/utils.py#L34-L47 | train |
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... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/utils.py#L50-L60 | train |
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",
".",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/masksolve.py#L25-L102 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/masksolve.py#L105-L132 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L52-L55 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L57-L70 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L129-L145 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L174-L183 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L232-L241 | train |
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... | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L312-L327 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L329-L372 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L374-L460 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L462-L585 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L587-L600 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L602-L621 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L643-L683 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L685-L696 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L698-L706 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L708-L779 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L814-L1075 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L1077-L1178 | train |
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... | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/inject.py#L28-L334 | train |
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",
"."
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/models.py#L36-L44 | train |
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",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/tess/tess.py#L65-L90 | train |
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... | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/tess/tess.py#L92-L109 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L39-L88 | train |
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",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L91-L134 | train |
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",
"/",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L137-L193 | train |
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",
"/",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L196-L308 | train |
rodluger/everest | everest/detrender.py | Detrender.name | def name(self):
'''
Returns the name of the current :py:class:`Detrender` subclass.
'''
if self.cadence == 'lc':
return self.__class__.__name__
else:
return '%s.sc' % self.__class__.__name__ | python | def name(self):
'''
Returns the name of the current :py:class:`Detrender` subclass.
'''
if self.cadence == 'lc':
return self.__class__.__name__
else:
return '%s.sc' % self.__class__.__name__ | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"cadence",
"==",
"'lc'",
":",
"return",
"self",
".",
"__class__",
".",
"__name__",
"else",
":",
"return",
"'%s.sc'",
"%",
"self",
".",
"__class__",
".",
"__name__"
] | Returns the name of the current :py:class:`Detrender` subclass. | [
"Returns",
"the",
"name",
"of",
"the",
"current",
":",
"py",
":",
"class",
":",
"Detrender",
"subclass",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L300-L309 | train |
rodluger/everest | everest/detrender.py | Detrender.cv_precompute | def cv_precompute(self, mask, b):
'''
Pre-compute the matrices :py:obj:`A` and :py:obj:`B`
(cross-validation step only)
for chunk :py:obj:`b`.
'''
# Get current chunk and mask outliers
m1 = self.get_masked_chunk(b)
flux = self.fraw[m1]
K = GetCov... | python | def cv_precompute(self, mask, b):
'''
Pre-compute the matrices :py:obj:`A` and :py:obj:`B`
(cross-validation step only)
for chunk :py:obj:`b`.
'''
# Get current chunk and mask outliers
m1 = self.get_masked_chunk(b)
flux = self.fraw[m1]
K = GetCov... | [
"def",
"cv_precompute",
"(",
"self",
",",
"mask",
",",
"b",
")",
":",
"# Get current chunk and mask outliers",
"m1",
"=",
"self",
".",
"get_masked_chunk",
"(",
"b",
")",
"flux",
"=",
"self",
".",
"fraw",
"[",
"m1",
"]",
"K",
"=",
"GetCovariance",
"(",
"s... | Pre-compute the matrices :py:obj:`A` and :py:obj:`B`
(cross-validation step only)
for chunk :py:obj:`b`. | [
"Pre",
"-",
"compute",
"the",
"matrices",
":",
"py",
":",
"obj",
":",
"A",
"and",
":",
"py",
":",
"obj",
":",
"B",
"(",
"cross",
"-",
"validation",
"step",
"only",
")",
"for",
"chunk",
":",
"py",
":",
"obj",
":",
"b",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L327-L373 | train |
rodluger/everest | everest/detrender.py | Detrender.cv_compute | def cv_compute(self, b, A, B, C, mK, f, m1, m2):
'''
Compute the model (cross-validation step only) for chunk :py:obj:`b`.
'''
A = np.sum([l * a for l, a in zip(self.lam[b], A)
if l is not None], axis=0)
B = np.sum([l * b for l, b in zip(self.lam[b], B)
... | python | def cv_compute(self, b, A, B, C, mK, f, m1, m2):
'''
Compute the model (cross-validation step only) for chunk :py:obj:`b`.
'''
A = np.sum([l * a for l, a in zip(self.lam[b], A)
if l is not None], axis=0)
B = np.sum([l * b for l, b in zip(self.lam[b], B)
... | [
"def",
"cv_compute",
"(",
"self",
",",
"b",
",",
"A",
",",
"B",
",",
"C",
",",
"mK",
",",
"f",
",",
"m1",
",",
"m2",
")",
":",
"A",
"=",
"np",
".",
"sum",
"(",
"[",
"l",
"*",
"a",
"for",
"l",
",",
"a",
"in",
"zip",
"(",
"self",
".",
"... | Compute the model (cross-validation step only) for chunk :py:obj:`b`. | [
"Compute",
"the",
"model",
"(",
"cross",
"-",
"validation",
"step",
"only",
")",
"for",
"chunk",
":",
"py",
":",
"obj",
":",
"b",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L375-L397 | train |
rodluger/everest | everest/detrender.py | Detrender.get_outliers | def get_outliers(self):
'''
Performs iterative sigma clipping to get outliers.
'''
log.info("Clipping outliers...")
log.info('Iter %d/%d: %d outliers' %
(0, self.oiter, len(self.outmask)))
def M(x): return np.delete(x, np.concatenate(
[self... | python | def get_outliers(self):
'''
Performs iterative sigma clipping to get outliers.
'''
log.info("Clipping outliers...")
log.info('Iter %d/%d: %d outliers' %
(0, self.oiter, len(self.outmask)))
def M(x): return np.delete(x, np.concatenate(
[self... | [
"def",
"get_outliers",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Clipping outliers...\"",
")",
"log",
".",
"info",
"(",
"'Iter %d/%d: %d outliers'",
"%",
"(",
"0",
",",
"self",
".",
"oiter",
",",
"len",
"(",
"self",
".",
"outmask",
")",
")",
"... | Performs iterative sigma clipping to get outliers. | [
"Performs",
"iterative",
"sigma",
"clipping",
"to",
"get",
"outliers",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L399-L448 | train |
rodluger/everest | everest/detrender.py | Detrender.optimize_lambda | def optimize_lambda(self, validation):
'''
Returns the index of :py:attr:`self.lambda_arr` that minimizes the
validation scatter in the segment with minimum at the lowest value
of :py:obj:`lambda`, with
fractional tolerance :py:attr:`self.leps`.
:param numpy.ndarray vali... | python | def optimize_lambda(self, validation):
'''
Returns the index of :py:attr:`self.lambda_arr` that minimizes the
validation scatter in the segment with minimum at the lowest value
of :py:obj:`lambda`, with
fractional tolerance :py:attr:`self.leps`.
:param numpy.ndarray vali... | [
"def",
"optimize_lambda",
"(",
"self",
",",
"validation",
")",
":",
"maxm",
"=",
"0",
"minr",
"=",
"len",
"(",
"validation",
")",
"for",
"n",
"in",
"range",
"(",
"validation",
".",
"shape",
"[",
"1",
"]",
")",
":",
"# The index that minimizes the scatter f... | Returns the index of :py:attr:`self.lambda_arr` that minimizes the
validation scatter in the segment with minimum at the lowest value
of :py:obj:`lambda`, with
fractional tolerance :py:attr:`self.leps`.
:param numpy.ndarray validation: The scatter in the validation set \
... | [
"Returns",
"the",
"index",
"of",
":",
"py",
":",
"attr",
":",
"self",
".",
"lambda_arr",
"that",
"minimizes",
"the",
"validation",
"scatter",
"in",
"the",
"segment",
"with",
"minimum",
"at",
"the",
"lowest",
"value",
"of",
":",
"py",
":",
"obj",
":",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L450-L477 | train |
rodluger/everest | everest/detrender.py | Detrender.cross_validate | def cross_validate(self, ax, info=''):
'''
Cross-validate to find the optimal value of :py:obj:`lambda`.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance to \
plot the cross-validation results.
:param str info: The label to show in the bottom right-hand co... | python | def cross_validate(self, ax, info=''):
'''
Cross-validate to find the optimal value of :py:obj:`lambda`.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance to \
plot the cross-validation results.
:param str info: The label to show in the bottom right-hand co... | [
"def",
"cross_validate",
"(",
"self",
",",
"ax",
",",
"info",
"=",
"''",
")",
":",
"# Loop over all chunks",
"ax",
"=",
"np",
".",
"atleast_1d",
"(",
"ax",
")",
"for",
"b",
",",
"brkpt",
"in",
"enumerate",
"(",
"self",
".",
"breakpoints",
")",
":",
"... | Cross-validate to find the optimal value of :py:obj:`lambda`.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance to \
plot the cross-validation results.
:param str info: The label to show in the bottom right-hand corner \
of the plot. Default `''` | [
"Cross",
"-",
"validate",
"to",
"find",
"the",
"optimal",
"value",
"of",
":",
"py",
":",
"obj",
":",
"lambda",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L498-L688 | train |
rodluger/everest | everest/detrender.py | Detrender.get_ylim | def get_ylim(self):
'''
Computes the ideal y-axis limits for the light curve plot. Attempts to
set the limits equal to those of the raw light curve, but if more than
1% of the flux lies either above or below these limits, auto-expands
to include those points. At the end, adds 5% ... | python | def get_ylim(self):
'''
Computes the ideal y-axis limits for the light curve plot. Attempts to
set the limits equal to those of the raw light curve, but if more than
1% of the flux lies either above or below these limits, auto-expands
to include those points. At the end, adds 5% ... | [
"def",
"get_ylim",
"(",
"self",
")",
":",
"bn",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"set",
"(",
"np",
".",
"concatenate",
"(",
"[",
"self",
".",
"badmask",
",",
"self",
".",
"nanmask",
"]",
")",
")",
")",
",",
"dtype",
"=",
"int",
")",
... | Computes the ideal y-axis limits for the light curve plot. Attempts to
set the limits equal to those of the raw light curve, but if more than
1% of the flux lies either above or below these limits, auto-expands
to include those points. At the end, adds 5% padding to both the
top and the ... | [
"Computes",
"the",
"ideal",
"y",
"-",
"axis",
"limits",
"for",
"the",
"light",
"curve",
"plot",
".",
"Attempts",
"to",
"set",
"the",
"limits",
"equal",
"to",
"those",
"of",
"the",
"raw",
"light",
"curve",
"but",
"if",
"more",
"than",
"1%",
"of",
"the",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L700-L722 | train |
rodluger/everest | everest/detrender.py | Detrender.plot_lc | def plot_lc(self, ax, info_left='', info_right='', color='b'):
'''
Plots the current light curve. This is called at several stages to
plot the de-trending progress as a function of the different
*PLD* orders.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance
... | python | def plot_lc(self, ax, info_left='', info_right='', color='b'):
'''
Plots the current light curve. This is called at several stages to
plot the de-trending progress as a function of the different
*PLD* orders.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance
... | [
"def",
"plot_lc",
"(",
"self",
",",
"ax",
",",
"info_left",
"=",
"''",
",",
"info_right",
"=",
"''",
",",
"color",
"=",
"'b'",
")",
":",
"# Plot",
"if",
"(",
"self",
".",
"cadence",
"==",
"'lc'",
")",
"or",
"(",
"len",
"(",
"self",
".",
"time",
... | Plots the current light curve. This is called at several stages to
plot the de-trending progress as a function of the different
*PLD* orders.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance
:param str info_left: Information to display at the left of the \
... | [
"Plots",
"the",
"current",
"light",
"curve",
".",
"This",
"is",
"called",
"at",
"several",
"stages",
"to",
"plot",
"the",
"de",
"-",
"trending",
"progress",
"as",
"a",
"function",
"of",
"the",
"different",
"*",
"PLD",
"*",
"orders",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L724-L835 | train |
rodluger/everest | everest/detrender.py | Detrender.plot_final | def plot_final(self, ax):
'''
Plots the final de-trended light curve.
'''
# Plot the light curve
bnmask = np.array(
list(set(np.concatenate([self.badmask, self.nanmask]))), dtype=int)
def M(x): return np.delete(x, bnmask)
if (self.cadence == 'lc') o... | python | def plot_final(self, ax):
'''
Plots the final de-trended light curve.
'''
# Plot the light curve
bnmask = np.array(
list(set(np.concatenate([self.badmask, self.nanmask]))), dtype=int)
def M(x): return np.delete(x, bnmask)
if (self.cadence == 'lc') o... | [
"def",
"plot_final",
"(",
"self",
",",
"ax",
")",
":",
"# Plot the light curve",
"bnmask",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"set",
"(",
"np",
".",
"concatenate",
"(",
"[",
"self",
".",
"badmask",
",",
"self",
".",
"nanmask",
"]",
")",
")",
... | Plots the final de-trended light curve. | [
"Plots",
"the",
"final",
"de",
"-",
"trended",
"light",
"curve",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L837-L894 | train |
rodluger/everest | everest/detrender.py | Detrender.plot_cbv | def plot_cbv(self, ax, flux, info, show_cbv=False):
'''
Plots the final CBV-corrected light curve.
'''
# Plot the light curve
bnmask = np.array(
list(set(np.concatenate([self.badmask, self.nanmask]))), dtype=int)
def M(x): return np.delete(x, bnmask)
... | python | def plot_cbv(self, ax, flux, info, show_cbv=False):
'''
Plots the final CBV-corrected light curve.
'''
# Plot the light curve
bnmask = np.array(
list(set(np.concatenate([self.badmask, self.nanmask]))), dtype=int)
def M(x): return np.delete(x, bnmask)
... | [
"def",
"plot_cbv",
"(",
"self",
",",
"ax",
",",
"flux",
",",
"info",
",",
"show_cbv",
"=",
"False",
")",
":",
"# Plot the light curve",
"bnmask",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"set",
"(",
"np",
".",
"concatenate",
"(",
"[",
"self",
".",
... | Plots the final CBV-corrected light curve. | [
"Plots",
"the",
"final",
"CBV",
"-",
"corrected",
"light",
"curve",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L896-L942 | train |
rodluger/everest | everest/detrender.py | Detrender.load_tpf | def load_tpf(self):
'''
Loads the target pixel file.
'''
if not self.loaded:
if self._data is not None:
data = self._data
else:
data = self._mission.GetData(
self.ID, season=self.season,
... | python | def load_tpf(self):
'''
Loads the target pixel file.
'''
if not self.loaded:
if self._data is not None:
data = self._data
else:
data = self._mission.GetData(
self.ID, season=self.season,
... | [
"def",
"load_tpf",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"loaded",
":",
"if",
"self",
".",
"_data",
"is",
"not",
"None",
":",
"data",
"=",
"self",
".",
"_data",
"else",
":",
"data",
"=",
"self",
".",
"_mission",
".",
"GetData",
"(",
"s... | Loads the target pixel file. | [
"Loads",
"the",
"target",
"pixel",
"file",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L944-L997 | train |
rodluger/everest | everest/detrender.py | Detrender.load_model | def load_model(self, name=None):
'''
Loads a saved version of the model.
'''
if self.clobber:
return False
if name is None:
name = self.name
file = os.path.join(self.dir, '%s.npz' % name)
if os.path.exists(file):
if not self.... | python | def load_model(self, name=None):
'''
Loads a saved version of the model.
'''
if self.clobber:
return False
if name is None:
name = self.name
file = os.path.join(self.dir, '%s.npz' % name)
if os.path.exists(file):
if not self.... | [
"def",
"load_model",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"self",
".",
"clobber",
":",
"return",
"False",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"name",
"file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self... | Loads a saved version of the model. | [
"Loads",
"a",
"saved",
"version",
"of",
"the",
"model",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L999-L1056 | train |
rodluger/everest | everest/detrender.py | Detrender.save_model | def save_model(self):
'''
Saves all of the de-trending information to disk in an `npz` file
and saves the DVS as a `pdf`.
'''
# Save the data
log.info("Saving data to '%s.npz'..." % self.name)
d = dict(self.__dict__)
d.pop('_weights', None)
d.pop... | python | def save_model(self):
'''
Saves all of the de-trending information to disk in an `npz` file
and saves the DVS as a `pdf`.
'''
# Save the data
log.info("Saving data to '%s.npz'..." % self.name)
d = dict(self.__dict__)
d.pop('_weights', None)
d.pop... | [
"def",
"save_model",
"(",
"self",
")",
":",
"# Save the data",
"log",
".",
"info",
"(",
"\"Saving data to '%s.npz'...\"",
"%",
"self",
".",
"name",
")",
"d",
"=",
"dict",
"(",
"self",
".",
"__dict__",
")",
"d",
".",
"pop",
"(",
"'_weights'",
",",
"None",... | Saves all of the de-trending information to disk in an `npz` file
and saves the DVS as a `pdf`. | [
"Saves",
"all",
"of",
"the",
"de",
"-",
"trending",
"information",
"to",
"disk",
"in",
"an",
"npz",
"file",
"and",
"saves",
"the",
"DVS",
"as",
"a",
"pdf",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1058-L1091 | train |
rodluger/everest | everest/detrender.py | Detrender.exception_handler | def exception_handler(self, pdb):
'''
A custom exception handler.
:param pdb: If :py:obj:`True`, enters PDB post-mortem \
mode for debugging.
'''
# Grab the exception
exctype, value, tb = sys.exc_info()
# Log the error and create a .err file
... | python | def exception_handler(self, pdb):
'''
A custom exception handler.
:param pdb: If :py:obj:`True`, enters PDB post-mortem \
mode for debugging.
'''
# Grab the exception
exctype, value, tb = sys.exc_info()
# Log the error and create a .err file
... | [
"def",
"exception_handler",
"(",
"self",
",",
"pdb",
")",
":",
"# Grab the exception",
"exctype",
",",
"value",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"# Log the error and create a .err file",
"errfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"... | A custom exception handler.
:param pdb: If :py:obj:`True`, enters PDB post-mortem \
mode for debugging. | [
"A",
"custom",
"exception",
"handler",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1093-L1119 | train |
rodluger/everest | everest/detrender.py | Detrender.update_gp | def update_gp(self):
'''
Calls :py:func:`gp.GetKernelParams` to optimize the GP and obtain the
covariance matrix for the regression.
'''
self.kernel_params = GetKernelParams(self.time, self.flux,
self.fraw_err,
... | python | def update_gp(self):
'''
Calls :py:func:`gp.GetKernelParams` to optimize the GP and obtain the
covariance matrix for the regression.
'''
self.kernel_params = GetKernelParams(self.time, self.flux,
self.fraw_err,
... | [
"def",
"update_gp",
"(",
"self",
")",
":",
"self",
".",
"kernel_params",
"=",
"GetKernelParams",
"(",
"self",
".",
"time",
",",
"self",
".",
"flux",
",",
"self",
".",
"fraw_err",
",",
"mask",
"=",
"self",
".",
"mask",
",",
"guess",
"=",
"self",
".",
... | Calls :py:func:`gp.GetKernelParams` to optimize the GP and obtain the
covariance matrix for the regression. | [
"Calls",
":",
"py",
":",
"func",
":",
"gp",
".",
"GetKernelParams",
"to",
"optimize",
"the",
"GP",
"and",
"obtain",
"the",
"covariance",
"matrix",
"for",
"the",
"regression",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1121-L1134 | train |
rodluger/everest | everest/detrender.py | Detrender.init_kernel | def init_kernel(self):
'''
Initializes the covariance matrix with a guess at
the GP kernel parameters.
'''
if self.kernel_params is None:
X = self.apply_mask(self.fpix / self.flux.reshape(-1, 1))
y = self.apply_mask(self.flux) - np.dot(X, np.linalg.solve... | python | def init_kernel(self):
'''
Initializes the covariance matrix with a guess at
the GP kernel parameters.
'''
if self.kernel_params is None:
X = self.apply_mask(self.fpix / self.flux.reshape(-1, 1))
y = self.apply_mask(self.flux) - np.dot(X, np.linalg.solve... | [
"def",
"init_kernel",
"(",
"self",
")",
":",
"if",
"self",
".",
"kernel_params",
"is",
"None",
":",
"X",
"=",
"self",
".",
"apply_mask",
"(",
"self",
".",
"fpix",
"/",
"self",
".",
"flux",
".",
"reshape",
"(",
"-",
"1",
",",
"1",
")",
")",
"y",
... | Initializes the covariance matrix with a guess at
the GP kernel parameters. | [
"Initializes",
"the",
"covariance",
"matrix",
"with",
"a",
"guess",
"at",
"the",
"GP",
"kernel",
"parameters",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1136-L1153 | train |
rodluger/everest | everest/detrender.py | Detrender.run | def run(self):
'''
Runs the de-trending step.
'''
try:
# Load raw data
log.info("Loading target data...")
self.load_tpf()
self.mask_planets()
self.plot_aperture([self.dvs.top_right() for i in range(4)])
self.init_... | python | def run(self):
'''
Runs the de-trending step.
'''
try:
# Load raw data
log.info("Loading target data...")
self.load_tpf()
self.mask_planets()
self.plot_aperture([self.dvs.top_right() for i in range(4)])
self.init_... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"# Load raw data",
"log",
".",
"info",
"(",
"\"Loading target data...\"",
")",
"self",
".",
"load_tpf",
"(",
")",
"self",
".",
"mask_planets",
"(",
")",
"self",
".",
"plot_aperture",
"(",
"[",
"self",
".",... | Runs the de-trending step. | [
"Runs",
"the",
"de",
"-",
"trending",
"step",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1170-L1219 | train |
rodluger/everest | everest/detrender.py | Detrender.publish | def publish(self, **kwargs):
'''
Correct the light curve with the CBVs, generate a
cover page for the DVS figure,
and produce a FITS file for publication.
'''
try:
# HACK: Force these params for publication
self.cbv_win = 999
self.cb... | python | def publish(self, **kwargs):
'''
Correct the light curve with the CBVs, generate a
cover page for the DVS figure,
and produce a FITS file for publication.
'''
try:
# HACK: Force these params for publication
self.cbv_win = 999
self.cb... | [
"def",
"publish",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"# HACK: Force these params for publication",
"self",
".",
"cbv_win",
"=",
"999",
"self",
".",
"cbv_order",
"=",
"3",
"self",
".",
"cbv_num",
"=",
"1",
"# Get the CBVs",
"self",
... | Correct the light curve with the CBVs, generate a
cover page for the DVS figure,
and produce a FITS file for publication. | [
"Correct",
"the",
"light",
"curve",
"with",
"the",
"CBVs",
"generate",
"a",
"cover",
"page",
"for",
"the",
"DVS",
"figure",
"and",
"produce",
"a",
"FITS",
"file",
"for",
"publication",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1221-L1279 | train |
rodluger/everest | everest/detrender.py | nPLD.setup | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param tuple cdpp_range: If :py:obj:`parent_model` is set, \
neighbors are selected only if \
their de-trended CDPPs fall wit... | python | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param tuple cdpp_range: If :py:obj:`parent_model` is set, \
neighbors are selected only if \
their de-trended CDPPs fall wit... | [
"def",
"setup",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get neighbors",
"self",
".",
"parent_model",
"=",
"kwargs",
".",
"get",
"(",
"'parent_model'",
",",
"None",
")",
"neighbors",
"=",
"kwargs",
".",
"get",
"(",
"'neighbors'",
",",
"10",
"... | This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param tuple cdpp_range: If :py:obj:`parent_model` is set, \
neighbors are selected only if \
their de-trended CDPPs fall within this range. Default `None`
:param t... | [
"This",
"is",
"called",
"during",
"production",
"de",
"-",
"trending",
"prior",
"to",
"calling",
"the",
":",
"py",
":",
"obj",
":",
"Detrender",
".",
"run",
"()",
"method",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1336-L1458 | train |
rodluger/everest | everest/detrender.py | iPLD.setup | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param str parent_model: The name of the model to operate on. \
Default `nPLD`
'''
# Load the parent model
self.pa... | python | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param str parent_model: The name of the model to operate on. \
Default `nPLD`
'''
# Load the parent model
self.pa... | [
"def",
"setup",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Load the parent model",
"self",
".",
"parent_model",
"=",
"kwargs",
".",
"get",
"(",
"'parent_model'",
",",
"'nPLD'",
")",
"if",
"not",
"self",
".",
"load_model",
"(",
"self",
".",
"paren... | This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param str parent_model: The name of the model to operate on. \
Default `nPLD` | [
"This",
"is",
"called",
"during",
"production",
"de",
"-",
"trending",
"prior",
"to",
"calling",
"the",
":",
"py",
":",
"obj",
":",
"Detrender",
".",
"run",
"()",
"method",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1469-L1505 | train |
rodluger/everest | everest/detrender.py | pPLD.setup | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param inter piter: The number of iterations in the minimizer. \
Default 3
:param int pmaxf: The maximum number of function evaluati... | python | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param inter piter: The number of iterations in the minimizer. \
Default 3
:param int pmaxf: The maximum number of function evaluati... | [
"def",
"setup",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Check for saved model",
"clobber",
"=",
"self",
".",
"clobber",
"self",
".",
"clobber",
"=",
"False",
"if",
"not",
"self",
".",
"load_model",
"(",
"'nPLD'",
")",
":",
"raise",
"Exception"... | This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param inter piter: The number of iterations in the minimizer. \
Default 3
:param int pmaxf: The maximum number of function evaluations per \
iteration. Default 300... | [
"This",
"is",
"called",
"during",
"production",
"de",
"-",
"trending",
"prior",
"to",
"calling",
"the",
":",
"py",
":",
"obj",
":",
"Detrender",
".",
"run",
"()",
"method",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1515-L1539 | train |
rodluger/everest | everest/detrender.py | pPLD.run | def run(self):
'''
Runs the de-trending.
'''
try:
# Plot original
self.plot_aperture([self.dvs.top_right() for i in range(4)])
self.plot_lc(self.dvs.left(), info_right='nPLD', color='k')
# Cross-validate
self.cross_validate(... | python | def run(self):
'''
Runs the de-trending.
'''
try:
# Plot original
self.plot_aperture([self.dvs.top_right() for i in range(4)])
self.plot_lc(self.dvs.left(), info_right='nPLD', color='k')
# Cross-validate
self.cross_validate(... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"# Plot original",
"self",
".",
"plot_aperture",
"(",
"[",
"self",
".",
"dvs",
".",
"top_right",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"4",
")",
"]",
")",
"self",
".",
"plot_lc",
"(",
"self",
"... | Runs the de-trending. | [
"Runs",
"the",
"de",
"-",
"trending",
"."
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1541-L1569 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.