repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
vnmabus/dcor
dcor/_dcor_internals.py
_double_centered_imp
def _double_centered_imp(a, out=None): """ Real implementation of :func:`double_centered`. This function is used to make parameter ``out`` keyword-only in Python 2. """ out = _float_copy_to_out(out, a) dim = np.size(a, 0) mu = np.sum(a) / (dim * dim) sum_cols = np.sum(a, 0, keepd...
python
def _double_centered_imp(a, out=None): """ Real implementation of :func:`double_centered`. This function is used to make parameter ``out`` keyword-only in Python 2. """ out = _float_copy_to_out(out, a) dim = np.size(a, 0) mu = np.sum(a) / (dim * dim) sum_cols = np.sum(a, 0, keepd...
[ "def", "_double_centered_imp", "(", "a", ",", "out", "=", "None", ")", ":", "out", "=", "_float_copy_to_out", "(", "out", ",", "a", ")", "dim", "=", "np", ".", "size", "(", "a", ",", "0", ")", "mu", "=", "np", ".", "sum", "(", "a", ")", "/", ...
Real implementation of :func:`double_centered`. This function is used to make parameter ``out`` keyword-only in Python 2.
[ "Real", "implementation", "of", ":", "func", ":", "double_centered", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L56-L79
train
Real implementation of double_centered.
vnmabus/dcor
dcor/_dcor_internals.py
_u_centered_imp
def _u_centered_imp(a, out=None): """ Real implementation of :func:`u_centered`. This function is used to make parameter ``out`` keyword-only in Python 2. """ out = _float_copy_to_out(out, a) dim = np.size(a, 0) u_mu = np.sum(a) / ((dim - 1) * (dim - 2)) sum_cols = np.sum(a, 0, k...
python
def _u_centered_imp(a, out=None): """ Real implementation of :func:`u_centered`. This function is used to make parameter ``out`` keyword-only in Python 2. """ out = _float_copy_to_out(out, a) dim = np.size(a, 0) u_mu = np.sum(a) / ((dim - 1) * (dim - 2)) sum_cols = np.sum(a, 0, k...
[ "def", "_u_centered_imp", "(", "a", ",", "out", "=", "None", ")", ":", "out", "=", "_float_copy_to_out", "(", "out", ",", "a", ")", "dim", "=", "np", ".", "size", "(", "a", ",", "0", ")", "u_mu", "=", "np", ".", "sum", "(", "a", ")", "/", "("...
Real implementation of :func:`u_centered`. This function is used to make parameter ``out`` keyword-only in Python 2.
[ "Real", "implementation", "of", ":", "func", ":", "u_centered", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L146-L172
train
Real implementation of u_centered.
vnmabus/dcor
dcor/_dcor_internals.py
u_product
def u_product(a, b): r""" Inner product in the Hilbert space of :math:`U`-centered distance matrices. This inner product is defined as .. math:: \frac{1}{n(n-3)} \sum_{i,j=1}^n a_{i, j} b_{i, j} Parameters ---------- a: array_like First input array to be multiplied. b:...
python
def u_product(a, b): r""" Inner product in the Hilbert space of :math:`U`-centered distance matrices. This inner product is defined as .. math:: \frac{1}{n(n-3)} \sum_{i,j=1}^n a_{i, j} b_{i, j} Parameters ---------- a: array_like First input array to be multiplied. b:...
[ "def", "u_product", "(", "a", ",", "b", ")", ":", "n", "=", "np", ".", "size", "(", "a", ",", "0", ")", "return", "np", ".", "sum", "(", "a", "*", "b", ")", "/", "(", "n", "*", "(", "n", "-", "3", ")", ")" ]
r""" Inner product in the Hilbert space of :math:`U`-centered distance matrices. This inner product is defined as .. math:: \frac{1}{n(n-3)} \sum_{i,j=1}^n a_{i, j} b_{i, j} Parameters ---------- a: array_like First input array to be multiplied. b: array_like Secon...
[ "r", "Inner", "product", "in", "the", "Hilbert", "space", "of", ":", "math", ":", "U", "-", "centered", "distance", "matrices", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L294-L367
train
Returns the inner product of two arrays a and b.
vnmabus/dcor
dcor/_dcor_internals.py
u_projection
def u_projection(a): r""" Return the orthogonal projection function over :math:`a`. The function returned computes the orthogonal projection over :math:`a` in the Hilbert space of :math:`U`-centered distance matrices. The projection of a matrix :math:`B` over a matrix :math:`A` is defined ...
python
def u_projection(a): r""" Return the orthogonal projection function over :math:`a`. The function returned computes the orthogonal projection over :math:`a` in the Hilbert space of :math:`U`-centered distance matrices. The projection of a matrix :math:`B` over a matrix :math:`A` is defined ...
[ "def", "u_projection", "(", "a", ")", ":", "c", "=", "a", "denominator", "=", "u_product", "(", "c", ",", "c", ")", "docstring", "=", "\"\"\"\n Orthogonal projection over a :math:`U`-centered distance matrix.\n\n This function was returned by :code:`u_projection`. The com...
r""" Return the orthogonal projection function over :math:`a`. The function returned computes the orthogonal projection over :math:`a` in the Hilbert space of :math:`U`-centered distance matrices. The projection of a matrix :math:`B` over a matrix :math:`A` is defined as .. math:: ...
[ "r", "Return", "the", "orthogonal", "projection", "function", "over", ":", "math", ":", "a", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L370-L480
train
r Returns the orthogonal projection function over a matrix.
vnmabus/dcor
dcor/_dcor_internals.py
u_complementary_projection
def u_complementary_projection(a): r""" Return the orthogonal projection function over :math:`a^{\perp}`. The function returned computes the orthogonal projection over :math:`a^{\perp}` (the complementary projection over a) in the Hilbert space of :math:`U`-centered distance matrices. The proj...
python
def u_complementary_projection(a): r""" Return the orthogonal projection function over :math:`a^{\perp}`. The function returned computes the orthogonal projection over :math:`a^{\perp}` (the complementary projection over a) in the Hilbert space of :math:`U`-centered distance matrices. The proj...
[ "def", "u_complementary_projection", "(", "a", ")", ":", "proj", "=", "u_projection", "(", "a", ")", "def", "projection", "(", "a", ")", ":", "\"\"\"\n Orthogonal projection over the complementary space.\n\n This function was returned by :code:`u_complementary_proje...
r""" Return the orthogonal projection function over :math:`a^{\perp}`. The function returned computes the orthogonal projection over :math:`a^{\perp}` (the complementary projection over a) in the Hilbert space of :math:`U`-centered distance matrices. The projection of a matrix :math:`B` over a mat...
[ "r", "Return", "the", "orthogonal", "projection", "function", "over", ":", "math", ":", "a^", "{", "\\", "perp", "}", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L483-L573
train
r Returns the orthogonal projection function over a matrix.
vnmabus/dcor
dcor/_dcor_internals.py
_distance_matrix_generic
def _distance_matrix_generic(x, centering, exponent=1): """Compute a centered distance matrix given a matrix.""" _check_valid_dcov_exponent(exponent) x = _transform_to_2d(x) # Calculate distance matrices a = distances.pairwise_distances(x, exponent=exponent) # Double centering a = centeri...
python
def _distance_matrix_generic(x, centering, exponent=1): """Compute a centered distance matrix given a matrix.""" _check_valid_dcov_exponent(exponent) x = _transform_to_2d(x) # Calculate distance matrices a = distances.pairwise_distances(x, exponent=exponent) # Double centering a = centeri...
[ "def", "_distance_matrix_generic", "(", "x", ",", "centering", ",", "exponent", "=", "1", ")", ":", "_check_valid_dcov_exponent", "(", "exponent", ")", "x", "=", "_transform_to_2d", "(", "x", ")", "# Calculate distance matrices", "a", "=", "distances", ".", "pai...
Compute a centered distance matrix given a matrix.
[ "Compute", "a", "centered", "distance", "matrix", "given", "a", "matrix", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L576-L588
train
Compute a centered distance matrix given a matrix.
vnmabus/dcor
dcor/_dcor_internals.py
_af_inv_scaled
def _af_inv_scaled(x): """Scale a random vector for using the affinely invariant measures""" x = _transform_to_2d(x) cov_matrix = np.atleast_2d(np.cov(x, rowvar=False)) cov_matrix_power = _mat_sqrt_inv(cov_matrix) return x.dot(cov_matrix_power)
python
def _af_inv_scaled(x): """Scale a random vector for using the affinely invariant measures""" x = _transform_to_2d(x) cov_matrix = np.atleast_2d(np.cov(x, rowvar=False)) cov_matrix_power = _mat_sqrt_inv(cov_matrix) return x.dot(cov_matrix_power)
[ "def", "_af_inv_scaled", "(", "x", ")", ":", "x", "=", "_transform_to_2d", "(", "x", ")", "cov_matrix", "=", "np", ".", "atleast_2d", "(", "np", ".", "cov", "(", "x", ",", "rowvar", "=", "False", ")", ")", "cov_matrix_power", "=", "_mat_sqrt_inv", "(",...
Scale a random vector for using the affinely invariant measures
[ "Scale", "a", "random", "vector", "for", "using", "the", "affinely", "invariant", "measures" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L615-L623
train
Scale a random vector for using the affinely invariant measures
vnmabus/dcor
dcor/_partial_dcor.py
partial_distance_covariance
def partial_distance_covariance(x, y, z): """ Partial distance covariance estimator. Compute the estimator for the partial distance covariance of the random vectors corresponding to :math:`x` and :math:`y` with respect to the random variable corresponding to :math:`z`. Parameters ---------...
python
def partial_distance_covariance(x, y, z): """ Partial distance covariance estimator. Compute the estimator for the partial distance covariance of the random vectors corresponding to :math:`x` and :math:`y` with respect to the random variable corresponding to :math:`z`. Parameters ---------...
[ "def", "partial_distance_covariance", "(", "x", ",", "y", ",", "z", ")", ":", "a", "=", "_u_distance_matrix", "(", "x", ")", "b", "=", "_u_distance_matrix", "(", "y", ")", "c", "=", "_u_distance_matrix", "(", "z", ")", "proj", "=", "u_complementary_project...
Partial distance covariance estimator. Compute the estimator for the partial distance covariance of the random vectors corresponding to :math:`x` and :math:`y` with respect to the random variable corresponding to :math:`z`. Parameters ---------- x: array_like First random vector. The c...
[ "Partial", "distance", "covariance", "estimator", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_partial_dcor.py#L13-L70
train
Compute the partial distance covariance estimator for the given random vectors x y and z.
vnmabus/dcor
dcor/_partial_dcor.py
partial_distance_correlation
def partial_distance_correlation(x, y, z): # pylint:disable=too-many-locals """ Partial distance correlation estimator. Compute the estimator for the partial distance correlation of the random vectors corresponding to :math:`x` and :math:`y` with respect to the random variable corresponding to :ma...
python
def partial_distance_correlation(x, y, z): # pylint:disable=too-many-locals """ Partial distance correlation estimator. Compute the estimator for the partial distance correlation of the random vectors corresponding to :math:`x` and :math:`y` with respect to the random variable corresponding to :ma...
[ "def", "partial_distance_correlation", "(", "x", ",", "y", ",", "z", ")", ":", "# pylint:disable=too-many-locals", "a", "=", "_u_distance_matrix", "(", "x", ")", "b", "=", "_u_distance_matrix", "(", "y", ")", "c", "=", "_u_distance_matrix", "(", "z", ")", "a...
Partial distance correlation estimator. Compute the estimator for the partial distance correlation of the random vectors corresponding to :math:`x` and :math:`y` with respect to the random variable corresponding to :math:`z`. Parameters ---------- x: array_like First random vector. The...
[ "Partial", "distance", "correlation", "estimator", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_partial_dcor.py#L73-L145
train
Partial distance correlation estimator.
vnmabus/dcor
dcor/_energy.py
_energy_distance_from_distance_matrices
def _energy_distance_from_distance_matrices( distance_xx, distance_yy, distance_xy): """Compute energy distance with precalculated distance matrices.""" return (2 * np.mean(distance_xy) - np.mean(distance_xx) - np.mean(distance_yy))
python
def _energy_distance_from_distance_matrices( distance_xx, distance_yy, distance_xy): """Compute energy distance with precalculated distance matrices.""" return (2 * np.mean(distance_xy) - np.mean(distance_xx) - np.mean(distance_yy))
[ "def", "_energy_distance_from_distance_matrices", "(", "distance_xx", ",", "distance_yy", ",", "distance_xy", ")", ":", "return", "(", "2", "*", "np", ".", "mean", "(", "distance_xy", ")", "-", "np", ".", "mean", "(", "distance_xx", ")", "-", "np", ".", "m...
Compute energy distance with precalculated distance matrices.
[ "Compute", "energy", "distance", "with", "precalculated", "distance", "matrices", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_energy.py#L24-L28
train
Compute energy distance with precalculated distance matrices.
vnmabus/dcor
dcor/_energy.py
_energy_distance_imp
def _energy_distance_imp(x, y, exponent=1): """ Real implementation of :func:`energy_distance`. This function is used to make parameter ``exponent`` keyword-only in Python 2. """ x = _transform_to_2d(x) y = _transform_to_2d(y) _check_valid_energy_exponent(exponent) distance_xx = ...
python
def _energy_distance_imp(x, y, exponent=1): """ Real implementation of :func:`energy_distance`. This function is used to make parameter ``exponent`` keyword-only in Python 2. """ x = _transform_to_2d(x) y = _transform_to_2d(y) _check_valid_energy_exponent(exponent) distance_xx = ...
[ "def", "_energy_distance_imp", "(", "x", ",", "y", ",", "exponent", "=", "1", ")", ":", "x", "=", "_transform_to_2d", "(", "x", ")", "y", "=", "_transform_to_2d", "(", "y", ")", "_check_valid_energy_exponent", "(", "exponent", ")", "distance_xx", "=", "dis...
Real implementation of :func:`energy_distance`. This function is used to make parameter ``exponent`` keyword-only in Python 2.
[ "Real", "implementation", "of", ":", "func", ":", "energy_distance", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_energy.py#L31-L50
train
Implementation of energy_distance.
vnmabus/dcor
dcor/_dcor.py
_distance_covariance_sqr_naive
def _distance_covariance_sqr_naive(x, y, exponent=1): """ Naive biased estimator for distance covariance. Computes the unbiased estimator for distance covariance between two matrices, using an :math:`O(N^2)` algorithm. """ a = _distance_matrix(x, exponent=exponent) b = _distance_matrix(y, e...
python
def _distance_covariance_sqr_naive(x, y, exponent=1): """ Naive biased estimator for distance covariance. Computes the unbiased estimator for distance covariance between two matrices, using an :math:`O(N^2)` algorithm. """ a = _distance_matrix(x, exponent=exponent) b = _distance_matrix(y, e...
[ "def", "_distance_covariance_sqr_naive", "(", "x", ",", "y", ",", "exponent", "=", "1", ")", ":", "a", "=", "_distance_matrix", "(", "x", ",", "exponent", "=", "exponent", ")", "b", "=", "_distance_matrix", "(", "y", ",", "exponent", "=", "exponent", ")"...
Naive biased estimator for distance covariance. Computes the unbiased estimator for distance covariance between two matrices, using an :math:`O(N^2)` algorithm.
[ "Naive", "biased", "estimator", "for", "distance", "covariance", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L34-L44
train
Naive biased distance covariance.
vnmabus/dcor
dcor/_dcor.py
_u_distance_covariance_sqr_naive
def _u_distance_covariance_sqr_naive(x, y, exponent=1): """ Naive unbiased estimator for distance covariance. Computes the unbiased estimator for distance covariance between two matrices, using an :math:`O(N^2)` algorithm. """ a = _u_distance_matrix(x, exponent=exponent) b = _u_distance_mat...
python
def _u_distance_covariance_sqr_naive(x, y, exponent=1): """ Naive unbiased estimator for distance covariance. Computes the unbiased estimator for distance covariance between two matrices, using an :math:`O(N^2)` algorithm. """ a = _u_distance_matrix(x, exponent=exponent) b = _u_distance_mat...
[ "def", "_u_distance_covariance_sqr_naive", "(", "x", ",", "y", ",", "exponent", "=", "1", ")", ":", "a", "=", "_u_distance_matrix", "(", "x", ",", "exponent", "=", "exponent", ")", "b", "=", "_u_distance_matrix", "(", "y", ",", "exponent", "=", "exponent",...
Naive unbiased estimator for distance covariance. Computes the unbiased estimator for distance covariance between two matrices, using an :math:`O(N^2)` algorithm.
[ "Naive", "unbiased", "estimator", "for", "distance", "covariance", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L47-L57
train
Naive unbiased estimator for distance covariance between two matrices.
vnmabus/dcor
dcor/_dcor.py
_distance_sqr_stats_naive_generic
def _distance_sqr_stats_naive_generic(x, y, matrix_centered, product, exponent=1): """Compute generic squared stats.""" a = matrix_centered(x, exponent=exponent) b = matrix_centered(y, exponent=exponent) covariance_xy_sqr = product(a, b) variance_x_sqr = produc...
python
def _distance_sqr_stats_naive_generic(x, y, matrix_centered, product, exponent=1): """Compute generic squared stats.""" a = matrix_centered(x, exponent=exponent) b = matrix_centered(y, exponent=exponent) covariance_xy_sqr = product(a, b) variance_x_sqr = produc...
[ "def", "_distance_sqr_stats_naive_generic", "(", "x", ",", "y", ",", "matrix_centered", ",", "product", ",", "exponent", "=", "1", ")", ":", "a", "=", "matrix_centered", "(", "x", ",", "exponent", "=", "exponent", ")", "b", "=", "matrix_centered", "(", "y"...
Compute generic squared stats.
[ "Compute", "generic", "squared", "stats", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L60-L83
train
Compute generic squared stats.
vnmabus/dcor
dcor/_dcor.py
_distance_correlation_sqr_naive
def _distance_correlation_sqr_naive(x, y, exponent=1): """Biased distance correlation estimator between two matrices.""" return _distance_sqr_stats_naive_generic( x, y, matrix_centered=_distance_matrix, product=mean_product, exponent=exponent).correlation_xy
python
def _distance_correlation_sqr_naive(x, y, exponent=1): """Biased distance correlation estimator between two matrices.""" return _distance_sqr_stats_naive_generic( x, y, matrix_centered=_distance_matrix, product=mean_product, exponent=exponent).correlation_xy
[ "def", "_distance_correlation_sqr_naive", "(", "x", ",", "y", ",", "exponent", "=", "1", ")", ":", "return", "_distance_sqr_stats_naive_generic", "(", "x", ",", "y", ",", "matrix_centered", "=", "_distance_matrix", ",", "product", "=", "mean_product", ",", "expo...
Biased distance correlation estimator between two matrices.
[ "Biased", "distance", "correlation", "estimator", "between", "two", "matrices", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L86-L92
train
Biased distance correlation estimator between two matrices.
vnmabus/dcor
dcor/_dcor.py
_u_distance_correlation_sqr_naive
def _u_distance_correlation_sqr_naive(x, y, exponent=1): """Bias-corrected distance correlation estimator between two matrices.""" return _distance_sqr_stats_naive_generic( x, y, matrix_centered=_u_distance_matrix, product=u_product, exponent=exponent).correlation_xy
python
def _u_distance_correlation_sqr_naive(x, y, exponent=1): """Bias-corrected distance correlation estimator between two matrices.""" return _distance_sqr_stats_naive_generic( x, y, matrix_centered=_u_distance_matrix, product=u_product, exponent=exponent).correlation_xy
[ "def", "_u_distance_correlation_sqr_naive", "(", "x", ",", "y", ",", "exponent", "=", "1", ")", ":", "return", "_distance_sqr_stats_naive_generic", "(", "x", ",", "y", ",", "matrix_centered", "=", "_u_distance_matrix", ",", "product", "=", "u_product", ",", "exp...
Bias-corrected distance correlation estimator between two matrices.
[ "Bias", "-", "corrected", "distance", "correlation", "estimator", "between", "two", "matrices", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L95-L101
train
Bias - correcteded distance correlation estimator between two matrices.
vnmabus/dcor
dcor/_dcor.py
_can_use_fast_algorithm
def _can_use_fast_algorithm(x, y, exponent=1): """ Check if the fast algorithm for distance stats can be used. The fast algorithm has complexity :math:`O(NlogN)`, better than the complexity of the naive algorithm (:math:`O(N^2)`). The algorithm can only be used for random variables (not vectors) w...
python
def _can_use_fast_algorithm(x, y, exponent=1): """ Check if the fast algorithm for distance stats can be used. The fast algorithm has complexity :math:`O(NlogN)`, better than the complexity of the naive algorithm (:math:`O(N^2)`). The algorithm can only be used for random variables (not vectors) w...
[ "def", "_can_use_fast_algorithm", "(", "x", ",", "y", ",", "exponent", "=", "1", ")", ":", "return", "(", "_is_random_variable", "(", "x", ")", "and", "_is_random_variable", "(", "y", ")", "and", "x", ".", "shape", "[", "0", "]", ">", "3", "and", "y"...
Check if the fast algorithm for distance stats can be used. The fast algorithm has complexity :math:`O(NlogN)`, better than the complexity of the naive algorithm (:math:`O(N^2)`). The algorithm can only be used for random variables (not vectors) where the number of instances is greater than 3. Also, t...
[ "Check", "if", "the", "fast", "algorithm", "for", "distance", "stats", "can", "be", "used", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L115-L127
train
Check if the fast algorithm for distance stats can be used.
vnmabus/dcor
dcor/_dcor.py
_distance_covariance_sqr_fast_generic
def _distance_covariance_sqr_fast_generic( x, y, unbiased=False): # pylint:disable=too-many-locals # This function has many locals so it can be compared # with the original algorithm. """Fast algorithm for the squared distance covariance.""" x = np.asarray(x) y = np.asarray(y) x = np.r...
python
def _distance_covariance_sqr_fast_generic( x, y, unbiased=False): # pylint:disable=too-many-locals # This function has many locals so it can be compared # with the original algorithm. """Fast algorithm for the squared distance covariance.""" x = np.asarray(x) y = np.asarray(y) x = np.r...
[ "def", "_distance_covariance_sqr_fast_generic", "(", "x", ",", "y", ",", "unbiased", "=", "False", ")", ":", "# pylint:disable=too-many-locals", "# This function has many locals so it can be compared", "# with the original algorithm.", "x", "=", "np", ".", "asarray", "(", "...
Fast algorithm for the squared distance covariance.
[ "Fast", "algorithm", "for", "the", "squared", "distance", "covariance", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L229-L303
train
Fast algorithm for the squared distance covariance.
vnmabus/dcor
dcor/_dcor.py
_distance_stats_sqr_fast_generic
def _distance_stats_sqr_fast_generic(x, y, dcov_function): """Compute the distance stats using the fast algorithm.""" covariance_xy_sqr = dcov_function(x, y) variance_x_sqr = dcov_function(x, x) variance_y_sqr = dcov_function(y, y) denominator_sqr_signed = variance_x_sqr * variance_y_sqr denomin...
python
def _distance_stats_sqr_fast_generic(x, y, dcov_function): """Compute the distance stats using the fast algorithm.""" covariance_xy_sqr = dcov_function(x, y) variance_x_sqr = dcov_function(x, x) variance_y_sqr = dcov_function(y, y) denominator_sqr_signed = variance_x_sqr * variance_y_sqr denomin...
[ "def", "_distance_stats_sqr_fast_generic", "(", "x", ",", "y", ",", "dcov_function", ")", ":", "covariance_xy_sqr", "=", "dcov_function", "(", "x", ",", "y", ")", "variance_x_sqr", "=", "dcov_function", "(", "x", ",", "x", ")", "variance_y_sqr", "=", "dcov_fun...
Compute the distance stats using the fast algorithm.
[ "Compute", "the", "distance", "stats", "using", "the", "fast", "algorithm", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L316-L335
train
Compute the distance stats using the fast algorithm.
vnmabus/dcor
dcor/_dcor.py
distance_covariance_sqr
def distance_covariance_sqr(x, y, **kwargs): """ distance_covariance_sqr(x, y, *, exponent=1) Computes the usual (biased) estimator for the squared distance covariance between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond with t...
python
def distance_covariance_sqr(x, y, **kwargs): """ distance_covariance_sqr(x, y, *, exponent=1) Computes the usual (biased) estimator for the squared distance covariance between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond with t...
[ "def", "distance_covariance_sqr", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "if", "_can_use_fast_algorithm", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "return", "_distance_covariance_sqr_fast", "(", "x", ",", "y", ")", "else", ...
distance_covariance_sqr(x, y, *, exponent=1) Computes the usual (biased) estimator for the squared distance covariance between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond with the individual random variables while the rows are...
[ "distance_covariance_sqr", "(", "x", "y", "*", "exponent", "=", "1", ")" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L360-L417
train
Calculates the squared distance covariance between two random vectors.
vnmabus/dcor
dcor/_dcor.py
u_distance_covariance_sqr
def u_distance_covariance_sqr(x, y, **kwargs): """ u_distance_covariance_sqr(x, y, *, exponent=1) Computes the unbiased estimator for the squared distance covariance between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond with the...
python
def u_distance_covariance_sqr(x, y, **kwargs): """ u_distance_covariance_sqr(x, y, *, exponent=1) Computes the unbiased estimator for the squared distance covariance between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond with the...
[ "def", "u_distance_covariance_sqr", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "if", "_can_use_fast_algorithm", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "return", "_u_distance_covariance_sqr_fast", "(", "x", ",", "y", ")", "else...
u_distance_covariance_sqr(x, y, *, exponent=1) Computes the unbiased estimator for the squared distance covariance between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond with the individual random variables while the rows are ind...
[ "u_distance_covariance_sqr", "(", "x", "y", "*", "exponent", "=", "1", ")" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L420-L477
train
This function computes the unbiased distance covariance between two random vectors.
vnmabus/dcor
dcor/_dcor.py
distance_stats_sqr
def distance_stats_sqr(x, y, **kwargs): """ distance_stats_sqr(x, y, *, exponent=1) Computes the usual (biased) estimators for the squared distance covariance and squared distance correlation between two random vectors, and the individual squared distance variances. Parameters ---------- ...
python
def distance_stats_sqr(x, y, **kwargs): """ distance_stats_sqr(x, y, *, exponent=1) Computes the usual (biased) estimators for the squared distance covariance and squared distance correlation between two random vectors, and the individual squared distance variances. Parameters ---------- ...
[ "def", "distance_stats_sqr", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "if", "_can_use_fast_algorithm", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "return", "_distance_stats_sqr_fast", "(", "x", ",", "y", ")", "else", ":", "r...
distance_stats_sqr(x, y, *, exponent=1) Computes the usual (biased) estimators for the squared distance covariance and squared distance correlation between two random vectors, and the individual squared distance variances. Parameters ---------- x: array_like First random vector. The co...
[ "distance_stats_sqr", "(", "x", "y", "*", "exponent", "=", "1", ")" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L537-L609
train
This function computes the squared distance covariance and squared distance correlation between two random vectors and the individual squared distance variances.
vnmabus/dcor
dcor/_dcor.py
u_distance_stats_sqr
def u_distance_stats_sqr(x, y, **kwargs): """ u_distance_stats_sqr(x, y, *, exponent=1) Computes the unbiased estimators for the squared distance covariance and squared distance correlation between two random vectors, and the individual squared distance variances. Parameters ---------- ...
python
def u_distance_stats_sqr(x, y, **kwargs): """ u_distance_stats_sqr(x, y, *, exponent=1) Computes the unbiased estimators for the squared distance covariance and squared distance correlation between two random vectors, and the individual squared distance variances. Parameters ---------- ...
[ "def", "u_distance_stats_sqr", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "if", "_can_use_fast_algorithm", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "return", "_u_distance_stats_sqr_fast", "(", "x", ",", "y", ")", "else", ":", ...
u_distance_stats_sqr(x, y, *, exponent=1) Computes the unbiased estimators for the squared distance covariance and squared distance correlation between two random vectors, and the individual squared distance variances. Parameters ---------- x: array_like First random vector. The column...
[ "u_distance_stats_sqr", "(", "x", "y", "*", "exponent", "=", "1", ")" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L612-L687
train
This function computes the unbiased un
vnmabus/dcor
dcor/_dcor.py
distance_stats
def distance_stats(x, y, **kwargs): """ distance_stats(x, y, *, exponent=1) Computes the usual (biased) estimators for the distance covariance and distance correlation between two random vectors, and the individual distance variances. Parameters ---------- x: array_like First r...
python
def distance_stats(x, y, **kwargs): """ distance_stats(x, y, *, exponent=1) Computes the usual (biased) estimators for the distance covariance and distance correlation between two random vectors, and the individual distance variances. Parameters ---------- x: array_like First r...
[ "def", "distance_stats", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "return", "Stats", "(", "*", "[", "_sqrt", "(", "s", ")", "for", "s", "in", "distance_stats_sqr", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", "]", ")" ]
distance_stats(x, y, *, exponent=1) Computes the usual (biased) estimators for the distance covariance and distance correlation between two random vectors, and the individual distance variances. Parameters ---------- x: array_like First random vector. The columns correspond with the in...
[ "distance_stats", "(", "x", "y", "*", "exponent", "=", "1", ")" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L690-L755
train
This function computes the distance covariance and distance correlation between two random vectors and the individual distance variances.
vnmabus/dcor
dcor/_dcor.py
distance_correlation_sqr
def distance_correlation_sqr(x, y, **kwargs): """ distance_correlation_sqr(x, y, *, exponent=1) Computes the usual (biased) estimator for the squared distance correlation between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond wit...
python
def distance_correlation_sqr(x, y, **kwargs): """ distance_correlation_sqr(x, y, *, exponent=1) Computes the usual (biased) estimator for the squared distance correlation between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond wit...
[ "def", "distance_correlation_sqr", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "if", "_can_use_fast_algorithm", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "return", "_distance_correlation_sqr_fast", "(", "x", ",", "y", ")", "else",...
distance_correlation_sqr(x, y, *, exponent=1) Computes the usual (biased) estimator for the squared distance correlation between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond with the individual random variables while the rows a...
[ "distance_correlation_sqr", "(", "x", "y", "*", "exponent", "=", "1", ")" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L758-L815
train
A simple distance correlation algorithm for the unbiased random vectors.
vnmabus/dcor
dcor/_dcor.py
u_distance_correlation_sqr
def u_distance_correlation_sqr(x, y, **kwargs): """ u_distance_correlation_sqr(x, y, *, exponent=1) Computes the bias-corrected estimator for the squared distance correlation between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond...
python
def u_distance_correlation_sqr(x, y, **kwargs): """ u_distance_correlation_sqr(x, y, *, exponent=1) Computes the bias-corrected estimator for the squared distance correlation between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond...
[ "def", "u_distance_correlation_sqr", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "if", "_can_use_fast_algorithm", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "return", "_u_distance_correlation_sqr_fast", "(", "x", ",", "y", ")", "el...
u_distance_correlation_sqr(x, y, *, exponent=1) Computes the bias-corrected estimator for the squared distance correlation between two random vectors. Parameters ---------- x: array_like First random vector. The columns correspond with the individual random variables while the rows...
[ "u_distance_correlation_sqr", "(", "x", "y", "*", "exponent", "=", "1", ")" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L818-L877
train
Returns the squared distance correlation between two random vectors.
vnmabus/dcor
dcor/_dcor.py
distance_correlation_af_inv_sqr
def distance_correlation_af_inv_sqr(x, y): """ Square of the affinely invariant distance correlation. Computes the estimator for the square of the affinely invariant distance correlation between two random vectors. .. warning:: The return value of this function is undefined when the ...
python
def distance_correlation_af_inv_sqr(x, y): """ Square of the affinely invariant distance correlation. Computes the estimator for the square of the affinely invariant distance correlation between two random vectors. .. warning:: The return value of this function is undefined when the ...
[ "def", "distance_correlation_af_inv_sqr", "(", "x", ",", "y", ")", ":", "x", "=", "_af_inv_scaled", "(", "x", ")", "y", "=", "_af_inv_scaled", "(", "y", ")", "correlation", "=", "distance_correlation_sqr", "(", "x", ",", "y", ")", "return", "0", "if", "n...
Square of the affinely invariant distance correlation. Computes the estimator for the square of the affinely invariant distance correlation between two random vectors. .. warning:: The return value of this function is undefined when the covariance matrix of :math:`x` or :math:`y` is singu...
[ "Square", "of", "the", "affinely", "invariant", "distance", "correlation", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L937-L988
train
Calculates the squared affinely invariant distance correlation between two random vectors.
vnmabus/dcor
dcor/_pairwise.py
pairwise
def pairwise(function, x, y=None, **kwargs): """ pairwise(function, x, y=None, *, pool=None, is_symmetric=None, **kwargs) Computes a dependency measure between each pair of elements. Parameters ---------- function: Dependency measure function. x: iterable of array_like First list o...
python
def pairwise(function, x, y=None, **kwargs): """ pairwise(function, x, y=None, *, pool=None, is_symmetric=None, **kwargs) Computes a dependency measure between each pair of elements. Parameters ---------- function: Dependency measure function. x: iterable of array_like First list o...
[ "def", "pairwise", "(", "function", ",", "x", ",", "y", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "_pairwise_imp", "(", "function", ",", "x", ",", "y", ",", "*", "*", "kwargs", ")" ]
pairwise(function, x, y=None, *, pool=None, is_symmetric=None, **kwargs) Computes a dependency measure between each pair of elements. Parameters ---------- function: Dependency measure function. x: iterable of array_like First list of random vectors. The columns of each vector correspond ...
[ "pairwise", "(", "function", "x", "y", "=", "None", "*", "pool", "=", "None", "is_symmetric", "=", "None", "**", "kwargs", ")" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_pairwise.py#L10-L94
train
A function that computes the dependency measure between each pair of elements.
vnmabus/dcor
dcor/_pairwise.py
_pairwise_imp
def _pairwise_imp(function, x, y=None, pool=None, is_symmetric=None, **kwargs): """ Real implementation of :func:`pairwise`. This function is used to make several parameters keyword-only in Python 2. """ map_function = pool.map if pool else map if is_symmetric is None: is_symmetri...
python
def _pairwise_imp(function, x, y=None, pool=None, is_symmetric=None, **kwargs): """ Real implementation of :func:`pairwise`. This function is used to make several parameters keyword-only in Python 2. """ map_function = pool.map if pool else map if is_symmetric is None: is_symmetri...
[ "def", "_pairwise_imp", "(", "function", ",", "x", ",", "y", "=", "None", ",", "pool", "=", "None", ",", "is_symmetric", "=", "None", ",", "*", "*", "kwargs", ")", ":", "map_function", "=", "pool", ".", "map", "if", "pool", "else", "map", "if", "is...
Real implementation of :func:`pairwise`. This function is used to make several parameters keyword-only in Python 2.
[ "Real", "implementation", "of", ":", "func", ":", "pairwise", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_pairwise.py#L97-L134
train
Real implementation of pairwise.
vnmabus/dcor
dcor/_utils.py
_jit
def _jit(function): """ Compile a function using a jit compiler. The function is always compiled to check errors, but is only used outside tests, so that code coverage analysis can be performed in jitted functions. The tests set sys._called_from_test in conftest.py. """ import sys co...
python
def _jit(function): """ Compile a function using a jit compiler. The function is always compiled to check errors, but is only used outside tests, so that code coverage analysis can be performed in jitted functions. The tests set sys._called_from_test in conftest.py. """ import sys co...
[ "def", "_jit", "(", "function", ")", ":", "import", "sys", "compiled", "=", "numba", ".", "jit", "(", "function", ")", "if", "hasattr", "(", "sys", ",", "'_called_from_test'", ")", ":", "return", "function", "else", ":", "# pragma: no cover", "return", "co...
Compile a function using a jit compiler. The function is always compiled to check errors, but is only used outside tests, so that code coverage analysis can be performed in jitted functions. The tests set sys._called_from_test in conftest.py.
[ "Compile", "a", "function", "using", "a", "jit", "compiler", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_utils.py#L10-L27
train
Compile a function using a jit compiler.
vnmabus/dcor
dcor/_utils.py
_sqrt
def _sqrt(x): """ Return square root of an ndarray. This sqrt function for ndarrays tries to use the exponentiation operator if the objects stored do not supply a sqrt method. """ x = np.clip(x, a_min=0, a_max=None) try: return np.sqrt(x) except AttributeError: exponen...
python
def _sqrt(x): """ Return square root of an ndarray. This sqrt function for ndarrays tries to use the exponentiation operator if the objects stored do not supply a sqrt method. """ x = np.clip(x, a_min=0, a_max=None) try: return np.sqrt(x) except AttributeError: exponen...
[ "def", "_sqrt", "(", "x", ")", ":", "x", "=", "np", ".", "clip", "(", "x", ",", "a_min", "=", "0", ",", "a_max", "=", "None", ")", "try", ":", "return", "np", ".", "sqrt", "(", "x", ")", "except", "AttributeError", ":", "exponent", "=", "0.5", ...
Return square root of an ndarray. This sqrt function for ndarrays tries to use the exponentiation operator if the objects stored do not supply a sqrt method.
[ "Return", "square", "root", "of", "an", "ndarray", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_utils.py#L30-L50
train
This function returns the square root of an ndarray.
vnmabus/dcor
dcor/_utils.py
_transform_to_2d
def _transform_to_2d(t): """Convert vectors to column matrices, to always have a 2d shape.""" t = np.asarray(t) dim = len(t.shape) assert dim <= 2 if dim < 2: t = np.atleast_2d(t).T return t
python
def _transform_to_2d(t): """Convert vectors to column matrices, to always have a 2d shape.""" t = np.asarray(t) dim = len(t.shape) assert dim <= 2 if dim < 2: t = np.atleast_2d(t).T return t
[ "def", "_transform_to_2d", "(", "t", ")", ":", "t", "=", "np", ".", "asarray", "(", "t", ")", "dim", "=", "len", "(", "t", ".", "shape", ")", "assert", "dim", "<=", "2", "if", "dim", "<", "2", ":", "t", "=", "np", ".", "atleast_2d", "(", "t",...
Convert vectors to column matrices, to always have a 2d shape.
[ "Convert", "vectors", "to", "column", "matrices", "to", "always", "have", "a", "2d", "shape", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_utils.py#L53-L63
train
Convert vectors to column matrices to always have a 2d shape.
vnmabus/dcor
dcor/_utils.py
_can_be_double
def _can_be_double(x): """ Return if the array can be safely converted to double. That happens when the dtype is a float with the same size of a double or narrower, or when is an integer that can be safely converted to double (if the roundtrip conversion works). """ return ((np.issubdtype(...
python
def _can_be_double(x): """ Return if the array can be safely converted to double. That happens when the dtype is a float with the same size of a double or narrower, or when is an integer that can be safely converted to double (if the roundtrip conversion works). """ return ((np.issubdtype(...
[ "def", "_can_be_double", "(", "x", ")", ":", "return", "(", "(", "np", ".", "issubdtype", "(", "x", ".", "dtype", ",", "np", ".", "floating", ")", "and", "x", ".", "dtype", ".", "itemsize", "<=", "np", ".", "dtype", "(", "float", ")", ".", "items...
Return if the array can be safely converted to double. That happens when the dtype is a float with the same size of a double or narrower, or when is an integer that can be safely converted to double (if the roundtrip conversion works).
[ "Return", "if", "the", "array", "can", "be", "safely", "converted", "to", "double", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_utils.py#L66-L78
train
Return True if the array can be safely converted to double.
vnmabus/dcor
dcor/distances.py
_cdist_naive
def _cdist_naive(x, y, exponent=1): """Pairwise distance, custom implementation.""" squared_norms = ((x[_np.newaxis, :, :] - y[:, _np.newaxis, :]) ** 2).sum(2) exponent = exponent / 2 try: exponent = squared_norms.take(0).from_float(exponent) except AttributeError: pass return ...
python
def _cdist_naive(x, y, exponent=1): """Pairwise distance, custom implementation.""" squared_norms = ((x[_np.newaxis, :, :] - y[:, _np.newaxis, :]) ** 2).sum(2) exponent = exponent / 2 try: exponent = squared_norms.take(0).from_float(exponent) except AttributeError: pass return ...
[ "def", "_cdist_naive", "(", "x", ",", "y", ",", "exponent", "=", "1", ")", ":", "squared_norms", "=", "(", "(", "x", "[", "_np", ".", "newaxis", ",", ":", ",", ":", "]", "-", "y", "[", ":", ",", "_np", ".", "newaxis", ",", ":", "]", ")", "*...
Pairwise distance, custom implementation.
[ "Pairwise", "distance", "custom", "implementation", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L18-L28
train
Pairwise distance custom implementation.
vnmabus/dcor
dcor/distances.py
_pdist_scipy
def _pdist_scipy(x, exponent=1): """Pairwise distance between points in a set.""" metric = 'euclidean' if exponent != 1: metric = 'sqeuclidean' distances = _spatial.distance.pdist(x, metric=metric) distances = _spatial.distance.squareform(distances) if exponent != 1: distances...
python
def _pdist_scipy(x, exponent=1): """Pairwise distance between points in a set.""" metric = 'euclidean' if exponent != 1: metric = 'sqeuclidean' distances = _spatial.distance.pdist(x, metric=metric) distances = _spatial.distance.squareform(distances) if exponent != 1: distances...
[ "def", "_pdist_scipy", "(", "x", ",", "exponent", "=", "1", ")", ":", "metric", "=", "'euclidean'", "if", "exponent", "!=", "1", ":", "metric", "=", "'sqeuclidean'", "distances", "=", "_spatial", ".", "distance", ".", "pdist", "(", "x", ",", "metric", ...
Pairwise distance between points in a set.
[ "Pairwise", "distance", "between", "points", "in", "a", "set", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L31-L44
train
Pairwise distance between points in a set.
vnmabus/dcor
dcor/distances.py
_cdist_scipy
def _cdist_scipy(x, y, exponent=1): """Pairwise distance between the points in two sets.""" metric = 'euclidean' if exponent != 1: metric = 'sqeuclidean' distances = _spatial.distance.cdist(x, y, metric=metric) if exponent != 1: distances **= exponent / 2 return distances
python
def _cdist_scipy(x, y, exponent=1): """Pairwise distance between the points in two sets.""" metric = 'euclidean' if exponent != 1: metric = 'sqeuclidean' distances = _spatial.distance.cdist(x, y, metric=metric) if exponent != 1: distances **= exponent / 2 return distances
[ "def", "_cdist_scipy", "(", "x", ",", "y", ",", "exponent", "=", "1", ")", ":", "metric", "=", "'euclidean'", "if", "exponent", "!=", "1", ":", "metric", "=", "'sqeuclidean'", "distances", "=", "_spatial", ".", "distance", ".", "cdist", "(", "x", ",", ...
Pairwise distance between the points in two sets.
[ "Pairwise", "distance", "between", "the", "points", "in", "two", "sets", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L47-L59
train
Pairwise distance between the points in two sets.
vnmabus/dcor
dcor/distances.py
_pdist
def _pdist(x, exponent=1): """ Pairwise distance between points in a set. As Scipy converts every value to double, this wrapper uses a less efficient implementation if the original dtype can not be converted to double. """ if _can_be_double(x): return _pdist_scipy(x, exponent) ...
python
def _pdist(x, exponent=1): """ Pairwise distance between points in a set. As Scipy converts every value to double, this wrapper uses a less efficient implementation if the original dtype can not be converted to double. """ if _can_be_double(x): return _pdist_scipy(x, exponent) ...
[ "def", "_pdist", "(", "x", ",", "exponent", "=", "1", ")", ":", "if", "_can_be_double", "(", "x", ")", ":", "return", "_pdist_scipy", "(", "x", ",", "exponent", ")", "else", ":", "return", "_cdist_naive", "(", "x", ",", "x", ",", "exponent", ")" ]
Pairwise distance between points in a set. As Scipy converts every value to double, this wrapper uses a less efficient implementation if the original dtype can not be converted to double.
[ "Pairwise", "distance", "between", "points", "in", "a", "set", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L62-L74
train
Pairwise distance between points in a set.
vnmabus/dcor
dcor/distances.py
_cdist
def _cdist(x, y, exponent=1): """ Pairwise distance between points in two sets. As Scipy converts every value to double, this wrapper uses a less efficient implementation if the original dtype can not be converted to double. """ if _can_be_double(x) and _can_be_double(y): return _c...
python
def _cdist(x, y, exponent=1): """ Pairwise distance between points in two sets. As Scipy converts every value to double, this wrapper uses a less efficient implementation if the original dtype can not be converted to double. """ if _can_be_double(x) and _can_be_double(y): return _c...
[ "def", "_cdist", "(", "x", ",", "y", ",", "exponent", "=", "1", ")", ":", "if", "_can_be_double", "(", "x", ")", "and", "_can_be_double", "(", "y", ")", ":", "return", "_cdist_scipy", "(", "x", ",", "y", ",", "exponent", ")", "else", ":", "return",...
Pairwise distance between points in two sets. As Scipy converts every value to double, this wrapper uses a less efficient implementation if the original dtype can not be converted to double.
[ "Pairwise", "distance", "between", "points", "in", "two", "sets", "." ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L77-L89
train
Pairwise distance between points in two sets.
vnmabus/dcor
dcor/distances.py
pairwise_distances
def pairwise_distances(x, y=None, **kwargs): r""" pairwise_distances(x, y=None, *, exponent=1) Pairwise distance between points. Return the pairwise distance between points in two sets, or in the same set if only one set is passed. Parameters ---------- x: array_like An :math:...
python
def pairwise_distances(x, y=None, **kwargs): r""" pairwise_distances(x, y=None, *, exponent=1) Pairwise distance between points. Return the pairwise distance between points in two sets, or in the same set if only one set is passed. Parameters ---------- x: array_like An :math:...
[ "def", "pairwise_distances", "(", "x", ",", "y", "=", "None", ",", "*", "*", "kwargs", ")", ":", "x", "=", "_transform_to_2d", "(", "x", ")", "if", "y", "is", "None", "or", "y", "is", "x", ":", "return", "_pdist", "(", "x", ",", "*", "*", "kwar...
r""" pairwise_distances(x, y=None, *, exponent=1) Pairwise distance between points. Return the pairwise distance between points in two sets, or in the same set if only one set is passed. Parameters ---------- x: array_like An :math:`n \times m` array of :math:`n` observations in ...
[ "r", "pairwise_distances", "(", "x", "y", "=", "None", "*", "exponent", "=", "1", ")" ]
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L92-L149
train
r Returns the pairwise distance between two points or in the same set.
kumar303/mohawk
mohawk/receiver.py
Receiver.respond
def respond(self, content=EmptyValue, content_type=EmptyValue, always_hash_content=True, ext=None): """ Respond to the request. This generates the :attr:`mohawk.Receiver.response_header` attribute. :param content=E...
python
def respond(self, content=EmptyValue, content_type=EmptyValue, always_hash_content=True, ext=None): """ Respond to the request. This generates the :attr:`mohawk.Receiver.response_header` attribute. :param content=E...
[ "def", "respond", "(", "self", ",", "content", "=", "EmptyValue", ",", "content_type", "=", "EmptyValue", ",", "always_hash_content", "=", "True", ",", "ext", "=", "None", ")", ":", "log", ".", "debug", "(", "'generating response header'", ")", "resource", "...
Respond to the request. This generates the :attr:`mohawk.Receiver.response_header` attribute. :param content=EmptyValue: Byte string of response body that will be sent. :type content=EmptyValue: str :param content_type=EmptyValue: content-type header value for response. ...
[ "Respond", "to", "the", "request", "." ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/receiver.py#L123-L171
train
This method generates the response header for the current resource.
kumar303/mohawk
mohawk/util.py
calculate_payload_hash
def calculate_payload_hash(payload, algorithm, content_type): """Calculates a hash for a given payload.""" p_hash = hashlib.new(algorithm) parts = [] parts.append('hawk.' + str(HAWK_VER) + '.payload\n') parts.append(parse_content_type(content_type) + '\n') parts.append(payload or '') parts....
python
def calculate_payload_hash(payload, algorithm, content_type): """Calculates a hash for a given payload.""" p_hash = hashlib.new(algorithm) parts = [] parts.append('hawk.' + str(HAWK_VER) + '.payload\n') parts.append(parse_content_type(content_type) + '\n') parts.append(payload or '') parts....
[ "def", "calculate_payload_hash", "(", "payload", ",", "algorithm", ",", "content_type", ")", ":", "p_hash", "=", "hashlib", ".", "new", "(", "algorithm", ")", "parts", "=", "[", "]", "parts", ".", "append", "(", "'hawk.'", "+", "str", "(", "HAWK_VER", ")...
Calculates a hash for a given payload.
[ "Calculates", "a", "hash", "for", "a", "given", "payload", "." ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L49-L69
train
Calculates a hash for a given payload.
kumar303/mohawk
mohawk/util.py
calculate_mac
def calculate_mac(mac_type, resource, content_hash): """Calculates a message authorization code (MAC).""" normalized = normalize_string(mac_type, resource, content_hash) log.debug(u'normalized resource for mac calc: {norm}' .format(norm=normalized)) digestmod = getattr(hashlib, resource.cr...
python
def calculate_mac(mac_type, resource, content_hash): """Calculates a message authorization code (MAC).""" normalized = normalize_string(mac_type, resource, content_hash) log.debug(u'normalized resource for mac calc: {norm}' .format(norm=normalized)) digestmod = getattr(hashlib, resource.cr...
[ "def", "calculate_mac", "(", "mac_type", ",", "resource", ",", "content_hash", ")", ":", "normalized", "=", "normalize_string", "(", "mac_type", ",", "resource", ",", "content_hash", ")", "log", ".", "debug", "(", "u'normalized resource for mac calc: {norm}'", ".", ...
Calculates a message authorization code (MAC).
[ "Calculates", "a", "message", "authorization", "code", "(", "MAC", ")", "." ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L72-L88
train
Calculates a message authorization code ( MAC ).
kumar303/mohawk
mohawk/util.py
calculate_ts_mac
def calculate_ts_mac(ts, credentials): """Calculates a message authorization code (MAC) for a timestamp.""" normalized = ('hawk.{hawk_ver}.ts\n{ts}\n' .format(hawk_ver=HAWK_VER, ts=ts)) log.debug(u'normalized resource for ts mac calc: {norm}' .format(norm=normalized)) dig...
python
def calculate_ts_mac(ts, credentials): """Calculates a message authorization code (MAC) for a timestamp.""" normalized = ('hawk.{hawk_ver}.ts\n{ts}\n' .format(hawk_ver=HAWK_VER, ts=ts)) log.debug(u'normalized resource for ts mac calc: {norm}' .format(norm=normalized)) dig...
[ "def", "calculate_ts_mac", "(", "ts", ",", "credentials", ")", ":", "normalized", "=", "(", "'hawk.{hawk_ver}.ts\\n{ts}\\n'", ".", "format", "(", "hawk_ver", "=", "HAWK_VER", ",", "ts", "=", "ts", ")", ")", "log", ".", "debug", "(", "u'normalized resource for ...
Calculates a message authorization code (MAC) for a timestamp.
[ "Calculates", "a", "message", "authorization", "code", "(", "MAC", ")", "for", "a", "timestamp", "." ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L91-L106
train
Calculates a message authorization code for a timestamp.
kumar303/mohawk
mohawk/util.py
normalize_string
def normalize_string(mac_type, resource, content_hash): """Serializes mac_type and resource into a HAWK string.""" normalized = [ 'hawk.' + str(HAWK_VER) + '.' + mac_type, normalize_header_attr(resource.timestamp), normalize_header_attr(resource.nonce), normalize_header_attr(res...
python
def normalize_string(mac_type, resource, content_hash): """Serializes mac_type and resource into a HAWK string.""" normalized = [ 'hawk.' + str(HAWK_VER) + '.' + mac_type, normalize_header_attr(resource.timestamp), normalize_header_attr(resource.nonce), normalize_header_attr(res...
[ "def", "normalize_string", "(", "mac_type", ",", "resource", ",", "content_hash", ")", ":", "normalized", "=", "[", "'hawk.'", "+", "str", "(", "HAWK_VER", ")", "+", "'.'", "+", "mac_type", ",", "normalize_header_attr", "(", "resource", ".", "timestamp", ")"...
Serializes mac_type and resource into a HAWK string.
[ "Serializes", "mac_type", "and", "resource", "into", "a", "HAWK", "string", "." ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L109-L136
train
Serializes mac_type and resource into a HAWK string.
kumar303/mohawk
mohawk/util.py
parse_authorization_header
def parse_authorization_header(auth_header): """ Example Authorization header: 'Hawk id="dh37fgj492je", ts="1367076201", nonce="NPHgnG", ext="and welcome!", mac="CeWHy4d9kbLGhDlkyw2Nh3PJ7SDOdZDa267KH4ZaNMY="' """ if len(auth_header) > MAX_LENGTH: raise BadHeaderValue('Header exc...
python
def parse_authorization_header(auth_header): """ Example Authorization header: 'Hawk id="dh37fgj492je", ts="1367076201", nonce="NPHgnG", ext="and welcome!", mac="CeWHy4d9kbLGhDlkyw2Nh3PJ7SDOdZDa267KH4ZaNMY="' """ if len(auth_header) > MAX_LENGTH: raise BadHeaderValue('Header exc...
[ "def", "parse_authorization_header", "(", "auth_header", ")", ":", "if", "len", "(", "auth_header", ")", ">", "MAX_LENGTH", ":", "raise", "BadHeaderValue", "(", "'Header exceeds maximum length of {max_length}'", ".", "format", "(", "max_length", "=", "MAX_LENGTH", ")"...
Example Authorization header: 'Hawk id="dh37fgj492je", ts="1367076201", nonce="NPHgnG", ext="and welcome!", mac="CeWHy4d9kbLGhDlkyw2Nh3PJ7SDOdZDa267KH4ZaNMY="'
[ "Example", "Authorization", "header", ":" ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L147-L192
train
Parses an authorization header into a single object.
kumar303/mohawk
mohawk/bewit.py
get_bewit
def get_bewit(resource): """ Returns a bewit identifier for the resource as a string. :param resource: Resource to generate a bewit for :type resource: `mohawk.base.Resource` """ if resource.method != 'GET': raise ValueError('bewits can only be generated for GET requests') i...
python
def get_bewit(resource): """ Returns a bewit identifier for the resource as a string. :param resource: Resource to generate a bewit for :type resource: `mohawk.base.Resource` """ if resource.method != 'GET': raise ValueError('bewits can only be generated for GET requests') i...
[ "def", "get_bewit", "(", "resource", ")", ":", "if", "resource", ".", "method", "!=", "'GET'", ":", "raise", "ValueError", "(", "'bewits can only be generated for GET requests'", ")", "if", "resource", ".", "nonce", "!=", "''", ":", "raise", "ValueError", "(", ...
Returns a bewit identifier for the resource as a string. :param resource: Resource to generate a bewit for :type resource: `mohawk.base.Resource`
[ "Returns", "a", "bewit", "identifier", "for", "the", "resource", "as", "a", "string", "." ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L21-L61
train
Returns a bewit identifier for the resource as a string.
kumar303/mohawk
mohawk/bewit.py
parse_bewit
def parse_bewit(bewit): """ Returns a `bewittuple` representing the parts of an encoded bewit string. This has the following named attributes: (id, expiration, mac, ext) :param bewit: A base64 encoded bewit string :type bewit: str """ decoded_bewit = b64decode(bewit).decode(...
python
def parse_bewit(bewit): """ Returns a `bewittuple` representing the parts of an encoded bewit string. This has the following named attributes: (id, expiration, mac, ext) :param bewit: A base64 encoded bewit string :type bewit: str """ decoded_bewit = b64decode(bewit).decode(...
[ "def", "parse_bewit", "(", "bewit", ")", ":", "decoded_bewit", "=", "b64decode", "(", "bewit", ")", ".", "decode", "(", "'ascii'", ")", "bewit_parts", "=", "decoded_bewit", ".", "split", "(", "\"\\\\\"", ")", "if", "len", "(", "bewit_parts", ")", "!=", "...
Returns a `bewittuple` representing the parts of an encoded bewit string. This has the following named attributes: (id, expiration, mac, ext) :param bewit: A base64 encoded bewit string :type bewit: str
[ "Returns", "a", "bewittuple", "representing", "the", "parts", "of", "an", "encoded", "bewit", "string", ".", "This", "has", "the", "following", "named", "attributes", ":", "(", "id", "expiration", "mac", "ext", ")" ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L67-L81
train
Parses a base64 encoded bewit string into a bewittuple.
kumar303/mohawk
mohawk/bewit.py
strip_bewit
def strip_bewit(url): """ Strips the bewit parameter out of a url. Returns (encoded_bewit, stripped_url) Raises InvalidBewit if no bewit found. :param url: The url containing a bewit parameter :type url: str """ m = re.search('[?&]bewit=([^&]+)', url) if not m: rai...
python
def strip_bewit(url): """ Strips the bewit parameter out of a url. Returns (encoded_bewit, stripped_url) Raises InvalidBewit if no bewit found. :param url: The url containing a bewit parameter :type url: str """ m = re.search('[?&]bewit=([^&]+)', url) if not m: rai...
[ "def", "strip_bewit", "(", "url", ")", ":", "m", "=", "re", ".", "search", "(", "'[?&]bewit=([^&]+)'", ",", "url", ")", "if", "not", "m", ":", "raise", "InvalidBewit", "(", "'no bewit data found'", ")", "bewit", "=", "m", ".", "group", "(", "1", ")", ...
Strips the bewit parameter out of a url. Returns (encoded_bewit, stripped_url) Raises InvalidBewit if no bewit found. :param url: The url containing a bewit parameter :type url: str
[ "Strips", "the", "bewit", "parameter", "out", "of", "a", "url", "." ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L84-L101
train
Strips the bewit parameter out of a url.
kumar303/mohawk
mohawk/bewit.py
check_bewit
def check_bewit(url, credential_lookup, now=None): """ Validates the given bewit. Returns True if the resource has a valid bewit parameter attached, or raises a subclass of HawkFail otherwise. :param credential_lookup: Callable to look up the credentials dict by sender ID. The cred...
python
def check_bewit(url, credential_lookup, now=None): """ Validates the given bewit. Returns True if the resource has a valid bewit parameter attached, or raises a subclass of HawkFail otherwise. :param credential_lookup: Callable to look up the credentials dict by sender ID. The cred...
[ "def", "check_bewit", "(", "url", ",", "credential_lookup", ",", "now", "=", "None", ")", ":", "raw_bewit", ",", "stripped_url", "=", "strip_bewit", "(", "url", ")", "bewit", "=", "parse_bewit", "(", "raw_bewit", ")", "try", ":", "credentials", "=", "crede...
Validates the given bewit. Returns True if the resource has a valid bewit parameter attached, or raises a subclass of HawkFail otherwise. :param credential_lookup: Callable to look up the credentials dict by sender ID. The credentials dict must have the keys: ``id``, ``key``, and `...
[ "Validates", "the", "given", "bewit", "." ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L104-L159
train
Checks if a given bewit is valid and raises a subclass of HawkFail otherwise.
kumar303/mohawk
mohawk/sender.py
Sender.accept_response
def accept_response(self, response_header, content=EmptyValue, content_type=EmptyValue, accept_untrusted_content=False, localtime_offset_in_seconds=0, timestamp_skew_in_seconds...
python
def accept_response(self, response_header, content=EmptyValue, content_type=EmptyValue, accept_untrusted_content=False, localtime_offset_in_seconds=0, timestamp_skew_in_seconds...
[ "def", "accept_response", "(", "self", ",", "response_header", ",", "content", "=", "EmptyValue", ",", "content_type", "=", "EmptyValue", ",", "accept_untrusted_content", "=", "False", ",", "localtime_offset_in_seconds", "=", "0", ",", "timestamp_skew_in_seconds", "="...
Accept a response to this request. :param response_header: A `Hawk`_ ``Server-Authorization`` header such as one created by :class:`mohawk.Receiver`. :type response_header: str :param content=EmptyValue: Byte string of the response body received. :type content=E...
[ "Accept", "a", "response", "to", "this", "request", "." ]
037be67ccf50ae704705e67add44e02737a65d21
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/sender.py#L106-L175
train
Accept a response to the Hawk server.
kajic/django-model-changes
django_model_changes/changes.py
ChangesMixin.current_state
def current_state(self): """ Returns a ``field -> value`` dict of the current state of the instance. """ field_names = set() [field_names.add(f.name) for f in self._meta.local_fields] [field_names.add(f.attname) for f in self._meta.local_fields] return dict([(fiel...
python
def current_state(self): """ Returns a ``field -> value`` dict of the current state of the instance. """ field_names = set() [field_names.add(f.name) for f in self._meta.local_fields] [field_names.add(f.attname) for f in self._meta.local_fields] return dict([(fiel...
[ "def", "current_state", "(", "self", ")", ":", "field_names", "=", "set", "(", ")", "[", "field_names", ".", "add", "(", "f", ".", "name", ")", "for", "f", "in", "self", ".", "_meta", ".", "local_fields", "]", "[", "field_names", ".", "add", "(", "...
Returns a ``field -> value`` dict of the current state of the instance.
[ "Returns", "a", "field", "-", ">", "value", "dict", "of", "the", "current", "state", "of", "the", "instance", "." ]
92124ebdf29cba930eb1ced00135823b961041d3
https://github.com/kajic/django-model-changes/blob/92124ebdf29cba930eb1ced00135823b961041d3/django_model_changes/changes.py#L98-L105
train
Returns a dict of the current state of the instance.
kajic/django-model-changes
django_model_changes/changes.py
ChangesMixin.was_persisted
def was_persisted(self): """ Returns true if the instance was persisted (saved) in its old state. Examples:: >>> user = User() >>> user.save() >>> user.was_persisted() False >>> user = User.objects.get(pk=1) >>> u...
python
def was_persisted(self): """ Returns true if the instance was persisted (saved) in its old state. Examples:: >>> user = User() >>> user.save() >>> user.was_persisted() False >>> user = User.objects.get(pk=1) >>> u...
[ "def", "was_persisted", "(", "self", ")", ":", "pk_name", "=", "self", ".", "_meta", ".", "pk", ".", "name", "return", "bool", "(", "self", ".", "old_state", "(", ")", "[", "pk_name", "]", ")" ]
Returns true if the instance was persisted (saved) in its old state. Examples:: >>> user = User() >>> user.save() >>> user.was_persisted() False >>> user = User.objects.get(pk=1) >>> user.delete() >>> user.was_persist...
[ "Returns", "true", "if", "the", "instance", "was", "persisted", "(", "saved", ")", "in", "its", "old", "state", "." ]
92124ebdf29cba930eb1ced00135823b961041d3
https://github.com/kajic/django-model-changes/blob/92124ebdf29cba930eb1ced00135823b961041d3/django_model_changes/changes.py#L149-L167
train
Returns True if the user was persisted in its old state.
nilp0inter/cpe
cpe/cpe.py
CPE._trim
def _trim(cls, s): """ Remove trailing colons from the URI back to the first non-colon. :param string s: input URI string :returns: URI string with trailing colons removed :rtype: string TEST: trailing colons necessary >>> s = '1:2::::' >>> CPE._trim(s)...
python
def _trim(cls, s): """ Remove trailing colons from the URI back to the first non-colon. :param string s: input URI string :returns: URI string with trailing colons removed :rtype: string TEST: trailing colons necessary >>> s = '1:2::::' >>> CPE._trim(s)...
[ "def", "_trim", "(", "cls", ",", "s", ")", ":", "reverse", "=", "s", "[", ":", ":", "-", "1", "]", "idx", "=", "0", "for", "i", "in", "range", "(", "0", ",", "len", "(", "reverse", ")", ")", ":", "if", "reverse", "[", "i", "]", "==", "\":...
Remove trailing colons from the URI back to the first non-colon. :param string s: input URI string :returns: URI string with trailing colons removed :rtype: string TEST: trailing colons necessary >>> s = '1:2::::' >>> CPE._trim(s) '1:2' TEST: trailing ...
[ "Remove", "trailing", "colons", "from", "the", "URI", "back", "to", "the", "first", "non", "-", "colon", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L115-L146
train
Removes trailing colons from the URI back to the first non - colon.
nilp0inter/cpe
cpe/cpe.py
CPE._create_cpe_parts
def _create_cpe_parts(self, system, components): """ Create the structure to store the input type of system associated with components of CPE Name (hardware, operating system and software). :param string system: type of system associated with CPE Name :param dict components: CPE...
python
def _create_cpe_parts(self, system, components): """ Create the structure to store the input type of system associated with components of CPE Name (hardware, operating system and software). :param string system: type of system associated with CPE Name :param dict components: CPE...
[ "def", "_create_cpe_parts", "(", "self", ",", "system", ",", "components", ")", ":", "if", "system", "not", "in", "CPEComponent", ".", "SYSTEM_VALUES", ":", "errmsg", "=", "\"Key '{0}' is not exist\"", ".", "format", "(", "system", ")", "raise", "ValueError", ...
Create the structure to store the input type of system associated with components of CPE Name (hardware, operating system and software). :param string system: type of system associated with CPE Name :param dict components: CPE Name components to store :returns: None :exception: ...
[ "Create", "the", "structure", "to", "store", "the", "input", "type", "of", "system", "associated", "with", "components", "of", "CPE", "Name", "(", "hardware", "operating", "system", "and", "software", ")", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L389-L408
train
Create the structure to store the input type of system associated with CPE Name components of CPE Name.
nilp0inter/cpe
cpe/cpe.py
CPE._get_attribute_components
def _get_attribute_components(self, att): """ Returns the component list of input attribute. :param string att: Attribute name to get :returns: List of Component objects of the attribute in CPE Name :rtype: list :exception: ValueError - invalid attribute name """...
python
def _get_attribute_components(self, att): """ Returns the component list of input attribute. :param string att: Attribute name to get :returns: List of Component objects of the attribute in CPE Name :rtype: list :exception: ValueError - invalid attribute name """...
[ "def", "_get_attribute_components", "(", "self", ",", "att", ")", ":", "lc", "=", "[", "]", "if", "not", "CPEComponent", ".", "is_valid_attribute", "(", "att", ")", ":", "errmsg", "=", "\"Invalid attribute name '{0}' is not exist\"", ".", "format", "(", "att", ...
Returns the component list of input attribute. :param string att: Attribute name to get :returns: List of Component objects of the attribute in CPE Name :rtype: list :exception: ValueError - invalid attribute name
[ "Returns", "the", "component", "list", "of", "input", "attribute", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L410-L431
train
Returns the list of Component objects of the attribute in CPE Name
nilp0inter/cpe
cpe/cpe.py
CPE._pack_edition
def _pack_edition(self): """ Pack the values of the five arguments into the simple edition component. If all the values are blank, just return a blank. :returns: "edition", "sw_edition", "target_sw", "target_hw" and "other" attributes packed in a only value :rtype: s...
python
def _pack_edition(self): """ Pack the values of the five arguments into the simple edition component. If all the values are blank, just return a blank. :returns: "edition", "sw_edition", "target_sw", "target_hw" and "other" attributes packed in a only value :rtype: s...
[ "def", "_pack_edition", "(", "self", ")", ":", "COMP_KEYS", "=", "(", "CPEComponent", ".", "ATT_EDITION", ",", "CPEComponent", ".", "ATT_SW_EDITION", ",", "CPEComponent", ".", "ATT_TARGET_SW", ",", "CPEComponent", ".", "ATT_TARGET_HW", ",", "CPEComponent", ".", ...
Pack the values of the five arguments into the simple edition component. If all the values are blank, just return a blank. :returns: "edition", "sw_edition", "target_sw", "target_hw" and "other" attributes packed in a only value :rtype: string :exception: TypeError - incompa...
[ "Pack", "the", "values", "of", "the", "five", "arguments", "into", "the", "simple", "edition", "component", ".", "If", "all", "the", "values", "are", "blank", "just", "return", "a", "blank", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L433-L505
train
Pack the values of the five arguments into the simple edition component and return the string representation of the edition attribute.
nilp0inter/cpe
cpe/cpe.py
CPE.as_uri_2_3
def as_uri_2_3(self): """ Returns the CPE Name as URI string of version 2.3. :returns: CPE Name as URI string of version 2.3 :rtype: string :exception: TypeError - incompatible version """ uri = [] uri.append("cpe:/") ordered_comp_parts = { ...
python
def as_uri_2_3(self): """ Returns the CPE Name as URI string of version 2.3. :returns: CPE Name as URI string of version 2.3 :rtype: string :exception: TypeError - incompatible version """ uri = [] uri.append("cpe:/") ordered_comp_parts = { ...
[ "def", "as_uri_2_3", "(", "self", ")", ":", "uri", "=", "[", "]", "uri", ".", "append", "(", "\"cpe:/\"", ")", "ordered_comp_parts", "=", "{", "0", ":", "CPEComponent", ".", "ATT_PART", ",", "1", ":", "CPEComponent", ".", "ATT_VENDOR", ",", "2", ":", ...
Returns the CPE Name as URI string of version 2.3. :returns: CPE Name as URI string of version 2.3 :rtype: string :exception: TypeError - incompatible version
[ "Returns", "the", "CPE", "Name", "as", "URI", "string", "of", "version", "2", ".", "3", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L517-L602
train
Returns the CPE Name as URI string of version 2. 3.
nilp0inter/cpe
cpe/cpe.py
CPE.as_wfn
def as_wfn(self): """ Returns the CPE Name as Well-Formed Name string of version 2.3. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version """ from .cpe2_3_wfn import CPE2_3_WFN wfn = [] wfn.append(CPE2_3_W...
python
def as_wfn(self): """ Returns the CPE Name as Well-Formed Name string of version 2.3. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version """ from .cpe2_3_wfn import CPE2_3_WFN wfn = [] wfn.append(CPE2_3_W...
[ "def", "as_wfn", "(", "self", ")", ":", "from", ".", "cpe2_3_wfn", "import", "CPE2_3_WFN", "wfn", "=", "[", "]", "wfn", ".", "append", "(", "CPE2_3_WFN", ".", "CPE_PREFIX", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "CPEComponent", "....
Returns the CPE Name as Well-Formed Name string of version 2.3. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version
[ "Returns", "the", "CPE", "Name", "as", "Well", "-", "Formed", "Name", "string", "of", "version", "2", ".", "3", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L604-L666
train
Returns the CPE Name as Well - Formed Name string of version 2. 3.
nilp0inter/cpe
cpe/cpe.py
CPE.as_fs
def as_fs(self): """ Returns the CPE Name as formatted string of version 2.3. :returns: CPE Name as formatted string :rtype: string :exception: TypeError - incompatible version """ fs = [] fs.append("cpe:2.3:") for i in range(0, len(CPEComponent...
python
def as_fs(self): """ Returns the CPE Name as formatted string of version 2.3. :returns: CPE Name as formatted string :rtype: string :exception: TypeError - incompatible version """ fs = [] fs.append("cpe:2.3:") for i in range(0, len(CPEComponent...
[ "def", "as_fs", "(", "self", ")", ":", "fs", "=", "[", "]", "fs", ".", "append", "(", "\"cpe:2.3:\"", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "CPEComponent", ".", "ordered_comp_parts", ")", ")", ":", "ck", "=", "CPEComponent", "....
Returns the CPE Name as formatted string of version 2.3. :returns: CPE Name as formatted string :rtype: string :exception: TypeError - incompatible version
[ "Returns", "the", "CPE", "Name", "as", "formatted", "string", "of", "version", "2", ".", "3", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L668-L714
train
Returns the CPE Name as formatted string of version 2. 3.
nilp0inter/cpe
cpe/comp/cpecomp_simple.py
CPEComponentSimple._is_alphanum
def _is_alphanum(cls, c): """ Returns True if c is an uppercase letter, a lowercase letter, a digit or an underscore, otherwise False. :param string c: Character to check :returns: True if char is alphanumeric or an underscore, False otherwise :rtype: boolean...
python
def _is_alphanum(cls, c): """ Returns True if c is an uppercase letter, a lowercase letter, a digit or an underscore, otherwise False. :param string c: Character to check :returns: True if char is alphanumeric or an underscore, False otherwise :rtype: boolean...
[ "def", "_is_alphanum", "(", "cls", ",", "c", ")", ":", "alphanum_rxc", "=", "re", ".", "compile", "(", "CPEComponentSimple", ".", "_ALPHANUM_PATTERN", ")", "return", "(", "alphanum_rxc", ".", "match", "(", "c", ")", "is", "not", "None", ")" ]
Returns True if c is an uppercase letter, a lowercase letter, a digit or an underscore, otherwise False. :param string c: Character to check :returns: True if char is alphanumeric or an underscore, False otherwise :rtype: boolean TEST: a wrong character >>> ...
[ "Returns", "True", "if", "c", "is", "an", "uppercase", "letter", "a", "lowercase", "letter", "a", "digit", "or", "an", "underscore", "otherwise", "False", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L98-L115
train
Checks if the character c is an alphanumeric character.
nilp0inter/cpe
cpe/comp/cpecomp_simple.py
CPEComponentSimple._pct_encode_uri
def _pct_encode_uri(cls, c): """ Return the appropriate percent-encoding of character c (URI string). Certain characters are returned without encoding. :param string c: Character to check :returns: Encoded character as URI :rtype: string TEST: >>> c = '...
python
def _pct_encode_uri(cls, c): """ Return the appropriate percent-encoding of character c (URI string). Certain characters are returned without encoding. :param string c: Character to check :returns: Encoded character as URI :rtype: string TEST: >>> c = '...
[ "def", "_pct_encode_uri", "(", "cls", ",", "c", ")", ":", "CPEComponentSimple", ".", "spechar_to_pce", "[", "'-'", "]", "=", "c", "# bound without encoding", "CPEComponentSimple", ".", "spechar_to_pce", "[", "'.'", "]", "=", "c", "# bound without encoding", "retur...
Return the appropriate percent-encoding of character c (URI string). Certain characters are returned without encoding. :param string c: Character to check :returns: Encoded character as URI :rtype: string TEST: >>> c = '.' >>> CPEComponentSimple._pct_encode_uri...
[ "Return", "the", "appropriate", "percent", "-", "encoding", "of", "character", "c", "(", "URI", "string", ")", ".", "Certain", "characters", "are", "returned", "without", "encoding", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L118-L143
train
Return the appropriate percent - encoding of character c.
nilp0inter/cpe
cpe/comp/cpecomp_simple.py
CPEComponentSimple._is_valid_language
def _is_valid_language(self): """ Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value.lower() lang_rxc = re.comp...
python
def _is_valid_language(self): """ Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value.lower() lang_rxc = re.comp...
[ "def", "_is_valid_language", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_encoded_value", ".", "lower", "(", ")", "lang_rxc", "=", "re", ".", "compile", "(", "CPEComponentSimple", ".", "_LANGTAG_PATTERN", ")", "return", "lang_rxc", ".", "match", "(...
Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean
[ "Return", "True", "if", "the", "value", "of", "component", "in", "attribute", "language", "is", "valid", "and", "otherwise", "False", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L184-L195
train
Returns True if the value of component in attribute language is valid False otherwise.
nilp0inter/cpe
cpe/comp/cpecomp_simple.py
CPEComponentSimple._is_valid_part
def _is_valid_part(self): """ Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value.lower() part_rxc = re...
python
def _is_valid_part(self): """ Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value.lower() part_rxc = re...
[ "def", "_is_valid_part", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_encoded_value", ".", "lower", "(", ")", "part_rxc", "=", "re", ".", "compile", "(", "CPEComponentSimple", ".", "_PART_PATTERN", ")", "return", "part_rxc", ".", "match", "(", "c...
Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean
[ "Return", "True", "if", "the", "value", "of", "component", "in", "attribute", "part", "is", "valid", "and", "otherwise", "False", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L197-L208
train
Returns True if the value of component in attribute part is valid False otherwise.
nilp0inter/cpe
cpe/comp/cpecomp_simple.py
CPEComponentSimple._parse
def _parse(self, comp_att): """ Check if the value of component is correct in the attribute "comp_att". :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component """ errmsg = "Invali...
python
def _parse(self, comp_att): """ Check if the value of component is correct in the attribute "comp_att". :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component """ errmsg = "Invali...
[ "def", "_parse", "(", "self", ",", "comp_att", ")", ":", "errmsg", "=", "\"Invalid attribute '{0}'\"", ".", "format", "(", "comp_att", ")", "if", "not", "CPEComponent", ".", "is_valid_attribute", "(", "comp_att", ")", ":", "raise", "ValueError", "(", "errmsg",...
Check if the value of component is correct in the attribute "comp_att". :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component
[ "Check", "if", "the", "value", "of", "component", "is", "correct", "in", "the", "attribute", "comp_att", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L223-L259
train
Parse the value of component and return the component s value.
nilp0inter/cpe
cpe/comp/cpecomp_simple.py
CPEComponentSimple.as_fs
def as_fs(self): """ Returns the value of component encoded as formatted string. Inspect each character in value of component. Certain nonalpha characters pass thru without escaping into the result, but most retain escaping. :returns: Formatted string associated with co...
python
def as_fs(self): """ Returns the value of component encoded as formatted string. Inspect each character in value of component. Certain nonalpha characters pass thru without escaping into the result, but most retain escaping. :returns: Formatted string associated with co...
[ "def", "as_fs", "(", "self", ")", ":", "s", "=", "self", ".", "_standard_value", "result", "=", "[", "]", "idx", "=", "0", "while", "(", "idx", "<", "len", "(", "s", ")", ")", ":", "c", "=", "s", "[", "idx", "]", "# get the idx'th character of s", ...
Returns the value of component encoded as formatted string. Inspect each character in value of component. Certain nonalpha characters pass thru without escaping into the result, but most retain escaping. :returns: Formatted string associated with component :rtype: string
[ "Returns", "the", "value", "of", "component", "encoded", "as", "formatted", "string", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L261-L298
train
Returns the value of component encoded as a string.
nilp0inter/cpe
cpe/comp/cpecomp_simple.py
CPEComponentSimple.as_uri_2_3
def as_uri_2_3(self): """ Returns the value of component encoded as URI string. Scans an input string s and applies the following transformations: - Pass alphanumeric characters thru untouched - Percent-encode quoted non-alphanumerics as needed - Unquoted special charac...
python
def as_uri_2_3(self): """ Returns the value of component encoded as URI string. Scans an input string s and applies the following transformations: - Pass alphanumeric characters thru untouched - Percent-encode quoted non-alphanumerics as needed - Unquoted special charac...
[ "def", "as_uri_2_3", "(", "self", ")", ":", "s", "=", "self", ".", "_standard_value", "result", "=", "[", "]", "idx", "=", "0", "while", "(", "idx", "<", "len", "(", "s", ")", ")", ":", "thischar", "=", "s", "[", "idx", "]", "# get the idx'th chara...
Returns the value of component encoded as URI string. Scans an input string s and applies the following transformations: - Pass alphanumeric characters thru untouched - Percent-encode quoted non-alphanumerics as needed - Unquoted special characters are mapped to their special forms. ...
[ "Returns", "the", "value", "of", "component", "encoded", "as", "URI", "string", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L300-L344
train
Returns the value of component encoded as URI string.
nilp0inter/cpe
cpe/comp/cpecomp_simple.py
CPEComponentSimple.set_value
def set_value(self, comp_str, comp_att): """ Set the value of component. By default, the component has a simple value. :param string comp_str: new value of component :param string comp_att: attribute associated with value of component :returns: None :exception: V...
python
def set_value(self, comp_str, comp_att): """ Set the value of component. By default, the component has a simple value. :param string comp_str: new value of component :param string comp_att: attribute associated with value of component :returns: None :exception: V...
[ "def", "set_value", "(", "self", ",", "comp_str", ",", "comp_att", ")", ":", "old_value", "=", "self", ".", "_encoded_value", "self", ".", "_encoded_value", "=", "comp_str", "# Check the value of component", "try", ":", "self", ".", "_parse", "(", "comp_att", ...
Set the value of component. By default, the component has a simple value. :param string comp_str: new value of component :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component
[ "Set", "the", "value", "of", "component", ".", "By", "default", "the", "component", "has", "a", "simple", "value", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L367-L390
train
Set the value of component. By default the component has a simple value.
nilp0inter/cpe
cpe/comp/cpecomp2_3_fs.py
CPEComponent2_3_FS._decode
def _decode(self): """ Convert the characters of string s to standard value (WFN value). Inspect each character in value of component. Copy quoted characters, with their escaping, into the result. Look for unquoted non alphanumerics and if not "*" or "?", add escaping. :...
python
def _decode(self): """ Convert the characters of string s to standard value (WFN value). Inspect each character in value of component. Copy quoted characters, with their escaping, into the result. Look for unquoted non alphanumerics and if not "*" or "?", add escaping. :...
[ "def", "_decode", "(", "self", ")", ":", "result", "=", "[", "]", "idx", "=", "0", "s", "=", "self", ".", "_encoded_value", "embedded", "=", "False", "errmsg", "=", "[", "]", "errmsg", ".", "append", "(", "\"Invalid character '\"", ")", "while", "(", ...
Convert the characters of string s to standard value (WFN value). Inspect each character in value of component. Copy quoted characters, with their escaping, into the result. Look for unquoted non alphanumerics and if not "*" or "?", add escaping. :exception: ValueError - invalid charact...
[ "Convert", "the", "characters", "of", "string", "s", "to", "standard", "value", "(", "WFN", "value", ")", ".", "Inspect", "each", "character", "in", "value", "of", "component", ".", "Copy", "quoted", "characters", "with", "their", "escaping", "into", "the", ...
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_fs.py#L93-L165
train
This method decodes the value of the component into a list of strings.
nilp0inter/cpe
cpe/cpe1_1.py
CPE1_1._parse
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self.cpe_str.find(" ") != -1): errmsg = "Bad-formed CPE Name: it must not have whitespaces...
python
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self.cpe_str.find(" ") != -1): errmsg = "Bad-formed CPE Name: it must not have whitespaces...
[ "def", "_parse", "(", "self", ")", ":", "# CPE Name must not have whitespaces", "if", "(", "self", ".", "cpe_str", ".", "find", "(", "\" \"", ")", "!=", "-", "1", ")", ":", "errmsg", "=", "\"Bad-formed CPE Name: it must not have whitespaces\"", "raise", "ValueErro...
Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name
[ "Checks", "if", "the", "CPE", "Name", "is", "valid", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe1_1.py#L173-L264
train
Checks if the CPE Name is valid.
nilp0inter/cpe
cpe/cpe1_1.py
CPE1_1.get_attribute_values
def get_attribute_values(self, att_name): """ Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - in...
python
def get_attribute_values(self, att_name): """ Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - in...
[ "def", "get_attribute_values", "(", "self", ",", "att_name", ")", ":", "lc", "=", "[", "]", "if", "not", "CPEComponent", ".", "is_valid_attribute", "(", "att_name", ")", ":", "errmsg", "=", "\"Invalid attribute name: {0}\"", ".", "format", "(", "att_name", ")"...
Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - invalid attribute name
[ "Returns", "the", "values", "of", "attribute", "att_name", "of", "CPE", "Name", ".", "By", "default", "a", "only", "element", "in", "each", "part", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe1_1.py#L318-L348
train
Returns the values of attribute att_name of CPE Name.
nilp0inter/cpe
cpe/comp/cpecomp2_3_uri_edpacked.py
CPEComponent2_3_URI_edpacked.set_value
def set_value(self, comp_str): """ Set the value of component. :param string comp_str: value of component :returns: None :exception: ValueError - incorrect value of component """ self._is_negated = False self._encoded_value = comp_str self._stand...
python
def set_value(self, comp_str): """ Set the value of component. :param string comp_str: value of component :returns: None :exception: ValueError - incorrect value of component """ self._is_negated = False self._encoded_value = comp_str self._stand...
[ "def", "set_value", "(", "self", ",", "comp_str", ")", ":", "self", ".", "_is_negated", "=", "False", "self", ".", "_encoded_value", "=", "comp_str", "self", ".", "_standard_value", "=", "super", "(", "CPEComponent2_3_URI_edpacked", ",", "self", ")", ".", "_...
Set the value of component. :param string comp_str: value of component :returns: None :exception: ValueError - incorrect value of component
[ "Set", "the", "value", "of", "component", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_uri_edpacked.py#L91-L103
train
Set the value of component.
nilp0inter/cpe
cpe/comp/cpecomp1_1.py
CPEComponent1_1._decode
def _decode(self): """ Convert the encoded value of component to standard value (WFN value). """ s = self._encoded_value elements = s.replace('~', '').split('!') dec_elements = [] for elem in elements: result = [] idx = 0 whil...
python
def _decode(self): """ Convert the encoded value of component to standard value (WFN value). """ s = self._encoded_value elements = s.replace('~', '').split('!') dec_elements = [] for elem in elements: result = [] idx = 0 whil...
[ "def", "_decode", "(", "self", ")", ":", "s", "=", "self", ".", "_encoded_value", "elements", "=", "s", ".", "replace", "(", "'~'", ",", "''", ")", ".", "split", "(", "'!'", ")", "dec_elements", "=", "[", "]", "for", "elem", "in", "elements", ":", ...
Convert the encoded value of component to standard value (WFN value).
[ "Convert", "the", "encoded", "value", "of", "component", "to", "standard", "value", "(", "WFN", "value", ")", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L156-L183
train
Decode the encoded value of component into a standard value.
nilp0inter/cpe
cpe/comp/cpecomp1_1.py
CPEComponent1_1._is_valid_value
def _is_valid_value(self): """ Return True if the value of component in generic attribute is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value value_pattern = [] valu...
python
def _is_valid_value(self): """ Return True if the value of component in generic attribute is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value value_pattern = [] valu...
[ "def", "_is_valid_value", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_encoded_value", "value_pattern", "=", "[", "]", "value_pattern", ".", "append", "(", "\"^((\"", ")", "value_pattern", ".", "append", "(", "\"~[\"", ")", "value_pattern", ".", "a...
Return True if the value of component in generic attribute is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean
[ "Return", "True", "if", "the", "value", "of", "component", "in", "generic", "attribute", "is", "valid", "and", "otherwise", "False", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L185-L210
train
Returns True if the value of generic attribute is valid and otherwise False.
nilp0inter/cpe
cpe/comp/cpecomp1_1.py
CPEComponent1_1.as_wfn
def as_wfn(self): r""" Returns the value of compoment encoded as Well-Formed Name (WFN) string. :returns: WFN string :rtype: string TEST: >>> val = 'xp!vista' >>> comp1 = CPEComponent1_1(val, CPEComponentSimple.ATT_VERSION) >>> comp1.as_wfn() ...
python
def as_wfn(self): r""" Returns the value of compoment encoded as Well-Formed Name (WFN) string. :returns: WFN string :rtype: string TEST: >>> val = 'xp!vista' >>> comp1 = CPEComponent1_1(val, CPEComponentSimple.ATT_VERSION) >>> comp1.as_wfn() ...
[ "def", "as_wfn", "(", "self", ")", ":", "result", "=", "[", "]", "for", "s", "in", "self", ".", "_standard_value", ":", "result", ".", "append", "(", "s", ")", "result", ".", "append", "(", "CPEComponent1_1", ".", "_ESCAPE_SEPARATOR", ")", "return", "\...
r""" Returns the value of compoment encoded as Well-Formed Name (WFN) string. :returns: WFN string :rtype: string TEST: >>> val = 'xp!vista' >>> comp1 = CPEComponent1_1(val, CPEComponentSimple.ATT_VERSION) >>> comp1.as_wfn() 'xp\\!vista'
[ "r", "Returns", "the", "value", "of", "compoment", "encoded", "as", "Well", "-", "Formed", "Name", "(", "WFN", ")", "string", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L309-L331
train
r Returns the value of compoment encoded as Well - Formed Name ( WFN
nilp0inter/cpe
cpe/comp/cpecomp1_1.py
CPEComponent1_1.set_value
def set_value(self, comp_str, comp_att): """ Set the value of component. By default, the component has a simple value. :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component TEST:...
python
def set_value(self, comp_str, comp_att): """ Set the value of component. By default, the component has a simple value. :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component TEST:...
[ "def", "set_value", "(", "self", ",", "comp_str", ",", "comp_att", ")", ":", "super", "(", "CPEComponent1_1", ",", "self", ")", ".", "set_value", "(", "comp_str", ",", "comp_att", ")", "self", ".", "_is_negated", "=", "comp_str", ".", "startswith", "(", ...
Set the value of component. By default, the component has a simple value. :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component TEST: >>> val = 'xp!vista' >>> val2 = 'sp2' ...
[ "Set", "the", "value", "of", "component", ".", "By", "default", "the", "component", "has", "a", "simple", "value", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L333-L354
train
Set the value of component. By default the component has a simple value.
nilp0inter/cpe
cpe/cpe2_3_uri.py
CPE2_3_URI._create_component
def _create_component(cls, att, value): """ Returns a component with value "value". :param string att: Attribute name :param string value: Attribute value :returns: Component object created :rtype: CPEComponent :exception: ValueError - invalid value of attribute ...
python
def _create_component(cls, att, value): """ Returns a component with value "value". :param string att: Attribute name :param string value: Attribute value :returns: Component object created :rtype: CPEComponent :exception: ValueError - invalid value of attribute ...
[ "def", "_create_component", "(", "cls", ",", "att", ",", "value", ")", ":", "if", "value", "==", "CPEComponent2_3_URI", ".", "VALUE_UNDEFINED", ":", "comp", "=", "CPEComponentUndefined", "(", ")", "elif", "(", "value", "==", "CPEComponent2_3_URI", ".", "VALUE_...
Returns a component with value "value". :param string att: Attribute name :param string value: Attribute value :returns: Component object created :rtype: CPEComponent :exception: ValueError - invalid value of attribute
[ "Returns", "a", "component", "with", "value", "value", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L104-L131
train
Create a component object with value value.
nilp0inter/cpe
cpe/cpe2_3_uri.py
CPE2_3_URI._unpack_edition
def _unpack_edition(cls, value): """ Unpack its elements and set the attributes in wfn accordingly. Parse out the five elements: ~ edition ~ software edition ~ target sw ~ target hw ~ other :param string value: Value of edition attribute :returns: Dictionary with parts ...
python
def _unpack_edition(cls, value): """ Unpack its elements and set the attributes in wfn accordingly. Parse out the five elements: ~ edition ~ software edition ~ target sw ~ target hw ~ other :param string value: Value of edition attribute :returns: Dictionary with parts ...
[ "def", "_unpack_edition", "(", "cls", ",", "value", ")", ":", "components", "=", "value", ".", "split", "(", "CPEComponent2_3_URI", ".", "SEPARATOR_PACKED_EDITION", ")", "d", "=", "dict", "(", ")", "ed", "=", "components", "[", "1", "]", "sw_ed", "=", "c...
Unpack its elements and set the attributes in wfn accordingly. Parse out the five elements: ~ edition ~ software edition ~ target sw ~ target hw ~ other :param string value: Value of edition attribute :returns: Dictionary with parts of edition attribute :exception: ValueError -...
[ "Unpack", "its", "elements", "and", "set", "the", "attributes", "in", "wfn", "accordingly", ".", "Parse", "out", "the", "five", "elements", ":" ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L134-L166
train
Unpacks the edition attribute and sets the attributes in wfn accordingly.
nilp0inter/cpe
cpe/cpe2_3_uri.py
CPE2_3_URI._parse
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self._str.find(" ") != -1): msg = "Bad-formed CPE Name: it must not have whitespaces" ...
python
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self._str.find(" ") != -1): msg = "Bad-formed CPE Name: it must not have whitespaces" ...
[ "def", "_parse", "(", "self", ")", ":", "# CPE Name must not have whitespaces", "if", "(", "self", ".", "_str", ".", "find", "(", "\" \"", ")", "!=", "-", "1", ")", ":", "msg", "=", "\"Bad-formed CPE Name: it must not have whitespaces\"", "raise", "ValueError", ...
Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name
[ "Checks", "if", "the", "CPE", "Name", "is", "valid", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L254-L343
train
Parses the CPE Name and returns a dictionary of components and edition parts.
nilp0inter/cpe
cpe/cpe2_3_uri.py
CPE2_3_URI.as_wfn
def as_wfn(self): """ Returns the CPE Name as Well-Formed Name string of version 2.3. If edition component is not packed, only shows the first seven components, otherwise shows all. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatib...
python
def as_wfn(self): """ Returns the CPE Name as Well-Formed Name string of version 2.3. If edition component is not packed, only shows the first seven components, otherwise shows all. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatib...
[ "def", "as_wfn", "(", "self", ")", ":", "if", "self", ".", "_str", ".", "find", "(", "CPEComponent2_3_URI", ".", "SEPARATOR_PACKED_EDITION", ")", "==", "-", "1", ":", "# Edition unpacked, only show the first seven components", "wfn", "=", "[", "]", "wfn", ".", ...
Returns the CPE Name as Well-Formed Name string of version 2.3. If edition component is not packed, only shows the first seven components, otherwise shows all. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version
[ "Returns", "the", "CPE", "Name", "as", "Well", "-", "Formed", "Name", "string", "of", "version", "2", ".", "3", ".", "If", "edition", "component", "is", "not", "packed", "only", "shows", "the", "first", "seven", "components", "otherwise", "shows", "all", ...
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L345-L415
train
Returns the CPE Name as Well - Formed Name string of version 2. 3.
nilp0inter/cpe
cpe/comp/cpecomp2_3_uri.py
CPEComponent2_3_URI._decode
def _decode(self): """ Convert the characters of character in value of component to standard value (WFN value). This function scans the value of component and returns a copy with all percent-encoded characters decoded. :exception: ValueError - invalid character in value ...
python
def _decode(self): """ Convert the characters of character in value of component to standard value (WFN value). This function scans the value of component and returns a copy with all percent-encoded characters decoded. :exception: ValueError - invalid character in value ...
[ "def", "_decode", "(", "self", ")", ":", "result", "=", "[", "]", "idx", "=", "0", "s", "=", "self", ".", "_encoded_value", "embedded", "=", "False", "errmsg", "=", "[", "]", "errmsg", ".", "append", "(", "\"Invalid value: \"", ")", "while", "(", "id...
Convert the characters of character in value of component to standard value (WFN value). This function scans the value of component and returns a copy with all percent-encoded characters decoded. :exception: ValueError - invalid character in value of component
[ "Convert", "the", "characters", "of", "character", "in", "value", "of", "component", "to", "standard", "value", "(", "WFN", "value", ")", ".", "This", "function", "scans", "the", "value", "of", "component", "and", "returns", "a", "copy", "with", "all", "pe...
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_uri.py#L163-L244
train
This function decodes the characters of character in value of component into a list of values.
nilp0inter/cpe
cpe/comp/cpecomp2_3_uri.py
CPEComponent2_3_URI._is_valid_edition
def _is_valid_edition(self): """ Return True if the input value of attribute "edition" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._standard_value[0] packed = [] packed.app...
python
def _is_valid_edition(self): """ Return True if the input value of attribute "edition" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._standard_value[0] packed = [] packed.app...
[ "def", "_is_valid_edition", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_standard_value", "[", "0", "]", "packed", "=", "[", "]", "packed", ".", "append", "(", "\"(\"", ")", "packed", ".", "append", "(", "CPEComponent2_3_URI", ".", "SEPARATOR_PAC...
Return True if the input value of attribute "edition" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean
[ "Return", "True", "if", "the", "input", "value", "of", "attribute", "edition", "is", "valid", "and", "otherwise", "False", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_uri.py#L246-L271
train
Returns True if the input value of attribute edition is valid and otherwise False.
nilp0inter/cpe
cpe/comp/cpecomp2_3.py
CPEComponent2_3._is_valid_language
def _is_valid_language(self): """ Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean CASE 1: Language part with/without region part CASE 2: Language part ...
python
def _is_valid_language(self): """ Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean CASE 1: Language part with/without region part CASE 2: Language part ...
[ "def", "_is_valid_language", "(", "self", ")", ":", "def", "check_generic_language", "(", "self", ",", "value", ")", ":", "\"\"\"\n Check possible values in language part\n when region part exists or not in language value.\n\n Possible values of language ...
Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean CASE 1: Language part with/without region part CASE 2: Language part without region part CASE 3: Region part wi...
[ "Return", "True", "if", "the", "value", "of", "component", "in", "attribute", "language", "is", "valid", "and", "otherwise", "False", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3.py#L58-L245
train
Checks if the value of component in attribute language is valid and if it is valid.
nilp0inter/cpe
cpe/comp/cpecomp2_3.py
CPEComponent2_3._is_valid_part
def _is_valid_part(self): """ Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value # Check if value of ...
python
def _is_valid_part(self): """ Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value # Check if value of ...
[ "def", "_is_valid_part", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_encoded_value", "# Check if value of component do not have wildcard", "if", "(", "(", "comp_str", ".", "find", "(", "self", ".", "WILDCARD_ONE", ")", "==", "-", "1", ")", "and", "(...
Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean
[ "Return", "True", "if", "the", "value", "of", "component", "in", "attribute", "part", "is", "valid", "and", "otherwise", "False", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3.py#L247-L269
train
Check if the value of component in attribute part is valid and if otherwise False.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3._compare
def _compare(cls, source, target): """ Compares two values associated with a attribute of two WFNs, which may be logical values (ANY or NA) or string values. :param string source: First attribute value :param string target: Second attribute value :returns: The attribute ...
python
def _compare(cls, source, target): """ Compares two values associated with a attribute of two WFNs, which may be logical values (ANY or NA) or string values. :param string source: First attribute value :param string target: Second attribute value :returns: The attribute ...
[ "def", "_compare", "(", "cls", ",", "source", ",", "target", ")", ":", "if", "(", "CPESet2_3", ".", "_is_string", "(", "source", ")", ")", ":", "source", "=", "source", ".", "lower", "(", ")", "if", "(", "CPESet2_3", ".", "_is_string", "(", "target",...
Compares two values associated with a attribute of two WFNs, which may be logical values (ANY or NA) or string values. :param string source: First attribute value :param string target: Second attribute value :returns: The attribute comparison relation. :rtype: int This ...
[ "Compares", "two", "values", "associated", "with", "a", "attribute", "of", "two", "WFNs", "which", "may", "be", "logical", "values", "(", "ANY", "or", "NA", ")", "or", "string", "values", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L74-L121
train
Compares two values associated with a attribute of two WFNs and returns the attribute comparison relation.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3._compare_strings
def _compare_strings(cls, source, target): """ Compares a source string to a target string, and addresses the condition in which the source string includes unquoted special characters. It performs a simple regular expression match, with the assumption that (as required) ...
python
def _compare_strings(cls, source, target): """ Compares a source string to a target string, and addresses the condition in which the source string includes unquoted special characters. It performs a simple regular expression match, with the assumption that (as required) ...
[ "def", "_compare_strings", "(", "cls", ",", "source", ",", "target", ")", ":", "start", "=", "0", "end", "=", "len", "(", "source", ")", "begins", "=", "0", "ends", "=", "0", "# Reading of initial wildcard in source", "if", "source", ".", "startswith", "("...
Compares a source string to a target string, and addresses the condition in which the source string includes unquoted special characters. It performs a simple regular expression match, with the assumption that (as required) unquoted special characters appear only at the beginnin...
[ "Compares", "a", "source", "string", "to", "a", "target", "string", "and", "addresses", "the", "condition", "in", "which", "the", "source", "string", "includes", "unquoted", "special", "characters", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L124-L198
train
This function compares two strings in order to find the relation between the source and target strings.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3._contains_wildcards
def _contains_wildcards(cls, s): """ Return True if the string contains any unquoted special characters (question-mark or asterisk), otherwise False. Ex: _contains_wildcards("foo") => FALSE Ex: _contains_wildcards("foo\?") => FALSE Ex: _contains_wildcards("foo?") => TRUE...
python
def _contains_wildcards(cls, s): """ Return True if the string contains any unquoted special characters (question-mark or asterisk), otherwise False. Ex: _contains_wildcards("foo") => FALSE Ex: _contains_wildcards("foo\?") => FALSE Ex: _contains_wildcards("foo?") => TRUE...
[ "def", "_contains_wildcards", "(", "cls", ",", "s", ")", ":", "idx", "=", "s", ".", "find", "(", "\"*\"", ")", "if", "idx", "!=", "-", "1", ":", "if", "idx", "==", "0", ":", "return", "True", "else", ":", "if", "s", "[", "idx", "-", "1", "]",...
Return True if the string contains any unquoted special characters (question-mark or asterisk), otherwise False. Ex: _contains_wildcards("foo") => FALSE Ex: _contains_wildcards("foo\?") => FALSE Ex: _contains_wildcards("foo?") => TRUE Ex: _contains_wildcards("\*bar") => FALSE ...
[ "Return", "True", "if", "the", "string", "contains", "any", "unquoted", "special", "characters", "(", "question", "-", "mark", "or", "asterisk", ")", "otherwise", "False", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L201-L235
train
Return True if the string contains any unquoted special characters and otherwise False.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3._is_even_wildcards
def _is_even_wildcards(cls, str, idx): """ Returns True if an even number of escape (backslash) characters precede the character at index idx in string str. :param string str: string to check :returns: True if an even number of escape characters precede the character...
python
def _is_even_wildcards(cls, str, idx): """ Returns True if an even number of escape (backslash) characters precede the character at index idx in string str. :param string str: string to check :returns: True if an even number of escape characters precede the character...
[ "def", "_is_even_wildcards", "(", "cls", ",", "str", ",", "idx", ")", ":", "result", "=", "0", "while", "(", "(", "idx", ">", "0", ")", "and", "(", "str", "[", "idx", "-", "1", "]", "==", "\"\\\\\"", ")", ")", ":", "idx", "-=", "1", "result", ...
Returns True if an even number of escape (backslash) characters precede the character at index idx in string str. :param string str: string to check :returns: True if an even number of escape characters precede the character at index idx in string str, False otherwise. :rtyp...
[ "Returns", "True", "if", "an", "even", "number", "of", "escape", "(", "backslash", ")", "characters", "precede", "the", "character", "at", "index", "idx", "in", "string", "str", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L238-L255
train
Checks if the string str contains even wildcards.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3._is_string
def _is_string(cls, arg): """ Return True if arg is a string value, and False if arg is a logical value (ANY or NA). :param string arg: string to check :returns: True if value is a string, False if it is a logical value. :rtype: boolean This function is a suppor...
python
def _is_string(cls, arg): """ Return True if arg is a string value, and False if arg is a logical value (ANY or NA). :param string arg: string to check :returns: True if value is a string, False if it is a logical value. :rtype: boolean This function is a suppor...
[ "def", "_is_string", "(", "cls", ",", "arg", ")", ":", "isAny", "=", "arg", "==", "CPEComponent2_3_WFN", ".", "VALUE_ANY", "isNa", "=", "arg", "==", "CPEComponent2_3_WFN", ".", "VALUE_NA", "return", "not", "(", "isAny", "or", "isNa", ")" ]
Return True if arg is a string value, and False if arg is a logical value (ANY or NA). :param string arg: string to check :returns: True if value is a string, False if it is a logical value. :rtype: boolean This function is a support function for _compare().
[ "Return", "True", "if", "arg", "is", "a", "string", "value", "and", "False", "if", "arg", "is", "a", "logical", "value", "(", "ANY", "or", "NA", ")", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L258-L273
train
Checks if the given string value is a string value.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3.compare_wfns
def compare_wfns(cls, source, target): """ Compares two WFNs and returns a generator of pairwise attribute-value comparison results. It provides full access to the individual comparison results to enable use-case specific implementations of novel name-comparison algorithms. ...
python
def compare_wfns(cls, source, target): """ Compares two WFNs and returns a generator of pairwise attribute-value comparison results. It provides full access to the individual comparison results to enable use-case specific implementations of novel name-comparison algorithms. ...
[ "def", "compare_wfns", "(", "cls", ",", "source", ",", "target", ")", ":", "# Compare results using the get() function in WFN", "for", "att", "in", "CPEComponent", ".", "CPE_COMP_KEYS_EXTENDED", ":", "value_src", "=", "source", ".", "get_attribute_values", "(", "att",...
Compares two WFNs and returns a generator of pairwise attribute-value comparison results. It provides full access to the individual comparison results to enable use-case specific implementations of novel name-comparison algorithms. Compare each attribute of the Source WFN to the Target ...
[ "Compares", "two", "WFNs", "and", "returns", "a", "generator", "of", "pairwise", "attribute", "-", "value", "comparison", "results", ".", "It", "provides", "full", "access", "to", "the", "individual", "comparison", "results", "to", "enable", "use", "-", "case"...
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L276-L303
train
Compares two set of WFNs and returns a generator of pairwise attribute - value - comparison results.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3.cpe_disjoint
def cpe_disjoint(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is DISJOINT. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation betwe...
python
def cpe_disjoint(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is DISJOINT. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation betwe...
[ "def", "cpe_disjoint", "(", "cls", ",", "source", ",", "target", ")", ":", "# If any pairwise comparison returned DISJOINT then", "# the overall name relationship is DISJOINT", "for", "att", ",", "result", "in", "CPESet2_3", ".", "compare_wfns", "(", "source", ",", "ta...
Compares two WFNs and returns True if the set-theoretic relation between the names is DISJOINT. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between source and target is DISJOINT, otherwise Fal...
[ "Compares", "two", "WFNs", "and", "returns", "True", "if", "the", "set", "-", "theoretic", "relation", "between", "the", "names", "is", "DISJOINT", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L306-L324
train
Checks if the set - theoretic relation between two WFNs is DISJOINT.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3.cpe_equal
def cpe_equal(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is EQUAL. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between sou...
python
def cpe_equal(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is EQUAL. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between sou...
[ "def", "cpe_equal", "(", "cls", ",", "source", ",", "target", ")", ":", "# If any pairwise comparison returned EQUAL then", "# the overall name relationship is EQUAL", "for", "att", ",", "result", "in", "CPESet2_3", ".", "compare_wfns", "(", "source", ",", "target", "...
Compares two WFNs and returns True if the set-theoretic relation between the names is EQUAL. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between source and target is EQUAL, otherwise False. ...
[ "Compares", "two", "WFNs", "and", "returns", "True", "if", "the", "set", "-", "theoretic", "relation", "between", "the", "names", "is", "EQUAL", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L327-L345
train
Compares two set - theoretic WFNs and returns True if the set - theoretic relation between the names is EQUAL otherwise False.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3.cpe_subset
def cpe_subset(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUBSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relat...
python
def cpe_subset(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUBSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relat...
[ "def", "cpe_subset", "(", "cls", ",", "source", ",", "target", ")", ":", "# If any pairwise comparison returned something other than SUBSET", "# or EQUAL, then SUBSET is False.", "for", "att", ",", "result", "in", "CPESet2_3", ".", "compare_wfns", "(", "source", ",", "t...
Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUBSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between source and target is SUBSET, othe...
[ "Compares", "two", "WFNs", "and", "returns", "True", "if", "the", "set", "-", "theoretic", "relation", "between", "the", "names", "is", "(", "non", "-", "proper", ")", "SUBSET", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L348-L367
train
Returns True if the set - theoretic relation between source and target is SUBSET otherwise False.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3.cpe_superset
def cpe_superset(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUPERSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set r...
python
def cpe_superset(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUPERSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set r...
[ "def", "cpe_superset", "(", "cls", ",", "source", ",", "target", ")", ":", "# If any pairwise comparison returned something other than SUPERSET", "# or EQUAL, then SUPERSET is False.", "for", "att", ",", "result", "in", "CPESet2_3", ".", "compare_wfns", "(", "source", ","...
Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUPERSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between source and target is SUPERSET, ...
[ "Compares", "two", "WFNs", "and", "returns", "True", "if", "the", "set", "-", "theoretic", "relation", "between", "the", "names", "is", "(", "non", "-", "proper", ")", "SUPERSET", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L370-L390
train
Returns True if the set - theoretic relation between two WFNs is SUPERSET otherwise False.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3.append
def append(self, cpe): """ Adds a CPE element to the set if not already. Only WFN CPE Names are valid, so this function converts the input CPE object of version 2.3 to WFN style. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - inv...
python
def append(self, cpe): """ Adds a CPE element to the set if not already. Only WFN CPE Names are valid, so this function converts the input CPE object of version 2.3 to WFN style. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - inv...
[ "def", "append", "(", "self", ",", "cpe", ")", ":", "if", "cpe", ".", "VERSION", "!=", "CPE2_3", ".", "VERSION", ":", "errmsg", "=", "\"CPE Name version {0} not valid, version 2.3 expected\"", ".", "format", "(", "cpe", ".", "VERSION", ")", "raise", "ValueErro...
Adds a CPE element to the set if not already. Only WFN CPE Names are valid, so this function converts the input CPE object of version 2.3 to WFN style. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name
[ "Adds", "a", "CPE", "element", "to", "the", "set", "if", "not", "already", ".", "Only", "WFN", "CPE", "Names", "are", "valid", "so", "this", "function", "converts", "the", "input", "CPE", "object", "of", "version", "2", ".", "3", "to", "WFN", "style", ...
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L396-L421
train
Adds a CPE element to the set if not already.
nilp0inter/cpe
cpe/cpeset2_3.py
CPESet2_3.name_match
def name_match(self, wfn): """ Accepts a set of CPE Names K and a candidate CPE Name X. It returns 'True' if X matches any member of K, and 'False' otherwise. :param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}. :param CPE cpe: A candidate CPE Name X. :ret...
python
def name_match(self, wfn): """ Accepts a set of CPE Names K and a candidate CPE Name X. It returns 'True' if X matches any member of K, and 'False' otherwise. :param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}. :param CPE cpe: A candidate CPE Name X. :ret...
[ "def", "name_match", "(", "self", ",", "wfn", ")", ":", "for", "N", "in", "self", ".", "K", ":", "if", "CPESet2_3", ".", "cpe_superset", "(", "wfn", ",", "N", ")", ":", "return", "True", "return", "False" ]
Accepts a set of CPE Names K and a candidate CPE Name X. It returns 'True' if X matches any member of K, and 'False' otherwise. :param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}. :param CPE cpe: A candidate CPE Name X. :returns: True if X matches K, otherwise False. ...
[ "Accepts", "a", "set", "of", "CPE", "Names", "K", "and", "a", "candidate", "CPE", "Name", "X", ".", "It", "returns", "True", "if", "X", "matches", "any", "member", "of", "K", "and", "False", "otherwise", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L423-L437
train
Returns True if X matches any member of K False otherwise.
nilp0inter/cpe
cpe/cpe2_3_wfn.py
CPE2_3_WFN._parse
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # Check prefix and initial bracket of WFN if self._str[0:5] != CPE2_3_WFN.CPE_PREFIX: errmsg = "Bad-formed CPE Name: WFN prefix not...
python
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # Check prefix and initial bracket of WFN if self._str[0:5] != CPE2_3_WFN.CPE_PREFIX: errmsg = "Bad-formed CPE Name: WFN prefix not...
[ "def", "_parse", "(", "self", ")", ":", "# Check prefix and initial bracket of WFN", "if", "self", ".", "_str", "[", "0", ":", "5", "]", "!=", "CPE2_3_WFN", ".", "CPE_PREFIX", ":", "errmsg", "=", "\"Bad-formed CPE Name: WFN prefix not found\"", "raise", "ValueError"...
Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name
[ "Checks", "if", "the", "CPE", "Name", "is", "valid", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_wfn.py#L110-L216
train
Checks if the CPE Name is valid.
nilp0inter/cpe
cpe/cpelang2_2.py
CPELanguage2_2.language_match
def language_match(self, cpeset, cpel_dom=None): """ Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applic...
python
def language_match(self, cpeset, cpel_dom=None): """ Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applic...
[ "def", "language_match", "(", "self", ",", "cpeset", ",", "cpel_dom", "=", "None", ")", ":", "# Root element tag", "TAG_ROOT", "=", "'#document'", "# A container for child platform definitions", "TAG_PLATSPEC", "=", "'cpe:platform-specification'", "# Information about a platf...
Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applicability Language, represented as the XML infoset for the ...
[ "Accepts", "a", "set", "of", "known", "CPE", "Names", "and", "an", "expression", "in", "the", "CPE", "language", "and", "delivers", "the", "answer", "True", "if", "the", "expression", "matches", "with", "the", "set", ".", "Otherwise", "it", "returns", "Fal...
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_2.py#L59-L149
train
Returns True if the expression matches with the set False otherwise.
nilp0inter/cpe
cpe/cpeset2_2.py
CPESet2_2.append
def append(self, cpe): """ Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset2_2 import CPESet2_2 >>> from .cpe2_2 import CPE2_2...
python
def append(self, cpe): """ Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset2_2 import CPESet2_2 >>> from .cpe2_2 import CPE2_2...
[ "def", "append", "(", "self", ",", "cpe", ")", ":", "if", "cpe", ".", "VERSION", "!=", "CPE", ".", "VERSION_2_2", ":", "errmsg", "=", "\"CPE Name version {0} not valid, version 2.2 expected\"", ".", "format", "(", "cpe", ".", "VERSION", ")", "raise", "ValueErr...
Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset2_2 import CPESet2_2 >>> from .cpe2_2 import CPE2_2 >>> uri1 = 'cpe:/h:hp' >>>...
[ "Adds", "a", "CPE", "Name", "to", "the", "set", "if", "not", "already", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_2.py#L58-L86
train
Adds a CPE Name to the set if not already.
nilp0inter/cpe
cpe/comp/cpecomp2_3_wfn.py
CPEComponent2_3_WFN.set_value
def set_value(self, comp_str, comp_att): """ Set the value of component. :param string comp_str: value of component :param string comp_att: attribute associated with comp_str :returns: None :exception: ValueError - incorrect value of component """ # Del ...
python
def set_value(self, comp_str, comp_att): """ Set the value of component. :param string comp_str: value of component :param string comp_att: attribute associated with comp_str :returns: None :exception: ValueError - incorrect value of component """ # Del ...
[ "def", "set_value", "(", "self", ",", "comp_str", ",", "comp_att", ")", ":", "# Del double quotes of value", "str", "=", "comp_str", "[", "1", ":", "-", "1", "]", "self", ".", "_standard_value", "=", "str", "# Parse the value", "super", "(", "CPEComponent2_3_W...
Set the value of component. :param string comp_str: value of component :param string comp_att: attribute associated with comp_str :returns: None :exception: ValueError - incorrect value of component
[ "Set", "the", "value", "of", "component", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_wfn.py#L132-L147
train
Set the value of component.
nilp0inter/cpe
cpe/cpeset1_1.py
CPESet1_1.append
def append(self, cpe): """ Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset1_1 import CPESet1_1 >>> from .cpe1_1 import CPE1_1 ...
python
def append(self, cpe): """ Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset1_1 import CPESet1_1 >>> from .cpe1_1 import CPE1_1 ...
[ "def", "append", "(", "self", ",", "cpe", ")", ":", "if", "cpe", ".", "VERSION", "!=", "CPE", ".", "VERSION_1_1", ":", "msg", "=", "\"CPE Name version {0} not valid, version 1.1 expected\"", ".", "format", "(", "cpe", ".", "VERSION", ")", "raise", "ValueError"...
Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset1_1 import CPESet1_1 >>> from .cpe1_1 import CPE1_1 >>> uri1 = 'cpe://microsoft:windows...
[ "Adds", "a", "CPE", "Name", "to", "the", "set", "if", "not", "already", "." ]
670d947472a7652af5149324977b50f9a7af9bcf
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset1_1.py#L56-L83
train
Adds a CPE Name to the set if not already.