partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | plot_sampler_fingerprint | Make a plot of the sampler's "fingerprint": univariate marginal histograms for all hyperparameters.
The hyperparameters are mapped to [0, 1] using
:py:meth:`hyperprior.elementwise_cdf`, so this can only be used with prior
distributions which implement this function.
Returns the figure and axis... | gptools/utils.py | def plot_sampler_fingerprint(
sampler, hyperprior, weights=None, cutoff_weight=None, nbins=None,
labels=None, burn=0, chain_mask=None, temp_idx=0, points=None,
plot_samples=False, sample_color='k', point_color=None, point_lw=3,
title='', rot_x_labels=False, figsize=None
):
"""Mak... | def plot_sampler_fingerprint(
sampler, hyperprior, weights=None, cutoff_weight=None, nbins=None,
labels=None, burn=0, chain_mask=None, temp_idx=0, points=None,
plot_samples=False, sample_color='k', point_color=None, point_lw=3,
title='', rot_x_labels=False, figsize=None
):
"""Mak... | [
"Make",
"a",
"plot",
"of",
"the",
"sampler",
"s",
"fingerprint",
":",
"univariate",
"marginal",
"histograms",
"for",
"all",
"hyperparameters",
".",
"The",
"hyperparameters",
"are",
"mapped",
"to",
"[",
"0",
"1",
"]",
"using",
":",
"py",
":",
"meth",
":",
... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L2441-L2614 | [
"def",
"plot_sampler_fingerprint",
"(",
"sampler",
",",
"hyperprior",
",",
"weights",
"=",
"None",
",",
"cutoff_weight",
"=",
"None",
",",
"nbins",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"burn",
"=",
"0",
",",
"chain_mask",
"=",
"None",
",",
"temp... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | plot_sampler_cov | Make a plot of the sampler's correlation or covariance matrix.
Returns the figure and axis created.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or array, (`n_temps`, `n_chains`, `n_samp`, `n_dim`), (`n_chains`, `n_samp`, `n_dim`) or (`n_samp`, `n_dim`)
The sample... | gptools/utils.py | def plot_sampler_cov(
sampler, method='corr', weights=None, cutoff_weight=None, labels=None,
burn=0, chain_mask=None, temp_idx=0, cbar_label=None, title='',
rot_x_labels=False, figsize=None, xlabel_on_top=True
):
"""Make a plot of the sampler's correlation or covariance matrix.
... | def plot_sampler_cov(
sampler, method='corr', weights=None, cutoff_weight=None, labels=None,
burn=0, chain_mask=None, temp_idx=0, cbar_label=None, title='',
rot_x_labels=False, figsize=None, xlabel_on_top=True
):
"""Make a plot of the sampler's correlation or covariance matrix.
... | [
"Make",
"a",
"plot",
"of",
"the",
"sampler",
"s",
"correlation",
"or",
"covariance",
"matrix",
".",
"Returns",
"the",
"figure",
"and",
"axis",
"created",
".",
"Parameters",
"----------",
"sampler",
":",
":",
"py",
":",
"class",
":",
"emcee",
".",
"Sampler"... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L2616-L2752 | [
"def",
"plot_sampler_cov",
"(",
"sampler",
",",
"method",
"=",
"'corr'",
",",
"weights",
"=",
"None",
",",
"cutoff_weight",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"burn",
"=",
"0",
",",
"chain_mask",
"=",
"None",
",",
"temp_idx",
"=",
"0",
",",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | ProductJointPrior.sample_u | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | gptools/utils.py | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L285-L306 | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"p1_num_params",
"=",
"len",
"(",
"self",
".",
"p1",
".",
"bounds",
")",
"return",
"scipy",
".",
"concatenate",
"(",
"(",
"self",
".",
"p1",
".",
"sample_u",
"(",
"q",
"[",
":",
"p1_num_params",
"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | ProductJointPrior.elementwise_cdf | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | gptools/utils.py | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L308-L330 | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p1_num_params",
"=",
"len",
"(",
"self",
".",
"p1",
".",
"bounds",
")",
"return",
"scipy",
".",
"concatenate",
"(",
"(",
"self",
".",
"p1",
".",
"elementwise_cdf",
"(",
"p",
"[",
":",
"p1_nu... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | ProductJointPrior.random_draw | Draw random samples of the hyperparameters.
The outputs of the two priors are stacked vertically.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is... | gptools/utils.py | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
The outputs of the two priors are stacked vertically.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only o... | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
The outputs of the two priors are stacked vertically.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only o... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"The",
"outputs",
"of",
"the",
"two",
"priors",
"are",
"stacked",
"vertically",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"num... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L332-L349 | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"draw_1",
"=",
"self",
".",
"p1",
".",
"random_draw",
"(",
"size",
"=",
"size",
")",
"draw_2",
"=",
"self",
".",
"p2",
".",
"random_draw",
"(",
"size",
"=",
"size",
")",
"if",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | UniformJointPrior.sample_u | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | gptools/utils.py | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L392-L414 | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"bounds",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of ... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | UniformJointPrior.elementwise_cdf | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | gptools/utils.py | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L416-L445 | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"bounds",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the num... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | UniformJointPrior.random_draw | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | gptools/utils.py | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L447-L456 | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"numpy",
".",
"random",
".",
"uniform",
"(",
"low",
"=",
"b",
"[",
"0",
"]",
",",
"high",
"=",
"b",
"[",
"1",
"]",
",",
"size",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | CoreEdgeJointPrior.random_draw | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | gptools/utils.py | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L520-L554 | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"1",
"single_val",
"=",
"True",
"else",
":",
"single_val",
"=",
"False",
"out_shape",
"=",
"[",
"len",
"(",
"self",
".",
"bounds",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | IndependentJointPrior.sample_u | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | gptools/utils.py | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L708-L730 | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"univariate_priors",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | IndependentJointPrior.elementwise_cdf | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | gptools/utils.py | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L732-L753 | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"univariate_priors",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must eq... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | IndependentJointPrior.random_draw | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | gptools/utils.py | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L755-L764 | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"p",
".",
"rvs",
"(",
"size",
"=",
"size",
")",
"for",
"p",
"in",
"self",
".",
"univariate_priors",
"]",
")"
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | NormalJointPrior.bounds | The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful. | gptools/utils.py | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.norm.interval(self.i, loc=m, scale=s) for s, m in z... | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.norm.interval(self.i, loc=m, scale=s) for s, m in z... | [
"The",
"bounds",
"of",
"the",
"random",
"variable",
".",
"Set",
"self",
".",
"i",
"=",
"0",
".",
"95",
"to",
"return",
"the",
"95%",
"interval",
"if",
"this",
"is",
"used",
"for",
"setting",
"bounds",
"on",
"optimizers",
"/",
"etc",
".",
"where",
"in... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L803-L809 | [
"def",
"bounds",
"(",
"self",
")",
":",
"return",
"[",
"scipy",
".",
"stats",
".",
"norm",
".",
"interval",
"(",
"self",
".",
"i",
",",
"loc",
"=",
"m",
",",
"scale",
"=",
"s",
")",
"for",
"s",
",",
"m",
"in",
"zip",
"(",
"self",
".",
"sigma"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | NormalJointPrior.sample_u | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | gptools/utils.py | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L811-L833 | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of p... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | NormalJointPrior.elementwise_cdf | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | gptools/utils.py | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L835-L856 | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the numb... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | NormalJointPrior.random_draw | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | gptools/utils.py | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L858-L867 | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"scipy",
".",
"stats",
".",
"norm",
".",
"rvs",
"(",
"loc",
"=",
"m",
",",
"scale",
"=",
"s",
",",
"size",
"=",
"size",
")",
"fo... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | LogNormalJointPrior.bounds | The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful. | gptools/utils.py | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.lognorm.interval(self.i, s, loc=0, scale=em) for s,... | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.lognorm.interval(self.i, s, loc=0, scale=em) for s,... | [
"The",
"bounds",
"of",
"the",
"random",
"variable",
".",
"Set",
"self",
".",
"i",
"=",
"0",
".",
"95",
"to",
"return",
"the",
"95%",
"interval",
"if",
"this",
"is",
"used",
"for",
"setting",
"bounds",
"on",
"optimizers",
"/",
"etc",
".",
"where",
"in... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L909-L915 | [
"def",
"bounds",
"(",
"self",
")",
":",
"return",
"[",
"scipy",
".",
"stats",
".",
"lognorm",
".",
"interval",
"(",
"self",
".",
"i",
",",
"s",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"em",
")",
"for",
"s",
",",
"em",
"in",
"zip",
"(",
"self... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | LogNormalJointPrior.sample_u | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | gptools/utils.py | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L917-L939 | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of p... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | LogNormalJointPrior.elementwise_cdf | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | gptools/utils.py | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L941-L962 | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the numb... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | LogNormalJointPrior.random_draw | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | gptools/utils.py | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L964-L973 | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"scipy",
".",
"stats",
".",
"lognorm",
".",
"rvs",
"(",
"s",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"em",
",",
"size",
"=",
"s... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | GammaJointPrior.bounds | The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful. | gptools/utils.py | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.gamma.interval(self.i, a, loc=0, scale=1.0 / b) for... | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.gamma.interval(self.i, a, loc=0, scale=1.0 / b) for... | [
"The",
"bounds",
"of",
"the",
"random",
"variable",
".",
"Set",
"self",
".",
"i",
"=",
"0",
".",
"95",
"to",
"return",
"the",
"95%",
"interval",
"if",
"this",
"is",
"used",
"for",
"setting",
"bounds",
"on",
"optimizers",
"/",
"etc",
".",
"where",
"in... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1015-L1021 | [
"def",
"bounds",
"(",
"self",
")",
":",
"return",
"[",
"scipy",
".",
"stats",
".",
"gamma",
".",
"interval",
"(",
"self",
".",
"i",
",",
"a",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"1.0",
"/",
"b",
")",
"for",
"a",
",",
"b",
"in",
"zip",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | GammaJointPrior.sample_u | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | gptools/utils.py | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1023-L1045 | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"a",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of param... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | GammaJointPrior.elementwise_cdf | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | gptools/utils.py | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1047-L1068 | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"a",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the number o... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | GammaJointPrior.random_draw | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | gptools/utils.py | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1070-L1079 | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"scipy",
".",
"stats",
".",
"gamma",
".",
"rvs",
"(",
"a",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"1.0",
"/",
"b",
",",
"size"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | SortedUniformJointPrior.sample_u | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | gptools/utils.py | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1154-L1189 | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"self",
".",
"num_var",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of parameters!\"",
")",... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | SortedUniformJointPrior.elementwise_cdf | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | gptools/utils.py | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1191-L1233 | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"bounds",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the num... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | SortedUniformJointPrior.random_draw | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | gptools/utils.py | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | markchil/gptools | python | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1235-L1267 | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"1",
"single_val",
"=",
"True",
"else",
":",
"single_val",
"=",
"False",
"out_shape",
"=",
"[",
"self",
".",
"num_var",
"]",
"try",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 |
train | zapier_cancel_hook | Zapier can post something like this when tickets are cancelled
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
} | wafer/tickets/views.py | def zapier_cancel_hook(request):
'''
Zapier can post something like this when tickets are cancelled
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKET... | def zapier_cancel_hook(request):
'''
Zapier can post something like this when tickets are cancelled
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKET... | [
"Zapier",
"can",
"post",
"something",
"like",
"this",
"when",
"tickets",
"are",
"cancelled",
"{",
"ticket_type",
":",
"Individual",
"(",
"Regular",
")",
"barcode",
":",
"12345678",
"email",
":",
"demo"
] | CTPUG/wafer | python | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/tickets/views.py#L55-L73 | [
"def",
"zapier_cancel_hook",
"(",
"request",
")",
":",
"if",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_ZAPIER_SECRET'",
",",
"None",
")",
"!=",
"settings",
".",
"WAFER_TICKETS_SECRET",
":",
"raise",
"PermissionDenied",
"(",
"'Incorrect secret'",
")",
"# ... | a20af3c399267f76373dc342f4d542a9bc457c35 |
train | zapier_guest_hook | Zapier can POST something like this when tickets are bought:
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
} | wafer/tickets/views.py | def zapier_guest_hook(request):
'''
Zapier can POST something like this when tickets are bought:
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKETS_... | def zapier_guest_hook(request):
'''
Zapier can POST something like this when tickets are bought:
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKETS_... | [
"Zapier",
"can",
"POST",
"something",
"like",
"this",
"when",
"tickets",
"are",
"bought",
":",
"{"
] | CTPUG/wafer | python | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/tickets/views.py#L81-L99 | [
"def",
"zapier_guest_hook",
"(",
"request",
")",
":",
"if",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_ZAPIER_SECRET'",
",",
"None",
")",
"!=",
"settings",
".",
"WAFER_TICKETS_SECRET",
":",
"raise",
"PermissionDenied",
"(",
"'Incorrect secret'",
")",
"# T... | a20af3c399267f76373dc342f4d542a9bc457c35 |
train | TVM.fetch_token | Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header. | cocaine/detail/secadaptor.py | def fetch_token(self):
"""Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header.
"""
grant_type = 'client_credentials'
channel = yield self._tvm.ticket_full(
self._client_id, self._client_secret, grant_type, {})
ticket... | def fetch_token(self):
"""Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header.
"""
grant_type = 'client_credentials'
channel = yield self._tvm.ticket_full(
self._client_id, self._client_secret, grant_type, {})
ticket... | [
"Gains",
"token",
"from",
"secure",
"backend",
"service",
"."
] | cocaine/cocaine-framework-python | python | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/secadaptor.py#L54-L65 | [
"def",
"fetch_token",
"(",
"self",
")",
":",
"grant_type",
"=",
"'client_credentials'",
"channel",
"=",
"yield",
"self",
".",
"_tvm",
".",
"ticket_full",
"(",
"self",
".",
"_client_id",
",",
"self",
".",
"_client_secret",
",",
"grant_type",
",",
"{",
"}",
... | d8a30074b6338bac4389eb996e00d404338115e4 |
train | SecureServiceFabric.make_secure_adaptor | :param service: Service to wrap in.
:param mod: Name (type) of token refresh backend.
:param client_id: Client identifier.
:param client_secret: Client secret.
:param tok_update_sec: Token update interval in seconds. | cocaine/detail/secadaptor.py | def make_secure_adaptor(service, mod, client_id, client_secret, tok_update_sec=None):
"""
:param service: Service to wrap in.
:param mod: Name (type) of token refresh backend.
:param client_id: Client identifier.
:param client_secret: Client secret.
:param tok_update_sec:... | def make_secure_adaptor(service, mod, client_id, client_secret, tok_update_sec=None):
"""
:param service: Service to wrap in.
:param mod: Name (type) of token refresh backend.
:param client_id: Client identifier.
:param client_secret: Client secret.
:param tok_update_sec:... | [
":",
"param",
"service",
":",
"Service",
"to",
"wrap",
"in",
".",
":",
"param",
"mod",
":",
"Name",
"(",
"type",
")",
"of",
"token",
"refresh",
"backend",
".",
":",
"param",
"client_id",
":",
"Client",
"identifier",
".",
":",
"param",
"client_secret",
... | cocaine/cocaine-framework-python | python | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/secadaptor.py#L131-L142 | [
"def",
"make_secure_adaptor",
"(",
"service",
",",
"mod",
",",
"client_id",
",",
"client_secret",
",",
"tok_update_sec",
"=",
"None",
")",
":",
"if",
"mod",
"==",
"'TVM'",
":",
"return",
"SecureServiceAdaptor",
"(",
"service",
",",
"TVM",
"(",
"client_id",
"... | d8a30074b6338bac4389eb996e00d404338115e4 |
train | process_summary | Extracting information from an albacore summary file.
Only reads which have a >0 length are returned.
The fields below may or may not exist, depending on the type of sequencing performed.
Fields 1-14 are for 1D sequencing.
Fields 1-23 for 2D sequencing.
Fields 24-27, 2-5, 22-23 for 1D^2 (1D2) sequ... | nanoget/extraction_functions.py | def process_summary(summaryfile, **kwargs):
"""Extracting information from an albacore summary file.
Only reads which have a >0 length are returned.
The fields below may or may not exist, depending on the type of sequencing performed.
Fields 1-14 are for 1D sequencing.
Fields 1-23 for 2D sequencin... | def process_summary(summaryfile, **kwargs):
"""Extracting information from an albacore summary file.
Only reads which have a >0 length are returned.
The fields below may or may not exist, depending on the type of sequencing performed.
Fields 1-14 are for 1D sequencing.
Fields 1-23 for 2D sequencin... | [
"Extracting",
"information",
"from",
"an",
"albacore",
"summary",
"file",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L12-L90 | [
"def",
"process_summary",
"(",
"summaryfile",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Collecting metrics from summary file {} for {} sequencing\"",
".",
"format",
"(",
"summaryfile",
",",
"kwargs",
"[",
"\"readtype\"",
"]",
")",
"... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | check_bam | Check if bam file is valid.
Bam file should:
- exists
- has an index (create if necessary)
- is sorted by coordinate
- has at least one mapped read | nanoget/extraction_functions.py | def check_bam(bam, samtype="bam"):
"""Check if bam file is valid.
Bam file should:
- exists
- has an index (create if necessary)
- is sorted by coordinate
- has at least one mapped read
"""
ut.check_existance(bam)
samfile = pysam.AlignmentFile(bam, "rb")
if not samfile.has_index... | def check_bam(bam, samtype="bam"):
"""Check if bam file is valid.
Bam file should:
- exists
- has an index (create if necessary)
- is sorted by coordinate
- has at least one mapped read
"""
ut.check_existance(bam)
samfile = pysam.AlignmentFile(bam, "rb")
if not samfile.has_index... | [
"Check",
"if",
"bam",
"file",
"is",
"valid",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L93-L117 | [
"def",
"check_bam",
"(",
"bam",
",",
"samtype",
"=",
"\"bam\"",
")",
":",
"ut",
".",
"check_existance",
"(",
"bam",
")",
"samfile",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam",
",",
"\"rb\"",
")",
"if",
"not",
"samfile",
".",
"has_index",
"(",
")",
... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | process_ubam | Extracting metrics from unaligned bam format
Extracting lengths | nanoget/extraction_functions.py | def process_ubam(bam, **kwargs):
"""Extracting metrics from unaligned bam format
Extracting lengths
"""
logging.info("Nanoget: Starting to collect statistics from ubam file {}.".format(bam))
samfile = pysam.AlignmentFile(bam, "rb", check_sq=False)
if not samfile.has_index():
pysam.index(... | def process_ubam(bam, **kwargs):
"""Extracting metrics from unaligned bam format
Extracting lengths
"""
logging.info("Nanoget: Starting to collect statistics from ubam file {}.".format(bam))
samfile = pysam.AlignmentFile(bam, "rb", check_sq=False)
if not samfile.has_index():
pysam.index(... | [
"Extracting",
"metrics",
"from",
"unaligned",
"bam",
"format",
"Extracting",
"lengths"
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L120-L139 | [
"def",
"process_ubam",
"(",
"bam",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from ubam file {}.\"",
".",
"format",
"(",
"bam",
")",
")",
"samfile",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam",
... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | process_bam | Combines metrics from bam after extraction.
Processing function: calls pool of worker functions
to extract from a bam file the following metrics:
-lengths
-aligned lengths
-qualities
-aligned qualities
-mapping qualities
-edit distances to the reference genome scaled by read length
... | nanoget/extraction_functions.py | def process_bam(bam, **kwargs):
"""Combines metrics from bam after extraction.
Processing function: calls pool of worker functions
to extract from a bam file the following metrics:
-lengths
-aligned lengths
-qualities
-aligned qualities
-mapping qualities
-edit distances to the refe... | def process_bam(bam, **kwargs):
"""Combines metrics from bam after extraction.
Processing function: calls pool of worker functions
to extract from a bam file the following metrics:
-lengths
-aligned lengths
-qualities
-aligned qualities
-mapping qualities
-edit distances to the refe... | [
"Combines",
"metrics",
"from",
"bam",
"after",
"extraction",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L142-L168 | [
"def",
"process_bam",
"(",
"bam",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from bam file {}.\"",
".",
"format",
"(",
"bam",
")",
")",
"samfile",
"=",
"check_bam",
"(",
"bam",
")",
"chromosomes",
... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | extract_from_bam | Extracts metrics from bam.
Worker function per chromosome
loop over a bam file and create list with tuples containing metrics:
-qualities
-aligned qualities
-lengths
-aligned lengths
-mapping qualities
-edit distances to the reference genome scaled by read length | nanoget/extraction_functions.py | def extract_from_bam(params):
"""Extracts metrics from bam.
Worker function per chromosome
loop over a bam file and create list with tuples containing metrics:
-qualities
-aligned qualities
-lengths
-aligned lengths
-mapping qualities
-edit distances to the reference genome scaled b... | def extract_from_bam(params):
"""Extracts metrics from bam.
Worker function per chromosome
loop over a bam file and create list with tuples containing metrics:
-qualities
-aligned qualities
-lengths
-aligned lengths
-mapping qualities
-edit distances to the reference genome scaled b... | [
"Extracts",
"metrics",
"from",
"bam",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L200-L223 | [
"def",
"extract_from_bam",
"(",
"params",
")",
":",
"bam",
",",
"chromosome",
"=",
"params",
"samfile",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam",
",",
"\"rb\"",
")",
"return",
"[",
"(",
"read",
".",
"query_name",
",",
"nanomath",
".",
"ave_qual",
"... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | get_pID | Return the percent identity of a read.
based on the NM tag if present,
if not calculate from MD tag and CIGAR string
read.query_alignment_length can be zero in the case of ultra long reads aligned with minimap2 -L | nanoget/extraction_functions.py | def get_pID(read):
"""Return the percent identity of a read.
based on the NM tag if present,
if not calculate from MD tag and CIGAR string
read.query_alignment_length can be zero in the case of ultra long reads aligned with minimap2 -L
"""
try:
return 100 * (1 - read.get_tag("NM") / re... | def get_pID(read):
"""Return the percent identity of a read.
based on the NM tag if present,
if not calculate from MD tag and CIGAR string
read.query_alignment_length can be zero in the case of ultra long reads aligned with minimap2 -L
"""
try:
return 100 * (1 - read.get_tag("NM") / re... | [
"Return",
"the",
"percent",
"identity",
"of",
"a",
"read",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L226-L243 | [
"def",
"get_pID",
"(",
"read",
")",
":",
"try",
":",
"return",
"100",
"*",
"(",
"1",
"-",
"read",
".",
"get_tag",
"(",
"\"NM\"",
")",
"/",
"read",
".",
"query_alignment_length",
")",
"except",
"KeyError",
":",
"try",
":",
"return",
"100",
"*",
"(",
... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | handle_compressed_input | Return handles from compressed files according to extension.
Check for which fastq input is presented and open a handle accordingly
Can read from compressed files (gz, bz2, bgz) or uncompressed
Relies on file extensions to recognize compression | nanoget/extraction_functions.py | def handle_compressed_input(inputfq, file_type="fastq"):
"""Return handles from compressed files according to extension.
Check for which fastq input is presented and open a handle accordingly
Can read from compressed files (gz, bz2, bgz) or uncompressed
Relies on file extensions to recognize compressio... | def handle_compressed_input(inputfq, file_type="fastq"):
"""Return handles from compressed files according to extension.
Check for which fastq input is presented and open a handle accordingly
Can read from compressed files (gz, bz2, bgz) or uncompressed
Relies on file extensions to recognize compressio... | [
"Return",
"handles",
"from",
"compressed",
"files",
"according",
"to",
"extension",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L256-L277 | [
"def",
"handle_compressed_input",
"(",
"inputfq",
",",
"file_type",
"=",
"\"fastq\"",
")",
":",
"ut",
".",
"check_existance",
"(",
"inputfq",
")",
"if",
"inputfq",
".",
"endswith",
"(",
"(",
"'.gz'",
",",
"'bgz'",
")",
")",
":",
"import",
"gzip",
"logging"... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | process_fasta | Combine metrics extracted from a fasta file. | nanoget/extraction_functions.py | def process_fasta(fasta, **kwargs):
"""Combine metrics extracted from a fasta file."""
logging.info("Nanoget: Starting to collect statistics from a fasta file.")
inputfasta = handle_compressed_input(fasta, file_type="fasta")
return ut.reduce_memory_usage(pd.DataFrame(
data=[len(rec) for rec in S... | def process_fasta(fasta, **kwargs):
"""Combine metrics extracted from a fasta file."""
logging.info("Nanoget: Starting to collect statistics from a fasta file.")
inputfasta = handle_compressed_input(fasta, file_type="fasta")
return ut.reduce_memory_usage(pd.DataFrame(
data=[len(rec) for rec in S... | [
"Combine",
"metrics",
"extracted",
"from",
"a",
"fasta",
"file",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L280-L287 | [
"def",
"process_fasta",
"(",
"fasta",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from a fasta file.\"",
")",
"inputfasta",
"=",
"handle_compressed_input",
"(",
"fasta",
",",
"file_type",
"=",
"\"fasta\"",... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | process_fastq_plain | Combine metrics extracted from a fastq file. | nanoget/extraction_functions.py | def process_fastq_plain(fastq, **kwargs):
"""Combine metrics extracted from a fastq file."""
logging.info("Nanoget: Starting to collect statistics from plain fastq file.")
inputfastq = handle_compressed_input(fastq)
return ut.reduce_memory_usage(pd.DataFrame(
data=[res for res in extract_from_fa... | def process_fastq_plain(fastq, **kwargs):
"""Combine metrics extracted from a fastq file."""
logging.info("Nanoget: Starting to collect statistics from plain fastq file.")
inputfastq = handle_compressed_input(fastq)
return ut.reduce_memory_usage(pd.DataFrame(
data=[res for res in extract_from_fa... | [
"Combine",
"metrics",
"extracted",
"from",
"a",
"fastq",
"file",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L290-L297 | [
"def",
"process_fastq_plain",
"(",
"fastq",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from plain fastq file.\"",
")",
"inputfastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"return",
"ut",
".",... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | extract_from_fastq | Extract metrics from a fastq file.
Return average quality and read length | nanoget/extraction_functions.py | def extract_from_fastq(fq):
"""Extract metrics from a fastq file.
Return average quality and read length
"""
for rec in SeqIO.parse(fq, "fastq"):
yield nanomath.ave_qual(rec.letter_annotations["phred_quality"]), len(rec) | def extract_from_fastq(fq):
"""Extract metrics from a fastq file.
Return average quality and read length
"""
for rec in SeqIO.parse(fq, "fastq"):
yield nanomath.ave_qual(rec.letter_annotations["phred_quality"]), len(rec) | [
"Extract",
"metrics",
"from",
"a",
"fastq",
"file",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L300-L306 | [
"def",
"extract_from_fastq",
"(",
"fq",
")",
":",
"for",
"rec",
"in",
"SeqIO",
".",
"parse",
"(",
"fq",
",",
"\"fastq\"",
")",
":",
"yield",
"nanomath",
".",
"ave_qual",
"(",
"rec",
".",
"letter_annotations",
"[",
"\"phred_quality\"",
"]",
")",
",",
"len... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | stream_fastq_full | Generator for returning metrics extracted from fastq.
Extract from a fastq file:
-readname
-average and median quality
-read_lenght | nanoget/extraction_functions.py | def stream_fastq_full(fastq, threads):
"""Generator for returning metrics extracted from fastq.
Extract from a fastq file:
-readname
-average and median quality
-read_lenght
"""
logging.info("Nanoget: Starting to collect full metrics from plain fastq file.")
inputfastq = handle_compress... | def stream_fastq_full(fastq, threads):
"""Generator for returning metrics extracted from fastq.
Extract from a fastq file:
-readname
-average and median quality
-read_lenght
"""
logging.info("Nanoget: Starting to collect full metrics from plain fastq file.")
inputfastq = handle_compress... | [
"Generator",
"for",
"returning",
"metrics",
"extracted",
"from",
"fastq",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L309-L322 | [
"def",
"stream_fastq_full",
"(",
"fastq",
",",
"threads",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect full metrics from plain fastq file.\"",
")",
"inputfastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"with",
"cfutures",
".",
"Proce... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | extract_all_from_fastq | Extract metrics from a fastq file.
Return identifier, read length, average quality and median quality | nanoget/extraction_functions.py | def extract_all_from_fastq(rec):
"""Extract metrics from a fastq file.
Return identifier, read length, average quality and median quality
"""
return (rec.id,
len(rec),
nanomath.ave_qual(rec.letter_annotations["phred_quality"]),
nanomath.median_qual(rec.letter_annotat... | def extract_all_from_fastq(rec):
"""Extract metrics from a fastq file.
Return identifier, read length, average quality and median quality
"""
return (rec.id,
len(rec),
nanomath.ave_qual(rec.letter_annotations["phred_quality"]),
nanomath.median_qual(rec.letter_annotat... | [
"Extract",
"metrics",
"from",
"a",
"fastq",
"file",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L325-L333 | [
"def",
"extract_all_from_fastq",
"(",
"rec",
")",
":",
"return",
"(",
"rec",
".",
"id",
",",
"len",
"(",
"rec",
")",
",",
"nanomath",
".",
"ave_qual",
"(",
"rec",
".",
"letter_annotations",
"[",
"\"phred_quality\"",
"]",
")",
",",
"nanomath",
".",
"media... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | process_fastq_rich | Extract metrics from a richer fastq file.
Extract information from fastq files generated by albacore or MinKNOW,
containing richer information in the header (key-value pairs)
read=<int> [72]
ch=<int> [159]
start_time=<timestamp> [2016-07-15T14:23:22Z] # UTC ISO 8601 ISO 3339 timestamp
Z indica... | nanoget/extraction_functions.py | def process_fastq_rich(fastq, **kwargs):
"""Extract metrics from a richer fastq file.
Extract information from fastq files generated by albacore or MinKNOW,
containing richer information in the header (key-value pairs)
read=<int> [72]
ch=<int> [159]
start_time=<timestamp> [2016-07-15T14:23:22Z]... | def process_fastq_rich(fastq, **kwargs):
"""Extract metrics from a richer fastq file.
Extract information from fastq files generated by albacore or MinKNOW,
containing richer information in the header (key-value pairs)
read=<int> [72]
ch=<int> [159]
start_time=<timestamp> [2016-07-15T14:23:22Z]... | [
"Extract",
"metrics",
"from",
"a",
"richer",
"fastq",
"file",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L341-L374 | [
"def",
"process_fastq_rich",
"(",
"fastq",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from rich fastq file.\"",
")",
"inputfastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"res",
"=",
"[",
"]"... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | readfq | Generator function adapted from https://github.com/lh3/readfq. | nanoget/extraction_functions.py | def readfq(fp):
"""Generator function adapted from https://github.com/lh3/readfq."""
last = None # this is a buffer keeping the last unprocessed line
while True: # mimic closure; is it a bad idea?
if not last: # the first record or a record following a fastq
for l in fp: # search for... | def readfq(fp):
"""Generator function adapted from https://github.com/lh3/readfq."""
last = None # this is a buffer keeping the last unprocessed line
while True: # mimic closure; is it a bad idea?
if not last: # the first record or a record following a fastq
for l in fp: # search for... | [
"Generator",
"function",
"adapted",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"lh3",
"/",
"readfq",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L377-L409 | [
"def",
"readfq",
"(",
"fp",
")",
":",
"last",
"=",
"None",
"# this is a buffer keeping the last unprocessed line",
"while",
"True",
":",
"# mimic closure; is it a bad idea?",
"if",
"not",
"last",
":",
"# the first record or a record following a fastq",
"for",
"l",
"in",
"... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | fq_minimal | Minimal fastq metrics extractor.
Quickly parse a fasta/fastq file - but makes expectations on the file format
There will be dragons if unexpected format is used
Expects a fastq_rich format, but extracts only timestamp and length | nanoget/extraction_functions.py | def fq_minimal(fq):
"""Minimal fastq metrics extractor.
Quickly parse a fasta/fastq file - but makes expectations on the file format
There will be dragons if unexpected format is used
Expects a fastq_rich format, but extracts only timestamp and length
"""
try:
while True:
ti... | def fq_minimal(fq):
"""Minimal fastq metrics extractor.
Quickly parse a fasta/fastq file - but makes expectations on the file format
There will be dragons if unexpected format is used
Expects a fastq_rich format, but extracts only timestamp and length
"""
try:
while True:
ti... | [
"Minimal",
"fastq",
"metrics",
"extractor",
"."
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L412-L427 | [
"def",
"fq_minimal",
"(",
"fq",
")",
":",
"try",
":",
"while",
"True",
":",
"time",
"=",
"next",
"(",
"fq",
")",
"[",
"1",
":",
"]",
".",
"split",
"(",
"\" \"",
")",
"[",
"4",
"]",
"[",
"11",
":",
"-",
"1",
"]",
"length",
"=",
"len",
"(",
... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | process_fastq_minimal | Swiftly extract minimal features (length and timestamp) from a rich fastq file | nanoget/extraction_functions.py | def process_fastq_minimal(fastq, **kwargs):
"""Swiftly extract minimal features (length and timestamp) from a rich fastq file"""
infastq = handle_compressed_input(fastq)
try:
df = pd.DataFrame(
data=[rec for rec in fq_minimal(infastq) if rec],
columns=["timestamp", "lengths"]... | def process_fastq_minimal(fastq, **kwargs):
"""Swiftly extract minimal features (length and timestamp) from a rich fastq file"""
infastq = handle_compressed_input(fastq)
try:
df = pd.DataFrame(
data=[rec for rec in fq_minimal(infastq) if rec],
columns=["timestamp", "lengths"]... | [
"Swiftly",
"extract",
"minimal",
"features",
"(",
"length",
"and",
"timestamp",
")",
"from",
"a",
"rich",
"fastq",
"file"
] | wdecoster/nanoget | python | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L430-L441 | [
"def",
"process_fastq_minimal",
"(",
"fastq",
",",
"*",
"*",
"kwargs",
")",
":",
"infastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"try",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"data",
"=",
"[",
"rec",
"for",
"rec",
"in",
"fq_minimal",
... | fb7306220e261849b96785fab02dd2f35a0e3b60 |
train | _get_piece | Returns Piece subclass given index of piece.
:type: index: int
:type: loc Location
:raise: KeyError | chess_py/core/algebraic/converter.py | def _get_piece(string, index):
"""
Returns Piece subclass given index of piece.
:type: index: int
:type: loc Location
:raise: KeyError
"""
piece = string[index].strip()
piece = piece.upper()
piece_dict = {'R': Rook,
'P': Pawn,
'B': Bishop,
... | def _get_piece(string, index):
"""
Returns Piece subclass given index of piece.
:type: index: int
:type: loc Location
:raise: KeyError
"""
piece = string[index].strip()
piece = piece.upper()
piece_dict = {'R': Rook,
'P': Pawn,
'B': Bishop,
... | [
"Returns",
"Piece",
"subclass",
"given",
"index",
"of",
"piece",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L24-L44 | [
"def",
"_get_piece",
"(",
"string",
",",
"index",
")",
":",
"piece",
"=",
"string",
"[",
"index",
"]",
".",
"strip",
"(",
")",
"piece",
"=",
"piece",
".",
"upper",
"(",
")",
"piece_dict",
"=",
"{",
"'R'",
":",
"Rook",
",",
"'P'",
":",
"Pawn",
","... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | incomplete_alg | Converts a string written in short algebraic form into an incomplete move.
These incomplete moves do not have the initial location specified and
therefore cannot be used to update the board. IN order to fully utilize
incomplete move, it must be run through ``make_legal()`` with
the corresponding positio... | chess_py/core/algebraic/converter.py | def incomplete_alg(alg_str, input_color, position):
"""
Converts a string written in short algebraic form into an incomplete move.
These incomplete moves do not have the initial location specified and
therefore cannot be used to update the board. IN order to fully utilize
incomplete move, it must be... | def incomplete_alg(alg_str, input_color, position):
"""
Converts a string written in short algebraic form into an incomplete move.
These incomplete moves do not have the initial location specified and
therefore cannot be used to update the board. IN order to fully utilize
incomplete move, it must be... | [
"Converts",
"a",
"string",
"written",
"in",
"short",
"algebraic",
"form",
"into",
"an",
"incomplete",
"move",
".",
"These",
"incomplete",
"moves",
"do",
"not",
"have",
"the",
"initial",
"location",
"specified",
"and",
"therefore",
"cannot",
"be",
"used",
"to",... | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L105-L305 | [
"def",
"incomplete_alg",
"(",
"alg_str",
",",
"input_color",
",",
"position",
")",
":",
"edge_rank",
"=",
"0",
"if",
"input_color",
"==",
"color",
".",
"white",
"else",
"7",
"if",
"alg_str",
"is",
"None",
"or",
"len",
"(",
"alg_str",
")",
"<=",
"1",
":... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | make_legal | Converts an incomplete move (initial ``Location`` not specified)
and the corresponding position into the a complete move
with the most likely starting point specified. If no moves match, ``None``
is returned.
:type: move: Move
:type: position: Board
:rtype: Move | chess_py/core/algebraic/converter.py | def make_legal(move, position):
"""
Converts an incomplete move (initial ``Location`` not specified)
and the corresponding position into the a complete move
with the most likely starting point specified. If no moves match, ``None``
is returned.
:type: move: Move
:type: position: Board
:... | def make_legal(move, position):
"""
Converts an incomplete move (initial ``Location`` not specified)
and the corresponding position into the a complete move
with the most likely starting point specified. If no moves match, ``None``
is returned.
:type: move: Move
:type: position: Board
:... | [
"Converts",
"an",
"incomplete",
"move",
"(",
"initial",
"Location",
"not",
"specified",
")",
"and",
"the",
"corresponding",
"position",
"into",
"the",
"a",
"complete",
"move",
"with",
"the",
"most",
"likely",
"starting",
"point",
"specified",
".",
"If",
"no",
... | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L308-L330 | [
"def",
"make_legal",
"(",
"move",
",",
"position",
")",
":",
"assert",
"isinstance",
"(",
"move",
",",
"Move",
")",
"for",
"legal_move",
"in",
"position",
".",
"all_possible_moves",
"(",
"move",
".",
"color",
")",
":",
"if",
"move",
".",
"status",
"==",
... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | short_alg | Converts a string written in short algebraic form, the color
of the side whose turn it is, and the corresponding position
into a complete move that can be played. If no moves match,
None is returned.
Examples: e4, Nf3, exd5, Qxf3, 00, 000, e8=Q
:type: algebraic_string: str
:type: input_color: ... | chess_py/core/algebraic/converter.py | def short_alg(algebraic_string, input_color, position):
"""
Converts a string written in short algebraic form, the color
of the side whose turn it is, and the corresponding position
into a complete move that can be played. If no moves match,
None is returned.
Examples: e4, Nf3, exd5, Qxf3, 00, ... | def short_alg(algebraic_string, input_color, position):
"""
Converts a string written in short algebraic form, the color
of the side whose turn it is, and the corresponding position
into a complete move that can be played. If no moves match,
None is returned.
Examples: e4, Nf3, exd5, Qxf3, 00, ... | [
"Converts",
"a",
"string",
"written",
"in",
"short",
"algebraic",
"form",
"the",
"color",
"of",
"the",
"side",
"whose",
"turn",
"it",
"is",
"and",
"the",
"corresponding",
"position",
"into",
"a",
"complete",
"move",
"that",
"can",
"be",
"played",
".",
"If"... | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L333-L346 | [
"def",
"short_alg",
"(",
"algebraic_string",
",",
"input_color",
",",
"position",
")",
":",
"return",
"make_legal",
"(",
"incomplete_alg",
"(",
"algebraic_string",
",",
"input_color",
",",
"position",
")",
",",
"position",
")"
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | long_alg | Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move | chess_py/core/algebraic/converter.py | def long_alg(alg_str, position):
"""
Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move
... | def long_alg(alg_str, position):
"""
Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move
... | [
"Converts",
"a",
"string",
"written",
"in",
"long",
"algebraic",
"form",
"and",
"the",
"corresponding",
"position",
"into",
"a",
"complete",
"move",
"(",
"initial",
"location",
"specified",
")",
".",
"Used",
"primarily",
"for",
"UCI",
"but",
"can",
"be",
"us... | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L349-L383 | [
"def",
"long_alg",
"(",
"alg_str",
",",
"position",
")",
":",
"if",
"alg_str",
"is",
"None",
"or",
"len",
"(",
"alg_str",
")",
"<",
"4",
"or",
"len",
"(",
"alg_str",
")",
">",
"6",
":",
"raise",
"ValueError",
"(",
"\"Invalid string input {}\"",
".",
"f... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | MoleculeContainer.reset_query_marks | set or reset hyb and neighbors marks to atoms. | CGRtools/containers/molecule.py | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
# hybridization 1- sp3; 2- sp2; 3- sp1; 4- aromatic
for j, bond in self._adj[i].items():
... | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
# hybridization 1- sp3; 2- sp2; 3- sp1; 4- aromatic
for j, bond in self._adj[i].items():
... | [
"set",
"or",
"reset",
"hyb",
"and",
"neighbors",
"marks",
"to",
"atoms",
"."
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L38-L65 | [
"def",
"reset_query_marks",
"(",
"self",
")",
":",
"for",
"i",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"neighbors",
"=",
"0",
"hybridization",
"=",
"1",
"# hybridization 1- sp3; 2- sp2; 3- sp1; 4- aromatic",
"for",
"j",
",",
"bond",
"in",
"se... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | MoleculeContainer.implicify_hydrogens | remove explicit hydrogen if possible
:return: number of removed hydrogens | CGRtools/containers/molecule.py | def implicify_hydrogens(self):
"""
remove explicit hydrogen if possible
:return: number of removed hydrogens
"""
explicit = defaultdict(list)
c = 0
for n, atom in self.atoms():
if atom.element == 'H':
for m in self.neighbors(n):
... | def implicify_hydrogens(self):
"""
remove explicit hydrogen if possible
:return: number of removed hydrogens
"""
explicit = defaultdict(list)
c = 0
for n, atom in self.atoms():
if atom.element == 'H':
for m in self.neighbors(n):
... | [
"remove",
"explicit",
"hydrogen",
"if",
"possible"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L67-L93 | [
"def",
"implicify_hydrogens",
"(",
"self",
")",
":",
"explicit",
"=",
"defaultdict",
"(",
"list",
")",
"c",
"=",
"0",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"atom",
".",
"element",
"==",
"'H'",
":",
"for",
"m",
... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | MoleculeContainer.explicify_hydrogens | add explicit hydrogens to atoms
:return: number of added atoms | CGRtools/containers/molecule.py | def explicify_hydrogens(self):
"""
add explicit hydrogens to atoms
:return: number of added atoms
"""
tmp = []
for n, atom in self.atoms():
if atom.element != 'H':
for _ in range(atom.get_implicit_h([x.order for x in self._adj[n].values()])):
... | def explicify_hydrogens(self):
"""
add explicit hydrogens to atoms
:return: number of added atoms
"""
tmp = []
for n, atom in self.atoms():
if atom.element != 'H':
for _ in range(atom.get_implicit_h([x.order for x in self._adj[n].values()])):
... | [
"add",
"explicit",
"hydrogens",
"to",
"atoms"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L95-L110 | [
"def",
"explicify_hydrogens",
"(",
"self",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"atom",
".",
"element",
"!=",
"'H'",
":",
"for",
"_",
"in",
"range",
"(",
"atom",
".",
"get_impli... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | MoleculeContainer.substructure | create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view provides a read-only view
of the original structure scaffold withou... | CGRtools/containers/molecule.py | def substructure(self, atoms, meta=False, as_view=True):
"""
create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view pr... | def substructure(self, atoms, meta=False, as_view=True):
"""
create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view pr... | [
"create",
"substructure",
"containing",
"atoms",
"from",
"nbunch",
"list"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L112-L125 | [
"def",
"substructure",
"(",
"self",
",",
"atoms",
",",
"meta",
"=",
"False",
",",
"as_view",
"=",
"True",
")",
":",
"s",
"=",
"super",
"(",
")",
".",
"substructure",
"(",
"atoms",
",",
"meta",
",",
"as_view",
")",
"if",
"as_view",
":",
"s",
".",
... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | MoleculeContainer.check_valence | check valences of all atoms
:return: list of invalid atoms | CGRtools/containers/molecule.py | def check_valence(self):
"""
check valences of all atoms
:return: list of invalid atoms
"""
return [x for x, atom in self.atoms() if not atom.check_valence(self.environment(x))] | def check_valence(self):
"""
check valences of all atoms
:return: list of invalid atoms
"""
return [x for x, atom in self.atoms() if not atom.check_valence(self.environment(x))] | [
"check",
"valences",
"of",
"all",
"atoms"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L139-L145 | [
"def",
"check_valence",
"(",
"self",
")",
":",
"return",
"[",
"x",
"for",
"x",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
"if",
"not",
"atom",
".",
"check_valence",
"(",
"self",
".",
"environment",
"(",
"x",
")",
")",
"]"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | MoleculeContainer._matcher | return VF2 GraphMatcher
MoleculeContainer < MoleculeContainer
MoleculeContainer < CGRContainer | CGRtools/containers/molecule.py | def _matcher(self, other):
"""
return VF2 GraphMatcher
MoleculeContainer < MoleculeContainer
MoleculeContainer < CGRContainer
"""
if isinstance(other, (self._get_subclass('CGRContainer'), MoleculeContainer)):
return GraphMatcher(other, self, lambda x, y: x ==... | def _matcher(self, other):
"""
return VF2 GraphMatcher
MoleculeContainer < MoleculeContainer
MoleculeContainer < CGRContainer
"""
if isinstance(other, (self._get_subclass('CGRContainer'), MoleculeContainer)):
return GraphMatcher(other, self, lambda x, y: x ==... | [
"return",
"VF2",
"GraphMatcher"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L147-L156 | [
"def",
"_matcher",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"(",
"self",
".",
"_get_subclass",
"(",
"'CGRContainer'",
")",
",",
"MoleculeContainer",
")",
")",
":",
"return",
"GraphMatcher",
"(",
"other",
",",
"self",
",... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | to_datetime | Turn a date into a datetime at midnight. | jira_metrics_extract/query.py | def to_datetime(date):
"""Turn a date into a datetime at midnight.
"""
return datetime.datetime.combine(date, datetime.datetime.min.time()) | def to_datetime(date):
"""Turn a date into a datetime at midnight.
"""
return datetime.datetime.combine(date, datetime.datetime.min.time()) | [
"Turn",
"a",
"date",
"into",
"a",
"datetime",
"at",
"midnight",
"."
] | rnwolf/jira-metrics-extract | python | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/query.py#L9-L12 | [
"def",
"to_datetime",
"(",
"date",
")",
":",
"return",
"datetime",
".",
"datetime",
".",
"combine",
"(",
"date",
",",
"datetime",
".",
"datetime",
".",
"min",
".",
"time",
"(",
")",
")"
] | 56443211b3e1200f3def79173a21e0232332ae17 |
train | QueryManager.iter_size_changes | Yield an IssueSnapshot for each time the issue size changed | jira_metrics_extract/query.py | def iter_size_changes(self, issue):
"""Yield an IssueSnapshot for each time the issue size changed
"""
# Find the first size change, if any
try:
size_changes = list(filter(lambda h: h.field == 'Story Points',
itertools.chain.from_iterab... | def iter_size_changes(self, issue):
"""Yield an IssueSnapshot for each time the issue size changed
"""
# Find the first size change, if any
try:
size_changes = list(filter(lambda h: h.field == 'Story Points',
itertools.chain.from_iterab... | [
"Yield",
"an",
"IssueSnapshot",
"for",
"each",
"time",
"the",
"issue",
"size",
"changed"
] | rnwolf/jira-metrics-extract | python | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/query.py#L139-L183 | [
"def",
"iter_size_changes",
"(",
"self",
",",
"issue",
")",
":",
"# Find the first size change, if any",
"try",
":",
"size_changes",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"h",
":",
"h",
".",
"field",
"==",
"'Story Points'",
",",
"itertools",
".",
"chain",... | 56443211b3e1200f3def79173a21e0232332ae17 |
train | QueryManager.iter_changes | Yield an IssueSnapshot for each time the issue changed status or
resolution | jira_metrics_extract/query.py | def iter_changes(self, issue, include_resolution_changes=True):
"""Yield an IssueSnapshot for each time the issue changed status or
resolution
"""
is_resolved = False
# Find the first status change, if any
try:
status_changes = list(filter(
l... | def iter_changes(self, issue, include_resolution_changes=True):
"""Yield an IssueSnapshot for each time the issue changed status or
resolution
"""
is_resolved = False
# Find the first status change, if any
try:
status_changes = list(filter(
l... | [
"Yield",
"an",
"IssueSnapshot",
"for",
"each",
"time",
"the",
"issue",
"changed",
"status",
"or",
"resolution"
] | rnwolf/jira-metrics-extract | python | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/query.py#L187-L242 | [
"def",
"iter_changes",
"(",
"self",
",",
"issue",
",",
"include_resolution_changes",
"=",
"True",
")",
":",
"is_resolved",
"=",
"False",
"# Find the first status change, if any",
"try",
":",
"status_changes",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"h",
":",
... | 56443211b3e1200f3def79173a21e0232332ae17 |
train | QueryManager.find_issues | Return a list of issues with changelog metadata.
Searches for the `issue_types`, `project`, `valid_resolutions` and
'jql_filter' set in the passed-in `criteria` object.
Pass a JQL string to further qualify the query results. | jira_metrics_extract/query.py | def find_issues(self, criteria={}, jql=None, order='KEY ASC', verbose=False, changelog=True):
"""Return a list of issues with changelog metadata.
Searches for the `issue_types`, `project`, `valid_resolutions` and
'jql_filter' set in the passed-in `criteria` object.
Pass a JQL string to... | def find_issues(self, criteria={}, jql=None, order='KEY ASC', verbose=False, changelog=True):
"""Return a list of issues with changelog metadata.
Searches for the `issue_types`, `project`, `valid_resolutions` and
'jql_filter' set in the passed-in `criteria` object.
Pass a JQL string to... | [
"Return",
"a",
"list",
"of",
"issues",
"with",
"changelog",
"metadata",
"."
] | rnwolf/jira-metrics-extract | python | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/query.py#L246-L300 | [
"def",
"find_issues",
"(",
"self",
",",
"criteria",
"=",
"{",
"}",
",",
"jql",
"=",
"None",
",",
"order",
"=",
"'KEY ASC'",
",",
"verbose",
"=",
"False",
",",
"changelog",
"=",
"True",
")",
":",
"query",
"=",
"[",
"]",
"if",
"criteria",
".",
"get",... | 56443211b3e1200f3def79173a21e0232332ae17 |
train | CatalogDataView.list_catalogs | Lists existing catalogs respect to ui view template format | zengine/views/catalog_datas.py | def list_catalogs(self):
"""
Lists existing catalogs respect to ui view template format
"""
_form = CatalogSelectForm(current=self.current)
_form.set_choices_of('catalog', [(i, i) for i in fixture_bucket.get_keys()])
self.form_out(_form) | def list_catalogs(self):
"""
Lists existing catalogs respect to ui view template format
"""
_form = CatalogSelectForm(current=self.current)
_form.set_choices_of('catalog', [(i, i) for i in fixture_bucket.get_keys()])
self.form_out(_form) | [
"Lists",
"existing",
"catalogs",
"respect",
"to",
"ui",
"view",
"template",
"format"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/catalog_datas.py#L63-L69 | [
"def",
"list_catalogs",
"(",
"self",
")",
":",
"_form",
"=",
"CatalogSelectForm",
"(",
"current",
"=",
"self",
".",
"current",
")",
"_form",
".",
"set_choices_of",
"(",
"'catalog'",
",",
"[",
"(",
"i",
",",
"i",
")",
"for",
"i",
"in",
"fixture_bucket",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | CatalogDataView.get_catalog | Get existing catalog and fill the form with the model data.
If given key not found as catalog, it generates an empty catalog data form. | zengine/views/catalog_datas.py | def get_catalog(self):
"""
Get existing catalog and fill the form with the model data.
If given key not found as catalog, it generates an empty catalog data form.
"""
catalog_data = fixture_bucket.get(self.input['form']['catalog'])
# define add or edit based on catalog ... | def get_catalog(self):
"""
Get existing catalog and fill the form with the model data.
If given key not found as catalog, it generates an empty catalog data form.
"""
catalog_data = fixture_bucket.get(self.input['form']['catalog'])
# define add or edit based on catalog ... | [
"Get",
"existing",
"catalog",
"and",
"fill",
"the",
"form",
"with",
"the",
"model",
"data",
".",
"If",
"given",
"key",
"not",
"found",
"as",
"catalog",
"it",
"generates",
"an",
"empty",
"catalog",
"data",
"form",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/catalog_datas.py#L71-L103 | [
"def",
"get_catalog",
"(",
"self",
")",
":",
"catalog_data",
"=",
"fixture_bucket",
".",
"get",
"(",
"self",
".",
"input",
"[",
"'form'",
"]",
"[",
"'catalog'",
"]",
")",
"# define add or edit based on catalog data exists",
"add_or_edit",
"=",
"\"Edit\"",
"if",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | CatalogDataView.save_catalog | Saves the catalog data to given key
Cancels if the cmd is cancel
Notifies user with the process. | zengine/views/catalog_datas.py | def save_catalog(self):
"""
Saves the catalog data to given key
Cancels if the cmd is cancel
Notifies user with the process.
"""
if self.input["cmd"] == 'save_catalog':
try:
edited_object = dict()
for i in self.input["form"]["Ca... | def save_catalog(self):
"""
Saves the catalog data to given key
Cancels if the cmd is cancel
Notifies user with the process.
"""
if self.input["cmd"] == 'save_catalog':
try:
edited_object = dict()
for i in self.input["form"]["Ca... | [
"Saves",
"the",
"catalog",
"data",
"to",
"given",
"key",
"Cancels",
"if",
"the",
"cmd",
"is",
"cancel",
"Notifies",
"user",
"with",
"the",
"process",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/catalog_datas.py#L105-L127 | [
"def",
"save_catalog",
"(",
"self",
")",
":",
"if",
"self",
".",
"input",
"[",
"\"cmd\"",
"]",
"==",
"'save_catalog'",
":",
"try",
":",
"edited_object",
"=",
"dict",
"(",
")",
"for",
"i",
"in",
"self",
".",
"input",
"[",
"\"form\"",
"]",
"[",
"\"Cata... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | date_to_solr | converts DD-MM-YYYY to YYYY-MM-DDT00:00:00Z | zengine/lib/utils.py | def date_to_solr(d):
""" converts DD-MM-YYYY to YYYY-MM-DDT00:00:00Z"""
return "{y}-{m}-{day}T00:00:00Z".format(day=d[:2], m=d[3:5], y=d[6:]) if d else d | def date_to_solr(d):
""" converts DD-MM-YYYY to YYYY-MM-DDT00:00:00Z"""
return "{y}-{m}-{day}T00:00:00Z".format(day=d[:2], m=d[3:5], y=d[6:]) if d else d | [
"converts",
"DD",
"-",
"MM",
"-",
"YYYY",
"to",
"YYYY",
"-",
"MM",
"-",
"DDT00",
":",
"00",
":",
"00Z"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/utils.py#L19-L21 | [
"def",
"date_to_solr",
"(",
"d",
")",
":",
"return",
"\"{y}-{m}-{day}T00:00:00Z\"",
".",
"format",
"(",
"day",
"=",
"d",
"[",
":",
"2",
"]",
",",
"m",
"=",
"d",
"[",
"3",
":",
"5",
"]",
",",
"y",
"=",
"d",
"[",
"6",
":",
"]",
")",
"if",
"d",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | solr_to_date | converts YYYY-MM-DDT00:00:00Z to DD-MM-YYYY | zengine/lib/utils.py | def solr_to_date(d):
""" converts YYYY-MM-DDT00:00:00Z to DD-MM-YYYY """
return "{day}:{m}:{y}".format(y=d[:4], m=d[5:7], day=d[8:10]) if d else d | def solr_to_date(d):
""" converts YYYY-MM-DDT00:00:00Z to DD-MM-YYYY """
return "{day}:{m}:{y}".format(y=d[:4], m=d[5:7], day=d[8:10]) if d else d | [
"converts",
"YYYY",
"-",
"MM",
"-",
"DDT00",
":",
"00",
":",
"00Z",
"to",
"DD",
"-",
"MM",
"-",
"YYYY"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/utils.py#L24-L26 | [
"def",
"solr_to_date",
"(",
"d",
")",
":",
"return",
"\"{day}:{m}:{y}\"",
".",
"format",
"(",
"y",
"=",
"d",
"[",
":",
"4",
"]",
",",
"m",
"=",
"d",
"[",
"5",
":",
"7",
"]",
",",
"day",
"=",
"d",
"[",
"8",
":",
"10",
"]",
")",
"if",
"d",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | to_safe_str | converts some (tr) non-ascii chars to ascii counterparts,
then return the result as lowercase | zengine/lib/utils.py | def to_safe_str(s):
"""
converts some (tr) non-ascii chars to ascii counterparts,
then return the result as lowercase
"""
# TODO: This is insufficient as it doesn't do anything for other non-ascii chars
return re.sub(r'[^0-9a-zA-Z]+', '_', s.strip().replace(u'ğ', 'g').replace(u'ö', 'o').replace(... | def to_safe_str(s):
"""
converts some (tr) non-ascii chars to ascii counterparts,
then return the result as lowercase
"""
# TODO: This is insufficient as it doesn't do anything for other non-ascii chars
return re.sub(r'[^0-9a-zA-Z]+', '_', s.strip().replace(u'ğ', 'g').replace(u'ö', 'o').replace(... | [
"converts",
"some",
"(",
"tr",
")",
"non",
"-",
"ascii",
"chars",
"to",
"ascii",
"counterparts",
"then",
"return",
"the",
"result",
"as",
"lowercase"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/utils.py#L34-L43 | [
"def",
"to_safe_str",
"(",
"s",
")",
":",
"# TODO: This is insufficient as it doesn't do anything for other non-ascii chars",
"return",
"re",
".",
"sub",
"(",
"r'[^0-9a-zA-Z]+'",
",",
"'_'",
",",
"s",
".",
"strip",
"(",
")",
".",
"replace",
"(",
"u'ğ',",
" ",
"g')... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | merge_truthy | Merge multiple dictionaries, keeping the truthy values in case of key collisions.
Accepts any number of dictionaries, or any other object that returns a 2-tuple of
key and value pairs when its `.items()` method is called.
If a key exists in multiple dictionaries passed to this function, the values from th... | zengine/lib/utils.py | def merge_truthy(*dicts):
"""Merge multiple dictionaries, keeping the truthy values in case of key collisions.
Accepts any number of dictionaries, or any other object that returns a 2-tuple of
key and value pairs when its `.items()` method is called.
If a key exists in multiple dictionaries passed to ... | def merge_truthy(*dicts):
"""Merge multiple dictionaries, keeping the truthy values in case of key collisions.
Accepts any number of dictionaries, or any other object that returns a 2-tuple of
key and value pairs when its `.items()` method is called.
If a key exists in multiple dictionaries passed to ... | [
"Merge",
"multiple",
"dictionaries",
"keeping",
"the",
"truthy",
"values",
"in",
"case",
"of",
"key",
"collisions",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/utils.py#L46-L63 | [
"def",
"merge_truthy",
"(",
"*",
"dicts",
")",
":",
"merged",
"=",
"{",
"}",
"for",
"d",
"in",
"dicts",
":",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"merged",
"[",
"k",
"]",
"=",
"v",
"or",
"merged",
".",
"get",
"(",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | VersionRunner.perform | Perform the version upgrade on the database. | marabunta/runner.py | def perform(self):
"""Perform the version upgrade on the database.
"""
db_versions = self.table.versions()
version = self.version
if (version.is_processed(db_versions) and
not self.config.force_version == self.version.number):
self.log(
... | def perform(self):
"""Perform the version upgrade on the database.
"""
db_versions = self.table.versions()
version = self.version
if (version.is_processed(db_versions) and
not self.config.force_version == self.version.number):
self.log(
... | [
"Perform",
"the",
"version",
"upgrade",
"on",
"the",
"database",
"."
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/runner.py#L154-L178 | [
"def",
"perform",
"(",
"self",
")",
":",
"db_versions",
"=",
"self",
".",
"table",
".",
"versions",
"(",
")",
"version",
"=",
"self",
".",
"version",
"if",
"(",
"version",
".",
"is_processed",
"(",
"db_versions",
")",
"and",
"not",
"self",
".",
"config... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | VersionRunner._perform_version | Inner method for version upgrade.
Not intended for standalone use. This method performs the actual
version upgrade with all the pre, post operations and addons upgrades.
:param version: The migration version to upgrade to
:type version: Instance of Version class | marabunta/runner.py | def _perform_version(self, version):
"""Inner method for version upgrade.
Not intended for standalone use. This method performs the actual
version upgrade with all the pre, post operations and addons upgrades.
:param version: The migration version to upgrade to
:type version: I... | def _perform_version(self, version):
"""Inner method for version upgrade.
Not intended for standalone use. This method performs the actual
version upgrade with all the pre, post operations and addons upgrades.
:param version: The migration version to upgrade to
:type version: I... | [
"Inner",
"method",
"for",
"version",
"upgrade",
"."
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/runner.py#L180-L208 | [
"def",
"_perform_version",
"(",
"self",
",",
"version",
")",
":",
"if",
"version",
".",
"is_noop",
"(",
")",
":",
"self",
".",
"log",
"(",
"u'version {} is a noop'",
".",
"format",
"(",
"version",
".",
"number",
")",
")",
"else",
":",
"self",
".",
"log... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | logout | Log out view.
Simply deletes the session object.
For showing logout message:
'show_logout_message' field should be True in current.task_data,
Message should be sent in current.task_data with 'logout_message' field.
Message title should be sent in current.task_data with 'logout_title' fie... | zengine/views/auth.py | def logout(current):
"""
Log out view.
Simply deletes the session object.
For showing logout message:
'show_logout_message' field should be True in current.task_data,
Message should be sent in current.task_data with 'logout_message' field.
Message title should be sent in current.... | def logout(current):
"""
Log out view.
Simply deletes the session object.
For showing logout message:
'show_logout_message' field should be True in current.task_data,
Message should be sent in current.task_data with 'logout_message' field.
Message title should be sent in current.... | [
"Log",
"out",
"view",
".",
"Simply",
"deletes",
"the",
"session",
"object",
".",
"For",
"showing",
"logout",
"message",
":",
"show_logout_message",
"field",
"should",
"be",
"True",
"in",
"current",
".",
"task_data",
"Message",
"should",
"be",
"sent",
"in",
"... | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/auth.py#L29-L50 | [
"def",
"logout",
"(",
"current",
")",
":",
"current",
".",
"user",
".",
"is_online",
"(",
"False",
")",
"current",
".",
"session",
".",
"delete",
"(",
")",
"current",
".",
"output",
"[",
"'cmd'",
"]",
"=",
"'logout'",
"if",
"current",
".",
"task_data",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Login._do_upgrade | open websocket connection | zengine/views/auth.py | def _do_upgrade(self):
""" open websocket connection """
self.current.output['cmd'] = 'upgrade'
self.current.output['user_id'] = self.current.user_id
self.terminate_existing_login()
self.current.user.bind_private_channel(self.current.session.sess_id)
user_sess = UserSessi... | def _do_upgrade(self):
""" open websocket connection """
self.current.output['cmd'] = 'upgrade'
self.current.output['user_id'] = self.current.user_id
self.terminate_existing_login()
self.current.user.bind_private_channel(self.current.session.sess_id)
user_sess = UserSessi... | [
"open",
"websocket",
"connection"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/auth.py#L73-L84 | [
"def",
"_do_upgrade",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"output",
"[",
"'cmd'",
"]",
"=",
"'upgrade'",
"self",
".",
"current",
".",
"output",
"[",
"'user_id'",
"]",
"=",
"self",
".",
"current",
".",
"user_id",
"self",
".",
"terminate_... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Login.do_view | Authenticate user with given credentials.
Connects user's queue and exchange | zengine/views/auth.py | def do_view(self):
"""
Authenticate user with given credentials.
Connects user's queue and exchange
"""
self.current.output['login_process'] = True
self.current.task_data['login_successful'] = False
if self.current.is_auth:
self._do_upgrade()
e... | def do_view(self):
"""
Authenticate user with given credentials.
Connects user's queue and exchange
"""
self.current.output['login_process'] = True
self.current.task_data['login_successful'] = False
if self.current.is_auth:
self._do_upgrade()
e... | [
"Authenticate",
"user",
"with",
"given",
"credentials",
".",
"Connects",
"user",
"s",
"queue",
"and",
"exchange"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/auth.py#L96-L121 | [
"def",
"do_view",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"output",
"[",
"'login_process'",
"]",
"=",
"True",
"self",
".",
"current",
".",
"task_data",
"[",
"'login_successful'",
"]",
"=",
"False",
"if",
"self",
".",
"current",
".",
"is_auth"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Login.show_view | Show :attr:`LoginForm` form. | zengine/views/auth.py | def show_view(self):
"""
Show :attr:`LoginForm` form.
"""
self.current.output['login_process'] = True
if self.current.is_auth:
self._do_upgrade()
else:
self.current.output['forms'] = LoginForm(current=self.current).serialize() | def show_view(self):
"""
Show :attr:`LoginForm` form.
"""
self.current.output['login_process'] = True
if self.current.is_auth:
self._do_upgrade()
else:
self.current.output['forms'] = LoginForm(current=self.current).serialize() | [
"Show",
":",
"attr",
":",
"LoginForm",
"form",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/auth.py#L123-L131 | [
"def",
"show_view",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"output",
"[",
"'login_process'",
"]",
"=",
"True",
"if",
"self",
".",
"current",
".",
"is_auth",
":",
"self",
".",
"_do_upgrade",
"(",
")",
"else",
":",
"self",
".",
"current",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | skip | :param mapping: generator
:return: filtered generator | CGRtools/reactor.py | def skip(mapping):
"""
:param mapping: generator
:return: filtered generator
"""
found = set()
for m in mapping:
matched_atoms = set(m.values())
if found.intersection(matched_atoms):
continue
found.update(matched_atoms)
yield m | def skip(mapping):
"""
:param mapping: generator
:return: filtered generator
"""
found = set()
for m in mapping:
matched_atoms = set(m.values())
if found.intersection(matched_atoms):
continue
found.update(matched_atoms)
yield m | [
":",
"param",
"mapping",
":",
"generator",
":",
"return",
":",
"filtered",
"generator"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/reactor.py#L333-L344 | [
"def",
"skip",
"(",
"mapping",
")",
":",
"found",
"=",
"set",
"(",
")",
"for",
"m",
"in",
"mapping",
":",
"matched_atoms",
"=",
"set",
"(",
"m",
".",
"values",
"(",
")",
")",
"if",
"found",
".",
"intersection",
"(",
"matched_atoms",
")",
":",
"cont... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | Reactor.__get_mapping | match each pattern to each molecule.
if all patterns matches with all molecules
return generator of all possible mapping.
:param structures: disjoint molecules
:return: mapping generator | CGRtools/reactor.py | def __get_mapping(self, structures):
"""
match each pattern to each molecule.
if all patterns matches with all molecules
return generator of all possible mapping.
:param structures: disjoint molecules
:return: mapping generator
"""
for c in permutations(s... | def __get_mapping(self, structures):
"""
match each pattern to each molecule.
if all patterns matches with all molecules
return generator of all possible mapping.
:param structures: disjoint molecules
:return: mapping generator
"""
for c in permutations(s... | [
"match",
"each",
"pattern",
"to",
"each",
"molecule",
".",
"if",
"all",
"patterns",
"matches",
"with",
"all",
"molecules",
"return",
"generator",
"of",
"all",
"possible",
"mapping",
"."
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/reactor.py#L300-L315 | [
"def",
"__get_mapping",
"(",
"self",
",",
"structures",
")",
":",
"for",
"c",
"in",
"permutations",
"(",
"structures",
",",
"len",
"(",
"self",
".",
"__patterns",
")",
")",
":",
"for",
"m",
"in",
"product",
"(",
"*",
"(",
"x",
".",
"get_substructure_ma... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | Cache.get | return the cached value or default if it can't be found
:param default: default value
:return: cached value | zengine/lib/cache.py | def get(self, default=None):
"""
return the cached value or default if it can't be found
:param default: default value
:return: cached value
"""
d = cache.get(self.key)
return ((json.loads(d.decode('utf-8')) if self.serialize else d)
if d is not N... | def get(self, default=None):
"""
return the cached value or default if it can't be found
:param default: default value
:return: cached value
"""
d = cache.get(self.key)
return ((json.loads(d.decode('utf-8')) if self.serialize else d)
if d is not N... | [
"return",
"the",
"cached",
"value",
"or",
"default",
"if",
"it",
"can",
"t",
"be",
"found"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L79-L89 | [
"def",
"get",
"(",
"self",
",",
"default",
"=",
"None",
")",
":",
"d",
"=",
"cache",
".",
"get",
"(",
"self",
".",
"key",
")",
"return",
"(",
"(",
"json",
".",
"loads",
"(",
"d",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"if",
"self",
".",
"se... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Cache.set | set cache value
:param val: any picklable object
:param lifetime: exprition time in sec
:return: val | zengine/lib/cache.py | def set(self, val, lifetime=None):
"""
set cache value
:param val: any picklable object
:param lifetime: exprition time in sec
:return: val
"""
cache.set(self.key,
(json.dumps(val) if self.serialize else val),
lifetime or setti... | def set(self, val, lifetime=None):
"""
set cache value
:param val: any picklable object
:param lifetime: exprition time in sec
:return: val
"""
cache.set(self.key,
(json.dumps(val) if self.serialize else val),
lifetime or setti... | [
"set",
"cache",
"value"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L91-L102 | [
"def",
"set",
"(",
"self",
",",
"val",
",",
"lifetime",
"=",
"None",
")",
":",
"cache",
".",
"set",
"(",
"self",
".",
"key",
",",
"(",
"json",
".",
"dumps",
"(",
"val",
")",
"if",
"self",
".",
"serialize",
"else",
"val",
")",
",",
"lifetime",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Cache.add | Add given value to item (list)
Args:
val: A JSON serializable object.
Returns:
Cache backend response. | zengine/lib/cache.py | def add(self, val):
"""
Add given value to item (list)
Args:
val: A JSON serializable object.
Returns:
Cache backend response.
"""
return cache.lpush(self.key, json.dumps(val) if self.serialize else val) | def add(self, val):
"""
Add given value to item (list)
Args:
val: A JSON serializable object.
Returns:
Cache backend response.
"""
return cache.lpush(self.key, json.dumps(val) if self.serialize else val) | [
"Add",
"given",
"value",
"to",
"item",
"(",
"list",
")"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L143-L153 | [
"def",
"add",
"(",
"self",
",",
"val",
")",
":",
"return",
"cache",
".",
"lpush",
"(",
"self",
".",
"key",
",",
"json",
".",
"dumps",
"(",
"val",
")",
"if",
"self",
".",
"serialize",
"else",
"val",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Cache.get_all | Get all list items.
Returns:
Cache backend response. | zengine/lib/cache.py | def get_all(self):
"""
Get all list items.
Returns:
Cache backend response.
"""
result = cache.lrange(self.key, 0, -1)
return (json.loads(item.decode('utf-8')) for item in result if
item) if self.serialize else result | def get_all(self):
"""
Get all list items.
Returns:
Cache backend response.
"""
result = cache.lrange(self.key, 0, -1)
return (json.loads(item.decode('utf-8')) for item in result if
item) if self.serialize else result | [
"Get",
"all",
"list",
"items",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L155-L164 | [
"def",
"get_all",
"(",
"self",
")",
":",
"result",
"=",
"cache",
".",
"lrange",
"(",
"self",
".",
"key",
",",
"0",
",",
"-",
"1",
")",
"return",
"(",
"json",
".",
"loads",
"(",
"item",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"for",
"item",
"in... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Cache.remove_item | Removes given item from the list.
Args:
val: Item
Returns:
Cache backend response. | zengine/lib/cache.py | def remove_item(self, val):
"""
Removes given item from the list.
Args:
val: Item
Returns:
Cache backend response.
"""
return cache.lrem(self.key, json.dumps(val)) | def remove_item(self, val):
"""
Removes given item from the list.
Args:
val: Item
Returns:
Cache backend response.
"""
return cache.lrem(self.key, json.dumps(val)) | [
"Removes",
"given",
"item",
"from",
"the",
"list",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L175-L185 | [
"def",
"remove_item",
"(",
"self",
",",
"val",
")",
":",
"return",
"cache",
".",
"lrem",
"(",
"self",
".",
"key",
",",
"json",
".",
"dumps",
"(",
"val",
")",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Cache.flush | Removes all keys of this namespace
Without args, clears all keys starting with cls.PREFIX
if called with args, clears keys starting with given cls.PREFIX + args
Args:
*args: Arbitrary number of arguments.
Returns:
List of removed keys. | zengine/lib/cache.py | def flush(cls, *args):
"""
Removes all keys of this namespace
Without args, clears all keys starting with cls.PREFIX
if called with args, clears keys starting with given cls.PREFIX + args
Args:
*args: Arbitrary number of arguments.
Returns:
List ... | def flush(cls, *args):
"""
Removes all keys of this namespace
Without args, clears all keys starting with cls.PREFIX
if called with args, clears keys starting with given cls.PREFIX + args
Args:
*args: Arbitrary number of arguments.
Returns:
List ... | [
"Removes",
"all",
"keys",
"of",
"this",
"namespace",
"Without",
"args",
"clears",
"all",
"keys",
"starting",
"with",
"cls",
".",
"PREFIX",
"if",
"called",
"with",
"args",
"clears",
"keys",
"starting",
"with",
"given",
"cls",
".",
"PREFIX",
"+",
"args"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L188-L200 | [
"def",
"flush",
"(",
"cls",
",",
"*",
"args",
")",
":",
"return",
"_remove_keys",
"(",
"[",
"]",
",",
"[",
"(",
"cls",
".",
"_make_key",
"(",
"args",
")",
"if",
"args",
"else",
"cls",
".",
"PREFIX",
")",
"+",
"'*'",
"]",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | KeepAlive.update_or_expire_session | Deletes session if keepalive request expired
otherwise updates the keepalive timestamp value | zengine/lib/cache.py | def update_or_expire_session(self):
"""
Deletes session if keepalive request expired
otherwise updates the keepalive timestamp value
"""
if not hasattr(self, 'key'):
return
now = time.time()
timestamp = float(self.get() or 0) or now
sess_id = s... | def update_or_expire_session(self):
"""
Deletes session if keepalive request expired
otherwise updates the keepalive timestamp value
"""
if not hasattr(self, 'key'):
return
now = time.time()
timestamp = float(self.get() or 0) or now
sess_id = s... | [
"Deletes",
"session",
"if",
"keepalive",
"request",
"expired",
"otherwise",
"updates",
"the",
"keepalive",
"timestamp",
"value"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L250-L265 | [
"def",
"update_or_expire_session",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'key'",
")",
":",
"return",
"now",
"=",
"time",
".",
"time",
"(",
")",
"timestamp",
"=",
"float",
"(",
"self",
".",
"get",
"(",
")",
"or",
"0",
")"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | send_message_for_lane_change | Sends a message to possible owners of the current workflows
next lane.
Args:
**kwargs: ``current`` and ``possible_owners`` are required.
sender (User): User object | zengine/receivers.py | def send_message_for_lane_change(sender, **kwargs):
"""
Sends a message to possible owners of the current workflows
next lane.
Args:
**kwargs: ``current`` and ``possible_owners`` are required.
sender (User): User object
"""
current = kwargs['current']
owners = kwargs['possi... | def send_message_for_lane_change(sender, **kwargs):
"""
Sends a message to possible owners of the current workflows
next lane.
Args:
**kwargs: ``current`` and ``possible_owners`` are required.
sender (User): User object
"""
current = kwargs['current']
owners = kwargs['possi... | [
"Sends",
"a",
"message",
"to",
"possible",
"owners",
"of",
"the",
"current",
"workflows",
"next",
"lane",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/receivers.py#L29-L73 | [
"def",
"send_message_for_lane_change",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"current",
"=",
"kwargs",
"[",
"'current'",
"]",
"owners",
"=",
"kwargs",
"[",
"'possible_owners'",
"]",
"if",
"'lane_change_invite'",
"in",
"current",
".",
"task_data",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | set_password | Encrypts password of the user. | zengine/receivers.py | def set_password(sender, **kwargs):
"""
Encrypts password of the user.
"""
if sender.model_class.__name__ == 'User':
usr = kwargs['object']
if not usr.password.startswith('$pbkdf2'):
usr.set_password(usr.password)
usr.save() | def set_password(sender, **kwargs):
"""
Encrypts password of the user.
"""
if sender.model_class.__name__ == 'User':
usr = kwargs['object']
if not usr.password.startswith('$pbkdf2'):
usr.set_password(usr.password)
usr.save() | [
"Encrypts",
"password",
"of",
"the",
"user",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/receivers.py#L78-L86 | [
"def",
"set_password",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"sender",
".",
"model_class",
".",
"__name__",
"==",
"'User'",
":",
"usr",
"=",
"kwargs",
"[",
"'object'",
"]",
"if",
"not",
"usr",
".",
"password",
".",
"startswith",
"(",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.channel_list | Main screen for channel management.
Channels listed and operations can be chosen on the screen.
If there is an error message like non-choice,
it is shown here. | zengine/views/channel_management.py | def channel_list(self):
"""
Main screen for channel management.
Channels listed and operations can be chosen on the screen.
If there is an error message like non-choice,
it is shown here.
"""
if self.current.task_data.get('msg', False):
if self.curre... | def channel_list(self):
"""
Main screen for channel management.
Channels listed and operations can be chosen on the screen.
If there is an error message like non-choice,
it is shown here.
"""
if self.current.task_data.get('msg', False):
if self.curre... | [
"Main",
"screen",
"for",
"channel",
"management",
".",
"Channels",
"listed",
"and",
"operations",
"can",
"be",
"chosen",
"on",
"the",
"screen",
".",
"If",
"there",
"is",
"an",
"error",
"message",
"like",
"non",
"-",
"choice",
"it",
"is",
"shown",
"here",
... | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L57-L86 | [
"def",
"channel_list",
"(",
"self",
")",
":",
"if",
"self",
".",
"current",
".",
"task_data",
".",
"get",
"(",
"'msg'",
",",
"False",
")",
":",
"if",
"self",
".",
"current",
".",
"task_data",
".",
"get",
"(",
"'target_channel_key'",
",",
"False",
")",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.channel_choice_control | It controls errors. If there is an error,
returns channel list screen with error message. | zengine/views/channel_management.py | def channel_choice_control(self):
"""
It controls errors. If there is an error,
returns channel list screen with error message.
"""
self.current.task_data['control'], self.current.task_data['msg'] \
= self.selection_error_control(self.input['form'])
if self.cu... | def channel_choice_control(self):
"""
It controls errors. If there is an error,
returns channel list screen with error message.
"""
self.current.task_data['control'], self.current.task_data['msg'] \
= self.selection_error_control(self.input['form'])
if self.cu... | [
"It",
"controls",
"errors",
".",
"If",
"there",
"is",
"an",
"error",
"returns",
"channel",
"list",
"screen",
"with",
"error",
"message",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L88-L100 | [
"def",
"channel_choice_control",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_data",
"[",
"'control'",
"]",
",",
"self",
".",
"current",
".",
"task_data",
"[",
"'msg'",
"]",
"=",
"self",
".",
"selection_error_control",
"(",
"self",
".",
"input... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.create_new_channel | Features of new channel are specified like channel's name, owner etc. | zengine/views/channel_management.py | def create_new_channel(self):
"""
Features of new channel are specified like channel's name, owner etc.
"""
self.current.task_data['new_channel'] = True
_form = NewChannelForm(Channel(), current=self.current)
_form.title = _(u"Specify Features of New Channel to Create")
... | def create_new_channel(self):
"""
Features of new channel are specified like channel's name, owner etc.
"""
self.current.task_data['new_channel'] = True
_form = NewChannelForm(Channel(), current=self.current)
_form.title = _(u"Specify Features of New Channel to Create")
... | [
"Features",
"of",
"new",
"channel",
"are",
"specified",
"like",
"channel",
"s",
"name",
"owner",
"etc",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L102-L111 | [
"def",
"create_new_channel",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_data",
"[",
"'new_channel'",
"]",
"=",
"True",
"_form",
"=",
"NewChannelForm",
"(",
"Channel",
"(",
")",
",",
"current",
"=",
"self",
".",
"current",
")",
"_form",
"."... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.save_new_channel | It saves new channel according to specified channel features. | zengine/views/channel_management.py | def save_new_channel(self):
"""
It saves new channel according to specified channel features.
"""
form_info = self.input['form']
channel = Channel(typ=15, name=form_info['name'],
description=form_info['description'],
owner_id=f... | def save_new_channel(self):
"""
It saves new channel according to specified channel features.
"""
form_info = self.input['form']
channel = Channel(typ=15, name=form_info['name'],
description=form_info['description'],
owner_id=f... | [
"It",
"saves",
"new",
"channel",
"according",
"to",
"specified",
"channel",
"features",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L113-L123 | [
"def",
"save_new_channel",
"(",
"self",
")",
":",
"form_info",
"=",
"self",
".",
"input",
"[",
"'form'",
"]",
"channel",
"=",
"Channel",
"(",
"typ",
"=",
"15",
",",
"name",
"=",
"form_info",
"[",
"'name'",
"]",
",",
"description",
"=",
"form_info",
"["... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.choose_existing_channel | It is a channel choice list and chosen channels
at previous step shouldn't be on the screen. | zengine/views/channel_management.py | def choose_existing_channel(self):
"""
It is a channel choice list and chosen channels
at previous step shouldn't be on the screen.
"""
if self.current.task_data.get('msg', False):
self.show_warning_messages()
_form = ChannelListForm()
_form.title = ... | def choose_existing_channel(self):
"""
It is a channel choice list and chosen channels
at previous step shouldn't be on the screen.
"""
if self.current.task_data.get('msg', False):
self.show_warning_messages()
_form = ChannelListForm()
_form.title = ... | [
"It",
"is",
"a",
"channel",
"choice",
"list",
"and",
"chosen",
"channels",
"at",
"previous",
"step",
"shouldn",
"t",
"be",
"on",
"the",
"screen",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L125-L144 | [
"def",
"choose_existing_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"current",
".",
"task_data",
".",
"get",
"(",
"'msg'",
",",
"False",
")",
":",
"self",
".",
"show_warning_messages",
"(",
")",
"_form",
"=",
"ChannelListForm",
"(",
")",
"_form",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.existing_choice_control | It controls errors. It generates an error message
if zero or more than one channels are selected. | zengine/views/channel_management.py | def existing_choice_control(self):
"""
It controls errors. It generates an error message
if zero or more than one channels are selected.
"""
self.current.task_data['existing'] = False
self.current.task_data['msg'] = _(u"You should choose just one channel to do operation."... | def existing_choice_control(self):
"""
It controls errors. It generates an error message
if zero or more than one channels are selected.
"""
self.current.task_data['existing'] = False
self.current.task_data['msg'] = _(u"You should choose just one channel to do operation."... | [
"It",
"controls",
"errors",
".",
"It",
"generates",
"an",
"error",
"message",
"if",
"zero",
"or",
"more",
"than",
"one",
"channels",
"are",
"selected",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L146-L156 | [
"def",
"existing_choice_control",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_data",
"[",
"'existing'",
"]",
"=",
"False",
"self",
".",
"current",
".",
"task_data",
"[",
"'msg'",
"]",
"=",
"_",
"(",
"u\"You should choose just one channel to do oper... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.split_channel | A channel can be splitted to new channel or other existing channel.
It creates subscribers list as selectable to moved. | zengine/views/channel_management.py | def split_channel(self):
"""
A channel can be splitted to new channel or other existing channel.
It creates subscribers list as selectable to moved.
"""
if self.current.task_data.get('msg', False):
self.show_warning_messages()
self.current.task_data['split_o... | def split_channel(self):
"""
A channel can be splitted to new channel or other existing channel.
It creates subscribers list as selectable to moved.
"""
if self.current.task_data.get('msg', False):
self.show_warning_messages()
self.current.task_data['split_o... | [
"A",
"channel",
"can",
"be",
"splitted",
"to",
"new",
"channel",
"or",
"other",
"existing",
"channel",
".",
"It",
"creates",
"subscribers",
"list",
"as",
"selectable",
"to",
"moved",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L158-L179 | [
"def",
"split_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"current",
".",
"task_data",
".",
"get",
"(",
"'msg'",
",",
"False",
")",
":",
"self",
".",
"show_warning_messages",
"(",
")",
"self",
".",
"current",
".",
"task_data",
"[",
"'split_operat... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.subscriber_choice_control | It controls subscribers choice and generates
error message if there is a non-choice. | zengine/views/channel_management.py | def subscriber_choice_control(self):
"""
It controls subscribers choice and generates
error message if there is a non-choice.
"""
self.current.task_data['option'] = None
self.current.task_data['chosen_subscribers'], names = self.return_selected_form_items(
sel... | def subscriber_choice_control(self):
"""
It controls subscribers choice and generates
error message if there is a non-choice.
"""
self.current.task_data['option'] = None
self.current.task_data['chosen_subscribers'], names = self.return_selected_form_items(
sel... | [
"It",
"controls",
"subscribers",
"choice",
"and",
"generates",
"error",
"message",
"if",
"there",
"is",
"a",
"non",
"-",
"choice",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L181-L193 | [
"def",
"subscriber_choice_control",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_data",
"[",
"'option'",
"]",
"=",
"None",
"self",
".",
"current",
".",
"task_data",
"[",
"'chosen_subscribers'",
"]",
",",
"names",
"=",
"self",
".",
"return_select... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.move_complete_channel | Channels and theirs subscribers are moved
completely to new channel or existing channel. | zengine/views/channel_management.py | def move_complete_channel(self):
"""
Channels and theirs subscribers are moved
completely to new channel or existing channel.
"""
to_channel = Channel.objects.get(self.current.task_data['target_channel_key'])
chosen_channels = self.current.task_data['chosen_channels']
... | def move_complete_channel(self):
"""
Channels and theirs subscribers are moved
completely to new channel or existing channel.
"""
to_channel = Channel.objects.get(self.current.task_data['target_channel_key'])
chosen_channels = self.current.task_data['chosen_channels']
... | [
"Channels",
"and",
"theirs",
"subscribers",
"are",
"moved",
"completely",
"to",
"new",
"channel",
"or",
"existing",
"channel",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L195-L218 | [
"def",
"move_complete_channel",
"(",
"self",
")",
":",
"to_channel",
"=",
"Channel",
".",
"objects",
".",
"get",
"(",
"self",
".",
"current",
".",
"task_data",
"[",
"'target_channel_key'",
"]",
")",
"chosen_channels",
"=",
"self",
".",
"current",
".",
"task_... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.move_chosen_subscribers | After splitting operation, only chosen subscribers
are moved to new channel or existing channel. | zengine/views/channel_management.py | def move_chosen_subscribers(self):
"""
After splitting operation, only chosen subscribers
are moved to new channel or existing channel.
"""
from_channel = Channel.objects.get(self.current.task_data['chosen_channels'][0])
to_channel = Channel.objects.get(self.current.task_... | def move_chosen_subscribers(self):
"""
After splitting operation, only chosen subscribers
are moved to new channel or existing channel.
"""
from_channel = Channel.objects.get(self.current.task_data['chosen_channels'][0])
to_channel = Channel.objects.get(self.current.task_... | [
"After",
"splitting",
"operation",
"only",
"chosen",
"subscribers",
"are",
"moved",
"to",
"new",
"channel",
"or",
"existing",
"channel",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L220-L239 | [
"def",
"move_chosen_subscribers",
"(",
"self",
")",
":",
"from_channel",
"=",
"Channel",
".",
"objects",
".",
"get",
"(",
"self",
".",
"current",
".",
"task_data",
"[",
"'chosen_channels'",
"]",
"[",
"0",
"]",
")",
"to_channel",
"=",
"Channel",
".",
"objec... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.copy_and_move_messages | While splitting channel and moving chosen subscribers to new channel,
old channel's messages are copied and moved to new channel.
Args:
from_channel (Channel object): move messages from channel
to_channel (Channel object): move messages to channel | zengine/views/channel_management.py | def copy_and_move_messages(from_channel, to_channel):
"""
While splitting channel and moving chosen subscribers to new channel,
old channel's messages are copied and moved to new channel.
Args:
from_channel (Channel object): move messages from channel
to_chann... | def copy_and_move_messages(from_channel, to_channel):
"""
While splitting channel and moving chosen subscribers to new channel,
old channel's messages are copied and moved to new channel.
Args:
from_channel (Channel object): move messages from channel
to_chann... | [
"While",
"splitting",
"channel",
"and",
"moving",
"chosen",
"subscribers",
"to",
"new",
"channel",
"old",
"channel",
"s",
"messages",
"are",
"copied",
"and",
"moved",
"to",
"new",
"channel",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L242-L255 | [
"def",
"copy_and_move_messages",
"(",
"from_channel",
",",
"to_channel",
")",
":",
"with",
"BlockSave",
"(",
"Message",
",",
"query_dict",
"=",
"{",
"'channel_id'",
":",
"to_channel",
".",
"key",
"}",
")",
":",
"for",
"message",
"in",
"Message",
".",
"object... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.show_warning_messages | It shows incorrect operations or successful operation messages.
Args:
title (string): title of message box
box_type (string): type of message box (warning, info) | zengine/views/channel_management.py | def show_warning_messages(self, title=_(u"Incorrect Operation"), box_type='warning'):
"""
It shows incorrect operations or successful operation messages.
Args:
title (string): title of message box
box_type (string): type of message box (warning, info)
"""
... | def show_warning_messages(self, title=_(u"Incorrect Operation"), box_type='warning'):
"""
It shows incorrect operations or successful operation messages.
Args:
title (string): title of message box
box_type (string): type of message box (warning, info)
"""
... | [
"It",
"shows",
"incorrect",
"operations",
"or",
"successful",
"operation",
"messages",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L257-L267 | [
"def",
"show_warning_messages",
"(",
"self",
",",
"title",
"=",
"_",
"(",
"u\"Incorrect Operation\"",
")",
",",
"box_type",
"=",
"'warning'",
")",
":",
"msg",
"=",
"self",
".",
"current",
".",
"task_data",
"[",
"'msg'",
"]",
"self",
".",
"current",
".",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.return_selected_form_items | It returns chosen keys list from a given form.
Args:
form_info: serialized list of dict form data
Returns:
selected_keys(list): Chosen keys list
selected_names(list): Chosen channels' or subscribers' names. | zengine/views/channel_management.py | def return_selected_form_items(form_info):
"""
It returns chosen keys list from a given form.
Args:
form_info: serialized list of dict form data
Returns:
selected_keys(list): Chosen keys list
selected_names(list): Chosen channels' or subscribers' name... | def return_selected_form_items(form_info):
"""
It returns chosen keys list from a given form.
Args:
form_info: serialized list of dict form data
Returns:
selected_keys(list): Chosen keys list
selected_names(list): Chosen channels' or subscribers' name... | [
"It",
"returns",
"chosen",
"keys",
"list",
"from",
"a",
"given",
"form",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L270-L287 | [
"def",
"return_selected_form_items",
"(",
"form_info",
")",
":",
"selected_keys",
"=",
"[",
"]",
"selected_names",
"=",
"[",
"]",
"for",
"chosen",
"in",
"form_info",
":",
"if",
"chosen",
"[",
"'choice'",
"]",
":",
"selected_keys",
".",
"append",
"(",
"chosen... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ChannelManagement.selection_error_control | It controls the selection from the form according
to the operations, and returns an error message
if it does not comply with the rules.
Args:
form_info: Channel or subscriber form from the user
Returns: True or False
error message | zengine/views/channel_management.py | def selection_error_control(self, form_info):
"""
It controls the selection from the form according
to the operations, and returns an error message
if it does not comply with the rules.
Args:
form_info: Channel or subscriber form from the user
Returns: True ... | def selection_error_control(self, form_info):
"""
It controls the selection from the form according
to the operations, and returns an error message
if it does not comply with the rules.
Args:
form_info: Channel or subscriber form from the user
Returns: True ... | [
"It",
"controls",
"the",
"selection",
"from",
"the",
"form",
"according",
"to",
"the",
"operations",
"and",
"returns",
"an",
"error",
"message",
"if",
"it",
"does",
"not",
"comply",
"with",
"the",
"rules",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L289-L314 | [
"def",
"selection_error_control",
"(",
"self",
",",
"form_info",
")",
":",
"keys",
",",
"names",
"=",
"self",
".",
"return_selected_form_items",
"(",
"form_info",
"[",
"'ChannelList'",
"]",
")",
"chosen_channels_number",
"=",
"len",
"(",
"keys",
")",
"if",
"fo... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.