INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Calculate TP,TN,FP,FN for each class.
:param actual_vector: actual values
:type actual_vector : list
:param predict_vector: predict value
:type predict_vector : list
:param sample_weight : sample weights list
:type sample_weight : list
:return: [classes_list,table,TP,TN,FP,FN] | def matrix_params_calc(actual_vector, predict_vector, sample_weight):
"""
Calculate TP,TN,FP,FN for each class.
:param actual_vector: actual values
:type actual_vector : list
:param predict_vector: predict value
:type predict_vector : list
:param sample_weight : sample weights list
:typ... |
Check if the dataset is imbalanced.
:param P: condition positive
:type P : dict
:return: is_imbalanced as bool | def imbalance_check(P):
"""
Check if the dataset is imbalanced.
:param P: condition positive
:type P : dict
:return: is_imbalanced as bool
"""
p_list = list(P.values())
max_value = max(p_list)
min_value = min(p_list)
if min_value > 0:
balance_ratio = max_value / min_valu... |
Check if the problem is a binary classification.
:param classes: all classes name
:type classes : list
:return: is_binary as bool | def binary_check(classes):
"""
Check if the problem is a binary classification.
:param classes: all classes name
:type classes : list
:return: is_binary as bool
"""
num_classes = len(classes)
is_binary = False
if num_classes == 2:
is_binary = True
return is_binary |
Return recommend parameters which are more suitable due to the input dataset characteristics.
:param classes: all classes name
:type classes : list
:param P: condition positive
:type P : dict
:return: recommendation_list as list | def statistic_recommend(classes, P):
"""
Return recommend parameters which are more suitable due to the input dataset characteristics.
:param classes: all classes name
:type classes : list
:param P: condition positive
:type P : dict
:return: recommendation_list as list
"""
if imbal... |
Print final result.
:param failed: failed flag
:type failed: bool
:return: None | def print_result(failed=False):
"""
Print final result.
:param failed: failed flag
:type failed: bool
:return: None
"""
message = "Version tag tests "
if not failed:
print("\n" + message + "passed!")
else:
print("\n" + message + "failed!")
print("Passed : " + str... |
Calculate C (Pearson's C).
:param chi_square: chi squared
:type chi_square : float
:param POP: population
:type POP : int
:return: C as float | def pearson_C_calc(chi_square, POP):
"""
Calculate C (Pearson's C).
:param chi_square: chi squared
:type chi_square : float
:param POP: population
:type POP : int
:return: C as float
"""
try:
C = math.sqrt(chi_square / (POP + chi_square))
return C
except Exceptio... |
Calculate AUNP.
:param classes: classes
:type classes : list
:param P: condition positive
:type P : dict
:param POP: population
:type POP : dict
:param AUC_dict: AUC (Area under the ROC curve) for each class
:type AUC_dict : dict
:return: AUNP as float | def AUNP_calc(classes, P, POP, AUC_dict):
"""
Calculate AUNP.
:param classes: classes
:type classes : list
:param P: condition positive
:type P : dict
:param POP: population
:type POP : dict
:param AUC_dict: AUC (Area under the ROC curve) for each class
:type AUC_dict : dict
... |
Calculate CBA (Class balance accuracy).
:param classes: classes
:type classes : list
:param table: input matrix
:type table : dict
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:return: CBA as float | def CBA_calc(classes, table, TOP, P):
"""
Calculate CBA (Class balance accuracy).
:param classes: classes
:type classes : list
:param table: input matrix
:type table : dict
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:return... |
Calculate RR (Global performance index).
:param classes: classes
:type classes : list
:param TOP: test outcome positive
:type TOP : dict
:return: RR as float | def RR_calc(classes, TOP):
"""
Calculate RR (Global performance index).
:param classes: classes
:type classes : list
:param TOP: test outcome positive
:type TOP : dict
:return: RR as float
"""
try:
class_number = len(classes)
result = sum(list(TOP.values()))
... |
Calculate Overall_MCC.
:param classes: classes
:type classes : list
:param table: input matrix
:type table : dict
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:return: Overall_MCC as float | def overall_MCC_calc(classes, table, TOP, P):
"""
Calculate Overall_MCC.
:param classes: classes
:type classes : list
:param table: input matrix
:type table : dict
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:return: Overal... |
Calculate Overall_CEN coefficient.
:param classes: classes
:type classes : list
:param TP: true Positive Dict For All Classes
:type TP : dict
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:param class_name: reviewed class name
:ty... | def convex_combination(classes, TP, TOP, P, class_name, modified=False):
"""
Calculate Overall_CEN coefficient.
:param classes: classes
:type classes : list
:param TP: true Positive Dict For All Classes
:type TP : dict
:param TOP: test outcome positive
:type TOP : dict
:param P: con... |
Calculate Overall_CEN (Overall confusion entropy).
:param classes: classes
:type classes : list
:param TP: true positive dict for all classes
:type TP : dict
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:param CEN_dict: CEN dictionar... | def overall_CEN_calc(classes, TP, TOP, P, CEN_dict, modified=False):
"""
Calculate Overall_CEN (Overall confusion entropy).
:param classes: classes
:type classes : list
:param TP: true positive dict for all classes
:type TP : dict
:param TOP: test outcome positive
:type TOP : dict
:... |
Calculate n choose r.
:param n: n
:type n : int
:param r: r
:type r :int
:return: n choose r as int | def ncr(n, r):
"""
Calculate n choose r.
:param n: n
:type n : int
:param r: r
:type r :int
:return: n choose r as int
"""
r = min(r, n - r)
numer = reduce(op.mul, range(n, n - r, -1), 1)
denom = reduce(op.mul, range(1, r + 1), 1)
return numer // denom |
Calculate p_value.
:param TP: true positive
:type TP : dict
:param POP: population
:type POP : int
:param NIR: no information rate
:type NIR : float
:return: p_value as float | def p_value_calc(TP, POP, NIR):
"""
Calculate p_value.
:param TP: true positive
:type TP : dict
:param POP: population
:type POP : int
:param NIR: no information rate
:type NIR : float
:return: p_value as float
"""
try:
n = POP
x = sum(list(TP.values()))
... |
Calculate NIR (No information rate).
:param P: condition positive
:type P : dict
:param POP: population
:type POP : int
:return: NIR as float | def NIR_calc(P, POP):
"""
Calculate NIR (No information rate).
:param P: condition positive
:type P : dict
:param POP: population
:type POP : int
:return: NIR as float
"""
try:
max_P = max(list(P.values()))
length = POP
return max_P / length
except Except... |
Calculate hamming loss.
:param TP: true positive
:type TP : dict
:param POP: population
:type POP : int
:return: hamming loss as float | def hamming_calc(TP, POP):
"""
Calculate hamming loss.
:param TP: true positive
:type TP : dict
:param POP: population
:type POP : int
:return: hamming loss as float
"""
try:
length = POP
return (1 / length) * (length - sum(TP.values()))
except Exception:
... |
Calculate zero-one loss.
:param TP: true Positive
:type TP : dict
:param POP: population
:type POP : int
:return: zero_one loss as integer | def zero_one_loss_calc(TP, POP):
"""
Calculate zero-one loss.
:param TP: true Positive
:type TP : dict
:param POP: population
:type POP : int
:return: zero_one loss as integer
"""
try:
length = POP
return (length - sum(TP.values()))
except Exception:
retu... |
Calculate reference and response likelihood.
:param item : TOP or P
:type item : dict
:param POP: population
:type POP : dict
:return: reference or response likelihood as float | def entropy_calc(item, POP):
"""
Calculate reference and response likelihood.
:param item : TOP or P
:type item : dict
:param POP: population
:type POP : dict
:return: reference or response likelihood as float
"""
try:
result = 0
for i in item.keys():
lik... |
Calculate cross entropy.
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:param POP: population
:type POP : dict
:return: cross entropy as float | def cross_entropy_calc(TOP, P, POP):
"""
Calculate cross entropy.
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:param POP: population
:type POP : dict
:return: cross entropy as float
"""
try:
result = 0
for i ... |
Calculate joint entropy.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param POP: population
:type POP : dict
:return: joint entropy as float | def joint_entropy_calc(classes, table, POP):
"""
Calculate joint entropy.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param POP: population
:type POP : dict
:return: joint entropy as float
"""
try:
... |
Calculate conditional entropy.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param P: condition positive
:type P : dict
:param POP: population
:type POP : dict
:return: conditional entropy as float | def conditional_entropy_calc(classes, table, P, POP):
"""
Calculate conditional entropy.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param P: condition positive
:type P : dict
:param POP: population
:type... |
Calculate Goodman and Kruskal's lambda B.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param TOP: test outcome positive
:type TOP : dict
:param POP: population
:type POP : int
:return: Goodman and Kruskal's la... | def lambda_B_calc(classes, table, TOP, POP):
"""
Calculate Goodman and Kruskal's lambda B.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param TOP: test outcome positive
:type TOP : dict
:param POP: population
... |
Calculate Goodman and Kruskal's lambda A.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param P: condition positive
:type P : dict
:param POP: population
:type POP : int
:return: Goodman and Kruskal's lambda A ... | def lambda_A_calc(classes, table, P, POP):
"""
Calculate Goodman and Kruskal's lambda A.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param P: condition positive
:type P : dict
:param POP: population
:type... |
Calculate chi-squared.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:param POP: population
:type POP : dict
... | def chi_square_calc(classes, table, TOP, P, POP):
"""
Calculate chi-squared.
:param classes: confusion matrix classes
:type classes : list
:param table: confusion matrix table
:type table : dict
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:typ... |
Calculate kappa standard error.
:param PA: observed agreement among raters (overall accuracy)
:type PA : float
:param PE: hypothetical probability of chance agreement (random accuracy)
:type PE : float
:param POP: population
:type POP:int
:return: kappa standard error as float | def kappa_se_calc(PA, PE, POP):
"""
Calculate kappa standard error.
:param PA: observed agreement among raters (overall accuracy)
:type PA : float
:param PE: hypothetical probability of chance agreement (random accuracy)
:type PE : float
:param POP: population
:type POP:int
:return... |
Calculate confidence interval.
:param mean: mean of data
:type mean : float
:param SE: standard error of data
:type SE : float
:param CV: critical value
:type CV:float
:return: confidence interval as tuple | def CI_calc(mean, SE, CV=1.96):
"""
Calculate confidence interval.
:param mean: mean of data
:type mean : float
:param SE: standard error of data
:type SE : float
:param CV: critical value
:type CV:float
:return: confidence interval as tuple
"""
try:
CI_down = mean -... |
Calculate PPV_Micro and TPR_Micro.
:param TP: true positive
:type TP:dict
:param item: FN or FP
:type item : dict
:return: PPV_Micro or TPR_Micro as float | def micro_calc(TP, item):
"""
Calculate PPV_Micro and TPR_Micro.
:param TP: true positive
:type TP:dict
:param item: FN or FP
:type item : dict
:return: PPV_Micro or TPR_Micro as float
"""
try:
TP_sum = sum(TP.values())
item_sum = sum(item.values())
return TP... |
Calculate PPV_Macro and TPR_Macro.
:param item: PPV or TPR
:type item:dict
:return: PPV_Macro or TPR_Macro as float | def macro_calc(item):
"""
Calculate PPV_Macro and TPR_Macro.
:param item: PPV or TPR
:type item:dict
:return: PPV_Macro or TPR_Macro as float
"""
try:
item_sum = sum(item.values())
item_len = len(item.values())
return item_sum / item_len
except Exception:
... |
Calculate percent chance agreement for Scott's Pi.
:param P: condition positive
:type P : dict
:param TOP: test outcome positive
:type TOP : dict
:param POP: population
:type POP:dict
:return: percent chance agreement as float | def PC_PI_calc(P, TOP, POP):
"""
Calculate percent chance agreement for Scott's Pi.
:param P: condition positive
:type P : dict
:param TOP: test outcome positive
:type TOP : dict
:param POP: population
:type POP:dict
:return: percent chance agreement as float
"""
try:
... |
Calculate percent chance agreement for Gwet's AC1.
:param P: condition positive
:type P : dict
:param TOP: test outcome positive
:type TOP : dict
:param POP: population
:type POP:dict
:return: percent chance agreement as float | def PC_AC1_calc(P, TOP, POP):
"""
Calculate percent chance agreement for Gwet's AC1.
:param P: condition positive
:type P : dict
:param TOP: test outcome positive
:type TOP : dict
:param POP: population
:type POP:dict
:return: percent chance agreement as float
"""
try:
... |
Calculate overall jaccard index.
:param jaccard_list : list of jaccard index for each class
:type jaccard_list : list
:return: (jaccard_sum , jaccard_mean) as tuple | def overall_jaccard_index_calc(jaccard_list):
"""
Calculate overall jaccard index.
:param jaccard_list : list of jaccard index for each class
:type jaccard_list : list
:return: (jaccard_sum , jaccard_mean) as tuple
"""
try:
jaccard_sum = sum(jaccard_list)
jaccard_mean = jacc... |
Calculate overall accuracy.
:param TP: true positive
:type TP : dict
:param POP: population
:type POP:int
:return: overall_accuracy as float | def overall_accuracy_calc(TP, POP):
"""
Calculate overall accuracy.
:param TP: true positive
:type TP : dict
:param POP: population
:type POP:int
:return: overall_accuracy as float
"""
try:
overall_accuracy = sum(TP.values()) / POP
return overall_accuracy
except ... |
Return overall statistics.
:param RACC: random accuracy
:type RACC : dict
:param TPR: sensitivity, recall, hit rate, or true positive rate
:type TPR : dict
:param PPV: precision or positive predictive value
:type PPV : dict
:param TP: true positive
:type TP : dict
:param FN: false n... | def overall_statistics(
RACC,
RACCU,
TPR,
PPV,
TP,
FN,
FP,
POP,
P,
TOP,
jaccard_list,
CEN_dict,
MCEN_dict,
AUC_dict,
classes,
table):
"""
Return overall statistics.
:param RACC: r... |
Analysis AUC with interpretation table.
:param AUC: area under the ROC curve
:type AUC : float
:return: interpretation result as str | def AUC_analysis(AUC):
"""
Analysis AUC with interpretation table.
:param AUC: area under the ROC curve
:type AUC : float
:return: interpretation result as str
"""
try:
if AUC == "None":
return "None"
if AUC < 0.6:
return "Poor"
if AUC >= 0.6 ... |
Analysis kappa number with Cicchetti benchmark.
:param kappa: kappa number
:type kappa : float
:return: strength of agreement as str | def kappa_analysis_cicchetti(kappa):
"""
Analysis kappa number with Cicchetti benchmark.
:param kappa: kappa number
:type kappa : float
:return: strength of agreement as str
"""
try:
if kappa < 0.4:
return "Poor"
if kappa >= 0.4 and kappa < 0.59:
retu... |
Analysis kappa number with Landis-Koch benchmark.
:param kappa: kappa number
:type kappa : float
:return: strength of agreement as str | def kappa_analysis_koch(kappa):
"""
Analysis kappa number with Landis-Koch benchmark.
:param kappa: kappa number
:type kappa : float
:return: strength of agreement as str
"""
try:
if kappa < 0:
return "Poor"
if kappa >= 0 and kappa < 0.2:
return "Slig... |
Analysis kappa number with Altman benchmark.
:param kappa: kappa number
:type kappa : float
:return: strength of agreement as str | def kappa_analysis_altman(kappa):
"""
Analysis kappa number with Altman benchmark.
:param kappa: kappa number
:type kappa : float
:return: strength of agreement as str
"""
try:
if kappa < 0.2:
return "Poor"
if kappa >= 0.20 and kappa < 0.4:
return "Fa... |
Read requirements.txt. | def get_requires():
"""Read requirements.txt."""
requirements = open("requirements.txt", "r").read()
return list(filter(lambda x: x != "", requirements.split())) |
Read README.md and CHANGELOG.md. | def read_description():
"""Read README.md and CHANGELOG.md."""
try:
with open("README.md") as r:
description = "\n"
description += r.read()
with open("CHANGELOG.md") as c:
description += "\n"
description += c.read()
return description
e... |
Print confusion matrix.
:param one_vs_all : One-Vs-All mode flag
:type one_vs_all : bool
:param class_name : target class name for One-Vs-All mode
:type class_name : any valid type
:return: None | def print_matrix(self, one_vs_all=False, class_name=None):
"""
Print confusion matrix.
:param one_vs_all : One-Vs-All mode flag
:type one_vs_all : bool
:param class_name : target class name for One-Vs-All mode
:type class_name : any valid type
:return: None
... |
Print statistical measures table.
:param overall_param : overall parameters list for print, Example : ["Kappa","Scott PI]
:type overall_param : list
:param class_param : class parameters list for print, Example : ["TPR","TNR","AUC"]
:type class_param : list
:param class_name : c... | def stat(self, overall_param=None, class_param=None, class_name=None):
"""
Print statistical measures table.
:param overall_param : overall parameters list for print, Example : ["Kappa","Scott PI]
:type overall_param : list
:param class_param : class parameters list for print, E... |
Save ConfusionMatrix in .pycm (flat file format).
:param name: filename
:type name : str
:param address: flag for address return
:type address : bool
:param overall_param : overall parameters list for save, Example : ["Kappa","Scott PI]
:type overall_param : list
... | def save_stat(
self,
name,
address=True,
overall_param=None,
class_param=None,
class_name=None):
"""
Save ConfusionMatrix in .pycm (flat file format).
:param name: filename
:type name : str
:param address: f... |
Save ConfusionMatrix in HTML file.
:param name: filename
:type name : str
:param address: flag for address return
:type address : bool
:param overall_param : overall parameters list for save, Example : ["Kappa","Scott PI]
:type overall_param : list
:param class_p... | def save_html(
self,
name,
address=True,
overall_param=None,
class_param=None,
class_name=None, color=(0, 0, 0), normalize=False):
"""
Save ConfusionMatrix in HTML file.
:param name: filename
:type name : str
... |
Save ConfusionMatrix in CSV file.
:param name: filename
:type name : str
:param address: flag for address return
:type address : bool
:param class_param : class parameters list for save, Example : ["TPR","TNR","AUC"]
:type class_param : list
:param class_name : c... | def save_csv(
self,
name,
address=True,
class_param=None,
class_name=None,
matrix_save=True,
normalize=False):
"""
Save ConfusionMatrix in CSV file.
:param name: filename
:type name : str
:param ... |
Save ConfusionMatrix in .obj file.
:param name: filename
:type name : str
:param address: flag for address return
:type address : bool
:return: saving Status as dict {"Status":bool , "Message":str} | def save_obj(self, name, address=True):
"""
Save ConfusionMatrix in .obj file.
:param name: filename
:type name : str
:param address: flag for address return
:type address : bool
:return: saving Status as dict {"Status":bool , "Message":str}
"""
t... |
Calculate FBeta score.
:param beta: beta parameter
:type beta : float
:return: FBeta score for classes as dict | def F_beta(self, beta):
"""
Calculate FBeta score.
:param beta: beta parameter
:type beta : float
:return: FBeta score for classes as dict
"""
try:
F_dict = {}
for i in self.TP.keys():
F_dict[i] = F_calc(
... |
Calculate IBA_alpha score.
:param alpha: alpha parameter
:type alpha: float
:return: IBA_alpha score for classes as dict | def IBA_alpha(self, alpha):
"""
Calculate IBA_alpha score.
:param alpha: alpha parameter
:type alpha: float
:return: IBA_alpha score for classes as dict
"""
try:
IBA_dict = {}
for i in self.classes:
IBA_dict[i] = IBA_calc(s... |
Rename ConfusionMatrix classes.
:param mapping: mapping dictionary
:type mapping : dict
:return: None | def relabel(self, mapping):
"""
Rename ConfusionMatrix classes.
:param mapping: mapping dictionary
:type mapping : dict
:return: None
"""
if not isinstance(mapping, dict):
raise pycmMatrixError(MAPPING_FORMAT_ERROR)
if self.classes != list(map... |
*Sets the client cert for the requests.*
The cert is either a path to a .pem file, or a JSON array, or a list
having the cert path and the key path.
Values ``null`` and ``${None}`` can be used for clearing the cert.
*Examples*
| `Set Client Cert` | ${CURDIR}/client.pem |
... | def set_client_cert(self, cert):
"""*Sets the client cert for the requests.*
The cert is either a path to a .pem file, or a JSON array, or a list
having the cert path and the key path.
Values ``null`` and ``${None}`` can be used for clearing the cert.
*Examples*
| `Se... |
*Sets new request headers or updates the existing.*
``headers``: The headers to add or update as a JSON object or a
dictionary.
*Examples*
| `Set Headers` | { "authorization": "Basic QWxhZGRpbjpPcGVuU2VzYW1"} |
| `Set Headers` | { "Accept-Encoding": "identity"} |
| `Se... | def set_headers(self, headers):
"""*Sets new request headers or updates the existing.*
``headers``: The headers to add or update as a JSON object or a
dictionary.
*Examples*
| `Set Headers` | { "authorization": "Basic QWxhZGRpbjpPcGVuU2VzYW1"} |
| `Set Headers` | { "Ac... |
*Sets the schema to validate the request properties*
Expectations are effective for following requests in the test suite,
or until they are reset or updated by using expectation keywords again.
On the test suite level (suite setup), they are best used for expecting
the endpoint wide pro... | def expect_request(self, schema, merge=False):
"""*Sets the schema to validate the request properties*
Expectations are effective for following requests in the test suite,
or until they are reset or updated by using expectation keywords again.
On the test suite level (suite setup), they... |
*Updates the schema to validate the response body properties.*
Expectations are effective for following requests in the test suite,
or until they are reset or updated by using expectation keywords again.
On the test suite level (suite setup), they are best used for expecting
the endpoin... | def expect_response_body(self, schema):
"""*Updates the schema to validate the response body properties.*
Expectations are effective for following requests in the test suite,
or until they are reset or updated by using expectation keywords again.
On the test suite level (suite setup), t... |
*Sends a GET request to the endpoint.*
The endpoint is joined with the URL given on library init (if any).
If endpoint starts with ``http://`` or ``https://``, it is assumed
an URL outside the tested API (which may affect logging).
*Options*
``query``: Request query parameters... | def get(
self,
endpoint,
query=None,
timeout=None,
allow_redirects=None,
validate=True,
headers=None,
):
"""*Sends a GET request to the endpoint.*
The endpoint is joined with the URL given on library init (if any).
If endpoint starts w... |
*Sends a POST request to the endpoint.*
The endpoint is joined with the URL given on library init (if any).
If endpoint starts with ``http://`` or ``https://``, it is assumed
an URL outside the tested API (which may affect logging).
*Options*
``body``: Request body parameters ... | def post(
self,
endpoint,
body=None,
timeout=None,
allow_redirects=None,
validate=True,
headers=None,
):
"""*Sends a POST request to the endpoint.*
The endpoint is joined with the URL given on library init (if any).
If endpoint starts ... |
*Sends a DELETE request to the endpoint.*
The endpoint is joined with the URL given on library init (if any).
If endpoint starts with ``http://`` or ``https://``, it is assumed
an URL outside the tested API (which may affect logging).
*Options*
``timeout``: A number of seconds... | def delete(
self,
endpoint,
timeout=None,
allow_redirects=None,
validate=True,
headers=None,
):
"""*Sends a DELETE request to the endpoint.*
The endpoint is joined with the URL given on library init (if any).
If endpoint starts with ``http://`... |
*Asserts the field does not exist.*
The field consists of parts separated by spaces, the parts being
object property names or array indices starting from 0, and the root
being the instance created by the last request (see `Output` for it).
For asserting deeply nested properties or mult... | def missing(self, field):
"""*Asserts the field does not exist.*
The field consists of parts separated by spaces, the parts being
object property names or array indices starting from 0, and the root
being the instance created by the last request (see `Output` for it).
For asser... |
*Asserts the field as JSON null.*
The field consists of parts separated by spaces, the parts being
object property names or array indices starting from 0, and the root
being the instance created by the last request (see `Output` for it).
For asserting deeply nested properties or multip... | def null(self, field, **validations):
"""*Asserts the field as JSON null.*
The field consists of parts separated by spaces, the parts being
object property names or array indices starting from 0, and the root
being the instance created by the last request (see `Output` for it).
... |
*Asserts the field as JSON boolean.*
The field consists of parts separated by spaces, the parts being
object property names or array indices starting from 0, and the root
being the instance created by the last request (see `Output` for it).
For asserting deeply nested properties or mul... | def boolean(self, field, value=None, **validations):
"""*Asserts the field as JSON boolean.*
The field consists of parts separated by spaces, the parts being
object property names or array indices starting from 0, and the root
being the instance created by the last request (see `Output`... |
*Asserts the field as JSON integer.*
The field consists of parts separated by spaces, the parts being
object property names or array indices starting from 0, and the root
being the instance created by the last request (see `Output` for it).
For asserting deeply nested properties or mul... | def integer(self, field, *enum, **validations):
"""*Asserts the field as JSON integer.*
The field consists of parts separated by spaces, the parts being
object property names or array indices starting from 0, and the root
being the instance created by the last request (see `Output` for ... |
*Converts the input to JSON and returns it.*
Any of the following is accepted:
- The path to JSON file
- Any scalar that can be interpreted as JSON
- A dictionary or a list
*Examples*
| ${payload} | `Input` | ${CURDIR}/payload.json |
| ${object} | `Input` | {... | def input(self, what):
"""*Converts the input to JSON and returns it.*
Any of the following is accepted:
- The path to JSON file
- Any scalar that can be interpreted as JSON
- A dictionary or a list
*Examples*
| ${payload} | `Input` | ${CURDIR}/payload.json |
... |
*Outputs JSON Schema to terminal or a file.*
By default, the schema is output for the last request and response.
The output can be limited further by:
- The property of the last instance, e.g. ``request`` or ``response``
- Any nested property that exists, similarly as for assertion ke... | def output_schema(
self, what="", file_path=None, append=False, sort_keys=False
):
"""*Outputs JSON Schema to terminal or a file.*
By default, the schema is output for the last request and response.
The output can be limited further by:
- The property of the last instance,... |
*Writes the instances as JSON to a file.*
The instances are written to file as a JSON array of JSON objects,
each object representing a single instance, and having three properties:
- the request
- the response
- the schema for both, which have been updated according to the tes... | def rest_instances(self, file_path=None, sort_keys=False):
"""*Writes the instances as JSON to a file.*
The instances are written to file as a JSON array of JSON objects,
each object representing a single instance, and having three properties:
- the request
- the response
... |
Adds tools from self.toolbardata to self | def add_tools(self):
"""Adds tools from self.toolbardata to self"""
for data in self.toolbardata:
# tool type is in data[0]
if data[0] == "T":
# Simple tool
_, msg_type, label, tool_tip = data
icon = icons[label]
... |
Toolbar event handler | def OnTool(self, event):
"""Toolbar event handler"""
msgtype = self.ids_msgs[event.GetId()]
post_command_event(self, msgtype) |
Tool event handler | def OnToggleTool(self, event):
"""Tool event handler"""
config["check_spelling"] = str(event.IsChecked())
toggle_id = self.parent.menubar.FindMenuItem(_("View"),
_("Check spelling"))
if toggle_id != -1:
# Check may fail if... |
Updates the toolbar states | def OnUpdate(self, event):
"""Updates the toolbar states"""
# Gray out undo and redo id not available
undo_toolid = self.label2id["Undo"]
redo_toolid = self.label2id["Redo"]
self.EnableTool(undo_toolid, undo.stack().canundo())
self.EnableTool(redo_toolid, undo.stack().... |
Gets Button label from user and returns string | def _get_button_label(self):
"""Gets Button label from user and returns string"""
dlg = wx.TextEntryDialog(self, _('Button label:'))
if dlg.ShowModal() == wx.ID_OK:
label = dlg.GetValue()
else:
label = ""
dlg.Destroy()
return label |
Event handler for cell button toggle button | def OnButtonCell(self, event):
"""Event handler for cell button toggle button"""
if self.button_cell_button_id == event.GetId():
if event.IsChecked():
label = self._get_button_label()
post_command_event(self, self.ButtonCellMsg, text=label)
else:
... |
Event handler for video cell toggle button | def OnVideoCell(self, event):
"""Event handler for video cell toggle button"""
if self.video_cell_button_id == event.GetId():
if event.IsChecked():
wildcard = _("Media files") + " (*.*)|*.*"
videofile, __ = self.get_filepath_findex_from_user(
... |
Updates the toolbar states | def OnUpdate(self, event):
"""Updates the toolbar states"""
attributes = event.attr
self._update_buttoncell(attributes["button_cell"])
self.Refresh()
event.Skip() |
Creates the search menu | def make_menu(self):
"""Creates the search menu"""
menu = wx.Menu()
item = menu.Append(-1, "Recent Searches")
item.Enable(False)
for __id, txt in enumerate(self.search_history):
menu.Append(__id, txt)
return menu |
Search history has been selected | def OnMenu(self, event):
"""Search history has been selected"""
__id = event.GetId()
try:
menuitem = event.GetEventObject().FindItemById(__id)
selected_text = menuitem.GetItemLabel()
self.search.SetValue(selected_text)
except AttributeError:
... |
Event handler for starting the search | def OnSearch(self, event):
"""Event handler for starting the search"""
search_string = self.search.GetValue()
if search_string not in self.search_history:
self.search_history.append(search_string)
if len(self.search_history) > 10:
self.search_history.pop(0)
... |
Event handler for search direction toggle button | def OnSearchDirectionButton(self, event):
"""Event handler for search direction toggle button"""
if "DOWN" in self.search_options:
flag_index = self.search_options.index("DOWN")
self.search_options[flag_index] = "UP"
elif "UP" in self.search_options:
flag_ind... |
Event handler for search flag toggle buttons | def OnSearchFlag(self, event):
"""Event handler for search flag toggle buttons"""
for label in self.search_options_buttons:
button_id = self.label2id[label]
if button_id == event.GetId():
if event.IsChecked():
self.search_options.append(label)... |
Creates font choice combo box | def _create_font_choice_combo(self):
"""Creates font choice combo box"""
self.fonts = get_font_list()
self.font_choice_combo = \
_widgets.FontChoiceCombobox(self, choices=self.fonts,
style=wx.CB_READONLY, size=(125, -1))
self.font_cho... |
Creates font size combo box | def _create_font_size_combo(self):
"""Creates font size combo box"""
self.std_font_sizes = config["font_default_sizes"]
font_size = str(get_default_font().GetPointSize())
self.font_size_combo = \
wx.ComboBox(self, -1, value=font_size, size=(60, -1),
c... |
Creates font face buttons | def _create_font_face_buttons(self):
"""Creates font face buttons"""
font_face_buttons = [
(wx.FONTFLAG_BOLD, "OnBold", "FormatTextBold", _("Bold")),
(wx.FONTFLAG_ITALIC, "OnItalics", "FormatTextItalic",
_("Italics")),
(wx.FONTFLAG_UNDERLINED, "OnUnderli... |
Create text rotation toggle button | def _create_textrotation_button(self):
"""Create text rotation toggle button"""
iconnames = ["TextRotate270", "TextRotate0", "TextRotate90",
"TextRotate180"]
bmplist = [icons[iconname] for iconname in iconnames]
self.rotation_tb = _widgets.BitmapToggleButton(self, ... |
Creates horizontal justification button | def _create_justification_button(self):
"""Creates horizontal justification button"""
iconnames = ["JustifyLeft", "JustifyCenter", "JustifyRight"]
bmplist = [icons[iconname] for iconname in iconnames]
self.justify_tb = _widgets.BitmapToggleButton(self, bmplist)
self.justify_tb.S... |
Creates vertical alignment button | def _create_alignment_button(self):
"""Creates vertical alignment button"""
iconnames = ["AlignTop", "AlignCenter", "AlignBottom"]
bmplist = [icons[iconname] for iconname in iconnames]
self.alignment_tb = _widgets.BitmapToggleButton(self, bmplist)
self.alignment_tb.SetToolTipSt... |
Create border choice combo box | def _create_borderchoice_combo(self):
"""Create border choice combo box"""
choices = [c[0] for c in self.border_toggles]
self.borderchoice_combo = \
_widgets.BorderEditChoice(self, choices=choices,
style=wx.CB_READONLY, size=(50, -1))
s... |
Create pen width combo box | def _create_penwidth_combo(self):
"""Create pen width combo box"""
choices = map(unicode, xrange(12))
self.pen_width_combo = \
_widgets.PenWidthComboBox(self, choices=choices,
style=wx.CB_READONLY, size=(50, -1))
self.pen_width_combo.Se... |
Create color choice buttons | def _create_color_buttons(self):
"""Create color choice buttons"""
button_size = (30, 30)
button_style = wx.NO_BORDER
try:
self.linecolor_choice = \
csel.ColourSelect(self, -1, unichr(0x2500), (0, 0, 0),
size=button_size, st... |
Create merge button | def _create_merge_button(self):
"""Create merge button"""
bmp = icons["Merge"]
self.mergetool_id = wx.NewId()
self.AddCheckTool(self.mergetool_id, "Merge", bmp, bmp,
short_help_string=_("Merge cells"))
self.Bind(wx.EVT_TOOL, self.OnMerge, id=self.merget... |
Updates text font widget
Parameters
----------
textfont: String
\tFont name | def _update_font(self, textfont):
"""Updates text font widget
Parameters
----------
textfont: String
\tFont name
"""
try:
fontface_id = self.fonts.index(textfont)
except ValueError:
fontface_id = 0
self.font_choice_comb... |
Updates font weight widget
Parameters
----------
font_weight: Integer
\tButton down iif font_weight == wx.FONTWEIGHT_BOLD | def _update_font_weight(self, font_weight):
"""Updates font weight widget
Parameters
----------
font_weight: Integer
\tButton down iif font_weight == wx.FONTWEIGHT_BOLD
"""
toggle_state = font_weight & wx.FONTWEIGHT_BOLD == wx.FONTWEIGHT_BOLD
self.Tog... |
Updates font style widget
Parameters
----------
font_style: Integer
\tButton down iif font_style == wx.FONTSTYLE_ITALIC | def _update_font_style(self, font_style):
"""Updates font style widget
Parameters
----------
font_style: Integer
\tButton down iif font_style == wx.FONTSTYLE_ITALIC
"""
toggle_state = font_style & wx.FONTSTYLE_ITALIC == wx.FONTSTYLE_ITALIC
self.Toggle... |
Updates frozen cell widget
Parameters
----------
frozen: Bool or string
\tUntoggled iif False | def _update_frozencell(self, frozen):
"""Updates frozen cell widget
Parameters
----------
frozen: Bool or string
\tUntoggled iif False
"""
toggle_state = frozen is not False
self.ToggleTool(wx.FONTFLAG_MASK, toggle_state) |
Updates text rotation toggle button | def _update_textrotation(self, angle):
"""Updates text rotation toggle button"""
states = {0: 0, -90: 1, 180: 2, 90: 3}
try:
self.rotation_tb.state = states[round(angle)]
except KeyError:
self.rotation_tb.state = 0
self.rotation_tb.toggle(None)
... |
Updates horizontal text justification button
Parameters
----------
justification: String in ["left", "center", "right"]
\tSwitches button to untoggled if False and toggled if True | def _update_justification(self, justification):
"""Updates horizontal text justification button
Parameters
----------
justification: String in ["left", "center", "right"]
\tSwitches button to untoggled if False and toggled if True
"""
states = {"left": 2, "cen... |
Updates vertical text alignment button
Parameters
----------
alignment: String in ["top", "middle", "right"]
\tSwitches button to untoggled if False and toggled if True | def _update_alignment(self, alignment):
"""Updates vertical text alignment button
Parameters
----------
alignment: String in ["top", "middle", "right"]
\tSwitches button to untoggled if False and toggled if True
"""
states = {"top": 2, "middle": 0, "bottom": 1... |
Updates text font color button
Parameters
----------
fontcolor: Integer
\tText color in integer RGB format | def _update_fontcolor(self, fontcolor):
"""Updates text font color button
Parameters
----------
fontcolor: Integer
\tText color in integer RGB format
"""
textcolor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)
textcolor.SetRGB(fontcolor)
... |
Updates background color | def _update_bgbrush(self, bgcolor):
"""Updates background color"""
brush_color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)
brush_color.SetRGB(bgcolor)
self.bgcolor_choice.SetColour(brush_color) |
Updates background color | def _update_bordercolor(self, bordercolor):
"""Updates background color"""
border_color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_ACTIVEBORDER)
border_color.SetRGB(bordercolor)
self.linecolor_choice.SetColour(border_color) |
Updates the toolbar states | def OnUpdate(self, event):
"""Updates the toolbar states"""
attributes = event.attr
self._update_font(attributes["textfont"])
self._update_pointsize(attributes["pointsize"])
self._update_font_weight(attributes["fontweight"])
self._update_font_style(attributes["fontstyle... |
Change the borders that are affected by color and width changes | def OnBorderChoice(self, event):
"""Change the borders that are affected by color and width changes"""
choicelist = event.GetEventObject().GetItems()
self.borderstate = choicelist[event.GetInt()] |
Line width choice event handler | def OnLineWidth(self, event):
"""Line width choice event handler"""
linewidth_combobox = event.GetEventObject()
idx = event.GetInt()
width = int(linewidth_combobox.GetString(idx))
borders = self.bordermap[self.borderstate]
post_command_event(self, self.BorderWidthMsg, w... |
Line color choice event handler | def OnLineColor(self, event):
"""Line color choice event handler"""
color = event.GetValue().GetRGB()
borders = self.bordermap[self.borderstate]
post_command_event(self, self.BorderColorMsg, color=color,
borders=borders) |
Background color choice event handler | def OnBGColor(self, event):
"""Background color choice event handler"""
color = event.GetValue().GetRGB()
post_command_event(self, self.BackgroundColorMsg, color=color) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.