file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f10111.py
def f(n1, n2): if n2 == 0: if n1 == 0: n2 = 1 else: raise ValueError("Invalid Input: a non-zero value can't be divided by zero") return n1/n2 assert f(0, 5) == 0
benchmark_functions_edited/f7488.py
def f(f_x,y_true): if f_x*y_true>=0: return 0 else: return 1 assert f(0,0) == 0
benchmark_functions_edited/f6825.py
def f(i, size, Cartesian=True): if Cartesian: if i == 1: return 0 if i == 0: if size >= 2: return 1 return i assert f(1, 3) == 0
benchmark_functions_edited/f5579.py
def f(item): if type(item) == list: return sum(f(subitem) for subitem in item) else: return 1. assert f(1) == 1
benchmark_functions_edited/f8577.py
def f(val): rval = 0 for fragment in bytearray(val): rval <<= 8 rval |= fragment return rval assert f(b'\x09') == 9
benchmark_functions_edited/f11768.py
def f(y): total = 0 while y: total += y % 10 y //= 10 return total assert f(1000000) == 1
benchmark_functions_edited/f10781.py
def f(unnormalised: float, normalised: float) -> int: return round(unnormalised / normalised) assert f(4, 6) == 1
benchmark_functions_edited/f2338.py
def f(poly, t): return sum(coef * t ** k for k, coef in enumerate(poly)) assert f( [1, 0, 0, 0, 0, 0, 0, 0], 0) == 1
benchmark_functions_edited/f10023.py
def f(x, m): if x % 2 == 0: x = int(x / 2) else: x = int((x*m) + 1) return x assert f(2, 1) == 1
benchmark_functions_edited/f6561.py
def f(u,v): result = 0.0 for i in range (0,len(u)): result = result + (u[i]*v[i]) return result assert f( [1,-2,3], [0,0,0] ) == 0
benchmark_functions_edited/f3305.py
def f(x): if hasattr(x, 'shape'): return x.shape[0] else: return len(x) assert f([0, 1, 2]) == 3
benchmark_functions_edited/f6837.py
def f(n, limits=(-100,100)): (minn, maxn) = limits return max(min(maxn, n), minn) assert f(5, (0,10)) == 5
benchmark_functions_edited/f5144.py
def f(dividend, divisor, divide_by_zero_value=0): return dividend / divisor if divisor != 0 else divide_by_zero_value assert f(10, 5, 1) == 2
benchmark_functions_edited/f14426.py
def f(a, b): overlap = max(0, min(a[1], b[1]) - max(a[0], b[0]) + 1) return overlap assert f( [3, 4], [1, 2]) == 0
benchmark_functions_edited/f8467.py
def f(res, carry, MASK=0xFFFFFFFF): return (res ^ carry) & MASK assert f(int("0000", 2), int("0010", 2)) == 2
benchmark_functions_edited/f1147.py
def f(q1, q2): return q1[0] * q2[0] + q1[1] * q2[1] + q1[2] * q2[2] + q1[3] * q2[3] assert f( (0, 1, 0, 0), (1, 0, 0, 0) ) == 0
benchmark_functions_edited/f5612.py
def f(gen) -> int: # f(gen) is faster and consumes less memory than len([for x in gen]) n = 0 for x in gen: n += 1 return n assert f(range(0)) == 0
benchmark_functions_edited/f7863.py
def f(s) -> int: result = 0 for c in s: result *= 5 result += ord(c) return result assert f(b'') == 0
benchmark_functions_edited/f6936.py
def f(x): if x['mean_luminosity_km2'] > 5: return 10 elif x['mean_luminosity_km2'] > 1: return 5 else: return 1 assert f( {'mean_luminosity_km2': 1, 'num_people': 50000000}) == 1
benchmark_functions_edited/f4892.py
def f(a, b): if isinstance(a, str): raise NotImplementedError("String formating is not supported") return a % b assert f(2, 2) == 0
benchmark_functions_edited/f2109.py
def f(first,second): return round(abs(first * 100 / second - 100)) assert f(10, 10) == 0
benchmark_functions_edited/f4629.py
def f(data, index, n_bytes): return sum([data[index + j] << 8 * j for j in range(n_bytes)]) assert f(bytes(), 1, 0) == 0
benchmark_functions_edited/f13863.py
def f(sdam: float, scdm: float) -> float: return (sdam - scdm) / sdam assert f(1, 1) == 0
benchmark_functions_edited/f2352.py
def f(newdate, olddate): return int(round((newdate - olddate) / float(86400000000))) assert f(1000000000, 1000000000) == 0
benchmark_functions_edited/f5033.py
def f(x: int) -> int: z = (x + 1) // 2 y = x while z < y: y = z z = ( (x // z) + z) // 2 return y assert f(24) == 4
benchmark_functions_edited/f7982.py
def f(val): # val matches this EBNF: # '-'? [0-9]+ ('.' [0-9]+)? if "." in val: return float(val) else: return int(val) assert f(u"0") == 0
benchmark_functions_edited/f5395.py
def f(q, m=1, gamma=0.3, qmin=0.1): if q < qmin or q > 1: return 0 C = 1/(1/(gamma+1)*(1 - qmin**(gamma+1))) return C*q**gamma assert f(0, 1, 0.3) == 0
benchmark_functions_edited/f5798.py
def f(x, means, widths, index=None): if index is None: return (x - means) / widths return (x - means[index]) / widths[index] assert f(1, 1, 1) == 0
benchmark_functions_edited/f7726.py
def f(Dh, m, I_0): return Dh * m / I_0 assert f(0, 1, 1) == 0
benchmark_functions_edited/f7552.py
def f(hour_out,check_out,tolerance): if hour_out > check_out: if (hour_out - check_out) < tolerance: return ' ' else: return hour_out - check_out else: return ' ' assert f(2, 1, 1) == 1
benchmark_functions_edited/f6705.py
def f(trans, nxt): if type(trans) == str: return trans else: return nxt assert f(2, 3) == 3
benchmark_functions_edited/f4511.py
def f(list_, func): for i, x in enumerate(list_): if func(x): return i return None assert f( [1, 2, 3, 4], lambda x: x == 3 ) == 2
benchmark_functions_edited/f5281.py
def f(a: int, b: int) -> int: multiply = 1 if a == b: multiply += 1 return (a + b) * multiply assert f(1, 2) == 3
benchmark_functions_edited/f10067.py
def f(str): if not str: return None try: return int(str) except ValueError: return int(float(str)) except TypeError: return None assert f('0') == 0
benchmark_functions_edited/f2364.py
def f(text): return len([line for line in text.split("\n") if line.strip()]) assert f( "hi\n" "there" ) == 2
benchmark_functions_edited/f12128.py
def f(lumbyte: int, gamma: float ) -> int: return int(((lumbyte / 255) ** gamma) * 255) assert f(1, 2) == 0
benchmark_functions_edited/f4709.py
def f(num): s = 0 while num > 0: s += num % 10 num //= 10 return s assert f(300) == 3
benchmark_functions_edited/f2849.py
def f(num_iter): cumprod = 1 for el in num_iter: cumprod *= el return cumprod assert f([]) == 1
benchmark_functions_edited/f9280.py
def f(freq_band_name, freq_band_names, freq_bands): if freq_band_name in freq_band_names: print(freq_band_name) print(freq_band_names.index(freq_band_name)) return freq_bands[freq_band_names.index(freq_band_name)] return None assert f(1, [1, 2], [2, 2]) == 2
benchmark_functions_edited/f3003.py
def f(numbers): sum = 0 for i in numbers: sum += i**2 return sum assert f(list((0, 1, 0, 0, 0, 0))) == 1
benchmark_functions_edited/f2311.py
def f(brightness: int) -> int: return int(brightness / 17) assert f(125) == 7
benchmark_functions_edited/f4757.py
def f(bin): tmp = 0 buf = list(bin) buf.reverse() for i in buf: tmp = 256*tmp + i return tmp assert f(b'\x00\x00\x00') == 0
benchmark_functions_edited/f11313.py
def f(n): # Edge case. if n == 1: return 1 n_odds = sum([i for i in range(1, n + 1)]) idx = 1 odd = 1 lst = [] while idx != n_odds: odd += 2 lst.append(odd) idx += 1 return sum(lst[-n:]) assert f(2) == 8
benchmark_functions_edited/f10317.py
def f(obj): if not isinstance(obj, (list, tuple)): return 1 else: return len(obj) assert f(False) == 1
benchmark_functions_edited/f2324.py
def f(seq): for e in seq: if e: return e return False assert f(iter([1, 1])) == 1
benchmark_functions_edited/f9827.py
def f(function,value): new_value = function(value) while new_value != value: value = new_value ##debug("%s" % str(value).replace(" ","")) new_value = function(value) return value assert f(lambda x: x*x, 1) == 1
benchmark_functions_edited/f13851.py
def f(list1, list2): list1.sort() list2.sort() matches = i = j = 0 lenLst1 = len(list1) lenLst2 = len(list2) while i < lenLst1 and j < lenLst2: if list1[i] < list2[j]: i+=1 elif list1[i] > list2[j]: j+=1 else: #they are the same matches+=1 i+=1 j+=1 return matches assert f( [1, 2, 3, 4], [4, 3, 2, 1] ) == 4
benchmark_functions_edited/f7216.py
def f(value: str) -> int: try: intval = int(value) if intval < 1: intval = 1 return intval except: return 1 assert f(-10) == 1
benchmark_functions_edited/f12672.py
def f(value): if isinstance(value, str): try: return int(value) except ValueError: return None elif isinstance(value, int): return value assert f(**{'value': '1'}) == 1
benchmark_functions_edited/f11134.py
def f(n): if n < 0: raise ValueError('input must be a positive whole number') if n in [0, 1]: return n return f(n - 2) + f(n - 1) assert f(3) == 2
benchmark_functions_edited/f13758.py
def f(N, R, Es): return (9 * N ** 2 / (16 * R * Es ** 2)) ** (1 / 3) assert f(0, 1, 0.0001) == 0
benchmark_functions_edited/f3278.py
def f(str): x = 0 for c in str: x = (x << 8) | ord(c) return x assert f(b'') == 0
benchmark_functions_edited/f12023.py
def f(numero, mostrar=False): from math import factorial if mostrar: contador = numero while contador > 0: print(contador, end=" ") if contador != 1: print("x", end=" ") contador -= 1 print("=", end=" ") return factorial(numero) assert f(0, False) == 1
benchmark_functions_edited/f8260.py
def f(m, y, c): return (y-c)/m assert f(1, 0, 0) == 0
benchmark_functions_edited/f11539.py
def f(dictionary, key, default): try: return dictionary[key] except KeyError: return default assert f(dict(), 'x', 2) == 2
benchmark_functions_edited/f379.py
def f(x): return 700*(10**(x/2595.0)-1) assert f(f(0)) == 0
benchmark_functions_edited/f7337.py
def f(text): trash_count = 0 for char in text: if char in list(u'.\'"+-!?()[]{}*+@#$%^&_=|/\\'): trash_count += 1 return trash_count / float(len(text)) assert f(u"hello") == 0
benchmark_functions_edited/f14114.py
def f(r5): return (r5 >> 8) assert f(512) == 2
benchmark_functions_edited/f8310.py
def f(v: float, delta: float, m: float, M: float) -> float: mutated_v = v + delta if mutated_v > M: return 2 * M - mutated_v elif mutated_v < m: return 2 * m - mutated_v else: return mutated_v assert f(3, 0, 1, 3) == 3
benchmark_functions_edited/f3336.py
def f(type, item): try: return type[item] except: return type(item) assert f(int, 1) == 1
benchmark_functions_edited/f9254.py
def f(n, steps=20): sqrt = n / 2 for step in range(steps): sqrt = 1 / 2 * (sqrt + n / sqrt) return sqrt assert f(1) == 1
benchmark_functions_edited/f13451.py
def f(mu, std, beta=3.): return mu + beta * std assert f(0, 0) == 0
benchmark_functions_edited/f4476.py
def f(dictionary, key): if dictionary is None: return None return dictionary.get(key, None) assert f({1: 1}, 1) == 1
benchmark_functions_edited/f7652.py
def f(start, stop, step): __cpp__ = i = 0 return 5 assert f(1.0, 10.0, 1.0) == 5
benchmark_functions_edited/f723.py
def f(x): if x == 0: return 0.5 elif x > 0: return 1 return 0 assert f(1) == 1
benchmark_functions_edited/f6417.py
def f(dilation, kernel): return int(((kernel - 1) * (dilation - 1) + (kernel - 1)) / 2.0) assert f(9, 2) == 4
benchmark_functions_edited/f8245.py
def f(*args): return args[-1] assert f(1,2,3) == 3
benchmark_functions_edited/f12470.py
def f(n, m): if n == 0: return 1 elif n < 0: return 0 elif m == 0: return 0 else: with_m = f(n-m, m) without_m = f(n, m-1) return with_m + without_m assert f(0, 0) == 1
benchmark_functions_edited/f1145.py
def f(x): try: return x[0] except IndexError: return x assert f([3]) == 3
benchmark_functions_edited/f2443.py
def f(data): return int(data[0:8], 16) assert f("00000000") == 0
benchmark_functions_edited/f6976.py
def f(code, prev): if code > prev: return code else: return prev assert f(2, 0) == 2
benchmark_functions_edited/f8500.py
def f(a, b): diff = [key for key in a if a[key] != b[key]] return len(diff) assert f( {"a": 1, "b": 2, "c": 3}, {"a": 1, "b": 2, "c": 3}, ) == 0
benchmark_functions_edited/f3298.py
def f(number): weights = (3, 2, 7, 6, 5, 4, 3, 2, 1, 0) return sum(w * int(n) for w, n in zip(weights, number)) % 11 assert f('000000000') == 0
benchmark_functions_edited/f570.py
def f(numerator, denominator): return -((-numerator)//denominator) assert f(3, 1) == 3
benchmark_functions_edited/f11996.py
def f(mode): ret = {"round-robin": 1, "active-backup": 2, "xor": 3, "broadcast": 4, "lacp": 5} try: return ret[mode] except KeyError: pass return -1 assert f("lacp") == 5
benchmark_functions_edited/f13689.py
def f(input_array, value): head = 0 end = len(input_array) - 1 index = int((end - head)/2) while True: if end < head: return -1 if input_array[index] == value: return index elif value > input_array[index]: head = index + 1 elif value < input_array[index]: end = index - 1 index = head + int((end - head)/2) assert f( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3) == 2
benchmark_functions_edited/f7268.py
def f(s): try: return int(s) except ValueError: return s assert f(1) == 1
benchmark_functions_edited/f13436.py
def f(f, q): if hasattr(q, '_fields'): attrs = [] for field in q._fields: attr = getattr(q, field) attrs.append(f(f, attr)) cls = type(q) obj = cls(*attrs) return f(obj) elif isinstance(q, (list, tuple)): cls = type(q) return cls(f(f, x) for x in q) return f(q) assert f(lambda x: x, 1) == 1
benchmark_functions_edited/f6017.py
def f(numbers): return sum(numbers) / len(numbers) assert f(range(11)) == 5
benchmark_functions_edited/f8153.py
def f(object,attribute,default_value=None): if default_value is None: return eval("object."+attribute) try: return eval("object."+attribute) except: return default_value assert f(None,'value',1) == 1
benchmark_functions_edited/f3458.py
def f(*values): return next((v for v in values if v is not None and v != ""), "N/A") assert f(1, 2, 3) == 1
benchmark_functions_edited/f862.py
def f(s): return len(s.encode('utf-8')) assert f(u'é') == 2
benchmark_functions_edited/f1421.py
def f(a, b): return 1 if b > a else -1 if a > b else 0 assert f(3, 5) == 1
benchmark_functions_edited/f13385.py
def f(time, value, tstep): return value if time() >= tstep else 0 assert f(lambda: 1.5, 1, 1.25) == 1
benchmark_functions_edited/f14462.py
def f(n, x): height = n / 2 width = n c = width / 2 b = height a = height / (width / 2) ** 2 y = -(a * (x - c) ** 2) + b return y assert f(10, 0) == 0
benchmark_functions_edited/f3288.py
def f(deep_dict, path): value = deep_dict for key in path: value = value[key] return value assert f( {'a': {'b': 1, 'c': {'d': 3, 'e': 4}}}, ['a', 'c', 'd'] ) == 3
benchmark_functions_edited/f690.py
def f(byte): return (byte / 1048576) assert f(1048576) == 1
benchmark_functions_edited/f717.py
def f(k, l, m): return k**2 + l**2 + m**2 assert f(0, 1, 2) == 5
benchmark_functions_edited/f1414.py
def f( a , b ): while b: a , b = b , a%b return a assert f( 1, 121 ) == 1
benchmark_functions_edited/f8475.py
def f(child_counts): if not child_counts: return 1 elif len(child_counts) == 1: return child_counts[0] elif len(child_counts) == 2: return child_counts[0] * child_counts[1] else: raise ValueError assert f([1,2]) == 2
benchmark_functions_edited/f9482.py
def f(eci): max_size = 0 for key in eci.keys(): size = int(key[1]) if size > max_size: max_size = size return max_size assert f( {'C1': ['A', 'C', 'T'], 'C2': ['G', 'G', 'G'], 'C3': ['A', 'T', 'C'], 'C4': ['T', 'T', 'A'], 'C5': ['G', 'G', 'T'], 'C6': ['G', 'C', 'G'], 'C7': ['C', 'G', 'T']} ) == 7
benchmark_functions_edited/f4415.py
def f(x1, x2): x2 += x1 return x2 assert f(0, 2) == 2
benchmark_functions_edited/f7393.py
def f(x): d = 0 el = x while True: try: el = el[0] d += 1 except: break return d assert f( [ [ 1 ], [ 2, 3 ] ] ) == 2
benchmark_functions_edited/f9871.py
def f(hex_str): val = int(hex_str, 16) if val > 0x7FFF: val = ((val+0x8000) & 0xFFFF) - 0x8000 return val assert f('0000') == 0
benchmark_functions_edited/f3453.py
def f(array): if len(array) == 0: return 0 return sum(array[0::2]) * array[-1] assert f([1, 2]) == 2
benchmark_functions_edited/f1370.py
def f(file): with open(file, mode='rb') as fd: return sum(1 for _ in fd) assert f('test.txt') == 1
benchmark_functions_edited/f8955.py
def f(d, m, s, i): sec = float((m * 60) + s) dec = float(sec / 3600) deg = float(d + dec) if i.upper() == 'W': deg = deg * -1 elif i.upper() == 'S': deg = deg * -1 return float(deg) assert f(0, 0, 0, 'S') == 0
benchmark_functions_edited/f4367.py
def f(aa, wrapAt=360.): if wrapAt is None: return (aa[1] - aa[0]) else: return (aa[1] - aa[0]) % wrapAt assert f( (360, 360) ) == 0
benchmark_functions_edited/f8356.py
def f(a, b): while a % b != 0: a, b = b, a % b return b assert f(7, 13) == 1
benchmark_functions_edited/f2451.py
def f(X, shift=20): return X / (X + 1 + shift) assert f(0) == 0