How to use score_function method in hypothesis

Best Python code snippet using hypothesis

needlemanWunschN3.py

Source:needlemanWunschN3.py Github

copy

Full Screen

...43 for k in range(len(self.sequence_a) + 1)]44 # initalize matrix45 for i in range(1, len(self.sequence_a) + 1):46 self.computation_matrix[i][0][0] = self.computation_matrix[i - 1][0][0] \47 + self.score_function("", "", self.sequence_a[i - 1])48 for i in range(1, len(self.sequence_b) + 1):49 self.computation_matrix[0][i][0] = self.computation_matrix[0][i - 1][0] \50 + self.score_function("", "", self.sequence_b[i - 1])51 for i in range(1, len(self.sequence_c) + 1):52 self.computation_matrix[0][0][i] = self.computation_matrix[0][0][i - 1] \53 + self.score_function("", "", self.sequence_c[i - 1])54 for i in range(1, len(self.sequence_a) + 1):55 for j in range(1, len(self.sequence_b) + 1):56 self.computation_matrix[i][j][0] = self.computation_matrix[i - 1][j - 1][0] \57 + self.score_function(self.sequence_a[i - 1], self.sequence_b[j - 1],58 "")59 for i in range(1, len(self.sequence_a) + 1):60 for k in range(1, len(self.sequence_c) + 1):61 self.computation_matrix[i][0][k] = self.computation_matrix[i - 1][0][k - 1] \62 + self.score_function(self.sequence_a[i - 1], "",63 self.sequence_c[k - 1])64 for j in range(1, len(self.sequence_b) + 1):65 for k in range(1, len(self.sequence_c) + 1):66 self.computation_matrix[0][j][k] = self.computation_matrix[0][j - 1][k - 1] \67 + self.score_function("", self.sequence_b[j - 1],68 self.sequence_c[k - 1])69 for i in range(1, len(self.sequence_a) + 1):70 for j in range(1, len(self.sequence_b) + 1):71 for k in range(1, len(self.sequence_c) + 1):72 self.computation_matrix[i][j][k] = self.compute_minimum(i, j, k)73 def compute_minimum(self, i, j, k):74 """Compute the minimal value for a given cell of the matrix.75 The minimum is choosen of the following values:76 D(i-1, j-1, k-1) + w(a_i-1, b_j-1, c_k-1)77 D(i, j-1, k-1) + w(a_i, b_j-1, c_k-1)78 D(i-1, j, k-1) + w(a_i-1, b_j, c_k-1)79 D(i-1, j-1, k) + w(a_i-1, b_j-1, c_k)80 D(i, j, k-1) + w(a_i, b_j, c_k-1)81 D(i-1, j, k) + w(a_i-1, b_j, c_k)82 D(i, j-1, k) + w(a_i, b_j-1, c_k)83 i: index of sequence A84 j: index of sequence B85 k: index of sequence C86 """87 # no gap88 no_gap = self.computation_matrix[i - 1][j - 1][k - 1] \89 + self.score_function(self.sequence_a[i - 1], self.sequence_b[j - 1], self.sequence_c[k - 1])90 # one gap91 gap_a = self.computation_matrix[i][j - 1][k - 1] \92 + self.score_function("", self.sequence_b[j - 1], self.sequence_c[k - 1])93 gap_b = self.computation_matrix[i - 1][j][k - 1] \94 + self.score_function(self.sequence_a[i - 1], "", self.sequence_c[k - 1])95 gap_c = self.computation_matrix[i - 1][j - 1][k] \96 + self.score_function(self.sequence_a[i - 1], self.sequence_b[j - 1], "")97 # two gaps98 gap_ab = self.computation_matrix[i][j][k - 1] + self.score_function("", "", self.sequence_c[k - 1])99 gap_bc = self.computation_matrix[i - 1][j][k] + self.score_function(self.sequence_a[i - 1], "", "")100 gap_ac = self.computation_matrix[i][j - 1][k] + self.score_function("", self.sequence_b[j - 1], "")101 possible_values = [no_gap, gap_a, gap_b, gap_c, gap_ab, gap_bc, gap_ac]102 return min(possible_values)103 def traceback(self, maximal_optimal_solutions=-1):104 """Computes the traceback for the Needleman-Wunsch n=3 matrix."""105 self.traceback_stack = [[]]106 self.indices_stack = [[len(self.computation_matrix) - 1, len(self.computation_matrix[0]) - 1,107 len(self.computation_matrix[0][0]) - 1]]108 self.traceback_stack_index = 0109 traceback_done = False110 optimal_solutions_count = 0111 while not traceback_done:112 i = self.indices_stack[self.traceback_stack_index][0]113 j = self.indices_stack[self.traceback_stack_index][1]114 k = self.indices_stack[self.traceback_stack_index][2]115 optimal_solutions_count += 1116 split = False117 while i > 0 or j > 0 or k > 0:118 path_variable_i = i119 path_variable_j = j120 path_variable_k = k121 # no gap122 if i > 0 and j > 0 and k > 0:123 if self.computation_matrix[i][j][k] == self.computation_matrix[i - 1][j - 1][k - 1] \124 + self.score_function(self.sequence_a[i - 1], self.sequence_b[j - 1],125 self.sequence_c[k - 1]):126 self.traceback_stack[self.traceback_stack_index].append(mah.noGap)127 path_variable_i -= 1 # change i128 path_variable_j -= 1 # change j129 path_variable_k -= 1 # change k130 split = True131 # a gap in sequence a132 if j > 0 and k > 0:133 if self.computation_matrix[i][j][k] == self.computation_matrix[i][j - 1][k - 1] \134 + self.score_function("", self.sequence_b[j - 1], self.sequence_c[k - 1]):135 if split == False:136 self.traceback_stack[self.traceback_stack_index].append(mah.gapA)137 path_variable_j -= 1138 path_variable_k -= 1139 split = True140 else:141 self.split([i, j - 1, k - 1], mah.gapA)142 # a gap in sequence b143 if i > 0 and k > 0:144 if self.computation_matrix[i][j][k] == self.computation_matrix[i - 1][j][k - 1] \145 + self.score_function(self.sequence_a[i - 1], "", self.sequence_c[k - 1]):146 if split == False:147 self.traceback_stack[self.traceback_stack_index].append(mah.gapB)148 path_variable_i -= 1149 path_variable_k -= 1150 elif split == True:151 self.split([i - 1, j, k - 1], mah.gapB)152 # a gap in sequence c153 if i > 0 and j > 0:154 if self.computation_matrix[i][j][k] == self.computation_matrix[i - 1][j - 1][k] \155 + self.score_function(self.sequence_a[i - 1], self.sequence_b[j - 1], ""):156 if split == False:157 self.traceback_stack[self.traceback_stack_index].append(mah.gapC)158 path_variable_i -= 1159 path_variable_j -= 1160 elif split == True:161 self.split([i - 1, j - 1, k], mah.gapC)162 # a gap in sequence a and b163 if k > 0:164 if self.computation_matrix[i][j][k] == self.computation_matrix[i][j][k - 1] \165 + self.score_function("", "", self.sequence_c[k - 1]):166 if split == False:167 self.traceback_stack[self.traceback_stack_index].append(mah.gapAB)168 path_variable_k -= 1169 elif split == True:170 self.split([i, j, k - 1], mah.gapAB)171 # a gap in sequence a and c172 if j > 0:173 if self.computation_matrix[i][j][k] == self.computation_matrix[i][j - 1][k] \174 + self.score_function("", self.sequence_b[j - 1], ""):175 if split == False:176 self.traceback_stack[self.traceback_stack_index].append(mah.gapAC)177 path_variable_j -= 1178 elif split == True:179 self.split([i, j - 1, k], mah.gapAC)180 # a gap in sequence b and c181 if i > 0:182 if self.computation_matrix[i][j][k] == self.computation_matrix[i - 1][j][k] \183 + self.score_function(self.sequence_a[i - 1], "", ""):184 if split == False:185 self.traceback_stack[self.traceback_stack_index].append(mah.gapBC)186 path_variable_i -= 1187 elif split == True:188 self.split([i - 1, j, k], mah.gapBC)189 split = False190 i = path_variable_i191 j = path_variable_j192 k = path_variable_k193 if maximal_optimal_solutions != -1 and optimal_solutions_count >= maximal_optimal_solutions:194 break195 self.indices_stack[self.traceback_stack_index][0] = i196 self.indices_stack[self.traceback_stack_index][1] = j197 self.indices_stack[self.traceback_stack_index][2] = k...

Full Screen

Full Screen

06.py

Source:06.py Github

copy

Full Screen

...5 {6 'cases': [7 {8 'code': r"""9 >>> score_function("speling", "spelling")10 111 >>> score_function("used", "use")12 113 >>> score_function("misspelled", "spelling")14 615 >>> score_function("spelling", "spelling")16 017 >>> score_function("wird", "bird")18 119 >>> score_function("wird", "wire")20 121 """,22 'hidden': False,23 'locked': False24 },25 {26 'code': r"""27 >>> score_function("hello", "goodbye")28 729 >>> score_function("ate", "apple")30 331 >>> score_function("from", "form")32 233 >>> score_function("first", "flashy")34 435 >>> score_function("hash", "ash")36 137 >>> score_function("ash", "hash")38 139 """,40 'hidden': False,41 'locked': False42 },43 {44 'code': r"""45 >>> small_words_list = ["spell", "nest", "test", "pest", "best", "bird", "wired",46 ... "abstraction", "abstract", "peeling", "gestate", "west",47 ... "spelling", "bastion"]48 >>> autocorrect("speling", small_words_list, score_function)49 'spelling'50 >>> autocorrect("abstrction", small_words_list, score_function)51 'abstraction'...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1# flake8: noqa2# metric class3from deepchem.metrics.metric import Metric4# metrics utils5from deepchem.metrics.metric import threshold_predictions6from deepchem.metrics.metric import normalize_weight_shape7from deepchem.metrics.metric import normalize_labels_shape8from deepchem.metrics.metric import normalize_prediction_shape9from deepchem.metrics.metric import handle_classification_mode10from deepchem.metrics.metric import to_one_hot11from deepchem.metrics.metric import from_one_hot12# sklearn & scipy score function13from deepchem.metrics.score_function import matthews_corrcoef14from deepchem.metrics.score_function import recall_score15from deepchem.metrics.score_function import kappa_score16from deepchem.metrics.score_function import cohen_kappa_score17from deepchem.metrics.score_function import r2_score18from deepchem.metrics.score_function import mean_squared_error19from deepchem.metrics.score_function import mean_absolute_error20from deepchem.metrics.score_function import precision_score21from deepchem.metrics.score_function import precision_recall_curve22from deepchem.metrics.score_function import auc23from deepchem.metrics.score_function import jaccard_score24from deepchem.metrics.score_function import f1_score25from deepchem.metrics.score_function import roc_auc_score26from deepchem.metrics.score_function import accuracy_score27from deepchem.metrics.score_function import balanced_accuracy_score28from deepchem.metrics.score_function import top_k_accuracy_score29from deepchem.metrics.score_function import pearsonr30# original score function31from deepchem.metrics.score_function import pearson_r2_score32from deepchem.metrics.score_function import jaccard_index33from deepchem.metrics.score_function import pixel_error34from deepchem.metrics.score_function import prc_auc_score35from deepchem.metrics.score_function import rms_score36from deepchem.metrics.score_function import mae_score37from deepchem.metrics.score_function import bedroc_score...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful