Best Python code snippet using yandex-tank
bitvec.py
Source: bitvec.py
...9def _check_value(value):10 if type(value) != type(0) or not 0 <= value < 2:11 raise error, 'bitvec() items must have int value 0 or 1'12import math13def _compute_len(param):14 mant, l = math.frexp(float(param))15 bitmask = 1L << l16 if bitmask <= param:17 raise RuntimeError('(param, l) = %r' % ((param, l),))18 while l:19 bitmask = bitmask >> 120 if param & bitmask:21 break22 l = l - 123 return l24def _check_key(len, key):25 if type(key) != type(0):26 raise TypeError, 'sequence subscript not int'27 if key < 0:28 key = key + len29 if not 0 <= key < len:30 raise IndexError, 'list index out of range'31 return key32def _check_slice(len, i, j):33 #the type is ok, Python already checked that34 i, j = max(i, 0), min(len, j)35 if i > j:36 i = j37 return i, j38class BitVec:39 def __init__(self, *params):40 self._data = 0L41 self._len = 042 if not len(params):43 pass44 elif len(params) == 1:45 param, = params46 if type(param) == type([]):47 value = 0L48 bit_mask = 1L49 for item in param:50 # strict check51 #_check_value(item)52 if item:53 value = value | bit_mask54 bit_mask = bit_mask << 155 self._data = value56 self._len = len(param)57 elif type(param) == type(0L):58 if param < 0:59 raise error, 'bitvec() can\'t handle negative longs'60 self._data = param61 self._len = _compute_len(param)62 else:63 raise error, 'bitvec() requires array or long parameter'64 elif len(params) == 2:65 param, length = params66 if type(param) == type(0L):67 if param < 0:68 raise error, \69 'can\'t handle negative longs'70 self._data = param71 if type(length) != type(0):72 raise error, 'bitvec()\'s 2nd parameter must be int'73 computed_length = _compute_len(param)74 if computed_length > length:75 print 'warning: bitvec() value is longer than the length indicates, truncating value'76 self._data = self._data & \77 ((1L << length) - 1)78 self._len = length79 else:80 raise error, 'bitvec() requires array or long parameter'81 else:82 raise error, 'bitvec() requires 0 -- 2 parameter(s)'83 def append(self, item):84 #_check_value(item)85 #self[self._len:self._len] = [item]86 self[self._len:self._len] = \87 BitVec(long(not not item), 1)...
Check out the latest blogs from LambdaTest on this topic:
Software Risk Management (SRM) combines a set of tools, processes, and methods for managing risks in the software development lifecycle. In SRM, we want to make informed decisions about what can go wrong at various levels within a company (e.g., business, project, and software related).
It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Estimates are critical if you want to be successful with projects. If you begin with a bad estimating approach, the project will almost certainly fail. To produce a much more promising estimate, direct each estimation-process issue toward a repeatable standard process. A smart approach reduces the degree of uncertainty. When dealing with presales phases, having the most precise estimation findings can assist you to deal with the project plan. This also helps the process to function more successfully, especially when faced with tight schedules and the danger of deviation.
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!!