repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
jleinonen/pytmatrix | pytmatrix/radar.py | Kdp | def Kdp(scatterer):
"""
Specific differential phase (K_dp) for the current setup.
Args:
scatterer: a Scatterer instance.
Returns:
K_dp [deg/km].
NOTE: This only returns the correct value if the particle diameter and
wavelength are given in [mm]. The scatterer object should be ... | python | def Kdp(scatterer):
"""
Specific differential phase (K_dp) for the current setup.
Args:
scatterer: a Scatterer instance.
Returns:
K_dp [deg/km].
NOTE: This only returns the correct value if the particle diameter and
wavelength are given in [mm]. The scatterer object should be ... | [
"def",
"Kdp",
"(",
"scatterer",
")",
":",
"if",
"(",
"scatterer",
".",
"thet0",
"!=",
"scatterer",
".",
"thet",
")",
"or",
"(",
"scatterer",
".",
"phi0",
"!=",
"scatterer",
".",
"phi",
")",
":",
"raise",
"ValueError",
"(",
"\"A forward scattering geometry ... | Specific differential phase (K_dp) for the current setup.
Args:
scatterer: a Scatterer instance.
Returns:
K_dp [deg/km].
NOTE: This only returns the correct value if the particle diameter and
wavelength are given in [mm]. The scatterer object should be set to
forward scattering g... | [
"Specific",
"differential",
"phase",
"(",
"K_dp",
")",
"for",
"the",
"current",
"setup",
"."
] | train | https://github.com/jleinonen/pytmatrix/blob/8803507fe5332786feab105fa74acf63e7121718/pytmatrix/radar.py#L112-L133 |
jleinonen/pytmatrix | pytmatrix/refractive.py | mg_refractive | def mg_refractive(m, mix):
"""Maxwell-Garnett EMA for the refractive index.
Args:
m: Tuple of the complex refractive indices of the media.
mix: Tuple of the volume fractions of the media, len(mix)==len(m)
(if sum(mix)!=1, these are taken relative to sum(mix))
Returns:
The ... | python | def mg_refractive(m, mix):
"""Maxwell-Garnett EMA for the refractive index.
Args:
m: Tuple of the complex refractive indices of the media.
mix: Tuple of the volume fractions of the media, len(mix)==len(m)
(if sum(mix)!=1, these are taken relative to sum(mix))
Returns:
The ... | [
"def",
"mg_refractive",
"(",
"m",
",",
"mix",
")",
":",
"if",
"len",
"(",
"m",
")",
"==",
"2",
":",
"cF",
"=",
"float",
"(",
"mix",
"[",
"1",
"]",
")",
"/",
"(",
"mix",
"[",
"0",
"]",
"+",
"mix",
"[",
"1",
"]",
")",
"*",
"(",
"m",
"[",
... | Maxwell-Garnett EMA for the refractive index.
Args:
m: Tuple of the complex refractive indices of the media.
mix: Tuple of the volume fractions of the media, len(mix)==len(m)
(if sum(mix)!=1, these are taken relative to sum(mix))
Returns:
The Maxwell-Garnett approximation for ... | [
"Maxwell",
"-",
"Garnett",
"EMA",
"for",
"the",
"refractive",
"index",
"."
] | train | https://github.com/jleinonen/pytmatrix/blob/8803507fe5332786feab105fa74acf63e7121718/pytmatrix/refractive.py#L29-L57 |
jleinonen/pytmatrix | pytmatrix/refractive.py | bruggeman_refractive | def bruggeman_refractive(m, mix):
"""Bruggeman EMA for the refractive index.
For instructions, see mg_refractive in this module, except this routine
only works for two components.
"""
f1 = mix[0]/sum(mix)
f2 = mix[1]/sum(mix)
e1 = m[0]**2
e2 = m[1]**2
a = -2*(f1+f2)
b = (2*f1*e1... | python | def bruggeman_refractive(m, mix):
"""Bruggeman EMA for the refractive index.
For instructions, see mg_refractive in this module, except this routine
only works for two components.
"""
f1 = mix[0]/sum(mix)
f2 = mix[1]/sum(mix)
e1 = m[0]**2
e2 = m[1]**2
a = -2*(f1+f2)
b = (2*f1*e1... | [
"def",
"bruggeman_refractive",
"(",
"m",
",",
"mix",
")",
":",
"f1",
"=",
"mix",
"[",
"0",
"]",
"/",
"sum",
"(",
"mix",
")",
"f2",
"=",
"mix",
"[",
"1",
"]",
"/",
"sum",
"(",
"mix",
")",
"e1",
"=",
"m",
"[",
"0",
"]",
"**",
"2",
"e2",
"="... | Bruggeman EMA for the refractive index.
For instructions, see mg_refractive in this module, except this routine
only works for two components. | [
"Bruggeman",
"EMA",
"for",
"the",
"refractive",
"index",
"."
] | train | https://github.com/jleinonen/pytmatrix/blob/8803507fe5332786feab105fa74acf63e7121718/pytmatrix/refractive.py#L60-L74 |
jleinonen/pytmatrix | pytmatrix/refractive.py | ice_refractive | def ice_refractive(file):
"""
Interpolator for the refractive indices of ice.
Inputs:
File to read the refractive index lookup table from.
This is supplied as "ice_refr.dat", retrieved from
http://www.atmos.washington.edu/ice_optical_constants/
Returns:
A callable object th... | python | def ice_refractive(file):
"""
Interpolator for the refractive indices of ice.
Inputs:
File to read the refractive index lookup table from.
This is supplied as "ice_refr.dat", retrieved from
http://www.atmos.washington.edu/ice_optical_constants/
Returns:
A callable object th... | [
"def",
"ice_refractive",
"(",
"file",
")",
":",
"D",
"=",
"np",
".",
"loadtxt",
"(",
"file",
")",
"log_wl",
"=",
"np",
".",
"log10",
"(",
"D",
"[",
":",
",",
"0",
"]",
"/",
"1000",
")",
"re",
"=",
"D",
"[",
":",
",",
"1",
"]",
"log_im",
"="... | Interpolator for the refractive indices of ice.
Inputs:
File to read the refractive index lookup table from.
This is supplied as "ice_refr.dat", retrieved from
http://www.atmos.washington.edu/ice_optical_constants/
Returns:
A callable object that takes as parameters the wavelength ... | [
"Interpolator",
"for",
"the",
"refractive",
"indices",
"of",
"ice",
"."
] | train | https://github.com/jleinonen/pytmatrix/blob/8803507fe5332786feab105fa74acf63e7121718/pytmatrix/refractive.py#L107-L142 |
jleinonen/pytmatrix | pytmatrix/tmatrix_aux.py | dsr_thurai_2007 | def dsr_thurai_2007(D_eq):
"""
Drop shape relationship function from Thurai2007
(http://dx.doi.org/10.1175/JTECH2051.1) paper.
Arguments:
D_eq: Drop volume-equivalent diameter (mm)
Returns:
r: The vertical-to-horizontal drop axis ratio. Note: the Scatterer class
expects hori... | python | def dsr_thurai_2007(D_eq):
"""
Drop shape relationship function from Thurai2007
(http://dx.doi.org/10.1175/JTECH2051.1) paper.
Arguments:
D_eq: Drop volume-equivalent diameter (mm)
Returns:
r: The vertical-to-horizontal drop axis ratio. Note: the Scatterer class
expects hori... | [
"def",
"dsr_thurai_2007",
"(",
"D_eq",
")",
":",
"if",
"D_eq",
"<",
"0.7",
":",
"return",
"1.0",
"elif",
"D_eq",
"<",
"1.5",
":",
"return",
"1.173",
"-",
"0.5165",
"*",
"D_eq",
"+",
"0.4698",
"*",
"D_eq",
"**",
"2",
"-",
"0.1317",
"*",
"D_eq",
"**"... | Drop shape relationship function from Thurai2007
(http://dx.doi.org/10.1175/JTECH2051.1) paper.
Arguments:
D_eq: Drop volume-equivalent diameter (mm)
Returns:
r: The vertical-to-horizontal drop axis ratio. Note: the Scatterer class
expects horizontal to vertical, so you should pass ... | [
"Drop",
"shape",
"relationship",
"function",
"from",
"Thurai2007",
"(",
"http",
":",
"//",
"dx",
".",
"doi",
".",
"org",
"/",
"10",
".",
"1175",
"/",
"JTECH2051",
".",
"1",
")",
"paper",
".",
"Arguments",
":",
"D_eq",
":",
"Drop",
"volume",
"-",
"equ... | train | https://github.com/jleinonen/pytmatrix/blob/8803507fe5332786feab105fa74acf63e7121718/pytmatrix/tmatrix_aux.py#L47-L66 |
edublancas/sklearn-evaluation | sklearn_evaluation/compute.py | feature_importances | def feature_importances(data, top_n=None, feature_names=None):
"""
Get and order feature importances from a scikit-learn model
or from an array-like structure.
If data is a scikit-learn model with sub-estimators (e.g. RandomForest,
AdaBoost) the function will compute the standard deviation of each
... | python | def feature_importances(data, top_n=None, feature_names=None):
"""
Get and order feature importances from a scikit-learn model
or from an array-like structure.
If data is a scikit-learn model with sub-estimators (e.g. RandomForest,
AdaBoost) the function will compute the standard deviation of each
... | [
"def",
"feature_importances",
"(",
"data",
",",
"top_n",
"=",
"None",
",",
"feature_names",
"=",
"None",
")",
":",
"# data can be either a sklearn estimator or an iterator with",
"# the actual importances values, try to get the values",
"try",
":",
"imp",
"=",
"data",
".",
... | Get and order feature importances from a scikit-learn model
or from an array-like structure.
If data is a scikit-learn model with sub-estimators (e.g. RandomForest,
AdaBoost) the function will compute the standard deviation of each
feature.
Parameters
----------
data : sklearn model or arr... | [
"Get",
"and",
"order",
"feature",
"importances",
"from",
"a",
"scikit",
"-",
"learn",
"model",
"or",
"from",
"an",
"array",
"-",
"like",
"structure",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/compute.py#L4-L89 |
edublancas/sklearn-evaluation | sklearn_evaluation/util.py | _group_by | def _group_by(data, criteria):
"""
Group objects in data using a function or a key
"""
if isinstance(criteria, str):
criteria_str = criteria
def criteria(x):
return x[criteria_str]
res = defaultdict(list)
for element in data:
key = criteria(element)
... | python | def _group_by(data, criteria):
"""
Group objects in data using a function or a key
"""
if isinstance(criteria, str):
criteria_str = criteria
def criteria(x):
return x[criteria_str]
res = defaultdict(list)
for element in data:
key = criteria(element)
... | [
"def",
"_group_by",
"(",
"data",
",",
"criteria",
")",
":",
"if",
"isinstance",
"(",
"criteria",
",",
"str",
")",
":",
"criteria_str",
"=",
"criteria",
"def",
"criteria",
"(",
"x",
")",
":",
"return",
"x",
"[",
"criteria_str",
"]",
"res",
"=",
"default... | Group objects in data using a function or a key | [
"Group",
"objects",
"in",
"data",
"using",
"a",
"function",
"or",
"a",
"key"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/util.py#L37-L51 |
edublancas/sklearn-evaluation | sklearn_evaluation/util.py | _get_params_value | def _get_params_value(params):
"""
Given an iterator (k1, k2), returns a function that when called
with an object obj returns a tuple of the form:
((k1, obj.parameters[k1]), (k2, obj.parameters[k2]))
"""
# sort params for consistency
ord_params = sorted(params)
def fn(obj):
... | python | def _get_params_value(params):
"""
Given an iterator (k1, k2), returns a function that when called
with an object obj returns a tuple of the form:
((k1, obj.parameters[k1]), (k2, obj.parameters[k2]))
"""
# sort params for consistency
ord_params = sorted(params)
def fn(obj):
... | [
"def",
"_get_params_value",
"(",
"params",
")",
":",
"# sort params for consistency",
"ord_params",
"=",
"sorted",
"(",
"params",
")",
"def",
"fn",
"(",
"obj",
")",
":",
"l",
"=",
"[",
"]",
"for",
"p",
"in",
"ord_params",
":",
"try",
":",
"l",
".",
"ap... | Given an iterator (k1, k2), returns a function that when called
with an object obj returns a tuple of the form:
((k1, obj.parameters[k1]), (k2, obj.parameters[k2])) | [
"Given",
"an",
"iterator",
"(",
"k1",
"k2",
")",
"returns",
"a",
"function",
"that",
"when",
"called",
"with",
"an",
"object",
"obj",
"returns",
"a",
"tuple",
"of",
"the",
"form",
":",
"((",
"k1",
"obj",
".",
"parameters",
"[",
"k1",
"]",
")",
"(",
... | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/util.py#L54-L71 |
edublancas/sklearn-evaluation | sklearn_evaluation/util.py | _product | def _product(k, v):
"""
Perform the product between two objects
even if they don't support iteration
"""
if not _can_iterate(k):
k = [k]
if not _can_iterate(v):
v = [v]
return list(product(k, v)) | python | def _product(k, v):
"""
Perform the product between two objects
even if they don't support iteration
"""
if not _can_iterate(k):
k = [k]
if not _can_iterate(v):
v = [v]
return list(product(k, v)) | [
"def",
"_product",
"(",
"k",
",",
"v",
")",
":",
"if",
"not",
"_can_iterate",
"(",
"k",
")",
":",
"k",
"=",
"[",
"k",
"]",
"if",
"not",
"_can_iterate",
"(",
"v",
")",
":",
"v",
"=",
"[",
"v",
"]",
"return",
"list",
"(",
"product",
"(",
"k",
... | Perform the product between two objects
even if they don't support iteration | [
"Perform",
"the",
"product",
"between",
"two",
"objects",
"even",
"if",
"they",
"don",
"t",
"support",
"iteration"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/util.py#L80-L89 |
edublancas/sklearn-evaluation | sklearn_evaluation/util.py | _mapping_to_tuple_pairs | def _mapping_to_tuple_pairs(d):
"""
Convert a mapping object (such as a dictionary) to tuple pairs,
using its keys and values to generate the pairs and then generating
all possible combinations between those
e.g. {1: (1,2,3)} -> (((1, 1),), ((1, 2),), ((1, 3),))
"""
# order t... | python | def _mapping_to_tuple_pairs(d):
"""
Convert a mapping object (such as a dictionary) to tuple pairs,
using its keys and values to generate the pairs and then generating
all possible combinations between those
e.g. {1: (1,2,3)} -> (((1, 1),), ((1, 2),), ((1, 3),))
"""
# order t... | [
"def",
"_mapping_to_tuple_pairs",
"(",
"d",
")",
":",
"# order the keys, this will prevent different implementations of Python,",
"# return different results from the same dictionary since the order of",
"# iteration depends on it",
"t",
"=",
"[",
"]",
"ord_keys",
"=",
"sorted",
"(",... | Convert a mapping object (such as a dictionary) to tuple pairs,
using its keys and values to generate the pairs and then generating
all possible combinations between those
e.g. {1: (1,2,3)} -> (((1, 1),), ((1, 2),), ((1, 3),)) | [
"Convert",
"a",
"mapping",
"object",
"(",
"such",
"as",
"a",
"dictionary",
")",
"to",
"tuple",
"pairs",
"using",
"its",
"keys",
"and",
"values",
"to",
"generate",
"the",
"pairs",
"and",
"then",
"generating",
"all",
"possible",
"combinations",
"between",
"tho... | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/util.py#L92-L106 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/learning_curve.py | learning_curve | def learning_curve(train_scores, test_scores, train_sizes, ax=None):
"""Plot a learning curve
Plot a metric vs number of examples for the training and test set
Parameters
----------
train_scores : array-like
Scores for the training set
test_scores : array-like
Scores for the te... | python | def learning_curve(train_scores, test_scores, train_sizes, ax=None):
"""Plot a learning curve
Plot a metric vs number of examples for the training and test set
Parameters
----------
train_scores : array-like
Scores for the training set
test_scores : array-like
Scores for the te... | [
"def",
"learning_curve",
"(",
"train_scores",
",",
"test_scores",
",",
"train_sizes",
",",
"ax",
"=",
"None",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
"ax",
".",
"grid",
"(",
")",
"ax",
".",
"set_title",
"(",... | Plot a learning curve
Plot a metric vs number of examples for the training and test set
Parameters
----------
train_scores : array-like
Scores for the training set
test_scores : array-like
Scores for the test set
train_sizes : array-like
Relative or absolute numbers of ... | [
"Plot",
"a",
"learning",
"curve"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/learning_curve.py#L5-L59 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/precision_recall.py | precision_recall | def precision_recall(y_true, y_score, ax=None):
"""
Plot precision-recall curve.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples] or [n_samples, 2] for binary
classification or [n... | python | def precision_recall(y_true, y_score, ax=None):
"""
Plot precision-recall curve.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples] or [n_samples, 2] for binary
classification or [n... | [
"def",
"precision_recall",
"(",
"y_true",
",",
"y_score",
",",
"ax",
"=",
"None",
")",
":",
"if",
"any",
"(",
"(",
"val",
"is",
"None",
"for",
"val",
"in",
"(",
"y_true",
",",
"y_score",
")",
")",
")",
":",
"raise",
"ValueError",
"(",
"'y_true and y_... | Plot precision-recall curve.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples] or [n_samples, 2] for binary
classification or [n_samples, n_classes] for multiclass
Target scores (... | [
"Plot",
"precision",
"-",
"recall",
"curve",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/precision_recall.py#L9-L70 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/precision_recall.py | _precision_recall | def _precision_recall(y_true, y_score, ax=None):
"""
Plot precision-recall curve.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples]
Target scores (estimator predictions).
ax : matplo... | python | def _precision_recall(y_true, y_score, ax=None):
"""
Plot precision-recall curve.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples]
Target scores (estimator predictions).
ax : matplo... | [
"def",
"_precision_recall",
"(",
"y_true",
",",
"y_score",
",",
"ax",
"=",
"None",
")",
":",
"precision",
",",
"recall",
",",
"_",
"=",
"precision_recall_curve",
"(",
"y_true",
",",
"y_score",
")",
"average_precision",
"=",
"average_precision_score",
"(",
"y_t... | Plot precision-recall curve.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples]
Target scores (estimator predictions).
ax : matplotlib Axes
Axes object to draw the plot onto, otherwis... | [
"Plot",
"precision",
"-",
"recall",
"curve",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/precision_recall.py#L73-L101 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/precision_recall.py | _precision_recall_multi | def _precision_recall_multi(y_true, y_score, ax=None):
"""
Plot precision-recall curve.
Parameters
----------
y_true : array-like, shape = [n_samples, n_classes]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples, n_classes]
Target scores (estimator p... | python | def _precision_recall_multi(y_true, y_score, ax=None):
"""
Plot precision-recall curve.
Parameters
----------
y_true : array-like, shape = [n_samples, n_classes]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples, n_classes]
Target scores (estimator p... | [
"def",
"_precision_recall_multi",
"(",
"y_true",
",",
"y_score",
",",
"ax",
"=",
"None",
")",
":",
"# Compute micro-average ROC curve and ROC area",
"precision",
",",
"recall",
",",
"_",
"=",
"precision_recall_curve",
"(",
"y_true",
".",
"ravel",
"(",
")",
",",
... | Plot precision-recall curve.
Parameters
----------
y_true : array-like, shape = [n_samples, n_classes]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples, n_classes]
Target scores (estimator predictions).
ax : matplotlib Axes
Axes object to draw t... | [
"Plot",
"precision",
"-",
"recall",
"curve",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/precision_recall.py#L104-L136 |
edublancas/sklearn-evaluation | sklearn_evaluation/metrics.py | precision_at | def precision_at(y_true, y_score, proportion, ignore_nas=False):
'''
Calculates precision at a given proportion.
Only supports binary classification.
'''
# Sort scores in descending order
scores_sorted = np.sort(y_score)[::-1]
# Based on the proportion, get the index to split the data
#... | python | def precision_at(y_true, y_score, proportion, ignore_nas=False):
'''
Calculates precision at a given proportion.
Only supports binary classification.
'''
# Sort scores in descending order
scores_sorted = np.sort(y_score)[::-1]
# Based on the proportion, get the index to split the data
#... | [
"def",
"precision_at",
"(",
"y_true",
",",
"y_score",
",",
"proportion",
",",
"ignore_nas",
"=",
"False",
")",
":",
"# Sort scores in descending order",
"scores_sorted",
"=",
"np",
".",
"sort",
"(",
"y_score",
")",
"[",
":",
":",
"-",
"1",
"]",
"# Based on t... | Calculates precision at a given proportion.
Only supports binary classification. | [
"Calculates",
"precision",
"at",
"a",
"given",
"proportion",
".",
"Only",
"supports",
"binary",
"classification",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/metrics.py#L7-L29 |
edublancas/sklearn-evaluation | sklearn_evaluation/metrics.py | __precision | def __precision(y_true, y_pred):
'''
Precision metric tolerant to unlabeled data in y_true,
NA values are ignored for the precision calculation
'''
# make copies of the arrays to avoid modifying the original ones
y_true = np.copy(y_true)
y_pred = np.copy(y_pred)
# precision = tp... | python | def __precision(y_true, y_pred):
'''
Precision metric tolerant to unlabeled data in y_true,
NA values are ignored for the precision calculation
'''
# make copies of the arrays to avoid modifying the original ones
y_true = np.copy(y_true)
y_pred = np.copy(y_pred)
# precision = tp... | [
"def",
"__precision",
"(",
"y_true",
",",
"y_pred",
")",
":",
"# make copies of the arrays to avoid modifying the original ones",
"y_true",
"=",
"np",
".",
"copy",
"(",
"y_true",
")",
"y_pred",
"=",
"np",
".",
"copy",
"(",
"y_pred",
")",
"# precision = tp/(tp+fp)",
... | Precision metric tolerant to unlabeled data in y_true,
NA values are ignored for the precision calculation | [
"Precision",
"metric",
"tolerant",
"to",
"unlabeled",
"data",
"in",
"y_true",
"NA",
"values",
"are",
"ignored",
"for",
"the",
"precision",
"calculation"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/metrics.py#L51-L68 |
edublancas/sklearn-evaluation | sklearn_evaluation/metrics.py | labels_at | def labels_at(y_true, y_score, proportion, normalize=False):
'''
Return the number of labels encountered in the top X proportion
'''
# Get indexes of scores sorted in descending order
indexes = np.argsort(y_score)[::-1]
# Sort true values in the same order
y_true_sorted = y_true[indexe... | python | def labels_at(y_true, y_score, proportion, normalize=False):
'''
Return the number of labels encountered in the top X proportion
'''
# Get indexes of scores sorted in descending order
indexes = np.argsort(y_score)[::-1]
# Sort true values in the same order
y_true_sorted = y_true[indexe... | [
"def",
"labels_at",
"(",
"y_true",
",",
"y_score",
",",
"proportion",
",",
"normalize",
"=",
"False",
")",
":",
"# Get indexes of scores sorted in descending order",
"indexes",
"=",
"np",
".",
"argsort",
"(",
"y_score",
")",
"[",
":",
":",
"-",
"1",
"]",
"# ... | Return the number of labels encountered in the top X proportion | [
"Return",
"the",
"number",
"of",
"labels",
"encountered",
"in",
"the",
"top",
"X",
"proportion"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/metrics.py#L100-L122 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/validation_curve.py | validation_curve | def validation_curve(train_scores, test_scores, param_range, param_name=None,
semilogx=False, ax=None):
"""Plot a validation curve
Plot a metric vs hyperpameter values for the training and test set
Parameters
----------
train_scores : array-like
Scores for the training... | python | def validation_curve(train_scores, test_scores, param_range, param_name=None,
semilogx=False, ax=None):
"""Plot a validation curve
Plot a metric vs hyperpameter values for the training and test set
Parameters
----------
train_scores : array-like
Scores for the training... | [
"def",
"validation_curve",
"(",
"train_scores",
",",
"test_scores",
",",
"param_range",
",",
"param_name",
"=",
"None",
",",
"semilogx",
"=",
"False",
",",
"ax",
"=",
"None",
")",
":",
"if",
"ax",
"is",
"None",
":",
"ax",
"=",
"plt",
".",
"gca",
"(",
... | Plot a validation curve
Plot a metric vs hyperpameter values for the training and test set
Parameters
----------
train_scores : array-like
Scores for the training set
test_scores : array-like
Scores for the test set
param_range : array-like
Hyperparameter values used to... | [
"Plot",
"a",
"validation",
"curve"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/validation_curve.py#L5-L66 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/classification.py | confusion_matrix | def confusion_matrix(y_true, y_pred, target_names=None, normalize=False,
cmap=None, ax=None):
"""
Plot confustion matrix.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_pred : array-like, shape = [n_samples]
... | python | def confusion_matrix(y_true, y_pred, target_names=None, normalize=False,
cmap=None, ax=None):
"""
Plot confustion matrix.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_pred : array-like, shape = [n_samples]
... | [
"def",
"confusion_matrix",
"(",
"y_true",
",",
"y_pred",
",",
"target_names",
"=",
"None",
",",
"normalize",
"=",
"False",
",",
"cmap",
"=",
"None",
",",
"ax",
"=",
"None",
")",
":",
"if",
"any",
"(",
"(",
"val",
"is",
"None",
"for",
"val",
"in",
"... | Plot confustion matrix.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_pred : array-like, shape = [n_samples]
Target predicted classes (estimator predictions).
target_names : list
List containing the names of the target... | [
"Plot",
"confustion",
"matrix",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/classification.py#L13-L105 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/classification.py | feature_importances | def feature_importances(data, top_n=None, feature_names=None, ax=None):
"""
Get and order feature importances from a scikit-learn model
or from an array-like structure. If data is a scikit-learn model with
sub-estimators (e.g. RandomForest, AdaBoost) the function will compute the
standard deviation ... | python | def feature_importances(data, top_n=None, feature_names=None, ax=None):
"""
Get and order feature importances from a scikit-learn model
or from an array-like structure. If data is a scikit-learn model with
sub-estimators (e.g. RandomForest, AdaBoost) the function will compute the
standard deviation ... | [
"def",
"feature_importances",
"(",
"data",
",",
"top_n",
"=",
"None",
",",
"feature_names",
"=",
"None",
",",
"ax",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'data is needed to plot feature importances. '",
"'When plott... | Get and order feature importances from a scikit-learn model
or from an array-like structure. If data is a scikit-learn model with
sub-estimators (e.g. RandomForest, AdaBoost) the function will compute the
standard deviation of each feature.
Parameters
----------
data : sklearn model or array-li... | [
"Get",
"and",
"order",
"feature",
"importances",
"from",
"a",
"scikit",
"-",
"learn",
"model",
"or",
"from",
"an",
"array",
"-",
"like",
"structure",
".",
"If",
"data",
"is",
"a",
"scikit",
"-",
"learn",
"model",
"with",
"sub",
"-",
"estimators",
"(",
... | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/classification.py#L113-L166 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/classification.py | precision_at_proportions | def precision_at_proportions(y_true, y_score, ax=None):
"""
Plot precision values at different proportions.
Parameters
----------
y_true : array-like
Correct target values (ground truth).
y_score : array-like
Target scores (estimator predictions).
ax : matplotlib Axes
... | python | def precision_at_proportions(y_true, y_score, ax=None):
"""
Plot precision values at different proportions.
Parameters
----------
y_true : array-like
Correct target values (ground truth).
y_score : array-like
Target scores (estimator predictions).
ax : matplotlib Axes
... | [
"def",
"precision_at_proportions",
"(",
"y_true",
",",
"y_score",
",",
"ax",
"=",
"None",
")",
":",
"if",
"any",
"(",
"(",
"val",
"is",
"None",
"for",
"val",
"in",
"(",
"y_true",
",",
"y_score",
")",
")",
")",
":",
"raise",
"ValueError",
"(",
"'y_tru... | Plot precision values at different proportions.
Parameters
----------
y_true : array-like
Correct target values (ground truth).
y_score : array-like
Target scores (estimator predictions).
ax : matplotlib Axes
Axes object to draw the plot onto, otherwise uses current Axes
... | [
"Plot",
"precision",
"values",
"at",
"different",
"proportions",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/classification.py#L169-L216 |
edublancas/sklearn-evaluation | sklearn_evaluation/table.py | feature_importances | def feature_importances(data, top_n=None, feature_names=None):
"""
Get and order feature importances from a scikit-learn model
or from an array-like structure.
If data is a scikit-learn model with sub-estimators (e.g. RandomForest,
AdaBoost) the function will compute the standard deviation of each
... | python | def feature_importances(data, top_n=None, feature_names=None):
"""
Get and order feature importances from a scikit-learn model
or from an array-like structure.
If data is a scikit-learn model with sub-estimators (e.g. RandomForest,
AdaBoost) the function will compute the standard deviation of each
... | [
"def",
"feature_importances",
"(",
"data",
",",
"top_n",
"=",
"None",
",",
"feature_names",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'data is needed to tabulate feature importances. '",
"'When plotting using the evaluator you ... | Get and order feature importances from a scikit-learn model
or from an array-like structure.
If data is a scikit-learn model with sub-estimators (e.g. RandomForest,
AdaBoost) the function will compute the standard deviation of each
feature.
Parameters
----------
data : sklearn model or arr... | [
"Get",
"and",
"order",
"feature",
"importances",
"from",
"a",
"scikit",
"-",
"learn",
"model",
"or",
"from",
"an",
"array",
"-",
"like",
"structure",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/table.py#L30-L62 |
edublancas/sklearn-evaluation | docs/sphinxext/ipython_sphinxext/ipython_directive.py | block_parser | def block_parser(part, rgxin, rgxout, fmtin, fmtout):
"""
part is a string of ipython text, comprised of at most one
input, one output, comments, and blank lines. The block parser
parses the text into a list of::
blocks = [ (TOKEN0, data0), (TOKEN1, data1), ...]
where TOKEN is one of [COMME... | python | def block_parser(part, rgxin, rgxout, fmtin, fmtout):
"""
part is a string of ipython text, comprised of at most one
input, one output, comments, and blank lines. The block parser
parses the text into a list of::
blocks = [ (TOKEN0, data0), (TOKEN1, data1), ...]
where TOKEN is one of [COMME... | [
"def",
"block_parser",
"(",
"part",
",",
"rgxin",
",",
"rgxout",
",",
"fmtin",
",",
"fmtout",
")",
":",
"block",
"=",
"[",
"]",
"lines",
"=",
"part",
".",
"split",
"(",
"'\\n'",
")",
"N",
"=",
"len",
"(",
"lines",
")",
"i",
"=",
"0",
"decorator",... | part is a string of ipython text, comprised of at most one
input, one output, comments, and blank lines. The block parser
parses the text into a list of::
blocks = [ (TOKEN0, data0), (TOKEN1, data1), ...]
where TOKEN is one of [COMMENT | INPUT | OUTPUT ] and
data is, depending on the type of to... | [
"part",
"is",
"a",
"string",
"of",
"ipython",
"text",
"comprised",
"of",
"at",
"most",
"one",
"input",
"one",
"output",
"comments",
"and",
"blank",
"lines",
".",
"The",
"block",
"parser",
"parses",
"the",
"text",
"into",
"a",
"list",
"of",
"::"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/docs/sphinxext/ipython_sphinxext/ipython_directive.py#L165-L266 |
edublancas/sklearn-evaluation | docs/sphinxext/ipython_sphinxext/ipython_directive.py | EmbeddedSphinxShell.process_block | def process_block(self, block):
"""
process block from the block_parser and return a list of processed lines
"""
ret = []
output = None
input_lines = None
lineno = self.IP.execution_count
input_prompt = self.promptin % lineno
output_prompt = self.... | python | def process_block(self, block):
"""
process block from the block_parser and return a list of processed lines
"""
ret = []
output = None
input_lines = None
lineno = self.IP.execution_count
input_prompt = self.promptin % lineno
output_prompt = self.... | [
"def",
"process_block",
"(",
"self",
",",
"block",
")",
":",
"ret",
"=",
"[",
"]",
"output",
"=",
"None",
"input_lines",
"=",
"None",
"lineno",
"=",
"self",
".",
"IP",
".",
"execution_count",
"input_prompt",
"=",
"self",
".",
"promptin",
"%",
"lineno",
... | process block from the block_parser and return a list of processed lines | [
"process",
"block",
"from",
"the",
"block_parser",
"and",
"return",
"a",
"list",
"of",
"processed",
"lines"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/docs/sphinxext/ipython_sphinxext/ipython_directive.py#L640-L708 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/grid_search.py | grid_search | def grid_search(grid_scores, change, subset=None, kind='line', cmap=None,
ax=None):
"""
Plot results from a sklearn grid search by changing two parameters at most.
Parameters
----------
grid_scores : list of named tuples
Results from a sklearn grid search (get them using the... | python | def grid_search(grid_scores, change, subset=None, kind='line', cmap=None,
ax=None):
"""
Plot results from a sklearn grid search by changing two parameters at most.
Parameters
----------
grid_scores : list of named tuples
Results from a sklearn grid search (get them using the... | [
"def",
"grid_search",
"(",
"grid_scores",
",",
"change",
",",
"subset",
"=",
"None",
",",
"kind",
"=",
"'line'",
",",
"cmap",
"=",
"None",
",",
"ax",
"=",
"None",
")",
":",
"if",
"change",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"(",
"'change ... | Plot results from a sklearn grid search by changing two parameters at most.
Parameters
----------
grid_scores : list of named tuples
Results from a sklearn grid search (get them using the
`grid_scores_` parameter)
change : str or iterable with len<=2
Parameter to change
subs... | [
"Plot",
"results",
"from",
"a",
"sklearn",
"grid",
"search",
"by",
"changing",
"two",
"parameters",
"at",
"most",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/grid_search.py#L12-L64 |
edublancas/sklearn-evaluation | sklearn_evaluation/evaluator.py | ClassifierEvaluator.confusion_matrix | def confusion_matrix(self):
"""Confusion matrix plot
"""
return plot.confusion_matrix(self.y_true, self.y_pred,
self.target_names, ax=_gen_ax()) | python | def confusion_matrix(self):
"""Confusion matrix plot
"""
return plot.confusion_matrix(self.y_true, self.y_pred,
self.target_names, ax=_gen_ax()) | [
"def",
"confusion_matrix",
"(",
"self",
")",
":",
"return",
"plot",
".",
"confusion_matrix",
"(",
"self",
".",
"y_true",
",",
"self",
".",
"y_pred",
",",
"self",
".",
"target_names",
",",
"ax",
"=",
"_gen_ax",
"(",
")",
")"
] | Confusion matrix plot | [
"Confusion",
"matrix",
"plot"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/evaluator.py#L85-L89 |
edublancas/sklearn-evaluation | sklearn_evaluation/evaluator.py | ClassifierEvaluator.roc | def roc(self):
"""ROC plot
"""
return plot.roc(self.y_true, self.y_score, ax=_gen_ax()) | python | def roc(self):
"""ROC plot
"""
return plot.roc(self.y_true, self.y_score, ax=_gen_ax()) | [
"def",
"roc",
"(",
"self",
")",
":",
"return",
"plot",
".",
"roc",
"(",
"self",
".",
"y_true",
",",
"self",
".",
"y_score",
",",
"ax",
"=",
"_gen_ax",
"(",
")",
")"
] | ROC plot | [
"ROC",
"plot"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/evaluator.py#L92-L95 |
edublancas/sklearn-evaluation | sklearn_evaluation/evaluator.py | ClassifierEvaluator.precision_recall | def precision_recall(self):
"""Precision-recall plot
"""
return plot.precision_recall(self.y_true, self.y_score, ax=_gen_ax()) | python | def precision_recall(self):
"""Precision-recall plot
"""
return plot.precision_recall(self.y_true, self.y_score, ax=_gen_ax()) | [
"def",
"precision_recall",
"(",
"self",
")",
":",
"return",
"plot",
".",
"precision_recall",
"(",
"self",
".",
"y_true",
",",
"self",
".",
"y_score",
",",
"ax",
"=",
"_gen_ax",
"(",
")",
")"
] | Precision-recall plot | [
"Precision",
"-",
"recall",
"plot"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/evaluator.py#L98-L101 |
edublancas/sklearn-evaluation | sklearn_evaluation/evaluator.py | ClassifierEvaluator.feature_importances | def feature_importances(self):
"""Feature importances plot
"""
return plot.feature_importances(self.estimator,
feature_names=self.feature_names,
ax=_gen_ax()) | python | def feature_importances(self):
"""Feature importances plot
"""
return plot.feature_importances(self.estimator,
feature_names=self.feature_names,
ax=_gen_ax()) | [
"def",
"feature_importances",
"(",
"self",
")",
":",
"return",
"plot",
".",
"feature_importances",
"(",
"self",
".",
"estimator",
",",
"feature_names",
"=",
"self",
".",
"feature_names",
",",
"ax",
"=",
"_gen_ax",
"(",
")",
")"
] | Feature importances plot | [
"Feature",
"importances",
"plot"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/evaluator.py#L104-L109 |
edublancas/sklearn-evaluation | sklearn_evaluation/evaluator.py | ClassifierEvaluator.feature_importances_table | def feature_importances_table(self):
"""Feature importances table
"""
from . import table
return table.feature_importances(self.estimator,
feature_names=self.feature_names) | python | def feature_importances_table(self):
"""Feature importances table
"""
from . import table
return table.feature_importances(self.estimator,
feature_names=self.feature_names) | [
"def",
"feature_importances_table",
"(",
"self",
")",
":",
"from",
".",
"import",
"table",
"return",
"table",
".",
"feature_importances",
"(",
"self",
".",
"estimator",
",",
"feature_names",
"=",
"self",
".",
"feature_names",
")"
] | Feature importances table | [
"Feature",
"importances",
"table"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/evaluator.py#L112-L118 |
edublancas/sklearn-evaluation | sklearn_evaluation/evaluator.py | ClassifierEvaluator.precision_at_proportions | def precision_at_proportions(self):
"""Precision at proportions plot
"""
return plot.precision_at_proportions(self.y_true, self.y_score,
ax=_gen_ax()) | python | def precision_at_proportions(self):
"""Precision at proportions plot
"""
return plot.precision_at_proportions(self.y_true, self.y_score,
ax=_gen_ax()) | [
"def",
"precision_at_proportions",
"(",
"self",
")",
":",
"return",
"plot",
".",
"precision_at_proportions",
"(",
"self",
".",
"y_true",
",",
"self",
".",
"y_score",
",",
"ax",
"=",
"_gen_ax",
"(",
")",
")"
] | Precision at proportions plot | [
"Precision",
"at",
"proportions",
"plot"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/evaluator.py#L121-L125 |
edublancas/sklearn-evaluation | sklearn_evaluation/evaluator.py | ClassifierEvaluator.generate_report | def generate_report(self, template, path=None, style=None):
"""
Generate HTML report
Parameters
----------
template : markdown-formatted string or path to the template
file used for rendering the report. Any attribute of this
object can be included in th... | python | def generate_report(self, template, path=None, style=None):
"""
Generate HTML report
Parameters
----------
template : markdown-formatted string or path to the template
file used for rendering the report. Any attribute of this
object can be included in th... | [
"def",
"generate_report",
"(",
"self",
",",
"template",
",",
"path",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"from",
".",
"report",
"import",
"generate",
"return",
"generate",
"(",
"self",
",",
"template",
",",
"path",
",",
"style",
")"
] | Generate HTML report
Parameters
----------
template : markdown-formatted string or path to the template
file used for rendering the report. Any attribute of this
object can be included in the report using the {tag} format.
e.g.'# Report{estimator_name}{roc}{p... | [
"Generate",
"HTML",
"report"
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/evaluator.py#L127-L157 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/roc.py | roc | def roc(y_true, y_score, ax=None):
"""
Plot ROC curve.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples] or [n_samples, 2] for binary
classification or [n_samples, n_classes] for m... | python | def roc(y_true, y_score, ax=None):
"""
Plot ROC curve.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples] or [n_samples, 2] for binary
classification or [n_samples, n_classes] for m... | [
"def",
"roc",
"(",
"y_true",
",",
"y_score",
",",
"ax",
"=",
"None",
")",
":",
"if",
"any",
"(",
"(",
"val",
"is",
"None",
"for",
"val",
"in",
"(",
"y_true",
",",
"y_score",
")",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"y_true and y_score are ne... | Plot ROC curve.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples] or [n_samples, 2] for binary
classification or [n_samples, n_classes] for multiclass
Target scores (estimator pre... | [
"Plot",
"ROC",
"curve",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/roc.py#L9-L69 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/roc.py | _roc | def _roc(y_true, y_score, ax=None):
"""
Plot ROC curve for binary classification.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples]
Target scores (estimator predictions).
ax: matplot... | python | def _roc(y_true, y_score, ax=None):
"""
Plot ROC curve for binary classification.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples]
Target scores (estimator predictions).
ax: matplot... | [
"def",
"_roc",
"(",
"y_true",
",",
"y_score",
",",
"ax",
"=",
"None",
")",
":",
"# check dimensions",
"fpr",
",",
"tpr",
",",
"_",
"=",
"roc_curve",
"(",
"y_true",
",",
"y_score",
")",
"roc_auc",
"=",
"auc",
"(",
"fpr",
",",
"tpr",
")",
"ax",
".",
... | Plot ROC curve for binary classification.
Parameters
----------
y_true : array-like, shape = [n_samples]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples]
Target scores (estimator predictions).
ax: matplotlib Axes
Axes object to draw the plot on... | [
"Plot",
"ROC",
"curve",
"for",
"binary",
"classification",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/roc.py#L72-L98 |
edublancas/sklearn-evaluation | sklearn_evaluation/plot/roc.py | _roc_multi | def _roc_multi(y_true, y_score, ax=None):
"""
Plot ROC curve for multi classification.
Parameters
----------
y_true : array-like, shape = [n_samples, n_classes]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples, n_classes]
Target scores (estimator pr... | python | def _roc_multi(y_true, y_score, ax=None):
"""
Plot ROC curve for multi classification.
Parameters
----------
y_true : array-like, shape = [n_samples, n_classes]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples, n_classes]
Target scores (estimator pr... | [
"def",
"_roc_multi",
"(",
"y_true",
",",
"y_score",
",",
"ax",
"=",
"None",
")",
":",
"# Compute micro-average ROC curve and ROC area",
"fpr",
",",
"tpr",
",",
"_",
"=",
"roc_curve",
"(",
"y_true",
".",
"ravel",
"(",
")",
",",
"y_score",
".",
"ravel",
"(",... | Plot ROC curve for multi classification.
Parameters
----------
y_true : array-like, shape = [n_samples, n_classes]
Correct target values (ground truth).
y_score : array-like, shape = [n_samples, n_classes]
Target scores (estimator predictions).
ax: matplotlib Axes
Axes objec... | [
"Plot",
"ROC",
"curve",
"for",
"multi",
"classification",
"."
] | train | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/roc.py#L101-L130 |
hubo1016/vlcp | vlcp/utils/redisclient.py | RedisClient.get_connection | async def get_connection(self, container):
'''
Get an exclusive connection, useful for blocked commands and transactions.
You must call release or shutdown (not recommanded) to return the connection after use.
:param container: routine container
:return... | python | async def get_connection(self, container):
'''
Get an exclusive connection, useful for blocked commands and transactions.
You must call release or shutdown (not recommanded) to return the connection after use.
:param container: routine container
:return... | [
"async",
"def",
"get_connection",
"(",
"self",
",",
"container",
")",
":",
"if",
"self",
".",
"_connpool",
":",
"conn",
"=",
"self",
".",
"_connpool",
".",
"pop",
"(",
")",
"return",
"RedisClientBase",
"(",
"conn",
",",
"self",
")",
"else",
":",
"conn"... | Get an exclusive connection, useful for blocked commands and transactions.
You must call release or shutdown (not recommanded) to return the connection after use.
:param container: routine container
:returns: RedisClientBase object, with some commands same as RedisClie... | [
"Get",
"an",
"exclusive",
"connection",
"useful",
"for",
"blocked",
"commands",
"and",
"transactions",
".",
"You",
"must",
"call",
"release",
"or",
"shutdown",
"(",
"not",
"recommanded",
")",
"to",
"return",
"the",
"connection",
"after",
"use",
".",
":",
"pa... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/redisclient.py#L257-L275 |
hubo1016/vlcp | vlcp/utils/redisclient.py | RedisClient.execute_command | async def execute_command(self, container, *args):
'''
Execute command on Redis server:
- For (P)SUBSCRIBE/(P)UNSUBSCRIBE, the command is sent to the subscribe connection.
It is recommended to use (p)subscribe/(p)unsubscribe method instead of directly call the command
- F... | python | async def execute_command(self, container, *args):
'''
Execute command on Redis server:
- For (P)SUBSCRIBE/(P)UNSUBSCRIBE, the command is sent to the subscribe connection.
It is recommended to use (p)subscribe/(p)unsubscribe method instead of directly call the command
- F... | [
"async",
"def",
"execute_command",
"(",
"self",
",",
"container",
",",
"*",
"args",
")",
":",
"if",
"args",
":",
"cmd",
"=",
"_str",
"(",
"args",
"[",
"0",
"]",
")",
".",
"upper",
"(",
")",
"if",
"cmd",
"in",
"(",
"'SUBSCRIBE'",
",",
"'UNSUBSCRIBE'... | Execute command on Redis server:
- For (P)SUBSCRIBE/(P)UNSUBSCRIBE, the command is sent to the subscribe connection.
It is recommended to use (p)subscribe/(p)unsubscribe method instead of directly call the command
- For BLPOP, BRPOP, BRPOPLPUSH, the command is sent to a separated connect... | [
"Execute",
"command",
"on",
"Redis",
"server",
":",
"-",
"For",
"(",
"P",
")",
"SUBSCRIBE",
"/",
"(",
"P",
")",
"UNSUBSCRIBE",
"the",
"command",
"is",
"sent",
"to",
"the",
"subscribe",
"connection",
".",
"It",
"is",
"recommended",
"to",
"use",
"(",
"p"... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/redisclient.py#L296-L314 |
hubo1016/vlcp | vlcp/utils/redisclient.py | RedisClient.subscribe | async def subscribe(self, container, *keys):
'''
Subscribe to specified channels
:param container: routine container
:param *keys: subscribed channels
:returns: list of event matchers for the specified channels
'''
await self._get_subscr... | python | async def subscribe(self, container, *keys):
'''
Subscribe to specified channels
:param container: routine container
:param *keys: subscribed channels
:returns: list of event matchers for the specified channels
'''
await self._get_subscr... | [
"async",
"def",
"subscribe",
"(",
"self",
",",
"container",
",",
"*",
"keys",
")",
":",
"await",
"self",
".",
"_get_subscribe_connection",
"(",
"container",
")",
"realkeys",
"=",
"[",
"]",
"for",
"k",
"in",
"keys",
":",
"count",
"=",
"self",
".",
"_sub... | Subscribe to specified channels
:param container: routine container
:param *keys: subscribed channels
:returns: list of event matchers for the specified channels | [
"Subscribe",
"to",
"specified",
"channels",
":",
"param",
"container",
":",
"routine",
"container",
":",
"param",
"*",
"keys",
":",
"subscribed",
"channels",
":",
"returns",
":",
"list",
"of",
"event",
"matchers",
"for",
"the",
"specified",
"channels"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/redisclient.py#L316-L335 |
hubo1016/vlcp | vlcp/utils/redisclient.py | RedisClient.unsubscribe | async def unsubscribe(self, container, *keys):
'''
Unsubscribe specified channels. Every subscribed key should be unsubscribed exactly once, even if duplicated subscribed.
:param container: routine container
:param \*keys: subscribed channels
'''
await s... | python | async def unsubscribe(self, container, *keys):
'''
Unsubscribe specified channels. Every subscribed key should be unsubscribed exactly once, even if duplicated subscribed.
:param container: routine container
:param \*keys: subscribed channels
'''
await s... | [
"async",
"def",
"unsubscribe",
"(",
"self",
",",
"container",
",",
"*",
"keys",
")",
":",
"await",
"self",
".",
"_get_subscribe_connection",
"(",
"container",
")",
"realkeys",
"=",
"[",
"]",
"for",
"k",
"in",
"keys",
":",
"count",
"=",
"self",
".",
"_s... | Unsubscribe specified channels. Every subscribed key should be unsubscribed exactly once, even if duplicated subscribed.
:param container: routine container
:param \*keys: subscribed channels | [
"Unsubscribe",
"specified",
"channels",
".",
"Every",
"subscribed",
"key",
"should",
"be",
"unsubscribed",
"exactly",
"once",
"even",
"if",
"duplicated",
"subscribed",
".",
":",
"param",
"container",
":",
"routine",
"container",
":",
"param",
"\\",
"*",
"keys",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/redisclient.py#L337-L358 |
hubo1016/vlcp | vlcp/utils/redisclient.py | RedisClient.psubscribe | async def psubscribe(self, container, *keys):
'''
Subscribe to specified globs
:param container: routine container
:param \*keys: subscribed globs
:returns: list of event matchers for the specified globs
'''
await self._get_subscribe_co... | python | async def psubscribe(self, container, *keys):
'''
Subscribe to specified globs
:param container: routine container
:param \*keys: subscribed globs
:returns: list of event matchers for the specified globs
'''
await self._get_subscribe_co... | [
"async",
"def",
"psubscribe",
"(",
"self",
",",
"container",
",",
"*",
"keys",
")",
":",
"await",
"self",
".",
"_get_subscribe_connection",
"(",
"container",
")",
"realkeys",
"=",
"[",
"]",
"for",
"k",
"in",
"keys",
":",
"count",
"=",
"self",
".",
"_ps... | Subscribe to specified globs
:param container: routine container
:param \*keys: subscribed globs
:returns: list of event matchers for the specified globs | [
"Subscribe",
"to",
"specified",
"globs",
":",
"param",
"container",
":",
"routine",
"container",
":",
"param",
"\\",
"*",
"keys",
":",
"subscribed",
"globs",
":",
"returns",
":",
"list",
"of",
"event",
"matchers",
"for",
"the",
"specified",
"globs"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/redisclient.py#L360-L378 |
hubo1016/vlcp | vlcp/utils/redisclient.py | RedisClient.shutdown | async def shutdown(self, container, force=False):
'''
Shutdown all connections. Exclusive connections created by get_connection will shutdown after release()
'''
p = self._connpool
self._connpool = []
self._shutdown = True
if self._defaultconn:
p.appen... | python | async def shutdown(self, container, force=False):
'''
Shutdown all connections. Exclusive connections created by get_connection will shutdown after release()
'''
p = self._connpool
self._connpool = []
self._shutdown = True
if self._defaultconn:
p.appen... | [
"async",
"def",
"shutdown",
"(",
"self",
",",
"container",
",",
"force",
"=",
"False",
")",
":",
"p",
"=",
"self",
".",
"_connpool",
"self",
".",
"_connpool",
"=",
"[",
"]",
"self",
".",
"_shutdown",
"=",
"True",
"if",
"self",
".",
"_defaultconn",
":... | Shutdown all connections. Exclusive connections created by get_connection will shutdown after release() | [
"Shutdown",
"all",
"connections",
".",
"Exclusive",
"connections",
"created",
"by",
"get_connection",
"will",
"shutdown",
"after",
"release",
"()"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/redisclient.py#L399-L413 |
hubo1016/vlcp | vlcp/utils/redisclient.py | RedisClient.subscribe_state_matcher | def subscribe_state_matcher(self, container, connected = True):
'''
Return a matcher to match the subscribe connection status.
:param container: a routine container. NOTICE: this method is not a routine.
:param connected: if True, the matcher matches connection up. If F... | python | def subscribe_state_matcher(self, container, connected = True):
'''
Return a matcher to match the subscribe connection status.
:param container: a routine container. NOTICE: this method is not a routine.
:param connected: if True, the matcher matches connection up. If F... | [
"def",
"subscribe_state_matcher",
"(",
"self",
",",
"container",
",",
"connected",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"_subscribeconn",
":",
"self",
".",
"_subscribeconn",
"=",
"self",
".",
"_create_client",
"(",
"container",
")",
"return",
"Re... | Return a matcher to match the subscribe connection status.
:param container: a routine container. NOTICE: this method is not a routine.
:param connected: if True, the matcher matches connection up. If False, the matcher matches
connection down.
:returns:... | [
"Return",
"a",
"matcher",
"to",
"match",
"the",
"subscribe",
"connection",
"status",
".",
":",
"param",
"container",
":",
"a",
"routine",
"container",
".",
"NOTICE",
":",
"this",
"method",
"is",
"not",
"a",
"routine",
".",
":",
"param",
"connected",
":",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/redisclient.py#L438-L454 |
hubo1016/vlcp | vlcp/service/connection/zookeeperdb.py | _escape_path | def _escape_path(key):
'''
Replace '/', '\\' in key
'''
return _tobytes(key).replace(b'$', b'$_').replace(b'/', b'$+').replace(b'\\', b'$$') | python | def _escape_path(key):
'''
Replace '/', '\\' in key
'''
return _tobytes(key).replace(b'$', b'$_').replace(b'/', b'$+').replace(b'\\', b'$$') | [
"def",
"_escape_path",
"(",
"key",
")",
":",
"return",
"_tobytes",
"(",
"key",
")",
".",
"replace",
"(",
"b'$'",
",",
"b'$_'",
")",
".",
"replace",
"(",
"b'/'",
",",
"b'$+'",
")",
".",
"replace",
"(",
"b'\\\\'",
",",
"b'$$'",
")"
] | Replace '/', '\\' in key | [
"Replace",
"/",
"\\\\",
"in",
"key"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/service/connection/zookeeperdb.py#L56-L60 |
hubo1016/vlcp | vlcp/utils/dhcp.py | reassemble_options | def reassemble_options(payload):
'''
Reassemble partial options to options, returns a list of dhcp_option
DHCP options are basically `|tag|length|value|` structure. When an
option is longer than 255 bytes, it can be splitted into multiple
structures with the same tag. The splitted structures mu... | python | def reassemble_options(payload):
'''
Reassemble partial options to options, returns a list of dhcp_option
DHCP options are basically `|tag|length|value|` structure. When an
option is longer than 255 bytes, it can be splitted into multiple
structures with the same tag. The splitted structures mu... | [
"def",
"reassemble_options",
"(",
"payload",
")",
":",
"options",
"=",
"[",
"]",
"option_indices",
"=",
"{",
"}",
"def",
"process_option_list",
"(",
"partials",
")",
":",
"for",
"p",
"in",
"partials",
":",
"if",
"p",
".",
"tag",
"==",
"OPTION_END",
":",
... | Reassemble partial options to options, returns a list of dhcp_option
DHCP options are basically `|tag|length|value|` structure. When an
option is longer than 255 bytes, it can be splitted into multiple
structures with the same tag. The splitted structures must be
joined back to get the original opt... | [
"Reassemble",
"partial",
"options",
"to",
"options",
"returns",
"a",
"list",
"of",
"dhcp_option",
"DHCP",
"options",
"are",
"basically",
"|tag|length|value|",
"structure",
".",
"When",
"an",
"option",
"is",
"longer",
"than",
"255",
"bytes",
"it",
"can",
"be",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/dhcp.py#L248-L289 |
hubo1016/vlcp | vlcp/utils/dhcp.py | build_options | def build_options(payload, options, maxsize = 576, overload = OVERLOAD_FILE | OVERLOAD_SNAME, allowpartial = True):
'''
Split a list of options
This is the reverse operation of `reassemble_options`, it splits `dhcp_option` into
`dhcp_option_partial` if necessary, and set overload option if field ov... | python | def build_options(payload, options, maxsize = 576, overload = OVERLOAD_FILE | OVERLOAD_SNAME, allowpartial = True):
'''
Split a list of options
This is the reverse operation of `reassemble_options`, it splits `dhcp_option` into
`dhcp_option_partial` if necessary, and set overload option if field ov... | [
"def",
"build_options",
"(",
"payload",
",",
"options",
",",
"maxsize",
"=",
"576",
",",
"overload",
"=",
"OVERLOAD_FILE",
"|",
"OVERLOAD_SNAME",
",",
"allowpartial",
"=",
"True",
")",
":",
"if",
"maxsize",
"<",
"576",
":",
"maxsize",
"=",
"576",
"max_opti... | Split a list of options
This is the reverse operation of `reassemble_options`, it splits `dhcp_option` into
`dhcp_option_partial` if necessary, and set overload option if field overloading is
used.
:param options: a list of `dhcp_option`
:param maxsize: Limit the maximum DHCP message ... | [
"Split",
"a",
"list",
"of",
"options",
"This",
"is",
"the",
"reverse",
"operation",
"of",
"reassemble_options",
"it",
"splits",
"dhcp_option",
"into",
"dhcp_option_partial",
"if",
"necessary",
"and",
"set",
"overload",
"option",
"if",
"field",
"overloading",
"is",... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/dhcp.py#L291-L424 |
hubo1016/vlcp | vlcp/utils/dhcp.py | create_option_from_value | def create_option_from_value(tag, value):
"""
Set DHCP option with human friendly value
"""
dhcp_option.parser()
fake_opt = dhcp_option(tag = tag)
for c in dhcp_option.subclasses:
if c.criteria(fake_opt):
if hasattr(c, '_parse_from_value'):
return c(tag = tag,... | python | def create_option_from_value(tag, value):
"""
Set DHCP option with human friendly value
"""
dhcp_option.parser()
fake_opt = dhcp_option(tag = tag)
for c in dhcp_option.subclasses:
if c.criteria(fake_opt):
if hasattr(c, '_parse_from_value'):
return c(tag = tag,... | [
"def",
"create_option_from_value",
"(",
"tag",
",",
"value",
")",
":",
"dhcp_option",
".",
"parser",
"(",
")",
"fake_opt",
"=",
"dhcp_option",
"(",
"tag",
"=",
"tag",
")",
"for",
"c",
"in",
"dhcp_option",
".",
"subclasses",
":",
"if",
"c",
".",
"criteria... | Set DHCP option with human friendly value | [
"Set",
"DHCP",
"option",
"with",
"human",
"friendly",
"value"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/dhcp.py#L427-L441 |
hubo1016/vlcp | vlcp/utils/dhcp.py | create_dhcp_options | def create_dhcp_options(input_dict, ignoreError = False, generateNone = False):
"""
Try best to create dhcp_options from human friendly values, ignoring
invalid values
"""
retdict = {}
for k,v in dict(input_dict).items():
try:
if generateNone and v is None:
re... | python | def create_dhcp_options(input_dict, ignoreError = False, generateNone = False):
"""
Try best to create dhcp_options from human friendly values, ignoring
invalid values
"""
retdict = {}
for k,v in dict(input_dict).items():
try:
if generateNone and v is None:
re... | [
"def",
"create_dhcp_options",
"(",
"input_dict",
",",
"ignoreError",
"=",
"False",
",",
"generateNone",
"=",
"False",
")",
":",
"retdict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"dict",
"(",
"input_dict",
")",
".",
"items",
"(",
")",
":",
"try",
... | Try best to create dhcp_options from human friendly values, ignoring
invalid values | [
"Try",
"best",
"to",
"create",
"dhcp_options",
"from",
"human",
"friendly",
"values",
"ignoring",
"invalid",
"values"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/dhcp.py#L444-L465 |
hubo1016/vlcp | vlcp/event/event.py | with_indices | def with_indices(*args):
'''
Create indices for an event class. Every event class must be decorated with this decorator.
'''
def decorator(cls):
for c in cls.__bases__:
if hasattr(c, '_indicesNames'):
cls._classnameIndex = c._classnameIndex + 1
for i i... | python | def with_indices(*args):
'''
Create indices for an event class. Every event class must be decorated with this decorator.
'''
def decorator(cls):
for c in cls.__bases__:
if hasattr(c, '_indicesNames'):
cls._classnameIndex = c._classnameIndex + 1
for i i... | [
"def",
"with_indices",
"(",
"*",
"args",
")",
":",
"def",
"decorator",
"(",
"cls",
")",
":",
"for",
"c",
"in",
"cls",
".",
"__bases__",
":",
"if",
"hasattr",
"(",
"c",
",",
"'_indicesNames'",
")",
":",
"cls",
".",
"_classnameIndex",
"=",
"c",
".",
... | Create indices for an event class. Every event class must be decorated with this decorator. | [
"Create",
"indices",
"for",
"an",
"event",
"class",
".",
"Every",
"event",
"class",
"must",
"be",
"decorated",
"with",
"this",
"decorator",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/event.py#L208-L226 |
hubo1016/vlcp | vlcp/event/event.py | Diff_.two_way_difference | def two_way_difference(self, b, extra_add = (), extra_remove = ()):
"""
Return (self - b, b - self)
"""
if self is b:
return ((), ())
if isinstance(b, DiffRef_):
extra_remove = extra_remove + b.add
b = b.origin
if extra_add == extra_rem... | python | def two_way_difference(self, b, extra_add = (), extra_remove = ()):
"""
Return (self - b, b - self)
"""
if self is b:
return ((), ())
if isinstance(b, DiffRef_):
extra_remove = extra_remove + b.add
b = b.origin
if extra_add == extra_rem... | [
"def",
"two_way_difference",
"(",
"self",
",",
"b",
",",
"extra_add",
"=",
"(",
")",
",",
"extra_remove",
"=",
"(",
")",
")",
":",
"if",
"self",
"is",
"b",
":",
"return",
"(",
"(",
")",
",",
"(",
")",
")",
"if",
"isinstance",
"(",
"b",
",",
"Di... | Return (self - b, b - self) | [
"Return",
"(",
"self",
"-",
"b",
"b",
"-",
"self",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/event.py#L166-L202 |
hubo1016/vlcp | vlcp/event/event.py | Event.getTypename | def getTypename(cls):
'''
:returns: return the proper name to match
'''
if cls is Event:
return None
else:
for c in cls.__bases__:
if issubclass(c, Event):
if c is Event:
return cls._getTypename()... | python | def getTypename(cls):
'''
:returns: return the proper name to match
'''
if cls is Event:
return None
else:
for c in cls.__bases__:
if issubclass(c, Event):
if c is Event:
return cls._getTypename()... | [
"def",
"getTypename",
"(",
"cls",
")",
":",
"if",
"cls",
"is",
"Event",
":",
"return",
"None",
"else",
":",
"for",
"c",
"in",
"cls",
".",
"__bases__",
":",
"if",
"issubclass",
"(",
"c",
",",
"Event",
")",
":",
"if",
"c",
"is",
"Event",
":",
"retu... | :returns: return the proper name to match | [
":",
"returns",
":",
"return",
"the",
"proper",
"name",
"to",
"match"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/event.py#L292-L304 |
hubo1016/vlcp | vlcp/event/event.py | Event.createMatcher | def createMatcher(cls, *args, **kwargs):
'''
:param _ismatch: user-defined function ismatch(event) for matching test
:param \*args: indices
:param \*\*kwargs: index_name=index_value for matching criteria
'''
if kwargs and not args:
return EventMatcher(tuple(ge... | python | def createMatcher(cls, *args, **kwargs):
'''
:param _ismatch: user-defined function ismatch(event) for matching test
:param \*args: indices
:param \*\*kwargs: index_name=index_value for matching criteria
'''
if kwargs and not args:
return EventMatcher(tuple(ge... | [
"def",
"createMatcher",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"and",
"not",
"args",
":",
"return",
"EventMatcher",
"(",
"tuple",
"(",
"getattr",
"(",
"cls",
",",
"ind",
")",
"if",
"ind",
"[",
":",
"10",
... | :param _ismatch: user-defined function ismatch(event) for matching test
:param \*args: indices
:param \*\*kwargs: index_name=index_value for matching criteria | [
":",
"param",
"_ismatch",
":",
"user",
"-",
"defined",
"function",
"ismatch",
"(",
"event",
")",
"for",
"matching",
"test",
":",
"param",
"\\",
"*",
"args",
":",
"indices",
":",
"param",
"\\",
"*",
"\\",
"*",
"kwargs",
":",
"index_name",
"=",
"index_va... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/event.py#L331-L340 |
hubo1016/vlcp | vlcp/event/ratelimiter.py | RateLimiter.limit | async def limit(self, use = 1):
"""
Acquire "resources", wait until enough "resources" are acquired. For each loop,
`limit` number of "resources" are permitted.
:param use: number of "resouces" to be used.
:return: True if is limited
"""
c = self... | python | async def limit(self, use = 1):
"""
Acquire "resources", wait until enough "resources" are acquired. For each loop,
`limit` number of "resources" are permitted.
:param use: number of "resouces" to be used.
:return: True if is limited
"""
c = self... | [
"async",
"def",
"limit",
"(",
"self",
",",
"use",
"=",
"1",
")",
":",
"c",
"=",
"self",
".",
"_counter",
"self",
".",
"_counter",
"=",
"c",
"+",
"use",
"if",
"self",
".",
"_task",
"is",
"None",
":",
"self",
".",
"_task",
"=",
"self",
".",
"_con... | Acquire "resources", wait until enough "resources" are acquired. For each loop,
`limit` number of "resources" are permitted.
:param use: number of "resouces" to be used.
:return: True if is limited | [
"Acquire",
"resources",
"wait",
"until",
"enough",
"resources",
"are",
"acquired",
".",
"For",
"each",
"loop",
"limit",
"number",
"of",
"resources",
"are",
"permitted",
".",
":",
"param",
"use",
":",
"number",
"of",
"resouces",
"to",
"be",
"used",
".",
":"... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/ratelimiter.py#L55-L73 |
hubo1016/vlcp | vlcp/utils/connector.py | TaskPool.run_task | async def run_task(self, container, task, newthread = False):
"Run task() in task pool. Raise an exception or return the return value"
e = TaskEvent(self, task=task, newthread = newthread)
await container.wait_for_send(e)
ev = await TaskDoneEvent.createMatcher(e)
if hasattr(ev, '... | python | async def run_task(self, container, task, newthread = False):
"Run task() in task pool. Raise an exception or return the return value"
e = TaskEvent(self, task=task, newthread = newthread)
await container.wait_for_send(e)
ev = await TaskDoneEvent.createMatcher(e)
if hasattr(ev, '... | [
"async",
"def",
"run_task",
"(",
"self",
",",
"container",
",",
"task",
",",
"newthread",
"=",
"False",
")",
":",
"e",
"=",
"TaskEvent",
"(",
"self",
",",
"task",
"=",
"task",
",",
"newthread",
"=",
"newthread",
")",
"await",
"container",
".",
"wait_fo... | Run task() in task pool. Raise an exception or return the return value | [
"Run",
"task",
"()",
"in",
"task",
"pool",
".",
"Raise",
"an",
"exception",
"or",
"return",
"the",
"return",
"value"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/connector.py#L450-L458 |
hubo1016/vlcp | vlcp/utils/connector.py | TaskPool.run_gen_task | async def run_gen_task(self, container, gentask, newthread = True):
"Run generator gentask() in task pool, yield customized events"
e = TaskEvent(self, gen_task = gentask, newthread = newthread)
await container.wait_for_send(e)
ev = await TaskDoneEvent.createMatcher(e)
if hasattr... | python | async def run_gen_task(self, container, gentask, newthread = True):
"Run generator gentask() in task pool, yield customized events"
e = TaskEvent(self, gen_task = gentask, newthread = newthread)
await container.wait_for_send(e)
ev = await TaskDoneEvent.createMatcher(e)
if hasattr... | [
"async",
"def",
"run_gen_task",
"(",
"self",
",",
"container",
",",
"gentask",
",",
"newthread",
"=",
"True",
")",
":",
"e",
"=",
"TaskEvent",
"(",
"self",
",",
"gen_task",
"=",
"gentask",
",",
"newthread",
"=",
"newthread",
")",
"await",
"container",
".... | Run generator gentask() in task pool, yield customized events | [
"Run",
"generator",
"gentask",
"()",
"in",
"task",
"pool",
"yield",
"customized",
"events"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/connector.py#L462-L470 |
hubo1016/vlcp | vlcp/utils/connector.py | TaskPool.run_async_task | async def run_async_task(self, container, asynctask, newthread = True):
"Run asynctask(sender) in task pool, call sender(events) to send customized events, return result"
e = TaskEvent(self, async_task = asynctask, newthread = newthread)
await container.wait_for_send(e)
ev = await TaskDo... | python | async def run_async_task(self, container, asynctask, newthread = True):
"Run asynctask(sender) in task pool, call sender(events) to send customized events, return result"
e = TaskEvent(self, async_task = asynctask, newthread = newthread)
await container.wait_for_send(e)
ev = await TaskDo... | [
"async",
"def",
"run_async_task",
"(",
"self",
",",
"container",
",",
"asynctask",
",",
"newthread",
"=",
"True",
")",
":",
"e",
"=",
"TaskEvent",
"(",
"self",
",",
"async_task",
"=",
"asynctask",
",",
"newthread",
"=",
"newthread",
")",
"await",
"containe... | Run asynctask(sender) in task pool, call sender(events) to send customized events, return result | [
"Run",
"asynctask",
"(",
"sender",
")",
"in",
"task",
"pool",
"call",
"sender",
"(",
"events",
")",
"to",
"send",
"customized",
"events",
"return",
"result"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/connector.py#L474-L482 |
hubo1016/vlcp | vlcp/event/lock.py | Lock.lock | async def lock(self, container = None):
"Wait for lock acquire"
if container is None:
container = RoutineContainer.get_container(self.scheduler)
if self.locked:
pass
elif self.lockroutine:
await LockedEvent.createMatcher(self)
else:
... | python | async def lock(self, container = None):
"Wait for lock acquire"
if container is None:
container = RoutineContainer.get_container(self.scheduler)
if self.locked:
pass
elif self.lockroutine:
await LockedEvent.createMatcher(self)
else:
... | [
"async",
"def",
"lock",
"(",
"self",
",",
"container",
"=",
"None",
")",
":",
"if",
"container",
"is",
"None",
":",
"container",
"=",
"RoutineContainer",
".",
"get_container",
"(",
"self",
".",
"scheduler",
")",
"if",
"self",
".",
"locked",
":",
"pass",
... | Wait for lock acquire | [
"Wait",
"for",
"lock",
"acquire"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/lock.py#L54-L64 |
hubo1016/vlcp | vlcp/event/lock.py | Lock.trylock | def trylock(self):
"Try to acquire lock and return True; if cannot acquire the lock at this moment, return False."
if self.locked:
return True
if self.lockroutine:
return False
waiter = self.scheduler.send(LockEvent(self.context, self.key, self))
if waiter... | python | def trylock(self):
"Try to acquire lock and return True; if cannot acquire the lock at this moment, return False."
if self.locked:
return True
if self.lockroutine:
return False
waiter = self.scheduler.send(LockEvent(self.context, self.key, self))
if waiter... | [
"def",
"trylock",
"(",
"self",
")",
":",
"if",
"self",
".",
"locked",
":",
"return",
"True",
"if",
"self",
".",
"lockroutine",
":",
"return",
"False",
"waiter",
"=",
"self",
".",
"scheduler",
".",
"send",
"(",
"LockEvent",
"(",
"self",
".",
"context",
... | Try to acquire lock and return True; if cannot acquire the lock at this moment, return False. | [
"Try",
"to",
"acquire",
"lock",
"and",
"return",
"True",
";",
"if",
"cannot",
"acquire",
"the",
"lock",
"at",
"this",
"moment",
"return",
"False",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/lock.py#L65-L76 |
hubo1016/vlcp | vlcp/event/lock.py | Lock.beginlock | def beginlock(self, container):
"Start to acquire lock in another routine. Call trylock or lock later to acquire the lock. Call unlock to cancel the lock routine"
if self.locked:
return True
if self.lockroutine:
return False
self.lockroutine = container.subroutine... | python | def beginlock(self, container):
"Start to acquire lock in another routine. Call trylock or lock later to acquire the lock. Call unlock to cancel the lock routine"
if self.locked:
return True
if self.lockroutine:
return False
self.lockroutine = container.subroutine... | [
"def",
"beginlock",
"(",
"self",
",",
"container",
")",
":",
"if",
"self",
".",
"locked",
":",
"return",
"True",
"if",
"self",
".",
"lockroutine",
":",
"return",
"False",
"self",
".",
"lockroutine",
"=",
"container",
".",
"subroutine",
"(",
"self",
".",
... | Start to acquire lock in another routine. Call trylock or lock later to acquire the lock. Call unlock to cancel the lock routine | [
"Start",
"to",
"acquire",
"lock",
"in",
"another",
"routine",
".",
"Call",
"trylock",
"or",
"lock",
"later",
"to",
"acquire",
"the",
"lock",
".",
"Call",
"unlock",
"to",
"cancel",
"the",
"lock",
"routine"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/lock.py#L80-L87 |
hubo1016/vlcp | vlcp/event/lock.py | Lock.unlock | def unlock(self):
"Unlock the key"
if self.lockroutine:
self.lockroutine.close()
self.lockroutine = None
if self.locked:
self.locked = False
self.scheduler.ignore(LockEvent.createMatcher(self.context, self.key, self)) | python | def unlock(self):
"Unlock the key"
if self.lockroutine:
self.lockroutine.close()
self.lockroutine = None
if self.locked:
self.locked = False
self.scheduler.ignore(LockEvent.createMatcher(self.context, self.key, self)) | [
"def",
"unlock",
"(",
"self",
")",
":",
"if",
"self",
".",
"lockroutine",
":",
"self",
".",
"lockroutine",
".",
"close",
"(",
")",
"self",
".",
"lockroutine",
"=",
"None",
"if",
"self",
".",
"locked",
":",
"self",
".",
"locked",
"=",
"False",
"self",... | Unlock the key | [
"Unlock",
"the",
"key"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/lock.py#L88-L95 |
hubo1016/vlcp | vlcp/event/lock.py | Semaphore.create | def create(self):
"""
Create the subqueue to change the default behavior of Lock to semaphore.
"""
self.queue = self.scheduler.queue.addSubQueue(self.priority, LockEvent.createMatcher(self.context, self.key),
maxdefault = self.size, defaultQueueCl... | python | def create(self):
"""
Create the subqueue to change the default behavior of Lock to semaphore.
"""
self.queue = self.scheduler.queue.addSubQueue(self.priority, LockEvent.createMatcher(self.context, self.key),
maxdefault = self.size, defaultQueueCl... | [
"def",
"create",
"(",
"self",
")",
":",
"self",
".",
"queue",
"=",
"self",
".",
"scheduler",
".",
"queue",
".",
"addSubQueue",
"(",
"self",
".",
"priority",
",",
"LockEvent",
".",
"createMatcher",
"(",
"self",
".",
"context",
",",
"self",
".",
"key",
... | Create the subqueue to change the default behavior of Lock to semaphore. | [
"Create",
"the",
"subqueue",
"to",
"change",
"the",
"default",
"behavior",
"of",
"Lock",
"to",
"semaphore",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/lock.py#L141-L146 |
hubo1016/vlcp | vlcp/event/lock.py | Semaphore.destroy | async def destroy(self, container = None):
"""
Destroy the created subqueue to change the behavior back to Lock
"""
if container is None:
container = RoutineContainer(self.scheduler)
if self.queue is not None:
await container.syscall_noreturn(syscall_remov... | python | async def destroy(self, container = None):
"""
Destroy the created subqueue to change the behavior back to Lock
"""
if container is None:
container = RoutineContainer(self.scheduler)
if self.queue is not None:
await container.syscall_noreturn(syscall_remov... | [
"async",
"def",
"destroy",
"(",
"self",
",",
"container",
"=",
"None",
")",
":",
"if",
"container",
"is",
"None",
":",
"container",
"=",
"RoutineContainer",
"(",
"self",
".",
"scheduler",
")",
"if",
"self",
".",
"queue",
"is",
"not",
"None",
":",
"awai... | Destroy the created subqueue to change the behavior back to Lock | [
"Destroy",
"the",
"created",
"subqueue",
"to",
"change",
"the",
"behavior",
"back",
"to",
"Lock"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/lock.py#L147-L155 |
hubo1016/vlcp | vlcp/event/connection.py | Connection.shutdown | async def shutdown(self, force = False, connmark = -1):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.SHUTDOWN, force, connmark)) | python | async def shutdown(self, force = False, connmark = -1):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.SHUTDOWN, force, connmark)) | [
"async",
"def",
"shutdown",
"(",
"self",
",",
"force",
"=",
"False",
",",
"connmark",
"=",
"-",
"1",
")",
":",
"if",
"connmark",
"is",
"None",
":",
"connmark",
"=",
"self",
".",
"connmark",
"self",
".",
"scheduler",
".",
"emergesend",
"(",
"ConnectionC... | Can call without delegate | [
"Can",
"call",
"without",
"delegate"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/connection.py#L367-L373 |
hubo1016/vlcp | vlcp/event/connection.py | Connection.reconnect | async def reconnect(self, force = True, connmark = None):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.RECONNECT, force, connmark)) | python | async def reconnect(self, force = True, connmark = None):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.RECONNECT, force, connmark)) | [
"async",
"def",
"reconnect",
"(",
"self",
",",
"force",
"=",
"True",
",",
"connmark",
"=",
"None",
")",
":",
"if",
"connmark",
"is",
"None",
":",
"connmark",
"=",
"self",
".",
"connmark",
"self",
".",
"scheduler",
".",
"emergesend",
"(",
"ConnectionContr... | Can call without delegate | [
"Can",
"call",
"without",
"delegate"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/connection.py#L374-L380 |
hubo1016/vlcp | vlcp/event/connection.py | Connection.reset | async def reset(self, force = True, connmark = None):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.RESET, force, connmark)) | python | async def reset(self, force = True, connmark = None):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.RESET, force, connmark)) | [
"async",
"def",
"reset",
"(",
"self",
",",
"force",
"=",
"True",
",",
"connmark",
"=",
"None",
")",
":",
"if",
"connmark",
"is",
"None",
":",
"connmark",
"=",
"self",
".",
"connmark",
"self",
".",
"scheduler",
".",
"emergesend",
"(",
"ConnectionControlEv... | Can call without delegate | [
"Can",
"call",
"without",
"delegate"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/connection.py#L381-L387 |
hubo1016/vlcp | vlcp/event/connection.py | Connection.write | async def write(self, event, ignoreException = True):
'''
Can call without delegate
'''
connmark = self.connmark
if self.connected:
def _until():
if not self.connected or self.connmark != connmark:
return True
r = await ... | python | async def write(self, event, ignoreException = True):
'''
Can call without delegate
'''
connmark = self.connmark
if self.connected:
def _until():
if not self.connected or self.connmark != connmark:
return True
r = await ... | [
"async",
"def",
"write",
"(",
"self",
",",
"event",
",",
"ignoreException",
"=",
"True",
")",
":",
"connmark",
"=",
"self",
".",
"connmark",
"if",
"self",
".",
"connected",
":",
"def",
"_until",
"(",
")",
":",
"if",
"not",
"self",
".",
"connected",
"... | Can call without delegate | [
"Can",
"call",
"without",
"delegate"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/connection.py#L388-L405 |
hubo1016/vlcp | vlcp/event/connection.py | TcpServer.shutdown | async def shutdown(self, connmark = -1):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.SHUTDOWN, True, connmark)) | python | async def shutdown(self, connmark = -1):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.SHUTDOWN, True, connmark)) | [
"async",
"def",
"shutdown",
"(",
"self",
",",
"connmark",
"=",
"-",
"1",
")",
":",
"if",
"connmark",
"is",
"None",
":",
"connmark",
"=",
"self",
".",
"connmark",
"self",
".",
"scheduler",
".",
"emergesend",
"(",
"ConnectionControlEvent",
"(",
"self",
","... | Can call without delegate | [
"Can",
"call",
"without",
"delegate"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/connection.py#L1056-L1062 |
hubo1016/vlcp | vlcp/event/connection.py | TcpServer.stoplisten | async def stoplisten(self, connmark = -1):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.STOPLISTEN, True, connmark)) | python | async def stoplisten(self, connmark = -1):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.STOPLISTEN, True, connmark)) | [
"async",
"def",
"stoplisten",
"(",
"self",
",",
"connmark",
"=",
"-",
"1",
")",
":",
"if",
"connmark",
"is",
"None",
":",
"connmark",
"=",
"self",
".",
"connmark",
"self",
".",
"scheduler",
".",
"emergesend",
"(",
"ConnectionControlEvent",
"(",
"self",
"... | Can call without delegate | [
"Can",
"call",
"without",
"delegate"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/connection.py#L1064-L1070 |
hubo1016/vlcp | vlcp/event/connection.py | TcpServer.startlisten | async def startlisten(self, connmark = -1):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.STARTLISTEN, True, connmark)) | python | async def startlisten(self, connmark = -1):
'''
Can call without delegate
'''
if connmark is None:
connmark = self.connmark
self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.STARTLISTEN, True, connmark)) | [
"async",
"def",
"startlisten",
"(",
"self",
",",
"connmark",
"=",
"-",
"1",
")",
":",
"if",
"connmark",
"is",
"None",
":",
"connmark",
"=",
"self",
".",
"connmark",
"self",
".",
"scheduler",
".",
"emergesend",
"(",
"ConnectionControlEvent",
"(",
"self",
... | Can call without delegate | [
"Can",
"call",
"without",
"delegate"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/connection.py#L1072-L1078 |
hubo1016/vlcp | vlcp/start.py | default_start | def default_start():
"""
Use `sys.argv` for starting parameters. This is the entry-point of `vlcp-start`
"""
(config, daemon, pidfile, startup, fork) = parsearg()
if config is None:
if os.path.isfile('/etc/vlcp.conf'):
config = '/etc/vlcp.conf'
else:
print('/e... | python | def default_start():
"""
Use `sys.argv` for starting parameters. This is the entry-point of `vlcp-start`
"""
(config, daemon, pidfile, startup, fork) = parsearg()
if config is None:
if os.path.isfile('/etc/vlcp.conf'):
config = '/etc/vlcp.conf'
else:
print('/e... | [
"def",
"default_start",
"(",
")",
":",
"(",
"config",
",",
"daemon",
",",
"pidfile",
",",
"startup",
",",
"fork",
")",
"=",
"parsearg",
"(",
")",
"if",
"config",
"is",
"None",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"'/etc/vlcp.conf'",
")",... | Use `sys.argv` for starting parameters. This is the entry-point of `vlcp-start` | [
"Use",
"sys",
".",
"argv",
"for",
"starting",
"parameters",
".",
"This",
"is",
"the",
"entry",
"-",
"point",
"of",
"vlcp",
"-",
"start"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/start.py#L61-L73 |
hubo1016/vlcp | vlcp/utils/webclient.py | Response.close | def close(self):
"Stop the output stream, but further download will still perform"
if self.stream:
self.stream.close(self.scheduler)
self.stream = None | python | def close(self):
"Stop the output stream, but further download will still perform"
if self.stream:
self.stream.close(self.scheduler)
self.stream = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"stream",
":",
"self",
".",
"stream",
".",
"close",
"(",
"self",
".",
"scheduler",
")",
"self",
".",
"stream",
"=",
"None"
] | Stop the output stream, but further download will still perform | [
"Stop",
"the",
"output",
"stream",
"but",
"further",
"download",
"will",
"still",
"perform"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/webclient.py#L314-L318 |
hubo1016/vlcp | vlcp/utils/webclient.py | Response.shutdown | async def shutdown(self):
"Force stop the output stream, if there are more data to download, shutdown the connection"
if self.stream:
if not self.stream.dataeof and not self.stream.dataerror:
self.stream.close(self.scheduler)
await self.connection.shutdown()
... | python | async def shutdown(self):
"Force stop the output stream, if there are more data to download, shutdown the connection"
if self.stream:
if not self.stream.dataeof and not self.stream.dataerror:
self.stream.close(self.scheduler)
await self.connection.shutdown()
... | [
"async",
"def",
"shutdown",
"(",
"self",
")",
":",
"if",
"self",
".",
"stream",
":",
"if",
"not",
"self",
".",
"stream",
".",
"dataeof",
"and",
"not",
"self",
".",
"stream",
".",
"dataerror",
":",
"self",
".",
"stream",
".",
"close",
"(",
"self",
"... | Force stop the output stream, if there are more data to download, shutdown the connection | [
"Force",
"stop",
"the",
"output",
"stream",
"if",
"there",
"are",
"more",
"data",
"to",
"download",
"shutdown",
"the",
"connection"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/webclient.py#L319-L327 |
hubo1016/vlcp | vlcp/utils/networkplugin.py | createphysicalnetwork | def createphysicalnetwork(type, create_processor = partial(default_processor, excluding=('id', 'type')),
reorder_dict = default_iterate_dict):
"""
:param type: physical network type
:param create_processor: create_processor(physicalnetwork, walk, write, \*, paramet... | python | def createphysicalnetwork(type, create_processor = partial(default_processor, excluding=('id', 'type')),
reorder_dict = default_iterate_dict):
"""
:param type: physical network type
:param create_processor: create_processor(physicalnetwork, walk, write, \*, paramet... | [
"def",
"createphysicalnetwork",
"(",
"type",
",",
"create_processor",
"=",
"partial",
"(",
"default_processor",
",",
"excluding",
"=",
"(",
"'id'",
",",
"'type'",
")",
")",
",",
"reorder_dict",
"=",
"default_iterate_dict",
")",
":",
"# create an new physical network... | :param type: physical network type
:param create_processor: create_processor(physicalnetwork, walk, write, \*, parameters) | [
":",
"param",
"type",
":",
"physical",
"network",
"type",
":",
"param",
"create_processor",
":",
"create_processor",
"(",
"physicalnetwork",
"walk",
"write",
"\\",
"*",
"parameters",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/networkplugin.py#L43-L76 |
hubo1016/vlcp | vlcp/utils/networkplugin.py | deletephysicalnetwork | def deletephysicalnetwork(check_processor = default_physicalnetwork_delete_check,
reorder_dict = default_iterate_dict):
"""
:param check_processor: check_processor(physicalnetwork, physicalnetworkmap, walk, write, \*, parameters)
"""
def walker(walk, write, timestamp, par... | python | def deletephysicalnetwork(check_processor = default_physicalnetwork_delete_check,
reorder_dict = default_iterate_dict):
"""
:param check_processor: check_processor(physicalnetwork, physicalnetworkmap, walk, write, \*, parameters)
"""
def walker(walk, write, timestamp, par... | [
"def",
"deletephysicalnetwork",
"(",
"check_processor",
"=",
"default_physicalnetwork_delete_check",
",",
"reorder_dict",
"=",
"default_iterate_dict",
")",
":",
"def",
"walker",
"(",
"walk",
",",
"write",
",",
"timestamp",
",",
"parameters_dict",
")",
":",
"for",
"k... | :param check_processor: check_processor(physicalnetwork, physicalnetworkmap, walk, write, \*, parameters) | [
":",
"param",
"check_processor",
":",
"check_processor",
"(",
"physicalnetwork",
"physicalnetworkmap",
"walk",
"write",
"\\",
"*",
"parameters",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/networkplugin.py#L104-L132 |
hubo1016/vlcp | vlcp/utils/networkplugin.py | createphysicalport | def createphysicalport(create_processor = partial(default_processor, excluding=('vhost', 'systemid',
'bridge', 'name',
'physicalnetwork')),
... | python | def createphysicalport(create_processor = partial(default_processor, excluding=('vhost', 'systemid',
'bridge', 'name',
'physicalnetwork')),
... | [
"def",
"createphysicalport",
"(",
"create_processor",
"=",
"partial",
"(",
"default_processor",
",",
"excluding",
"=",
"(",
"'vhost'",
",",
"'systemid'",
",",
"'bridge'",
",",
"'name'",
",",
"'physicalnetwork'",
")",
")",
",",
"reorder_dict",
"=",
"default_iterate... | :param create_processor: create_processor(physicalport, physicalnetwork, physicalnetworkmap, walk, write, \*, parameters) | [
":",
"param",
"create_processor",
":",
"create_processor",
"(",
"physicalport",
"physicalnetwork",
"physicalnetworkmap",
"walk",
"write",
"\\",
"*",
"parameters",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/networkplugin.py#L141-L180 |
hubo1016/vlcp | vlcp/utils/networkplugin.py | updatephysicalport | def updatephysicalport(update_processor = partial(default_processor, excluding=('vhost', 'systemid',
'bridge', 'name'),
disabled=('physicalnetwork',)),
... | python | def updatephysicalport(update_processor = partial(default_processor, excluding=('vhost', 'systemid',
'bridge', 'name'),
disabled=('physicalnetwork',)),
... | [
"def",
"updatephysicalport",
"(",
"update_processor",
"=",
"partial",
"(",
"default_processor",
",",
"excluding",
"=",
"(",
"'vhost'",
",",
"'systemid'",
",",
"'bridge'",
",",
"'name'",
")",
",",
"disabled",
"=",
"(",
"'physicalnetwork'",
",",
")",
")",
",",
... | :param update_processor: update_processor(physcialport, walk, write, \*, parameters) | [
":",
"param",
"update_processor",
":",
"update_processor",
"(",
"physcialport",
"walk",
"write",
"\\",
"*",
"parameters",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/networkplugin.py#L183-L200 |
hubo1016/vlcp | vlcp/utils/networkplugin.py | deletephysicalport | def deletephysicalport(check_processor=_false_processor,
reorder_dict = default_iterate_dict):
"""
:param check_processor: check_processor(physicalport, physicalnetwork, physicalnetworkmap,
walk, write \*, parameters)
"""
def walker(walk, write, timesta... | python | def deletephysicalport(check_processor=_false_processor,
reorder_dict = default_iterate_dict):
"""
:param check_processor: check_processor(physicalport, physicalnetwork, physicalnetworkmap,
walk, write \*, parameters)
"""
def walker(walk, write, timesta... | [
"def",
"deletephysicalport",
"(",
"check_processor",
"=",
"_false_processor",
",",
"reorder_dict",
"=",
"default_iterate_dict",
")",
":",
"def",
"walker",
"(",
"walk",
",",
"write",
",",
"timestamp",
",",
"parameters_dict",
")",
":",
"for",
"key",
",",
"paramete... | :param check_processor: check_processor(physicalport, physicalnetwork, physicalnetworkmap,
walk, write \*, parameters) | [
":",
"param",
"check_processor",
":",
"check_processor",
"(",
"physicalport",
"physicalnetwork",
"physicalnetworkmap",
"walk",
"write",
"\\",
"*",
"parameters",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/networkplugin.py#L203-L237 |
hubo1016/vlcp | vlcp/utils/networkplugin.py | createlogicalnetwork | def createlogicalnetwork(create_processor = partial(default_processor, excluding=('id', 'physicalnetwork')),
reorder_dict = default_iterate_dict):
"""
:param create_processor: create_processor(logicalnetwork, logicalnetworkmap, physicalnetwork,
physicalnetwo... | python | def createlogicalnetwork(create_processor = partial(default_processor, excluding=('id', 'physicalnetwork')),
reorder_dict = default_iterate_dict):
"""
:param create_processor: create_processor(logicalnetwork, logicalnetworkmap, physicalnetwork,
physicalnetwo... | [
"def",
"createlogicalnetwork",
"(",
"create_processor",
"=",
"partial",
"(",
"default_processor",
",",
"excluding",
"=",
"(",
"'id'",
",",
"'physicalnetwork'",
")",
")",
",",
"reorder_dict",
"=",
"default_iterate_dict",
")",
":",
"def",
"walker",
"(",
"walk",
",... | :param create_processor: create_processor(logicalnetwork, logicalnetworkmap, physicalnetwork,
physicalnetworkmap, walk, write, \*, parameters) | [
":",
"param",
"create_processor",
":",
"create_processor",
"(",
"logicalnetwork",
"logicalnetworkmap",
"physicalnetwork",
"physicalnetworkmap",
"walk",
"write",
"\\",
"*",
"parameters",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/networkplugin.py#L247-L287 |
hubo1016/vlcp | vlcp/utils/networkplugin.py | deletelogicalnetwork | def deletelogicalnetwork(check_processor=default_logicalnetwork_delete_check,
reorder_dict = default_iterate_dict):
"""
:param check_processor: check_processor(logicalnetwork, logicalnetworkmap,
physicalnetwork, physicalnetworkmap,
... | python | def deletelogicalnetwork(check_processor=default_logicalnetwork_delete_check,
reorder_dict = default_iterate_dict):
"""
:param check_processor: check_processor(logicalnetwork, logicalnetworkmap,
physicalnetwork, physicalnetworkmap,
... | [
"def",
"deletelogicalnetwork",
"(",
"check_processor",
"=",
"default_logicalnetwork_delete_check",
",",
"reorder_dict",
"=",
"default_iterate_dict",
")",
":",
"def",
"walker",
"(",
"walk",
",",
"write",
",",
"timestamp",
",",
"parameters_dict",
")",
":",
"for",
"key... | :param check_processor: check_processor(logicalnetwork, logicalnetworkmap,
physicalnetwork, physicalnetworkmap,
walk, write, \*, parameters) | [
":",
"param",
"check_processor",
":",
"check_processor",
"(",
"logicalnetwork",
"logicalnetworkmap",
"physicalnetwork",
"physicalnetworkmap",
"walk",
"write",
"\\",
"*",
"parameters",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/networkplugin.py#L315-L356 |
hubo1016/vlcp | vlcp/utils/flowupdater.py | FlowUpdater.restart_walk | async def restart_walk(self):
"""
Force a re-walk
"""
if not self._restartwalk:
self._restartwalk = True
await self.wait_for_send(FlowUpdaterNotification(self, FlowUpdaterNotification.STARTWALK)) | python | async def restart_walk(self):
"""
Force a re-walk
"""
if not self._restartwalk:
self._restartwalk = True
await self.wait_for_send(FlowUpdaterNotification(self, FlowUpdaterNotification.STARTWALK)) | [
"async",
"def",
"restart_walk",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_restartwalk",
":",
"self",
".",
"_restartwalk",
"=",
"True",
"await",
"self",
".",
"wait_for_send",
"(",
"FlowUpdaterNotification",
"(",
"self",
",",
"FlowUpdaterNotification",
... | Force a re-walk | [
"Force",
"a",
"re",
"-",
"walk"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/flowupdater.py#L106-L112 |
hubo1016/vlcp | vlcp/utils/flowupdater.py | FlowUpdater._dataobject_update_detect | async def _dataobject_update_detect(self, _initialkeys, _savedresult):
"""
Coroutine that wait for retrieved value update notification
"""
def expr(newvalues, updatedvalues):
if any(v.getkey() in _initialkeys for v in updatedvalues if v is not None):
return Tr... | python | async def _dataobject_update_detect(self, _initialkeys, _savedresult):
"""
Coroutine that wait for retrieved value update notification
"""
def expr(newvalues, updatedvalues):
if any(v.getkey() in _initialkeys for v in updatedvalues if v is not None):
return Tr... | [
"async",
"def",
"_dataobject_update_detect",
"(",
"self",
",",
"_initialkeys",
",",
"_savedresult",
")",
":",
"def",
"expr",
"(",
"newvalues",
",",
"updatedvalues",
")",
":",
"if",
"any",
"(",
"v",
".",
"getkey",
"(",
")",
"in",
"_initialkeys",
"for",
"v",... | Coroutine that wait for retrieved value update notification | [
"Coroutine",
"that",
"wait",
"for",
"retrieved",
"value",
"update",
"notification"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/flowupdater.py#L114-L127 |
hubo1016/vlcp | vlcp/utils/flowupdater.py | FlowUpdater.updateobjects | def updateobjects(self, updatedvalues):
"""
Force a update notification on specified objects, even if they are not actually updated
in ObjectDB
"""
if not self._updatedset:
self.scheduler.emergesend(FlowUpdaterNotification(self, FlowUpdaterNotification.DATAUPDATED))
... | python | def updateobjects(self, updatedvalues):
"""
Force a update notification on specified objects, even if they are not actually updated
in ObjectDB
"""
if not self._updatedset:
self.scheduler.emergesend(FlowUpdaterNotification(self, FlowUpdaterNotification.DATAUPDATED))
... | [
"def",
"updateobjects",
"(",
"self",
",",
"updatedvalues",
")",
":",
"if",
"not",
"self",
".",
"_updatedset",
":",
"self",
".",
"scheduler",
".",
"emergesend",
"(",
"FlowUpdaterNotification",
"(",
"self",
",",
"FlowUpdaterNotification",
".",
"DATAUPDATED",
")",
... | Force a update notification on specified objects, even if they are not actually updated
in ObjectDB | [
"Force",
"a",
"update",
"notification",
"on",
"specified",
"objects",
"even",
"if",
"they",
"are",
"not",
"actually",
"updated",
"in",
"ObjectDB"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/flowupdater.py#L129-L136 |
hubo1016/vlcp | vlcp/utils/flowupdater.py | FlowUpdater._flowupdater | async def _flowupdater(self):
"""
Coroutine calling `updateflow()`
"""
lastresult = set(v for v in self._savedresult if v is not None and not v.isdeleted())
flowupdate = FlowUpdaterNotification.createMatcher(self, FlowUpdaterNotification.FLOWUPDATE)
while True:
... | python | async def _flowupdater(self):
"""
Coroutine calling `updateflow()`
"""
lastresult = set(v for v in self._savedresult if v is not None and not v.isdeleted())
flowupdate = FlowUpdaterNotification.createMatcher(self, FlowUpdaterNotification.FLOWUPDATE)
while True:
... | [
"async",
"def",
"_flowupdater",
"(",
"self",
")",
":",
"lastresult",
"=",
"set",
"(",
"v",
"for",
"v",
"in",
"self",
".",
"_savedresult",
"if",
"v",
"is",
"not",
"None",
"and",
"not",
"v",
".",
"isdeleted",
"(",
")",
")",
"flowupdate",
"=",
"FlowUpda... | Coroutine calling `updateflow()` | [
"Coroutine",
"calling",
"updateflow",
"()"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/flowupdater.py#L138-L165 |
hubo1016/vlcp | vlcp/utils/flowupdater.py | FlowUpdater.main | async def main(self):
"""
Main coroutine
"""
try:
lastkeys = set()
dataupdate = FlowUpdaterNotification.createMatcher(self, FlowUpdaterNotification.DATAUPDATED)
startwalk = FlowUpdaterNotification.createMatcher(self, FlowUpdaterNotification.STARTWALK)
... | python | async def main(self):
"""
Main coroutine
"""
try:
lastkeys = set()
dataupdate = FlowUpdaterNotification.createMatcher(self, FlowUpdaterNotification.DATAUPDATED)
startwalk = FlowUpdaterNotification.createMatcher(self, FlowUpdaterNotification.STARTWALK)
... | [
"async",
"def",
"main",
"(",
"self",
")",
":",
"try",
":",
"lastkeys",
"=",
"set",
"(",
")",
"dataupdate",
"=",
"FlowUpdaterNotification",
".",
"createMatcher",
"(",
"self",
",",
"FlowUpdaterNotification",
".",
"DATAUPDATED",
")",
"startwalk",
"=",
"FlowUpdate... | Main coroutine | [
"Main",
"coroutine"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/flowupdater.py#L167-L248 |
hubo1016/vlcp | vlcp/event/core.py | syscall_direct | def syscall_direct(*events):
'''
Directly process these events. This should never be used for normal events.
'''
def _syscall(scheduler, processor):
for e in events:
processor(e)
return _syscall | python | def syscall_direct(*events):
'''
Directly process these events. This should never be used for normal events.
'''
def _syscall(scheduler, processor):
for e in events:
processor(e)
return _syscall | [
"def",
"syscall_direct",
"(",
"*",
"events",
")",
":",
"def",
"_syscall",
"(",
"scheduler",
",",
"processor",
")",
":",
"for",
"e",
"in",
"events",
":",
"processor",
"(",
"e",
")",
"return",
"_syscall"
] | Directly process these events. This should never be used for normal events. | [
"Directly",
"process",
"these",
"events",
".",
"This",
"should",
"never",
"be",
"used",
"for",
"normal",
"events",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L520-L527 |
hubo1016/vlcp | vlcp/event/core.py | syscall_generator | def syscall_generator(generator):
'''
Directly process events from a generator function. This should never be used for normal events.
'''
def _syscall(scheduler, processor):
for e in generator():
processor(e)
return _syscall | python | def syscall_generator(generator):
'''
Directly process events from a generator function. This should never be used for normal events.
'''
def _syscall(scheduler, processor):
for e in generator():
processor(e)
return _syscall | [
"def",
"syscall_generator",
"(",
"generator",
")",
":",
"def",
"_syscall",
"(",
"scheduler",
",",
"processor",
")",
":",
"for",
"e",
"in",
"generator",
"(",
")",
":",
"processor",
"(",
"e",
")",
"return",
"_syscall"
] | Directly process events from a generator function. This should never be used for normal events. | [
"Directly",
"process",
"events",
"from",
"a",
"generator",
"function",
".",
"This",
"should",
"never",
"be",
"used",
"for",
"normal",
"events",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L529-L536 |
hubo1016/vlcp | vlcp/event/core.py | syscall_clearqueue | def syscall_clearqueue(queue):
'''
Clear a queue
'''
def _syscall(scheduler, processor):
qes, qees = queue.clear()
events = scheduler.queue.unblockqueue(queue)
for e in events:
scheduler.eventtree.remove(e)
for e in qes:
processor(e)
for e ... | python | def syscall_clearqueue(queue):
'''
Clear a queue
'''
def _syscall(scheduler, processor):
qes, qees = queue.clear()
events = scheduler.queue.unblockqueue(queue)
for e in events:
scheduler.eventtree.remove(e)
for e in qes:
processor(e)
for e ... | [
"def",
"syscall_clearqueue",
"(",
"queue",
")",
":",
"def",
"_syscall",
"(",
"scheduler",
",",
"processor",
")",
":",
"qes",
",",
"qees",
"=",
"queue",
".",
"clear",
"(",
")",
"events",
"=",
"scheduler",
".",
"queue",
".",
"unblockqueue",
"(",
"queue",
... | Clear a queue | [
"Clear",
"a",
"queue"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L538-L551 |
hubo1016/vlcp | vlcp/event/core.py | syscall_removequeue | def syscall_removequeue(queue, index):
'''
Remove subqueue `queue[index]` from queue.
'''
def _syscall(scheduler, processor):
events = scheduler.queue.unblockqueue(queue[index])
for e in events:
scheduler.eventtree.remove(e)
qes, qees = queue.removeSubQueue(index)
... | python | def syscall_removequeue(queue, index):
'''
Remove subqueue `queue[index]` from queue.
'''
def _syscall(scheduler, processor):
events = scheduler.queue.unblockqueue(queue[index])
for e in events:
scheduler.eventtree.remove(e)
qes, qees = queue.removeSubQueue(index)
... | [
"def",
"syscall_removequeue",
"(",
"queue",
",",
"index",
")",
":",
"def",
"_syscall",
"(",
"scheduler",
",",
"processor",
")",
":",
"events",
"=",
"scheduler",
".",
"queue",
".",
"unblockqueue",
"(",
"queue",
"[",
"index",
"]",
")",
"for",
"e",
"in",
... | Remove subqueue `queue[index]` from queue. | [
"Remove",
"subqueue",
"queue",
"[",
"index",
"]",
"from",
"queue",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L553-L566 |
hubo1016/vlcp | vlcp/event/core.py | syscall_clearremovequeue | def syscall_clearremovequeue(queue, index):
'''
Clear the subqueue `queue[index]` and remove it from queue.
'''
def _syscall(scheduler, processor):
qes, qees = queue[index].clear()
events = scheduler.queue.unblockqueue(queue[index])
for e in events:
scheduler.eventtre... | python | def syscall_clearremovequeue(queue, index):
'''
Clear the subqueue `queue[index]` and remove it from queue.
'''
def _syscall(scheduler, processor):
qes, qees = queue[index].clear()
events = scheduler.queue.unblockqueue(queue[index])
for e in events:
scheduler.eventtre... | [
"def",
"syscall_clearremovequeue",
"(",
"queue",
",",
"index",
")",
":",
"def",
"_syscall",
"(",
"scheduler",
",",
"processor",
")",
":",
"qes",
",",
"qees",
"=",
"queue",
"[",
"index",
"]",
".",
"clear",
"(",
")",
"events",
"=",
"scheduler",
".",
"que... | Clear the subqueue `queue[index]` and remove it from queue. | [
"Clear",
"the",
"subqueue",
"queue",
"[",
"index",
"]",
"and",
"remove",
"it",
"from",
"queue",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L568-L586 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.register | def register(self, matchers, runnable):
'''
Register an iterator(runnable) to scheduler and wait for events
:param matchers: sequence of EventMatchers
:param runnable: an iterator that accept send method
:param daemon: if True, the runnable will be regi... | python | def register(self, matchers, runnable):
'''
Register an iterator(runnable) to scheduler and wait for events
:param matchers: sequence of EventMatchers
:param runnable: an iterator that accept send method
:param daemon: if True, the runnable will be regi... | [
"def",
"register",
"(",
"self",
",",
"matchers",
",",
"runnable",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"'syscallfunc'",
",",
"None",
")",
"is",
"not",
"None",
"and",
"getattr",
"(",
"self",
",",
"'syscallrunnable'",
",",
"None",
")",
"is",
"Non... | Register an iterator(runnable) to scheduler and wait for events
:param matchers: sequence of EventMatchers
:param runnable: an iterator that accept send method
:param daemon: if True, the runnable will be registered as a daemon. | [
"Register",
"an",
"iterator",
"(",
"runnable",
")",
"to",
"scheduler",
"and",
"wait",
"for",
"events",
":",
"param",
"matchers",
":",
"sequence",
"of",
"EventMatchers",
":",
"param",
"runnable",
":",
"an",
"iterator",
"that",
"accept",
"send",
"method",
":",... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L128-L149 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.unregister | def unregister(self, matchers, runnable):
'''
Unregister an iterator(runnable) and stop waiting for events
:param matchers: sequence of EventMatchers
:param runnable: an iterator that accept send method
'''
for m in matchers:
self.matchtree.r... | python | def unregister(self, matchers, runnable):
'''
Unregister an iterator(runnable) and stop waiting for events
:param matchers: sequence of EventMatchers
:param runnable: an iterator that accept send method
'''
for m in matchers:
self.matchtree.r... | [
"def",
"unregister",
"(",
"self",
",",
"matchers",
",",
"runnable",
")",
":",
"for",
"m",
"in",
"matchers",
":",
"self",
".",
"matchtree",
".",
"remove",
"(",
"m",
",",
"runnable",
")",
"if",
"m",
".",
"indices",
"[",
"0",
"]",
"==",
"PollEvent",
"... | Unregister an iterator(runnable) and stop waiting for events
:param matchers: sequence of EventMatchers
:param runnable: an iterator that accept send method | [
"Unregister",
"an",
"iterator",
"(",
"runnable",
")",
"and",
"stop",
"waiting",
"for",
"events",
":",
"param",
"matchers",
":",
"sequence",
"of",
"EventMatchers",
":",
"param",
"runnable",
":",
"an",
"iterator",
"that",
"accept",
"send",
"method"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L150-L162 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.unregisterall | def unregisterall(self, runnable):
'''
Unregister all matches and detach the runnable. Automatically called when runnable returns StopIteration.
'''
if runnable in self.registerIndex:
for m in self.registerIndex[runnable]:
self.matchtree.remove(m, runnable)
... | python | def unregisterall(self, runnable):
'''
Unregister all matches and detach the runnable. Automatically called when runnable returns StopIteration.
'''
if runnable in self.registerIndex:
for m in self.registerIndex[runnable]:
self.matchtree.remove(m, runnable)
... | [
"def",
"unregisterall",
"(",
"self",
",",
"runnable",
")",
":",
"if",
"runnable",
"in",
"self",
".",
"registerIndex",
":",
"for",
"m",
"in",
"self",
".",
"registerIndex",
"[",
"runnable",
"]",
":",
"self",
".",
"matchtree",
".",
"remove",
"(",
"m",
","... | Unregister all matches and detach the runnable. Automatically called when runnable returns StopIteration. | [
"Unregister",
"all",
"matches",
"and",
"detach",
"the",
"runnable",
".",
"Automatically",
"called",
"when",
"runnable",
"returns",
"StopIteration",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L163-L173 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.ignore | def ignore(self, matcher):
'''
Unblock and ignore the matched events, if any.
'''
events = self.eventtree.findAndRemove(matcher)
for e in events:
self.queue.unblock(e)
e.canignore = True | python | def ignore(self, matcher):
'''
Unblock and ignore the matched events, if any.
'''
events = self.eventtree.findAndRemove(matcher)
for e in events:
self.queue.unblock(e)
e.canignore = True | [
"def",
"ignore",
"(",
"self",
",",
"matcher",
")",
":",
"events",
"=",
"self",
".",
"eventtree",
".",
"findAndRemove",
"(",
"matcher",
")",
"for",
"e",
"in",
"events",
":",
"self",
".",
"queue",
".",
"unblock",
"(",
"e",
")",
"e",
".",
"canignore",
... | Unblock and ignore the matched events, if any. | [
"Unblock",
"and",
"ignore",
"the",
"matched",
"events",
"if",
"any",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L174-L181 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.quit | def quit(self, daemononly = False):
'''
Send quit event to quit the main loop
'''
if not self.quitting:
self.quitting = True
self.queue.append(SystemControlEvent(SystemControlEvent.QUIT, daemononly = daemononly), True) | python | def quit(self, daemononly = False):
'''
Send quit event to quit the main loop
'''
if not self.quitting:
self.quitting = True
self.queue.append(SystemControlEvent(SystemControlEvent.QUIT, daemononly = daemononly), True) | [
"def",
"quit",
"(",
"self",
",",
"daemononly",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"quitting",
":",
"self",
".",
"quitting",
"=",
"True",
"self",
".",
"queue",
".",
"append",
"(",
"SystemControlEvent",
"(",
"SystemControlEvent",
".",
"QUIT"... | Send quit event to quit the main loop | [
"Send",
"quit",
"event",
"to",
"quit",
"the",
"main",
"loop"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L182-L188 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.setTimer | def setTimer(self, start, interval = None):
'''
Generate a TimerEvent on specified time
:param start: offset for time from now (seconds), or datetime for a fixed time
:param interval: if not None, the timer is regenerated by interval seconds.
:returns: ... | python | def setTimer(self, start, interval = None):
'''
Generate a TimerEvent on specified time
:param start: offset for time from now (seconds), or datetime for a fixed time
:param interval: if not None, the timer is regenerated by interval seconds.
:returns: ... | [
"def",
"setTimer",
"(",
"self",
",",
"start",
",",
"interval",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"start",
",",
"datetime",
")",
":",
"timestamp",
"=",
"(",
"start",
"-",
"datetime",
".",
"fromtimestamp",
"(",
"0",
")",
")",
".",
"total_... | Generate a TimerEvent on specified time
:param start: offset for time from now (seconds), or datetime for a fixed time
:param interval: if not None, the timer is regenerated by interval seconds.
:returns: a timer handle to wait or cancel the timer | [
"Generate",
"a",
"TimerEvent",
"on",
"specified",
"time",
":",
"param",
"start",
":",
"offset",
"for",
"time",
"from",
"now",
"(",
"seconds",
")",
"or",
"datetime",
"for",
"a",
"fixed",
"time",
":",
"param",
"interval",
":",
"if",
"not",
"None",
"the",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L201-L220 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.registerPolling | def registerPolling(self, fd, options = POLLING_IN|POLLING_OUT, daemon = False):
'''
register a polling file descriptor
:param fd: file descriptor or socket object
:param options: bit mask flags. Polling object should ignore the incompatible flag.
'''
se... | python | def registerPolling(self, fd, options = POLLING_IN|POLLING_OUT, daemon = False):
'''
register a polling file descriptor
:param fd: file descriptor or socket object
:param options: bit mask flags. Polling object should ignore the incompatible flag.
'''
se... | [
"def",
"registerPolling",
"(",
"self",
",",
"fd",
",",
"options",
"=",
"POLLING_IN",
"|",
"POLLING_OUT",
",",
"daemon",
"=",
"False",
")",
":",
"self",
".",
"polling",
".",
"register",
"(",
"fd",
",",
"options",
",",
"daemon",
")"
] | register a polling file descriptor
:param fd: file descriptor or socket object
:param options: bit mask flags. Polling object should ignore the incompatible flag. | [
"register",
"a",
"polling",
"file",
"descriptor",
":",
"param",
"fd",
":",
"file",
"descriptor",
"or",
"socket",
"object",
":",
"param",
"options",
":",
"bit",
"mask",
"flags",
".",
"Polling",
"object",
"should",
"ignore",
"the",
"incompatible",
"flag",
"."
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L230-L238 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.unregisterPolling | def unregisterPolling(self, fd, daemon = False):
'''
Unregister a polling file descriptor
:param fd: file descriptor or socket object
'''
self.polling.unregister(fd, daemon) | python | def unregisterPolling(self, fd, daemon = False):
'''
Unregister a polling file descriptor
:param fd: file descriptor or socket object
'''
self.polling.unregister(fd, daemon) | [
"def",
"unregisterPolling",
"(",
"self",
",",
"fd",
",",
"daemon",
"=",
"False",
")",
":",
"self",
".",
"polling",
".",
"unregister",
"(",
"fd",
",",
"daemon",
")"
] | Unregister a polling file descriptor
:param fd: file descriptor or socket object | [
"Unregister",
"a",
"polling",
"file",
"descriptor",
":",
"param",
"fd",
":",
"file",
"descriptor",
"or",
"socket",
"object"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L246-L252 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.setDaemon | def setDaemon(self, runnable, isdaemon, noregister = False):
'''
If a runnable is a daemon, it will not keep the main loop running. The main loop will end when all alived runnables are daemons.
'''
if not noregister and runnable not in self.registerIndex:
self.register((), ru... | python | def setDaemon(self, runnable, isdaemon, noregister = False):
'''
If a runnable is a daemon, it will not keep the main loop running. The main loop will end when all alived runnables are daemons.
'''
if not noregister and runnable not in self.registerIndex:
self.register((), ru... | [
"def",
"setDaemon",
"(",
"self",
",",
"runnable",
",",
"isdaemon",
",",
"noregister",
"=",
"False",
")",
":",
"if",
"not",
"noregister",
"and",
"runnable",
"not",
"in",
"self",
".",
"registerIndex",
":",
"self",
".",
"register",
"(",
"(",
")",
",",
"ru... | If a runnable is a daemon, it will not keep the main loop running. The main loop will end when all alived runnables are daemons. | [
"If",
"a",
"runnable",
"is",
"a",
"daemon",
"it",
"will",
"not",
"keep",
"the",
"main",
"loop",
"running",
".",
"The",
"main",
"loop",
"will",
"end",
"when",
"all",
"alived",
"runnables",
"are",
"daemons",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L259-L268 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.syscall | def syscall(self, func):
'''
Call the func in core context (main loop).
func should like::
def syscall_sample(scheduler, processor):
something...
where processor is a function which accept an event. When calling processor, scheduler directly... | python | def syscall(self, func):
'''
Call the func in core context (main loop).
func should like::
def syscall_sample(scheduler, processor):
something...
where processor is a function which accept an event. When calling processor, scheduler directly... | [
"def",
"syscall",
"(",
"self",
",",
"func",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"'syscallfunc'",
",",
"None",
")",
"is",
"not",
"None",
":",
"return",
"None",
"self",
".",
"syscallfunc",
"=",
"func",
"self",
".",
"syscallmatcher",
"=",
"Syscal... | Call the func in core context (main loop).
func should like::
def syscall_sample(scheduler, processor):
something...
where processor is a function which accept an event. When calling processor, scheduler directly process this event without
sending i... | [
"Call",
"the",
"func",
"in",
"core",
"context",
"(",
"main",
"loop",
")",
".",
"func",
"should",
"like",
"::",
"def",
"syscall_sample",
"(",
"scheduler",
"processor",
")",
":",
"something",
"..."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L269-L294 |
hubo1016/vlcp | vlcp/event/core.py | Scheduler.main | def main(self, installsignal = True, sendinit = True):
'''
Start main loop
'''
if installsignal:
sigterm = signal(SIGTERM, self._quitsignal)
sigint = signal(SIGINT, self._quitsignal)
try:
from signal import SIGUSR1
sigus... | python | def main(self, installsignal = True, sendinit = True):
'''
Start main loop
'''
if installsignal:
sigterm = signal(SIGTERM, self._quitsignal)
sigint = signal(SIGINT, self._quitsignal)
try:
from signal import SIGUSR1
sigus... | [
"def",
"main",
"(",
"self",
",",
"installsignal",
"=",
"True",
",",
"sendinit",
"=",
"True",
")",
":",
"if",
"installsignal",
":",
"sigterm",
"=",
"signal",
"(",
"SIGTERM",
",",
"self",
".",
"_quitsignal",
")",
"sigint",
"=",
"signal",
"(",
"SIGINT",
"... | Start main loop | [
"Start",
"main",
"loop"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/core.py#L303-L518 |
hubo1016/vlcp | vlcp/service/connection/tcpserver.py | TcpServerBase.getservers | def getservers(self, vhost = None):
'''
Return current servers
:param vhost: return only servers of vhost if specified. '' to return only default servers.
None for all servers.
'''
if vhost is not None:
return [s for s in self.connection... | python | def getservers(self, vhost = None):
'''
Return current servers
:param vhost: return only servers of vhost if specified. '' to return only default servers.
None for all servers.
'''
if vhost is not None:
return [s for s in self.connection... | [
"def",
"getservers",
"(",
"self",
",",
"vhost",
"=",
"None",
")",
":",
"if",
"vhost",
"is",
"not",
"None",
":",
"return",
"[",
"s",
"for",
"s",
"in",
"self",
".",
"connections",
"if",
"s",
".",
"protocol",
".",
"vhost",
"==",
"vhost",
"]",
"else",
... | Return current servers
:param vhost: return only servers of vhost if specified. '' to return only default servers.
None for all servers. | [
"Return",
"current",
"servers",
":",
"param",
"vhost",
":",
"return",
"only",
"servers",
"of",
"vhost",
"if",
"specified",
".",
"to",
"return",
"only",
"default",
"servers",
".",
"None",
"for",
"all",
"servers",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/service/connection/tcpserver.py#L138-L148 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.