repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
jgillick/LendingClub
lendingclub/filters.py
Filter.__normalize
def __normalize(self): """ Adjusts the values of the filters to be correct. For example, if you set grade 'B' to True, then 'All' should be set to False """ # Don't normalize if we're already normalizing or intializing if self.__normalizing is True or self.__init...
python
def __normalize(self): """ Adjusts the values of the filters to be correct. For example, if you set grade 'B' to True, then 'All' should be set to False """ # Don't normalize if we're already normalizing or intializing if self.__normalizing is True or self.__init...
[ "def", "__normalize", "(", "self", ")", ":", "# Don't normalize if we're already normalizing or intializing", "if", "self", ".", "__normalizing", "is", "True", "or", "self", ".", "__initialized", "is", "False", ":", "return", "self", ".", "__normalizing", "=", "True...
Adjusts the values of the filters to be correct. For example, if you set grade 'B' to True, then 'All' should be set to False
[ "Adjusts", "the", "values", "of", "the", "filters", "to", "be", "correct", ".", "For", "example", "if", "you", "set", "grade", "B", "to", "True", "then", "All", "should", "be", "set", "to", "False" ]
train
https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/filters.py#L221-L235
jgillick/LendingClub
lendingclub/filters.py
Filter.validate_one
def validate_one(self, loan): """ Validate a single loan result record against the filters Parameters ---------- loan : dict A single loan note record Returns ------- boolean True or raises FilterValidationError Raises ...
python
def validate_one(self, loan): """ Validate a single loan result record against the filters Parameters ---------- loan : dict A single loan note record Returns ------- boolean True or raises FilterValidationError Raises ...
[ "def", "validate_one", "(", "self", ",", "loan", ")", ":", "assert", "type", "(", "loan", ")", "is", "dict", ",", "'loan parameter must be a dictionary object'", "# Map the loan value keys to the filter keys", "req", "=", "{", "'loanGUID'", ":", "'loan_id'", ",", "'...
Validate a single loan result record against the filters Parameters ---------- loan : dict A single loan note record Returns ------- boolean True or raises FilterValidationError Raises ------ FilterValidationError ...
[ "Validate", "a", "single", "loan", "result", "record", "against", "the", "filters" ]
train
https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/filters.py#L265-L344
jgillick/LendingClub
lendingclub/filters.py
Filter.search_string
def search_string(self): """" Returns the JSON string that LendingClub expects for it's search """ self.__normalize() # Get the template tmpl_source = unicode(open(self.tmpl_file).read()) # Process template compiler = Compiler() template = compil...
python
def search_string(self): """" Returns the JSON string that LendingClub expects for it's search """ self.__normalize() # Get the template tmpl_source = unicode(open(self.tmpl_file).read()) # Process template compiler = Compiler() template = compil...
[ "def", "search_string", "(", "self", ")", ":", "self", ".", "__normalize", "(", ")", "# Get the template", "tmpl_source", "=", "unicode", "(", "open", "(", "self", ".", "tmpl_file", ")", ".", "read", "(", ")", ")", "# Process template", "compiler", "=", "C...
Returns the JSON string that LendingClub expects for it's search
[ "Returns", "the", "JSON", "string", "that", "LendingClub", "expects", "for", "it", "s", "search" ]
train
https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/filters.py#L346-L380
jgillick/LendingClub
lendingclub/filters.py
SavedFilter.all_filters
def all_filters(lc): """ Get a list of all your saved filters Parameters ---------- lc : :py:class:`lendingclub.LendingClub` An instance of the authenticated LendingClub class Returns ------- list A list of lendingclub.filters.Sav...
python
def all_filters(lc): """ Get a list of all your saved filters Parameters ---------- lc : :py:class:`lendingclub.LendingClub` An instance of the authenticated LendingClub class Returns ------- list A list of lendingclub.filters.Sav...
[ "def", "all_filters", "(", "lc", ")", ":", "filters", "=", "[", "]", "response", "=", "lc", ".", "session", ".", "get", "(", "'/browse/getSavedFiltersAj.action'", ")", "json_response", "=", "response", ".", "json", "(", ")", "# Load all filters", "if", "lc",...
Get a list of all your saved filters Parameters ---------- lc : :py:class:`lendingclub.LendingClub` An instance of the authenticated LendingClub class Returns ------- list A list of lendingclub.filters.SavedFilter objects
[ "Get", "a", "list", "of", "all", "your", "saved", "filters" ]
train
https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/filters.py#L431-L455
jgillick/LendingClub
lendingclub/filters.py
SavedFilter.load
def load(self): """ Load the filter from the server """ # Attempt to load the saved filter payload = { 'id': self.id } response = self.lc.session.get('/browse/getSavedFilterAj.action', query=payload) self.response = response json_respo...
python
def load(self): """ Load the filter from the server """ # Attempt to load the saved filter payload = { 'id': self.id } response = self.lc.session.get('/browse/getSavedFilterAj.action', query=payload) self.response = response json_respo...
[ "def", "load", "(", "self", ")", ":", "# Attempt to load the saved filter", "payload", "=", "{", "'id'", ":", "self", ".", "id", "}", "response", "=", "self", ".", "lc", ".", "session", ".", "get", "(", "'/browse/getSavedFilterAj.action'", ",", "query", "=",...
Load the filter from the server
[ "Load", "the", "filter", "from", "the", "server" ]
train
https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/filters.py#L468-L561
jgillick/LendingClub
lendingclub/filters.py
SavedFilter.__analyze
def __analyze(self): """ Analyze the filter JSON and attempt to parse out the individual filters. """ filter_values = {} # ID to filter name mapping name_map = { 10: 'grades', 11: 'loan_purpose', 13: 'approved', 15: 'fundin...
python
def __analyze(self): """ Analyze the filter JSON and attempt to parse out the individual filters. """ filter_values = {} # ID to filter name mapping name_map = { 10: 'grades', 11: 'loan_purpose', 13: 'approved', 15: 'fundin...
[ "def", "__analyze", "(", "self", ")", ":", "filter_values", "=", "{", "}", "# ID to filter name mapping", "name_map", "=", "{", "10", ":", "'grades'", ",", "11", ":", "'loan_purpose'", ",", "13", ":", "'approved'", ",", "15", ":", "'funding_progress'", ",", ...
Analyze the filter JSON and attempt to parse out the individual filters.
[ "Analyze", "the", "filter", "JSON", "and", "attempt", "to", "parse", "out", "the", "individual", "filters", "." ]
train
https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/filters.py#L572-L634
vnmabus/dcor
dcor/_dcor_internals.py
_float_copy_to_out
def _float_copy_to_out(out, origin): """ Copy origin to out and return it. If ``out`` is None, a new copy (casted to floating point) is used. If ``out`` and ``origin`` are the same, we simply return it. Otherwise we copy the values. """ if out is None: out = origin / 1 # The divis...
python
def _float_copy_to_out(out, origin): """ Copy origin to out and return it. If ``out`` is None, a new copy (casted to floating point) is used. If ``out`` and ``origin`` are the same, we simply return it. Otherwise we copy the values. """ if out is None: out = origin / 1 # The divis...
[ "def", "_float_copy_to_out", "(", "out", ",", "origin", ")", ":", "if", "out", "is", "None", ":", "out", "=", "origin", "/", "1", "# The division forces cast to a floating point type", "elif", "out", "is", "not", "origin", ":", "np", ".", "copyto", "(", "out...
Copy origin to out and return it. If ``out`` is None, a new copy (casted to floating point) is used. If ``out`` and ``origin`` are the same, we simply return it. Otherwise we copy the values.
[ "Copy", "origin", "to", "out", "and", "return", "it", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L40-L53
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L56-L79
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L146-L172
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L294-L367
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L370-L480
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", "}", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L483-L573
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L576-L588
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" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor_internals.py#L615-L623
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_partial_dcor.py#L13-L70
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_partial_dcor.py#L73-L145
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_energy.py#L24-L28
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_energy.py#L31-L50
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L34-L44
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L47-L57
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L60-L83
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L86-L92
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L95-L101
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L115-L127
vnmabus/dcor
dcor/_dcor.py
_dyad_update
def _dyad_update(y, c): # pylint:disable=too-many-locals # This function has many locals so it can be compared # with the original algorithm. """ Inner function of the fast distance covariance. This function is compiled because otherwise it would become a bottleneck. """ n = y.shape[0...
python
def _dyad_update(y, c): # pylint:disable=too-many-locals # This function has many locals so it can be compared # with the original algorithm. """ Inner function of the fast distance covariance. This function is compiled because otherwise it would become a bottleneck. """ n = y.shape[0...
[ "def", "_dyad_update", "(", "y", ",", "c", ")", ":", "# pylint:disable=too-many-locals", "# This function has many locals so it can be compared", "# with the original algorithm.", "n", "=", "y", ".", "shape", "[", "0", "]", "gamma", "=", "np", ".", "zeros", "(", "n"...
Inner function of the fast distance covariance. This function is compiled because otherwise it would become a bottleneck.
[ "Inner", "function", "of", "the", "fast", "distance", "covariance", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L131-L178
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L229-L303
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L316-L335
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", ")" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L360-L417
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", ")" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L420-L477
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", ")" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L537-L609
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", ")" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L612-L687
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", ")" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L690-L755
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", ")" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L758-L815
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", ")" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L818-L877
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_dcor.py#L937-L988
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", ")" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_pairwise.py#L10-L94
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_pairwise.py#L97-L134
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_utils.py#L10-L27
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_utils.py#L30-L50
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_utils.py#L53-L63
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/_utils.py#L66-L78
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L18-L28
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L31-L44
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L47-L59
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L62-L74
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", "." ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L77-L89
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", ")" ]
train
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L92-L149
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", "." ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/receiver.py#L123-L171
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", "." ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L49-L69
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", ")", "." ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L72-L88
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", "." ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L91-L106
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", "." ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L109-L136
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", ":" ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L147-L192
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", "." ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L21-L61
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", ")" ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L67-L81
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", "." ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L84-L101
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", "." ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L104-L159
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", "." ]
train
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/sender.py#L106-L175
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", "." ]
train
https://github.com/kajic/django-model-changes/blob/92124ebdf29cba930eb1ced00135823b961041d3/django_model_changes/changes.py#L98-L105
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", "." ]
train
https://github.com/kajic/django-model-changes/blob/92124ebdf29cba930eb1ced00135823b961041d3/django_model_changes/changes.py#L149-L167
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L115-L146
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", ")", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L389-L408
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L410-L431
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L433-L505
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L517-L602
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L604-L666
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L668-L714
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L98-L115
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L118-L143
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L184-L195
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L197-L208
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L223-L259
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L261-L298
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L300-L344
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L367-L390
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", ...
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_fs.py#L93-L165
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe1_1.py#L173-L264
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe1_1.py#L318-L348
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_uri_edpacked.py#L91-L103
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", ")", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L156-L183
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L185-L210
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L309-L331
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L333-L354
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L104-L131
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", ":" ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L134-L166
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L254-L343
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", ...
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L345-L415
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...
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_uri.py#L163-L244
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_uri.py#L246-L271
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3.py#L58-L245
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3.py#L247-L269
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L74-L121
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L124-L198
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L201-L235
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L238-L255
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", ")", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L258-L273
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"...
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L276-L303
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L306-L324
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L327-L345
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", "." ]
train
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L348-L367