Best Python code snippet using Airtest
update_point.py
Source:update_point.py
1from ...utilities import utils_func2def get_idx(number_of_similar_unit):3 number_of_similar_unit = int(number_of_similar_unit)4 if number_of_similar_unit == 0:5 return 06 elif number_of_similar_unit in [1, 2]:7 return 18 elif number_of_similar_unit in [3, 4, 5]:9 return 210 elif number_of_similar_unit > 5:11 return 312 return 013def update_alluvial_fan(data_set):14 curve_name = "Alluvial_Fan"15 if data_set[curve_name] == 0:16 return 017 points = [-1, 0, 2, 3]18 return utils_func.handle_addition(19 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))20def update_fluvial_channel(data_set):21 curve_name = "Fluvial_Channel"22 if data_set[curve_name] == 0:23 return 024 points = [-2, 0, 2, 3]25 return utils_func.handle_addition(26 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))27def update_fluvial_point_bar(data_set):28 curve_name = "Fluvial_Point_Bar"29 if data_set[curve_name] == 0:30 return 031 points = [-2, 0, 2, 3]32 return utils_func.handle_addition(33 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))34def update_levee(data_set):35 curve_name = "Levee"36 if data_set[curve_name] == 0:37 return 038 points = [-1, 1, 2, 3]39 return utils_func.handle_addition(40 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))41def update_crevasse_splay(data_set):42 curve_name = "Crevasse_Splay"43 if data_set[curve_name] == 0:44 return 045 points = [-1, 1, 2, 3]46 return utils_func.handle_addition(47 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))48def update_fluvial_floodplain(data_set):49 curve_name = "Fluvial_Floodplain"50 if data_set[curve_name] == 0:51 return 052 points = [-3, 0, 2, 3]53 return utils_func.handle_addition(54 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))55def update_progradational_lacustrine_delta(data_set):56 curve_name = "Progradational_Lacustrine_Delta"57 if data_set[curve_name] == 0:58 return 059 points = [-3, 0, 2, 3]60 return utils_func.handle_addition(61 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))62def update_lacustrine_fan_delta(data_set):63 curve_name = "Lacustrine_Fan_Delta"64 if data_set[curve_name] == 0:65 return 066 points = [-2, 0, 2, 3]67 return utils_func.handle_addition(68 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))69def update_progradational_lacustrine_shoreface(data_set):70 curve_name = "Progradational_Lacustrine_Shoreface"71 if data_set[curve_name] == 0:72 return 073 points = [-2, 0, 2, 3]74 return utils_func.handle_addition(75 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))76def update_transgressive_lacustrine_shoreface(data_set):77 curve_name = "Transgressive_Lacustrine_Shoreface"78 if data_set[curve_name] == 0:79 return 080 points = [-1, 1, 2, 3]81 return utils_func.handle_addition(82 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))83def update_aggradational_lacustrine_shoreface(data_set):84 curve_name = "Aggradational_Lacustrine_Shoreface"85 if data_set[curve_name] == 0:86 return 087 points = [-2, 1, 2, 3]88 return utils_func.handle_addition(89 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))90def update_lacustrine_offshore_transition(data_set):91 curve_name = "Lacustrine_Offshore_Transition"92 if data_set[curve_name] == 0:93 return 094 points = [-1, 1, 2, 3]95 return utils_func.handle_addition(96 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))97def update_lacustrine_shelf(data_set):98 curve_name = "Lacustrine_Shelf"99 if data_set[curve_name] == 0:100 return 0101 points = [-2, 0, 2, 3]102 return utils_func.handle_addition(103 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))104def update_proximal_sub_lacustrine_fan(data_set):105 curve_name = "Proximal_Sub-Lacustrine_Fan"106 if data_set[curve_name] == 0:107 return 0108 points = [-1, 0, 2, 3]109 return utils_func.handle_addition(110 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))111def update_distal_sub_lacustrine_fan(data_set):112 curve_name = "Distal_Sub-Lacustrine_Fan"113 if data_set[curve_name] == 0:114 return 0115 points = [-1, 0, 2, 3]116 return utils_func.handle_addition(117 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))118def update_lacustrine_turbidite(data_set):119 curve_name = "Lacustrine_Turbidite"120 if data_set[curve_name] == 0:121 return 0122 points = [-2, 1, 2, 3]123 return utils_func.handle_addition(124 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))125def update_distal_lacustrine_turbidites(data_set):126 curve_name = "Distal_Lacustrine_Turbidites"127 if data_set[curve_name] == 0:128 return 0129 points = [-2, 0, 2, 3]130 return utils_func.handle_addition(131 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))132def update_lacustrine_deepwater(data_set):133 curve_name = "Lacustrine_Deepwater"134 if data_set[curve_name] == 0:135 return 0136 points = [-3, 0, 2, 3]137 return utils_func.handle_addition(138 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))139def update_marine_delta(data_set):140 curve_name = "Marine_Delta"141 if data_set[curve_name] == 0:142 return 0143 points = [-3, 0, 2, 3]144 return utils_func.handle_addition(145 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))146def update_marine_fan_delta(data_set):147 curve_name = "Marine_Fan_Delta"148 if data_set[curve_name] == 0:149 return 0150 points = [-2, 0, 2, 3]151 return utils_func.handle_addition(152 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))153def update_tidal_channel_and_sand_flat(data_set):154 curve_name = "Tidal_Channel_And_Sand_Flat"155 if data_set[curve_name] == 0:156 return 0157 points = [-1, 1, 2, 3]158 return utils_func.handle_addition(159 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))160def update_sandy_tidal_flat(data_set):161 curve_name = "Sandy_Tidal_Flat"162 if data_set[curve_name] == 0:163 return 0164 points = [-1, 1, 2, 3]165 return utils_func.handle_addition(166 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))167def update_mixed_tidal_flat(data_set):168 curve_name = "Mixed_Tidal_Flat"169 if data_set[curve_name] == 0:170 return 0171 points = [-1, 1, 2, 3]172 return utils_func.handle_addition(173 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))174def update_muddy_tidal_flat(data_set):175 curve_name = "Muddy_Tidal_Flat"176 if data_set[curve_name] == 0:177 return 0178 points = [-1, 1, 2, 3]179 return utils_func.handle_addition(180 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))181def update_lagoon(data_set):182 curve_name = "Lagoon"183 if data_set[curve_name] == 0:184 return 0185 points = [-2, 0, 2, 3]186 return utils_func.handle_addition(187 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))188def update_progradational_marine_shoreface(data_set):189 curve_name = "Progradational_Marine_Shoreface"190 if data_set[curve_name] == 0:191 return 0192 points = [-2, 0, 2, 3]193 return utils_func.handle_addition(194 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))195def update_transgressive_marine_shoreface(data_set):196 curve_name = "Transgressive_Marine_Shoreface"197 if data_set[curve_name] == 0:198 return 0199 points = [-1, 1, 2, 3]200 return utils_func.handle_addition(201 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))202def update_aggradational_marine_shoreface(data_set):203 curve_name = "Aggradational_Marine_Shoreface"204 if data_set[curve_name] == 0:205 return 0206 points = [-2, 1, 2, 3]207 return utils_func.handle_addition(208 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))209def update_marine_offshore_transition(data_set):210 curve_name = "Marine_Offshore_Transition"211 if data_set[curve_name] == 0:212 return 0213 points = [-1, 1, 2, 3]214 return utils_func.handle_addition(215 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))216def update_marine_shelf(data_set):217 curve_name = "Marine_Shelf"218 if data_set[curve_name] == 0:219 return 0220 points = [-2, 0, 2, 3]221 return utils_func.handle_addition(222 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))223def update_proximal_submarine_fan(data_set):224 curve_name = "Proximal_Submarine_Fan"225 if data_set[curve_name] == 0:226 return 0227 points = [-1, 0, 2, 3]228 return utils_func.handle_addition(229 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))230def update_distal_submarine_fan(data_set):231 curve_name = "Distal_Submarine_Fan"232 if data_set[curve_name] == 0:233 return 0234 points = [-1, 0, 2, 3]235 return utils_func.handle_addition(236 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))237def update_marine_turbidite(data_set):238 curve_name = "Marine_Turbidite"239 if data_set[curve_name] == 0:240 return 0241 points = [-2, 1, 2, 3]242 return utils_func.handle_addition(243 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))244def update_distal_marine_turbidites(data_set):245 curve_name = "Distal_Marine_Turbidites"246 if data_set[curve_name] == 0:247 return 0248 points = [-2, 0, 2, 3]249 return utils_func.handle_addition(250 points[get_idx(data_set["Lateral_proximity"])] + int(data_set[curve_name]))251def update_marine_deepwater(data_set):252 curve_name = "Marine_Deepwater"253 if data_set[curve_name] == 0:254 return 0255 points = [-3, 0, 2, 3]256 return utils_func.handle_addition(...
Tree_code_all.py
Source:Tree_code_all.py
...13 for child in root.children:14 if child.value == "DT" or child.value == "NP" or child.value == "PRP$" or child.value == "PRP":15 valid = False16 if valid:17 idx_list.append(self.get_idx(root))18 for child in root.children:19 self.find_det_ins(child, idx_list)20 def find_sng_nouns(self, root, idx_list):21 if root.value == "NN":22 idx_list.append(self.get_idx(root))23 for child in root.children:24 self.find_sng_nouns(child, idx_list)25 def find_pl_noun(self, root, idx_list):26 if root.value == "NNS":27 idx_list.append(self.get_idx(root))28 for child in root.children:29 self.find_pl_noun(child, idx_list)30 def find_prep_ins(self, root, idx_list):31 if root.value == "VP":32 for child in root.children:33 if child.value == "NP":34 idx_list.append(self.get_idx(child))35 for child in root.children:36 self.find_prep_ins(child, idx_list)37 def find_worder(self, root, idx_list):38 if root.value == "VP":39 if (root.children[0].value == "MD" or "VB" in root.children[0].value) and (root.children[1].value == "ADVP" or root.children[1].value == "ADVJ"):40 idx_list.append(self.get_idx(root.children[0]))41 for child in root.children:42 self.find_worder(child, idx_list)43 def find_advp(self, root, idx_list):44 if root.value == "ADVP":45 if len(root.children) == 1 and root.children[0].value == "RB" and not self.get_idx(root) == 0:46 idx_list.append(self.get_idx(root.children[0]))47 if len(root.children) == 2 and root.children[0].value in ["RBR", "RBS"]:48 idx_list.append(self.get_idx(root.children[0]))49 if root.value == "ADJP":50 if len(root.children) == 2 and root.children[0].value in ["RBR", "RBS"]:51 idx_list.append(self.get_idx(root.children[0]))52 if root.children[1] == "JJ" and root.children[0] == "RB":53 idx_list.append(self.get_idx(root.children[0]))54 if root.children[0] == "JJ" and root.children[1] == "RB":55 idx_list.append(self.get_idx(root.children[0]))56 if root.children[0] == "RB" and "VB" in root.children[1]:57 idx_list.append(self.get_idx(root.children[0]))58 for child in root.children:59 self.find_advp(child, idx_list)60 def find_verb(self, root, idx_list):61 if root.value == "VB" or root.value == "VBZ" or root.value == "VBP" or root.value == "VBD" or root.value == "VBN" or root.value == "VBG":62 idx_list.append(self.get_idx(root))63 for child in root.children:64 self.find_verb(child, idx_list)65 def find_wform(self, root, idx_list):66 if root.value == "JJ" or root.value == "VB" or root.value == "VBZ" or root.value == "VBP" or root.value == "VBD" or root.value == "VBN" or root.value == "VBG":67 idx_list.append(self.get_idx(root))68 for child in root.children:69 self.find_wform(child, idx_list)70 def find_3sg(self, root, idx_list):71 if root.value == "VBZ":72 idx_list.append(self.get_idx(root))73 for child in root.children:74 self.find_3sg(child, idx_list)75 def find_n3sg(self, root, idx_list):76 if root.value == "VBP" or root.value == "VB":77 idx_list.append(self.get_idx(root))78 for child in root.children:79 self.find_n3sg(child, idx_list)80 def get_idx(self, root):81 if len(root.children):82 return self.get_idx(root.children[0])83 else:...
0316_remove_duplicate_letters_medium.py
Source:0316_remove_duplicate_letters_medium.py
1class Solution:2 def removeDuplicateLetters(self, s: str) -> str:3 def get_idx(c: str) -> int:4 return ord(c) - ord('a')5 count = [0] * 266 used = [False] * 267 for c in s:8 count[get_idx(c)] += 19 res = []10 for c in s:11 count[get_idx(c)] -= 112 if used[get_idx(c)]:13 continue14 while res and c < res[-1] and count[get_idx(res[-1])] > 0:15 used[get_idx(res[-1])] = False16 res.pop()17 res.append(c)18 used[get_idx(c)] = True...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!