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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | Kron2SumCov.listen | Listen to parameters change.
Parameters
----------
func : callable
Function to be called when a parameter changes. | glimix_core/cov/_kron2sum.py | def listen(self, func):
"""
Listen to parameters change.
Parameters
----------
func : callable
Function to be called when a parameter changes.
"""
self._C0.listen(func)
self._C1.listen(func) | def listen(self, func):
"""
Listen to parameters change.
Parameters
----------
func : callable
Function to be called when a parameter changes.
"""
self._C0.listen(func)
self._C1.listen(func) | [
"Listen",
"to",
"parameters",
"change",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_kron2sum.py#L161-L171 | [
"def",
"listen",
"(",
"self",
",",
"func",
")",
":",
"self",
".",
"_C0",
".",
"listen",
"(",
"func",
")",
"self",
".",
"_C1",
".",
"listen",
"(",
"func",
")"
] | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2SumCov._LhD | Implements Lₕ and D.
Returns
-------
Lh : ndarray
Uₕᵀ S₁⁻½ U₁ᵀ.
D : ndarray
(Sₕ ⊗ Sₓ + Iₕₓ)⁻¹. | glimix_core/cov/_kron2sum.py | def _LhD(self):
"""
Implements Lₕ and D.
Returns
-------
Lh : ndarray
Uₕᵀ S₁⁻½ U₁ᵀ.
D : ndarray
(Sₕ ⊗ Sₓ + Iₕₓ)⁻¹.
"""
from numpy_sugar.linalg import ddot
self._init_svd()
if self._cache["LhD"] is not None:
... | def _LhD(self):
"""
Implements Lₕ and D.
Returns
-------
Lh : ndarray
Uₕᵀ S₁⁻½ U₁ᵀ.
D : ndarray
(Sₕ ⊗ Sₓ + Iₕₓ)⁻¹.
"""
from numpy_sugar.linalg import ddot
self._init_svd()
if self._cache["LhD"] is not None:
... | [
"Implements",
"Lₕ",
"and",
"D",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_kron2sum.py#L188-L212 | [
"def",
"_LhD",
"(",
"self",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"ddot",
"self",
".",
"_init_svd",
"(",
")",
"if",
"self",
".",
"_cache",
"[",
"\"LhD\"",
"]",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_cache",
"[",
"\"LhD... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2SumCov.value | Covariance matrix K = C₀ ⊗ GGᵀ + C₁ ⊗ I.
Returns
-------
K : ndarray
C₀ ⊗ GGᵀ + C₁ ⊗ I. | glimix_core/cov/_kron2sum.py | def value(self):
"""
Covariance matrix K = C₀ ⊗ GGᵀ + C₁ ⊗ I.
Returns
-------
K : ndarray
C₀ ⊗ GGᵀ + C₁ ⊗ I.
"""
C0 = self._C0.value()
C1 = self._C1.value()
return kron(C0, self._GG) + kron(C1, self._I) | def value(self):
"""
Covariance matrix K = C₀ ⊗ GGᵀ + C₁ ⊗ I.
Returns
-------
K : ndarray
C₀ ⊗ GGᵀ + C₁ ⊗ I.
"""
C0 = self._C0.value()
C1 = self._C1.value()
return kron(C0, self._GG) + kron(C1, self._I) | [
"Covariance",
"matrix",
"K",
"=",
"C₀",
"⊗",
"GGᵀ",
"+",
"C₁",
"⊗",
"I",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_kron2sum.py#L253-L264 | [
"def",
"value",
"(",
"self",
")",
":",
"C0",
"=",
"self",
".",
"_C0",
".",
"value",
"(",
")",
"C1",
"=",
"self",
".",
"_C1",
".",
"value",
"(",
")",
"return",
"kron",
"(",
"C0",
",",
"self",
".",
"_GG",
")",
"+",
"kron",
"(",
"C1",
",",
"se... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2SumCov.gradient | Gradient of K.
Returns
-------
C0 : ndarray
Derivative of C₀ over its parameters.
C1 : ndarray
Derivative of C₁ over its parameters. | glimix_core/cov/_kron2sum.py | def gradient(self):
"""
Gradient of K.
Returns
-------
C0 : ndarray
Derivative of C₀ over its parameters.
C1 : ndarray
Derivative of C₁ over its parameters.
"""
self._init_svd()
C0 = self._C0.gradient()["Lu"].T
C1 =... | def gradient(self):
"""
Gradient of K.
Returns
-------
C0 : ndarray
Derivative of C₀ over its parameters.
C1 : ndarray
Derivative of C₁ over its parameters.
"""
self._init_svd()
C0 = self._C0.gradient()["Lu"].T
C1 =... | [
"Gradient",
"of",
"K",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_kron2sum.py#L266-L281 | [
"def",
"gradient",
"(",
"self",
")",
":",
"self",
".",
"_init_svd",
"(",
")",
"C0",
"=",
"self",
".",
"_C0",
".",
"gradient",
"(",
")",
"[",
"\"Lu\"",
"]",
".",
"T",
"C1",
"=",
"self",
".",
"_C1",
".",
"gradient",
"(",
")",
"[",
"\"Lu\"",
"]",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2SumCov.gradient_dot | Implements ∂K⋅v.
Parameters
----------
v : array_like
Vector from ∂K⋅v.
Returns
-------
C0.Lu : ndarray
∂K⋅v, where the gradient is taken over the C₀ parameters.
C1.Lu : ndarray
∂K⋅v, where the gradient is taken over the C₁ pa... | glimix_core/cov/_kron2sum.py | def gradient_dot(self, v):
"""
Implements ∂K⋅v.
Parameters
----------
v : array_like
Vector from ∂K⋅v.
Returns
-------
C0.Lu : ndarray
∂K⋅v, where the gradient is taken over the C₀ parameters.
C1.Lu : ndarray
∂... | def gradient_dot(self, v):
"""
Implements ∂K⋅v.
Parameters
----------
v : array_like
Vector from ∂K⋅v.
Returns
-------
C0.Lu : ndarray
∂K⋅v, where the gradient is taken over the C₀ parameters.
C1.Lu : ndarray
∂... | [
"Implements",
"∂K⋅v",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_kron2sum.py#L283-L311 | [
"def",
"gradient_dot",
"(",
"self",
",",
"v",
")",
":",
"self",
".",
"_init_svd",
"(",
")",
"V",
"=",
"unvec",
"(",
"v",
",",
"(",
"self",
".",
"G",
".",
"shape",
"[",
"0",
"]",
",",
"-",
"1",
")",
"+",
"v",
".",
"shape",
"[",
"1",
":",
"... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2SumCov.solve | Implements the product K⁻¹⋅v.
Parameters
----------
v : array_like
Array to be multiplied.
Returns
-------
x : ndarray
Solution x to the equation K⋅x = y. | glimix_core/cov/_kron2sum.py | def solve(self, v):
"""
Implements the product K⁻¹⋅v.
Parameters
----------
v : array_like
Array to be multiplied.
Returns
-------
x : ndarray
Solution x to the equation K⋅x = y.
"""
from numpy_sugar.linalg import ... | def solve(self, v):
"""
Implements the product K⁻¹⋅v.
Parameters
----------
v : array_like
Array to be multiplied.
Returns
-------
x : ndarray
Solution x to the equation K⋅x = y.
"""
from numpy_sugar.linalg import ... | [
"Implements",
"the",
"product",
"K⁻¹⋅v",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_kron2sum.py#L313-L331 | [
"def",
"solve",
"(",
"self",
",",
"v",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"ddot",
"self",
".",
"_init_svd",
"(",
")",
"L",
"=",
"kron",
"(",
"self",
".",
"Lh",
",",
"self",
".",
"Lx",
")",
"return",
"L",
".",
"T",
"@",
"d... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2SumCov.logdet | Implements log|K| = - log|D| + n⋅log|C₁|.
Returns
-------
logdet : float
Log-determinant of K. | glimix_core/cov/_kron2sum.py | def logdet(self):
"""
Implements log|K| = - log|D| + n⋅log|C₁|.
Returns
-------
logdet : float
Log-determinant of K.
"""
self._init_svd()
return -log(self._De).sum() + self.G.shape[0] * self.C1.logdet() | def logdet(self):
"""
Implements log|K| = - log|D| + n⋅log|C₁|.
Returns
-------
logdet : float
Log-determinant of K.
"""
self._init_svd()
return -log(self._De).sum() + self.G.shape[0] * self.C1.logdet() | [
"Implements",
"log|K|",
"=",
"-",
"log|D|",
"+",
"n⋅log|C₁|",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_kron2sum.py#L333-L343 | [
"def",
"logdet",
"(",
"self",
")",
":",
"self",
".",
"_init_svd",
"(",
")",
"return",
"-",
"log",
"(",
"self",
".",
"_De",
")",
".",
"sum",
"(",
")",
"+",
"self",
".",
"G",
".",
"shape",
"[",
"0",
"]",
"*",
"self",
".",
"C1",
".",
"logdet",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2SumCov.logdet_gradient | Implements ∂log|K| = Tr[K⁻¹∂K].
It can be shown that::
∂log|K| = diag(D)ᵀdiag(L(∂K)Lᵀ) = diag(D)ᵀ(diag(Lₕ∂C₀Lₕᵀ)⊗diag(LₓGGᵀLₓᵀ)),
when the derivative is over the parameters of C₀. Similarly,
∂log|K| = diag(D)ᵀdiag(L(∂K)Lᵀ) = diag(D)ᵀ(diag(Lₕ∂C₁Lₕᵀ)⊗diag(I)),
over the... | glimix_core/cov/_kron2sum.py | def logdet_gradient(self):
"""
Implements ∂log|K| = Tr[K⁻¹∂K].
It can be shown that::
∂log|K| = diag(D)ᵀdiag(L(∂K)Lᵀ) = diag(D)ᵀ(diag(Lₕ∂C₀Lₕᵀ)⊗diag(LₓGGᵀLₓᵀ)),
when the derivative is over the parameters of C₀. Similarly,
∂log|K| = diag(D)ᵀdiag(L(∂K)Lᵀ) = diag... | def logdet_gradient(self):
"""
Implements ∂log|K| = Tr[K⁻¹∂K].
It can be shown that::
∂log|K| = diag(D)ᵀdiag(L(∂K)Lᵀ) = diag(D)ᵀ(diag(Lₕ∂C₀Lₕᵀ)⊗diag(LₓGGᵀLₓᵀ)),
when the derivative is over the parameters of C₀. Similarly,
∂log|K| = diag(D)ᵀdiag(L(∂K)Lᵀ) = diag... | [
"Implements",
"∂log|K|",
"=",
"Tr",
"[",
"K⁻¹∂K",
"]",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_kron2sum.py#L345-L386 | [
"def",
"logdet_gradient",
"(",
"self",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"dotd",
"self",
".",
"_init_svd",
"(",
")",
"dC0",
"=",
"self",
".",
"_C0",
".",
"gradient",
"(",
")",
"[",
"\"Lu\"",
"]",
"grad_C0",
"=",
"zeros_like",
"(... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2SumCov.LdKL_dot | Implements L(∂K)Lᵀv.
The array v can have one or two dimensions and the first dimension has to have
size n⋅p.
Let vec(V) = v. We have
L(∂K)Lᵀ⋅v = ((Lₕ∂C₀Lₕᵀ) ⊗ (LₓGGᵀLₓᵀ))vec(V) = vec(LₓGGᵀLₓᵀVLₕ∂C₀Lₕᵀ),
when the derivative is over the parameters of C₀. Similarly,
... | glimix_core/cov/_kron2sum.py | def LdKL_dot(self, v, v1=None):
"""
Implements L(∂K)Lᵀv.
The array v can have one or two dimensions and the first dimension has to have
size n⋅p.
Let vec(V) = v. We have
L(∂K)Lᵀ⋅v = ((Lₕ∂C₀Lₕᵀ) ⊗ (LₓGGᵀLₓᵀ))vec(V) = vec(LₓGGᵀLₓᵀVLₕ∂C₀Lₕᵀ),
when the derivat... | def LdKL_dot(self, v, v1=None):
"""
Implements L(∂K)Lᵀv.
The array v can have one or two dimensions and the first dimension has to have
size n⋅p.
Let vec(V) = v. We have
L(∂K)Lᵀ⋅v = ((Lₕ∂C₀Lₕᵀ) ⊗ (LₓGGᵀLₓᵀ))vec(V) = vec(LₓGGᵀLₓᵀVLₕ∂C₀Lₕᵀ),
when the derivat... | [
"Implements",
"L",
"(",
"∂K",
")",
"Lᵀv",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_kron2sum.py#L388-L430 | [
"def",
"LdKL_dot",
"(",
"self",
",",
"v",
",",
"v1",
"=",
"None",
")",
":",
"self",
".",
"_init_svd",
"(",
")",
"def",
"dot",
"(",
"a",
",",
"b",
")",
":",
"r",
"=",
"tensordot",
"(",
"a",
",",
"b",
",",
"axes",
"=",
"(",
"[",
"1",
"]",
"... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | rsolve | Robust solve Ax=y. | glimix_core/_util/solve.py | def rsolve(A, y):
"""
Robust solve Ax=y.
"""
from numpy_sugar.linalg import rsolve as _rsolve
try:
beta = _rsolve(A, y)
except LinAlgError:
msg = "Could not converge to solve Ax=y."
msg += " Setting x to zero."
warnings.warn(msg, RuntimeWarning)
beta = ze... | def rsolve(A, y):
"""
Robust solve Ax=y.
"""
from numpy_sugar.linalg import rsolve as _rsolve
try:
beta = _rsolve(A, y)
except LinAlgError:
msg = "Could not converge to solve Ax=y."
msg += " Setting x to zero."
warnings.warn(msg, RuntimeWarning)
beta = ze... | [
"Robust",
"solve",
"Ax",
"=",
"y",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/_util/solve.py#L37-L51 | [
"def",
"rsolve",
"(",
"A",
",",
"y",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"rsolve",
"as",
"_rsolve",
"try",
":",
"beta",
"=",
"_rsolve",
"(",
"A",
",",
"y",
")",
"except",
"LinAlgError",
":",
"msg",
"=",
"\"Could not converge to solv... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | multivariate_normal | Draw random samples from a multivariate normal distribution.
Parameters
----------
random : np.random.RandomState instance
Random state.
mean : array_like
Mean of the n-dimensional distribution.
cov : array_like
Covariance matrix of the distribution. It must be symmetric and... | glimix_core/_util/random.py | def multivariate_normal(random, mean, cov):
"""
Draw random samples from a multivariate normal distribution.
Parameters
----------
random : np.random.RandomState instance
Random state.
mean : array_like
Mean of the n-dimensional distribution.
cov : array_like
Covaria... | def multivariate_normal(random, mean, cov):
"""
Draw random samples from a multivariate normal distribution.
Parameters
----------
random : np.random.RandomState instance
Random state.
mean : array_like
Mean of the n-dimensional distribution.
cov : array_like
Covaria... | [
"Draw",
"random",
"samples",
"from",
"a",
"multivariate",
"normal",
"distribution",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/_util/random.py#L1-L23 | [
"def",
"multivariate_normal",
"(",
"random",
",",
"mean",
",",
"cov",
")",
":",
"from",
"numpy",
".",
"linalg",
"import",
"cholesky",
"L",
"=",
"cholesky",
"(",
"cov",
")",
"return",
"L",
"@",
"random",
".",
"randn",
"(",
"L",
".",
"shape",
"[",
"0",... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | SumCov.gradient | Sum of covariance function derivatives.
Returns
-------
dict
∂K₀ + ∂K₁ + ⋯ | glimix_core/cov/_sum.py | def gradient(self):
"""
Sum of covariance function derivatives.
Returns
-------
dict
∂K₀ + ∂K₁ + ⋯
"""
grad = {}
for i, f in enumerate(self._covariances):
for varname, g in f.gradient().items():
grad[f"{self._name}[... | def gradient(self):
"""
Sum of covariance function derivatives.
Returns
-------
dict
∂K₀ + ∂K₁ + ⋯
"""
grad = {}
for i, f in enumerate(self._covariances):
for varname, g in f.gradient().items():
grad[f"{self._name}[... | [
"Sum",
"of",
"covariance",
"function",
"derivatives",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_sum.py#L57-L70 | [
"def",
"gradient",
"(",
"self",
")",
":",
"grad",
"=",
"{",
"}",
"for",
"i",
",",
"f",
"in",
"enumerate",
"(",
"self",
".",
"_covariances",
")",
":",
"for",
"varname",
",",
"g",
"in",
"f",
".",
"gradient",
"(",
")",
".",
"items",
"(",
")",
":",... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LinearCov.value | Covariance matrix.
Returns
-------
K : ndarray
s⋅XXᵀ. | glimix_core/cov/_linear.py | def value(self):
"""
Covariance matrix.
Returns
-------
K : ndarray
s⋅XXᵀ.
"""
X = self.X
return self.scale * (X @ X.T) | def value(self):
"""
Covariance matrix.
Returns
-------
K : ndarray
s⋅XXᵀ.
"""
X = self.X
return self.scale * (X @ X.T) | [
"Covariance",
"matrix",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_linear.py#L79-L89 | [
"def",
"value",
"(",
"self",
")",
":",
"X",
"=",
"self",
".",
"X",
"return",
"self",
".",
"scale",
"*",
"(",
"X",
"@",
"X",
".",
"T",
")"
] | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | KronMean.B | Effect-sizes parameter, B. | glimix_core/mean/_kron.py | def B(self):
"""
Effect-sizes parameter, B.
"""
return unvec(self._vecB.value, (self.X.shape[1], self.A.shape[0])) | def B(self):
"""
Effect-sizes parameter, B.
"""
return unvec(self._vecB.value, (self.X.shape[1], self.A.shape[0])) | [
"Effect",
"-",
"sizes",
"parameter",
"B",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/mean/_kron.py#L94-L98 | [
"def",
"B",
"(",
"self",
")",
":",
"return",
"unvec",
"(",
"self",
".",
"_vecB",
".",
"value",
",",
"(",
"self",
".",
"X",
".",
"shape",
"[",
"1",
"]",
",",
"self",
".",
"A",
".",
"shape",
"[",
"0",
"]",
")",
")"
] | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | bernoulli_sample | r"""Bernoulli likelihood sampling.
Sample according to
.. math::
\mathbf y \sim \prod_{i=1}^n
\text{Bernoulli}(\mu_i = \text{logit}(z_i))
\mathcal N(~ o \mathbf 1 + \mathbf a^\intercal \boldsymbol\alpha;
~ (h^2 - v_c)\mathrm G^\intercal\mathrm G +
(1-h^2-v_c)\mathrm I ... | glimix_core/random/_canonical.py | def bernoulli_sample(
offset,
G,
heritability=0.5,
causal_variants=None,
causal_variance=0,
random_state=None,
):
r"""Bernoulli likelihood sampling.
Sample according to
.. math::
\mathbf y \sim \prod_{i=1}^n
\text{Bernoulli}(\mu_i = \text{logit}(z_i))
\math... | def bernoulli_sample(
offset,
G,
heritability=0.5,
causal_variants=None,
causal_variance=0,
random_state=None,
):
r"""Bernoulli likelihood sampling.
Sample according to
.. math::
\mathbf y \sim \prod_{i=1}^n
\text{Bernoulli}(\mu_i = \text{logit}(z_i))
\math... | [
"r",
"Bernoulli",
"likelihood",
"sampling",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/random/_canonical.py#L10-L68 | [
"def",
"bernoulli_sample",
"(",
"offset",
",",
"G",
",",
"heritability",
"=",
"0.5",
",",
"causal_variants",
"=",
"None",
",",
"causal_variance",
"=",
"0",
",",
"random_state",
"=",
"None",
",",
")",
":",
"link",
"=",
"LogitLink",
"(",
")",
"mean",
",",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | poisson_sample | Poisson likelihood sampling.
Parameters
----------
random_state : random_state
Set the initial random state.
Example
-------
.. doctest::
>>> from glimix_core.random import poisson_sample
>>> from numpy.random import RandomState
>>> offset = -0.5
>>> G... | glimix_core/random/_canonical.py | def poisson_sample(
offset,
G,
heritability=0.5,
causal_variants=None,
causal_variance=0,
random_state=None,
):
"""Poisson likelihood sampling.
Parameters
----------
random_state : random_state
Set the initial random state.
Example
-------
.. doctest::
... | def poisson_sample(
offset,
G,
heritability=0.5,
causal_variants=None,
causal_variance=0,
random_state=None,
):
"""Poisson likelihood sampling.
Parameters
----------
random_state : random_state
Set the initial random state.
Example
-------
.. doctest::
... | [
"Poisson",
"likelihood",
"sampling",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/random/_canonical.py#L110-L144 | [
"def",
"poisson_sample",
"(",
"offset",
",",
"G",
",",
"heritability",
"=",
"0.5",
",",
"causal_variants",
"=",
"None",
",",
"causal_variance",
"=",
"0",
",",
"random_state",
"=",
"None",
",",
")",
":",
"mean",
",",
"cov",
"=",
"_mean_cov",
"(",
"offset"... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | PosteriorLinearKernel.L | r"""Cholesky decomposition of :math:`\mathrm B`.
.. math::
\mathrm B = \mathrm Q^{\intercal}\tilde{\mathrm{T}}\mathrm Q
+ \mathrm{S}^{-1} | glimix_core/_ep/posterior_linear_kernel.py | def L(self):
r"""Cholesky decomposition of :math:`\mathrm B`.
.. math::
\mathrm B = \mathrm Q^{\intercal}\tilde{\mathrm{T}}\mathrm Q
+ \mathrm{S}^{-1}
"""
from numpy_sugar.linalg import ddot, sum2diag
if self._L_cache is not None:
return... | def L(self):
r"""Cholesky decomposition of :math:`\mathrm B`.
.. math::
\mathrm B = \mathrm Q^{\intercal}\tilde{\mathrm{T}}\mathrm Q
+ \mathrm{S}^{-1}
"""
from numpy_sugar.linalg import ddot, sum2diag
if self._L_cache is not None:
return... | [
"r",
"Cholesky",
"decomposition",
"of",
":",
"math",
":",
"\\",
"mathrm",
"B",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/_ep/posterior_linear_kernel.py#L65-L88 | [
"def",
"L",
"(",
"self",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"ddot",
",",
"sum2diag",
"if",
"self",
".",
"_L_cache",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_L_cache",
"s",
"=",
"self",
".",
"_cov",
"[",
"\"scale\"",
"... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | ExpFamGP.fit | r"""Maximise the marginal likelihood.
Parameters
----------
verbose : bool
``True`` for progress output; ``False`` otherwise.
Defaults to ``True``.
factr : float, optional
The iteration stops when
``(f^k - f^{k+1})/max{|f^k|,|f^{k+1}|,1} <... | glimix_core/ggp/_expfam.py | def fit(self, verbose=True, factr=1e5, pgtol=1e-7):
r"""Maximise the marginal likelihood.
Parameters
----------
verbose : bool
``True`` for progress output; ``False`` otherwise.
Defaults to ``True``.
factr : float, optional
The iteration stops... | def fit(self, verbose=True, factr=1e5, pgtol=1e-7):
r"""Maximise the marginal likelihood.
Parameters
----------
verbose : bool
``True`` for progress output; ``False`` otherwise.
Defaults to ``True``.
factr : float, optional
The iteration stops... | [
"r",
"Maximise",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/ggp/_expfam.py#L83-L104 | [
"def",
"fit",
"(",
"self",
",",
"verbose",
"=",
"True",
",",
"factr",
"=",
"1e5",
",",
"pgtol",
"=",
"1e-7",
")",
":",
"self",
".",
"_maximize",
"(",
"verbose",
"=",
"verbose",
",",
"factr",
"=",
"factr",
",",
"pgtol",
"=",
"pgtol",
")"
] | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | GLMM.covariance | r"""Covariance of the prior.
Returns
-------
:class:`numpy.ndarray`
:math:`v_0 \mathrm K + v_1 \mathrm I`. | glimix_core/glmm/_glmm.py | def covariance(self):
r"""Covariance of the prior.
Returns
-------
:class:`numpy.ndarray`
:math:`v_0 \mathrm K + v_1 \mathrm I`.
"""
from numpy_sugar.linalg import ddot, sum2diag
Q0 = self._QS[0][0]
S0 = self._QS[1]
return sum2diag(do... | def covariance(self):
r"""Covariance of the prior.
Returns
-------
:class:`numpy.ndarray`
:math:`v_0 \mathrm K + v_1 \mathrm I`.
"""
from numpy_sugar.linalg import ddot, sum2diag
Q0 = self._QS[0][0]
S0 = self._QS[1]
return sum2diag(do... | [
"r",
"Covariance",
"of",
"the",
"prior",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/glmm/_glmm.py#L127-L139 | [
"def",
"covariance",
"(",
"self",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"ddot",
",",
"sum2diag",
"Q0",
"=",
"self",
".",
"_QS",
"[",
"0",
"]",
"[",
"0",
"]",
"S0",
"=",
"self",
".",
"_QS",
"[",
"1",
"]",
"return",
"sum2diag",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | GLMM.fit | r"""Maximise the marginal likelihood.
Parameters
----------
verbose : bool
``True`` for progress output; ``False`` otherwise.
Defaults to ``True``.
factr : float, optional
The iteration stops when
``(f^k - f^{k+1})/max{|f^k|,|f^{k+1}|,1} <... | glimix_core/glmm/_glmm.py | def fit(self, verbose=True, factr=1e5, pgtol=1e-7):
r"""Maximise the marginal likelihood.
Parameters
----------
verbose : bool
``True`` for progress output; ``False`` otherwise.
Defaults to ``True``.
factr : float, optional
The iteration stops... | def fit(self, verbose=True, factr=1e5, pgtol=1e-7):
r"""Maximise the marginal likelihood.
Parameters
----------
verbose : bool
``True`` for progress output; ``False`` otherwise.
Defaults to ``True``.
factr : float, optional
The iteration stops... | [
"r",
"Maximise",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/glmm/_glmm.py#L169-L192 | [
"def",
"fit",
"(",
"self",
",",
"verbose",
"=",
"True",
",",
"factr",
"=",
"1e5",
",",
"pgtol",
"=",
"1e-7",
")",
":",
"self",
".",
"_verbose",
"=",
"verbose",
"self",
".",
"_maximize",
"(",
"verbose",
"=",
"verbose",
",",
"factr",
"=",
"factr",
",... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | GLMM.posteriori_mean | r""" Mean of the estimated posteriori.
This is also the maximum a posteriori estimation of the latent variable. | glimix_core/glmm/_glmm.py | def posteriori_mean(self):
r""" Mean of the estimated posteriori.
This is also the maximum a posteriori estimation of the latent variable.
"""
from numpy_sugar.linalg import rsolve
Sigma = self.posteriori_covariance()
eta = self._ep._posterior.eta
return dot(Sig... | def posteriori_mean(self):
r""" Mean of the estimated posteriori.
This is also the maximum a posteriori estimation of the latent variable.
"""
from numpy_sugar.linalg import rsolve
Sigma = self.posteriori_covariance()
eta = self._ep._posterior.eta
return dot(Sig... | [
"r",
"Mean",
"of",
"the",
"estimated",
"posteriori",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/glmm/_glmm.py#L220-L229 | [
"def",
"posteriori_mean",
"(",
"self",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"rsolve",
"Sigma",
"=",
"self",
".",
"posteriori_covariance",
"(",
")",
"eta",
"=",
"self",
".",
"_ep",
".",
"_posterior",
".",
"eta",
"return",
"dot",
"(",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | GLMM.posteriori_covariance | r""" Covariance of the estimated posteriori. | glimix_core/glmm/_glmm.py | def posteriori_covariance(self):
r""" Covariance of the estimated posteriori."""
K = GLMM.covariance(self)
tau = self._ep._posterior.tau
return pinv(pinv(K) + diag(1 / tau)) | def posteriori_covariance(self):
r""" Covariance of the estimated posteriori."""
K = GLMM.covariance(self)
tau = self._ep._posterior.tau
return pinv(pinv(K) + diag(1 / tau)) | [
"r",
"Covariance",
"of",
"the",
"estimated",
"posteriori",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/glmm/_glmm.py#L231-L235 | [
"def",
"posteriori_covariance",
"(",
"self",
")",
":",
"K",
"=",
"GLMM",
".",
"covariance",
"(",
"self",
")",
"tau",
"=",
"self",
".",
"_ep",
".",
"_posterior",
".",
"tau",
"return",
"pinv",
"(",
"pinv",
"(",
"K",
")",
"+",
"diag",
"(",
"1",
"/",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | _bstar_1effect | Same as :func:`_bstar_set` but for single-effect. | glimix_core/lmm/_lmm_scan.py | def _bstar_1effect(beta, alpha, yTBy, yTBX, yTBM, XTBX, XTBM, MTBM):
"""
Same as :func:`_bstar_set` but for single-effect.
"""
from numpy_sugar import epsilon
from numpy_sugar.linalg import dotd
from numpy import sum
r = full(MTBM[0].shape[0], yTBy)
r -= 2 * add.reduce([dot(i, beta) for... | def _bstar_1effect(beta, alpha, yTBy, yTBX, yTBM, XTBX, XTBM, MTBM):
"""
Same as :func:`_bstar_set` but for single-effect.
"""
from numpy_sugar import epsilon
from numpy_sugar.linalg import dotd
from numpy import sum
r = full(MTBM[0].shape[0], yTBy)
r -= 2 * add.reduce([dot(i, beta) for... | [
"Same",
"as",
":",
"func",
":",
"_bstar_set",
"but",
"for",
"single",
"-",
"effect",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm_scan.py#L536-L551 | [
"def",
"_bstar_1effect",
"(",
"beta",
",",
"alpha",
",",
"yTBy",
",",
"yTBX",
",",
"yTBM",
",",
"XTBX",
",",
"XTBM",
",",
"MTBM",
")",
":",
"from",
"numpy_sugar",
"import",
"epsilon",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"dotd",
"from",
"numpy... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | _bstar_set | Compute -2𝐲ᵀBEⱼ𝐛ⱼ + (𝐛ⱼEⱼ)ᵀBEⱼ𝐛ⱼ.
For 𝐛ⱼ = [𝜷ⱼᵀ 𝜶ⱼᵀ]ᵀ. | glimix_core/lmm/_lmm_scan.py | def _bstar_set(beta, alpha, yTBy, yTBX, yTBM, XTBX, XTBM, MTBM):
"""
Compute -2𝐲ᵀBEⱼ𝐛ⱼ + (𝐛ⱼEⱼ)ᵀBEⱼ𝐛ⱼ.
For 𝐛ⱼ = [𝜷ⱼᵀ 𝜶ⱼᵀ]ᵀ.
"""
from numpy_sugar import epsilon
r = yTBy
r -= 2 * add.reduce([i @ beta for i in yTBX])
r -= 2 * add.reduce([i @ alpha for i in yTBM])
r += add.redu... | def _bstar_set(beta, alpha, yTBy, yTBX, yTBM, XTBX, XTBM, MTBM):
"""
Compute -2𝐲ᵀBEⱼ𝐛ⱼ + (𝐛ⱼEⱼ)ᵀBEⱼ𝐛ⱼ.
For 𝐛ⱼ = [𝜷ⱼᵀ 𝜶ⱼᵀ]ᵀ.
"""
from numpy_sugar import epsilon
r = yTBy
r -= 2 * add.reduce([i @ beta for i in yTBX])
r -= 2 * add.reduce([i @ alpha for i in yTBM])
r += add.redu... | [
"Compute",
"-",
"2𝐲ᵀBEⱼ𝐛ⱼ",
"+",
"(",
"𝐛ⱼEⱼ",
")",
"ᵀBEⱼ𝐛ⱼ",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm_scan.py#L554-L568 | [
"def",
"_bstar_set",
"(",
"beta",
",",
"alpha",
",",
"yTBy",
",",
"yTBX",
",",
"yTBM",
",",
"XTBX",
",",
"XTBM",
",",
"MTBM",
")",
":",
"from",
"numpy_sugar",
"import",
"epsilon",
"r",
"=",
"yTBy",
"r",
"-=",
"2",
"*",
"add",
".",
"reduce",
"(",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | FastScanner.null_lml | Log of the marginal likelihood for the null hypothesis.
It is implemented as ::
2·log(p(Y)) = -n·log(2𝜋s) - log|D| - n,
Returns
-------
lml : float
Log of the marginal likelihood. | glimix_core/lmm/_lmm_scan.py | def null_lml(self):
"""
Log of the marginal likelihood for the null hypothesis.
It is implemented as ::
2·log(p(Y)) = -n·log(2𝜋s) - log|D| - n,
Returns
-------
lml : float
Log of the marginal likelihood.
"""
n = self._nsamples
... | def null_lml(self):
"""
Log of the marginal likelihood for the null hypothesis.
It is implemented as ::
2·log(p(Y)) = -n·log(2𝜋s) - log|D| - n,
Returns
-------
lml : float
Log of the marginal likelihood.
"""
n = self._nsamples
... | [
"Log",
"of",
"the",
"marginal",
"likelihood",
"for",
"the",
"null",
"hypothesis",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm_scan.py#L114-L129 | [
"def",
"null_lml",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"_nsamples",
"scale",
"=",
"self",
".",
"null_scale",
"return",
"(",
"self",
".",
"_static_lml",
"(",
")",
"-",
"n",
"*",
"log",
"(",
"scale",
")",
")",
"/",
"2"
] | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | FastScanner.null_beta | Optimal 𝜷 according to the marginal likelihood.
It is compute by solving the equation ::
(XᵀBX)𝜷 = XᵀB𝐲.
Returns
-------
beta : ndarray
Optimal 𝜷. | glimix_core/lmm/_lmm_scan.py | def null_beta(self):
"""
Optimal 𝜷 according to the marginal likelihood.
It is compute by solving the equation ::
(XᵀBX)𝜷 = XᵀB𝐲.
Returns
-------
beta : ndarray
Optimal 𝜷.
"""
ETBE = self._ETBE
yTBX = self._yTBX
... | def null_beta(self):
"""
Optimal 𝜷 according to the marginal likelihood.
It is compute by solving the equation ::
(XᵀBX)𝜷 = XᵀB𝐲.
Returns
-------
beta : ndarray
Optimal 𝜷.
"""
ETBE = self._ETBE
yTBX = self._yTBX
... | [
"Optimal",
"𝜷",
"according",
"to",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm_scan.py#L133-L151 | [
"def",
"null_beta",
"(",
"self",
")",
":",
"ETBE",
"=",
"self",
".",
"_ETBE",
"yTBX",
"=",
"self",
".",
"_yTBX",
"A",
"=",
"sum",
"(",
"i",
".",
"XTBX",
"for",
"i",
"in",
"ETBE",
")",
"b",
"=",
"sum",
"(",
"yTBX",
")",
"return",
"rsolve",
"(",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | FastScanner.null_beta_covariance | Covariance of the optimal 𝜷 according to the marginal likelihood.
Returns
-------
beta_covariance : ndarray
(Xᵀ(s(K + vI))⁻¹X)⁻¹. | glimix_core/lmm/_lmm_scan.py | def null_beta_covariance(self):
"""
Covariance of the optimal 𝜷 according to the marginal likelihood.
Returns
-------
beta_covariance : ndarray
(Xᵀ(s(K + vI))⁻¹X)⁻¹.
"""
A = sum(i @ j.T for (i, j) in zip(self._XTQDi, self._XTQ))
return self.n... | def null_beta_covariance(self):
"""
Covariance of the optimal 𝜷 according to the marginal likelihood.
Returns
-------
beta_covariance : ndarray
(Xᵀ(s(K + vI))⁻¹X)⁻¹.
"""
A = sum(i @ j.T for (i, j) in zip(self._XTQDi, self._XTQ))
return self.n... | [
"Covariance",
"of",
"the",
"optimal",
"𝜷",
"according",
"to",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm_scan.py#L155-L165 | [
"def",
"null_beta_covariance",
"(",
"self",
")",
":",
"A",
"=",
"sum",
"(",
"i",
"@",
"j",
".",
"T",
"for",
"(",
"i",
",",
"j",
")",
"in",
"zip",
"(",
"self",
".",
"_XTQDi",
",",
"self",
".",
"_XTQ",
")",
")",
"return",
"self",
".",
"null_scale... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | FastScanner.null_scale | Optimal s according to the marginal likelihood.
The optimal s is given by ::
s = n⁻¹𝐲ᵀB(𝐲 - X𝜷),
where 𝜷 is optimal.
Returns
-------
scale : float
Optimal scale. | glimix_core/lmm/_lmm_scan.py | def null_scale(self):
"""
Optimal s according to the marginal likelihood.
The optimal s is given by ::
s = n⁻¹𝐲ᵀB(𝐲 - X𝜷),
where 𝜷 is optimal.
Returns
-------
scale : float
Optimal scale.
"""
n = self._nsamples
... | def null_scale(self):
"""
Optimal s according to the marginal likelihood.
The optimal s is given by ::
s = n⁻¹𝐲ᵀB(𝐲 - X𝜷),
where 𝜷 is optimal.
Returns
-------
scale : float
Optimal scale.
"""
n = self._nsamples
... | [
"Optimal",
"s",
"according",
"to",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm_scan.py#L182-L200 | [
"def",
"null_scale",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"_nsamples",
"beta",
"=",
"self",
".",
"null_beta",
"sqrdot",
"=",
"self",
".",
"_yTBy",
"-",
"dot",
"(",
"sum",
"(",
"self",
".",
"_yTBX",
")",
",",
"beta",
")",
"return",
"sqrdot"... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | FastScanner.fast_scan | LMLs, fixed-effect sizes, and scales for single-marker scan.
Parameters
----------
M : array_like
Matrix of fixed-effects across columns.
verbose : bool, optional
``True`` for progress information; ``False`` otherwise.
Defaults to ``True``.
R... | glimix_core/lmm/_lmm_scan.py | def fast_scan(self, M, verbose=True):
"""
LMLs, fixed-effect sizes, and scales for single-marker scan.
Parameters
----------
M : array_like
Matrix of fixed-effects across columns.
verbose : bool, optional
``True`` for progress information; ``False... | def fast_scan(self, M, verbose=True):
"""
LMLs, fixed-effect sizes, and scales for single-marker scan.
Parameters
----------
M : array_like
Matrix of fixed-effects across columns.
verbose : bool, optional
``True`` for progress information; ``False... | [
"LMLs",
"fixed",
"-",
"effect",
"sizes",
"and",
"scales",
"for",
"single",
"-",
"marker",
"scan",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm_scan.py#L202-L265 | [
"def",
"fast_scan",
"(",
"self",
",",
"M",
",",
"verbose",
"=",
"True",
")",
":",
"from",
"tqdm",
"import",
"tqdm",
"if",
"M",
".",
"ndim",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"\"`M` array must be bidimensional.\"",
")",
"p",
"=",
"M",
".",
"sh... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | FastScanner.scan | LML, fixed-effect sizes, and scale of the candidate set.
Parameters
----------
M : array_like
Fixed-effects set.
Returns
-------
lml : float
Log of the marginal likelihood.
effsizes0 : ndarray
Covariates fixed-effect sizes.
... | glimix_core/lmm/_lmm_scan.py | def scan(self, M):
"""
LML, fixed-effect sizes, and scale of the candidate set.
Parameters
----------
M : array_like
Fixed-effects set.
Returns
-------
lml : float
Log of the marginal likelihood.
effsizes0 : ndarray
... | def scan(self, M):
"""
LML, fixed-effect sizes, and scale of the candidate set.
Parameters
----------
M : array_like
Fixed-effects set.
Returns
-------
lml : float
Log of the marginal likelihood.
effsizes0 : ndarray
... | [
"LML",
"fixed",
"-",
"effect",
"sizes",
"and",
"scale",
"of",
"the",
"candidate",
"set",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm_scan.py#L267-L315 | [
"def",
"scan",
"(",
"self",
",",
"M",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"ddot",
"from",
"numpy_sugar",
"import",
"is_all_finite",
"M",
"=",
"asarray",
"(",
"M",
",",
"float",
")",
"if",
"M",
".",
"shape",
"[",
"1",
"]",
"==",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | KronFastScanner.null_lml | Log of the marginal likelihood for the null hypothesis.
It is implemented as ::
2·log(p(Y)) = -n·p·log(2𝜋s) - log|K| - n·p,
for which s and 𝚩 are optimal.
Returns
-------
lml : float
Log of the marginal likelihood. | glimix_core/lmm/_kron2sum_scan.py | def null_lml(self):
"""
Log of the marginal likelihood for the null hypothesis.
It is implemented as ::
2·log(p(Y)) = -n·p·log(2𝜋s) - log|K| - n·p,
for which s and 𝚩 are optimal.
Returns
-------
lml : float
Log of the marginal likelih... | def null_lml(self):
"""
Log of the marginal likelihood for the null hypothesis.
It is implemented as ::
2·log(p(Y)) = -n·p·log(2𝜋s) - log|K| - n·p,
for which s and 𝚩 are optimal.
Returns
-------
lml : float
Log of the marginal likelih... | [
"Log",
"of",
"the",
"marginal",
"likelihood",
"for",
"the",
"null",
"hypothesis",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_kron2sum_scan.py#L60-L77 | [
"def",
"null_lml",
"(",
"self",
")",
":",
"np",
"=",
"self",
".",
"_nsamples",
"*",
"self",
".",
"_ntraits",
"scale",
"=",
"self",
".",
"null_scale",
"return",
"self",
".",
"_static_lml",
"(",
")",
"/",
"2",
"-",
"np",
"*",
"safe_log",
"(",
"scale",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | KronFastScanner.null_scale | Optimal s according to the marginal likelihood.
The optimal s is given by
s = (n·p)⁻¹𝐲ᵀK⁻¹(𝐲 - 𝐦),
where 𝐦 = (A ⊗ X)vec(𝚩) and 𝚩 is optimal.
Returns
-------
scale : float
Optimal scale. | glimix_core/lmm/_kron2sum_scan.py | def null_scale(self):
"""
Optimal s according to the marginal likelihood.
The optimal s is given by
s = (n·p)⁻¹𝐲ᵀK⁻¹(𝐲 - 𝐦),
where 𝐦 = (A ⊗ X)vec(𝚩) and 𝚩 is optimal.
Returns
-------
scale : float
Optimal scale.
"""
... | def null_scale(self):
"""
Optimal s according to the marginal likelihood.
The optimal s is given by
s = (n·p)⁻¹𝐲ᵀK⁻¹(𝐲 - 𝐦),
where 𝐦 = (A ⊗ X)vec(𝚩) and 𝚩 is optimal.
Returns
-------
scale : float
Optimal scale.
"""
... | [
"Optimal",
"s",
"according",
"to",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_kron2sum_scan.py#L126-L146 | [
"def",
"null_scale",
"(",
"self",
")",
":",
"np",
"=",
"self",
".",
"_nsamples",
"*",
"self",
".",
"_ntraits",
"b",
"=",
"vec",
"(",
"self",
".",
"null_beta",
")",
"mKiy",
"=",
"b",
".",
"T",
"@",
"self",
".",
"_MKiy",
"sqrtdot",
"=",
"self",
"."... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | KronFastScanner.scan | LML, fixed-effect sizes, and scale of the candidate set.
Parameters
----------
A1 : (p, e) array_like
Trait-by-environments design matrix.
X1 : (n, m) array_like
Variants set matrix.
Returns
-------
lml : float
Log of the marg... | glimix_core/lmm/_kron2sum_scan.py | def scan(self, A1, X1):
"""
LML, fixed-effect sizes, and scale of the candidate set.
Parameters
----------
A1 : (p, e) array_like
Trait-by-environments design matrix.
X1 : (n, m) array_like
Variants set matrix.
Returns
-------
... | def scan(self, A1, X1):
"""
LML, fixed-effect sizes, and scale of the candidate set.
Parameters
----------
A1 : (p, e) array_like
Trait-by-environments design matrix.
X1 : (n, m) array_like
Variants set matrix.
Returns
-------
... | [
"LML",
"fixed",
"-",
"effect",
"sizes",
"and",
"scale",
"of",
"the",
"candidate",
"set",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_kron2sum_scan.py#L148-L246 | [
"def",
"scan",
"(",
"self",
",",
"A1",
",",
"X1",
")",
":",
"from",
"numpy",
"import",
"empty",
"from",
"numpy",
".",
"linalg",
"import",
"multi_dot",
"from",
"numpy_sugar",
"import",
"epsilon",
",",
"is_all_finite",
"from",
"scipy",
".",
"linalg",
"import... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | GGPSampler.sample | r"""Sample from the specified distribution.
Parameters
----------
random_state : random_state
Set the initial random state.
Returns
-------
numpy.ndarray
Sample. | glimix_core/random/_ggp.py | def sample(self, random_state=None):
r"""Sample from the specified distribution.
Parameters
----------
random_state : random_state
Set the initial random state.
Returns
-------
numpy.ndarray
Sample.
"""
from numpy_sugar im... | def sample(self, random_state=None):
r"""Sample from the specified distribution.
Parameters
----------
random_state : random_state
Set the initial random state.
Returns
-------
numpy.ndarray
Sample.
"""
from numpy_sugar im... | [
"r",
"Sample",
"from",
"the",
"specified",
"distribution",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/random/_ggp.py#L52-L77 | [
"def",
"sample",
"(",
"self",
",",
"random_state",
"=",
"None",
")",
":",
"from",
"numpy_sugar",
"import",
"epsilon",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"sum2diag",
"from",
"numpy_sugar",
".",
"random",
"import",
"multivariate_normal",
"if",
"random... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | economic_qs_zeros | Eigen decomposition of a zero matrix. | glimix_core/_util/eigen.py | def economic_qs_zeros(n):
"""Eigen decomposition of a zero matrix."""
Q0 = empty((n, 0))
Q1 = eye(n)
S0 = empty(0)
return ((Q0, Q1), S0) | def economic_qs_zeros(n):
"""Eigen decomposition of a zero matrix."""
Q0 = empty((n, 0))
Q1 = eye(n)
S0 = empty(0)
return ((Q0, Q1), S0) | [
"Eigen",
"decomposition",
"of",
"a",
"zero",
"matrix",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/_util/eigen.py#L4-L11 | [
"def",
"economic_qs_zeros",
"(",
"n",
")",
":",
"Q0",
"=",
"empty",
"(",
"(",
"n",
",",
"0",
")",
")",
"Q1",
"=",
"eye",
"(",
"n",
")",
"S0",
"=",
"empty",
"(",
"0",
")",
"return",
"(",
"(",
"Q0",
",",
"Q1",
")",
",",
"S0",
")"
] | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2Sum.get_fast_scanner | Return :class:`.FastScanner` for association scan.
Returns
-------
:class:`.FastScanner`
Instance of a class designed to perform very fast association scan. | glimix_core/lmm/_kron2sum.py | def get_fast_scanner(self):
"""
Return :class:`.FastScanner` for association scan.
Returns
-------
:class:`.FastScanner`
Instance of a class designed to perform very fast association scan.
"""
terms = self._terms
return KronFastScanner(self._Y... | def get_fast_scanner(self):
"""
Return :class:`.FastScanner` for association scan.
Returns
-------
:class:`.FastScanner`
Instance of a class designed to perform very fast association scan.
"""
terms = self._terms
return KronFastScanner(self._Y... | [
"Return",
":",
"class",
":",
".",
"FastScanner",
"for",
"association",
"scan",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_kron2sum.py#L140-L150 | [
"def",
"get_fast_scanner",
"(",
"self",
")",
":",
"terms",
"=",
"self",
".",
"_terms",
"return",
"KronFastScanner",
"(",
"self",
".",
"_Y",
",",
"self",
".",
"_mean",
".",
"A",
",",
"self",
".",
"_mean",
".",
"X",
",",
"self",
".",
"_cov",
".",
"Ge... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2Sum.lml | Log of the marginal likelihood.
Let 𝐲 = vec(Y), M = A⊗X, and H = MᵀK⁻¹M. The restricted log of the marginal
likelihood is given by [R07]_::
2⋅log(p(𝐲)) = -(n⋅p - c⋅p) log(2π) + log(|MᵀM|) - log(|K|) - log(|H|)
- (𝐲-𝐦)ᵀ K⁻¹ (𝐲-𝐦),
where 𝐦 = M𝛃 for 𝛃 = H⁻¹Mᵀ... | glimix_core/lmm/_kron2sum.py | def lml(self):
"""
Log of the marginal likelihood.
Let 𝐲 = vec(Y), M = A⊗X, and H = MᵀK⁻¹M. The restricted log of the marginal
likelihood is given by [R07]_::
2⋅log(p(𝐲)) = -(n⋅p - c⋅p) log(2π) + log(|MᵀM|) - log(|K|) - log(|H|)
- (𝐲-𝐦)ᵀ K⁻¹ (𝐲-𝐦),
... | def lml(self):
"""
Log of the marginal likelihood.
Let 𝐲 = vec(Y), M = A⊗X, and H = MᵀK⁻¹M. The restricted log of the marginal
likelihood is given by [R07]_::
2⋅log(p(𝐲)) = -(n⋅p - c⋅p) log(2π) + log(|MᵀM|) - log(|K|) - log(|H|)
- (𝐲-𝐦)ᵀ K⁻¹ (𝐲-𝐦),
... | [
"Log",
"of",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_kron2sum.py#L293-L357 | [
"def",
"lml",
"(",
"self",
")",
":",
"terms",
"=",
"self",
".",
"_terms",
"yKiy",
"=",
"terms",
"[",
"\"yKiy\"",
"]",
"mKiy",
"=",
"terms",
"[",
"\"mKiy\"",
"]",
"mKim",
"=",
"terms",
"[",
"\"mKim\"",
"]",
"lml",
"=",
"-",
"self",
".",
"_df",
"*"... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Kron2Sum._lml_gradient | Gradient of the log of the marginal likelihood.
Let 𝐲 = vec(Y), 𝕂 = K⁻¹∂(K)K⁻¹, and H = MᵀK⁻¹M. The gradient is given by::
2⋅∂log(p(𝐲)) = -tr(K⁻¹∂K) - tr(H⁻¹∂H) + 𝐲ᵀ𝕂𝐲 - 𝐦ᵀ𝕂(2⋅𝐲-𝐦)
- 2⋅(𝐦-𝐲)ᵀK⁻¹∂(𝐦).
Observe that
∂𝛃 = -H⁻¹(∂H)𝛃 - H⁻¹Mᵀ𝕂𝐲 and ∂... | glimix_core/lmm/_kron2sum.py | def _lml_gradient(self):
"""
Gradient of the log of the marginal likelihood.
Let 𝐲 = vec(Y), 𝕂 = K⁻¹∂(K)K⁻¹, and H = MᵀK⁻¹M. The gradient is given by::
2⋅∂log(p(𝐲)) = -tr(K⁻¹∂K) - tr(H⁻¹∂H) + 𝐲ᵀ𝕂𝐲 - 𝐦ᵀ𝕂(2⋅𝐲-𝐦)
- 2⋅(𝐦-𝐲)ᵀK⁻¹∂(𝐦).
Observe that
... | def _lml_gradient(self):
"""
Gradient of the log of the marginal likelihood.
Let 𝐲 = vec(Y), 𝕂 = K⁻¹∂(K)K⁻¹, and H = MᵀK⁻¹M. The gradient is given by::
2⋅∂log(p(𝐲)) = -tr(K⁻¹∂K) - tr(H⁻¹∂H) + 𝐲ᵀ𝕂𝐲 - 𝐦ᵀ𝕂(2⋅𝐲-𝐦)
- 2⋅(𝐦-𝐲)ᵀK⁻¹∂(𝐦).
Observe that
... | [
"Gradient",
"of",
"the",
"log",
"of",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_kron2sum.py#L523-L691 | [
"def",
"_lml_gradient",
"(",
"self",
")",
":",
"from",
"scipy",
".",
"linalg",
"import",
"cho_solve",
"terms",
"=",
"self",
".",
"_terms",
"dC0",
"=",
"self",
".",
"_cov",
".",
"C0",
".",
"gradient",
"(",
")",
"[",
"\"Lu\"",
"]",
"dC1",
"=",
"self",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | GLMMExpFam.gradient | r"""Gradient of the log of the marginal likelihood.
Returns
-------
dict
Map between variables to their gradient values. | glimix_core/glmm/_expfam.py | def gradient(self):
r"""Gradient of the log of the marginal likelihood.
Returns
-------
dict
Map between variables to their gradient values.
"""
self._update_approx()
g = self._ep.lml_derivatives(self._X)
ed = exp(-self.logitdelta)
es... | def gradient(self):
r"""Gradient of the log of the marginal likelihood.
Returns
-------
dict
Map between variables to their gradient values.
"""
self._update_approx()
g = self._ep.lml_derivatives(self._X)
ed = exp(-self.logitdelta)
es... | [
"r",
"Gradient",
"of",
"the",
"log",
"of",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/glmm/_expfam.py#L127-L146 | [
"def",
"gradient",
"(",
"self",
")",
":",
"self",
".",
"_update_approx",
"(",
")",
"g",
"=",
"self",
".",
"_ep",
".",
"lml_derivatives",
"(",
"self",
".",
"_X",
")",
"ed",
"=",
"exp",
"(",
"-",
"self",
".",
"logitdelta",
")",
"es",
"=",
"exp",
"(... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LRFreeFormCov.gradient | Derivative of the covariance matrix over the lower triangular, flat part of L.
It is equal to
∂K/∂Lᵢⱼ = ALᵀ + LAᵀ,
where Aᵢⱼ is an n×m matrix of zeros except at [Aᵢⱼ]ᵢⱼ=1.
Returns
-------
Lu : ndarray
Derivative of K over the lower-triangular, flat par... | glimix_core/cov/_lrfree.py | def gradient(self):
"""
Derivative of the covariance matrix over the lower triangular, flat part of L.
It is equal to
∂K/∂Lᵢⱼ = ALᵀ + LAᵀ,
where Aᵢⱼ is an n×m matrix of zeros except at [Aᵢⱼ]ᵢⱼ=1.
Returns
-------
Lu : ndarray
Derivative ... | def gradient(self):
"""
Derivative of the covariance matrix over the lower triangular, flat part of L.
It is equal to
∂K/∂Lᵢⱼ = ALᵀ + LAᵀ,
where Aᵢⱼ is an n×m matrix of zeros except at [Aᵢⱼ]ᵢⱼ=1.
Returns
-------
Lu : ndarray
Derivative ... | [
"Derivative",
"of",
"the",
"covariance",
"matrix",
"over",
"the",
"lower",
"triangular",
"flat",
"part",
"of",
"L",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/cov/_lrfree.py#L129-L153 | [
"def",
"gradient",
"(",
"self",
")",
":",
"L",
"=",
"self",
".",
"L",
"n",
"=",
"self",
".",
"L",
".",
"shape",
"[",
"0",
"]",
"grad",
"=",
"{",
"\"Lu\"",
":",
"zeros",
"(",
"(",
"n",
",",
"n",
",",
"n",
"*",
"self",
".",
"_L",
".",
"shap... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM.beta | Fixed-effect sizes.
Returns
-------
effect-sizes : numpy.ndarray
Optimal fixed-effect sizes.
Notes
-----
Setting the derivative of log(p(𝐲)) over effect sizes equal
to zero leads to solutions 𝜷 from equation ::
(QᵀX)ᵀD⁻¹(QᵀX)𝜷 = (QᵀX)... | glimix_core/lmm/_lmm.py | def beta(self):
"""
Fixed-effect sizes.
Returns
-------
effect-sizes : numpy.ndarray
Optimal fixed-effect sizes.
Notes
-----
Setting the derivative of log(p(𝐲)) over effect sizes equal
to zero leads to solutions 𝜷 from equation ::
... | def beta(self):
"""
Fixed-effect sizes.
Returns
-------
effect-sizes : numpy.ndarray
Optimal fixed-effect sizes.
Notes
-----
Setting the derivative of log(p(𝐲)) over effect sizes equal
to zero leads to solutions 𝜷 from equation ::
... | [
"Fixed",
"-",
"effect",
"sizes",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L181-L199 | [
"def",
"beta",
"(",
"self",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"rsolve",
"return",
"rsolve",
"(",
"self",
".",
"_X",
"[",
"\"VT\"",
"]",
",",
"rsolve",
"(",
"self",
".",
"_X",
"[",
"\"tX\"",
"]",
",",
"self",
".",
"mean",
"("... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM.beta_covariance | Estimates the covariance-matrix of the optimal beta.
Returns
-------
beta-covariance : ndarray
(Xᵀ(s((1-𝛿)K + 𝛿I))⁻¹X)⁻¹.
References
----------
.. Rencher, A. C., & Schaalje, G. B. (2008). Linear models in statistics. John
Wiley & Sons. | glimix_core/lmm/_lmm.py | def beta_covariance(self):
"""
Estimates the covariance-matrix of the optimal beta.
Returns
-------
beta-covariance : ndarray
(Xᵀ(s((1-𝛿)K + 𝛿I))⁻¹X)⁻¹.
References
----------
.. Rencher, A. C., & Schaalje, G. B. (2008). Linear models in sta... | def beta_covariance(self):
"""
Estimates the covariance-matrix of the optimal beta.
Returns
-------
beta-covariance : ndarray
(Xᵀ(s((1-𝛿)K + 𝛿I))⁻¹X)⁻¹.
References
----------
.. Rencher, A. C., & Schaalje, G. B. (2008). Linear models in sta... | [
"Estimates",
"the",
"covariance",
"-",
"matrix",
"of",
"the",
"optimal",
"beta",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L209-L234 | [
"def",
"beta_covariance",
"(",
"self",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"ddot",
"tX",
"=",
"self",
".",
"_X",
"[",
"\"tX\"",
"]",
"Q",
"=",
"concatenate",
"(",
"self",
".",
"_QS",
"[",
"0",
"]",
",",
"axis",
"=",
"1",
")",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM.fix | Disable parameter optimization.
Parameters
----------
param : str
Possible values are ``"delta"``, ``"beta"``, and ``"scale"``. | glimix_core/lmm/_lmm.py | def fix(self, param):
"""
Disable parameter optimization.
Parameters
----------
param : str
Possible values are ``"delta"``, ``"beta"``, and ``"scale"``.
"""
if param == "delta":
super()._fix("logistic")
else:
self._fix... | def fix(self, param):
"""
Disable parameter optimization.
Parameters
----------
param : str
Possible values are ``"delta"``, ``"beta"``, and ``"scale"``.
"""
if param == "delta":
super()._fix("logistic")
else:
self._fix... | [
"Disable",
"parameter",
"optimization",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L236-L248 | [
"def",
"fix",
"(",
"self",
",",
"param",
")",
":",
"if",
"param",
"==",
"\"delta\"",
":",
"super",
"(",
")",
".",
"_fix",
"(",
"\"logistic\"",
")",
"else",
":",
"self",
".",
"_fix",
"[",
"param",
"]",
"=",
"True"
] | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM.unfix | Enable parameter optimization.
Parameters
----------
param : str
Possible values are ``"delta"``, ``"beta"``, and ``"scale"``. | glimix_core/lmm/_lmm.py | def unfix(self, param):
"""
Enable parameter optimization.
Parameters
----------
param : str
Possible values are ``"delta"``, ``"beta"``, and ``"scale"``.
"""
if param == "delta":
self._unfix("logistic")
else:
self._fix... | def unfix(self, param):
"""
Enable parameter optimization.
Parameters
----------
param : str
Possible values are ``"delta"``, ``"beta"``, and ``"scale"``.
"""
if param == "delta":
self._unfix("logistic")
else:
self._fix... | [
"Enable",
"parameter",
"optimization",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L250-L262 | [
"def",
"unfix",
"(",
"self",
",",
"param",
")",
":",
"if",
"param",
"==",
"\"delta\"",
":",
"self",
".",
"_unfix",
"(",
"\"logistic\"",
")",
"else",
":",
"self",
".",
"_fix",
"[",
"param",
"]",
"=",
"False"
] | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM.fit | Maximise the marginal likelihood.
Parameters
----------
verbose : bool, optional
``True`` for progress output; ``False`` otherwise.
Defaults to ``True``. | glimix_core/lmm/_lmm.py | def fit(self, verbose=True):
"""
Maximise the marginal likelihood.
Parameters
----------
verbose : bool, optional
``True`` for progress output; ``False`` otherwise.
Defaults to ``True``.
"""
if not self._isfixed("logistic"):
se... | def fit(self, verbose=True):
"""
Maximise the marginal likelihood.
Parameters
----------
verbose : bool, optional
``True`` for progress output; ``False`` otherwise.
Defaults to ``True``.
"""
if not self._isfixed("logistic"):
se... | [
"Maximise",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L288-L305 | [
"def",
"fit",
"(",
"self",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"_isfixed",
"(",
"\"logistic\"",
")",
":",
"self",
".",
"_maximize_scalar",
"(",
"desc",
"=",
"\"LMM\"",
",",
"rtol",
"=",
"1e-6",
",",
"atol",
"=",
"1e-6",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM.get_fast_scanner | Return :class:`.FastScanner` for association scan.
Returns
-------
fast-scanner : :class:`.FastScanner`
Instance of a class designed to perform very fast association scan. | glimix_core/lmm/_lmm.py | def get_fast_scanner(self):
"""
Return :class:`.FastScanner` for association scan.
Returns
-------
fast-scanner : :class:`.FastScanner`
Instance of a class designed to perform very fast association scan.
"""
v0 = self.v0
v1 = self.v1
Q... | def get_fast_scanner(self):
"""
Return :class:`.FastScanner` for association scan.
Returns
-------
fast-scanner : :class:`.FastScanner`
Instance of a class designed to perform very fast association scan.
"""
v0 = self.v0
v1 = self.v1
Q... | [
"Return",
":",
"class",
":",
".",
"FastScanner",
"for",
"association",
"scan",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L307-L319 | [
"def",
"get_fast_scanner",
"(",
"self",
")",
":",
"v0",
"=",
"self",
".",
"v0",
"v1",
"=",
"self",
".",
"v1",
"QS",
"=",
"(",
"self",
".",
"_QS",
"[",
"0",
"]",
",",
"v0",
"*",
"self",
".",
"_QS",
"[",
"1",
"]",
")",
"return",
"FastScanner",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM.value | Internal use only. | glimix_core/lmm/_lmm.py | def value(self):
"""
Internal use only.
"""
if not self._fix["beta"]:
self._update_beta()
if not self._fix["scale"]:
self._update_scale()
return self.lml() | def value(self):
"""
Internal use only.
"""
if not self._fix["beta"]:
self._update_beta()
if not self._fix["scale"]:
self._update_scale()
return self.lml() | [
"Internal",
"use",
"only",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L321-L331 | [
"def",
"value",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_fix",
"[",
"\"beta\"",
"]",
":",
"self",
".",
"_update_beta",
"(",
")",
"if",
"not",
"self",
".",
"_fix",
"[",
"\"scale\"",
"]",
":",
"self",
".",
"_update_scale",
"(",
")",
"return... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM.lml | Log of the marginal likelihood.
Returns
-------
lml : float
Log of the marginal likelihood.
Notes
-----
The log of the marginal likelihood is given by ::
2⋅log(p(𝐲)) = -n⋅log(2π) - n⋅log(s) - log|D| - (Qᵀ𝐲)ᵀs⁻¹D⁻¹(Qᵀ𝐲)
... | glimix_core/lmm/_lmm.py | def lml(self):
"""
Log of the marginal likelihood.
Returns
-------
lml : float
Log of the marginal likelihood.
Notes
-----
The log of the marginal likelihood is given by ::
2⋅log(p(𝐲)) = -n⋅log(2π) - n⋅log(s) - log|D| - (Qᵀ𝐲)ᵀs... | def lml(self):
"""
Log of the marginal likelihood.
Returns
-------
lml : float
Log of the marginal likelihood.
Notes
-----
The log of the marginal likelihood is given by ::
2⋅log(p(𝐲)) = -n⋅log(2π) - n⋅log(s) - log|D| - (Qᵀ𝐲)ᵀs... | [
"Log",
"of",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L353-L388 | [
"def",
"lml",
"(",
"self",
")",
":",
"reml",
"=",
"(",
"self",
".",
"_logdetXX",
"(",
")",
"-",
"self",
".",
"_logdetH",
"(",
")",
")",
"/",
"2",
"if",
"self",
".",
"_optimal",
"[",
"\"scale\"",
"]",
":",
"lml",
"=",
"self",
".",
"_lml_optimal_sc... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM.delta | Variance ratio between ``K`` and ``I``. | glimix_core/lmm/_lmm.py | def delta(self):
"""
Variance ratio between ``K`` and ``I``.
"""
v = float(self._logistic.value)
if v > 0.0:
v = 1 / (1 + exp(-v))
else:
v = exp(v)
v = v / (v + 1.0)
return min(max(v, epsilon.tiny), 1 - epsilon.tiny) | def delta(self):
"""
Variance ratio between ``K`` and ``I``.
"""
v = float(self._logistic.value)
if v > 0.0:
v = 1 / (1 + exp(-v))
else:
v = exp(v)
v = v / (v + 1.0)
return min(max(v, epsilon.tiny), 1 - epsilon.tiny) | [
"Variance",
"ratio",
"between",
"K",
"and",
"I",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L403-L416 | [
"def",
"delta",
"(",
"self",
")",
":",
"v",
"=",
"float",
"(",
"self",
".",
"_logistic",
".",
"value",
")",
"if",
"v",
">",
"0.0",
":",
"v",
"=",
"1",
"/",
"(",
"1",
"+",
"exp",
"(",
"-",
"v",
")",
")",
"else",
":",
"v",
"=",
"exp",
"(",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM._logdetXX | log(|XᵀX|). | glimix_core/lmm/_lmm.py | def _logdetXX(self):
"""
log(|XᵀX|).
"""
if not self._restricted:
return 0.0
ldet = slogdet(self._X["tX"].T @ self._X["tX"])
if ldet[0] != 1.0:
raise ValueError("The determinant of XᵀX should be positive.")
return ldet[1] | def _logdetXX(self):
"""
log(|XᵀX|).
"""
if not self._restricted:
return 0.0
ldet = slogdet(self._X["tX"].T @ self._X["tX"])
if ldet[0] != 1.0:
raise ValueError("The determinant of XᵀX should be positive.")
return ldet[1] | [
"log",
"(",
"|XᵀX|",
")",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L489-L499 | [
"def",
"_logdetXX",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_restricted",
":",
"return",
"0.0",
"ldet",
"=",
"slogdet",
"(",
"self",
".",
"_X",
"[",
"\"tX\"",
"]",
".",
"T",
"@",
"self",
".",
"_X",
"[",
"\"tX\"",
"]",
")",
"if",
"ldet",... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM._logdetH | log(|H|) for H = s⁻¹XᵀQD⁻¹QᵀX. | glimix_core/lmm/_lmm.py | def _logdetH(self):
"""
log(|H|) for H = s⁻¹XᵀQD⁻¹QᵀX.
"""
if not self._restricted:
return 0.0
ldet = slogdet(sum(self._XTQDiQTX) / self.scale)
if ldet[0] != 1.0:
raise ValueError("The determinant of H should be positive.")
return ldet[1] | def _logdetH(self):
"""
log(|H|) for H = s⁻¹XᵀQD⁻¹QᵀX.
"""
if not self._restricted:
return 0.0
ldet = slogdet(sum(self._XTQDiQTX) / self.scale)
if ldet[0] != 1.0:
raise ValueError("The determinant of H should be positive.")
return ldet[1] | [
"log",
"(",
"|H|",
")",
"for",
"H",
"=",
"s⁻¹XᵀQD⁻¹QᵀX",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L501-L510 | [
"def",
"_logdetH",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_restricted",
":",
"return",
"0.0",
"ldet",
"=",
"slogdet",
"(",
"sum",
"(",
"self",
".",
"_XTQDiQTX",
")",
"/",
"self",
".",
"scale",
")",
"if",
"ldet",
"[",
"0",
"]",
"!=",
"1... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM._lml_optimal_scale | Log of the marginal likelihood for optimal scale.
Implementation for unrestricted LML::
Returns
-------
lml : float
Log of the marginal likelihood. | glimix_core/lmm/_lmm.py | def _lml_optimal_scale(self):
"""
Log of the marginal likelihood for optimal scale.
Implementation for unrestricted LML::
Returns
-------
lml : float
Log of the marginal likelihood.
"""
assert self._optimal["scale"]
n = len(self._y)
... | def _lml_optimal_scale(self):
"""
Log of the marginal likelihood for optimal scale.
Implementation for unrestricted LML::
Returns
-------
lml : float
Log of the marginal likelihood.
"""
assert self._optimal["scale"]
n = len(self._y)
... | [
"Log",
"of",
"the",
"marginal",
"likelihood",
"for",
"optimal",
"scale",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L512-L528 | [
"def",
"_lml_optimal_scale",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_optimal",
"[",
"\"scale\"",
"]",
"n",
"=",
"len",
"(",
"self",
".",
"_y",
")",
"lml",
"=",
"-",
"self",
".",
"_df",
"*",
"log2pi",
"-",
"self",
".",
"_df",
"-",
"n",
"*"... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM._lml_arbitrary_scale | Log of the marginal likelihood for arbitrary scale.
Returns
-------
lml : float
Log of the marginal likelihood. | glimix_core/lmm/_lmm.py | def _lml_arbitrary_scale(self):
"""
Log of the marginal likelihood for arbitrary scale.
Returns
-------
lml : float
Log of the marginal likelihood.
"""
s = self.scale
D = self._D
n = len(self._y)
lml = -self._df * log2pi - n * ... | def _lml_arbitrary_scale(self):
"""
Log of the marginal likelihood for arbitrary scale.
Returns
-------
lml : float
Log of the marginal likelihood.
"""
s = self.scale
D = self._D
n = len(self._y)
lml = -self._df * log2pi - n * ... | [
"Log",
"of",
"the",
"marginal",
"likelihood",
"for",
"arbitrary",
"scale",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L530-L547 | [
"def",
"_lml_arbitrary_scale",
"(",
"self",
")",
":",
"s",
"=",
"self",
".",
"scale",
"D",
"=",
"self",
".",
"_D",
"n",
"=",
"len",
"(",
"self",
".",
"_y",
")",
"lml",
"=",
"-",
"self",
".",
"_df",
"*",
"log2pi",
"-",
"n",
"*",
"log",
"(",
"s... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | LMM._df | Degrees of freedom. | glimix_core/lmm/_lmm.py | def _df(self):
"""
Degrees of freedom.
"""
if not self._restricted:
return self.nsamples
return self.nsamples - self._X["tX"].shape[1] | def _df(self):
"""
Degrees of freedom.
"""
if not self._restricted:
return self.nsamples
return self.nsamples - self._X["tX"].shape[1] | [
"Degrees",
"of",
"freedom",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L550-L556 | [
"def",
"_df",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_restricted",
":",
"return",
"self",
".",
"nsamples",
"return",
"self",
".",
"nsamples",
"-",
"self",
".",
"_X",
"[",
"\"tX\"",
"]",
".",
"shape",
"[",
"1",
"]"
] | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | GLMMNormal.get_fast_scanner | r"""Return :class:`glimix_core.lmm.FastScanner` for the current
delta. | glimix_core/glmm/_normal.py | def get_fast_scanner(self):
r"""Return :class:`glimix_core.lmm.FastScanner` for the current
delta."""
from numpy_sugar.linalg import ddot, economic_qs, sum2diag
y = self.eta / self.tau
if self._QS is None:
K = eye(y.shape[0]) / self.tau
else:
Q0 ... | def get_fast_scanner(self):
r"""Return :class:`glimix_core.lmm.FastScanner` for the current
delta."""
from numpy_sugar.linalg import ddot, economic_qs, sum2diag
y = self.eta / self.tau
if self._QS is None:
K = eye(y.shape[0]) / self.tau
else:
Q0 ... | [
"r",
"Return",
":",
"class",
":",
"glimix_core",
".",
"lmm",
".",
"FastScanner",
"for",
"the",
"current",
"delta",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/glmm/_normal.py#L97-L112 | [
"def",
"get_fast_scanner",
"(",
"self",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"ddot",
",",
"economic_qs",
",",
"sum2diag",
"y",
"=",
"self",
".",
"eta",
"/",
"self",
".",
"tau",
"if",
"self",
".",
"_QS",
"is",
"None",
":",
"K",
"=... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | GLMMNormal.value | r"""Log of the marginal likelihood.
Formally,
.. math::
- \frac{n}{2}\log{2\pi} - \frac{1}{2} \log{\left|
v_0 \mathrm K + v_1 \mathrm I + \tilde{\Sigma} \right|}
- \frac{1}{2}
\left(\tilde{\boldsymbol\mu} -
\mathr... | glimix_core/glmm/_normal.py | def value(self):
r"""Log of the marginal likelihood.
Formally,
.. math::
- \frac{n}{2}\log{2\pi} - \frac{1}{2} \log{\left|
v_0 \mathrm K + v_1 \mathrm I + \tilde{\Sigma} \right|}
- \frac{1}{2}
\left(\tilde{\boldsymbol\mu} -
... | def value(self):
r"""Log of the marginal likelihood.
Formally,
.. math::
- \frac{n}{2}\log{2\pi} - \frac{1}{2} \log{\left|
v_0 \mathrm K + v_1 \mathrm I + \tilde{\Sigma} \right|}
- \frac{1}{2}
\left(\tilde{\boldsymbol\mu} -
... | [
"r",
"Log",
"of",
"the",
"marginal",
"likelihood",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/glmm/_normal.py#L175-L226 | [
"def",
"value",
"(",
"self",
")",
":",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"ddot",
",",
"sum2diag",
"if",
"self",
".",
"_cache",
"[",
"\"value\"",
"]",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_cache",
"[",
"\"value\"",
"]",
"scale... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Posterior._initialize | r"""Initialize the mean and covariance of the posterior.
Given that :math:`\tilde{\mathrm T}` is a matrix of zeros right before
the first EP iteration, we have
.. math::
\boldsymbol\mu = \mathrm K^{-1} \mathbf m ~\text{ and }~
\Sigma = \mathrm K
as the initial... | glimix_core/_ep/posterior.py | def _initialize(self):
r"""Initialize the mean and covariance of the posterior.
Given that :math:`\tilde{\mathrm T}` is a matrix of zeros right before
the first EP iteration, we have
.. math::
\boldsymbol\mu = \mathrm K^{-1} \mathbf m ~\text{ and }~
\Sigma = \m... | def _initialize(self):
r"""Initialize the mean and covariance of the posterior.
Given that :math:`\tilde{\mathrm T}` is a matrix of zeros right before
the first EP iteration, we have
.. math::
\boldsymbol\mu = \mathrm K^{-1} \mathbf m ~\text{ and }~
\Sigma = \m... | [
"r",
"Initialize",
"the",
"mean",
"and",
"covariance",
"of",
"the",
"posterior",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/_ep/posterior.py#L63-L87 | [
"def",
"_initialize",
"(",
"self",
")",
":",
"if",
"self",
".",
"_mean",
"is",
"None",
"or",
"self",
".",
"_cov",
"is",
"None",
":",
"return",
"Q",
"=",
"self",
".",
"_cov",
"[",
"\"QS\"",
"]",
"[",
"0",
"]",
"[",
"0",
"]",
"S",
"=",
"self",
... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | Posterior.L | r"""Cholesky decomposition of :math:`\mathrm B`.
.. math::
\mathrm B = \mathrm Q^{\intercal}\tilde{\mathrm{T}}\mathrm Q
+ \mathrm{S}^{-1} | glimix_core/_ep/posterior.py | def L(self):
r"""Cholesky decomposition of :math:`\mathrm B`.
.. math::
\mathrm B = \mathrm Q^{\intercal}\tilde{\mathrm{T}}\mathrm Q
+ \mathrm{S}^{-1}
"""
from scipy.linalg import cho_factor
from numpy_sugar.linalg import ddot, sum2diag
if s... | def L(self):
r"""Cholesky decomposition of :math:`\mathrm B`.
.. math::
\mathrm B = \mathrm Q^{\intercal}\tilde{\mathrm{T}}\mathrm Q
+ \mathrm{S}^{-1}
"""
from scipy.linalg import cho_factor
from numpy_sugar.linalg import ddot, sum2diag
if s... | [
"r",
"Cholesky",
"decomposition",
"of",
":",
"math",
":",
"\\",
"mathrm",
"B",
"."
] | limix/glimix-core | python | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/_ep/posterior.py#L107-L126 | [
"def",
"L",
"(",
"self",
")",
":",
"from",
"scipy",
".",
"linalg",
"import",
"cho_factor",
"from",
"numpy_sugar",
".",
"linalg",
"import",
"ddot",
",",
"sum2diag",
"if",
"self",
".",
"_L_cache",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_L_cache"... | cddd0994591d100499cc41c1f480ddd575e7a980 |
valid | build_engine_session | Build an engine and a session.
:param str connection: An RFC-1738 database connection string
:param bool echo: Turn on echoing SQL
:param Optional[bool] autoflush: Defaults to True if not specified in kwargs or configuration.
:param Optional[bool] autocommit: Defaults to False if not specified in kwarg... | src/bio2bel/manager/connection_manager.py | def build_engine_session(connection, echo=False, autoflush=None, autocommit=None, expire_on_commit=None,
scopefunc=None):
"""Build an engine and a session.
:param str connection: An RFC-1738 database connection string
:param bool echo: Turn on echoing SQL
:param Optional[bool] ... | def build_engine_session(connection, echo=False, autoflush=None, autocommit=None, expire_on_commit=None,
scopefunc=None):
"""Build an engine and a session.
:param str connection: An RFC-1738 database connection string
:param bool echo: Turn on echoing SQL
:param Optional[bool] ... | [
"Build",
"an",
"engine",
"and",
"a",
"session",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/connection_manager.py#L105-L150 | [
"def",
"build_engine_session",
"(",
"connection",
",",
"echo",
"=",
"False",
",",
"autoflush",
"=",
"None",
",",
"autocommit",
"=",
"None",
",",
"expire_on_commit",
"=",
"None",
",",
"scopefunc",
"=",
"None",
")",
":",
"if",
"connection",
"is",
"None",
":"... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | ConnectionManager._get_connection | Get a default connection string.
Wraps :func:`bio2bel.utils.get_connection` and passing this class's :data:`module_name` to it. | src/bio2bel/manager/connection_manager.py | def _get_connection(cls, connection: Optional[str] = None) -> str:
"""Get a default connection string.
Wraps :func:`bio2bel.utils.get_connection` and passing this class's :data:`module_name` to it.
"""
return get_connection(cls.module_name, connection=connection) | def _get_connection(cls, connection: Optional[str] = None) -> str:
"""Get a default connection string.
Wraps :func:`bio2bel.utils.get_connection` and passing this class's :data:`module_name` to it.
"""
return get_connection(cls.module_name, connection=connection) | [
"Get",
"a",
"default",
"connection",
"string",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/connection_manager.py#L82-L87 | [
"def",
"_get_connection",
"(",
"cls",
",",
"connection",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"str",
":",
"return",
"get_connection",
"(",
"cls",
".",
"module_name",
",",
"connection",
"=",
"connection",
")"
] | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | setup_smtp_factory | expects a dictionary with 'mail.' keys to create an appropriate smtplib.SMTP instance | application/briefkasten/notifications.py | def setup_smtp_factory(**settings):
""" expects a dictionary with 'mail.' keys to create an appropriate smtplib.SMTP instance"""
return CustomSMTP(
host=settings.get('mail.host', 'localhost'),
port=int(settings.get('mail.port', 25)),
user=settings.get('mail.user'),
password=setti... | def setup_smtp_factory(**settings):
""" expects a dictionary with 'mail.' keys to create an appropriate smtplib.SMTP instance"""
return CustomSMTP(
host=settings.get('mail.host', 'localhost'),
port=int(settings.get('mail.port', 25)),
user=settings.get('mail.user'),
password=setti... | [
"expects",
"a",
"dictionary",
"with",
"mail",
".",
"keys",
"to",
"create",
"an",
"appropriate",
"smtplib",
".",
"SMTP",
"instance"
] | ZeitOnline/briefkasten | python | https://github.com/ZeitOnline/briefkasten/blob/ce6b6eeb89196014fe21d68614c20059d02daa11/application/briefkasten/notifications.py#L26-L34 | [
"def",
"setup_smtp_factory",
"(",
"*",
"*",
"settings",
")",
":",
"return",
"CustomSMTP",
"(",
"host",
"=",
"settings",
".",
"get",
"(",
"'mail.host'",
",",
"'localhost'",
")",
",",
"port",
"=",
"int",
"(",
"settings",
".",
"get",
"(",
"'mail.port'",
","... | ce6b6eeb89196014fe21d68614c20059d02daa11 |
valid | sendMultiPart | a helper method that composes and sends an email with attachments
requires a pre-configured smtplib.SMTP instance | application/briefkasten/notifications.py | def sendMultiPart(smtp, gpg_context, sender, recipients, subject, text, attachments):
""" a helper method that composes and sends an email with attachments
requires a pre-configured smtplib.SMTP instance"""
sent = 0
for to in recipients:
if not to.startswith('<'):
uid = '<%s>' % to
... | def sendMultiPart(smtp, gpg_context, sender, recipients, subject, text, attachments):
""" a helper method that composes and sends an email with attachments
requires a pre-configured smtplib.SMTP instance"""
sent = 0
for to in recipients:
if not to.startswith('<'):
uid = '<%s>' % to
... | [
"a",
"helper",
"method",
"that",
"composes",
"and",
"sends",
"an",
"email",
"with",
"attachments",
"requires",
"a",
"pre",
"-",
"configured",
"smtplib",
".",
"SMTP",
"instance"
] | ZeitOnline/briefkasten | python | https://github.com/ZeitOnline/briefkasten/blob/ce6b6eeb89196014fe21d68614c20059d02daa11/application/briefkasten/notifications.py#L44-L83 | [
"def",
"sendMultiPart",
"(",
"smtp",
",",
"gpg_context",
",",
"sender",
",",
"recipients",
",",
"subject",
",",
"text",
",",
"attachments",
")",
":",
"sent",
"=",
"0",
"for",
"to",
"in",
"recipients",
":",
"if",
"not",
"to",
".",
"startswith",
"(",
"'<... | ce6b6eeb89196014fe21d68614c20059d02daa11 |
valid | CustomSMTP.begin | connects and optionally authenticates a connection. | application/briefkasten/notifications.py | def begin(self):
""" connects and optionally authenticates a connection."""
self.connect(self.host, self.port)
if self.user:
self.starttls()
self.login(self.user, self.password) | def begin(self):
""" connects and optionally authenticates a connection."""
self.connect(self.host, self.port)
if self.user:
self.starttls()
self.login(self.user, self.password) | [
"connects",
"and",
"optionally",
"authenticates",
"a",
"connection",
"."
] | ZeitOnline/briefkasten | python | https://github.com/ZeitOnline/briefkasten/blob/ce6b6eeb89196014fe21d68614c20059d02daa11/application/briefkasten/notifications.py#L18-L23 | [
"def",
"begin",
"(",
"self",
")",
":",
"self",
".",
"connect",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
"if",
"self",
".",
"user",
":",
"self",
".",
"starttls",
"(",
")",
"self",
".",
"login",
"(",
"self",
".",
"user",
",",
"sel... | ce6b6eeb89196014fe21d68614c20059d02daa11 |
valid | make_downloader | Make a function that downloads the data for you, or uses a cached version at the given path.
:param url: The URL of some data
:param path: The path of the cached data, or where data is cached if it does not already exist
:return: A function that downloads the data and returns the path of the data | src/bio2bel/downloading.py | def make_downloader(url: str, path: str) -> Callable[[bool], str]: # noqa: D202
"""Make a function that downloads the data for you, or uses a cached version at the given path.
:param url: The URL of some data
:param path: The path of the cached data, or where data is cached if it does not already exist
... | def make_downloader(url: str, path: str) -> Callable[[bool], str]: # noqa: D202
"""Make a function that downloads the data for you, or uses a cached version at the given path.
:param url: The URL of some data
:param path: The path of the cached data, or where data is cached if it does not already exist
... | [
"Make",
"a",
"function",
"that",
"downloads",
"the",
"data",
"for",
"you",
"or",
"uses",
"a",
"cached",
"version",
"at",
"the",
"given",
"path",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/downloading.py#L22-L43 | [
"def",
"make_downloader",
"(",
"url",
":",
"str",
",",
"path",
":",
"str",
")",
"->",
"Callable",
"[",
"[",
"bool",
"]",
",",
"str",
"]",
":",
"# noqa: D202",
"def",
"download_data",
"(",
"force_download",
":",
"bool",
"=",
"False",
")",
"->",
"str",
... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | make_df_getter | Build a function that handles downloading tabular data and parsing it into a pandas DataFrame.
:param data_url: The URL of the data
:param data_path: The path where the data should get stored
:param kwargs: Any other arguments to pass to :func:`pandas.read_csv` | src/bio2bel/downloading.py | def make_df_getter(data_url: str, data_path: str, **kwargs) -> Callable[[Optional[str], bool, bool], pd.DataFrame]:
"""Build a function that handles downloading tabular data and parsing it into a pandas DataFrame.
:param data_url: The URL of the data
:param data_path: The path where the data should get sto... | def make_df_getter(data_url: str, data_path: str, **kwargs) -> Callable[[Optional[str], bool, bool], pd.DataFrame]:
"""Build a function that handles downloading tabular data and parsing it into a pandas DataFrame.
:param data_url: The URL of the data
:param data_path: The path where the data should get sto... | [
"Build",
"a",
"function",
"that",
"handles",
"downloading",
"tabular",
"data",
"and",
"parsing",
"it",
"into",
"a",
"pandas",
"DataFrame",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/downloading.py#L46-L70 | [
"def",
"make_df_getter",
"(",
"data_url",
":",
"str",
",",
"data_path",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"Callable",
"[",
"[",
"Optional",
"[",
"str",
"]",
",",
"bool",
",",
"bool",
"]",
",",
"pd",
".",
"DataFrame",
"]",
":",
"downlo... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | TypedUrnGenerator.generate | Generate a :term:`URI` based on parameters passed.
:param id: The id of the concept or collection.
:param type: What we're generating a :term:`URI` for: `concept`
or `collection`.
:rtype: string | skosprovider/uri.py | def generate(self, **kwargs):
'''
Generate a :term:`URI` based on parameters passed.
:param id: The id of the concept or collection.
:param type: What we're generating a :term:`URI` for: `concept`
or `collection`.
:rtype: string
'''
if kwargs['type'] ... | def generate(self, **kwargs):
'''
Generate a :term:`URI` based on parameters passed.
:param id: The id of the concept or collection.
:param type: What we're generating a :term:`URI` for: `concept`
or `collection`.
:rtype: string
'''
if kwargs['type'] ... | [
"Generate",
"a",
":",
"term",
":",
"URI",
"based",
"on",
"parameters",
"passed",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/uri.py#L115-L128 | [
"def",
"generate",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"[",
"'type'",
"]",
"not",
"in",
"[",
"'concept'",
",",
"'collection'",
"]",
":",
"raise",
"ValueError",
"(",
"'Type %s is invalid'",
"%",
"kwargs",
"[",
"'type'",
"]",
... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | has_address | Determine whether the packet has an "address" encoded into it.
There exists an undocumented bug/edge case in the spec - some packets
with 0x82 as _start_, still encode the address into the packet, and thus
throws off decoding. This edge case is handled explicitly. | nessclient/packet.py | def has_address(start: int, data_length: int) -> bool:
"""
Determine whether the packet has an "address" encoded into it.
There exists an undocumented bug/edge case in the spec - some packets
with 0x82 as _start_, still encode the address into the packet, and thus
throws off decoding. This edge case... | def has_address(start: int, data_length: int) -> bool:
"""
Determine whether the packet has an "address" encoded into it.
There exists an undocumented bug/edge case in the spec - some packets
with 0x82 as _start_, still encode the address into the packet, and thus
throws off decoding. This edge case... | [
"Determine",
"whether",
"the",
"packet",
"has",
"an",
"address",
"encoded",
"into",
"it",
".",
"There",
"exists",
"an",
"undocumented",
"bug",
"/",
"edge",
"case",
"in",
"the",
"spec",
"-",
"some",
"packets",
"with",
"0x82",
"as",
"_start_",
"still",
"enco... | nickw444/nessclient | python | https://github.com/nickw444/nessclient/blob/9a2e3d450448312f56e708b8c7adeaef878cc28a/nessclient/packet.py#L164-L171 | [
"def",
"has_address",
"(",
"start",
":",
"int",
",",
"data_length",
":",
"int",
")",
"->",
"bool",
":",
"return",
"bool",
"(",
"0x01",
"&",
"start",
")",
"or",
"(",
"start",
"==",
"0x82",
"and",
"data_length",
"==",
"16",
")"
] | 9a2e3d450448312f56e708b8c7adeaef878cc28a |
valid | decode_timestamp | Decode timestamp using bespoke decoder.
Cannot use simple strptime since the ness panel contains a bug
that P199E zone and state updates emitted on the hour cause a minute
value of `60` to be sent, causing strptime to fail. This decoder handles
this edge case. | nessclient/packet.py | def decode_timestamp(data: str) -> datetime.datetime:
"""
Decode timestamp using bespoke decoder.
Cannot use simple strptime since the ness panel contains a bug
that P199E zone and state updates emitted on the hour cause a minute
value of `60` to be sent, causing strptime to fail. This decoder handl... | def decode_timestamp(data: str) -> datetime.datetime:
"""
Decode timestamp using bespoke decoder.
Cannot use simple strptime since the ness panel contains a bug
that P199E zone and state updates emitted on the hour cause a minute
value of `60` to be sent, causing strptime to fail. This decoder handl... | [
"Decode",
"timestamp",
"using",
"bespoke",
"decoder",
".",
"Cannot",
"use",
"simple",
"strptime",
"since",
"the",
"ness",
"panel",
"contains",
"a",
"bug",
"that",
"P199E",
"zone",
"and",
"state",
"updates",
"emitted",
"on",
"the",
"hour",
"cause",
"a",
"minu... | nickw444/nessclient | python | https://github.com/nickw444/nessclient/blob/9a2e3d450448312f56e708b8c7adeaef878cc28a/nessclient/packet.py#L186-L205 | [
"def",
"decode_timestamp",
"(",
"data",
":",
"str",
")",
"->",
"datetime",
".",
"datetime",
":",
"year",
"=",
"2000",
"+",
"int",
"(",
"data",
"[",
"0",
":",
"2",
"]",
")",
"month",
"=",
"int",
"(",
"data",
"[",
"2",
":",
"4",
"]",
")",
"day",
... | 9a2e3d450448312f56e708b8c7adeaef878cc28a |
valid | create_application | Create a Flask application. | src/bio2bel/web/application.py | def create_application(connection: Optional[str] = None) -> Flask:
"""Create a Flask application."""
app = Flask(__name__)
flask_bootstrap.Bootstrap(app)
Admin(app)
connection = connection or DEFAULT_CACHE_CONNECTION
engine, session = build_engine_session(connection)
for name, add_admin i... | def create_application(connection: Optional[str] = None) -> Flask:
"""Create a Flask application."""
app = Flask(__name__)
flask_bootstrap.Bootstrap(app)
Admin(app)
connection = connection or DEFAULT_CACHE_CONNECTION
engine, session = build_engine_session(connection)
for name, add_admin i... | [
"Create",
"a",
"Flask",
"application",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/web/application.py#L55-L72 | [
"def",
"create_application",
"(",
"connection",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Flask",
":",
"app",
"=",
"Flask",
"(",
"__name__",
")",
"flask_bootstrap",
".",
"Bootstrap",
"(",
"app",
")",
"Admin",
"(",
"app",
")",
"connection... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | Registry.register_provider | Register a :class:`skosprovider.providers.VocabularyProvider`.
:param skosprovider.providers.VocabularyProvider provider: The provider
to register.
:raises RegistryException: A provider with this id or uri has already
been registered. | skosprovider/registry.py | def register_provider(self, provider):
'''
Register a :class:`skosprovider.providers.VocabularyProvider`.
:param skosprovider.providers.VocabularyProvider provider: The provider
to register.
:raises RegistryException: A provider with this id or uri has already
b... | def register_provider(self, provider):
'''
Register a :class:`skosprovider.providers.VocabularyProvider`.
:param skosprovider.providers.VocabularyProvider provider: The provider
to register.
:raises RegistryException: A provider with this id or uri has already
b... | [
"Register",
"a",
":",
"class",
":",
"skosprovider",
".",
"providers",
".",
"VocabularyProvider",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L37-L55 | [
"def",
"register_provider",
"(",
"self",
",",
"provider",
")",
":",
"if",
"provider",
".",
"get_vocabulary_id",
"(",
")",
"in",
"self",
".",
"providers",
":",
"raise",
"RegistryException",
"(",
"'A provider with this id has already been registered.'",
")",
"self",
"... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | Registry.remove_provider | Remove the provider with the given id or :term:`URI`.
:param str id: The identifier for the provider.
:returns: A :class:`skosprovider.providers.VocabularyProvider` or
`False` if the id is unknown. | skosprovider/registry.py | def remove_provider(self, id):
'''
Remove the provider with the given id or :term:`URI`.
:param str id: The identifier for the provider.
:returns: A :class:`skosprovider.providers.VocabularyProvider` or
`False` if the id is unknown.
'''
if id in self.provider... | def remove_provider(self, id):
'''
Remove the provider with the given id or :term:`URI`.
:param str id: The identifier for the provider.
:returns: A :class:`skosprovider.providers.VocabularyProvider` or
`False` if the id is unknown.
'''
if id in self.provider... | [
"Remove",
"the",
"provider",
"with",
"the",
"given",
"id",
"or",
":",
"term",
":",
"URI",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L57-L74 | [
"def",
"remove_provider",
"(",
"self",
",",
"id",
")",
":",
"if",
"id",
"in",
"self",
".",
"providers",
":",
"p",
"=",
"self",
".",
"providers",
".",
"get",
"(",
"id",
",",
"False",
")",
"del",
"self",
".",
"providers",
"[",
"id",
"]",
"del",
"se... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | Registry.get_provider | Get a provider by id or :term:`uri`.
:param str id: The identifier for the provider. This can either be the
id with which it was registered or the :term:`uri` of the conceptscheme
that the provider services.
:returns: A :class:`skosprovider.providers.VocabularyProvider`
... | skosprovider/registry.py | def get_provider(self, id):
'''
Get a provider by id or :term:`uri`.
:param str id: The identifier for the provider. This can either be the
id with which it was registered or the :term:`uri` of the conceptscheme
that the provider services.
:returns: A :class:`sko... | def get_provider(self, id):
'''
Get a provider by id or :term:`uri`.
:param str id: The identifier for the provider. This can either be the
id with which it was registered or the :term:`uri` of the conceptscheme
that the provider services.
:returns: A :class:`sko... | [
"Get",
"a",
"provider",
"by",
"id",
"or",
":",
"term",
":",
"uri",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L76-L90 | [
"def",
"get_provider",
"(",
"self",
",",
"id",
")",
":",
"if",
"id",
"in",
"self",
".",
"providers",
":",
"return",
"self",
".",
"providers",
".",
"get",
"(",
"id",
",",
"False",
")",
"elif",
"is_uri",
"(",
"id",
")",
"and",
"id",
"in",
"self",
"... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | Registry.get_providers | Get all providers registered.
If keyword `ids` is present, get only the providers with these ids.
If keys `subject` is present, get only the providers that have this subject.
.. code-block:: python
# Get all providers with subject 'biology'
registry.get_providers(subjec... | skosprovider/registry.py | def get_providers(self, **kwargs):
'''Get all providers registered.
If keyword `ids` is present, get only the providers with these ids.
If keys `subject` is present, get only the providers that have this subject.
.. code-block:: python
# Get all providers with subject 'bio... | def get_providers(self, **kwargs):
'''Get all providers registered.
If keyword `ids` is present, get only the providers with these ids.
If keys `subject` is present, get only the providers that have this subject.
.. code-block:: python
# Get all providers with subject 'bio... | [
"Get",
"all",
"providers",
"registered",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L92-L123 | [
"def",
"get_providers",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'ids'",
"in",
"kwargs",
":",
"ids",
"=",
"[",
"self",
".",
"concept_scheme_uri_map",
".",
"get",
"(",
"id",
",",
"id",
")",
"for",
"id",
"in",
"kwargs",
"[",
"'ids'",
"]... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | Registry.find | Launch a query across all or a selection of providers.
.. code-block:: python
# Find anything that has a label of church in any provider.
registry.find({'label': 'church'})
# Find anything that has a label of church with the BUILDINGS provider.
# Attention, thi... | skosprovider/registry.py | def find(self, query, **kwargs):
'''Launch a query across all or a selection of providers.
.. code-block:: python
# Find anything that has a label of church in any provider.
registry.find({'label': 'church'})
# Find anything that has a label of church with the BUIL... | def find(self, query, **kwargs):
'''Launch a query across all or a selection of providers.
.. code-block:: python
# Find anything that has a label of church in any provider.
registry.find({'label': 'church'})
# Find anything that has a label of church with the BUIL... | [
"Launch",
"a",
"query",
"across",
"all",
"or",
"a",
"selection",
"of",
"providers",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L125-L175 | [
"def",
"find",
"(",
"self",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'providers'",
"not",
"in",
"kwargs",
":",
"providers",
"=",
"self",
".",
"get_providers",
"(",
")",
"else",
":",
"pargs",
"=",
"kwargs",
"[",
"'providers'",
"]",
"if"... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | Registry.get_all | Get all concepts from all providers.
.. code-block:: python
# get all concepts in all providers.
registry.get_all()
# get all concepts in all providers.
# If possible, display the results with a Dutch label.
registry.get_all(language='nl')
... | skosprovider/registry.py | def get_all(self, **kwargs):
'''Get all concepts from all providers.
.. code-block:: python
# get all concepts in all providers.
registry.get_all()
# get all concepts in all providers.
# If possible, display the results with a Dutch label.
r... | def get_all(self, **kwargs):
'''Get all concepts from all providers.
.. code-block:: python
# get all concepts in all providers.
registry.get_all()
# get all concepts in all providers.
# If possible, display the results with a Dutch label.
r... | [
"Get",
"all",
"concepts",
"from",
"all",
"providers",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L177-L201 | [
"def",
"get_all",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwarguments",
"=",
"{",
"}",
"if",
"'language'",
"in",
"kwargs",
":",
"kwarguments",
"[",
"'language'",
"]",
"=",
"kwargs",
"[",
"'language'",
"]",
"return",
"[",
"{",
"'id'",
":",
"p... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | Registry.get_by_uri | Get a concept or collection by its uri.
Returns a single concept or collection if one exists with this uri.
Returns False otherwise.
:param string uri: The uri to find a concept or collection for.
:raises ValueError: The uri is invalid.
:rtype: :class:`skosprovider.skos.Concept... | skosprovider/registry.py | def get_by_uri(self, uri):
'''Get a concept or collection by its uri.
Returns a single concept or collection if one exists with this uri.
Returns False otherwise.
:param string uri: The uri to find a concept or collection for.
:raises ValueError: The uri is invalid.
:rt... | def get_by_uri(self, uri):
'''Get a concept or collection by its uri.
Returns a single concept or collection if one exists with this uri.
Returns False otherwise.
:param string uri: The uri to find a concept or collection for.
:raises ValueError: The uri is invalid.
:rt... | [
"Get",
"a",
"concept",
"or",
"collection",
"by",
"its",
"uri",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L203-L227 | [
"def",
"get_by_uri",
"(",
"self",
",",
"uri",
")",
":",
"if",
"not",
"is_uri",
"(",
"uri",
")",
":",
"raise",
"ValueError",
"(",
"'%s is not a valid URI.'",
"%",
"uri",
")",
"# Check if there's a provider that's more likely to have the URI",
"csuris",
"=",
"[",
"c... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | ExtensionImporter.find_module | Find a module if its name starts with :code:`self.group` and is registered. | src/bio2bel/exthook.py | def find_module(self, fullname, path=None):
"""Find a module if its name starts with :code:`self.group` and is registered."""
if not fullname.startswith(self._group_with_dot):
return
end_name = fullname[len(self._group_with_dot):]
for entry_point in iter_entry_points(group=se... | def find_module(self, fullname, path=None):
"""Find a module if its name starts with :code:`self.group` and is registered."""
if not fullname.startswith(self._group_with_dot):
return
end_name = fullname[len(self._group_with_dot):]
for entry_point in iter_entry_points(group=se... | [
"Find",
"a",
"module",
"if",
"its",
"name",
"starts",
"with",
":",
"code",
":",
"self",
".",
"group",
"and",
"is",
"registered",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/exthook.py#L35-L42 | [
"def",
"find_module",
"(",
"self",
",",
"fullname",
",",
"path",
"=",
"None",
")",
":",
"if",
"not",
"fullname",
".",
"startswith",
"(",
"self",
".",
"_group_with_dot",
")",
":",
"return",
"end_name",
"=",
"fullname",
"[",
"len",
"(",
"self",
".",
"_gr... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | ExtensionImporter.load_module | Load a module if its name starts with :code:`self.group` and is registered. | src/bio2bel/exthook.py | def load_module(self, fullname):
"""Load a module if its name starts with :code:`self.group` and is registered."""
if fullname in sys.modules:
return sys.modules[fullname]
end_name = fullname[len(self._group_with_dot):]
for entry_point in iter_entry_points(group=self.group, n... | def load_module(self, fullname):
"""Load a module if its name starts with :code:`self.group` and is registered."""
if fullname in sys.modules:
return sys.modules[fullname]
end_name = fullname[len(self._group_with_dot):]
for entry_point in iter_entry_points(group=self.group, n... | [
"Load",
"a",
"module",
"if",
"its",
"name",
"starts",
"with",
":",
"code",
":",
"self",
".",
"group",
"and",
"is",
"registered",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/exthook.py#L44-L52 | [
"def",
"load_module",
"(",
"self",
",",
"fullname",
")",
":",
"if",
"fullname",
"in",
"sys",
".",
"modules",
":",
"return",
"sys",
".",
"modules",
"[",
"fullname",
"]",
"end_name",
"=",
"fullname",
"[",
"len",
"(",
"self",
".",
"_group_with_dot",
")",
... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | upload_theme | upload and/or update the theme with the current git state | deployment/appserver.py | def upload_theme():
""" upload and/or update the theme with the current git state"""
get_vars()
with fab.settings():
local_theme_path = path.abspath(
path.join(fab.env['config_base'],
fab.env.instance.config['local_theme_path']))
rsync(
'-av',
... | def upload_theme():
""" upload and/or update the theme with the current git state"""
get_vars()
with fab.settings():
local_theme_path = path.abspath(
path.join(fab.env['config_base'],
fab.env.instance.config['local_theme_path']))
rsync(
'-av',
... | [
"upload",
"and",
"/",
"or",
"update",
"the",
"theme",
"with",
"the",
"current",
"git",
"state"
] | ZeitOnline/briefkasten | python | https://github.com/ZeitOnline/briefkasten/blob/ce6b6eeb89196014fe21d68614c20059d02daa11/deployment/appserver.py#L25-L38 | [
"def",
"upload_theme",
"(",
")",
":",
"get_vars",
"(",
")",
"with",
"fab",
".",
"settings",
"(",
")",
":",
"local_theme_path",
"=",
"path",
".",
"abspath",
"(",
"path",
".",
"join",
"(",
"fab",
".",
"env",
"[",
"'config_base'",
"]",
",",
"fab",
".",
... | ce6b6eeb89196014fe21d68614c20059d02daa11 |
valid | upload_pgp_keys | upload and/or update the PGP keys for editors, import them into PGP | deployment/appserver.py | def upload_pgp_keys():
""" upload and/or update the PGP keys for editors, import them into PGP"""
get_vars()
upload_target = '/tmp/pgp_pubkeys.tmp'
with fab.settings(fab.hide('running')):
fab.run('rm -rf %s' % upload_target)
fab.run('mkdir %s' % upload_target)
local_key_path = pa... | def upload_pgp_keys():
""" upload and/or update the PGP keys for editors, import them into PGP"""
get_vars()
upload_target = '/tmp/pgp_pubkeys.tmp'
with fab.settings(fab.hide('running')):
fab.run('rm -rf %s' % upload_target)
fab.run('mkdir %s' % upload_target)
local_key_path = pa... | [
"upload",
"and",
"/",
"or",
"update",
"the",
"PGP",
"keys",
"for",
"editors",
"import",
"them",
"into",
"PGP"
] | ZeitOnline/briefkasten | python | https://github.com/ZeitOnline/briefkasten/blob/ce6b6eeb89196014fe21d68614c20059d02daa11/deployment/appserver.py#L42-L57 | [
"def",
"upload_pgp_keys",
"(",
")",
":",
"get_vars",
"(",
")",
"upload_target",
"=",
"'/tmp/pgp_pubkeys.tmp'",
"with",
"fab",
".",
"settings",
"(",
"fab",
".",
"hide",
"(",
"'running'",
")",
")",
":",
"fab",
".",
"run",
"(",
"'rm -rf %s'",
"%",
"upload_tar... | ce6b6eeb89196014fe21d68614c20059d02daa11 |
valid | upload_backend | Build the backend and upload it to the remote server at the given index | deployment/appserver.py | def upload_backend(index='dev', user=None):
"""
Build the backend and upload it to the remote server at the given index
"""
get_vars()
use_devpi(index=index)
with fab.lcd('../application'):
fab.local('make upload') | def upload_backend(index='dev', user=None):
"""
Build the backend and upload it to the remote server at the given index
"""
get_vars()
use_devpi(index=index)
with fab.lcd('../application'):
fab.local('make upload') | [
"Build",
"the",
"backend",
"and",
"upload",
"it",
"to",
"the",
"remote",
"server",
"at",
"the",
"given",
"index"
] | ZeitOnline/briefkasten | python | https://github.com/ZeitOnline/briefkasten/blob/ce6b6eeb89196014fe21d68614c20059d02daa11/deployment/appserver.py#L61-L68 | [
"def",
"upload_backend",
"(",
"index",
"=",
"'dev'",
",",
"user",
"=",
"None",
")",
":",
"get_vars",
"(",
")",
"use_devpi",
"(",
"index",
"=",
"index",
")",
"with",
"fab",
".",
"lcd",
"(",
"'../application'",
")",
":",
"fab",
".",
"local",
"(",
"'mak... | ce6b6eeb89196014fe21d68614c20059d02daa11 |
valid | update_backend | Install the backend from the given devpi index at the given version on the target host and restart the service.
If version is None, it defaults to the latest version
Optionally, build and upload the application first from local sources. This requires a
full backend development environment on the machine r... | deployment/appserver.py | def update_backend(use_pypi=False, index='dev', build=True, user=None, version=None):
"""
Install the backend from the given devpi index at the given version on the target host and restart the service.
If version is None, it defaults to the latest version
Optionally, build and upload the application f... | def update_backend(use_pypi=False, index='dev', build=True, user=None, version=None):
"""
Install the backend from the given devpi index at the given version on the target host and restart the service.
If version is None, it defaults to the latest version
Optionally, build and upload the application f... | [
"Install",
"the",
"backend",
"from",
"the",
"given",
"devpi",
"index",
"at",
"the",
"given",
"version",
"on",
"the",
"target",
"host",
"and",
"restart",
"the",
"service",
"."
] | ZeitOnline/briefkasten | python | https://github.com/ZeitOnline/briefkasten/blob/ce6b6eeb89196014fe21d68614c20059d02daa11/deployment/appserver.py#L84-L108 | [
"def",
"update_backend",
"(",
"use_pypi",
"=",
"False",
",",
"index",
"=",
"'dev'",
",",
"build",
"=",
"True",
",",
"user",
"=",
"None",
",",
"version",
"=",
"None",
")",
":",
"get_vars",
"(",
")",
"if",
"value_asbool",
"(",
"build",
")",
":",
"uploa... | ce6b6eeb89196014fe21d68614c20059d02daa11 |
valid | VocabularyProvider._sort | Returns a sorted version of a list of concepts. Will leave the original
list unsorted.
:param list concepts: A list of concepts and collections.
:param string sort: What to sort on: `id`, `label` or `sortlabel`
:param string language: Language to use when sorting on `label` or
... | skosprovider/providers.py | def _sort(self, concepts, sort=None, language='any', reverse=False):
'''
Returns a sorted version of a list of concepts. Will leave the original
list unsorted.
:param list concepts: A list of concepts and collections.
:param string sort: What to sort on: `id`, `label` or `sortla... | def _sort(self, concepts, sort=None, language='any', reverse=False):
'''
Returns a sorted version of a list of concepts. Will leave the original
list unsorted.
:param list concepts: A list of concepts and collections.
:param string sort: What to sort on: `id`, `label` or `sortla... | [
"Returns",
"a",
"sorted",
"version",
"of",
"a",
"list",
"of",
"concepts",
".",
"Will",
"leave",
"the",
"original",
"list",
"unsorted",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/providers.py#L121-L136 | [
"def",
"_sort",
"(",
"self",
",",
"concepts",
",",
"sort",
"=",
"None",
",",
"language",
"=",
"'any'",
",",
"reverse",
"=",
"False",
")",
":",
"sorted",
"=",
"copy",
".",
"copy",
"(",
"concepts",
")",
"if",
"sort",
":",
"sorted",
".",
"sort",
"(",
... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | MemoryProvider._include_in_find | :param c: A :class:`skosprovider.skos.Concept` or
:class:`skosprovider.skos.Collection`.
:param query: A dict that can be used to express a query.
:rtype: boolean | skosprovider/providers.py | def _include_in_find(self, c, query):
'''
:param c: A :class:`skosprovider.skos.Concept` or
:class:`skosprovider.skos.Collection`.
:param query: A dict that can be used to express a query.
:rtype: boolean
'''
include = True
if include and 'type' in que... | def _include_in_find(self, c, query):
'''
:param c: A :class:`skosprovider.skos.Concept` or
:class:`skosprovider.skos.Collection`.
:param query: A dict that can be used to express a query.
:rtype: boolean
'''
include = True
if include and 'type' in que... | [
":",
"param",
"c",
":",
"A",
":",
"class",
":",
"skosprovider",
".",
"skos",
".",
"Concept",
"or",
":",
"class",
":",
"skosprovider",
".",
"skos",
".",
"Collection",
".",
":",
"param",
"query",
":",
"A",
"dict",
"that",
"can",
"be",
"used",
"to",
"... | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/providers.py#L458-L486 | [
"def",
"_include_in_find",
"(",
"self",
",",
"c",
",",
"query",
")",
":",
"include",
"=",
"True",
"if",
"include",
"and",
"'type'",
"in",
"query",
":",
"include",
"=",
"query",
"[",
"'type'",
"]",
"==",
"c",
".",
"type",
"if",
"include",
"and",
"'lab... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | MemoryProvider._get_find_dict | Return a dict that can be used in the return list of the :meth:`find`
method.
:param c: A :class:`skosprovider.skos.Concept` or
:class:`skosprovider.skos.Collection`.
:rtype: dict | skosprovider/providers.py | def _get_find_dict(self, c, **kwargs):
'''
Return a dict that can be used in the return list of the :meth:`find`
method.
:param c: A :class:`skosprovider.skos.Concept` or
:class:`skosprovider.skos.Collection`.
:rtype: dict
'''
language = self._get_lan... | def _get_find_dict(self, c, **kwargs):
'''
Return a dict that can be used in the return list of the :meth:`find`
method.
:param c: A :class:`skosprovider.skos.Concept` or
:class:`skosprovider.skos.Collection`.
:rtype: dict
'''
language = self._get_lan... | [
"Return",
"a",
"dict",
"that",
"can",
"be",
"used",
"in",
"the",
"return",
"list",
"of",
"the",
":",
"meth",
":",
"find",
"method",
"."
] | koenedaele/skosprovider | python | https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/providers.py#L488-L503 | [
"def",
"_get_find_dict",
"(",
"self",
",",
"c",
",",
"*",
"*",
"kwargs",
")",
":",
"language",
"=",
"self",
".",
"_get_language",
"(",
"*",
"*",
"kwargs",
")",
"return",
"{",
"'id'",
":",
"c",
".",
"id",
",",
"'uri'",
":",
"c",
".",
"uri",
",",
... | 7304a37953978ca8227febc2d3cc2b2be178f215 |
valid | Client.update | Force update of alarm status and zones | nessclient/client.py | async def update(self) -> None:
"""Force update of alarm status and zones"""
_LOGGER.debug("Requesting state update from server (S00, S14)")
await asyncio.gather(
# List unsealed Zones
self.send_command('S00'),
# Arming status update
self.send_comm... | async def update(self) -> None:
"""Force update of alarm status and zones"""
_LOGGER.debug("Requesting state update from server (S00, S14)")
await asyncio.gather(
# List unsealed Zones
self.send_command('S00'),
# Arming status update
self.send_comm... | [
"Force",
"update",
"of",
"alarm",
"status",
"and",
"zones"
] | nickw444/nessclient | python | https://github.com/nickw444/nessclient/blob/9a2e3d450448312f56e708b8c7adeaef878cc28a/nessclient/client.py#L73-L81 | [
"async",
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Requesting state update from server (S00, S14)\"",
")",
"await",
"asyncio",
".",
"gather",
"(",
"# List unsealed Zones",
"self",
".",
"send_command",
"(",
"'S00'",
")",... | 9a2e3d450448312f56e708b8c7adeaef878cc28a |
valid | Client._update_loop | Schedule a state update to keep the connection alive | nessclient/client.py | async def _update_loop(self) -> None:
"""Schedule a state update to keep the connection alive"""
await asyncio.sleep(self._update_interval)
while not self._closed:
await self.update()
await asyncio.sleep(self._update_interval) | async def _update_loop(self) -> None:
"""Schedule a state update to keep the connection alive"""
await asyncio.sleep(self._update_interval)
while not self._closed:
await self.update()
await asyncio.sleep(self._update_interval) | [
"Schedule",
"a",
"state",
"update",
"to",
"keep",
"the",
"connection",
"alive"
] | nickw444/nessclient | python | https://github.com/nickw444/nessclient/blob/9a2e3d450448312f56e708b8c7adeaef878cc28a/nessclient/client.py#L150-L155 | [
"async",
"def",
"_update_loop",
"(",
"self",
")",
"->",
"None",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"self",
".",
"_update_interval",
")",
"while",
"not",
"self",
".",
"_closed",
":",
"await",
"self",
".",
"update",
"(",
")",
"await",
"asyncio",
... | 9a2e3d450448312f56e708b8c7adeaef878cc28a |
valid | add_cli_to_bel_namespace | Add a ``upload_bel_namespace`` command to main :mod:`click` function. | src/bio2bel/manager/namespace_manager.py | def add_cli_to_bel_namespace(main: click.Group) -> click.Group: # noqa: D202
"""Add a ``upload_bel_namespace`` command to main :mod:`click` function."""
@main.command()
@click.option('-u', '--update', is_flag=True)
@click.pass_obj
def upload(manager: BELNamespaceManagerMixin, update):
"""U... | def add_cli_to_bel_namespace(main: click.Group) -> click.Group: # noqa: D202
"""Add a ``upload_bel_namespace`` command to main :mod:`click` function."""
@main.command()
@click.option('-u', '--update', is_flag=True)
@click.pass_obj
def upload(manager: BELNamespaceManagerMixin, update):
"""U... | [
"Add",
"a",
"upload_bel_namespace",
"command",
"to",
"main",
":",
"mod",
":",
"click",
"function",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L493-L504 | [
"def",
"add_cli_to_bel_namespace",
"(",
"main",
":",
"click",
".",
"Group",
")",
"->",
"click",
".",
"Group",
":",
"# noqa: D202",
"@",
"main",
".",
"command",
"(",
")",
"@",
"click",
".",
"option",
"(",
"'-u'",
",",
"'--update'",
",",
"is_flag",
"=",
... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | add_cli_clear_bel_namespace | Add a ``clear_bel_namespace`` command to main :mod:`click` function. | src/bio2bel/manager/namespace_manager.py | def add_cli_clear_bel_namespace(main: click.Group) -> click.Group: # noqa: D202
"""Add a ``clear_bel_namespace`` command to main :mod:`click` function."""
@main.command()
@click.pass_obj
def drop(manager: BELNamespaceManagerMixin):
"""Clear names/identifiers to terminology store."""
na... | def add_cli_clear_bel_namespace(main: click.Group) -> click.Group: # noqa: D202
"""Add a ``clear_bel_namespace`` command to main :mod:`click` function."""
@main.command()
@click.pass_obj
def drop(manager: BELNamespaceManagerMixin):
"""Clear names/identifiers to terminology store."""
na... | [
"Add",
"a",
"clear_bel_namespace",
"command",
"to",
"main",
":",
"mod",
":",
"click",
"function",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L507-L519 | [
"def",
"add_cli_clear_bel_namespace",
"(",
"main",
":",
"click",
".",
"Group",
")",
"->",
"click",
".",
"Group",
":",
"# noqa: D202",
"@",
"main",
".",
"command",
"(",
")",
"@",
"click",
".",
"pass_obj",
"def",
"drop",
"(",
"manager",
":",
"BELNamespaceMan... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | add_cli_write_bel_namespace | Add a ``write_bel_namespace`` command to main :mod:`click` function. | src/bio2bel/manager/namespace_manager.py | def add_cli_write_bel_namespace(main: click.Group) -> click.Group: # noqa: D202
"""Add a ``write_bel_namespace`` command to main :mod:`click` function."""
@main.command()
@click.option('-d', '--directory', type=click.Path(file_okay=False, dir_okay=True), default=os.getcwd(),
help='output... | def add_cli_write_bel_namespace(main: click.Group) -> click.Group: # noqa: D202
"""Add a ``write_bel_namespace`` command to main :mod:`click` function."""
@main.command()
@click.option('-d', '--directory', type=click.Path(file_okay=False, dir_okay=True), default=os.getcwd(),
help='output... | [
"Add",
"a",
"write_bel_namespace",
"command",
"to",
"main",
":",
"mod",
":",
"click",
"function",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L522-L533 | [
"def",
"add_cli_write_bel_namespace",
"(",
"main",
":",
"click",
".",
"Group",
")",
"->",
"click",
".",
"Group",
":",
"# noqa: D202",
"@",
"main",
".",
"command",
"(",
")",
"@",
"click",
".",
"option",
"(",
"'-d'",
",",
"'--directory'",
",",
"type",
"=",... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | add_cli_write_bel_annotation | Add a ``write_bel_annotation`` command to main :mod:`click` function. | src/bio2bel/manager/namespace_manager.py | def add_cli_write_bel_annotation(main: click.Group) -> click.Group: # noqa: D202
"""Add a ``write_bel_annotation`` command to main :mod:`click` function."""
@main.command()
@click.option('-d', '--directory', type=click.Path(file_okay=False, dir_okay=True), default=os.getcwd(),
help='outp... | def add_cli_write_bel_annotation(main: click.Group) -> click.Group: # noqa: D202
"""Add a ``write_bel_annotation`` command to main :mod:`click` function."""
@main.command()
@click.option('-d', '--directory', type=click.Path(file_okay=False, dir_okay=True), default=os.getcwd(),
help='outp... | [
"Add",
"a",
"write_bel_annotation",
"command",
"to",
"main",
":",
"mod",
":",
"click",
"function",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L536-L548 | [
"def",
"add_cli_write_bel_annotation",
"(",
"main",
":",
"click",
".",
"Group",
")",
"->",
"click",
".",
"Group",
":",
"# noqa: D202",
"@",
"main",
".",
"command",
"(",
")",
"@",
"click",
".",
"option",
"(",
"'-d'",
",",
"'--directory'",
",",
"type",
"="... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | BELNamespaceManagerMixin._iterate_namespace_models | Return an iterator over the models to be converted to the namespace. | src/bio2bel/manager/namespace_manager.py | def _iterate_namespace_models(self, **kwargs) -> Iterable:
"""Return an iterator over the models to be converted to the namespace."""
return tqdm(
self._get_query(self.namespace_model),
total=self._count_model(self.namespace_model),
**kwargs
) | def _iterate_namespace_models(self, **kwargs) -> Iterable:
"""Return an iterator over the models to be converted to the namespace."""
return tqdm(
self._get_query(self.namespace_model),
total=self._count_model(self.namespace_model),
**kwargs
) | [
"Return",
"an",
"iterator",
"over",
"the",
"models",
"to",
"be",
"converted",
"to",
"the",
"namespace",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L203-L209 | [
"def",
"_iterate_namespace_models",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"Iterable",
":",
"return",
"tqdm",
"(",
"self",
".",
"_get_query",
"(",
"self",
".",
"namespace_model",
")",
",",
"total",
"=",
"self",
".",
"_count_model",
"(",
"self",
... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | BELNamespaceManagerMixin._get_default_namespace | Get the reference BEL namespace if it exists. | src/bio2bel/manager/namespace_manager.py | def _get_default_namespace(self) -> Optional[Namespace]:
"""Get the reference BEL namespace if it exists."""
return self._get_query(Namespace).filter(Namespace.url == self._get_namespace_url()).one_or_none() | def _get_default_namespace(self) -> Optional[Namespace]:
"""Get the reference BEL namespace if it exists."""
return self._get_query(Namespace).filter(Namespace.url == self._get_namespace_url()).one_or_none() | [
"Get",
"the",
"reference",
"BEL",
"namespace",
"if",
"it",
"exists",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L226-L228 | [
"def",
"_get_default_namespace",
"(",
"self",
")",
"->",
"Optional",
"[",
"Namespace",
"]",
":",
"return",
"self",
".",
"_get_query",
"(",
"Namespace",
")",
".",
"filter",
"(",
"Namespace",
".",
"url",
"==",
"self",
".",
"_get_namespace_url",
"(",
")",
")"... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | BELNamespaceManagerMixin._make_namespace | Make a namespace. | src/bio2bel/manager/namespace_manager.py | def _make_namespace(self) -> Namespace:
"""Make a namespace."""
namespace = Namespace(
name=self._get_namespace_name(),
keyword=self._get_namespace_keyword(),
url=self._get_namespace_url(),
version=str(time.asctime()),
)
self.session.add(na... | def _make_namespace(self) -> Namespace:
"""Make a namespace."""
namespace = Namespace(
name=self._get_namespace_name(),
keyword=self._get_namespace_keyword(),
url=self._get_namespace_url(),
version=str(time.asctime()),
)
self.session.add(na... | [
"Make",
"a",
"namespace",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L240-L258 | [
"def",
"_make_namespace",
"(",
"self",
")",
"->",
"Namespace",
":",
"namespace",
"=",
"Namespace",
"(",
"name",
"=",
"self",
".",
"_get_namespace_name",
"(",
")",
",",
"keyword",
"=",
"self",
".",
"_get_namespace_keyword",
"(",
")",
",",
"url",
"=",
"self"... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | BELNamespaceManagerMixin._get_old_entry_identifiers | Convert a PyBEL generalized namespace entries to a set.
Default to using the identifier, but can be overridden to use the name instead.
>>> {term.identifier for term in namespace.entries} | src/bio2bel/manager/namespace_manager.py | def _get_old_entry_identifiers(namespace: Namespace) -> Set[NamespaceEntry]:
"""Convert a PyBEL generalized namespace entries to a set.
Default to using the identifier, but can be overridden to use the name instead.
>>> {term.identifier for term in namespace.entries}
"""
return... | def _get_old_entry_identifiers(namespace: Namespace) -> Set[NamespaceEntry]:
"""Convert a PyBEL generalized namespace entries to a set.
Default to using the identifier, but can be overridden to use the name instead.
>>> {term.identifier for term in namespace.entries}
"""
return... | [
"Convert",
"a",
"PyBEL",
"generalized",
"namespace",
"entries",
"to",
"a",
"set",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L261-L268 | [
"def",
"_get_old_entry_identifiers",
"(",
"namespace",
":",
"Namespace",
")",
"->",
"Set",
"[",
"NamespaceEntry",
"]",
":",
"return",
"{",
"term",
".",
"identifier",
"for",
"term",
"in",
"namespace",
".",
"entries",
"}"
] | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | BELNamespaceManagerMixin._update_namespace | Update an already-created namespace.
Note: Only call this if namespace won't be none! | src/bio2bel/manager/namespace_manager.py | def _update_namespace(self, namespace: Namespace) -> None:
"""Update an already-created namespace.
Note: Only call this if namespace won't be none!
"""
old_entry_identifiers = self._get_old_entry_identifiers(namespace)
new_count = 0
skip_count = 0
for model in s... | def _update_namespace(self, namespace: Namespace) -> None:
"""Update an already-created namespace.
Note: Only call this if namespace won't be none!
"""
old_entry_identifiers = self._get_old_entry_identifiers(namespace)
new_count = 0
skip_count = 0
for model in s... | [
"Update",
"an",
"already",
"-",
"created",
"namespace",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L270-L294 | [
"def",
"_update_namespace",
"(",
"self",
",",
"namespace",
":",
"Namespace",
")",
"->",
"None",
":",
"old_entry_identifiers",
"=",
"self",
".",
"_get_old_entry_identifiers",
"(",
"namespace",
")",
"new_count",
"=",
"0",
"skip_count",
"=",
"0",
"for",
"model",
... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | BELNamespaceManagerMixin.add_namespace_to_graph | Add this manager's namespace to the graph. | src/bio2bel/manager/namespace_manager.py | def add_namespace_to_graph(self, graph: BELGraph) -> Namespace:
"""Add this manager's namespace to the graph."""
namespace = self.upload_bel_namespace()
graph.namespace_url[namespace.keyword] = namespace.url
# Add this manager as an annotation, too
self._add_annotation_to_graph(... | def add_namespace_to_graph(self, graph: BELGraph) -> Namespace:
"""Add this manager's namespace to the graph."""
namespace = self.upload_bel_namespace()
graph.namespace_url[namespace.keyword] = namespace.url
# Add this manager as an annotation, too
self._add_annotation_to_graph(... | [
"Add",
"this",
"manager",
"s",
"namespace",
"to",
"the",
"graph",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L296-L304 | [
"def",
"add_namespace_to_graph",
"(",
"self",
",",
"graph",
":",
"BELGraph",
")",
"->",
"Namespace",
":",
"namespace",
"=",
"self",
".",
"upload_bel_namespace",
"(",
")",
"graph",
".",
"namespace_url",
"[",
"namespace",
".",
"keyword",
"]",
"=",
"namespace",
... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | BELNamespaceManagerMixin._add_annotation_to_graph | Add this manager as an annotation to the graph. | src/bio2bel/manager/namespace_manager.py | def _add_annotation_to_graph(self, graph: BELGraph) -> None:
"""Add this manager as an annotation to the graph."""
if 'bio2bel' not in graph.annotation_list:
graph.annotation_list['bio2bel'] = set()
graph.annotation_list['bio2bel'].add(self.module_name) | def _add_annotation_to_graph(self, graph: BELGraph) -> None:
"""Add this manager as an annotation to the graph."""
if 'bio2bel' not in graph.annotation_list:
graph.annotation_list['bio2bel'] = set()
graph.annotation_list['bio2bel'].add(self.module_name) | [
"Add",
"this",
"manager",
"as",
"an",
"annotation",
"to",
"the",
"graph",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L306-L311 | [
"def",
"_add_annotation_to_graph",
"(",
"self",
",",
"graph",
":",
"BELGraph",
")",
"->",
"None",
":",
"if",
"'bio2bel'",
"not",
"in",
"graph",
".",
"annotation_list",
":",
"graph",
".",
"annotation_list",
"[",
"'bio2bel'",
"]",
"=",
"set",
"(",
")",
"grap... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | BELNamespaceManagerMixin.upload_bel_namespace | Upload the namespace to the PyBEL database.
:param update: Should the namespace be updated first? | src/bio2bel/manager/namespace_manager.py | def upload_bel_namespace(self, update: bool = False) -> Namespace:
"""Upload the namespace to the PyBEL database.
:param update: Should the namespace be updated first?
"""
if not self.is_populated():
self.populate()
namespace = self._get_default_namespace()
... | def upload_bel_namespace(self, update: bool = False) -> Namespace:
"""Upload the namespace to the PyBEL database.
:param update: Should the namespace be updated first?
"""
if not self.is_populated():
self.populate()
namespace = self._get_default_namespace()
... | [
"Upload",
"the",
"namespace",
"to",
"the",
"PyBEL",
"database",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L313-L330 | [
"def",
"upload_bel_namespace",
"(",
"self",
",",
"update",
":",
"bool",
"=",
"False",
")",
"->",
"Namespace",
":",
"if",
"not",
"self",
".",
"is_populated",
"(",
")",
":",
"self",
".",
"populate",
"(",
")",
"namespace",
"=",
"self",
".",
"_get_default_na... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
valid | BELNamespaceManagerMixin.drop_bel_namespace | Remove the default namespace if it exists. | src/bio2bel/manager/namespace_manager.py | def drop_bel_namespace(self) -> Optional[Namespace]:
"""Remove the default namespace if it exists."""
namespace = self._get_default_namespace()
if namespace is not None:
for entry in tqdm(namespace.entries, desc=f'deleting entries in {self._get_namespace_name()}'):
s... | def drop_bel_namespace(self) -> Optional[Namespace]:
"""Remove the default namespace if it exists."""
namespace = self._get_default_namespace()
if namespace is not None:
for entry in tqdm(namespace.entries, desc=f'deleting entries in {self._get_namespace_name()}'):
s... | [
"Remove",
"the",
"default",
"namespace",
"if",
"it",
"exists",
"."
] | bio2bel/bio2bel | python | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L332-L343 | [
"def",
"drop_bel_namespace",
"(",
"self",
")",
"->",
"Optional",
"[",
"Namespace",
"]",
":",
"namespace",
"=",
"self",
".",
"_get_default_namespace",
"(",
")",
"if",
"namespace",
"is",
"not",
"None",
":",
"for",
"entry",
"in",
"tqdm",
"(",
"namespace",
"."... | d80762d891fa18b248709ff0b0f97ebb65ec64c2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.