How to use build_codes method in yandex-tank

Best Python code snippet using yandex-tank

main.py

Source:main.py Github

copy

Full Screen

...68 node1, node2 = heapq.heappop(self.heap), heapq.heappop(self.heap)69 internal_node = HeapNode(node1.occurrences + node2.occurrences, None, node1, node2)70 heapq.heappush(self.heap, internal_node)71 self.root = heapq.heappop(self.heap)72 def build_codes(self):73 self.root.build_codes_from_tree(b'', self.codes)74 def build_codes_for_file(self, data_filename, dict_filename):75 self.build_dict(data_filename)76 self.write_dict(dict_filename)77 self.build_heap()78 self.build_tree()79 self.build_codes()80 def build_codes_from_dict_file(self, dict_filename):81 self.read_dict(dict_filename)82 self.build_heap()83 self.build_tree()84 self.build_codes()85 with open(PADDING, 'r') as f:86 self.padding = int(f.read())87 def read_block_for_encoding(self, file):88 block = b''89 byte = file.read(1)90 while byte != b'':91 block += self.codes[byte]92 if len(block) % 8 == 0:93 return block, False94 byte = file.read(1)95 return block, True96 def make_padding(self, block):97 self.padding = 8 - len(block) % 898 block += b'0' * self.padding...

Full Screen

Full Screen

huffman.py

Source:huffman.py Github

copy

Full Screen

...10 if t.l==None and t.r==None: ans[t.lab] = ''.join(path)11 else:12 path.append('0') ; traverse_tree(t.l, ans, path) ; path.pop()13 path.append('1') ; traverse_tree(t.r, ans, path) ; path.pop()14def build_codes(s):15 ans = dict()16 freq = [ 0 for _ in range(26) ]17 for c in s: freq[ord(c)-ORDA] += 118 h,t = list(),dict()19 for i in range(len(freq)):20 if freq[i]!=0:21 heappush(h, (freq[i], chr(i+ORDA)))22 t[chr(i+ORDA)] = node(chr(i+ORDA), None, None, freq[i])23 while len(h)>=2:24 f1,s1 = heappop(h) ; t1 = t[s1]25 f2,s2 = heappop(h) ; t2 = t[s2]26 f3,s3 = f1+f2,s1+s227 heappush(h, (f3, s3))28 t[s3] = node(s3, t1, t2, f3)29 traverse_tree(t[h[0][1]], ans, list())30 return ans...

Full Screen

Full Screen

m

Source:m Github

copy

Full Screen

1#!/usr/bin/env python32from enert import *3import sys4argv = sys.argv[1:]5argc = len(argv)6if argc != 1 or argv[0] == "-h":7 print("Usage: m <r|b>")8 exit()9f = File("./Mfile")10if not f.exist():11 f = File("../Mfile")12if not f.exist():13 print("Mfile: not found")14 exit()15lines = f.readlines()16run_codes = []17build_codes = []18build_idx = -119for i, line in enumerate(lines):20 if not line == "":21 run_codes.append(line)22 continue23 else:24 build_idx = i25 break26build_codes = lines[build_idx+1:]27if argv[0] == "r":28 for code in run_codes:29 Shell(code).call()30elif argv[0] == "b":31 for code in build_codes:...

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 yandex-tank 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