How to use write_one_line method in avocado

Best Python code snippet using avocado_python

higgs_preprocessing.py

Source:higgs_preprocessing.py Github

copy

Full Screen

...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()...

Full Screen

Full Screen

linus_stress.py

Source:linus_stress.py Github

copy

Full Screen

...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)...

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 avocado 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