id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
45,500 | andrenarchy/krypy | krypy/utils.py | norm_squared | def norm_squared(x, Mx=None, inner_product=ip_euclid):
'''Compute the norm^2 w.r.t. to a given scalar product.'''
assert(len(x.shape) == 2)
if Mx is None:
rho = inner_product(x, x)
else:
assert(len(Mx.shape) == 2)
rho = inner_product(x, Mx)
if rho.shape == (1, 1):
if... | python | def norm_squared(x, Mx=None, inner_product=ip_euclid):
'''Compute the norm^2 w.r.t. to a given scalar product.'''
assert(len(x.shape) == 2)
if Mx is None:
rho = inner_product(x, x)
else:
assert(len(Mx.shape) == 2)
rho = inner_product(x, Mx)
if rho.shape == (1, 1):
if... | [
"def",
"norm_squared",
"(",
"x",
",",
"Mx",
"=",
"None",
",",
"inner_product",
"=",
"ip_euclid",
")",
":",
"assert",
"(",
"len",
"(",
"x",
".",
"shape",
")",
"==",
"2",
")",
"if",
"Mx",
"is",
"None",
":",
"rho",
"=",
"inner_product",
"(",
"x",
",... | Compute the norm^2 w.r.t. to a given scalar product. | [
"Compute",
"the",
"norm^2",
"w",
".",
"r",
".",
"t",
".",
"to",
"a",
"given",
"scalar",
"product",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L164-L178 |
45,501 | andrenarchy/krypy | krypy/utils.py | get_linearoperator | def get_linearoperator(shape, A, timer=None):
"""Enhances aslinearoperator if A is None."""
ret = None
import scipy.sparse.linalg as scipylinalg
if isinstance(A, LinearOperator):
ret = A
elif A is None:
ret = IdentityLinearOperator(shape)
elif isinstance(A, numpy.ndarray) or issp... | python | def get_linearoperator(shape, A, timer=None):
"""Enhances aslinearoperator if A is None."""
ret = None
import scipy.sparse.linalg as scipylinalg
if isinstance(A, LinearOperator):
ret = A
elif A is None:
ret = IdentityLinearOperator(shape)
elif isinstance(A, numpy.ndarray) or issp... | [
"def",
"get_linearoperator",
"(",
"shape",
",",
"A",
",",
"timer",
"=",
"None",
")",
":",
"ret",
"=",
"None",
"import",
"scipy",
".",
"sparse",
".",
"linalg",
"as",
"scipylinalg",
"if",
"isinstance",
"(",
"A",
",",
"LinearOperator",
")",
":",
"ret",
"=... | Enhances aslinearoperator if A is None. | [
"Enhances",
"aslinearoperator",
"if",
"A",
"is",
"None",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L207-L236 |
45,502 | andrenarchy/krypy | krypy/utils.py | orthonormality | def orthonormality(V, ip_B=None):
"""Measure orthonormality of given basis.
:param V: a matrix :math:`V=[v_1,\ldots,v_n]` with ``shape==(N,n)``.
:param ip_B: (optional) the inner product to use, see :py:meth:`inner`.
:return: :math:`\\| I_n - \\langle V,V \\rangle \\|_2`.
"""
return norm(numpy... | python | def orthonormality(V, ip_B=None):
"""Measure orthonormality of given basis.
:param V: a matrix :math:`V=[v_1,\ldots,v_n]` with ``shape==(N,n)``.
:param ip_B: (optional) the inner product to use, see :py:meth:`inner`.
:return: :math:`\\| I_n - \\langle V,V \\rangle \\|_2`.
"""
return norm(numpy... | [
"def",
"orthonormality",
"(",
"V",
",",
"ip_B",
"=",
"None",
")",
":",
"return",
"norm",
"(",
"numpy",
".",
"eye",
"(",
"V",
".",
"shape",
"[",
"1",
"]",
")",
"-",
"inner",
"(",
"V",
",",
"V",
",",
"ip_B",
"=",
"ip_B",
")",
")"
] | Measure orthonormality of given basis.
:param V: a matrix :math:`V=[v_1,\ldots,v_n]` with ``shape==(N,n)``.
:param ip_B: (optional) the inner product to use, see :py:meth:`inner`.
:return: :math:`\\| I_n - \\langle V,V \\rangle \\|_2`. | [
"Measure",
"orthonormality",
"of",
"given",
"basis",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L260-L268 |
45,503 | andrenarchy/krypy | krypy/utils.py | arnoldi_res | def arnoldi_res(A, V, H, ip_B=None):
"""Measure Arnoldi residual.
:param A: a linear operator that can be used with scipy's aslinearoperator
with ``shape==(N,N)``.
:param V: Arnoldi basis matrix with ``shape==(N,n)``.
:param H: Hessenberg matrix: either :math:`\\underline{H}_{n-1}` with
``s... | python | def arnoldi_res(A, V, H, ip_B=None):
"""Measure Arnoldi residual.
:param A: a linear operator that can be used with scipy's aslinearoperator
with ``shape==(N,N)``.
:param V: Arnoldi basis matrix with ``shape==(N,n)``.
:param H: Hessenberg matrix: either :math:`\\underline{H}_{n-1}` with
``s... | [
"def",
"arnoldi_res",
"(",
"A",
",",
"V",
",",
"H",
",",
"ip_B",
"=",
"None",
")",
":",
"N",
"=",
"V",
".",
"shape",
"[",
"0",
"]",
"invariant",
"=",
"H",
".",
"shape",
"[",
"0",
"]",
"==",
"H",
".",
"shape",
"[",
"1",
"]",
"A",
"=",
"get... | Measure Arnoldi residual.
:param A: a linear operator that can be used with scipy's aslinearoperator
with ``shape==(N,N)``.
:param V: Arnoldi basis matrix with ``shape==(N,n)``.
:param H: Hessenberg matrix: either :math:`\\underline{H}_{n-1}` with
``shape==(n,n-1)`` or :math:`H_n` with ``shape=... | [
"Measure",
"Arnoldi",
"residual",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L271-L292 |
45,504 | andrenarchy/krypy | krypy/utils.py | qr | def qr(X, ip_B=None, reorthos=1):
"""QR factorization with customizable inner product.
:param X: array with ``shape==(N,k)``
:param ip_B: (optional) inner product, see :py:meth:`inner`.
:param reorthos: (optional) numer of reorthogonalizations. Defaults to
1 (i.e. 2 runs of modified Gram-Schmidt)... | python | def qr(X, ip_B=None, reorthos=1):
"""QR factorization with customizable inner product.
:param X: array with ``shape==(N,k)``
:param ip_B: (optional) inner product, see :py:meth:`inner`.
:param reorthos: (optional) numer of reorthogonalizations. Defaults to
1 (i.e. 2 runs of modified Gram-Schmidt)... | [
"def",
"qr",
"(",
"X",
",",
"ip_B",
"=",
"None",
",",
"reorthos",
"=",
"1",
")",
":",
"if",
"ip_B",
"is",
"None",
"and",
"X",
".",
"shape",
"[",
"1",
"]",
">",
"0",
":",
"return",
"scipy",
".",
"linalg",
".",
"qr",
"(",
"X",
",",
"mode",
"=... | QR factorization with customizable inner product.
:param X: array with ``shape==(N,k)``
:param ip_B: (optional) inner product, see :py:meth:`inner`.
:param reorthos: (optional) numer of reorthogonalizations. Defaults to
1 (i.e. 2 runs of modified Gram-Schmidt) which should be enough in most
cas... | [
"QR",
"factorization",
"with",
"customizable",
"inner",
"product",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L648-L675 |
45,505 | andrenarchy/krypy | krypy/utils.py | angles | def angles(F, G, ip_B=None, compute_vectors=False):
"""Principal angles between two subspaces.
This algorithm is based on algorithm 6.2 in `Knyazev, Argentati. Principal
angles between subspaces in an A-based scalar product: algorithms and
perturbation estimates. 2002.` This algorithm can also handle s... | python | def angles(F, G, ip_B=None, compute_vectors=False):
"""Principal angles between two subspaces.
This algorithm is based on algorithm 6.2 in `Knyazev, Argentati. Principal
angles between subspaces in an A-based scalar product: algorithms and
perturbation estimates. 2002.` This algorithm can also handle s... | [
"def",
"angles",
"(",
"F",
",",
"G",
",",
"ip_B",
"=",
"None",
",",
"compute_vectors",
"=",
"False",
")",
":",
"# make sure that F.shape[1]>=G.shape[1]",
"reverse",
"=",
"False",
"if",
"F",
".",
"shape",
"[",
"1",
"]",
"<",
"G",
".",
"shape",
"[",
"1",... | Principal angles between two subspaces.
This algorithm is based on algorithm 6.2 in `Knyazev, Argentati. Principal
angles between subspaces in an A-based scalar product: algorithms and
perturbation estimates. 2002.` This algorithm can also handle small angles
(in contrast to the naive cosine-based svd ... | [
"Principal",
"angles",
"between",
"two",
"subspaces",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L678-L772 |
45,506 | andrenarchy/krypy | krypy/utils.py | gap | def gap(lamda, sigma, mode='individual'):
"""Compute spectral gap.
Useful for eigenvalue/eigenvector bounds. Computes the gap
:math:`\delta\geq 0` between two sets of real numbers ``lamda`` and
``sigma``. The gap can be computed in several ways and may not exist, see
the ``mode`` parameter.
:p... | python | def gap(lamda, sigma, mode='individual'):
"""Compute spectral gap.
Useful for eigenvalue/eigenvector bounds. Computes the gap
:math:`\delta\geq 0` between two sets of real numbers ``lamda`` and
``sigma``. The gap can be computed in several ways and may not exist, see
the ``mode`` parameter.
:p... | [
"def",
"gap",
"(",
"lamda",
",",
"sigma",
",",
"mode",
"=",
"'individual'",
")",
":",
"# sanitize input",
"if",
"numpy",
".",
"isscalar",
"(",
"lamda",
")",
":",
"lamda",
"=",
"[",
"lamda",
"]",
"lamda",
"=",
"numpy",
".",
"array",
"(",
"lamda",
")",... | Compute spectral gap.
Useful for eigenvalue/eigenvector bounds. Computes the gap
:math:`\delta\geq 0` between two sets of real numbers ``lamda`` and
``sigma``. The gap can be computed in several ways and may not exist, see
the ``mode`` parameter.
:param lamda: a non-empty set
:math:`\Lambda=... | [
"Compute",
"spectral",
"gap",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1603-L1656 |
45,507 | andrenarchy/krypy | krypy/utils.py | bound_perturbed_gmres | def bound_perturbed_gmres(pseudo, p, epsilon, deltas):
'''Compute GMRES perturbation bound based on pseudospectrum
Computes the GMRES bound from [SifEM13]_.
'''
if not numpy.all(numpy.array(deltas) > epsilon):
raise ArgumentError('all deltas have to be greater than epsilon')
bound = []
... | python | def bound_perturbed_gmres(pseudo, p, epsilon, deltas):
'''Compute GMRES perturbation bound based on pseudospectrum
Computes the GMRES bound from [SifEM13]_.
'''
if not numpy.all(numpy.array(deltas) > epsilon):
raise ArgumentError('all deltas have to be greater than epsilon')
bound = []
... | [
"def",
"bound_perturbed_gmres",
"(",
"pseudo",
",",
"p",
",",
"epsilon",
",",
"deltas",
")",
":",
"if",
"not",
"numpy",
".",
"all",
"(",
"numpy",
".",
"array",
"(",
"deltas",
")",
">",
"epsilon",
")",
":",
"raise",
"ArgumentError",
"(",
"'all deltas have... | Compute GMRES perturbation bound based on pseudospectrum
Computes the GMRES bound from [SifEM13]_. | [
"Compute",
"GMRES",
"perturbation",
"bound",
"based",
"on",
"pseudospectrum"
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1946-L1969 |
45,508 | andrenarchy/krypy | krypy/utils.py | get_residual_norms | def get_residual_norms(H, self_adjoint=False):
'''Compute relative residual norms from Hessenberg matrix.
It is assumed that the initial guess is chosen as zero.'''
H = H.copy()
n_, n = H.shape
y = numpy.eye(n_, 1, dtype=H.dtype)
resnorms = [1.]
for i in range(n_-1):
G = Givens(H[i:... | python | def get_residual_norms(H, self_adjoint=False):
'''Compute relative residual norms from Hessenberg matrix.
It is assumed that the initial guess is chosen as zero.'''
H = H.copy()
n_, n = H.shape
y = numpy.eye(n_, 1, dtype=H.dtype)
resnorms = [1.]
for i in range(n_-1):
G = Givens(H[i:... | [
"def",
"get_residual_norms",
"(",
"H",
",",
"self_adjoint",
"=",
"False",
")",
":",
"H",
"=",
"H",
".",
"copy",
"(",
")",
"n_",
",",
"n",
"=",
"H",
".",
"shape",
"y",
"=",
"numpy",
".",
"eye",
"(",
"n_",
",",
"1",
",",
"dtype",
"=",
"H",
".",... | Compute relative residual norms from Hessenberg matrix.
It is assumed that the initial guess is chosen as zero. | [
"Compute",
"relative",
"residual",
"norms",
"from",
"Hessenberg",
"matrix",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L2037-L2055 |
45,509 | andrenarchy/krypy | krypy/utils.py | House.apply | def apply(self, x):
"""Apply Householder transformation to vector x.
Applies the Householder transformation efficiently to the given vector.
"""
# make sure that x is a (N,*) matrix
if len(x.shape) != 2:
raise ArgumentError('x is not a matrix of shape (N,*)')
... | python | def apply(self, x):
"""Apply Householder transformation to vector x.
Applies the Householder transformation efficiently to the given vector.
"""
# make sure that x is a (N,*) matrix
if len(x.shape) != 2:
raise ArgumentError('x is not a matrix of shape (N,*)')
... | [
"def",
"apply",
"(",
"self",
",",
"x",
")",
":",
"# make sure that x is a (N,*) matrix",
"if",
"len",
"(",
"x",
".",
"shape",
")",
"!=",
"2",
":",
"raise",
"ArgumentError",
"(",
"'x is not a matrix of shape (N,*)'",
")",
"if",
"self",
".",
"beta",
"==",
"0",... | Apply Householder transformation to vector x.
Applies the Householder transformation efficiently to the given vector. | [
"Apply",
"Householder",
"transformation",
"to",
"vector",
"x",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L342-L352 |
45,510 | andrenarchy/krypy | krypy/utils.py | House.matrix | def matrix(self):
"""Build matrix representation of Householder transformation.
Builds the matrix representation
:math:`H = I - \\beta vv^*`.
**Use with care!** This routine may be helpful for testing purposes but
should not be used in production codes for high dimensions since... | python | def matrix(self):
"""Build matrix representation of Householder transformation.
Builds the matrix representation
:math:`H = I - \\beta vv^*`.
**Use with care!** This routine may be helpful for testing purposes but
should not be used in production codes for high dimensions since... | [
"def",
"matrix",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"v",
".",
"shape",
"[",
"0",
"]",
"return",
"numpy",
".",
"eye",
"(",
"n",
",",
"n",
")",
"-",
"self",
".",
"beta",
"*",
"numpy",
".",
"dot",
"(",
"self",
".",
"v",
",",
"self",... | Build matrix representation of Householder transformation.
Builds the matrix representation
:math:`H = I - \\beta vv^*`.
**Use with care!** This routine may be helpful for testing purposes but
should not be used in production codes for high dimensions since
the resulting matrix... | [
"Build",
"matrix",
"representation",
"of",
"Householder",
"transformation",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L354-L365 |
45,511 | andrenarchy/krypy | krypy/utils.py | Projection._apply | def _apply(self, a, return_Ya=False):
r'''Single application of the projection.
:param a: array with ``a.shape==(N,m)``.
:param return_inner: (optional) should the inner product
:math:`\langle Y,a\rangle` be returned?
:return:
* :math:`P_{\mathcal{X},\mathcal{Y}^\pe... | python | def _apply(self, a, return_Ya=False):
r'''Single application of the projection.
:param a: array with ``a.shape==(N,m)``.
:param return_inner: (optional) should the inner product
:math:`\langle Y,a\rangle` be returned?
:return:
* :math:`P_{\mathcal{X},\mathcal{Y}^\pe... | [
"def",
"_apply",
"(",
"self",
",",
"a",
",",
"return_Ya",
"=",
"False",
")",
":",
"# is projection the zero operator?",
"if",
"self",
".",
"V",
".",
"shape",
"[",
"1",
"]",
"==",
"0",
":",
"Pa",
"=",
"numpy",
".",
"zeros",
"(",
"a",
".",
"shape",
"... | r'''Single application of the projection.
:param a: array with ``a.shape==(N,m)``.
:param return_inner: (optional) should the inner product
:math:`\langle Y,a\rangle` be returned?
:return:
* :math:`P_{\mathcal{X},\mathcal{Y}^\perp} a =
X \langle Y,X\rangle^{-1} ... | [
"r",
"Single",
"application",
"of",
"the",
"projection",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L490-L520 |
45,512 | andrenarchy/krypy | krypy/utils.py | Projection._apply_adj | def _apply_adj(self, a):
# is projection the zero operator?
if self.V.shape[1] == 0:
return numpy.zeros(a.shape)
'''Single application of the adjoint projection.'''
c = inner(self.V, a, ip_B=self.ip_B)
if self.Q is not None and self.R is not None:
c = self... | python | def _apply_adj(self, a):
# is projection the zero operator?
if self.V.shape[1] == 0:
return numpy.zeros(a.shape)
'''Single application of the adjoint projection.'''
c = inner(self.V, a, ip_B=self.ip_B)
if self.Q is not None and self.R is not None:
c = self... | [
"def",
"_apply_adj",
"(",
"self",
",",
"a",
")",
":",
"# is projection the zero operator?",
"if",
"self",
".",
"V",
".",
"shape",
"[",
"1",
"]",
"==",
"0",
":",
"return",
"numpy",
".",
"zeros",
"(",
"a",
".",
"shape",
")",
"c",
"=",
"inner",
"(",
"... | Single application of the adjoint projection. | [
"Single",
"application",
"of",
"the",
"adjoint",
"projection",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L522-L531 |
45,513 | andrenarchy/krypy | krypy/utils.py | Projection.apply | def apply(self, a, return_Ya=False):
r"""Apply the projection to an array.
The computation is carried out without explicitly forming the
matrix corresponding to the projection (which would be an array with
``shape==(N,N)``).
See also :py:meth:`_apply`.
"""
# is ... | python | def apply(self, a, return_Ya=False):
r"""Apply the projection to an array.
The computation is carried out without explicitly forming the
matrix corresponding to the projection (which would be an array with
``shape==(N,N)``).
See also :py:meth:`_apply`.
"""
# is ... | [
"def",
"apply",
"(",
"self",
",",
"a",
",",
"return_Ya",
"=",
"False",
")",
":",
"# is projection the zero operator?",
"if",
"self",
".",
"V",
".",
"shape",
"[",
"1",
"]",
"==",
"0",
":",
"Pa",
"=",
"numpy",
".",
"zeros",
"(",
"a",
".",
"shape",
")... | r"""Apply the projection to an array.
The computation is carried out without explicitly forming the
matrix corresponding to the projection (which would be an array with
``shape==(N,N)``).
See also :py:meth:`_apply`. | [
"r",
"Apply",
"the",
"projection",
"to",
"an",
"array",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L533-L558 |
45,514 | andrenarchy/krypy | krypy/utils.py | Projection.apply_complement | def apply_complement(self, a, return_Ya=False):
"""Apply the complementary projection to an array.
:param z: array with ``shape==(N,m)``.
:return: :math:`P_{\\mathcal{Y}^\\perp,\\mathcal{X}}z =
z - P_{\\mathcal{X},\\mathcal{Y}^\\perp} z`.
"""
# is projection the zer... | python | def apply_complement(self, a, return_Ya=False):
"""Apply the complementary projection to an array.
:param z: array with ``shape==(N,m)``.
:return: :math:`P_{\\mathcal{Y}^\\perp,\\mathcal{X}}z =
z - P_{\\mathcal{X},\\mathcal{Y}^\\perp} z`.
"""
# is projection the zer... | [
"def",
"apply_complement",
"(",
"self",
",",
"a",
",",
"return_Ya",
"=",
"False",
")",
":",
"# is projection the zero operator? --> complement is identity",
"if",
"self",
".",
"V",
".",
"shape",
"[",
"1",
"]",
"==",
"0",
":",
"if",
"return_Ya",
":",
"return",
... | Apply the complementary projection to an array.
:param z: array with ``shape==(N,m)``.
:return: :math:`P_{\\mathcal{Y}^\\perp,\\mathcal{X}}z =
z - P_{\\mathcal{X},\\mathcal{Y}^\\perp} z`. | [
"Apply",
"the",
"complementary",
"projection",
"to",
"an",
"array",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L571-L594 |
45,515 | andrenarchy/krypy | krypy/utils.py | Timings.get | def get(self, key):
'''Return timings for `key`. Returns 0 if not present.'''
if key in self and len(self[key]) > 0:
return min(self[key])
else:
return 0 | python | def get(self, key):
'''Return timings for `key`. Returns 0 if not present.'''
if key in self and len(self[key]) > 0:
return min(self[key])
else:
return 0 | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
"and",
"len",
"(",
"self",
"[",
"key",
"]",
")",
">",
"0",
":",
"return",
"min",
"(",
"self",
"[",
"key",
"]",
")",
"else",
":",
"return",
"0"
] | Return timings for `key`. Returns 0 if not present. | [
"Return",
"timings",
"for",
"key",
".",
"Returns",
"0",
"if",
"not",
"present",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1304-L1309 |
45,516 | andrenarchy/krypy | krypy/utils.py | Timings.get_ops | def get_ops(self, ops):
'''Return timings for dictionary ops holding the operation names as
keys and the number of applications as values.'''
time = 0.
for op, count in ops.items():
time += self.get(op) * count
return time | python | def get_ops(self, ops):
'''Return timings for dictionary ops holding the operation names as
keys and the number of applications as values.'''
time = 0.
for op, count in ops.items():
time += self.get(op) * count
return time | [
"def",
"get_ops",
"(",
"self",
",",
"ops",
")",
":",
"time",
"=",
"0.",
"for",
"op",
",",
"count",
"in",
"ops",
".",
"items",
"(",
")",
":",
"time",
"+=",
"self",
".",
"get",
"(",
"op",
")",
"*",
"count",
"return",
"time"
] | Return timings for dictionary ops holding the operation names as
keys and the number of applications as values. | [
"Return",
"timings",
"for",
"dictionary",
"ops",
"holding",
"the",
"operation",
"names",
"as",
"keys",
"and",
"the",
"number",
"of",
"applications",
"as",
"values",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1311-L1317 |
45,517 | andrenarchy/krypy | krypy/utils.py | Intervals.min_pos | def min_pos(self):
'''Returns minimal positive value or None.'''
if self.__len__() == 0:
return ArgumentError('empty set has no minimum positive value.')
if self.contains(0):
return None
positive = [interval for interval in self.intervals
if in... | python | def min_pos(self):
'''Returns minimal positive value or None.'''
if self.__len__() == 0:
return ArgumentError('empty set has no minimum positive value.')
if self.contains(0):
return None
positive = [interval for interval in self.intervals
if in... | [
"def",
"min_pos",
"(",
"self",
")",
":",
"if",
"self",
".",
"__len__",
"(",
")",
"==",
"0",
":",
"return",
"ArgumentError",
"(",
"'empty set has no minimum positive value.'",
")",
"if",
"self",
".",
"contains",
"(",
"0",
")",
":",
"return",
"None",
"positi... | Returns minimal positive value or None. | [
"Returns",
"minimal",
"positive",
"value",
"or",
"None",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1751-L1761 |
45,518 | andrenarchy/krypy | krypy/utils.py | Intervals.max_neg | def max_neg(self):
'''Returns maximum negative value or None.'''
if self.__len__() == 0:
return ArgumentError('empty set has no maximum negative value.')
if self.contains(0):
return None
negative = [interval for interval in self.intervals
if in... | python | def max_neg(self):
'''Returns maximum negative value or None.'''
if self.__len__() == 0:
return ArgumentError('empty set has no maximum negative value.')
if self.contains(0):
return None
negative = [interval for interval in self.intervals
if in... | [
"def",
"max_neg",
"(",
"self",
")",
":",
"if",
"self",
".",
"__len__",
"(",
")",
"==",
"0",
":",
"return",
"ArgumentError",
"(",
"'empty set has no maximum negative value.'",
")",
"if",
"self",
".",
"contains",
"(",
"0",
")",
":",
"return",
"None",
"negati... | Returns maximum negative value or None. | [
"Returns",
"maximum",
"negative",
"value",
"or",
"None",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1763-L1773 |
45,519 | andrenarchy/krypy | krypy/utils.py | Intervals.min_abs | def min_abs(self):
'''Returns minimum absolute value.'''
if self.__len__() == 0:
return ArgumentError('empty set has no minimum absolute value.')
if self.contains(0):
return 0
return numpy.min([numpy.abs(val)
for val in [self.max_neg(), s... | python | def min_abs(self):
'''Returns minimum absolute value.'''
if self.__len__() == 0:
return ArgumentError('empty set has no minimum absolute value.')
if self.contains(0):
return 0
return numpy.min([numpy.abs(val)
for val in [self.max_neg(), s... | [
"def",
"min_abs",
"(",
"self",
")",
":",
"if",
"self",
".",
"__len__",
"(",
")",
"==",
"0",
":",
"return",
"ArgumentError",
"(",
"'empty set has no minimum absolute value.'",
")",
"if",
"self",
".",
"contains",
"(",
"0",
")",
":",
"return",
"0",
"return",
... | Returns minimum absolute value. | [
"Returns",
"minimum",
"absolute",
"value",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1775-L1783 |
45,520 | andrenarchy/krypy | krypy/utils.py | Intervals.max_abs | def max_abs(self):
'''Returns maximum absolute value.'''
if self.__len__() == 0:
return ArgumentError('empty set has no maximum absolute value.')
return numpy.max(numpy.abs([self.max(), self.min()])) | python | def max_abs(self):
'''Returns maximum absolute value.'''
if self.__len__() == 0:
return ArgumentError('empty set has no maximum absolute value.')
return numpy.max(numpy.abs([self.max(), self.min()])) | [
"def",
"max_abs",
"(",
"self",
")",
":",
"if",
"self",
".",
"__len__",
"(",
")",
"==",
"0",
":",
"return",
"ArgumentError",
"(",
"'empty set has no maximum absolute value.'",
")",
"return",
"numpy",
".",
"max",
"(",
"numpy",
".",
"abs",
"(",
"[",
"self",
... | Returns maximum absolute value. | [
"Returns",
"maximum",
"absolute",
"value",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1785-L1789 |
45,521 | andrenarchy/krypy | krypy/utils.py | BoundMinres.get_step | def get_step(self, tol):
'''Return step at which bound falls below tolerance. '''
return 2 * numpy.log(tol/2.)/numpy.log(self.base) | python | def get_step(self, tol):
'''Return step at which bound falls below tolerance. '''
return 2 * numpy.log(tol/2.)/numpy.log(self.base) | [
"def",
"get_step",
"(",
"self",
",",
"tol",
")",
":",
"return",
"2",
"*",
"numpy",
".",
"log",
"(",
"tol",
"/",
"2.",
")",
"/",
"numpy",
".",
"log",
"(",
"self",
".",
"base",
")"
] | Return step at which bound falls below tolerance. | [
"Return",
"step",
"at",
"which",
"bound",
"falls",
"below",
"tolerance",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1941-L1943 |
45,522 | andrenarchy/krypy | krypy/utils.py | NormalizedRootsPolynomial.minmax_candidates | def minmax_candidates(self):
'''Get points where derivative is zero.
Useful for computing the extrema of the polynomial over an interval if
the polynomial has real roots. In this case, the maximum is attained
for one of the interval endpoints or a point from the result of this
f... | python | def minmax_candidates(self):
'''Get points where derivative is zero.
Useful for computing the extrema of the polynomial over an interval if
the polynomial has real roots. In this case, the maximum is attained
for one of the interval endpoints or a point from the result of this
f... | [
"def",
"minmax_candidates",
"(",
"self",
")",
":",
"from",
"numpy",
".",
"polynomial",
"import",
"Polynomial",
"as",
"P",
"p",
"=",
"P",
".",
"fromroots",
"(",
"self",
".",
"roots",
")",
"return",
"p",
".",
"deriv",
"(",
"1",
")",
".",
"roots",
"(",
... | Get points where derivative is zero.
Useful for computing the extrema of the polynomial over an interval if
the polynomial has real roots. In this case, the maximum is attained
for one of the interval endpoints or a point from the result of this
function that is contained in the interva... | [
"Get",
"points",
"where",
"derivative",
"is",
"zero",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1991-L2001 |
45,523 | dslackw/alarm | alarm/main.py | ALARM.errors | def errors(self):
"""
Check for usage errors
"""
try:
self.now = datetime.datetime.now()
if len(self.alarm_day) < 2 or len(self.alarm_day) > 2:
print("error: day: usage 'DD' such us '0%s' not '%s'" % (
self.alarm_day, self.alarm... | python | def errors(self):
"""
Check for usage errors
"""
try:
self.now = datetime.datetime.now()
if len(self.alarm_day) < 2 or len(self.alarm_day) > 2:
print("error: day: usage 'DD' such us '0%s' not '%s'" % (
self.alarm_day, self.alarm... | [
"def",
"errors",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"if",
"len",
"(",
"self",
".",
"alarm_day",
")",
"<",
"2",
"or",
"len",
"(",
"self",
".",
"alarm_day",
")",
">",
"2"... | Check for usage errors | [
"Check",
"for",
"usage",
"errors"
] | 6c6a6eea372057094862d5c1b7d4d7b38b453bfc | https://github.com/dslackw/alarm/blob/6c6a6eea372057094862d5c1b7d4d7b38b453bfc/alarm/main.py#L140-L175 |
45,524 | andrenarchy/krypy | krypy/recycling/factories.py | RitzFactory._get_best_subset | def _get_best_subset(self, ritz):
'''Return candidate set with smallest goal functional.'''
# (c,\omega(c)) for all considered subsets c
overall_evaluations = {}
def evaluate(_subset, _evaluations):
try:
_evaluations[_subset] = \
self.sub... | python | def _get_best_subset(self, ritz):
'''Return candidate set with smallest goal functional.'''
# (c,\omega(c)) for all considered subsets c
overall_evaluations = {}
def evaluate(_subset, _evaluations):
try:
_evaluations[_subset] = \
self.sub... | [
"def",
"_get_best_subset",
"(",
"self",
",",
"ritz",
")",
":",
"# (c,\\omega(c)) for all considered subsets c",
"overall_evaluations",
"=",
"{",
"}",
"def",
"evaluate",
"(",
"_subset",
",",
"_evaluations",
")",
":",
"try",
":",
"_evaluations",
"[",
"_subset",
"]",... | Return candidate set with smallest goal functional. | [
"Return",
"candidate",
"set",
"with",
"smallest",
"goal",
"functional",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/recycling/factories.py#L53-L136 |
45,525 | click-contrib/click-default-group | click_default_group.py | DefaultGroup.set_default_command | def set_default_command(self, command):
"""Sets a command function as the default command."""
cmd_name = command.name
self.add_command(command)
self.default_cmd_name = cmd_name | python | def set_default_command(self, command):
"""Sets a command function as the default command."""
cmd_name = command.name
self.add_command(command)
self.default_cmd_name = cmd_name | [
"def",
"set_default_command",
"(",
"self",
",",
"command",
")",
":",
"cmd_name",
"=",
"command",
".",
"name",
"self",
".",
"add_command",
"(",
"command",
")",
"self",
".",
"default_cmd_name",
"=",
"cmd_name"
] | Sets a command function as the default command. | [
"Sets",
"a",
"command",
"function",
"as",
"the",
"default",
"command",
"."
] | 70427e5dabc04c86c3fb74b2c950fec857d6a213 | https://github.com/click-contrib/click-default-group/blob/70427e5dabc04c86c3fb74b2c950fec857d6a213/click_default_group.py#L74-L78 |
45,526 | andrenarchy/krypy | krypy/linsys.py | LinearSystem.get_residual | def get_residual(self, z, compute_norm=False):
r'''Compute residual.
For a given :math:`z\in\mathbb{C}^N`, the residual
.. math::
r = M M_l ( b - A z )
is computed. If ``compute_norm == True``, then also the absolute
residual norm
.. math::
\| M ... | python | def get_residual(self, z, compute_norm=False):
r'''Compute residual.
For a given :math:`z\in\mathbb{C}^N`, the residual
.. math::
r = M M_l ( b - A z )
is computed. If ``compute_norm == True``, then also the absolute
residual norm
.. math::
\| M ... | [
"def",
"get_residual",
"(",
"self",
",",
"z",
",",
"compute_norm",
"=",
"False",
")",
":",
"if",
"z",
"is",
"None",
":",
"if",
"compute_norm",
":",
"return",
"self",
".",
"MMlb",
",",
"self",
".",
"Mlb",
",",
"self",
".",
"MMlb_norm",
"return",
"self... | r'''Compute residual.
For a given :math:`z\in\mathbb{C}^N`, the residual
.. math::
r = M M_l ( b - A z )
is computed. If ``compute_norm == True``, then also the absolute
residual norm
.. math::
\| M M_l (b-Az)\|_{M^{-1}}
is computed.
:p... | [
"r",
"Compute",
"residual",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L123-L154 |
45,527 | andrenarchy/krypy | krypy/linsys.py | LinearSystem.get_ip_Minv_B | def get_ip_Minv_B(self):
'''Returns the inner product that is implicitly used with the positive
definite preconditioner ``M``.'''
if not isinstance(self.M, utils.IdentityLinearOperator):
if isinstance(self.Minv, utils.IdentityLinearOperator):
raise utils.ArgumentError... | python | def get_ip_Minv_B(self):
'''Returns the inner product that is implicitly used with the positive
definite preconditioner ``M``.'''
if not isinstance(self.M, utils.IdentityLinearOperator):
if isinstance(self.Minv, utils.IdentityLinearOperator):
raise utils.ArgumentError... | [
"def",
"get_ip_Minv_B",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"M",
",",
"utils",
".",
"IdentityLinearOperator",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"Minv",
",",
"utils",
".",
"IdentityLinearOperator",
")",
":",
"... | Returns the inner product that is implicitly used with the positive
definite preconditioner ``M``. | [
"Returns",
"the",
"inner",
"product",
"that",
"is",
"implicitly",
"used",
"with",
"the",
"positive",
"definite",
"preconditioner",
"M",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L156-L168 |
45,528 | andrenarchy/krypy | krypy/linsys.py | _KrylovSolver._get_xk | def _get_xk(self, yk):
'''Compute approximate solution from initial guess and approximate
solution of the preconditioned linear system.'''
if yk is not None:
return self.x0 + self.linear_system.Mr * yk
return self.x0 | python | def _get_xk(self, yk):
'''Compute approximate solution from initial guess and approximate
solution of the preconditioned linear system.'''
if yk is not None:
return self.x0 + self.linear_system.Mr * yk
return self.x0 | [
"def",
"_get_xk",
"(",
"self",
",",
"yk",
")",
":",
"if",
"yk",
"is",
"not",
"None",
":",
"return",
"self",
".",
"x0",
"+",
"self",
".",
"linear_system",
".",
"Mr",
"*",
"yk",
"return",
"self",
".",
"x0"
] | Compute approximate solution from initial guess and approximate
solution of the preconditioned linear system. | [
"Compute",
"approximate",
"solution",
"from",
"initial",
"guess",
"and",
"approximate",
"solution",
"of",
"the",
"preconditioned",
"linear",
"system",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L392-L397 |
45,529 | andrenarchy/krypy | krypy/linsys.py | _KrylovSolver._finalize_iteration | def _finalize_iteration(self, yk, resnorm):
'''Compute solution, error norm and residual norm if required.
:return: the residual norm or ``None``.
'''
self.xk = None
# compute error norm if asked for
if self.linear_system.exact_solution is not None:
self.xk =... | python | def _finalize_iteration(self, yk, resnorm):
'''Compute solution, error norm and residual norm if required.
:return: the residual norm or ``None``.
'''
self.xk = None
# compute error norm if asked for
if self.linear_system.exact_solution is not None:
self.xk =... | [
"def",
"_finalize_iteration",
"(",
"self",
",",
"yk",
",",
"resnorm",
")",
":",
"self",
".",
"xk",
"=",
"None",
"# compute error norm if asked for",
"if",
"self",
".",
"linear_system",
".",
"exact_solution",
"is",
"not",
"None",
":",
"self",
".",
"xk",
"=",
... | Compute solution, error norm and residual norm if required.
:return: the residual norm or ``None``. | [
"Compute",
"solution",
"error",
"norm",
"and",
"residual",
"norm",
"if",
"required",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L399-L451 |
45,530 | andrenarchy/krypy | krypy/linsys.py | Gmres.operations | def operations(nsteps):
'''Returns the number of operations needed for nsteps of GMRES'''
return {'A': 1 + nsteps,
'M': 2 + nsteps,
'Ml': 2 + nsteps,
'Mr': 1 + nsteps,
'ip_B': 2 + nsteps + nsteps*(nsteps+1)/2,
'axpy': 4 + 2*... | python | def operations(nsteps):
'''Returns the number of operations needed for nsteps of GMRES'''
return {'A': 1 + nsteps,
'M': 2 + nsteps,
'Ml': 2 + nsteps,
'Mr': 1 + nsteps,
'ip_B': 2 + nsteps + nsteps*(nsteps+1)/2,
'axpy': 4 + 2*... | [
"def",
"operations",
"(",
"nsteps",
")",
":",
"return",
"{",
"'A'",
":",
"1",
"+",
"nsteps",
",",
"'M'",
":",
"2",
"+",
"nsteps",
",",
"'Ml'",
":",
"2",
"+",
"nsteps",
",",
"'Mr'",
":",
"1",
"+",
"nsteps",
",",
"'ip_B'",
":",
"2",
"+",
"nsteps"... | Returns the number of operations needed for nsteps of GMRES | [
"Returns",
"the",
"number",
"of",
"operations",
"needed",
"for",
"nsteps",
"of",
"GMRES"
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L897-L905 |
45,531 | andrenarchy/krypy | krypy/recycling/linsys.py | _RecyclingSolver.solve | def solve(self, linear_system,
vector_factory=None,
*args, **kwargs):
'''Solve the given linear system with recycling.
The provided `vector_factory` determines which vectors are used for
deflation.
:param linear_system: the :py:class:`~krypy.linsys.LinearSys... | python | def solve(self, linear_system,
vector_factory=None,
*args, **kwargs):
'''Solve the given linear system with recycling.
The provided `vector_factory` determines which vectors are used for
deflation.
:param linear_system: the :py:class:`~krypy.linsys.LinearSys... | [
"def",
"solve",
"(",
"self",
",",
"linear_system",
",",
"vector_factory",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# replace linear_system with equivalent TimedLinearSystem on demand",
"if",
"not",
"isinstance",
"(",
"linear_system",
",",
... | Solve the given linear system with recycling.
The provided `vector_factory` determines which vectors are used for
deflation.
:param linear_system: the :py:class:`~krypy.linsys.LinearSystem` that
is about to be solved.
:param vector_factory: (optional) see description in const... | [
"Solve",
"the",
"given",
"linear",
"system",
"with",
"recycling",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/recycling/linsys.py#L52-L111 |
45,532 | getdnsapi/getdns-python-bindings | examples/checkdanecert.py | compute_hash | def compute_hash(func, string):
"""compute hash of string using given hash function"""
h = func()
h.update(string)
return h.hexdigest() | python | def compute_hash(func, string):
"""compute hash of string using given hash function"""
h = func()
h.update(string)
return h.hexdigest() | [
"def",
"compute_hash",
"(",
"func",
",",
"string",
")",
":",
"h",
"=",
"func",
"(",
")",
"h",
".",
"update",
"(",
"string",
")",
"return",
"h",
".",
"hexdigest",
"(",
")"
] | compute hash of string using given hash function | [
"compute",
"hash",
"of",
"string",
"using",
"given",
"hash",
"function"
] | 6a094f7fcc148afaaa822152f9037ca9fa4ada6c | https://github.com/getdnsapi/getdns-python-bindings/blob/6a094f7fcc148afaaa822152f9037ca9fa4ada6c/examples/checkdanecert.py#L25-L29 |
45,533 | reincubate/deviceidentifier-py | deviceidentifier/util/local.py | get_local_serial | def get_local_serial():
''' Retrieves the serial number from the executing host.
For example, 'C02NT43PFY14'
'''
return [x for x in [subprocess.Popen("system_profiler SPHardwareDataType |grep -v tray |awk '/Serial/ {print $4}'", shell=True, stdout=subprocess.PIPE).communicate()[0].strip()] if x] | python | def get_local_serial():
''' Retrieves the serial number from the executing host.
For example, 'C02NT43PFY14'
'''
return [x for x in [subprocess.Popen("system_profiler SPHardwareDataType |grep -v tray |awk '/Serial/ {print $4}'", shell=True, stdout=subprocess.PIPE).communicate()[0].strip()] if x] | [
"def",
"get_local_serial",
"(",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"[",
"subprocess",
".",
"Popen",
"(",
"\"system_profiler SPHardwareDataType |grep -v tray |awk '/Serial/ {print $4}'\"",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
".",... | Retrieves the serial number from the executing host.
For example, 'C02NT43PFY14' | [
"Retrieves",
"the",
"serial",
"number",
"from",
"the",
"executing",
"host",
".",
"For",
"example",
"C02NT43PFY14"
] | e6ddf73c6ab3b26a703bca8619fc999dfeaeb5d2 | https://github.com/reincubate/deviceidentifier-py/blob/e6ddf73c6ab3b26a703bca8619fc999dfeaeb5d2/deviceidentifier/util/local.py#L4-L8 |
45,534 | andrenarchy/krypy | krypy/recycling/evaluators.py | RitzApriori._estimate_eval_intervals | def _estimate_eval_intervals(ritz, indices, indices_remaining,
eps_min=0,
eps_max=0,
eps_res=None):
'''Estimate evals based on eval inclusion theorem + heuristic.
:returns: Intervals object with inclusion... | python | def _estimate_eval_intervals(ritz, indices, indices_remaining,
eps_min=0,
eps_max=0,
eps_res=None):
'''Estimate evals based on eval inclusion theorem + heuristic.
:returns: Intervals object with inclusion... | [
"def",
"_estimate_eval_intervals",
"(",
"ritz",
",",
"indices",
",",
"indices_remaining",
",",
"eps_min",
"=",
"0",
",",
"eps_max",
"=",
"0",
",",
"eps_res",
"=",
"None",
")",
":",
"if",
"len",
"(",
"indices",
")",
"==",
"0",
":",
"return",
"utils",
".... | Estimate evals based on eval inclusion theorem + heuristic.
:returns: Intervals object with inclusion intervals for eigenvalues | [
"Estimate",
"evals",
"based",
"on",
"eval",
"inclusion",
"theorem",
"+",
"heuristic",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/recycling/evaluators.py#L76-L135 |
45,535 | andrenarchy/krypy | krypy/deflation.py | ObliqueProjection.correct | def correct(self, z):
'''Correct the given approximate solution ``z`` with respect to the
linear system ``linear_system`` and the deflation space defined by
``U``.'''
c = self.linear_system.Ml*(
self.linear_system.b - self.linear_system.A*z)
c = utils.inner(self.W, c,... | python | def correct(self, z):
'''Correct the given approximate solution ``z`` with respect to the
linear system ``linear_system`` and the deflation space defined by
``U``.'''
c = self.linear_system.Ml*(
self.linear_system.b - self.linear_system.A*z)
c = utils.inner(self.W, c,... | [
"def",
"correct",
"(",
"self",
",",
"z",
")",
":",
"c",
"=",
"self",
".",
"linear_system",
".",
"Ml",
"*",
"(",
"self",
".",
"linear_system",
".",
"b",
"-",
"self",
".",
"linear_system",
".",
"A",
"*",
"z",
")",
"c",
"=",
"utils",
".",
"inner",
... | Correct the given approximate solution ``z`` with respect to the
linear system ``linear_system`` and the deflation space defined by
``U``. | [
"Correct",
"the",
"given",
"approximate",
"solution",
"z",
"with",
"respect",
"to",
"the",
"linear",
"system",
"linear_system",
"and",
"the",
"deflation",
"space",
"defined",
"by",
"U",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L52-L63 |
45,536 | andrenarchy/krypy | krypy/deflation.py | _DeflationMixin._apply_projection | def _apply_projection(self, Av):
'''Apply the projection and store inner product.
:param v: the vector resulting from an application of :math:`M_lAM_r`
to the current Arnoldi vector. (CG needs special treatment, here).
'''
PAv, UAv = self.projection.apply_complement(Av, return... | python | def _apply_projection(self, Av):
'''Apply the projection and store inner product.
:param v: the vector resulting from an application of :math:`M_lAM_r`
to the current Arnoldi vector. (CG needs special treatment, here).
'''
PAv, UAv = self.projection.apply_complement(Av, return... | [
"def",
"_apply_projection",
"(",
"self",
",",
"Av",
")",
":",
"PAv",
",",
"UAv",
"=",
"self",
".",
"projection",
".",
"apply_complement",
"(",
"Av",
",",
"return_Ya",
"=",
"True",
")",
"self",
".",
"C",
"=",
"numpy",
".",
"c_",
"[",
"self",
".",
"C... | Apply the projection and store inner product.
:param v: the vector resulting from an application of :math:`M_lAM_r`
to the current Arnoldi vector. (CG needs special treatment, here). | [
"Apply",
"the",
"projection",
"and",
"store",
"inner",
"product",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L129-L137 |
45,537 | andrenarchy/krypy | krypy/deflation.py | _DeflationMixin._get_initial_residual | def _get_initial_residual(self, x0):
'''Return the projected initial residual.
Returns :math:`MPM_l(b-Ax_0)`.
'''
if x0 is None:
Mlr = self.linear_system.Mlb
else:
r = self.linear_system.b - self.linear_system.A*x0
Mlr = self.linear_system.Ml*... | python | def _get_initial_residual(self, x0):
'''Return the projected initial residual.
Returns :math:`MPM_l(b-Ax_0)`.
'''
if x0 is None:
Mlr = self.linear_system.Mlb
else:
r = self.linear_system.b - self.linear_system.A*x0
Mlr = self.linear_system.Ml*... | [
"def",
"_get_initial_residual",
"(",
"self",
",",
"x0",
")",
":",
"if",
"x0",
"is",
"None",
":",
"Mlr",
"=",
"self",
".",
"linear_system",
".",
"Mlb",
"else",
":",
"r",
"=",
"self",
".",
"linear_system",
".",
"b",
"-",
"self",
".",
"linear_system",
"... | Return the projected initial residual.
Returns :math:`MPM_l(b-Ax_0)`. | [
"Return",
"the",
"projected",
"initial",
"residual",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L139-L153 |
45,538 | andrenarchy/krypy | krypy/deflation.py | _DeflationMixin.estimate_time | def estimate_time(self, nsteps, ndefl, deflweight=1.0):
'''Estimate time needed to run nsteps iterations with deflation
Uses timings from :py:attr:`linear_system` if it is an instance of
:py:class:`~krypy.linsys.TimedLinearSystem`. Otherwise, an
:py:class:`~krypy.utils.OtherError`
... | python | def estimate_time(self, nsteps, ndefl, deflweight=1.0):
'''Estimate time needed to run nsteps iterations with deflation
Uses timings from :py:attr:`linear_system` if it is an instance of
:py:class:`~krypy.linsys.TimedLinearSystem`. Otherwise, an
:py:class:`~krypy.utils.OtherError`
... | [
"def",
"estimate_time",
"(",
"self",
",",
"nsteps",
",",
"ndefl",
",",
"deflweight",
"=",
"1.0",
")",
":",
"# get ops for nsteps of this solver",
"solver_ops",
"=",
"self",
".",
"operations",
"(",
"nsteps",
")",
"# define ops for deflation setup + application with ndefl... | Estimate time needed to run nsteps iterations with deflation
Uses timings from :py:attr:`linear_system` if it is an instance of
:py:class:`~krypy.linsys.TimedLinearSystem`. Otherwise, an
:py:class:`~krypy.utils.OtherError`
is raised.
:param nsteps: number of iterations.
... | [
"Estimate",
"time",
"needed",
"to",
"run",
"nsteps",
"iterations",
"with",
"deflation"
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L182-L220 |
45,539 | andrenarchy/krypy | krypy/deflation.py | Ritz.get_vectors | def get_vectors(self, indices=None):
'''Compute Ritz vectors.'''
H_ = self._deflated_solver.H
(n_, n) = H_.shape
coeffs = self.coeffs if indices is None else self.coeffs[:, indices]
return numpy.c_[self._deflated_solver.V[:, :n],
self._deflated_solver.proj... | python | def get_vectors(self, indices=None):
'''Compute Ritz vectors.'''
H_ = self._deflated_solver.H
(n_, n) = H_.shape
coeffs = self.coeffs if indices is None else self.coeffs[:, indices]
return numpy.c_[self._deflated_solver.V[:, :n],
self._deflated_solver.proj... | [
"def",
"get_vectors",
"(",
"self",
",",
"indices",
"=",
"None",
")",
":",
"H_",
"=",
"self",
".",
"_deflated_solver",
".",
"H",
"(",
"n_",
",",
"n",
")",
"=",
"H_",
".",
"shape",
"coeffs",
"=",
"self",
".",
"coeffs",
"if",
"indices",
"is",
"None",
... | Compute Ritz vectors. | [
"Compute",
"Ritz",
"vectors",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L808-L814 |
45,540 | andrenarchy/krypy | krypy/deflation.py | Ritz.get_explicit_residual | def get_explicit_residual(self, indices=None):
'''Explicitly computes the Ritz residual.'''
ritz_vecs = self.get_vectors(indices)
return self._deflated_solver.linear_system.MlAMr * ritz_vecs \
- ritz_vecs * self.values | python | def get_explicit_residual(self, indices=None):
'''Explicitly computes the Ritz residual.'''
ritz_vecs = self.get_vectors(indices)
return self._deflated_solver.linear_system.MlAMr * ritz_vecs \
- ritz_vecs * self.values | [
"def",
"get_explicit_residual",
"(",
"self",
",",
"indices",
"=",
"None",
")",
":",
"ritz_vecs",
"=",
"self",
".",
"get_vectors",
"(",
"indices",
")",
"return",
"self",
".",
"_deflated_solver",
".",
"linear_system",
".",
"MlAMr",
"*",
"ritz_vecs",
"-",
"ritz... | Explicitly computes the Ritz residual. | [
"Explicitly",
"computes",
"the",
"Ritz",
"residual",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L816-L820 |
45,541 | andrenarchy/krypy | krypy/deflation.py | Ritz.get_explicit_resnorms | def get_explicit_resnorms(self, indices=None):
'''Explicitly computes the Ritz residual norms.'''
res = self.get_explicit_residual(indices)
# apply preconditioner
linear_system = self._deflated_solver.linear_system
Mres = linear_system.M * res
# compute norms
re... | python | def get_explicit_resnorms(self, indices=None):
'''Explicitly computes the Ritz residual norms.'''
res = self.get_explicit_residual(indices)
# apply preconditioner
linear_system = self._deflated_solver.linear_system
Mres = linear_system.M * res
# compute norms
re... | [
"def",
"get_explicit_resnorms",
"(",
"self",
",",
"indices",
"=",
"None",
")",
":",
"res",
"=",
"self",
".",
"get_explicit_residual",
"(",
"indices",
")",
"# apply preconditioner",
"linear_system",
"=",
"self",
".",
"_deflated_solver",
".",
"linear_system",
"Mres"... | Explicitly computes the Ritz residual norms. | [
"Explicitly",
"computes",
"the",
"Ritz",
"residual",
"norms",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L822-L835 |
45,542 | wrobstory/bearcart | bearcart/bearcart.py | Chart.transform_data | def transform_data(self, data):
'''Transform Pandas Timeseries into JSON format
Parameters
----------
data: DataFrame or Series
Pandas DataFrame or Series must have datetime index
Returns
-------
JSON to object.json_data
Example
----... | python | def transform_data(self, data):
'''Transform Pandas Timeseries into JSON format
Parameters
----------
data: DataFrame or Series
Pandas DataFrame or Series must have datetime index
Returns
-------
JSON to object.json_data
Example
----... | [
"def",
"transform_data",
"(",
"self",
",",
"data",
")",
":",
"def",
"type_check",
"(",
"value",
")",
":",
"'''Type check values for JSON serialization. Native Python JSON\n serialization will not recognize some Numpy data types properly,\n so they must be explictly ... | Transform Pandas Timeseries into JSON format
Parameters
----------
data: DataFrame or Series
Pandas DataFrame or Series must have datetime index
Returns
-------
JSON to object.json_data
Example
-------
>>>vis.transform_data(df)
... | [
"Transform",
"Pandas",
"Timeseries",
"into",
"JSON",
"format"
] | 8a65684830f4f0d63b455120ae329c3ebb479572 | https://github.com/wrobstory/bearcart/blob/8a65684830f4f0d63b455120ae329c3ebb479572/bearcart/bearcart.py#L147-L193 |
45,543 | wrobstory/bearcart | bearcart/bearcart.py | Chart._build_graph | def _build_graph(self):
'''Build Rickshaw graph syntax with all data'''
# Set palette colors if necessary
if not self.colors:
self.palette = self.env.get_template('palette.js')
self.template_vars.update({'palette': self.palette.render()})
self.colors = {x['na... | python | def _build_graph(self):
'''Build Rickshaw graph syntax with all data'''
# Set palette colors if necessary
if not self.colors:
self.palette = self.env.get_template('palette.js')
self.template_vars.update({'palette': self.palette.render()})
self.colors = {x['na... | [
"def",
"_build_graph",
"(",
"self",
")",
":",
"# Set palette colors if necessary",
"if",
"not",
"self",
".",
"colors",
":",
"self",
".",
"palette",
"=",
"self",
".",
"env",
".",
"get_template",
"(",
"'palette.js'",
")",
"self",
".",
"template_vars",
".",
"up... | Build Rickshaw graph syntax with all data | [
"Build",
"Rickshaw",
"graph",
"syntax",
"with",
"all",
"data"
] | 8a65684830f4f0d63b455120ae329c3ebb479572 | https://github.com/wrobstory/bearcart/blob/8a65684830f4f0d63b455120ae329c3ebb479572/bearcart/bearcart.py#L195-L218 |
45,544 | wrobstory/bearcart | bearcart/bearcart.py | Chart.create_chart | def create_chart(self, html_path='index.html', data_path='data.json',
js_path='rickshaw.min.js', css_path='rickshaw.min.css',
html_prefix=''):
'''Save bearcart output to HTML and JSON.
Parameters
----------
html_path: string, default 'index.html... | python | def create_chart(self, html_path='index.html', data_path='data.json',
js_path='rickshaw.min.js', css_path='rickshaw.min.css',
html_prefix=''):
'''Save bearcart output to HTML and JSON.
Parameters
----------
html_path: string, default 'index.html... | [
"def",
"create_chart",
"(",
"self",
",",
"html_path",
"=",
"'index.html'",
",",
"data_path",
"=",
"'data.json'",
",",
"js_path",
"=",
"'rickshaw.min.js'",
",",
"css_path",
"=",
"'rickshaw.min.css'",
",",
"html_prefix",
"=",
"''",
")",
":",
"self",
".",
"templa... | Save bearcart output to HTML and JSON.
Parameters
----------
html_path: string, default 'index.html'
Path for html output
data_path: string, default 'data.json'
Path for data JSON output
js_path: string, default 'rickshaw.min.js'
If passed, th... | [
"Save",
"bearcart",
"output",
"to",
"HTML",
"and",
"JSON",
"."
] | 8a65684830f4f0d63b455120ae329c3ebb479572 | https://github.com/wrobstory/bearcart/blob/8a65684830f4f0d63b455120ae329c3ebb479572/bearcart/bearcart.py#L220-L279 |
45,545 | raymontag/kppy | kppy/groups.py | v1Group.set_expire | def set_expire(self, y = 2999, mon = 12, d = 28, h = 23, min_ = 59,
s = 59):
"""This method is used to change the expire date of a group
- y is the year between 1 and 9999 inclusive
- mon is the month between 1 and 12
- d is a day in the given month
... | python | def set_expire(self, y = 2999, mon = 12, d = 28, h = 23, min_ = 59,
s = 59):
"""This method is used to change the expire date of a group
- y is the year between 1 and 9999 inclusive
- mon is the month between 1 and 12
- d is a day in the given month
... | [
"def",
"set_expire",
"(",
"self",
",",
"y",
"=",
"2999",
",",
"mon",
"=",
"12",
",",
"d",
"=",
"28",
",",
"h",
"=",
"23",
",",
"min_",
"=",
"59",
",",
"s",
"=",
"59",
")",
":",
"if",
"type",
"(",
"y",
")",
"is",
"not",
"int",
"or",
"type"... | This method is used to change the expire date of a group
- y is the year between 1 and 9999 inclusive
- mon is the month between 1 and 12
- d is a day in the given month
- h is a hour between 0 and 23
- min_ is a minute between 0 and 59
- s is a s... | [
"This",
"method",
"is",
"used",
"to",
"change",
"the",
"expire",
"date",
"of",
"a",
"group"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/groups.py#L79-L108 |
45,546 | raymontag/kppy | kppy/groups.py | v1Group.create_entry | def create_entry(self, title='', image=1, url='', username='', password='',
comment='', y=2999, mon=12, d=28, h=23, min_=59, s=59):
"""This method creates an entry in this group.
Compare to StdEntry for information about the arguments.
One of the following arguments is ne... | python | def create_entry(self, title='', image=1, url='', username='', password='',
comment='', y=2999, mon=12, d=28, h=23, min_=59, s=59):
"""This method creates an entry in this group.
Compare to StdEntry for information about the arguments.
One of the following arguments is ne... | [
"def",
"create_entry",
"(",
"self",
",",
"title",
"=",
"''",
",",
"image",
"=",
"1",
",",
"url",
"=",
"''",
",",
"username",
"=",
"''",
",",
"password",
"=",
"''",
",",
"comment",
"=",
"''",
",",
"y",
"=",
"2999",
",",
"mon",
"=",
"12",
",",
... | This method creates an entry in this group.
Compare to StdEntry for information about the arguments.
One of the following arguments is needed:
- title
- url
- username
- password
- comment | [
"This",
"method",
"creates",
"an",
"entry",
"in",
"this",
"group",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/groups.py#L125-L142 |
45,547 | raymontag/kppy | kppy/entries.py | v1Entry.set_title | def set_title(self, title = None):
"""This method is used to change an entry title.
A new title string is needed.
"""
if title is None or type(title) is not str:
raise KPError("Need a new title.")
else:
self.title = title
self.last_mod = dat... | python | def set_title(self, title = None):
"""This method is used to change an entry title.
A new title string is needed.
"""
if title is None or type(title) is not str:
raise KPError("Need a new title.")
else:
self.title = title
self.last_mod = dat... | [
"def",
"set_title",
"(",
"self",
",",
"title",
"=",
"None",
")",
":",
"if",
"title",
"is",
"None",
"or",
"type",
"(",
"title",
")",
"is",
"not",
"str",
":",
"raise",
"KPError",
"(",
"\"Need a new title.\"",
")",
"else",
":",
"self",
".",
"title",
"="... | This method is used to change an entry title.
A new title string is needed. | [
"This",
"method",
"is",
"used",
"to",
"change",
"an",
"entry",
"title",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L55-L67 |
45,548 | raymontag/kppy | kppy/entries.py | v1Entry.set_image | def set_image(self, image = None):
"""This method is used to set the image number.
image must be an unsigned int.
"""
if image is None or type(image) is not int:
raise KPError("Need a new image number")
else:
self.image = image
self.... | python | def set_image(self, image = None):
"""This method is used to set the image number.
image must be an unsigned int.
"""
if image is None or type(image) is not int:
raise KPError("Need a new image number")
else:
self.image = image
self.... | [
"def",
"set_image",
"(",
"self",
",",
"image",
"=",
"None",
")",
":",
"if",
"image",
"is",
"None",
"or",
"type",
"(",
"image",
")",
"is",
"not",
"int",
":",
"raise",
"KPError",
"(",
"\"Need a new image number\"",
")",
"else",
":",
"self",
".",
"image",... | This method is used to set the image number.
image must be an unsigned int. | [
"This",
"method",
"is",
"used",
"to",
"set",
"the",
"image",
"number",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L69-L81 |
45,549 | raymontag/kppy | kppy/entries.py | v1Entry.set_url | def set_url(self, url = None):
"""This method is used to set the url.
url must be a string.
"""
if url is None or type(url) is not str:
raise KPError("Need a new image number")
else:
self.url = url
self.last_mod = datetime.no... | python | def set_url(self, url = None):
"""This method is used to set the url.
url must be a string.
"""
if url is None or type(url) is not str:
raise KPError("Need a new image number")
else:
self.url = url
self.last_mod = datetime.no... | [
"def",
"set_url",
"(",
"self",
",",
"url",
"=",
"None",
")",
":",
"if",
"url",
"is",
"None",
"or",
"type",
"(",
"url",
")",
"is",
"not",
"str",
":",
"raise",
"KPError",
"(",
"\"Need a new image number\"",
")",
"else",
":",
"self",
".",
"url",
"=",
... | This method is used to set the url.
url must be a string. | [
"This",
"method",
"is",
"used",
"to",
"set",
"the",
"url",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L83-L95 |
45,550 | raymontag/kppy | kppy/entries.py | v1Entry.set_username | def set_username(self, username = None):
"""This method is used to set the username.
username must be a string.
"""
if username is None or type(username) is not str:
raise KPError("Need a new image number")
else:
self.username = username
... | python | def set_username(self, username = None):
"""This method is used to set the username.
username must be a string.
"""
if username is None or type(username) is not str:
raise KPError("Need a new image number")
else:
self.username = username
... | [
"def",
"set_username",
"(",
"self",
",",
"username",
"=",
"None",
")",
":",
"if",
"username",
"is",
"None",
"or",
"type",
"(",
"username",
")",
"is",
"not",
"str",
":",
"raise",
"KPError",
"(",
"\"Need a new image number\"",
")",
"else",
":",
"self",
"."... | This method is used to set the username.
username must be a string. | [
"This",
"method",
"is",
"used",
"to",
"set",
"the",
"username",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L97-L109 |
45,551 | raymontag/kppy | kppy/entries.py | v1Entry.set_password | def set_password(self, password = None):
"""This method is used to set the password.
password must be a string.
"""
if password is None or type(password) is not str:
raise KPError("Need a new image number")
else:
self.password = password
... | python | def set_password(self, password = None):
"""This method is used to set the password.
password must be a string.
"""
if password is None or type(password) is not str:
raise KPError("Need a new image number")
else:
self.password = password
... | [
"def",
"set_password",
"(",
"self",
",",
"password",
"=",
"None",
")",
":",
"if",
"password",
"is",
"None",
"or",
"type",
"(",
"password",
")",
"is",
"not",
"str",
":",
"raise",
"KPError",
"(",
"\"Need a new image number\"",
")",
"else",
":",
"self",
"."... | This method is used to set the password.
password must be a string. | [
"This",
"method",
"is",
"used",
"to",
"set",
"the",
"password",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L111-L123 |
45,552 | raymontag/kppy | kppy/entries.py | v1Entry.set_comment | def set_comment(self, comment = None):
"""This method is used to the the comment.
comment must be a string.
"""
if comment is None or type(comment) is not str:
raise KPError("Need a new image number")
else:
self.comment = comment
sel... | python | def set_comment(self, comment = None):
"""This method is used to the the comment.
comment must be a string.
"""
if comment is None or type(comment) is not str:
raise KPError("Need a new image number")
else:
self.comment = comment
sel... | [
"def",
"set_comment",
"(",
"self",
",",
"comment",
"=",
"None",
")",
":",
"if",
"comment",
"is",
"None",
"or",
"type",
"(",
"comment",
")",
"is",
"not",
"str",
":",
"raise",
"KPError",
"(",
"\"Need a new image number\"",
")",
"else",
":",
"self",
".",
... | This method is used to the the comment.
comment must be a string. | [
"This",
"method",
"is",
"used",
"to",
"the",
"the",
"comment",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L125-L137 |
45,553 | raymontag/kppy | kppy/database.py | KPDBv1.read_buf | def read_buf(self):
"""Read database file"""
with open(self.filepath, 'rb') as handler:
try:
buf = handler.read()
# There should be a header at least
if len(buf) < 124:
raise KPError('Unexpected file size. ... | python | def read_buf(self):
"""Read database file"""
with open(self.filepath, 'rb') as handler:
try:
buf = handler.read()
# There should be a header at least
if len(buf) < 124:
raise KPError('Unexpected file size. ... | [
"def",
"read_buf",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"filepath",
",",
"'rb'",
")",
"as",
"handler",
":",
"try",
":",
"buf",
"=",
"handler",
".",
"read",
"(",
")",
"# There should be a header at least",
"if",
"len",
"(",
"buf",
")... | Read database file | [
"Read",
"database",
"file"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L295-L309 |
45,554 | raymontag/kppy | kppy/database.py | KPDBv1.close | def close(self):
"""This method closes the database correctly."""
if self.filepath is not None:
if path.isfile(self.filepath+'.lock'):
remove(self.filepath+'.lock')
self.filepath = None
self.read_only = False
self.lock()
... | python | def close(self):
"""This method closes the database correctly."""
if self.filepath is not None:
if path.isfile(self.filepath+'.lock'):
remove(self.filepath+'.lock')
self.filepath = None
self.read_only = False
self.lock()
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"filepath",
"is",
"not",
"None",
":",
"if",
"path",
".",
"isfile",
"(",
"self",
".",
"filepath",
"+",
"'.lock'",
")",
":",
"remove",
"(",
"self",
".",
"filepath",
"+",
"'.lock'",
")",
"self"... | This method closes the database correctly. | [
"This",
"method",
"closes",
"the",
"database",
"correctly",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L448-L459 |
45,555 | raymontag/kppy | kppy/database.py | KPDBv1.lock | def lock(self):
"""This method locks the database."""
self.password = None
self.keyfile = None
self.groups[:] = []
self.entries[:] = []
self._group_order[:] = []
self._entry_order[:] = []
self.root_group = v1Group()
self._num_groups = 1
... | python | def lock(self):
"""This method locks the database."""
self.password = None
self.keyfile = None
self.groups[:] = []
self.entries[:] = []
self._group_order[:] = []
self._entry_order[:] = []
self.root_group = v1Group()
self._num_groups = 1
... | [
"def",
"lock",
"(",
"self",
")",
":",
"self",
".",
"password",
"=",
"None",
"self",
".",
"keyfile",
"=",
"None",
"self",
".",
"groups",
"[",
":",
"]",
"=",
"[",
"]",
"self",
".",
"entries",
"[",
":",
"]",
"=",
"[",
"]",
"self",
".",
"_group_ord... | This method locks the database. | [
"This",
"method",
"locks",
"the",
"database",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L461-L473 |
45,556 | raymontag/kppy | kppy/database.py | KPDBv1.unlock | def unlock(self, password = None, keyfile = None, buf = None):
"""Unlock the database.
masterkey is needed.
"""
if ((password is None or password == "") and (keyfile is None or
keyfile == "")):
raise KPError("A password/keyfile is needed")
elif... | python | def unlock(self, password = None, keyfile = None, buf = None):
"""Unlock the database.
masterkey is needed.
"""
if ((password is None or password == "") and (keyfile is None or
keyfile == "")):
raise KPError("A password/keyfile is needed")
elif... | [
"def",
"unlock",
"(",
"self",
",",
"password",
"=",
"None",
",",
"keyfile",
"=",
"None",
",",
"buf",
"=",
"None",
")",
":",
"if",
"(",
"(",
"password",
"is",
"None",
"or",
"password",
"==",
"\"\"",
")",
"and",
"(",
"keyfile",
"is",
"None",
"or",
... | Unlock the database.
masterkey is needed. | [
"Unlock",
"the",
"database",
".",
"masterkey",
"is",
"needed",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L475-L494 |
45,557 | raymontag/kppy | kppy/database.py | KPDBv1.remove_group | def remove_group(self, group = None):
"""This method removes a group.
The group needed to remove the group.
group must be a v1Group.
"""
if group is None:
raise KPError("Need group to remove a group")
elif type(group) is not v1Group:
ra... | python | def remove_group(self, group = None):
"""This method removes a group.
The group needed to remove the group.
group must be a v1Group.
"""
if group is None:
raise KPError("Need group to remove a group")
elif type(group) is not v1Group:
ra... | [
"def",
"remove_group",
"(",
"self",
",",
"group",
"=",
"None",
")",
":",
"if",
"group",
"is",
"None",
":",
"raise",
"KPError",
"(",
"\"Need group to remove a group\"",
")",
"elif",
"type",
"(",
"group",
")",
"is",
"not",
"v1Group",
":",
"raise",
"KPError",... | This method removes a group.
The group needed to remove the group.
group must be a v1Group. | [
"This",
"method",
"removes",
"a",
"group",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L547-L579 |
45,558 | raymontag/kppy | kppy/database.py | KPDBv1.move_group | def move_group(self, group = None, parent = None):
"""Append group to a new parent.
group and parent must be v1Group-instances.
"""
if group is None or type(group) is not v1Group:
raise KPError("A valid group must be given.")
elif parent is not None and type(parent... | python | def move_group(self, group = None, parent = None):
"""Append group to a new parent.
group and parent must be v1Group-instances.
"""
if group is None or type(group) is not v1Group:
raise KPError("A valid group must be given.")
elif parent is not None and type(parent... | [
"def",
"move_group",
"(",
"self",
",",
"group",
"=",
"None",
",",
"parent",
"=",
"None",
")",
":",
"if",
"group",
"is",
"None",
"or",
"type",
"(",
"group",
")",
"is",
"not",
"v1Group",
":",
"raise",
"KPError",
"(",
"\"A valid group must be given.\"",
")"... | Append group to a new parent.
group and parent must be v1Group-instances. | [
"Append",
"group",
"to",
"a",
"new",
"parent",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L581-L619 |
45,559 | raymontag/kppy | kppy/database.py | KPDBv1.move_group_in_parent | def move_group_in_parent(self, group = None, index = None):
"""Move group to another position in group's parent.
index must be a valid index of group.parent.groups
"""
if group is None or index is None:
raise KPError("group and index must be set")
e... | python | def move_group_in_parent(self, group = None, index = None):
"""Move group to another position in group's parent.
index must be a valid index of group.parent.groups
"""
if group is None or index is None:
raise KPError("group and index must be set")
e... | [
"def",
"move_group_in_parent",
"(",
"self",
",",
"group",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"if",
"group",
"is",
"None",
"or",
"index",
"is",
"None",
":",
"raise",
"KPError",
"(",
"\"group and index must be set\"",
")",
"elif",
"type",
"(",... | Move group to another position in group's parent.
index must be a valid index of group.parent.groups | [
"Move",
"group",
"to",
"another",
"position",
"in",
"group",
"s",
"parent",
".",
"index",
"must",
"be",
"a",
"valid",
"index",
"of",
"group",
".",
"parent",
".",
"groups"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L621-L652 |
45,560 | raymontag/kppy | kppy/database.py | KPDBv1._move_group_helper | def _move_group_helper(self, group):
"""A helper to move the chidren of a group."""
for i in group.children:
self.groups.remove(i)
i.level = group.level + 1
self.groups.insert(self.groups.index(group) + 1, i)
if i.children:
self._move_grou... | python | def _move_group_helper(self, group):
"""A helper to move the chidren of a group."""
for i in group.children:
self.groups.remove(i)
i.level = group.level + 1
self.groups.insert(self.groups.index(group) + 1, i)
if i.children:
self._move_grou... | [
"def",
"_move_group_helper",
"(",
"self",
",",
"group",
")",
":",
"for",
"i",
"in",
"group",
".",
"children",
":",
"self",
".",
"groups",
".",
"remove",
"(",
"i",
")",
"i",
".",
"level",
"=",
"group",
".",
"level",
"+",
"1",
"self",
".",
"groups",
... | A helper to move the chidren of a group. | [
"A",
"helper",
"to",
"move",
"the",
"chidren",
"of",
"a",
"group",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L654-L662 |
45,561 | raymontag/kppy | kppy/database.py | KPDBv1.create_entry | def create_entry(self, group = None, title = "", image = 1, url = "",
username = "", password = "", comment = "",
y = 2999, mon = 12, d = 28, h = 23, min_ = 59,
s = 59):
"""This method creates a new entry.
The group which should hol... | python | def create_entry(self, group = None, title = "", image = 1, url = "",
username = "", password = "", comment = "",
y = 2999, mon = 12, d = 28, h = 23, min_ = 59,
s = 59):
"""This method creates a new entry.
The group which should hol... | [
"def",
"create_entry",
"(",
"self",
",",
"group",
"=",
"None",
",",
"title",
"=",
"\"\"",
",",
"image",
"=",
"1",
",",
"url",
"=",
"\"\"",
",",
"username",
"=",
"\"\"",
",",
"password",
"=",
"\"\"",
",",
"comment",
"=",
"\"\"",
",",
"y",
"=",
"29... | This method creates a new entry.
The group which should hold the entry is needed.
image must be an unsigned int >0, group a v1Group.
It is possible to give an expire date in the following way:
- y is the year between 1 and 9999 inclusive
- mon is the mo... | [
"This",
"method",
"creates",
"a",
"new",
"entry",
".",
"The",
"group",
"which",
"should",
"hold",
"the",
"entry",
"is",
"needed",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L664-L723 |
45,562 | raymontag/kppy | kppy/database.py | KPDBv1.remove_entry | def remove_entry(self, entry = None):
"""This method can remove entries.
The v1Entry-object entry is needed.
"""
if entry is None or type(entry) is not v1Entry:
raise KPError("Need an entry.")
elif entry in self.entries:
entry.gr... | python | def remove_entry(self, entry = None):
"""This method can remove entries.
The v1Entry-object entry is needed.
"""
if entry is None or type(entry) is not v1Entry:
raise KPError("Need an entry.")
elif entry in self.entries:
entry.gr... | [
"def",
"remove_entry",
"(",
"self",
",",
"entry",
"=",
"None",
")",
":",
"if",
"entry",
"is",
"None",
"or",
"type",
"(",
"entry",
")",
"is",
"not",
"v1Entry",
":",
"raise",
"KPError",
"(",
"\"Need an entry.\"",
")",
"elif",
"entry",
"in",
"self",
".",
... | This method can remove entries.
The v1Entry-object entry is needed. | [
"This",
"method",
"can",
"remove",
"entries",
".",
"The",
"v1Entry",
"-",
"object",
"entry",
"is",
"needed",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L725-L740 |
45,563 | raymontag/kppy | kppy/database.py | KPDBv1.move_entry | def move_entry(self, entry = None, group = None):
"""Move an entry to another group.
A v1Group group and a v1Entry entry are needed.
"""
if entry is None or group is None or type(entry) is not v1Entry or \
type(group) is not v1Group:
raise KPError("Need an entr... | python | def move_entry(self, entry = None, group = None):
"""Move an entry to another group.
A v1Group group and a v1Entry entry are needed.
"""
if entry is None or group is None or type(entry) is not v1Entry or \
type(group) is not v1Group:
raise KPError("Need an entr... | [
"def",
"move_entry",
"(",
"self",
",",
"entry",
"=",
"None",
",",
"group",
"=",
"None",
")",
":",
"if",
"entry",
"is",
"None",
"or",
"group",
"is",
"None",
"or",
"type",
"(",
"entry",
")",
"is",
"not",
"v1Entry",
"or",
"type",
"(",
"group",
")",
... | Move an entry to another group.
A v1Group group and a v1Entry entry are needed. | [
"Move",
"an",
"entry",
"to",
"another",
"group",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L742-L761 |
45,564 | raymontag/kppy | kppy/database.py | KPDBv1.move_entry_in_group | def move_entry_in_group(self, entry = None, index = None):
"""Move entry to another position inside a group.
An entry and a valid index to insert the entry in the
entry list of the holding group is needed. 0 means
that the entry is moved to the first position 1 to
the second and... | python | def move_entry_in_group(self, entry = None, index = None):
"""Move entry to another position inside a group.
An entry and a valid index to insert the entry in the
entry list of the holding group is needed. 0 means
that the entry is moved to the first position 1 to
the second and... | [
"def",
"move_entry_in_group",
"(",
"self",
",",
"entry",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"if",
"entry",
"is",
"None",
"or",
"index",
"is",
"None",
"or",
"type",
"(",
"entry",
")",
"is",
"not",
"v1Entry",
"or",
"type",
"(",
"index",
... | Move entry to another position inside a group.
An entry and a valid index to insert the entry in the
entry list of the holding group is needed. 0 means
that the entry is moved to the first position 1 to
the second and so on. | [
"Move",
"entry",
"to",
"another",
"position",
"inside",
"a",
"group",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L763-L790 |
45,565 | raymontag/kppy | kppy/database.py | KPDBv1._transform_key | def _transform_key(self, masterkey):
"""This method creates the key to decrypt the database"""
aes = AES.new(self._transf_randomseed, AES.MODE_ECB)
# Encrypt the created hash
for _ in range(self._key_transf_rounds):
masterkey = aes.encrypt(masterkey)
# Finally, has... | python | def _transform_key(self, masterkey):
"""This method creates the key to decrypt the database"""
aes = AES.new(self._transf_randomseed, AES.MODE_ECB)
# Encrypt the created hash
for _ in range(self._key_transf_rounds):
masterkey = aes.encrypt(masterkey)
# Finally, has... | [
"def",
"_transform_key",
"(",
"self",
",",
"masterkey",
")",
":",
"aes",
"=",
"AES",
".",
"new",
"(",
"self",
".",
"_transf_randomseed",
",",
"AES",
".",
"MODE_ECB",
")",
"# Encrypt the created hash",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"_key_tran... | This method creates the key to decrypt the database | [
"This",
"method",
"creates",
"the",
"key",
"to",
"decrypt",
"the",
"database"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L792-L808 |
45,566 | raymontag/kppy | kppy/database.py | KPDBv1._get_filekey | def _get_filekey(self):
"""This method creates a key from a keyfile."""
if not os.path.exists(self.keyfile):
raise KPError('Keyfile not exists.')
try:
with open(self.keyfile, 'rb') as handler:
handler.seek(0, os.SEEK_END)
size = handler.te... | python | def _get_filekey(self):
"""This method creates a key from a keyfile."""
if not os.path.exists(self.keyfile):
raise KPError('Keyfile not exists.')
try:
with open(self.keyfile, 'rb') as handler:
handler.seek(0, os.SEEK_END)
size = handler.te... | [
"def",
"_get_filekey",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"keyfile",
")",
":",
"raise",
"KPError",
"(",
"'Keyfile not exists.'",
")",
"try",
":",
"with",
"open",
"(",
"self",
".",
"keyfile",
",",
"... | This method creates a key from a keyfile. | [
"This",
"method",
"creates",
"a",
"key",
"from",
"a",
"keyfile",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L817-L844 |
45,567 | raymontag/kppy | kppy/database.py | KPDBv1._cbc_decrypt | def _cbc_decrypt(self, final_key, crypted_content):
"""This method decrypts the database"""
# Just decrypt the content with the created key
aes = AES.new(final_key, AES.MODE_CBC, self._enc_iv)
decrypted_content = aes.decrypt(crypted_content)
padding = decrypted_content[-1]
... | python | def _cbc_decrypt(self, final_key, crypted_content):
"""This method decrypts the database"""
# Just decrypt the content with the created key
aes = AES.new(final_key, AES.MODE_CBC, self._enc_iv)
decrypted_content = aes.decrypt(crypted_content)
padding = decrypted_content[-1]
... | [
"def",
"_cbc_decrypt",
"(",
"self",
",",
"final_key",
",",
"crypted_content",
")",
":",
"# Just decrypt the content with the created key",
"aes",
"=",
"AES",
".",
"new",
"(",
"final_key",
",",
"AES",
".",
"MODE_CBC",
",",
"self",
".",
"_enc_iv",
")",
"decrypted_... | This method decrypts the database | [
"This",
"method",
"decrypts",
"the",
"database"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L846-L859 |
45,568 | raymontag/kppy | kppy/database.py | KPDBv1._cbc_encrypt | def _cbc_encrypt(self, content, final_key):
"""This method encrypts the content."""
aes = AES.new(final_key, AES.MODE_CBC, self._enc_iv)
padding = (16 - len(content) % AES.block_size)
for _ in range(padding):
content += chr(padding).encode()
temp = bytes(content)
... | python | def _cbc_encrypt(self, content, final_key):
"""This method encrypts the content."""
aes = AES.new(final_key, AES.MODE_CBC, self._enc_iv)
padding = (16 - len(content) % AES.block_size)
for _ in range(padding):
content += chr(padding).encode()
temp = bytes(content)
... | [
"def",
"_cbc_encrypt",
"(",
"self",
",",
"content",
",",
"final_key",
")",
":",
"aes",
"=",
"AES",
".",
"new",
"(",
"final_key",
",",
"AES",
".",
"MODE_CBC",
",",
"self",
".",
"_enc_iv",
")",
"padding",
"=",
"(",
"16",
"-",
"len",
"(",
"content",
"... | This method encrypts the content. | [
"This",
"method",
"encrypts",
"the",
"content",
"."
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L861-L871 |
45,569 | raymontag/kppy | kppy/database.py | KPDBv1._read_group_field | def _read_group_field(self, group, levels, field_type, field_size,
decrypted_content):
"""This method handles the different fields of a group"""
if field_type == 0x0000:
# Ignored (commentar block)
pass
elif field_type == 0x0001:
g... | python | def _read_group_field(self, group, levels, field_type, field_size,
decrypted_content):
"""This method handles the different fields of a group"""
if field_type == 0x0000:
# Ignored (commentar block)
pass
elif field_type == 0x0001:
g... | [
"def",
"_read_group_field",
"(",
"self",
",",
"group",
",",
"levels",
",",
"field_type",
",",
"field_size",
",",
"decrypted_content",
")",
":",
"if",
"field_type",
"==",
"0x0000",
":",
"# Ignored (commentar block)",
"pass",
"elif",
"field_type",
"==",
"0x0001",
... | This method handles the different fields of a group | [
"This",
"method",
"handles",
"the",
"different",
"fields",
"of",
"a",
"group"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L873-L910 |
45,570 | raymontag/kppy | kppy/database.py | KPDBv1._read_entry_field | def _read_entry_field(self, entry, field_type, field_size,
decrypted_content):
"""This method handles the different fields of an entry"""
if field_type == 0x0000:
# Ignored
pass
elif field_type == 0x0001:
entry.uuid = decrypted_conte... | python | def _read_entry_field(self, entry, field_type, field_size,
decrypted_content):
"""This method handles the different fields of an entry"""
if field_type == 0x0000:
# Ignored
pass
elif field_type == 0x0001:
entry.uuid = decrypted_conte... | [
"def",
"_read_entry_field",
"(",
"self",
",",
"entry",
",",
"field_type",
",",
"field_size",
",",
"decrypted_content",
")",
":",
"if",
"field_type",
"==",
"0x0000",
":",
"# Ignored",
"pass",
"elif",
"field_type",
"==",
"0x0001",
":",
"entry",
".",
"uuid",
"=... | This method handles the different fields of an entry | [
"This",
"method",
"handles",
"the",
"different",
"fields",
"of",
"an",
"entry"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L912-L960 |
45,571 | raymontag/kppy | kppy/database.py | KPDBv1._get_date | def _get_date(self, decrypted_content):
"""This method is used to decode the packed dates of entries"""
# Just copied from original KeePassX source
date_field = struct.unpack('<5B', decrypted_content[:5])
dw1 = date_field[0]
dw2 = date_field[1]
dw3 = date_field[2... | python | def _get_date(self, decrypted_content):
"""This method is used to decode the packed dates of entries"""
# Just copied from original KeePassX source
date_field = struct.unpack('<5B', decrypted_content[:5])
dw1 = date_field[0]
dw2 = date_field[1]
dw3 = date_field[2... | [
"def",
"_get_date",
"(",
"self",
",",
"decrypted_content",
")",
":",
"# Just copied from original KeePassX source",
"date_field",
"=",
"struct",
".",
"unpack",
"(",
"'<5B'",
",",
"decrypted_content",
"[",
":",
"5",
"]",
")",
"dw1",
"=",
"date_field",
"[",
"0",
... | This method is used to decode the packed dates of entries | [
"This",
"method",
"is",
"used",
"to",
"decode",
"the",
"packed",
"dates",
"of",
"entries"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L962-L979 |
45,572 | raymontag/kppy | kppy/database.py | KPDBv1._pack_date | def _pack_date(self, date):
"""This method is used to encode dates"""
# Just copied from original KeePassX source
y, mon, d, h, min_, s = date.timetuple()[:6]
dw1 = 0x0000FFFF & ((y>>6) & 0x0000003F)
dw2 = 0x0000FFFF & ((y & 0x0000003F)<<2 | ((mon>>2) & 0x00000003))
... | python | def _pack_date(self, date):
"""This method is used to encode dates"""
# Just copied from original KeePassX source
y, mon, d, h, min_, s = date.timetuple()[:6]
dw1 = 0x0000FFFF & ((y>>6) & 0x0000003F)
dw2 = 0x0000FFFF & ((y & 0x0000003F)<<2 | ((mon>>2) & 0x00000003))
... | [
"def",
"_pack_date",
"(",
"self",
",",
"date",
")",
":",
"# Just copied from original KeePassX source",
"y",
",",
"mon",
",",
"d",
",",
"h",
",",
"min_",
",",
"s",
"=",
"date",
".",
"timetuple",
"(",
")",
"[",
":",
"6",
"]",
"dw1",
"=",
"0x0000FFFF",
... | This method is used to encode dates | [
"This",
"method",
"is",
"used",
"to",
"encode",
"dates"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L981-L994 |
45,573 | raymontag/kppy | kppy/database.py | KPDBv1._create_group_tree | def _create_group_tree(self, levels):
"""This method creates a group tree"""
if levels[0] != 0:
raise KPError("Invalid group tree")
for i in range(len(self.groups)):
if(levels[i] == 0):
self.groups[i].parent = self.root_group
self... | python | def _create_group_tree(self, levels):
"""This method creates a group tree"""
if levels[0] != 0:
raise KPError("Invalid group tree")
for i in range(len(self.groups)):
if(levels[i] == 0):
self.groups[i].parent = self.root_group
self... | [
"def",
"_create_group_tree",
"(",
"self",
",",
"levels",
")",
":",
"if",
"levels",
"[",
"0",
"]",
"!=",
"0",
":",
"raise",
"KPError",
"(",
"\"Invalid group tree\"",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"groups",
")",
")",
":"... | This method creates a group tree | [
"This",
"method",
"creates",
"a",
"group",
"tree"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L996-L1030 |
45,574 | raymontag/kppy | kppy/database.py | KPDBv1._save_group_field | def _save_group_field(self, field_type, group):
"""This method packs a group field"""
if field_type == 0x0000:
# Ignored (commentar block)
pass
elif field_type == 0x0001:
if group.id_ is not None:
return (4, struct.pack('<I', group.id_... | python | def _save_group_field(self, field_type, group):
"""This method packs a group field"""
if field_type == 0x0000:
# Ignored (commentar block)
pass
elif field_type == 0x0001:
if group.id_ is not None:
return (4, struct.pack('<I', group.id_... | [
"def",
"_save_group_field",
"(",
"self",
",",
"field_type",
",",
"group",
")",
":",
"if",
"field_type",
"==",
"0x0000",
":",
"# Ignored (commentar block)",
"pass",
"elif",
"field_type",
"==",
"0x0001",
":",
"if",
"group",
".",
"id_",
"is",
"not",
"None",
":"... | This method packs a group field | [
"This",
"method",
"packs",
"a",
"group",
"field"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L1032-L1066 |
45,575 | raymontag/kppy | kppy/database.py | KPDBv1._save_entry_field | def _save_entry_field(self, field_type, entry):
"""This group packs a entry field"""
if field_type == 0x0000:
# Ignored
pass
elif field_type == 0x0001:
if entry.uuid is not None:
return (16, entry.uuid)
elif field_type == 0x0002:
... | python | def _save_entry_field(self, field_type, entry):
"""This group packs a entry field"""
if field_type == 0x0000:
# Ignored
pass
elif field_type == 0x0001:
if entry.uuid is not None:
return (16, entry.uuid)
elif field_type == 0x0002:
... | [
"def",
"_save_entry_field",
"(",
"self",
",",
"field_type",
",",
"entry",
")",
":",
"if",
"field_type",
"==",
"0x0000",
":",
"# Ignored",
"pass",
"elif",
"field_type",
"==",
"0x0001",
":",
"if",
"entry",
".",
"uuid",
"is",
"not",
"None",
":",
"return",
"... | This group packs a entry field | [
"This",
"group",
"packs",
"a",
"entry",
"field"
] | a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a | https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L1068-L1121 |
45,576 | latchset/custodia | docs/source/examples/cfgparser.py | CustodiaConfigParser.getsecret | def getsecret(self, section, option, **kwargs):
"""Get a secret from Custodia
"""
# keyword-only arguments, vars and fallback are directly passed through
raw = kwargs.get('raw', False)
value = self.get(section, option, **kwargs)
if raw:
return value
re... | python | def getsecret(self, section, option, **kwargs):
"""Get a secret from Custodia
"""
# keyword-only arguments, vars and fallback are directly passed through
raw = kwargs.get('raw', False)
value = self.get(section, option, **kwargs)
if raw:
return value
re... | [
"def",
"getsecret",
"(",
"self",
",",
"section",
",",
"option",
",",
"*",
"*",
"kwargs",
")",
":",
"# keyword-only arguments, vars and fallback are directly passed through",
"raw",
"=",
"kwargs",
".",
"get",
"(",
"'raw'",
",",
"False",
")",
"value",
"=",
"self",... | Get a secret from Custodia | [
"Get",
"a",
"secret",
"from",
"Custodia"
] | 5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d | https://github.com/latchset/custodia/blob/5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d/docs/source/examples/cfgparser.py#L109-L117 |
45,577 | latchset/custodia | src/custodia/server/__init__.py | _load_plugin_class | def _load_plugin_class(menu, name):
"""Load Custodia plugin
Entry points are preferred over dotted import path.
"""
group = 'custodia.{}'.format(menu)
eps = list(pkg_resources.iter_entry_points(group, name))
if len(eps) > 1:
raise ValueError(
"Multiple entry points for {} {}... | python | def _load_plugin_class(menu, name):
"""Load Custodia plugin
Entry points are preferred over dotted import path.
"""
group = 'custodia.{}'.format(menu)
eps = list(pkg_resources.iter_entry_points(group, name))
if len(eps) > 1:
raise ValueError(
"Multiple entry points for {} {}... | [
"def",
"_load_plugin_class",
"(",
"menu",
",",
"name",
")",
":",
"group",
"=",
"'custodia.{}'",
".",
"format",
"(",
"menu",
")",
"eps",
"=",
"list",
"(",
"pkg_resources",
".",
"iter_entry_points",
"(",
"group",
",",
"name",
")",
")",
"if",
"len",
"(",
... | Load Custodia plugin
Entry points are preferred over dotted import path. | [
"Load",
"Custodia",
"plugin"
] | 5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d | https://github.com/latchset/custodia/blob/5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d/src/custodia/server/__init__.py#L34-L57 |
45,578 | latchset/custodia | src/custodia/server/__init__.py | _load_plugins | def _load_plugins(config, cfgparser):
"""Load and initialize plugins
"""
# set umask before any plugin gets a chance to create a file
os.umask(config['umask'])
for s in cfgparser.sections():
if s in {'ENV', 'global'}:
# ENV section is only used for interpolation
cont... | python | def _load_plugins(config, cfgparser):
"""Load and initialize plugins
"""
# set umask before any plugin gets a chance to create a file
os.umask(config['umask'])
for s in cfgparser.sections():
if s in {'ENV', 'global'}:
# ENV section is only used for interpolation
cont... | [
"def",
"_load_plugins",
"(",
"config",
",",
"cfgparser",
")",
":",
"# set umask before any plugin gets a chance to create a file",
"os",
".",
"umask",
"(",
"config",
"[",
"'umask'",
"]",
")",
"for",
"s",
"in",
"cfgparser",
".",
"sections",
"(",
")",
":",
"if",
... | Load and initialize plugins | [
"Load",
"and",
"initialize",
"plugins"
] | 5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d | https://github.com/latchset/custodia/blob/5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d/src/custodia/server/__init__.py#L86-L127 |
45,579 | latchset/custodia | src/custodia/plugin.py | OptionHandler.get | def get(self, po):
"""Lookup value for a PluginOption instance
Args:
po: PluginOption
Returns: converted value
"""
name = po.name
typ = po.typ
default = po.default
handler = getattr(self, '_get_{}'.format(typ), None)
if handler is No... | python | def get(self, po):
"""Lookup value for a PluginOption instance
Args:
po: PluginOption
Returns: converted value
"""
name = po.name
typ = po.typ
default = po.default
handler = getattr(self, '_get_{}'.format(typ), None)
if handler is No... | [
"def",
"get",
"(",
"self",
",",
"po",
")",
":",
"name",
"=",
"po",
".",
"name",
"typ",
"=",
"po",
".",
"typ",
"default",
"=",
"po",
".",
"default",
"handler",
"=",
"getattr",
"(",
"self",
",",
"'_get_{}'",
".",
"format",
"(",
"typ",
")",
",",
"... | Lookup value for a PluginOption instance
Args:
po: PluginOption
Returns: converted value | [
"Lookup",
"value",
"for",
"a",
"PluginOption",
"instance"
] | 5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d | https://github.com/latchset/custodia/blob/5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d/src/custodia/plugin.py#L80-L106 |
45,580 | latchset/custodia | src/custodia/message/simple.py | SimpleKey.parse | def parse(self, msg, name):
"""Parses a simple message
:param msg: the json-decoded value
:param name: the requested name
:raises UnknownMessageType: if the type is not 'simple'
:raises InvalidMessage: if the message cannot be parsed or validated
"""
# On reque... | python | def parse(self, msg, name):
"""Parses a simple message
:param msg: the json-decoded value
:param name: the requested name
:raises UnknownMessageType: if the type is not 'simple'
:raises InvalidMessage: if the message cannot be parsed or validated
"""
# On reque... | [
"def",
"parse",
"(",
"self",
",",
"msg",
",",
"name",
")",
":",
"# On requests we imply 'simple' if there is no input message",
"if",
"msg",
"is",
"None",
":",
"return",
"if",
"not",
"isinstance",
"(",
"msg",
",",
"string_types",
")",
":",
"raise",
"InvalidMessa... | Parses a simple message
:param msg: the json-decoded value
:param name: the requested name
:raises UnknownMessageType: if the type is not 'simple'
:raises InvalidMessage: if the message cannot be parsed or validated | [
"Parses",
"a",
"simple",
"message"
] | 5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d | https://github.com/latchset/custodia/blob/5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d/src/custodia/message/simple.py#L13-L32 |
45,581 | latchset/custodia | src/custodia/ipa/vault.py | krb5_unparse_principal_name | def krb5_unparse_principal_name(name):
"""Split a Kerberos principal name into parts
Returns:
* ('host', hostname, realm) for a host principal
* (servicename, hostname, realm) for a service principal
* (None, username, realm) for a user principal
:param text name: Kerberos principal n... | python | def krb5_unparse_principal_name(name):
"""Split a Kerberos principal name into parts
Returns:
* ('host', hostname, realm) for a host principal
* (servicename, hostname, realm) for a service principal
* (None, username, realm) for a user principal
:param text name: Kerberos principal n... | [
"def",
"krb5_unparse_principal_name",
"(",
"name",
")",
":",
"prefix",
",",
"realm",
"=",
"name",
".",
"split",
"(",
"u'@'",
")",
"if",
"u'/'",
"in",
"prefix",
":",
"service",
",",
"host",
"=",
"prefix",
".",
"rsplit",
"(",
"u'/'",
",",
"1",
")",
"re... | Split a Kerberos principal name into parts
Returns:
* ('host', hostname, realm) for a host principal
* (servicename, hostname, realm) for a service principal
* (None, username, realm) for a user principal
:param text name: Kerberos principal name
:return: (service, host, realm) or (No... | [
"Split",
"a",
"Kerberos",
"principal",
"name",
"into",
"parts"
] | 5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d | https://github.com/latchset/custodia/blob/5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d/src/custodia/ipa/vault.py#L18-L34 |
45,582 | latchset/custodia | src/custodia/message/kem.py | KEMHandler.parse | def parse(self, msg, name):
"""Parses the message.
We check that the message is properly formatted.
:param msg: a json-encoded value containing a JWS or JWE+JWS token
:raises InvalidMessage: if the message cannot be parsed or validated
:returns: A verified payload
"""... | python | def parse(self, msg, name):
"""Parses the message.
We check that the message is properly formatted.
:param msg: a json-encoded value containing a JWS or JWE+JWS token
:raises InvalidMessage: if the message cannot be parsed or validated
:returns: A verified payload
"""... | [
"def",
"parse",
"(",
"self",
",",
"msg",
",",
"name",
")",
":",
"try",
":",
"jtok",
"=",
"JWT",
"(",
"jwt",
"=",
"msg",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"InvalidMessage",
"(",
"'Failed to parse message: %s'",
"%",
"str",
"(",
"e",
... | Parses the message.
We check that the message is properly formatted.
:param msg: a json-encoded value containing a JWS or JWE+JWS token
:raises InvalidMessage: if the message cannot be parsed or validated
:returns: A verified payload | [
"Parses",
"the",
"message",
"."
] | 5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d | https://github.com/latchset/custodia/blob/5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d/src/custodia/message/kem.py#L133-L183 |
45,583 | latchset/custodia | src/custodia/server/args.py | instance_name | def instance_name(string):
"""Check for valid instance name
"""
invalid = ':/@'
if set(string).intersection(invalid):
msg = 'Invalid instance name {}'.format(string)
raise argparse.ArgumentTypeError(msg)
return string | python | def instance_name(string):
"""Check for valid instance name
"""
invalid = ':/@'
if set(string).intersection(invalid):
msg = 'Invalid instance name {}'.format(string)
raise argparse.ArgumentTypeError(msg)
return string | [
"def",
"instance_name",
"(",
"string",
")",
":",
"invalid",
"=",
"':/@'",
"if",
"set",
"(",
"string",
")",
".",
"intersection",
"(",
"invalid",
")",
":",
"msg",
"=",
"'Invalid instance name {}'",
".",
"format",
"(",
"string",
")",
"raise",
"argparse",
".",... | Check for valid instance name | [
"Check",
"for",
"valid",
"instance",
"name"
] | 5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d | https://github.com/latchset/custodia/blob/5ad4cd7a2f40babc6b8b5d16215b7e27ca993b6d/src/custodia/server/args.py#L35-L42 |
45,584 | rocky/python-xasm | xasm/pyc_convert.py | copy_magic_into_pyc | def copy_magic_into_pyc(input_pyc, output_pyc,
src_version, dest_version):
"""Bytecodes are the same except the magic number, so just change
that"""
(version, timestamp, magic_int,
co, is_pypy, source_size) = load_module(input_pyc)
assert version == float(src_version), (
... | python | def copy_magic_into_pyc(input_pyc, output_pyc,
src_version, dest_version):
"""Bytecodes are the same except the magic number, so just change
that"""
(version, timestamp, magic_int,
co, is_pypy, source_size) = load_module(input_pyc)
assert version == float(src_version), (
... | [
"def",
"copy_magic_into_pyc",
"(",
"input_pyc",
",",
"output_pyc",
",",
"src_version",
",",
"dest_version",
")",
":",
"(",
"version",
",",
"timestamp",
",",
"magic_int",
",",
"co",
",",
"is_pypy",
",",
"source_size",
")",
"=",
"load_module",
"(",
"input_pyc",
... | Bytecodes are the same except the magic number, so just change
that | [
"Bytecodes",
"are",
"the",
"same",
"except",
"the",
"magic",
"number",
"so",
"just",
"change",
"that"
] | 03e9576112934d00fbc70645b781ed7b3e3fcda1 | https://github.com/rocky/python-xasm/blob/03e9576112934d00fbc70645b781ed7b3e3fcda1/xasm/pyc_convert.py#L27-L39 |
45,585 | rocky/python-xasm | xasm/pyc_convert.py | transform_26_27 | def transform_26_27(inst, new_inst, i, n, offset,
instructions, new_asm):
"""Change JUMP_IF_FALSE and JUMP_IF_TRUE to
POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE"""
if inst.opname in ('JUMP_IF_FALSE', 'JUMP_IF_TRUE'):
i += 1
assert i < n
assert instructions[i].opname =... | python | def transform_26_27(inst, new_inst, i, n, offset,
instructions, new_asm):
"""Change JUMP_IF_FALSE and JUMP_IF_TRUE to
POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE"""
if inst.opname in ('JUMP_IF_FALSE', 'JUMP_IF_TRUE'):
i += 1
assert i < n
assert instructions[i].opname =... | [
"def",
"transform_26_27",
"(",
"inst",
",",
"new_inst",
",",
"i",
",",
"n",
",",
"offset",
",",
"instructions",
",",
"new_asm",
")",
":",
"if",
"inst",
".",
"opname",
"in",
"(",
"'JUMP_IF_FALSE'",
",",
"'JUMP_IF_TRUE'",
")",
":",
"i",
"+=",
"1",
"asser... | Change JUMP_IF_FALSE and JUMP_IF_TRUE to
POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE | [
"Change",
"JUMP_IF_FALSE",
"and",
"JUMP_IF_TRUE",
"to",
"POP_JUMP_IF_FALSE",
"and",
"POP_JUMP_IF_TRUE"
] | 03e9576112934d00fbc70645b781ed7b3e3fcda1 | https://github.com/rocky/python-xasm/blob/03e9576112934d00fbc70645b781ed7b3e3fcda1/xasm/pyc_convert.py#L53-L70 |
45,586 | rocky/python-xasm | xasm/pyc_convert.py | transform_32_33 | def transform_32_33(inst, new_inst, i, n, offset,
instructions, new_asm):
"""MAKEFUNCTION adds another const. probably MAKECLASS as well
"""
add_size = xdis.op_size(new_inst.opcode, opcode_33)
if inst.opname in ('MAKE_FUNCTION','MAKE_CLOSURE'):
# Previous instruction should b... | python | def transform_32_33(inst, new_inst, i, n, offset,
instructions, new_asm):
"""MAKEFUNCTION adds another const. probably MAKECLASS as well
"""
add_size = xdis.op_size(new_inst.opcode, opcode_33)
if inst.opname in ('MAKE_FUNCTION','MAKE_CLOSURE'):
# Previous instruction should b... | [
"def",
"transform_32_33",
"(",
"inst",
",",
"new_inst",
",",
"i",
",",
"n",
",",
"offset",
",",
"instructions",
",",
"new_asm",
")",
":",
"add_size",
"=",
"xdis",
".",
"op_size",
"(",
"new_inst",
".",
"opcode",
",",
"opcode_33",
")",
"if",
"inst",
".",... | MAKEFUNCTION adds another const. probably MAKECLASS as well | [
"MAKEFUNCTION",
"adds",
"another",
"const",
".",
"probably",
"MAKECLASS",
"as",
"well"
] | 03e9576112934d00fbc70645b781ed7b3e3fcda1 | https://github.com/rocky/python-xasm/blob/03e9576112934d00fbc70645b781ed7b3e3fcda1/xasm/pyc_convert.py#L72-L106 |
45,587 | rocky/python-xasm | xasm/pyc_convert.py | transform_33_32 | def transform_33_32(inst, new_inst, i, n, offset,
instructions, new_asm):
"""MAKE_FUNCTION, and MAKE_CLOSURE have an additional LOAD_CONST of a name
that are not in Python 3.2. Remove these.
"""
add_size = xdis.op_size(new_inst.opcode, opcode_33)
if inst.opname in ('MAKE_FUNCTION... | python | def transform_33_32(inst, new_inst, i, n, offset,
instructions, new_asm):
"""MAKE_FUNCTION, and MAKE_CLOSURE have an additional LOAD_CONST of a name
that are not in Python 3.2. Remove these.
"""
add_size = xdis.op_size(new_inst.opcode, opcode_33)
if inst.opname in ('MAKE_FUNCTION... | [
"def",
"transform_33_32",
"(",
"inst",
",",
"new_inst",
",",
"i",
",",
"n",
",",
"offset",
",",
"instructions",
",",
"new_asm",
")",
":",
"add_size",
"=",
"xdis",
".",
"op_size",
"(",
"new_inst",
".",
"opcode",
",",
"opcode_33",
")",
"if",
"inst",
".",... | MAKE_FUNCTION, and MAKE_CLOSURE have an additional LOAD_CONST of a name
that are not in Python 3.2. Remove these. | [
"MAKE_FUNCTION",
"and",
"MAKE_CLOSURE",
"have",
"an",
"additional",
"LOAD_CONST",
"of",
"a",
"name",
"that",
"are",
"not",
"in",
"Python",
"3",
".",
"2",
".",
"Remove",
"these",
"."
] | 03e9576112934d00fbc70645b781ed7b3e3fcda1 | https://github.com/rocky/python-xasm/blob/03e9576112934d00fbc70645b781ed7b3e3fcda1/xasm/pyc_convert.py#L108-L134 |
45,588 | rocky/python-xasm | xasm/pyc_convert.py | main | def main(conversion_type, input_pyc, output_pyc):
"""Convert Python bytecode from one version to another.
INPUT_PYC contains the input bytecode path name
OUTPUT_PYC contians the output bytecode path name if supplied
The --conversion type option specifies what conversion to do.
Note: there are a v... | python | def main(conversion_type, input_pyc, output_pyc):
"""Convert Python bytecode from one version to another.
INPUT_PYC contains the input bytecode path name
OUTPUT_PYC contians the output bytecode path name if supplied
The --conversion type option specifies what conversion to do.
Note: there are a v... | [
"def",
"main",
"(",
"conversion_type",
",",
"input_pyc",
",",
"output_pyc",
")",
":",
"shortname",
"=",
"osp",
".",
"basename",
"(",
"input_pyc",
")",
"if",
"shortname",
".",
"endswith",
"(",
"'.pyc'",
")",
":",
"shortname",
"=",
"shortname",
"[",
":",
"... | Convert Python bytecode from one version to another.
INPUT_PYC contains the input bytecode path name
OUTPUT_PYC contians the output bytecode path name if supplied
The --conversion type option specifies what conversion to do.
Note: there are a very limited set of conversions currently supported.
H... | [
"Convert",
"Python",
"bytecode",
"from",
"one",
"version",
"to",
"another",
"."
] | 03e9576112934d00fbc70645b781ed7b3e3fcda1 | https://github.com/rocky/python-xasm/blob/03e9576112934d00fbc70645b781ed7b3e3fcda1/xasm/pyc_convert.py#L189-L220 |
45,589 | kailashbuki/fingerprint | fingerprint/fingerprint.py | Fingerprint.generate | def generate(self, str=None, fpath=None):
"""generates fingerprints of the input. Either provide `str` to compute fingerprint directly from your string or `fpath` to compute fingerprint from the text of the file. Make sure to have your text decoded in `utf-8` format if you pass the input string.
Args:
... | python | def generate(self, str=None, fpath=None):
"""generates fingerprints of the input. Either provide `str` to compute fingerprint directly from your string or `fpath` to compute fingerprint from the text of the file. Make sure to have your text decoded in `utf-8` format if you pass the input string.
Args:
... | [
"def",
"generate",
"(",
"self",
",",
"str",
"=",
"None",
",",
"fpath",
"=",
"None",
")",
":",
"self",
".",
"prepare_storage",
"(",
")",
"self",
".",
"str",
"=",
"self",
".",
"load_file",
"(",
"fpath",
")",
"if",
"fpath",
"else",
"self",
".",
"sanit... | generates fingerprints of the input. Either provide `str` to compute fingerprint directly from your string or `fpath` to compute fingerprint from the text of the file. Make sure to have your text decoded in `utf-8` format if you pass the input string.
Args:
str (Optional(str)): string whose fingerp... | [
"generates",
"fingerprints",
"of",
"the",
"input",
".",
"Either",
"provide",
"str",
"to",
"compute",
"fingerprint",
"directly",
"from",
"your",
"string",
"or",
"fpath",
"to",
"compute",
"fingerprint",
"from",
"the",
"text",
"of",
"the",
"file",
".",
"Make",
... | 674bf8615d81afa7657b003f8700590ff269de65 | https://github.com/kailashbuki/fingerprint/blob/674bf8615d81afa7657b003f8700590ff269de65/fingerprint/fingerprint.py#L114-L133 |
45,590 | rocky/python-xasm | xasm/xasm_cli.py | main | def main(pyc_file, asm_path):
"""
Create Python bytecode from a Python assembly file.
ASM_PATH gives the input Python assembly file. We suggest ending the
file in .pyc
If --pyc-file is given, that indicates the path to write the
Python bytecode. The path should end in '.pyc'.
See https://... | python | def main(pyc_file, asm_path):
"""
Create Python bytecode from a Python assembly file.
ASM_PATH gives the input Python assembly file. We suggest ending the
file in .pyc
If --pyc-file is given, that indicates the path to write the
Python bytecode. The path should end in '.pyc'.
See https://... | [
"def",
"main",
"(",
"pyc_file",
",",
"asm_path",
")",
":",
"if",
"os",
".",
"stat",
"(",
"asm_path",
")",
".",
"st_size",
"==",
"0",
":",
"print",
"(",
"\"Size of assembly file %s is zero\"",
"%",
"asm_path",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"as... | Create Python bytecode from a Python assembly file.
ASM_PATH gives the input Python assembly file. We suggest ending the
file in .pyc
If --pyc-file is given, that indicates the path to write the
Python bytecode. The path should end in '.pyc'.
See https://github.com/rocky/python-xasm/blob/master/H... | [
"Create",
"Python",
"bytecode",
"from",
"a",
"Python",
"assembly",
"file",
"."
] | 03e9576112934d00fbc70645b781ed7b3e3fcda1 | https://github.com/rocky/python-xasm/blob/03e9576112934d00fbc70645b781ed7b3e3fcda1/xasm/xasm_cli.py#L11-L32 |
45,591 | tgs/requests-jwt | requests_jwt.py | JWTAuth.expire | def expire(self, secs):
"""
Adds the standard 'exp' field, used to prevent replay attacks.
Adds the 'exp' field to the payload. When a request is made,
the field says that it should expire at now + `secs` seconds.
Of course, this provides no protection unless the server reads
... | python | def expire(self, secs):
"""
Adds the standard 'exp' field, used to prevent replay attacks.
Adds the 'exp' field to the payload. When a request is made,
the field says that it should expire at now + `secs` seconds.
Of course, this provides no protection unless the server reads
... | [
"def",
"expire",
"(",
"self",
",",
"secs",
")",
":",
"self",
".",
"add_field",
"(",
"'exp'",
",",
"lambda",
"req",
":",
"int",
"(",
"time",
".",
"time",
"(",
")",
"+",
"secs",
")",
")"
] | Adds the standard 'exp' field, used to prevent replay attacks.
Adds the 'exp' field to the payload. When a request is made,
the field says that it should expire at now + `secs` seconds.
Of course, this provides no protection unless the server reads
and interprets this field. | [
"Adds",
"the",
"standard",
"exp",
"field",
"used",
"to",
"prevent",
"replay",
"attacks",
"."
] | 0806813c3da1d379e5ced09328cffa35bfbb73ad | https://github.com/tgs/requests-jwt/blob/0806813c3da1d379e5ced09328cffa35bfbb73ad/requests_jwt.py#L117-L128 |
45,592 | tgs/requests-jwt | requests_jwt.py | JWTAuth._generate | def _generate(self, request):
"""
Generate a payload for the given request.
"""
payload = {}
for field, gen in self._generators.items():
value = None
if callable(gen):
value = gen(request)
else:
value = gen
... | python | def _generate(self, request):
"""
Generate a payload for the given request.
"""
payload = {}
for field, gen in self._generators.items():
value = None
if callable(gen):
value = gen(request)
else:
value = gen
... | [
"def",
"_generate",
"(",
"self",
",",
"request",
")",
":",
"payload",
"=",
"{",
"}",
"for",
"field",
",",
"gen",
"in",
"self",
".",
"_generators",
".",
"items",
"(",
")",
":",
"value",
"=",
"None",
"if",
"callable",
"(",
"gen",
")",
":",
"value",
... | Generate a payload for the given request. | [
"Generate",
"a",
"payload",
"for",
"the",
"given",
"request",
"."
] | 0806813c3da1d379e5ced09328cffa35bfbb73ad | https://github.com/tgs/requests-jwt/blob/0806813c3da1d379e5ced09328cffa35bfbb73ad/requests_jwt.py#L137-L151 |
45,593 | mapnik/Cascadenik | cascadenik/compile.py | url2fs | def url2fs(url):
""" encode a URL to be safe as a filename """
uri, extension = posixpath.splitext(url)
return safe64.dir(uri) + extension | python | def url2fs(url):
""" encode a URL to be safe as a filename """
uri, extension = posixpath.splitext(url)
return safe64.dir(uri) + extension | [
"def",
"url2fs",
"(",
"url",
")",
":",
"uri",
",",
"extension",
"=",
"posixpath",
".",
"splitext",
"(",
"url",
")",
"return",
"safe64",
".",
"dir",
"(",
"uri",
")",
"+",
"extension"
] | encode a URL to be safe as a filename | [
"encode",
"a",
"URL",
"to",
"be",
"safe",
"as",
"a",
"filename"
] | 82f66859340a31dfcb24af127274f262d4f3ad85 | https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L104-L107 |
45,594 | mapnik/Cascadenik | cascadenik/compile.py | is_merc_projection | def is_merc_projection(srs):
""" Return true if the map projection matches that used by VEarth, Google, OSM, etc.
Is currently necessary for zoom-level shorthand for scale-denominator.
"""
if srs.lower() == '+init=epsg:900913':
return True
# observed
srs = dict([p.split('=') fo... | python | def is_merc_projection(srs):
""" Return true if the map projection matches that used by VEarth, Google, OSM, etc.
Is currently necessary for zoom-level shorthand for scale-denominator.
"""
if srs.lower() == '+init=epsg:900913':
return True
# observed
srs = dict([p.split('=') fo... | [
"def",
"is_merc_projection",
"(",
"srs",
")",
":",
"if",
"srs",
".",
"lower",
"(",
")",
"==",
"'+init=epsg:900913'",
":",
"return",
"True",
"# observed",
"srs",
"=",
"dict",
"(",
"[",
"p",
".",
"split",
"(",
"'='",
")",
"for",
"p",
"in",
"srs",
".",
... | Return true if the map projection matches that used by VEarth, Google, OSM, etc.
Is currently necessary for zoom-level shorthand for scale-denominator. | [
"Return",
"true",
"if",
"the",
"map",
"projection",
"matches",
"that",
"used",
"by",
"VEarth",
"Google",
"OSM",
"etc",
".",
"Is",
"currently",
"necessary",
"for",
"zoom",
"-",
"level",
"shorthand",
"for",
"scale",
"-",
"denominator",
"."
] | 82f66859340a31dfcb24af127274f262d4f3ad85 | https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L587-L608 |
45,595 | mapnik/Cascadenik | cascadenik/compile.py | extract_declarations | def extract_declarations(map_el, dirs, scale=1, user_styles=[]):
""" Given a Map element and directories object, remove and return a complete
list of style declarations from any Stylesheet elements found within.
"""
styles = []
#
# First, look at all the stylesheets defined in the map i... | python | def extract_declarations(map_el, dirs, scale=1, user_styles=[]):
""" Given a Map element and directories object, remove and return a complete
list of style declarations from any Stylesheet elements found within.
"""
styles = []
#
# First, look at all the stylesheets defined in the map i... | [
"def",
"extract_declarations",
"(",
"map_el",
",",
"dirs",
",",
"scale",
"=",
"1",
",",
"user_styles",
"=",
"[",
"]",
")",
":",
"styles",
"=",
"[",
"]",
"#",
"# First, look at all the stylesheets defined in the map itself.",
"#",
"for",
"stylesheet",
"in",
"map_... | Given a Map element and directories object, remove and return a complete
list of style declarations from any Stylesheet elements found within. | [
"Given",
"a",
"Map",
"element",
"and",
"directories",
"object",
"remove",
"and",
"return",
"a",
"complete",
"list",
"of",
"style",
"declarations",
"from",
"any",
"Stylesheet",
"elements",
"found",
"within",
"."
] | 82f66859340a31dfcb24af127274f262d4f3ad85 | https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L610-L656 |
45,596 | mapnik/Cascadenik | cascadenik/compile.py | is_applicable_selector | def is_applicable_selector(selector, filter):
""" Given a Selector and Filter, return True if the Selector is
compatible with the given Filter, and False if they contradict.
"""
for test in selector.allTests():
if not test.isCompatible(filter.tests):
return False
return ... | python | def is_applicable_selector(selector, filter):
""" Given a Selector and Filter, return True if the Selector is
compatible with the given Filter, and False if they contradict.
"""
for test in selector.allTests():
if not test.isCompatible(filter.tests):
return False
return ... | [
"def",
"is_applicable_selector",
"(",
"selector",
",",
"filter",
")",
":",
"for",
"test",
"in",
"selector",
".",
"allTests",
"(",
")",
":",
"if",
"not",
"test",
".",
"isCompatible",
"(",
"filter",
".",
"tests",
")",
":",
"return",
"False",
"return",
"Tru... | Given a Selector and Filter, return True if the Selector is
compatible with the given Filter, and False if they contradict. | [
"Given",
"a",
"Selector",
"and",
"Filter",
"return",
"True",
"if",
"the",
"Selector",
"is",
"compatible",
"with",
"the",
"given",
"Filter",
"and",
"False",
"if",
"they",
"contradict",
"."
] | 82f66859340a31dfcb24af127274f262d4f3ad85 | https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L787-L795 |
45,597 | mapnik/Cascadenik | cascadenik/compile.py | get_polygon_rules | def get_polygon_rules(declarations):
""" Given a Map element, a Layer element, and a list of declarations,
create a new Style element with a PolygonSymbolizer, add it to Map
and refer to it in Layer.
"""
property_map = {'polygon-fill': 'fill', 'polygon-opacity': 'fill-opacity',
... | python | def get_polygon_rules(declarations):
""" Given a Map element, a Layer element, and a list of declarations,
create a new Style element with a PolygonSymbolizer, add it to Map
and refer to it in Layer.
"""
property_map = {'polygon-fill': 'fill', 'polygon-opacity': 'fill-opacity',
... | [
"def",
"get_polygon_rules",
"(",
"declarations",
")",
":",
"property_map",
"=",
"{",
"'polygon-fill'",
":",
"'fill'",
",",
"'polygon-opacity'",
":",
"'fill-opacity'",
",",
"'polygon-gamma'",
":",
"'gamma'",
",",
"'polygon-meta-output'",
":",
"'meta-output'",
",",
"'... | Given a Map element, a Layer element, and a list of declarations,
create a new Style element with a PolygonSymbolizer, add it to Map
and refer to it in Layer. | [
"Given",
"a",
"Map",
"element",
"a",
"Layer",
"element",
"and",
"a",
"list",
"of",
"declarations",
"create",
"a",
"new",
"Style",
"element",
"with",
"a",
"PolygonSymbolizer",
"add",
"it",
"to",
"Map",
"and",
"refer",
"to",
"it",
"in",
"Layer",
"."
] | 82f66859340a31dfcb24af127274f262d4f3ad85 | https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L844-L867 |
45,598 | mapnik/Cascadenik | cascadenik/compile.py | get_raster_rules | def get_raster_rules(declarations):
""" Given a Map element, a Layer element, and a list of declarations,
create a new Style element with a RasterSymbolizer, add it to Map
and refer to it in Layer.
The RasterSymbolizer will always created, even if there are
no applicable dec... | python | def get_raster_rules(declarations):
""" Given a Map element, a Layer element, and a list of declarations,
create a new Style element with a RasterSymbolizer, add it to Map
and refer to it in Layer.
The RasterSymbolizer will always created, even if there are
no applicable dec... | [
"def",
"get_raster_rules",
"(",
"declarations",
")",
":",
"property_map",
"=",
"{",
"'raster-opacity'",
":",
"'opacity'",
",",
"'raster-mode'",
":",
"'mode'",
",",
"'raster-scaling'",
":",
"'scaling'",
"}",
"property_names",
"=",
"property_map",
".",
"keys",
"(",
... | Given a Map element, a Layer element, and a list of declarations,
create a new Style element with a RasterSymbolizer, add it to Map
and refer to it in Layer.
The RasterSymbolizer will always created, even if there are
no applicable declarations. | [
"Given",
"a",
"Map",
"element",
"a",
"Layer",
"element",
"and",
"a",
"list",
"of",
"declarations",
"create",
"a",
"new",
"Style",
"element",
"with",
"a",
"RasterSymbolizer",
"add",
"it",
"to",
"Map",
"and",
"refer",
"to",
"it",
"in",
"Layer",
".",
"The",... | 82f66859340a31dfcb24af127274f262d4f3ad85 | https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L869-L900 |
45,599 | mapnik/Cascadenik | cascadenik/compile.py | locally_cache_remote_file | def locally_cache_remote_file(href, dir):
""" Locally cache a remote resource using a predictable file name
and awareness of modification date. Assume that files are "normal"
which is to say they have filenames with extensions.
"""
scheme, host, remote_path, params, query, fragment = urlpars... | python | def locally_cache_remote_file(href, dir):
""" Locally cache a remote resource using a predictable file name
and awareness of modification date. Assume that files are "normal"
which is to say they have filenames with extensions.
"""
scheme, host, remote_path, params, query, fragment = urlpars... | [
"def",
"locally_cache_remote_file",
"(",
"href",
",",
"dir",
")",
":",
"scheme",
",",
"host",
",",
"remote_path",
",",
"params",
",",
"query",
",",
"fragment",
"=",
"urlparse",
"(",
"href",
")",
"assert",
"scheme",
"in",
"(",
"'http'",
",",
"'https'",
")... | Locally cache a remote resource using a predictable file name
and awareness of modification date. Assume that files are "normal"
which is to say they have filenames with extensions. | [
"Locally",
"cache",
"a",
"remote",
"resource",
"using",
"a",
"predictable",
"file",
"name",
"and",
"awareness",
"of",
"modification",
"date",
".",
"Assume",
"that",
"files",
"are",
"normal",
"which",
"is",
"to",
"say",
"they",
"have",
"filenames",
"with",
"e... | 82f66859340a31dfcb24af127274f262d4f3ad85 | https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L1064-L1117 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.