Best Python code snippet using avocado_python
higgs_preprocessing.py
Source:higgs_preprocessing.py
...13test_open = open(test_file, 'w')14line = higgs_open.readline() # readline()读åä¸æ´è¡ï¼å
æ¬æåç'\n'15has_read = 016# higgsæ件29åï¼ç¬¬1åæ¯å±æ§(1-signal,0-background)ï¼åé¢28åæ¯ç¹å¾å¼17def write_one_line(tokens, file):18 label = float(tokens[0])19 file.write(str(label))20 for i in range(1, len(tokens)):21 feature_value = float(tokens[i])22 # libsvmæ°æ®æ ¼å¼: [label][index1]: [value1][index2]:[value2] â¦23 file.write(' ' + str(i - 1) + ':' + str(feature_value))24 file.write('\n')25while True:26 tokens = line.split(',')27 if not line: # 空ç½è¡åæ¢è¯»28 break29 if has_read < num_train:30 write_one_line(tokens, train_open)31 else:32 write_one_line(tokens, test_open)33 has_read += 134 print("has read {} lines from original higgs datafile".format(has_read))35 line = higgs_open.readline()36# å
³éæ件37higgs_open.close()38train_open.close()...
linus_stress.py
Source:linus_stress.py
...12 utils.system(utils.get_cc() + ' linus_stress.c -D_POSIX_C_SOURCE=200112 -o linus_stress')13 def initialize(self):14 pass15 def run_the_test(self, iterations):16 utils.write_one_line('/proc/sys/vm/dirty_ratio', '4')17 utils.write_one_line('/proc/sys/vm/dirty_background_ratio', '2')18 cmd = os.path.join(self.srcdir, 'linus_stress')19 args = "%d" % (utils_memory.memtotal() / 32)20 profilers = self.job.profilers21 if profilers.present():22 profilers.start(self)23 for i in range(iterations):24 utils.system(cmd + ' ' + args)25 if profilers.present():26 profilers.stop(self)27 profilers.report(self)28 def execute(self, iterations=1):29 dirty_ratio = utils.read_one_line('/proc/sys/vm/dirty_ratio')30 dirty_background_ratio = utils.read_one_line('/proc/sys/vm/dirty_background_ratio')31 try:32 self.run_the_test(iterations)33 finally:34 utils.write_one_line('/proc/sys/vm/dirty_ratio', dirty_ratio)...
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!!