file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f12600.py
def f(host, list): for exception in list: if host == exception: return 1 try: if exception[0] == '.' and host[-len(exception):] == exception: return 1 except IndexError: pass return 0 assert f('', []) == 0
benchmark_functions_edited/f366.py
def f(a, b): return (a > b) - (a < b) assert f(True, True) == 0
benchmark_functions_edited/f337.py
def f(string): return len(string.encode('utf-8')) assert f('') == 0
benchmark_functions_edited/f2328.py
def f(l): if ".doc" in str(l): return 1 else: return 0 assert f(b"hello.dot") == 0
benchmark_functions_edited/f12825.py
def f(n: int) -> int: if n < 5: # handle recursive base case return 2**(n - 1) else: # place each tile at end of row and recurse on remainder return (f(n - 1) + f(n - 2) + f(n - 3) + f(n - 4)) assert f(4) == 8
benchmark_functions_edited/f7543.py
def f(parts): for part in parts: if 'military' in part: return 1 return 0 assert f( ["We are a military-Friendly Apt. located in the heart of downtown Chicago"]) == 1
benchmark_functions_edited/f13462.py
def f(items=[]): return sum(items) / len(items) assert f([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3
benchmark_functions_edited/f2087.py
def f(t, y, solver): if t > 28: return 1 return 0 assert f(27.0, 1, None) == 0
benchmark_functions_edited/f3548.py
def f(n): total = 0 k = 1 while k <= n: total += k k += 1 return total assert f(0) == 0
benchmark_functions_edited/f2770.py
def f(x0, x1, img0, img1, x): f = (x-x0)/(x1-x0) return img0 + f*(img1-img0) assert f(1, 2, 0, 10, 1) == 0
benchmark_functions_edited/f10202.py
def f(fileDesc): fileDesc.write("To use this project, you'll need G++ Compiler.\n\n") return 0 assert f(open("README.md", "w")) == 0
benchmark_functions_edited/f739.py
def f(a: int = 0, b: int = 1) -> float: print(a / b) return a / b assert f(0, 1) == 0
benchmark_functions_edited/f3954.py
def f(my_list_of_outputs): result = 0 for output in my_list_of_outputs: result += output.satoshis return result assert f([]) == 0
benchmark_functions_edited/f1898.py
def f(version, is_quiet=False): if not is_quiet: print("version: {0}".format(version)) return 0 assert f("4321") == 0
benchmark_functions_edited/f8666.py
def f(text, open={"(", "[", "{"}, close={")", "]", "}"}): level = 0 for c in text: if c in open: level += 1 elif c in close: level -= 1 return level assert f("()()") == 0
benchmark_functions_edited/f7961.py
def f(num1, num2=1): return (num1*num2) assert f(2, 0) == 0
benchmark_functions_edited/f13914.py
def f(options, unused_value): sort_code = 0 if 'COMPLEX' in options: sort_code += 1 if 'SORT2' in options: sort_code += 2 if 'RANDOM' in options: sort_code += 4 return sort_code assert f(['COMPLEX', 'SORT2'], 1.5) == 3
benchmark_functions_edited/f1177.py
def f(n_tr): return n_tr * (n_tr-1) / 2 assert f(1) == 0
benchmark_functions_edited/f11794.py
def f(axis): axis = axis.lower() axes = {'x': 0, 'y': 1, 'z': 2} if axis in axes: return axes[axis] return None assert f(**{'axis': 'x'}) == 0
benchmark_functions_edited/f11365.py
def f(integer, k): binary = '{:032b}'.format(integer & 0xffffffff) start = len(binary) - k end = len(binary) lower_bits = binary[start:end] lower_bits_integer = int(lower_bits, 2) return lower_bits_integer assert f(15, 3) == 7
benchmark_functions_edited/f6906.py
def f(values): values.sort(reverse=True) target = sum(values) / 2. total = 0 for v in values: total += v if total >= target: return v return 0 assert f([]) == 0
benchmark_functions_edited/f1877.py
def f(byteval, idx): return ((byteval & (1 << idx)) != 0) assert f(0x0, 1) == 0
benchmark_functions_edited/f10397.py
def f(value, fr=(0, 1), to=(0, 1)): value = (value - fr[0]) / (fr[1] - fr[0]) return to[0] + value * (to[1] - to[0]) assert f(0.5, (0, 1), (0, 2)) == 1
benchmark_functions_edited/f5852.py
def f(ranks, tid): for irank,ts in enumerate(ranks): if tid in ts: return irank+1 return None assert f( [[1, 2, 3, 5, 7], [5, 6, 10, 11, 12], [9]], 12 ) == 2
benchmark_functions_edited/f72.py
def f(x, y, **kwargs): print(kwargs) return x + y assert f(4, 5) == 9
benchmark_functions_edited/f8896.py
def f(f, t): return f['a_x'] + f['b_x'] * t + f['c_x'] * t * t + f['d_x'] * t * t * t assert f( { 'a_x': 1, 'b_x': 2, 'c_x': 3, 'd_x': 4, }, 0, ) == 1
benchmark_functions_edited/f3578.py
def f(n1, v1): if v1 >= n1: return n1 while n1 % v1 != 0: v1 -= 1 return v1 assert f(2, 4) == 2
benchmark_functions_edited/f6158.py
def f(x): abs(x) # checks type of argument if x < 0: return -1 else: return 1 assert f(42) == 1
benchmark_functions_edited/f9027.py
def f(filename: str) -> int: with open(filename, "r") as f: return len(f.readlines()) assert f("no_such_file") == 0
benchmark_functions_edited/f1564.py
def f(diagonal_1, diagonal_2): return float((diagonal_1 * diagonal_2) / 2) assert f(4, 3) == 6
benchmark_functions_edited/f1250.py
def f(x, y): if y == 0: raise ValueError("Cannot divide by 0") return x / y assert f(10, 5) == 2
benchmark_functions_edited/f9832.py
def f(data, code = None): if isinstance(data,list): sum = 0 for d in data: sum += f(d, code=code) return sum if data != '' and data != 'NA': if code == None or data == code: return 1 return 0 assert f(['NA', 1, 2]) == 2
benchmark_functions_edited/f14147.py
def f(data: bytes, filepath: str) -> int: if not isinstance(data, bytes): raise TypeError("data expecting type bytes, got {0}".format(type(data))) if not isinstance(filepath, str): raise TypeError("data expecting type bytes, got {0}".format(type(data))) with open(filepath, "wb") as fd: return fd.write(data) assert f(b"123456789", "test_file.txt") == 9
benchmark_functions_edited/f2793.py
def f(arr, item): return len(arr) - arr[::-1].index(item) - 1 assert f(list('abcd'), 'c') == 2
benchmark_functions_edited/f9365.py
def f(doc: str, end: int, start: int = 0): return doc.count("\n", start, end) + 1 assert f( "", 0 ) == 1
benchmark_functions_edited/f3766.py
def f(s: int) -> int: if (s & (s - 1) == 0) and s != 0: return 1 else: return 0 assert f(6) == 0
benchmark_functions_edited/f6888.py
def f(x, k, xp, yp): product = 1.0 for i, elem_x in enumerate(xp): if(i == k): continue product *= (float((x - elem_x)) / float((xp[k] - elem_x))) return product assert f(3, 0, [1, 2, 3, 4], [1, 2, 3, 4]) == 0
benchmark_functions_edited/f3682.py
def f(shear_mod, bulk_mod): return (9*bulk_mod*shear_mod)/( (3*bulk_mod)+shear_mod) assert f(0, 200) == 0
benchmark_functions_edited/f14158.py
def f(event): if len(event['children']) == 0: return 0 children = 0 for child in event['children']: children += 1 + f(child) return children assert f( {'children': [{'children': [{'children': [{'children': [], 'args': {}}, {'children': [], 'args': {}}], 'args': {}}, {'children': [{'children': [], 'args': {}}, {'children': [], 'args': {}}], 'args': {}}], 'args': {}}]}) == 7
benchmark_functions_edited/f672.py
def f(x) -> int: return x and (1, -1)[x < 0] assert f(0) == 0
benchmark_functions_edited/f9239.py
def f(codon, seq): i = 0 # Scan sequence until we hit the start codon or the end of the sequence while seq[i:i+3] != codon and i < len(seq): i += 1 if i == len(seq): return -1 return i assert f('TGA', 'ATGCTGA') == 4
benchmark_functions_edited/f5419.py
def f(i, alpha): return (alpha ** (i + 1) - (i + 1) * alpha + i) / (1 - alpha) assert f(0, 0.3) == 0
benchmark_functions_edited/f4900.py
def f(name, email): if str(name).lower() in str(email).lower(): return 1 else: return 0 assert f('<EMAIL>', 'Smith') == 0
benchmark_functions_edited/f11483.py
def f(h_old, h_new): return float(-h_new + h_old) assert f(2, 1) == 1
benchmark_functions_edited/f876.py
def f(list, value): return list.index(value) assert f(range(10), 5) == 5
benchmark_functions_edited/f13780.py
def f(obj, membername, *args, **kwargs): return getattr(obj, membername)(*args, **kwargs) assert f(False, "bit_length") == 0
benchmark_functions_edited/f2783.py
def f(x: int, n: int, m: int) -> int: ans = 1 while n: if n & 1: ans = ans * x % m x = x * x % m n >>= 1 return ans assert f(2, 22, 10) == 4
benchmark_functions_edited/f12988.py
def f(preds_word: str, target_word: str) -> int: return int(preds_word != target_word) assert f(1, "1") == 1
benchmark_functions_edited/f10550.py
def f(event_name): import re if event_name == "baseline": return 0 else: match_obj = re.match(r'^followup_(\d+)y$', event_name) if match_obj: return int(match_obj.groups()[0]) assert f("followup_6y") == 6
benchmark_functions_edited/f10740.py
def f(sequence): s = list(sequence) a = 0 b = True while b: b = False for i in range(1, len(s)): if s[i-1] > s[i]: s[i], s[i-1] = s[i-1], s[i] a += 1 b = True return a assert f([]) == 0
benchmark_functions_edited/f4649.py
def f(x, y): if x == y: return 1 return 0 assert f(3, 0) == 0
benchmark_functions_edited/f8845.py
def f(ref, qry): if len(ref) != len(qry): raise Exception('%d != %d' %(len(ref), len(qry))) for i in range(len(ref)): rot = ref[i:] + ref[:i] if rot == qry: return i raise Exception('no match') assert f( 'TGACT', 'TGACT') == 0
benchmark_functions_edited/f4031.py
def f(x, a, b, c, d, e): return a * x**6 + b * x**5 + c * x**4 + d * x**3 + e * x**2 assert f(2, 0, 0, 0, 0, 0) == 0
benchmark_functions_edited/f10990.py
def f(obj: dict, name: str) -> int: value = obj[name] if not isinstance(value, int): raise TypeError(f'{name} must be integer: {type(value)}') elif value < 0: raise ValueError(f'{name} must be positive integer: {value}') return value assert f( {'x': 3}, 'x' ) == 3
benchmark_functions_edited/f4285.py
def f(cigar_op): # taken from htslib bam_cigar_type function return 0x3c1a7 >> (cigar_op << 1) & 3 assert f(2) == 2
benchmark_functions_edited/f13679.py
def f(selectpicker_id: str) -> int: max_values = { "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "10": 10, "11": 15, "12": 20, "13": 30, "14": 40, "15": 50, "16": 99 } return max_values.get(selectpicker_id, 99) assert f( "4") == 4
benchmark_functions_edited/f3504.py
def f(val, bits): if (val & (1 << (bits - 1))) != 0: val = val - (1 << bits) return val assert f(6, 32) == 6
benchmark_functions_edited/f5361.py
def f(data): count = 0 for b in data: if b < 0x20 or 0x80 <= b: count += 1 return count assert f(b"\x7f\x00\x00") == 2
benchmark_functions_edited/f2905.py
def f(labels): labels = labels % 2 return labels assert f(0) == 0
benchmark_functions_edited/f6151.py
def f(dictionary): if dictionary: keys = [int(k) for k in dictionary if k] if keys: return max(keys) + 1 return 1 assert f({'1': 1, '2': 1}) == 3
benchmark_functions_edited/f2264.py
def f(value): bitcount = bin(value).count("1") return bitcount assert f(33) == 2
benchmark_functions_edited/f12461.py
def f(size, hole_count, hole_area): board_area = size[0] * size[1] if board_area == 0: return 0 hole_percentage = hole_area / board_area hole_score = (hole_percentage - 0.25) ** 2 size_score = (board_area - 8) ** 2 return hole_score * size_score assert f( (2, 2), 1, 2 ) == 1
benchmark_functions_edited/f1238.py
def f(v): return sum(x ** 2 for x in v) ** 0.5 assert f([-1, 0]) == 1
benchmark_functions_edited/f2624.py
def f(pt0, pt1): return (pt0[0] - pt1[0])**2 + (pt0[1] - pt1[1])**2 assert f( (0, 0), (1, -1)) == 2
benchmark_functions_edited/f5545.py
def f(q,I0,Rg): from numpy import exp return I0*exp(-(q*Rg)**2/3) assert f(0,1,1) == 1
benchmark_functions_edited/f7499.py
def f(repository, undeployed_value_tuple, deployed_value_tuple): return undeployed_value_tuple[2] - deployed_value_tuple[2] assert f(None, ('x', 1, 11), ('y', 2, 10)) == 1
benchmark_functions_edited/f351.py
def f(a_b, func): return func(*a_b) assert f( (1,2,3), lambda a, b, c: a*b*c ) == 6
benchmark_functions_edited/f4741.py
def f(ncols, row, col): # lambda ncols, row, col: ncols * (row - 1) + col return ncols * (row - 1) + col assert f(2, 1, 1) == 1
benchmark_functions_edited/f282.py
def f(value): value += 1 return value assert f(2) == 3
benchmark_functions_edited/f6498.py
def f(bytez): result = 0 for i in range(len(bytez)): if bytez[i] == 255 and bytez[i + 1] == 218: result = i + 2 break return result assert f(b'\x00\x00\x00\x00\x00\x00') == 0
benchmark_functions_edited/f8365.py
def f(in_string, max_len): curr_len = len(in_string) if curr_len > max_len: return curr_len return max_len assert f("ab", 2) == 2
benchmark_functions_edited/f5835.py
def f(f1, f2, eps): res = f1 - f2 if abs(res) <= eps: # '<=',so eps == 0 works as expected return 0 elif res < 0: return -1 return 1 assert f(0, 0.5, 1) == 0
benchmark_functions_edited/f7232.py
def f(seq): # Convert sequence to upper case seq = seq.upper() # Count E's and D's, since these are the negative residues return seq.count('E') + seq.count('D') assert f('A') == 0
benchmark_functions_edited/f193.py
def f(x, y, a): return x * (1 - a) + y * a assert f(-1, 1, 0.5) == 0
benchmark_functions_edited/f14531.py
def f(n, k, p): if (k > n- k): k = n - k Coef = [0 for i in range(k + 1)] Coef[0] = 1 for i in range(1, n + 1): for j in range(min(i, k), 0, -1): Coef[j] = (Coef[j] + Coef[j-1]) % p return Coef[k] assert f(5, 0, 3) == 1
benchmark_functions_edited/f6212.py
def f(n): try: decimal = int(n, 2) return decimal except ValueError: return "Invalid binary number" assert f(bin(1)) == 1
benchmark_functions_edited/f12999.py
def f(value): if not isinstance(value, (int, float)) and value is not None: raise TypeError("Glyph left margin must be an :ref:`type-int-float`, " "not %s." % type(value).__name__) return value assert f(0) == 0
benchmark_functions_edited/f6274.py
def f(x, a, b): return a*x + b assert f(1, 0, 0) == 0
benchmark_functions_edited/f10421.py
def f(dy, ml=False): nb = int(dy) nb = nb * 24 * 60 * 60 return nb * 1000 if ml else nb assert f(0) == 0
benchmark_functions_edited/f10628.py
def f(s, default=0): try: return int(float(s)) except Exception: return default assert f("0.0") == 0
benchmark_functions_edited/f8965.py
def f(q, bin_edges): for i in range(len(bin_edges)): if q > bin_edges[i] and q <= bin_edges[i+1]: return i return None assert f(0.2, [0.0, 0.1, 0.3, 0.4]) == 1
benchmark_functions_edited/f3414.py
def f(sentence): return sum(1 for c in sentence if c != ' ') assert f("A sentence") == 9
benchmark_functions_edited/f5438.py
def f(data): n = len(data) if n < 1: raise ValueError('mean requires at least one data point') return sum(data) / float(n) assert f([1, 2, 3, 4, 5, 6, 7]) == 4
benchmark_functions_edited/f7865.py
def f(a, b): return a if a >= b else b assert f(3, 2) == 3
benchmark_functions_edited/f12728.py
def f(x, par): V = 0.5*par**2*x**2 return V assert f(0, -2) == 0
benchmark_functions_edited/f3634.py
def f(total, day): avg = total/day return avg assert f(3, 1) == 3
benchmark_functions_edited/f5929.py
def f(image_shape, crop_degree=0): crop_h = 0 if crop_degree > 0: crop_h = image_shape[0] // (180 / crop_degree) return crop_h assert f( (480, 640) ) == 0
benchmark_functions_edited/f320.py
def f(scores, query): return sum(scores.values()) assert f({'a': 1, 'b': 2}, 'a b') == 3
benchmark_functions_edited/f3270.py
def f(string): return 0 if string == '01' else 1 assert f(11) == 1
benchmark_functions_edited/f10201.py
def f(v): res = 0 for elt in v: for coef in elt: res += coef ** 2 return res assert f(list()) == 0
benchmark_functions_edited/f3927.py
def f(l): maxi = 0 for i, e in enumerate(l): maxi = i if e > l[maxi] else maxi return maxi assert f([0.0, 0.0, 0.0]) == 0
benchmark_functions_edited/f7203.py
def f(quant,index): if quant is None or quant == 0: return quant else: return quant.dx(index) assert f(0,0) == 0
benchmark_functions_edited/f2885.py
def f(dict, key, d=None): if key in dict: return dict[key] return d assert f({'a': 1, 'b': 2}, 'c', 3) == 3
benchmark_functions_edited/f9191.py
def f(n: int) -> int: if n: # see https://stackoverflow.com/a/14267825/17332200 exp = (n // 2).bit_length() res = 1 << exp return res else: return 0 assert f(5) == 4
benchmark_functions_edited/f7659.py
def f(x, y): if x < y: return f(y, x) residual = x % y if residual == 0: return y if residual == 1: return 1 return f(y, residual) assert f(9, 12) == 3
benchmark_functions_edited/f1566.py
def f(v, *args): return round(v, *args) assert f(1.9) == 2
benchmark_functions_edited/f6683.py
def f(cur, crc, table): l_crc = (0x000000ff & cur) tmp = crc ^ l_crc crc = (crc >> 8) ^ table[(tmp & 0xff)] return crc assert f(1, 1, [2]) == 2
benchmark_functions_edited/f5049.py
def f(entry): return entry['SN'] assert f( {'SN': 9, 'SD': '1234', 'ET': 'E2'}) == 9
benchmark_functions_edited/f3556.py
def f(elevator, direction): directions = {'up': 1, 'down': -1} return elevator + directions[direction] assert f(5, 'down') == 4
benchmark_functions_edited/f4574.py
def f(text): if isinstance(text, (list, tuple)): text = "\n".join(text) return len(text.split()) if text else 0 assert f(()) == 0