repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L300-L309 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L327-L373 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L375-L397 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L399-L448 |
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",
":",
"... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L450-L477 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L498-L688 |
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",... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L700-L722 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L724-L835 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L837-L894 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L896-L942 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L944-L997 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L999-L1056 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1058-L1091 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1093-L1119 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1121-L1134 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1136-L1153 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1170-L1219 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1221-L1279 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1336-L1458 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1469-L1505 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1515-L1539 |
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",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1541-L1569 |
rodluger/everest | everest/detrender.py | pPLD.cross_validate | def cross_validate(self, ax):
'''
Performs the cross-validation step.
'''
# The CDPP to beat
cdpp_opt = self.get_cdpp_arr()
# Loop over all chunks
for b, brkpt in enumerate(self.breakpoints):
log.info("Cross-validating chunk %d/%d..." %
... | python | def cross_validate(self, ax):
'''
Performs the cross-validation step.
'''
# The CDPP to beat
cdpp_opt = self.get_cdpp_arr()
# Loop over all chunks
for b, brkpt in enumerate(self.breakpoints):
log.info("Cross-validating chunk %d/%d..." %
... | [
"def",
"cross_validate",
"(",
"self",
",",
"ax",
")",
":",
"# The CDPP to beat",
"cdpp_opt",
"=",
"self",
".",
"get_cdpp_arr",
"(",
")",
"# Loop over all chunks",
"for",
"b",
",",
"brkpt",
"in",
"enumerate",
"(",
"self",
".",
"breakpoints",
")",
":",
"log",
... | Performs the cross-validation step. | [
"Performs",
"the",
"cross",
"-",
"validation",
"step",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1571-L1676 |
rodluger/everest | everest/detrender.py | pPLD.validation_scatter | def validation_scatter(self, log_lam, b, masks, pre_v, gp, flux,
time, med):
'''
Computes the scatter in the validation set.
'''
# Update the lambda matrix
self.lam[b] = 10 ** log_lam
# Validation set scatter
scatter = [None for i in ... | python | def validation_scatter(self, log_lam, b, masks, pre_v, gp, flux,
time, med):
'''
Computes the scatter in the validation set.
'''
# Update the lambda matrix
self.lam[b] = 10 ** log_lam
# Validation set scatter
scatter = [None for i in ... | [
"def",
"validation_scatter",
"(",
"self",
",",
"log_lam",
",",
"b",
",",
"masks",
",",
"pre_v",
",",
"gp",
",",
"flux",
",",
"time",
",",
"med",
")",
":",
"# Update the lambda matrix",
"self",
".",
"lam",
"[",
"b",
"]",
"=",
"10",
"**",
"log_lam",
"#... | Computes the scatter in the validation set. | [
"Computes",
"the",
"scatter",
"in",
"the",
"validation",
"set",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1678-L1703 |
lsbardel/python-stdnet | stdnet/utils/populate.py | populate | def populate(datatype='string', size=10, start=None, end=None,
converter=None, choice_from=None, **kwargs):
'''Utility function for populating lists with random data.
Useful for populating database with data for fuzzy testing.
Supported data-types
* *string*
For example::
populat... | python | def populate(datatype='string', size=10, start=None, end=None,
converter=None, choice_from=None, **kwargs):
'''Utility function for populating lists with random data.
Useful for populating database with data for fuzzy testing.
Supported data-types
* *string*
For example::
populat... | [
"def",
"populate",
"(",
"datatype",
"=",
"'string'",
",",
"size",
"=",
"10",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"converter",
"=",
"None",
",",
"choice_from",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"[",
... | Utility function for populating lists with random data.
Useful for populating database with data for fuzzy testing.
Supported data-types
* *string*
For example::
populate('string',100, min_len=3, max_len=10)
create a 100 elements list with random strings
with random length between 3 and... | [
"Utility",
"function",
"for",
"populating",
"lists",
"with",
"random",
"data",
".",
"Useful",
"for",
"populating",
"database",
"with",
"data",
"for",
"fuzzy",
"testing",
".",
"Supported",
"data",
"-",
"types",
"*",
"*",
"string",
"*",
"For",
"example",
"::",... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/populate.py#L16-L84 |
rodluger/everest | everest/search.py | Search | def Search(star, pos_tol=2.5, neg_tol=50., **ps_kwargs):
'''
NOTE: `pos_tol` is the positive (i.e., above the median)
outlier tolerance in standard deviations.
NOTE: `neg_tol` is the negative (i.e., below the median)
outlier tolerance in standard deviations.
'''
# Smooth the light curve
... | python | def Search(star, pos_tol=2.5, neg_tol=50., **ps_kwargs):
'''
NOTE: `pos_tol` is the positive (i.e., above the median)
outlier tolerance in standard deviations.
NOTE: `neg_tol` is the negative (i.e., below the median)
outlier tolerance in standard deviations.
'''
# Smooth the light curve
... | [
"def",
"Search",
"(",
"star",
",",
"pos_tol",
"=",
"2.5",
",",
"neg_tol",
"=",
"50.",
",",
"*",
"*",
"ps_kwargs",
")",
":",
"# Smooth the light curve",
"t",
"=",
"np",
".",
"delete",
"(",
"star",
".",
"time",
",",
"np",
".",
"concatenate",
"(",
"[",
... | NOTE: `pos_tol` is the positive (i.e., above the median)
outlier tolerance in standard deviations.
NOTE: `neg_tol` is the negative (i.e., below the median)
outlier tolerance in standard deviations. | [
"NOTE",
":",
"pos_tol",
"is",
"the",
"positive",
"(",
"i",
".",
"e",
".",
"above",
"the",
"median",
")",
"outlier",
"tolerance",
"in",
"standard",
"deviations",
".",
"NOTE",
":",
"neg_tol",
"is",
"the",
"negative",
"(",
"i",
".",
"e",
".",
"below",
"... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/search.py#L29-L131 |
lsbardel/python-stdnet | stdnet/odm/session.py | SessionModel.iterdirty | def iterdirty(self):
'''Ordered iterator over dirty elements.'''
return iter(chain(itervalues(self._new), itervalues(self._modified))) | python | def iterdirty(self):
'''Ordered iterator over dirty elements.'''
return iter(chain(itervalues(self._new), itervalues(self._modified))) | [
"def",
"iterdirty",
"(",
"self",
")",
":",
"return",
"iter",
"(",
"chain",
"(",
"itervalues",
"(",
"self",
".",
"_new",
")",
",",
"itervalues",
"(",
"self",
".",
"_modified",
")",
")",
")"
] | Ordered iterator over dirty elements. | [
"Ordered",
"iterator",
"over",
"dirty",
"elements",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L108-L110 |
lsbardel/python-stdnet | stdnet/odm/session.py | SessionModel.add | def add(self, instance, modified=True, persistent=None,
force_update=False):
'''Add a new instance to this :class:`SessionModel`.
:param modified: Optional flag indicating if the ``instance`` has been
modified. By default its value is ``True``.
:param force_update: if ``instance`` is pers... | python | def add(self, instance, modified=True, persistent=None,
force_update=False):
'''Add a new instance to this :class:`SessionModel`.
:param modified: Optional flag indicating if the ``instance`` has been
modified. By default its value is ``True``.
:param force_update: if ``instance`` is pers... | [
"def",
"add",
"(",
"self",
",",
"instance",
",",
"modified",
"=",
"True",
",",
"persistent",
"=",
"None",
",",
"force_update",
"=",
"False",
")",
":",
"if",
"instance",
".",
"_meta",
".",
"type",
"==",
"'structure'",
":",
"return",
"self",
".",
"_add_s... | Add a new instance to this :class:`SessionModel`.
:param modified: Optional flag indicating if the ``instance`` has been
modified. By default its value is ``True``.
:param force_update: if ``instance`` is persistent, it forces an update of the
data rather than a full replacement. This is used by the
... | [
"Add",
"a",
"new",
"instance",
"to",
"this",
":",
"class",
":",
"SessionModel",
".",
":",
"param",
"modified",
":",
"Optional",
"flag",
"indicating",
"if",
"the",
"instance",
"has",
"been",
"modified",
".",
"By",
"default",
"its",
"value",
"is",
"True",
... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L119-L152 |
lsbardel/python-stdnet | stdnet/odm/session.py | SessionModel.delete | def delete(self, instance, session):
'''delete an *instance*'''
if instance._meta.type == 'structure':
return self._delete_structure(instance)
inst = self.pop(instance)
instance = inst if inst is not None else instance
if instance is not None:
state... | python | def delete(self, instance, session):
'''delete an *instance*'''
if instance._meta.type == 'structure':
return self._delete_structure(instance)
inst = self.pop(instance)
instance = inst if inst is not None else instance
if instance is not None:
state... | [
"def",
"delete",
"(",
"self",
",",
"instance",
",",
"session",
")",
":",
"if",
"instance",
".",
"_meta",
".",
"type",
"==",
"'structure'",
":",
"return",
"self",
".",
"_delete_structure",
"(",
"instance",
")",
"inst",
"=",
"self",
".",
"pop",
"(",
"ins... | delete an *instance* | [
"delete",
"an",
"*",
"instance",
"*"
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L154-L168 |
lsbardel/python-stdnet | stdnet/odm/session.py | SessionModel.pop | def pop(self, instance):
'''Remove ``instance`` from the :class:`SessionModel`. Instance
could be a :class:`Model` or an id.
:parameter instance: a :class:`Model` or an ``id``.
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session.
'''
if isinstance(instan... | python | def pop(self, instance):
'''Remove ``instance`` from the :class:`SessionModel`. Instance
could be a :class:`Model` or an id.
:parameter instance: a :class:`Model` or an ``id``.
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session.
'''
if isinstance(instan... | [
"def",
"pop",
"(",
"self",
",",
"instance",
")",
":",
"if",
"isinstance",
"(",
"instance",
",",
"self",
".",
"model",
")",
":",
"iid",
"=",
"instance",
".",
"get_state",
"(",
")",
".",
"iid",
"else",
":",
"iid",
"=",
"instance",
"instance",
"=",
"N... | Remove ``instance`` from the :class:`SessionModel`. Instance
could be a :class:`Model` or an id.
:parameter instance: a :class:`Model` or an ``id``.
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session. | [
"Remove",
"instance",
"from",
"the",
":",
"class",
":",
"SessionModel",
".",
"Instance",
"could",
"be",
"a",
":",
"class",
":",
"Model",
"or",
"an",
"id",
".",
":",
"parameter",
"instance",
":",
"a",
":",
"class",
":",
"Model",
"or",
"an",
"id",
".",... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L170-L190 |
lsbardel/python-stdnet | stdnet/odm/session.py | SessionModel.expunge | def expunge(self, instance):
'''Remove *instance* from the :class:`Session`. Instance could be a
:class:`Model` or an id.
:parameter instance: a :class:`Model` or an *id*
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session.
'''
instance = self.pop(instan... | python | def expunge(self, instance):
'''Remove *instance* from the :class:`Session`. Instance could be a
:class:`Model` or an id.
:parameter instance: a :class:`Model` or an *id*
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session.
'''
instance = self.pop(instan... | [
"def",
"expunge",
"(",
"self",
",",
"instance",
")",
":",
"instance",
"=",
"self",
".",
"pop",
"(",
"instance",
")",
"instance",
".",
"session",
"=",
"None",
"return",
"instance"
] | Remove *instance* from the :class:`Session`. Instance could be a
:class:`Model` or an id.
:parameter instance: a :class:`Model` or an *id*
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session. | [
"Remove",
"*",
"instance",
"*",
"from",
"the",
":",
"class",
":",
"Session",
".",
"Instance",
"could",
"be",
"a",
":",
"class",
":",
"Model",
"or",
"an",
"id",
".",
":",
"parameter",
"instance",
":",
"a",
":",
"class",
":",
"Model",
"or",
"an",
"*"... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L192-L202 |
lsbardel/python-stdnet | stdnet/odm/session.py | SessionModel.post_commit | def post_commit(self, results):
'''\
Process results after a commit.
:parameter results: iterator over :class:`stdnet.instance_session_result`
items.
:rtype: a two elements tuple containing a list of instances saved and
a list of ids of instances deleted.'''
tpy = self._meta.pk_to_pytho... | python | def post_commit(self, results):
'''\
Process results after a commit.
:parameter results: iterator over :class:`stdnet.instance_session_result`
items.
:rtype: a two elements tuple containing a list of instances saved and
a list of ids of instances deleted.'''
tpy = self._meta.pk_to_pytho... | [
"def",
"post_commit",
"(",
"self",
",",
"results",
")",
":",
"tpy",
"=",
"self",
".",
"_meta",
".",
"pk_to_python",
"instances",
"=",
"[",
"]",
"deleted",
"=",
"[",
"]",
"errors",
"=",
"[",
"]",
"# The length of results must be the same as the length of\r",
"#... | \
Process results after a commit.
:parameter results: iterator over :class:`stdnet.instance_session_result`
items.
:rtype: a two elements tuple containing a list of instances saved and
a list of ids of instances deleted. | [
"\\",
"Process",
"results",
"after",
"a",
"commit",
".",
":",
"parameter",
"results",
":",
"iterator",
"over",
":",
"class",
":",
"stdnet",
".",
"instance_session_result",
"items",
".",
":",
"rtype",
":",
"a",
"two",
"elements",
"tuple",
"containing",
"a",
... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L204-L238 |
lsbardel/python-stdnet | stdnet/odm/session.py | Transaction.commit | def commit(self, callback=None):
'''Close the transaction and commit session to the backend.'''
if self.executed:
raise InvalidTransaction('Invalid operation. '
'Transaction already executed.')
session = self.session
self.session = N... | python | def commit(self, callback=None):
'''Close the transaction and commit session to the backend.'''
if self.executed:
raise InvalidTransaction('Invalid operation. '
'Transaction already executed.')
session = self.session
self.session = N... | [
"def",
"commit",
"(",
"self",
",",
"callback",
"=",
"None",
")",
":",
"if",
"self",
".",
"executed",
":",
"raise",
"InvalidTransaction",
"(",
"'Invalid operation. '",
"'Transaction already executed.'",
")",
"session",
"=",
"self",
".",
"session",
"self",
".",
... | Close the transaction and commit session to the backend. | [
"Close",
"the",
"transaction",
"and",
"commit",
"session",
"to",
"the",
"backend",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L427-L435 |
lsbardel/python-stdnet | stdnet/odm/session.py | Session.dirty | def dirty(self):
'''The set of instances in this :class:`Session` which have
been modified.'''
return frozenset(chain(*tuple((sm.dirty for sm
in itervalues(self._models))))) | python | def dirty(self):
'''The set of instances in this :class:`Session` which have
been modified.'''
return frozenset(chain(*tuple((sm.dirty for sm
in itervalues(self._models))))) | [
"def",
"dirty",
"(",
"self",
")",
":",
"return",
"frozenset",
"(",
"chain",
"(",
"*",
"tuple",
"(",
"(",
"sm",
".",
"dirty",
"for",
"sm",
"in",
"itervalues",
"(",
"self",
".",
"_models",
")",
")",
")",
")",
")"
] | The set of instances in this :class:`Session` which have
been modified. | [
"The",
"set",
"of",
"instances",
"in",
"this",
":",
"class",
":",
"Session",
"which",
"have",
"been",
"modified",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L547-L551 |
lsbardel/python-stdnet | stdnet/odm/session.py | Session.begin | def begin(self, **options):
'''Begin a new :class:`Transaction`. If this :class:`Session`
is already in a :ref:`transactional state <transactional-state>`,
an error will occur. It returns the :attr:`transaction` attribute.
This method is mostly used within a ``with`` statement block::
with session.... | python | def begin(self, **options):
'''Begin a new :class:`Transaction`. If this :class:`Session`
is already in a :ref:`transactional state <transactional-state>`,
an error will occur. It returns the :attr:`transaction` attribute.
This method is mostly used within a ``with`` statement block::
with session.... | [
"def",
"begin",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"if",
"self",
".",
"transaction",
"is",
"not",
"None",
":",
"raise",
"InvalidTransaction",
"(",
"\"A transaction is already begun.\"",
")",
"else",
":",
"self",
".",
"transaction",
"=",
"Transa... | Begin a new :class:`Transaction`. If this :class:`Session`
is already in a :ref:`transactional state <transactional-state>`,
an error will occur. It returns the :attr:`transaction` attribute.
This method is mostly used within a ``with`` statement block::
with session.begin() as t:
t.add(...)
... | [
"Begin",
"a",
"new",
":",
"class",
":",
"Transaction",
".",
"If",
"this",
":",
"class",
":",
"Session",
"is",
"already",
"in",
"a",
":",
"ref",
":",
"transactional",
"state",
"<transactional",
"-",
"state",
">",
"an",
"error",
"will",
"occur",
".",
"It... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L553-L577 |
lsbardel/python-stdnet | stdnet/odm/session.py | Session.query | def query(self, model, **kwargs):
'''Create a new :class:`Query` for *model*.'''
sm = self.model(model)
query_class = sm.manager.query_class or Query
return query_class(sm._meta, self, **kwargs) | python | def query(self, model, **kwargs):
'''Create a new :class:`Query` for *model*.'''
sm = self.model(model)
query_class = sm.manager.query_class or Query
return query_class(sm._meta, self, **kwargs) | [
"def",
"query",
"(",
"self",
",",
"model",
",",
"*",
"*",
"kwargs",
")",
":",
"sm",
"=",
"self",
".",
"model",
"(",
"model",
")",
"query_class",
"=",
"sm",
".",
"manager",
".",
"query_class",
"or",
"Query",
"return",
"query_class",
"(",
"sm",
".",
... | Create a new :class:`Query` for *model*. | [
"Create",
"a",
"new",
":",
"class",
":",
"Query",
"for",
"*",
"model",
"*",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L590-L594 |
lsbardel/python-stdnet | stdnet/odm/session.py | Session.update_or_create | def update_or_create(self, model, **kwargs):
'''Update or create a new instance of ``model``.
This method can raise an exception if the ``kwargs`` dictionary
contains field data that does not validate.
:param model: a :class:`StdModel`
:param kwargs: dictionary of parame... | python | def update_or_create(self, model, **kwargs):
'''Update or create a new instance of ``model``.
This method can raise an exception if the ``kwargs`` dictionary
contains field data that does not validate.
:param model: a :class:`StdModel`
:param kwargs: dictionary of parame... | [
"def",
"update_or_create",
"(",
"self",
",",
"model",
",",
"*",
"*",
"kwargs",
")",
":",
"backend",
"=",
"self",
".",
"model",
"(",
"model",
")",
".",
"backend",
"return",
"backend",
".",
"execute",
"(",
"self",
".",
"_update_or_create",
"(",
"model",
... | Update or create a new instance of ``model``.
This method can raise an exception if the ``kwargs`` dictionary
contains field data that does not validate.
:param model: a :class:`StdModel`
:param kwargs: dictionary of parameters.
:returns: A two elements tuple containing ... | [
"Update",
"or",
"create",
"a",
"new",
"instance",
"of",
"model",
".",
"This",
"method",
"can",
"raise",
"an",
"exception",
"if",
"the",
"kwargs",
"dictionary",
"contains",
"field",
"data",
"that",
"does",
"not",
"validate",
".",
":",
"param",
"model",
":",... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L600-L612 |
lsbardel/python-stdnet | stdnet/odm/session.py | Session.add | def add(self, instance, modified=True, **params):
'''Add an ``instance`` to the session.
If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the back-end server immediately.
:parameter instance: a :class:`Model` ... | python | def add(self, instance, modified=True, **params):
'''Add an ``instance`` to the session.
If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the back-end server immediately.
:parameter instance: a :class:`Model` ... | [
"def",
"add",
"(",
"self",
",",
"instance",
",",
"modified",
"=",
"True",
",",
"*",
"*",
"params",
")",
":",
"sm",
"=",
"self",
".",
"model",
"(",
"instance",
")",
"instance",
".",
"session",
"=",
"self",
"o",
"=",
"sm",
".",
"add",
"(",
"instanc... | Add an ``instance`` to the session.
If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the back-end server immediately.
:parameter instance: a :class:`Model` instance. It must be registered
with the :attr:`r... | [
"Add",
"an",
"instance",
"to",
"the",
"session",
".",
"If",
"the",
"session",
"is",
"not",
"in",
"a",
":",
"ref",
":",
"transactional",
"state",
"<transactional",
"-",
"state",
">",
"this",
"operation",
"commits",
"changes",
"to",
"the",
"back",
"-",
"en... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L614-L638 |
lsbardel/python-stdnet | stdnet/odm/session.py | Session.delete | def delete(self, instance_or_query):
'''Delete an ``instance`` or a ``query``.
Adds ``instance_or_query`` to this :class:`Session` list
of data to be deleted. If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the... | python | def delete(self, instance_or_query):
'''Delete an ``instance`` or a ``query``.
Adds ``instance_or_query`` to this :class:`Session` list
of data to be deleted. If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the... | [
"def",
"delete",
"(",
"self",
",",
"instance_or_query",
")",
":",
"sm",
"=",
"self",
".",
"model",
"(",
"instance_or_query",
")",
"# not an instance of a Model. Assume it is a query.\r",
"if",
"is_query",
"(",
"instance_or_query",
")",
":",
"if",
"instance_or_query",
... | Delete an ``instance`` or a ``query``.
Adds ``instance_or_query`` to this :class:`Session` list
of data to be deleted. If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the backend server immediately.
:paramete... | [
"Delete",
"an",
"instance",
"or",
"a",
"query",
".",
"Adds",
"instance_or_query",
"to",
"this",
":",
"class",
":",
"Session",
"list",
"of",
"data",
"to",
"be",
"deleted",
".",
"If",
"the",
"session",
"is",
"not",
"in",
"a",
":",
"ref",
":",
"transactio... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L640-L664 |
lsbardel/python-stdnet | stdnet/odm/session.py | Session.model | def model(self, model, create=True):
'''Returns the :class:`SessionModel` for ``model`` which
can be :class:`Model`, or a :class:`MetaClass`, or an instance
of :class:`Model`.'''
manager = self.manager(model)
sm = self._models.get(manager)
if sm is None and create:
sm ... | python | def model(self, model, create=True):
'''Returns the :class:`SessionModel` for ``model`` which
can be :class:`Model`, or a :class:`MetaClass`, or an instance
of :class:`Model`.'''
manager = self.manager(model)
sm = self._models.get(manager)
if sm is None and create:
sm ... | [
"def",
"model",
"(",
"self",
",",
"model",
",",
"create",
"=",
"True",
")",
":",
"manager",
"=",
"self",
".",
"manager",
"(",
"model",
")",
"sm",
"=",
"self",
".",
"_models",
".",
"get",
"(",
"manager",
")",
"if",
"sm",
"is",
"None",
"and",
"crea... | Returns the :class:`SessionModel` for ``model`` which
can be :class:`Model`, or a :class:`MetaClass`, or an instance
of :class:`Model`. | [
"Returns",
"the",
":",
"class",
":",
"SessionModel",
"for",
"model",
"which",
"can",
"be",
":",
"class",
":",
"Model",
"or",
"a",
":",
"class",
":",
"MetaClass",
"or",
"an",
"instance",
"of",
":",
"class",
":",
"Model",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L684-L693 |
lsbardel/python-stdnet | stdnet/odm/session.py | Session.expunge | def expunge(self, instance=None):
'''Remove ``instance`` from this :class:`Session`. If ``instance``
is not given, it removes all instances from this :class:`Session`.'''
if instance is not None:
sm = self._models.get(instance._meta)
if sm:
return sm.expunge... | python | def expunge(self, instance=None):
'''Remove ``instance`` from this :class:`Session`. If ``instance``
is not given, it removes all instances from this :class:`Session`.'''
if instance is not None:
sm = self._models.get(instance._meta)
if sm:
return sm.expunge... | [
"def",
"expunge",
"(",
"self",
",",
"instance",
"=",
"None",
")",
":",
"if",
"instance",
"is",
"not",
"None",
":",
"sm",
"=",
"self",
".",
"_models",
".",
"get",
"(",
"instance",
".",
"_meta",
")",
"if",
"sm",
":",
"return",
"sm",
".",
"expunge",
... | Remove ``instance`` from this :class:`Session`. If ``instance``
is not given, it removes all instances from this :class:`Session`. | [
"Remove",
"instance",
"from",
"this",
":",
"class",
":",
"Session",
".",
"If",
"instance",
"is",
"not",
"given",
"it",
"removes",
"all",
"instances",
"from",
"this",
":",
"class",
":",
"Session",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L695-L703 |
lsbardel/python-stdnet | stdnet/odm/session.py | Session.manager | def manager(self, model):
'''Retrieve the :class:`Manager` for ``model`` which can be any of the
values valid for the :meth:`model` method.'''
try:
return self.router[model]
except KeyError:
meta = getattr(model, '_meta', model)
if meta.type == 'structu... | python | def manager(self, model):
'''Retrieve the :class:`Manager` for ``model`` which can be any of the
values valid for the :meth:`model` method.'''
try:
return self.router[model]
except KeyError:
meta = getattr(model, '_meta', model)
if meta.type == 'structu... | [
"def",
"manager",
"(",
"self",
",",
"model",
")",
":",
"try",
":",
"return",
"self",
".",
"router",
"[",
"model",
"]",
"except",
"KeyError",
":",
"meta",
"=",
"getattr",
"(",
"model",
",",
"'_meta'",
",",
"model",
")",
"if",
"meta",
".",
"type",
"=... | Retrieve the :class:`Manager` for ``model`` which can be any of the
values valid for the :meth:`model` method. | [
"Retrieve",
"the",
":",
"class",
":",
"Manager",
"for",
"model",
"which",
"can",
"be",
"any",
"of",
"the",
"values",
"valid",
"for",
"the",
":",
"meth",
":",
"model",
"method",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L705-L722 |
lsbardel/python-stdnet | stdnet/odm/session.py | Manager.new | def new(self, *args, **kwargs):
'''Create a new instance of :attr:`model` and commit it to the backend
server. This a shortcut method for the more verbose::
instance = manager.session().add(MyModel(**kwargs))
'''
return self.session().add(self.model(*args, **kwargs)) | python | def new(self, *args, **kwargs):
'''Create a new instance of :attr:`model` and commit it to the backend
server. This a shortcut method for the more verbose::
instance = manager.session().add(MyModel(**kwargs))
'''
return self.session().add(self.model(*args, **kwargs)) | [
"def",
"new",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"session",
"(",
")",
".",
"add",
"(",
"self",
".",
"model",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")"
] | Create a new instance of :attr:`model` and commit it to the backend
server. This a shortcut method for the more verbose::
instance = manager.session().add(MyModel(**kwargs)) | [
"Create",
"a",
"new",
"instance",
"of",
":",
"attr",
":",
"model",
"and",
"commit",
"it",
"to",
"the",
"backend",
"server",
".",
"This",
"a",
"shortcut",
"method",
"for",
"the",
"more",
"verbose",
"::",
"instance",
"=",
"manager",
".",
"session",
"()",
... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L924-L930 |
lsbardel/python-stdnet | stdnet/odm/session.py | Manager.query | def query(self, session=None):
'''Returns a new :class:`Query` for :attr:`Manager.model`.'''
if session is None or session.router is not self.router:
session = self.session()
return session.query(self.model) | python | def query(self, session=None):
'''Returns a new :class:`Query` for :attr:`Manager.model`.'''
if session is None or session.router is not self.router:
session = self.session()
return session.query(self.model) | [
"def",
"query",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"if",
"session",
"is",
"None",
"or",
"session",
".",
"router",
"is",
"not",
"self",
".",
"router",
":",
"session",
"=",
"self",
".",
"session",
"(",
")",
"return",
"session",
".",
... | Returns a new :class:`Query` for :attr:`Manager.model`. | [
"Returns",
"a",
"new",
":",
"class",
":",
"Query",
"for",
":",
"attr",
":",
"Manager",
".",
"model",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L957-L961 |
lsbardel/python-stdnet | stdnet/odm/session.py | Manager.search | def search(self, text, lookup=None):
'''Returns a new :class:`Query` for :attr:`Manager.model` with
a full text search value.'''
return self.query().search(text, lookup=lookup) | python | def search(self, text, lookup=None):
'''Returns a new :class:`Query` for :attr:`Manager.model` with
a full text search value.'''
return self.query().search(text, lookup=lookup) | [
"def",
"search",
"(",
"self",
",",
"text",
",",
"lookup",
"=",
"None",
")",
":",
"return",
"self",
".",
"query",
"(",
")",
".",
"search",
"(",
"text",
",",
"lookup",
"=",
"lookup",
")"
] | Returns a new :class:`Query` for :attr:`Manager.model` with
a full text search value. | [
"Returns",
"a",
"new",
":",
"class",
":",
"Query",
"for",
":",
"attr",
":",
"Manager",
".",
"model",
"with",
"a",
"full",
"text",
"search",
"value",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L977-L980 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | pairs_to_dict | def pairs_to_dict(response, encoding):
"Create a dict given a list of key/value pairs"
it = iter(response)
return dict(((k.decode(encoding), v) for k, v in zip(it, it))) | python | def pairs_to_dict(response, encoding):
"Create a dict given a list of key/value pairs"
it = iter(response)
return dict(((k.decode(encoding), v) for k, v in zip(it, it))) | [
"def",
"pairs_to_dict",
"(",
"response",
",",
"encoding",
")",
":",
"it",
"=",
"iter",
"(",
"response",
")",
"return",
"dict",
"(",
"(",
"(",
"k",
".",
"decode",
"(",
"encoding",
")",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"zip",
"(",
"it",
... | Create a dict given a list of key/value pairs | [
"Create",
"a",
"dict",
"given",
"a",
"list",
"of",
"key",
"/",
"value",
"pairs"
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L36-L39 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | odmrun.load_related | def load_related(self, meta, fname, data, fields, encoding):
'''Parse data for related objects.'''
field = meta.dfields[fname]
if field in meta.multifields:
fmeta = field.structure_class()._meta
if fmeta.name in ('hashtable', 'zset'):
return ((native... | python | def load_related(self, meta, fname, data, fields, encoding):
'''Parse data for related objects.'''
field = meta.dfields[fname]
if field in meta.multifields:
fmeta = field.structure_class()._meta
if fmeta.name in ('hashtable', 'zset'):
return ((native... | [
"def",
"load_related",
"(",
"self",
",",
"meta",
",",
"fname",
",",
"data",
",",
"fields",
",",
"encoding",
")",
":",
"field",
"=",
"meta",
".",
"dfields",
"[",
"fname",
"]",
"if",
"field",
"in",
"meta",
".",
"multifields",
":",
"fmeta",
"=",
"field"... | Parse data for related objects. | [
"Parse",
"data",
"for",
"related",
"objects",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L107-L121 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | RedisQuery._execute_query | def _execute_query(self):
'''Execute the query without fetching data. Returns the number of
elements in the query.'''
pipe = self.pipe
if not self.card:
if self.meta.ordering:
self.ismember = getattr(self.backend.client, 'zrank')
self.card = get... | python | def _execute_query(self):
'''Execute the query without fetching data. Returns the number of
elements in the query.'''
pipe = self.pipe
if not self.card:
if self.meta.ordering:
self.ismember = getattr(self.backend.client, 'zrank')
self.card = get... | [
"def",
"_execute_query",
"(",
"self",
")",
":",
"pipe",
"=",
"self",
".",
"pipe",
"if",
"not",
"self",
".",
"card",
":",
"if",
"self",
".",
"meta",
".",
"ordering",
":",
"self",
".",
"ismember",
"=",
"getattr",
"(",
"self",
".",
"backend",
".",
"cl... | Execute the query without fetching data. Returns the number of
elements in the query. | [
"Execute",
"the",
"query",
"without",
"fetching",
"data",
".",
"Returns",
"the",
"number",
"of",
"elements",
"in",
"the",
"query",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L222-L239 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | RedisQuery.order | def order(self, last):
'''Perform ordering with respect model fields.'''
desc = last.desc
field = last.name
nested = last.nested
nested_args = []
while nested:
meta = nested.model._meta
nested_args.extend((self.backend.basekey(meta), nested... | python | def order(self, last):
'''Perform ordering with respect model fields.'''
desc = last.desc
field = last.name
nested = last.nested
nested_args = []
while nested:
meta = nested.model._meta
nested_args.extend((self.backend.basekey(meta), nested... | [
"def",
"order",
"(",
"self",
",",
"last",
")",
":",
"desc",
"=",
"last",
".",
"desc",
"field",
"=",
"last",
".",
"name",
"nested",
"=",
"last",
".",
"nested",
"nested_args",
"=",
"[",
"]",
"while",
"nested",
":",
"meta",
"=",
"nested",
".",
"model"... | Perform ordering with respect model fields. | [
"Perform",
"ordering",
"with",
"respect",
"model",
"fields",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L241-L258 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | RedisQuery.related_lua_args | def related_lua_args(self):
'''Generator of load_related arguments'''
related = self.queryelem.select_related
if related:
meta = self.meta
for rel in related:
field = meta.dfields[rel]
relmodel = field.relmodel
bk = ... | python | def related_lua_args(self):
'''Generator of load_related arguments'''
related = self.queryelem.select_related
if related:
meta = self.meta
for rel in related:
field = meta.dfields[rel]
relmodel = field.relmodel
bk = ... | [
"def",
"related_lua_args",
"(",
"self",
")",
":",
"related",
"=",
"self",
".",
"queryelem",
".",
"select_related",
"if",
"related",
":",
"meta",
"=",
"self",
".",
"meta",
"for",
"rel",
"in",
"related",
":",
"field",
"=",
"meta",
".",
"dfields",
"[",
"r... | Generator of load_related arguments | [
"Generator",
"of",
"load_related",
"arguments"
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L346-L363 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | Zset.ipop_range | def ipop_range(self, start, stop=None, withscores=True, **options):
'''Remove and return a range from the ordered set by rank (index).'''
return self.backend.execute(
self.client.zpopbyrank(self.id, start, stop,
withscores=withscores, **options),
... | python | def ipop_range(self, start, stop=None, withscores=True, **options):
'''Remove and return a range from the ordered set by rank (index).'''
return self.backend.execute(
self.client.zpopbyrank(self.id, start, stop,
withscores=withscores, **options),
... | [
"def",
"ipop_range",
"(",
"self",
",",
"start",
",",
"stop",
"=",
"None",
",",
"withscores",
"=",
"True",
",",
"*",
"*",
"options",
")",
":",
"return",
"self",
".",
"backend",
".",
"execute",
"(",
"self",
".",
"client",
".",
"zpopbyrank",
"(",
"self"... | Remove and return a range from the ordered set by rank (index). | [
"Remove",
"and",
"return",
"a",
"range",
"from",
"the",
"ordered",
"set",
"by",
"rank",
"(",
"index",
")",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L482-L487 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | Zset.pop_range | def pop_range(self, start, stop=None, withscores=True, **options):
'''Remove and return a range from the ordered set by score.'''
return self.backend.execute(
self.client.zpopbyscore(self.id, start, stop,
withscores=withscores, **options),
... | python | def pop_range(self, start, stop=None, withscores=True, **options):
'''Remove and return a range from the ordered set by score.'''
return self.backend.execute(
self.client.zpopbyscore(self.id, start, stop,
withscores=withscores, **options),
... | [
"def",
"pop_range",
"(",
"self",
",",
"start",
",",
"stop",
"=",
"None",
",",
"withscores",
"=",
"True",
",",
"*",
"*",
"options",
")",
":",
"return",
"self",
".",
"backend",
".",
"execute",
"(",
"self",
".",
"client",
".",
"zpopbyscore",
"(",
"self"... | Remove and return a range from the ordered set by score. | [
"Remove",
"and",
"return",
"a",
"range",
"from",
"the",
"ordered",
"set",
"by",
"score",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L489-L494 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | BackendDataServer.meta | def meta(self, meta):
'''Extract model metadata for lua script stdnet/lib/lua/odm.lua'''
data = meta.as_dict()
data['namespace'] = self.basekey(meta)
return data | python | def meta(self, meta):
'''Extract model metadata for lua script stdnet/lib/lua/odm.lua'''
data = meta.as_dict()
data['namespace'] = self.basekey(meta)
return data | [
"def",
"meta",
"(",
"self",
",",
"meta",
")",
":",
"data",
"=",
"meta",
".",
"as_dict",
"(",
")",
"data",
"[",
"'namespace'",
"]",
"=",
"self",
".",
"basekey",
"(",
"meta",
")",
"return",
"data"
] | Extract model metadata for lua script stdnet/lib/lua/odm.lua | [
"Extract",
"model",
"metadata",
"for",
"lua",
"script",
"stdnet",
"/",
"lib",
"/",
"lua",
"/",
"odm",
".",
"lua"
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L755-L759 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | BackendDataServer.execute_session | def execute_session(self, session_data):
'''Execute a session in redis.'''
pipe = self.client.pipeline()
for sm in session_data: # loop through model sessions
meta = sm.meta
if sm.structures:
self.flush_structure(sm, pipe)
delquery = No... | python | def execute_session(self, session_data):
'''Execute a session in redis.'''
pipe = self.client.pipeline()
for sm in session_data: # loop through model sessions
meta = sm.meta
if sm.structures:
self.flush_structure(sm, pipe)
delquery = No... | [
"def",
"execute_session",
"(",
"self",
",",
"session_data",
")",
":",
"pipe",
"=",
"self",
".",
"client",
".",
"pipeline",
"(",
")",
"for",
"sm",
"in",
"session_data",
":",
"# loop through model sessions\r",
"meta",
"=",
"sm",
".",
"meta",
"if",
"sm",
".",... | Execute a session in redis. | [
"Execute",
"a",
"session",
"in",
"redis",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L776-L814 |
lsbardel/python-stdnet | stdnet/backends/redisb/__init__.py | BackendDataServer.flush | def flush(self, meta=None):
'''Flush all model keys from the database'''
pattern = self.basekey(meta) if meta else self.namespace
return self.client.delpattern('%s*' % pattern) | python | def flush(self, meta=None):
'''Flush all model keys from the database'''
pattern = self.basekey(meta) if meta else self.namespace
return self.client.delpattern('%s*' % pattern) | [
"def",
"flush",
"(",
"self",
",",
"meta",
"=",
"None",
")",
":",
"pattern",
"=",
"self",
".",
"basekey",
"(",
"meta",
")",
"if",
"meta",
"else",
"self",
".",
"namespace",
"return",
"self",
".",
"client",
".",
"delpattern",
"(",
"'%s*'",
"%",
"pattern... | Flush all model keys from the database | [
"Flush",
"all",
"model",
"keys",
"from",
"the",
"database"
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L850-L853 |
rodluger/everest | everest/gp.py | GetCovariance | def GetCovariance(kernel, kernel_params, time, errors):
'''
Returns the covariance matrix for a given light curve
segment.
:param array_like kernel_params: A list of kernel parameters \
(white noise amplitude, red noise amplitude, and red noise timescale)
:param array_like time: The time ... | python | def GetCovariance(kernel, kernel_params, time, errors):
'''
Returns the covariance matrix for a given light curve
segment.
:param array_like kernel_params: A list of kernel parameters \
(white noise amplitude, red noise amplitude, and red noise timescale)
:param array_like time: The time ... | [
"def",
"GetCovariance",
"(",
"kernel",
",",
"kernel_params",
",",
"time",
",",
"errors",
")",
":",
"# NOTE: We purposefully compute the covariance matrix",
"# *without* the GP white noise term",
"K",
"=",
"np",
".",
"diag",
"(",
"errors",
"**",
"2",
")",
"K",
"+=",
... | Returns the covariance matrix for a given light curve
segment.
:param array_like kernel_params: A list of kernel parameters \
(white noise amplitude, red noise amplitude, and red noise timescale)
:param array_like time: The time array (*N*)
:param array_like errors: The data error array (*N*)... | [
"Returns",
"the",
"covariance",
"matrix",
"for",
"a",
"given",
"light",
"curve",
"segment",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/gp.py#L71-L89 |
rodluger/everest | everest/gp.py | GetKernelParams | def GetKernelParams(time, flux, errors, kernel='Basic', mask=[],
giter=3, gmaxf=200, guess=None):
'''
Optimizes the GP by training it on the current de-trended light curve.
Returns the white noise amplitude, red noise amplitude,
and red noise timescale.
:param array_like time: T... | python | def GetKernelParams(time, flux, errors, kernel='Basic', mask=[],
giter=3, gmaxf=200, guess=None):
'''
Optimizes the GP by training it on the current de-trended light curve.
Returns the white noise amplitude, red noise amplitude,
and red noise timescale.
:param array_like time: T... | [
"def",
"GetKernelParams",
"(",
"time",
",",
"flux",
",",
"errors",
",",
"kernel",
"=",
"'Basic'",
",",
"mask",
"=",
"[",
"]",
",",
"giter",
"=",
"3",
",",
"gmaxf",
"=",
"200",
",",
"guess",
"=",
"None",
")",
":",
"log",
".",
"info",
"(",
"\"Optim... | Optimizes the GP by training it on the current de-trended light curve.
Returns the white noise amplitude, red noise amplitude,
and red noise timescale.
:param array_like time: The time array
:param array_like flux: The flux array
:param array_like errors: The flux errors array
:param array_like... | [
"Optimizes",
"the",
"GP",
"by",
"training",
"it",
"on",
"the",
"current",
"de",
"-",
"trended",
"light",
"curve",
".",
"Returns",
"the",
"white",
"noise",
"amplitude",
"red",
"noise",
"amplitude",
"and",
"red",
"noise",
"timescale",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/gp.py#L92-L192 |
rodluger/everest | everest/gp.py | NegLnLike | def NegLnLike(x, time, flux, errors, kernel):
'''
Returns the negative log-likelihood function and its gradient.
'''
gp = GP(kernel, x, white=True)
gp.compute(time, errors)
if OLDGEORGE:
nll = -gp.lnlikelihood(flux)
# NOTE: There was a bug on this next line! Used to be
... | python | def NegLnLike(x, time, flux, errors, kernel):
'''
Returns the negative log-likelihood function and its gradient.
'''
gp = GP(kernel, x, white=True)
gp.compute(time, errors)
if OLDGEORGE:
nll = -gp.lnlikelihood(flux)
# NOTE: There was a bug on this next line! Used to be
... | [
"def",
"NegLnLike",
"(",
"x",
",",
"time",
",",
"flux",
",",
"errors",
",",
"kernel",
")",
":",
"gp",
"=",
"GP",
"(",
"kernel",
",",
"x",
",",
"white",
"=",
"True",
")",
"gp",
".",
"compute",
"(",
"time",
",",
"errors",
")",
"if",
"OLDGEORGE",
... | Returns the negative log-likelihood function and its gradient. | [
"Returns",
"the",
"negative",
"log",
"-",
"likelihood",
"function",
"and",
"its",
"gradient",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/gp.py#L195-L231 |
lsbardel/python-stdnet | stdnet/utils/dates.py | missing_intervals | def missing_intervals(startdate, enddate, start, end,
dateconverter=None,
parseinterval=None,
intervals=None):
'''Given a ``startdate`` and an ``enddate`` dates, evaluate the
date intervals from which data is not available. It return a list of
... | python | def missing_intervals(startdate, enddate, start, end,
dateconverter=None,
parseinterval=None,
intervals=None):
'''Given a ``startdate`` and an ``enddate`` dates, evaluate the
date intervals from which data is not available. It return a list of
... | [
"def",
"missing_intervals",
"(",
"startdate",
",",
"enddate",
",",
"start",
",",
"end",
",",
"dateconverter",
"=",
"None",
",",
"parseinterval",
"=",
"None",
",",
"intervals",
"=",
"None",
")",
":",
"parseinterval",
"=",
"parseinterval",
"or",
"default_parse_i... | Given a ``startdate`` and an ``enddate`` dates, evaluate the
date intervals from which data is not available. It return a list of
two-dimensional tuples containing start and end date for the interval.
The list could countain 0,1 or 2 tuples. | [
"Given",
"a",
"startdate",
"and",
"an",
"enddate",
"dates",
"evaluate",
"the",
"date",
"intervals",
"from",
"which",
"data",
"is",
"not",
"available",
".",
"It",
"return",
"a",
"list",
"of",
"two",
"-",
"dimensional",
"tuples",
"containing",
"start",
"and",
... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/dates.py#L120-L161 |
lsbardel/python-stdnet | stdnet/utils/dates.py | dategenerator | def dategenerator(start, end, step=1, desc=False):
'''Generates dates between *atrt* and *end*.'''
delta = timedelta(abs(step))
end = max(start, end)
if desc:
dt = end
while dt >= start:
yield dt
dt -= delta
else:
dt = start
while dt... | python | def dategenerator(start, end, step=1, desc=False):
'''Generates dates between *atrt* and *end*.'''
delta = timedelta(abs(step))
end = max(start, end)
if desc:
dt = end
while dt >= start:
yield dt
dt -= delta
else:
dt = start
while dt... | [
"def",
"dategenerator",
"(",
"start",
",",
"end",
",",
"step",
"=",
"1",
",",
"desc",
"=",
"False",
")",
":",
"delta",
"=",
"timedelta",
"(",
"abs",
"(",
"step",
")",
")",
"end",
"=",
"max",
"(",
"start",
",",
"end",
")",
"if",
"desc",
":",
"dt... | Generates dates between *atrt* and *end*. | [
"Generates",
"dates",
"between",
"*",
"atrt",
"*",
"and",
"*",
"end",
"*",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/dates.py#L164-L177 |
rodluger/everest | everest/utils.py | InitLog | def InitLog(file_name=None, log_level=logging.DEBUG,
screen_level=logging.CRITICAL, pdb=False):
'''
A little routine to initialize the logging functionality.
:param str file_name: The name of the file to log to. \
Default :py:obj:`None` (set internally by :py:mod:`everest`)
:para... | python | def InitLog(file_name=None, log_level=logging.DEBUG,
screen_level=logging.CRITICAL, pdb=False):
'''
A little routine to initialize the logging functionality.
:param str file_name: The name of the file to log to. \
Default :py:obj:`None` (set internally by :py:mod:`everest`)
:para... | [
"def",
"InitLog",
"(",
"file_name",
"=",
"None",
",",
"log_level",
"=",
"logging",
".",
"DEBUG",
",",
"screen_level",
"=",
"logging",
".",
"CRITICAL",
",",
"pdb",
"=",
"False",
")",
":",
"# Initialize the logging",
"root",
"=",
"logging",
".",
"getLogger",
... | A little routine to initialize the logging functionality.
:param str file_name: The name of the file to log to. \
Default :py:obj:`None` (set internally by :py:mod:`everest`)
:param int log_level: The file logging level (0-50). Default 10 (debug)
:param int screen_level: The screen logging level... | [
"A",
"little",
"routine",
"to",
"initialize",
"the",
"logging",
"functionality",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/utils.py#L66-L113 |
rodluger/everest | everest/utils.py | ExceptionHook | def ExceptionHook(exctype, value, tb):
'''
A custom exception handler that logs errors to file.
'''
for line in traceback.format_exception_only(exctype, value):
log.error(line.replace('\n', ''))
for line in traceback.format_tb(tb):
log.error(line.replace('\n', ''))
sys.__except... | python | def ExceptionHook(exctype, value, tb):
'''
A custom exception handler that logs errors to file.
'''
for line in traceback.format_exception_only(exctype, value):
log.error(line.replace('\n', ''))
for line in traceback.format_tb(tb):
log.error(line.replace('\n', ''))
sys.__except... | [
"def",
"ExceptionHook",
"(",
"exctype",
",",
"value",
",",
"tb",
")",
":",
"for",
"line",
"in",
"traceback",
".",
"format_exception_only",
"(",
"exctype",
",",
"value",
")",
":",
"log",
".",
"error",
"(",
"line",
".",
"replace",
"(",
"'\\n'",
",",
"''"... | A custom exception handler that logs errors to file. | [
"A",
"custom",
"exception",
"handler",
"that",
"logs",
"errors",
"to",
"file",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/utils.py#L116-L126 |
rodluger/everest | everest/utils.py | ExceptionHookPDB | def ExceptionHookPDB(exctype, value, tb):
'''
A custom exception handler, with :py:obj:`pdb` post-mortem for debugging.
'''
for line in traceback.format_exception_only(exctype, value):
log.error(line.replace('\n', ''))
for line in traceback.format_tb(tb):
log.error(line.replace('\n... | python | def ExceptionHookPDB(exctype, value, tb):
'''
A custom exception handler, with :py:obj:`pdb` post-mortem for debugging.
'''
for line in traceback.format_exception_only(exctype, value):
log.error(line.replace('\n', ''))
for line in traceback.format_tb(tb):
log.error(line.replace('\n... | [
"def",
"ExceptionHookPDB",
"(",
"exctype",
",",
"value",
",",
"tb",
")",
":",
"for",
"line",
"in",
"traceback",
".",
"format_exception_only",
"(",
"exctype",
",",
"value",
")",
":",
"log",
".",
"error",
"(",
"line",
".",
"replace",
"(",
"'\\n'",
",",
"... | A custom exception handler, with :py:obj:`pdb` post-mortem for debugging. | [
"A",
"custom",
"exception",
"handler",
"with",
":",
"py",
":",
"obj",
":",
"pdb",
"post",
"-",
"mortem",
"for",
"debugging",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/utils.py#L129-L140 |
rodluger/everest | everest/utils.py | sort_like | def sort_like(l, col1, col2):
'''
Sorts the list :py:obj:`l` by comparing :py:obj:`col2` to :py:obj:`col1`.
Specifically, finds the indices :py:obj:`i` such that ``col2[i] = col1``
and returns ``l[i]``. This is useful when comparing the CDPP values of
catalogs generated by different pipelines. The
... | python | def sort_like(l, col1, col2):
'''
Sorts the list :py:obj:`l` by comparing :py:obj:`col2` to :py:obj:`col1`.
Specifically, finds the indices :py:obj:`i` such that ``col2[i] = col1``
and returns ``l[i]``. This is useful when comparing the CDPP values of
catalogs generated by different pipelines. The
... | [
"def",
"sort_like",
"(",
"l",
",",
"col1",
",",
"col2",
")",
":",
"s",
"=",
"np",
".",
"zeros_like",
"(",
"col1",
")",
"*",
"np",
".",
"nan",
"for",
"i",
",",
"c",
"in",
"enumerate",
"(",
"col1",
")",
":",
"j",
"=",
"np",
".",
"argmax",
"(",
... | Sorts the list :py:obj:`l` by comparing :py:obj:`col2` to :py:obj:`col1`.
Specifically, finds the indices :py:obj:`i` such that ``col2[i] = col1``
and returns ``l[i]``. This is useful when comparing the CDPP values of
catalogs generated by different pipelines. The
target IDs are all the same, but won't ... | [
"Sorts",
"the",
"list",
":",
"py",
":",
"obj",
":",
"l",
"by",
"comparing",
":",
"py",
":",
"obj",
":",
"col2",
"to",
":",
"py",
":",
"obj",
":",
"col1",
".",
"Specifically",
"finds",
"the",
"indices",
":",
"py",
":",
"obj",
":",
"i",
"such",
"... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/utils.py#L159-L183 |
rodluger/everest | everest/utils.py | prange | def prange(*x):
'''
Progress bar range with `tqdm`
'''
try:
root = logging.getLogger()
if len(root.handlers):
for h in root.handlers:
if (type(h) is logging.StreamHandler) and \
(h.level != logging.CRITICAL):
from ... | python | def prange(*x):
'''
Progress bar range with `tqdm`
'''
try:
root = logging.getLogger()
if len(root.handlers):
for h in root.handlers:
if (type(h) is logging.StreamHandler) and \
(h.level != logging.CRITICAL):
from ... | [
"def",
"prange",
"(",
"*",
"x",
")",
":",
"try",
":",
"root",
"=",
"logging",
".",
"getLogger",
"(",
")",
"if",
"len",
"(",
"root",
".",
"handlers",
")",
":",
"for",
"h",
"in",
"root",
".",
"handlers",
":",
"if",
"(",
"type",
"(",
"h",
")",
"... | Progress bar range with `tqdm` | [
"Progress",
"bar",
"range",
"with",
"tqdm"
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/utils.py#L237-L256 |
lsbardel/python-stdnet | stdnet/apps/columnts/npts.py | ColumnTS.front | def front(self, *fields):
'''Return the front pair of the structure'''
ts = self.irange(0, 0, fields=fields)
if ts:
return ts.start(), ts[0] | python | def front(self, *fields):
'''Return the front pair of the structure'''
ts = self.irange(0, 0, fields=fields)
if ts:
return ts.start(), ts[0] | [
"def",
"front",
"(",
"self",
",",
"*",
"fields",
")",
":",
"ts",
"=",
"self",
".",
"irange",
"(",
"0",
",",
"0",
",",
"fields",
"=",
"fields",
")",
"if",
"ts",
":",
"return",
"ts",
".",
"start",
"(",
")",
",",
"ts",
"[",
"0",
"]"
] | Return the front pair of the structure | [
"Return",
"the",
"front",
"pair",
"of",
"the",
"structure"
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/npts.py#L19-L23 |
lsbardel/python-stdnet | stdnet/apps/columnts/npts.py | ColumnTS.back | def back(self, *fields):
'''Return the back pair of the structure'''
ts = self.irange(-1, -1, fields=fields)
if ts:
return ts.end(), ts[0] | python | def back(self, *fields):
'''Return the back pair of the structure'''
ts = self.irange(-1, -1, fields=fields)
if ts:
return ts.end(), ts[0] | [
"def",
"back",
"(",
"self",
",",
"*",
"fields",
")",
":",
"ts",
"=",
"self",
".",
"irange",
"(",
"-",
"1",
",",
"-",
"1",
",",
"fields",
"=",
"fields",
")",
"if",
"ts",
":",
"return",
"ts",
".",
"end",
"(",
")",
",",
"ts",
"[",
"0",
"]"
] | Return the back pair of the structure | [
"Return",
"the",
"back",
"pair",
"of",
"the",
"structure"
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/npts.py#L25-L29 |
lsbardel/python-stdnet | stdnet/backends/__init__.py | parse_backend | def parse_backend(backend):
"""Converts the "backend" into the database connection parameters.
It returns a (scheme, host, params) tuple."""
r = urlparse.urlsplit(backend)
scheme, host = r.scheme, r.netloc
path, query = r.path, r.query
if path and not query:
query, path = path, ''
... | python | def parse_backend(backend):
"""Converts the "backend" into the database connection parameters.
It returns a (scheme, host, params) tuple."""
r = urlparse.urlsplit(backend)
scheme, host = r.scheme, r.netloc
path, query = r.path, r.query
if path and not query:
query, path = path, ''
... | [
"def",
"parse_backend",
"(",
"backend",
")",
":",
"r",
"=",
"urlparse",
".",
"urlsplit",
"(",
"backend",
")",
"scheme",
",",
"host",
"=",
"r",
".",
"scheme",
",",
"r",
".",
"netloc",
"path",
",",
"query",
"=",
"r",
".",
"path",
",",
"r",
".",
"qu... | Converts the "backend" into the database connection parameters.
It returns a (scheme, host, params) tuple. | [
"Converts",
"the",
"backend",
"into",
"the",
"database",
"connection",
"parameters",
".",
"It",
"returns",
"a",
"(",
"scheme",
"host",
"params",
")",
"tuple",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/__init__.py#L470-L488 |
lsbardel/python-stdnet | stdnet/backends/__init__.py | getdb | def getdb(backend=None, **kwargs):
'''get a :class:`BackendDataServer`.'''
if isinstance(backend, BackendDataServer):
return backend
backend = backend or settings.DEFAULT_BACKEND
if not backend:
return None
scheme, address, params = parse_backend(backend)
params.update(kw... | python | def getdb(backend=None, **kwargs):
'''get a :class:`BackendDataServer`.'''
if isinstance(backend, BackendDataServer):
return backend
backend = backend or settings.DEFAULT_BACKEND
if not backend:
return None
scheme, address, params = parse_backend(backend)
params.update(kw... | [
"def",
"getdb",
"(",
"backend",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"backend",
",",
"BackendDataServer",
")",
":",
"return",
"backend",
"backend",
"=",
"backend",
"or",
"settings",
".",
"DEFAULT_BACKEND",
"if",
"not",
... | get a :class:`BackendDataServer`. | [
"get",
"a",
":",
"class",
":",
"BackendDataServer",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/__init__.py#L499-L510 |
lsbardel/python-stdnet | stdnet/backends/__init__.py | BackendDataServer.basekey | def basekey(self, meta, *args):
"""Calculate the key to access model data.
:parameter meta: a :class:`stdnet.odm.Metaclass`.
:parameter args: optional list of strings to prepend to the basekey.
:rtype: a native string
"""
key = '%s%s' % (self.namespace, meta.modelkey)
postfix = ':'.join... | python | def basekey(self, meta, *args):
"""Calculate the key to access model data.
:parameter meta: a :class:`stdnet.odm.Metaclass`.
:parameter args: optional list of strings to prepend to the basekey.
:rtype: a native string
"""
key = '%s%s' % (self.namespace, meta.modelkey)
postfix = ':'.join... | [
"def",
"basekey",
"(",
"self",
",",
"meta",
",",
"*",
"args",
")",
":",
"key",
"=",
"'%s%s'",
"%",
"(",
"self",
".",
"namespace",
",",
"meta",
".",
"modelkey",
")",
"postfix",
"=",
"':'",
".",
"join",
"(",
"(",
"str",
"(",
"p",
")",
"for",
"p",... | Calculate the key to access model data.
:parameter meta: a :class:`stdnet.odm.Metaclass`.
:parameter args: optional list of strings to prepend to the basekey.
:rtype: a native string | [
"Calculate",
"the",
"key",
"to",
"access",
"model",
"data",
".",
":",
"parameter",
"meta",
":",
"a",
":",
"class",
":",
"stdnet",
".",
"odm",
".",
"Metaclass",
".",
":",
"parameter",
"args",
":",
"optional",
"list",
"of",
"strings",
"to",
"prepend",
"t... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/__init__.py#L208-L217 |
lsbardel/python-stdnet | stdnet/backends/__init__.py | BackendDataServer.make_objects | def make_objects(self, meta, data, related_fields=None):
'''Generator of :class:`stdnet.odm.StdModel` instances with data
from database.
:parameter meta: instance of model :class:`stdnet.odm.Metaclass`.
:parameter data: iterator over instances data.
'''
make_object = meta.make_object
re... | python | def make_objects(self, meta, data, related_fields=None):
'''Generator of :class:`stdnet.odm.StdModel` instances with data
from database.
:parameter meta: instance of model :class:`stdnet.odm.Metaclass`.
:parameter data: iterator over instances data.
'''
make_object = meta.make_object
re... | [
"def",
"make_objects",
"(",
"self",
",",
"meta",
",",
"data",
",",
"related_fields",
"=",
"None",
")",
":",
"make_object",
"=",
"meta",
".",
"make_object",
"related_data",
"=",
"[",
"]",
"if",
"related_fields",
":",
"for",
"fname",
",",
"fdata",
"in",
"i... | Generator of :class:`stdnet.odm.StdModel` instances with data
from database.
:parameter meta: instance of model :class:`stdnet.odm.Metaclass`.
:parameter data: iterator over instances data. | [
"Generator",
"of",
":",
"class",
":",
"stdnet",
".",
"odm",
".",
"StdModel",
"instances",
"with",
"data",
"from",
"database",
".",
":",
"parameter",
"meta",
":",
"instance",
"of",
"model",
":",
"class",
":",
"stdnet",
".",
"odm",
".",
"Metaclass",
".",
... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/__init__.py#L227-L258 |
lsbardel/python-stdnet | stdnet/backends/__init__.py | BackendDataServer.structure | def structure(self, instance, client=None):
'''Create a backend :class:`stdnet.odm.Structure` handler.
:param instance: a :class:`stdnet.odm.Structure`
:param client: Optional client handler.
'''
struct = self.struct_map.get(instance._meta.name)
if struct is None:... | python | def structure(self, instance, client=None):
'''Create a backend :class:`stdnet.odm.Structure` handler.
:param instance: a :class:`stdnet.odm.Structure`
:param client: Optional client handler.
'''
struct = self.struct_map.get(instance._meta.name)
if struct is None:... | [
"def",
"structure",
"(",
"self",
",",
"instance",
",",
"client",
"=",
"None",
")",
":",
"struct",
"=",
"self",
".",
"struct_map",
".",
"get",
"(",
"instance",
".",
"_meta",
".",
"name",
")",
"if",
"struct",
"is",
"None",
":",
"raise",
"ModelNotAvailabl... | Create a backend :class:`stdnet.odm.Structure` handler.
:param instance: a :class:`stdnet.odm.Structure`
:param client: Optional client handler. | [
"Create",
"a",
"backend",
":",
"class",
":",
"stdnet",
".",
"odm",
".",
"Structure",
"handler",
".",
":",
"param",
"instance",
":",
"a",
":",
"class",
":",
"stdnet",
".",
"odm",
".",
"Structure",
":",
"param",
"client",
":",
"Optional",
"client",
"hand... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/__init__.py#L263-L274 |
rodluger/everest | everest/user.py | Search | def Search(ID, mission='k2'):
"""Why is my target not in the EVEREST database?"""
# Only K2 supported for now
assert mission == 'k2', "Only the K2 mission is supported for now."
print("Searching for target %d..." % ID)
# First check if it is in the database
season = missions.k2.Season(ID)
i... | python | def Search(ID, mission='k2'):
"""Why is my target not in the EVEREST database?"""
# Only K2 supported for now
assert mission == 'k2', "Only the K2 mission is supported for now."
print("Searching for target %d..." % ID)
# First check if it is in the database
season = missions.k2.Season(ID)
i... | [
"def",
"Search",
"(",
"ID",
",",
"mission",
"=",
"'k2'",
")",
":",
"# Only K2 supported for now",
"assert",
"mission",
"==",
"'k2'",
",",
"\"Only the K2 mission is supported for now.\"",
"print",
"(",
"\"Searching for target %d...\"",
"%",
"ID",
")",
"# First check if i... | Why is my target not in the EVEREST database? | [
"Why",
"is",
"my",
"target",
"not",
"in",
"the",
"EVEREST",
"database?"
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L61-L135 |
rodluger/everest | everest/user.py | DownloadFile | def DownloadFile(ID, season=None, mission='k2', cadence='lc',
filename=None, clobber=False):
'''
Download a given :py:mod:`everest` file from MAST.
:param str mission: The mission name. Default `k2`
:param str cadence: The light curve cadence. Default `lc`
:param str filename: The ... | python | def DownloadFile(ID, season=None, mission='k2', cadence='lc',
filename=None, clobber=False):
'''
Download a given :py:mod:`everest` file from MAST.
:param str mission: The mission name. Default `k2`
:param str cadence: The light curve cadence. Default `lc`
:param str filename: The ... | [
"def",
"DownloadFile",
"(",
"ID",
",",
"season",
"=",
"None",
",",
"mission",
"=",
"'k2'",
",",
"cadence",
"=",
"'lc'",
",",
"filename",
"=",
"None",
",",
"clobber",
"=",
"False",
")",
":",
"# Get season",
"if",
"season",
"is",
"None",
":",
"season",
... | Download a given :py:mod:`everest` file from MAST.
:param str mission: The mission name. Default `k2`
:param str cadence: The light curve cadence. Default `lc`
:param str filename: The name of the file to download. Default \
:py:obj:`None`, in which case the default \
FITS file is ret... | [
"Download",
"a",
"given",
":",
"py",
":",
"mod",
":",
"everest",
"file",
"from",
"MAST",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L137-L228 |
rodluger/everest | everest/user.py | DVS | def DVS(ID, season=None, mission='k2', clobber=False,
cadence='lc', model='nPLD'):
'''
Show the data validation summary (DVS) for a given target.
:param str mission: The mission name. Default `k2`
:param str cadence: The light curve cadence. Default `lc`
:param bool clobber: If :py:obj:`Tru... | python | def DVS(ID, season=None, mission='k2', clobber=False,
cadence='lc', model='nPLD'):
'''
Show the data validation summary (DVS) for a given target.
:param str mission: The mission name. Default `k2`
:param str cadence: The light curve cadence. Default `lc`
:param bool clobber: If :py:obj:`Tru... | [
"def",
"DVS",
"(",
"ID",
",",
"season",
"=",
"None",
",",
"mission",
"=",
"'k2'",
",",
"clobber",
"=",
"False",
",",
"cadence",
"=",
"'lc'",
",",
"model",
"=",
"'nPLD'",
")",
":",
"# Get season",
"if",
"season",
"is",
"None",
":",
"season",
"=",
"g... | Show the data validation summary (DVS) for a given target.
:param str mission: The mission name. Default `k2`
:param str cadence: The light curve cadence. Default `lc`
:param bool clobber: If :py:obj:`True`, download and overwrite \
existing files. Default :py:obj:`False` | [
"Show",
"the",
"data",
"validation",
"summary",
"(",
"DVS",
")",
"for",
"a",
"given",
"target",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L231-L275 |
rodluger/everest | everest/user.py | Everest.compute | def compute(self):
'''
Re-compute the :py:mod:`everest` model for the given
value of :py:obj:`lambda`.
For long cadence `k2` light curves, this should take several
seconds. For short cadence `k2` light curves, it may take a
few minutes. Note that this is a simple wrapper ... | python | def compute(self):
'''
Re-compute the :py:mod:`everest` model for the given
value of :py:obj:`lambda`.
For long cadence `k2` light curves, this should take several
seconds. For short cadence `k2` light curves, it may take a
few minutes. Note that this is a simple wrapper ... | [
"def",
"compute",
"(",
"self",
")",
":",
"# If we're doing iterative PLD, get the normalization",
"if",
"self",
".",
"model_name",
"==",
"'iPLD'",
":",
"self",
".",
"_get_norm",
"(",
")",
"# Compute as usual",
"super",
"(",
"Everest",
",",
"self",
")",
".",
"com... | Re-compute the :py:mod:`everest` model for the given
value of :py:obj:`lambda`.
For long cadence `k2` light curves, this should take several
seconds. For short cadence `k2` light curves, it may take a
few minutes. Note that this is a simple wrapper around
:py:func:`everest.Baseca... | [
"Re",
"-",
"compute",
"the",
":",
"py",
":",
"mod",
":",
"everest",
"model",
"for",
"the",
"given",
"value",
"of",
":",
"py",
":",
"obj",
":",
"lambda",
".",
"For",
"long",
"cadence",
"k2",
"light",
"curves",
"this",
"should",
"take",
"several",
"sec... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L368-L387 |
rodluger/everest | everest/user.py | Everest._get_norm | def _get_norm(self):
'''
Computes the PLD flux normalization array.
..note :: `iPLD` model **only**.
'''
log.info('Computing the PLD normalization...')
# Loop over all chunks
mod = [None for b in self.breakpoints]
for b, brkpt in enumerate(self.breakpo... | python | def _get_norm(self):
'''
Computes the PLD flux normalization array.
..note :: `iPLD` model **only**.
'''
log.info('Computing the PLD normalization...')
# Loop over all chunks
mod = [None for b in self.breakpoints]
for b, brkpt in enumerate(self.breakpo... | [
"def",
"_get_norm",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Computing the PLD normalization...'",
")",
"# Loop over all chunks",
"mod",
"=",
"[",
"None",
"for",
"b",
"in",
"self",
".",
"breakpoints",
"]",
"for",
"b",
",",
"brkpt",
"in",
"enumerate"... | Computes the PLD flux normalization array.
..note :: `iPLD` model **only**. | [
"Computes",
"the",
"PLD",
"flux",
"normalization",
"array",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L389-L467 |
rodluger/everest | everest/user.py | Everest.load_fits | def load_fits(self):
'''
Load the FITS file from disk and populate the
class instance with its data.
'''
log.info("Loading FITS file for %d." % (self.ID))
with pyfits.open(self.fitsfile) as f:
# Params and long cadence data
self.loaded = True
... | python | def load_fits(self):
'''
Load the FITS file from disk and populate the
class instance with its data.
'''
log.info("Loading FITS file for %d." % (self.ID))
with pyfits.open(self.fitsfile) as f:
# Params and long cadence data
self.loaded = True
... | [
"def",
"load_fits",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Loading FITS file for %d.\"",
"%",
"(",
"self",
".",
"ID",
")",
")",
"with",
"pyfits",
".",
"open",
"(",
"self",
".",
"fitsfile",
")",
"as",
"f",
":",
"# Params and long cadence data",
... | Load the FITS file from disk and populate the
class instance with its data. | [
"Load",
"the",
"FITS",
"file",
"from",
"disk",
"and",
"populate",
"the",
"class",
"instance",
"with",
"its",
"data",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L469-L621 |
rodluger/everest | everest/user.py | Everest.plot_aperture | def plot_aperture(self, show=True):
'''
Plot sample postage stamps for the target with the aperture
outline marked, as well as a high-res target image (if available).
:param bool show: Show the plot or return the `(fig, ax)` instance? \
Default :py:obj:`True`
'''... | python | def plot_aperture(self, show=True):
'''
Plot sample postage stamps for the target with the aperture
outline marked, as well as a high-res target image (if available).
:param bool show: Show the plot or return the `(fig, ax)` instance? \
Default :py:obj:`True`
'''... | [
"def",
"plot_aperture",
"(",
"self",
",",
"show",
"=",
"True",
")",
":",
"# Set up the axes",
"fig",
",",
"ax",
"=",
"pl",
".",
"subplots",
"(",
"2",
",",
"2",
",",
"figsize",
"=",
"(",
"6",
",",
"8",
")",
")",
"fig",
".",
"subplots_adjust",
"(",
... | Plot sample postage stamps for the target with the aperture
outline marked, as well as a high-res target image (if available).
:param bool show: Show the plot or return the `(fig, ax)` instance? \
Default :py:obj:`True` | [
"Plot",
"sample",
"postage",
"stamps",
"for",
"the",
"target",
"with",
"the",
"aperture",
"outline",
"marked",
"as",
"well",
"as",
"a",
"high",
"-",
"res",
"target",
"image",
"(",
"if",
"available",
")",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L623-L646 |
rodluger/everest | everest/user.py | Everest.plot | def plot(self, show=True, plot_raw=True, plot_gp=True,
plot_bad=True, plot_out=True, plot_cbv=True,
simple=False):
'''
Plots the final de-trended light curve.
:param bool show: Show the plot or return the `(fig, ax)` instance? \
Default :py:obj:`True`
... | python | def plot(self, show=True, plot_raw=True, plot_gp=True,
plot_bad=True, plot_out=True, plot_cbv=True,
simple=False):
'''
Plots the final de-trended light curve.
:param bool show: Show the plot or return the `(fig, ax)` instance? \
Default :py:obj:`True`
... | [
"def",
"plot",
"(",
"self",
",",
"show",
"=",
"True",
",",
"plot_raw",
"=",
"True",
",",
"plot_gp",
"=",
"True",
",",
"plot_bad",
"=",
"True",
",",
"plot_out",
"=",
"True",
",",
"plot_cbv",
"=",
"True",
",",
"simple",
"=",
"False",
")",
":",
"log",... | Plots the final de-trended light curve.
:param bool show: Show the plot or return the `(fig, ax)` instance? \
Default :py:obj:`True`
:param bool plot_raw: Show the raw light curve? Default :py:obj:`True`
:param bool plot_gp: Show the GP model prediction? \
Default ... | [
"Plots",
"the",
"final",
"de",
"-",
"trended",
"light",
"curve",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L648-L839 |
rodluger/everest | everest/user.py | Everest.dvs | def dvs(self):
'''
Shows the data validation summary (DVS) for the target.
'''
DVS(self.ID, season=self.season, mission=self.mission,
model=self.model_name, clobber=self.clobber) | python | def dvs(self):
'''
Shows the data validation summary (DVS) for the target.
'''
DVS(self.ID, season=self.season, mission=self.mission,
model=self.model_name, clobber=self.clobber) | [
"def",
"dvs",
"(",
"self",
")",
":",
"DVS",
"(",
"self",
".",
"ID",
",",
"season",
"=",
"self",
".",
"season",
",",
"mission",
"=",
"self",
".",
"mission",
",",
"model",
"=",
"self",
".",
"model_name",
",",
"clobber",
"=",
"self",
".",
"clobber",
... | Shows the data validation summary (DVS) for the target. | [
"Shows",
"the",
"data",
"validation",
"summary",
"(",
"DVS",
")",
"for",
"the",
"target",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L841-L848 |
rodluger/everest | everest/user.py | Everest.plot_pipeline | def plot_pipeline(self, pipeline, *args, **kwargs):
'''
Plots the light curve for the target de-trended with a given pipeline.
:param str pipeline: The name of the pipeline (lowercase). Options \
are 'everest2', 'everest1', and other mission-specific \
pipelines. F... | python | def plot_pipeline(self, pipeline, *args, **kwargs):
'''
Plots the light curve for the target de-trended with a given pipeline.
:param str pipeline: The name of the pipeline (lowercase). Options \
are 'everest2', 'everest1', and other mission-specific \
pipelines. F... | [
"def",
"plot_pipeline",
"(",
"self",
",",
"pipeline",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"pipeline",
"!=",
"'everest2'",
":",
"return",
"getattr",
"(",
"missions",
",",
"self",
".",
"mission",
")",
".",
"pipelines",
".",
"plot",... | Plots the light curve for the target de-trended with a given pipeline.
:param str pipeline: The name of the pipeline (lowercase). Options \
are 'everest2', 'everest1', and other mission-specific \
pipelines. For `K2`, the available pipelines are 'k2sff' \
and 'k2sc'... | [
"Plots",
"the",
"light",
"curve",
"for",
"the",
"target",
"de",
"-",
"trended",
"with",
"a",
"given",
"pipeline",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L850-L925 |
rodluger/everest | everest/user.py | Everest.get_pipeline | def get_pipeline(self, *args, **kwargs):
'''
Returns the `time` and `flux` arrays for the target obtained by a given
pipeline.
Options :py:obj:`args` and :py:obj:`kwargs` are passed directly to
the :py:func:`pipelines.get` function of the mission.
'''
return ge... | python | def get_pipeline(self, *args, **kwargs):
'''
Returns the `time` and `flux` arrays for the target obtained by a given
pipeline.
Options :py:obj:`args` and :py:obj:`kwargs` are passed directly to
the :py:func:`pipelines.get` function of the mission.
'''
return ge... | [
"def",
"get_pipeline",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"getattr",
"(",
"missions",
",",
"self",
".",
"mission",
")",
".",
"pipelines",
".",
"get",
"(",
"self",
".",
"ID",
",",
"*",
"args",
",",
"*",
"*"... | Returns the `time` and `flux` arrays for the target obtained by a given
pipeline.
Options :py:obj:`args` and :py:obj:`kwargs` are passed directly to
the :py:func:`pipelines.get` function of the mission. | [
"Returns",
"the",
"time",
"and",
"flux",
"arrays",
"for",
"the",
"target",
"obtained",
"by",
"a",
"given",
"pipeline",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L927-L938 |
rodluger/everest | everest/user.py | Everest.mask_planet | def mask_planet(self, t0, period, dur=0.2):
'''
Mask all of the transits/eclipses of a given planet/EB. After calling
this method, you must re-compute the model by calling
:py:meth:`compute` in order for the mask to take effect.
:param float t0: The time of first transit (same u... | python | def mask_planet(self, t0, period, dur=0.2):
'''
Mask all of the transits/eclipses of a given planet/EB. After calling
this method, you must re-compute the model by calling
:py:meth:`compute` in order for the mask to take effect.
:param float t0: The time of first transit (same u... | [
"def",
"mask_planet",
"(",
"self",
",",
"t0",
",",
"period",
",",
"dur",
"=",
"0.2",
")",
":",
"mask",
"=",
"[",
"]",
"t0",
"+=",
"np",
".",
"ceil",
"(",
"(",
"self",
".",
"time",
"[",
"0",
"]",
"-",
"dur",
"-",
"t0",
")",
"/",
"period",
")... | Mask all of the transits/eclipses of a given planet/EB. After calling
this method, you must re-compute the model by calling
:py:meth:`compute` in order for the mask to take effect.
:param float t0: The time of first transit (same units as light curve)
:param float period: The period of ... | [
"Mask",
"all",
"of",
"the",
"transits",
"/",
"eclipses",
"of",
"a",
"given",
"planet",
"/",
"EB",
".",
"After",
"calling",
"this",
"method",
"you",
"must",
"re",
"-",
"compute",
"the",
"model",
"by",
"calling",
":",
"py",
":",
"meth",
":",
"compute",
... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L940-L957 |
rodluger/everest | everest/user.py | Everest._plot_weights | def _plot_weights(self, show=True):
'''
.. warning:: Untested!
'''
# Set up the axes
fig = pl.figure(figsize=(12, 12))
fig.subplots_adjust(top=0.95, bottom=0.025, left=0.1, right=0.92)
fig.canvas.set_window_title(
'%s %d' % (self._mission.IDSTRING, s... | python | def _plot_weights(self, show=True):
'''
.. warning:: Untested!
'''
# Set up the axes
fig = pl.figure(figsize=(12, 12))
fig.subplots_adjust(top=0.95, bottom=0.025, left=0.1, right=0.92)
fig.canvas.set_window_title(
'%s %d' % (self._mission.IDSTRING, s... | [
"def",
"_plot_weights",
"(",
"self",
",",
"show",
"=",
"True",
")",
":",
"# Set up the axes",
"fig",
"=",
"pl",
".",
"figure",
"(",
"figsize",
"=",
"(",
"12",
",",
"12",
")",
")",
"fig",
".",
"subplots_adjust",
"(",
"top",
"=",
"0.95",
",",
"bottom",... | .. warning:: Untested! | [
"..",
"warning",
"::",
"Untested!"
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L959-L1139 |
rodluger/everest | everest/user.py | Everest._save_npz | def _save_npz(self):
'''
Saves all of the de-trending information to disk in an `npz` file
'''
# Save the data
d = dict(self.__dict__)
d.pop('_weights', None)
d.pop('_A', None)
d.pop('_B', None)
d.pop('_f', None)
d.pop('_mK', None)
... | python | def _save_npz(self):
'''
Saves all of the de-trending information to disk in an `npz` file
'''
# Save the data
d = dict(self.__dict__)
d.pop('_weights', None)
d.pop('_A', None)
d.pop('_B', None)
d.pop('_f', None)
d.pop('_mK', None)
... | [
"def",
"_save_npz",
"(",
"self",
")",
":",
"# Save the data",
"d",
"=",
"dict",
"(",
"self",
".",
"__dict__",
")",
"d",
".",
"pop",
"(",
"'_weights'",
",",
"None",
")",
"d",
".",
"pop",
"(",
"'_A'",
",",
"None",
")",
"d",
".",
"pop",
"(",
"'_B'",... | Saves all of the de-trending information to disk in an `npz` file | [
"Saves",
"all",
"of",
"the",
"de",
"-",
"trending",
"information",
"to",
"disk",
"in",
"an",
"npz",
"file"
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L1298-L1317 |
rodluger/everest | everest/user.py | Everest.optimize | def optimize(self, piter=3, pmaxf=300, ppert=0.1):
'''
Runs :py:obj:`pPLD` on the target in an attempt to further optimize the
values of the PLD priors. See :py:class:`everest.detrender.pPLD`.
'''
self._save_npz()
optimized = pPLD(self.ID, piter=piter, pmaxf=pmaxf,
... | python | def optimize(self, piter=3, pmaxf=300, ppert=0.1):
'''
Runs :py:obj:`pPLD` on the target in an attempt to further optimize the
values of the PLD priors. See :py:class:`everest.detrender.pPLD`.
'''
self._save_npz()
optimized = pPLD(self.ID, piter=piter, pmaxf=pmaxf,
... | [
"def",
"optimize",
"(",
"self",
",",
"piter",
"=",
"3",
",",
"pmaxf",
"=",
"300",
",",
"ppert",
"=",
"0.1",
")",
":",
"self",
".",
"_save_npz",
"(",
")",
"optimized",
"=",
"pPLD",
"(",
"self",
".",
"ID",
",",
"piter",
"=",
"piter",
",",
"pmaxf",
... | Runs :py:obj:`pPLD` on the target in an attempt to further optimize the
values of the PLD priors. See :py:class:`everest.detrender.pPLD`. | [
"Runs",
":",
"py",
":",
"obj",
":",
"pPLD",
"on",
"the",
"target",
"in",
"an",
"attempt",
"to",
"further",
"optimize",
"the",
"values",
"of",
"the",
"PLD",
"priors",
".",
"See",
":",
"py",
":",
"class",
":",
"everest",
".",
"detrender",
".",
"pPLD",
... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L1319-L1330 |
rodluger/everest | everest/user.py | Everest.plot_folded | def plot_folded(self, t0, period, dur=0.2):
'''
Plot the light curve folded on a given `period` and centered at `t0`.
When plotting folded transits, please mask them using
:py:meth:`mask_planet` and re-compute the model using
:py:meth:`compute`.
:param float t0: The time... | python | def plot_folded(self, t0, period, dur=0.2):
'''
Plot the light curve folded on a given `period` and centered at `t0`.
When plotting folded transits, please mask them using
:py:meth:`mask_planet` and re-compute the model using
:py:meth:`compute`.
:param float t0: The time... | [
"def",
"plot_folded",
"(",
"self",
",",
"t0",
",",
"period",
",",
"dur",
"=",
"0.2",
")",
":",
"# Mask the planet",
"self",
".",
"mask_planet",
"(",
"t0",
",",
"period",
",",
"dur",
")",
"# Whiten",
"gp",
"=",
"GP",
"(",
"self",
".",
"kernel",
",",
... | Plot the light curve folded on a given `period` and centered at `t0`.
When plotting folded transits, please mask them using
:py:meth:`mask_planet` and re-compute the model using
:py:meth:`compute`.
:param float t0: The time at which to center the plot \
(same units as lig... | [
"Plot",
"the",
"light",
"curve",
"folded",
"on",
"a",
"given",
"period",
"and",
"centered",
"at",
"t0",
".",
"When",
"plotting",
"folded",
"transits",
"please",
"mask",
"them",
"using",
":",
"py",
":",
"meth",
":",
"mask_planet",
"and",
"re",
"-",
"compu... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L1332-L1383 |
rodluger/everest | everest/user.py | Everest.plot_transit_model | def plot_transit_model(self, show=True, fold=None, ax=None):
'''
Plot the light curve de-trended with a join instrumental + transit
model with the best fit transit model overlaid. The transit model
should be specified using the :py:obj:`transit_model` attribute
and should be an i... | python | def plot_transit_model(self, show=True, fold=None, ax=None):
'''
Plot the light curve de-trended with a join instrumental + transit
model with the best fit transit model overlaid. The transit model
should be specified using the :py:obj:`transit_model` attribute
and should be an i... | [
"def",
"plot_transit_model",
"(",
"self",
",",
"show",
"=",
"True",
",",
"fold",
"=",
"None",
",",
"ax",
"=",
"None",
")",
":",
"if",
"self",
".",
"transit_model",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"No transit model provided!\"",
")",
"if",
... | Plot the light curve de-trended with a join instrumental + transit
model with the best fit transit model overlaid. The transit model
should be specified using the :py:obj:`transit_model` attribute
and should be an instance or list of instances of
:py:class:`everest.transit.TransitModel`.... | [
"Plot",
"the",
"light",
"curve",
"de",
"-",
"trended",
"with",
"a",
"join",
"instrumental",
"+",
"transit",
"model",
"with",
"the",
"best",
"fit",
"transit",
"model",
"overlaid",
".",
"The",
"transit",
"model",
"should",
"be",
"specified",
"using",
"the",
... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L1385-L1549 |
rodluger/everest | everest/mathutils.py | Interpolate | def Interpolate(time, mask, y):
'''
Masks certain elements in the array `y` and linearly
interpolates over them, returning an array `y'` of the
same length.
:param array_like time: The time array
:param array_like mask: The indices to be interpolated over
:param array_like y: The dependent ... | python | def Interpolate(time, mask, y):
'''
Masks certain elements in the array `y` and linearly
interpolates over them, returning an array `y'` of the
same length.
:param array_like time: The time array
:param array_like mask: The indices to be interpolated over
:param array_like y: The dependent ... | [
"def",
"Interpolate",
"(",
"time",
",",
"mask",
",",
"y",
")",
":",
"# Ensure `y` doesn't get modified in place",
"yy",
"=",
"np",
".",
"array",
"(",
"y",
")",
"t_",
"=",
"np",
".",
"delete",
"(",
"time",
",",
"mask",
")",
"y_",
"=",
"np",
".",
"dele... | Masks certain elements in the array `y` and linearly
interpolates over them, returning an array `y'` of the
same length.
:param array_like time: The time array
:param array_like mask: The indices to be interpolated over
:param array_like y: The dependent array | [
"Masks",
"certain",
"elements",
"in",
"the",
"array",
"y",
"and",
"linearly",
"interpolates",
"over",
"them",
"returning",
"an",
"array",
"y",
"of",
"the",
"same",
"length",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/mathutils.py#L21-L44 |
rodluger/everest | everest/mathutils.py | Chunks | def Chunks(l, n, all=False):
'''
Returns a generator of consecutive `n`-sized chunks of list `l`.
If `all` is `True`, returns **all** `n`-sized chunks in `l`
by iterating over the starting point.
'''
if all:
jarr = range(0, n - 1)
else:
jarr = [0]
for j in jarr:
... | python | def Chunks(l, n, all=False):
'''
Returns a generator of consecutive `n`-sized chunks of list `l`.
If `all` is `True`, returns **all** `n`-sized chunks in `l`
by iterating over the starting point.
'''
if all:
jarr = range(0, n - 1)
else:
jarr = [0]
for j in jarr:
... | [
"def",
"Chunks",
"(",
"l",
",",
"n",
",",
"all",
"=",
"False",
")",
":",
"if",
"all",
":",
"jarr",
"=",
"range",
"(",
"0",
",",
"n",
"-",
"1",
")",
"else",
":",
"jarr",
"=",
"[",
"0",
"]",
"for",
"j",
"in",
"jarr",
":",
"for",
"i",
"in",
... | Returns a generator of consecutive `n`-sized chunks of list `l`.
If `all` is `True`, returns **all** `n`-sized chunks in `l`
by iterating over the starting point. | [
"Returns",
"a",
"generator",
"of",
"consecutive",
"n",
"-",
"sized",
"chunks",
"of",
"list",
"l",
".",
"If",
"all",
"is",
"True",
"returns",
"**",
"all",
"**",
"n",
"-",
"sized",
"chunks",
"in",
"l",
"by",
"iterating",
"over",
"the",
"starting",
"point... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/mathutils.py#L58-L78 |
rodluger/everest | everest/mathutils.py | Smooth | def Smooth(x, window_len=100, window='hanning'):
'''
Smooth data by convolving on a given timescale.
:param ndarray x: The data array
:param int window_len: The size of the smoothing window. Default `100`
:param str window: The window type. Default `hanning`
'''
if window_len == 0:
... | python | def Smooth(x, window_len=100, window='hanning'):
'''
Smooth data by convolving on a given timescale.
:param ndarray x: The data array
:param int window_len: The size of the smoothing window. Default `100`
:param str window: The window type. Default `hanning`
'''
if window_len == 0:
... | [
"def",
"Smooth",
"(",
"x",
",",
"window_len",
"=",
"100",
",",
"window",
"=",
"'hanning'",
")",
":",
"if",
"window_len",
"==",
"0",
":",
"return",
"np",
".",
"zeros_like",
"(",
"x",
")",
"s",
"=",
"np",
".",
"r_",
"[",
"2",
"*",
"x",
"[",
"0",
... | Smooth data by convolving on a given timescale.
:param ndarray x: The data array
:param int window_len: The size of the smoothing window. Default `100`
:param str window: The window type. Default `hanning` | [
"Smooth",
"data",
"by",
"convolving",
"on",
"a",
"given",
"timescale",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/mathutils.py#L81-L101 |
rodluger/everest | everest/mathutils.py | Scatter | def Scatter(y, win=13, remove_outliers=False):
'''
Return the scatter in ppm based on the median running standard deviation
for a window size of :py:obj:`win` = 13 cadences (for K2, this
is ~6.5 hours, as in VJ14).
:param ndarray y: The array whose CDPP is to be computed
:param int win: The win... | python | def Scatter(y, win=13, remove_outliers=False):
'''
Return the scatter in ppm based on the median running standard deviation
for a window size of :py:obj:`win` = 13 cadences (for K2, this
is ~6.5 hours, as in VJ14).
:param ndarray y: The array whose CDPP is to be computed
:param int win: The win... | [
"def",
"Scatter",
"(",
"y",
",",
"win",
"=",
"13",
",",
"remove_outliers",
"=",
"False",
")",
":",
"if",
"remove_outliers",
":",
"# Remove 5-sigma outliers from data",
"# smoothed on a 1 day timescale",
"if",
"len",
"(",
"y",
")",
">=",
"50",
":",
"ys",
"=",
... | Return the scatter in ppm based on the median running standard deviation
for a window size of :py:obj:`win` = 13 cadences (for K2, this
is ~6.5 hours, as in VJ14).
:param ndarray y: The array whose CDPP is to be computed
:param int win: The window size in cadences. Default `13`
:param bool remove_o... | [
"Return",
"the",
"scatter",
"in",
"ppm",
"based",
"on",
"the",
"median",
"running",
"standard",
"deviation",
"for",
"a",
"window",
"size",
"of",
":",
"py",
":",
"obj",
":",
"win",
"=",
"13",
"cadences",
"(",
"for",
"K2",
"this",
"is",
"~6",
".",
"5",... | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/mathutils.py#L104-L136 |
rodluger/everest | everest/mathutils.py | SavGol | def SavGol(y, win=49):
'''
Subtracts a second order Savitsky-Golay filter with window size `win`
and returns the result. This acts as a high pass filter.
'''
if len(y) >= win:
return y - savgol_filter(y, win, 2) + np.nanmedian(y)
else:
return y | python | def SavGol(y, win=49):
'''
Subtracts a second order Savitsky-Golay filter with window size `win`
and returns the result. This acts as a high pass filter.
'''
if len(y) >= win:
return y - savgol_filter(y, win, 2) + np.nanmedian(y)
else:
return y | [
"def",
"SavGol",
"(",
"y",
",",
"win",
"=",
"49",
")",
":",
"if",
"len",
"(",
"y",
")",
">=",
"win",
":",
"return",
"y",
"-",
"savgol_filter",
"(",
"y",
",",
"win",
",",
"2",
")",
"+",
"np",
".",
"nanmedian",
"(",
"y",
")",
"else",
":",
"re... | Subtracts a second order Savitsky-Golay filter with window size `win`
and returns the result. This acts as a high pass filter. | [
"Subtracts",
"a",
"second",
"order",
"Savitsky",
"-",
"Golay",
"filter",
"with",
"window",
"size",
"win",
"and",
"returns",
"the",
"result",
".",
"This",
"acts",
"as",
"a",
"high",
"pass",
"filter",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/mathutils.py#L139-L149 |
rodluger/everest | everest/mathutils.py | NumRegressors | def NumRegressors(npix, pld_order, cross_terms=True):
'''
Return the number of regressors for `npix` pixels
and PLD order `pld_order`.
:param bool cross_terms: Include pixel cross-terms? Default :py:obj:`True`
'''
res = 0
for k in range(1, pld_order + 1):
if cross_terms:
... | python | def NumRegressors(npix, pld_order, cross_terms=True):
'''
Return the number of regressors for `npix` pixels
and PLD order `pld_order`.
:param bool cross_terms: Include pixel cross-terms? Default :py:obj:`True`
'''
res = 0
for k in range(1, pld_order + 1):
if cross_terms:
... | [
"def",
"NumRegressors",
"(",
"npix",
",",
"pld_order",
",",
"cross_terms",
"=",
"True",
")",
":",
"res",
"=",
"0",
"for",
"k",
"in",
"range",
"(",
"1",
",",
"pld_order",
"+",
"1",
")",
":",
"if",
"cross_terms",
":",
"res",
"+=",
"comb",
"(",
"npix"... | Return the number of regressors for `npix` pixels
and PLD order `pld_order`.
:param bool cross_terms: Include pixel cross-terms? Default :py:obj:`True` | [
"Return",
"the",
"number",
"of",
"regressors",
"for",
"npix",
"pixels",
"and",
"PLD",
"order",
"pld_order",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/mathutils.py#L152-L167 |
rodluger/everest | everest/mathutils.py | Downbin | def Downbin(x, newsize, axis=0, operation='mean'):
'''
Downbins an array to a smaller size.
:param array_like x: The array to down-bin
:param int newsize: The new size of the axis along which to down-bin
:param int axis: The axis to operate on. Default 0
:param str operation: The operation to p... | python | def Downbin(x, newsize, axis=0, operation='mean'):
'''
Downbins an array to a smaller size.
:param array_like x: The array to down-bin
:param int newsize: The new size of the axis along which to down-bin
:param int axis: The axis to operate on. Default 0
:param str operation: The operation to p... | [
"def",
"Downbin",
"(",
"x",
",",
"newsize",
",",
"axis",
"=",
"0",
",",
"operation",
"=",
"'mean'",
")",
":",
"assert",
"newsize",
"<",
"x",
".",
"shape",
"[",
"axis",
"]",
",",
"\"The new size of the array must be smaller than the current size.\"",
"oldsize",
... | Downbins an array to a smaller size.
:param array_like x: The array to down-bin
:param int newsize: The new size of the axis along which to down-bin
:param int axis: The axis to operate on. Default 0
:param str operation: The operation to perform when down-binning. \
Default `mean` | [
"Downbins",
"an",
"array",
"to",
"a",
"smaller",
"size",
"."
] | train | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/mathutils.py#L170-L205 |
lsbardel/python-stdnet | stdnet/odm/fields.py | Field.register_with_model | def register_with_model(self, name, model):
'''Called during the creation of a the :class:`StdModel`
class when :class:`Metaclass` is initialised. It fills
:attr:`Field.name` and :attr:`Field.model`. This is an internal
function users should never call.'''
if self.name:
raise FieldError('Fie... | python | def register_with_model(self, name, model):
'''Called during the creation of a the :class:`StdModel`
class when :class:`Metaclass` is initialised. It fills
:attr:`Field.name` and :attr:`Field.model`. This is an internal
function users should never call.'''
if self.name:
raise FieldError('Fie... | [
"def",
"register_with_model",
"(",
"self",
",",
"name",
",",
"model",
")",
":",
"if",
"self",
".",
"name",
":",
"raise",
"FieldError",
"(",
"'Field %s is already registered\\\n with a model'",
"%",
"self",
")",
"self",
".",
"name",
"=",
"name",
"self",
".",
... | Called during the creation of a the :class:`StdModel`
class when :class:`Metaclass` is initialised. It fills
:attr:`Field.name` and :attr:`Field.model`. This is an internal
function users should never call. | [
"Called",
"during",
"the",
"creation",
"of",
"a",
"the",
":",
"class",
":",
"StdModel",
"class",
"when",
":",
"class",
":",
"Metaclass",
"is",
"initialised",
".",
"It",
"fills",
":",
"attr",
":",
"Field",
".",
"name",
"and",
":",
"attr",
":",
"Field",
... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/fields.py#L192-L210 |
lsbardel/python-stdnet | stdnet/odm/fields.py | Field.add_to_fields | def add_to_fields(self):
'''Add this :class:`Field` to the fields of :attr:`model`.'''
meta = self.model._meta
meta.scalarfields.append(self)
if self.index:
meta.indices.append(self) | python | def add_to_fields(self):
'''Add this :class:`Field` to the fields of :attr:`model`.'''
meta = self.model._meta
meta.scalarfields.append(self)
if self.index:
meta.indices.append(self) | [
"def",
"add_to_fields",
"(",
"self",
")",
":",
"meta",
"=",
"self",
".",
"model",
".",
"_meta",
"meta",
".",
"scalarfields",
".",
"append",
"(",
"self",
")",
"if",
"self",
".",
"index",
":",
"meta",
".",
"indices",
".",
"append",
"(",
"self",
")"
] | Add this :class:`Field` to the fields of :attr:`model`. | [
"Add",
"this",
":",
"class",
":",
"Field",
"to",
"the",
"fields",
"of",
":",
"attr",
":",
"model",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/fields.py#L212-L217 |
lsbardel/python-stdnet | stdnet/odm/fields.py | Field.get_lookup | def get_lookup(self, remaining, errorClass=ValueError):
'''called by the :class:`Query` method when it needs to build
lookup on fields with additional nested fields. This is the case of
:class:`ForeignKey` and :class:`JSONField`.
:param remaining: the :ref:`double underscored` fields if this :class:`Field`
:pa... | python | def get_lookup(self, remaining, errorClass=ValueError):
'''called by the :class:`Query` method when it needs to build
lookup on fields with additional nested fields. This is the case of
:class:`ForeignKey` and :class:`JSONField`.
:param remaining: the :ref:`double underscored` fields if this :class:`Field`
:pa... | [
"def",
"get_lookup",
"(",
"self",
",",
"remaining",
",",
"errorClass",
"=",
"ValueError",
")",
":",
"if",
"remaining",
":",
"raise",
"errorClass",
"(",
"'Cannot use nested lookup on field %s'",
"%",
"self",
")",
"return",
"(",
"self",
".",
"attname",
",",
"Non... | called by the :class:`Query` method when it needs to build
lookup on fields with additional nested fields. This is the case of
:class:`ForeignKey` and :class:`JSONField`.
:param remaining: the :ref:`double underscored` fields if this :class:`Field`
:param errorClass: Optional exception class to use if the *remaining* ... | [
"called",
"by",
"the",
":",
"class",
":",
"Query",
"method",
"when",
"it",
"needs",
"to",
"build",
"lookup",
"on",
"fields",
"with",
"additional",
"nested",
"fields",
".",
"This",
"is",
"the",
"case",
"of",
":",
"class",
":",
"ForeignKey",
"and",
":",
... | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/fields.py#L254-L264 |
lsbardel/python-stdnet | stdnet/odm/fields.py | Field.get_value | def get_value(self, instance, *bits):
'''Retrieve the value :class:`Field` from a :class:`StdModel`
``instance``.
:param instance: The :class:`StdModel` ``instance`` invoking this function.
:param bits: Additional information for nested fields which derives from
the :ref:`double underscore <tutorial-unders... | python | def get_value(self, instance, *bits):
'''Retrieve the value :class:`Field` from a :class:`StdModel`
``instance``.
:param instance: The :class:`StdModel` ``instance`` invoking this function.
:param bits: Additional information for nested fields which derives from
the :ref:`double underscore <tutorial-unders... | [
"def",
"get_value",
"(",
"self",
",",
"instance",
",",
"*",
"bits",
")",
":",
"if",
"bits",
":",
"raise",
"AttributeError",
"else",
":",
"return",
"getattr",
"(",
"instance",
",",
"self",
".",
"attname",
")"
] | Retrieve the value :class:`Field` from a :class:`StdModel`
``instance``.
:param instance: The :class:`StdModel` ``instance`` invoking this function.
:param bits: Additional information for nested fields which derives from
the :ref:`double underscore <tutorial-underscore>` notation.
:return: the value of this :clas... | [
"Retrieve",
"the",
"value",
":",
"class",
":",
"Field",
"from",
"a",
":",
"class",
":",
"StdModel",
"instance",
"."
] | train | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/fields.py#L272-L288 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.