Best Python code snippet using Airtest
sw_4014.py
Source:sw_4014.py
...13# 2 2 1 1 1 1 1 1 114# 2 2 1 1 1 1 1 1 115# 2 2 2 2 2 2 1 1 116# 3 3 3 3 2 2 2 2 117def setup_forward(i,j,next_height):18 global X19 global setup_check20 j=j21 check = True22 for x in range(X):23 if j+x < N and MAP[i][j+x] == next_height and setup_check[j+x] == False:24 setup_check[j+x] = True25 continue26 else:27 check = False28 return check29def setup_backward(i,j,cur_height):30 global X31 global setup_check32 j=j33 check = True34 for x in range(X):35 if 0 <= j-x and MAP[i][j-x] == cur_height and setup_check[j-x] == False:36 setup_check[j - x] = True37 continue38 else:39 check = False40 break41 return check42def simulate():43 global ans44 global X45 global MAP46 global setup_check47 #ê°ë¡ë°©í¥48 c = 049 for i in range(N):50 # print(MAP[i])51 setup_check = [False] * N52 cur_hight = MAP[i][0]53 j=154 while(True):55 if j == N:56 # print("íµê³¼~")57 c+=158 break59 next_hight = MAP[i][j]60 if abs(cur_hight-next_hight) > 1:61 break62 elif abs(cur_hight-next_hight) == 0:63 j += 164 elif abs(cur_hight-next_hight) == 1: # ëì´ì°¨ì´ 1~65 if cur_hight < next_hight:66 # ë¤ë¡ ì¤ë¥´ë§ê¸¸ ì¤ì¹67 if setup_backward(i, j-1, cur_hight):68 cur_hight = next_hight69 j += 170 else:71 break72 elif cur_hight > next_hight:73 # ìì¼ë¡ ë´ë¦¬ë§ê¸¸ ì¤ì¹74 if setup_forward(i, j, next_hight):75 cur_hight = next_hight76 j += 177 else:78 break79 MAP = list(zip(*MAP))80 for i in range(N):81 # print(MAP[i])82 setup_check = [False] * N83 cur_hight = MAP[i][0]84 j=185 while(True):86 if j == N:87 # print("íµê³¼~")88 c+=189 break90 next_hight = MAP[i][j]91 if abs(cur_hight-next_hight) > 1:92 break93 elif abs(cur_hight-next_hight) == 0:94 j += 195 elif abs(cur_hight-next_hight) == 1: # ëì´ì°¨ì´ 1~96 if cur_hight < next_hight:97 # ë¤ë¡ ì¤ë¥´ë§ê¸¸ ì¤ì¹98 if setup_backward(i, j-1, cur_hight):99 cur_hight = next_hight100 j += 1101 else:102 break103 elif cur_hight > next_hight:104 # ìì¼ë¡ ë´ë¦¬ë§ê¸¸ ì¤ì¹105 if setup_forward(i, j, next_hight):106 cur_hight = next_hight107 j += 1108 else:109 break110 ans = c111for t in range(1,T+1):112 N,X = list(map(int,input().split()))113 MAP = [list(map(int,input().split())) for _ in range(N)]114 setup_check = [False] * N115 ans = 0116 simulate()117 print("#",end="")...
medicine_tray.py
Source:medicine_tray.py
...4import json5config_file = open("../../config.json", 'r')6configuration = json.loads(config_file.read())["medicine_tray"]7print(configuration)8def setup_forward():9 # setting up the RaspberryPi modes10 gpio.setwarnings(False) # Ignore warning for now11 gpio.setmode(gpio.BCM) # Use physical pin numbering12 # setting up the motor 113 gpio.setup(configuration['motor_1_direction_pin'], gpio.OUT)14 gpio.setup(configuration['motor_1_step_pin'], gpio.OUT)15 gpio.output(configuration['motor_1_direction_pin'], configuration["direction_left"])16def setup_backward():17 # setting up the RaspberryPi modes18 gpio.setwarnings(False) # Ignore warning for now19 gpio.setmode(gpio.BCM) # Use physical pin numbering20 # setting up the motor 121 gpio.setup(configuration['motor_1_direction_pin'], gpio.OUT)22 gpio.setup(configuration['motor_1_step_pin'], gpio.OUT)23 gpio.output(configuration['motor_1_direction_pin'], configuration["direction_right"])24def motor_rotate():25 gpio.output(configuration['motor_1_step_pin'], gpio.HIGH)26 sleep(.001)27 gpio.output(configuration['motor_1_step_pin'], gpio.LOW)28 sleep(.001)29def cleanup():30 gpio.cleanup()31def run_program(steps, direction):32 if direction == 'forward':33 setup_forward()34 if direction == 'backward':35 setup_backward()36 print("setup completed")37 counter = 038 while counter < steps:39 motor_rotate()40 counter += 1...
make_bem_sol.py
Source:make_bem_sol.py
1from __future__ import print_function2import subprocess3import os4from my_settings import *5# subject = sys.argv[1]6cmd = "/usr/local/common/meeg-cfin/configurations/bin/submit_to_isis"7os.environ["SUBJECTS_DIR"] = subjects_dir8subjects = ["0008", "0009", "0010", "0011", "0012", "0013",9 "0014", "0015", "0016", "0017", "0018", "0019", "0020",10 "0021", "0022"]11for subject in subjects:12 setup_forward = "mne_setup_forward_model --subject %s --surf --ico -6" % (13 subject)...
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!!