file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f8655.py
def f(args): try: print('hi from %s' % (__name__,)) except BaseException as e: print('ERROR: %s' % (e,)) return 1 return 0 assert f( ['/path/to/script.py', 'arg1', 'arg2', 'arg3']) == 0
benchmark_functions_edited/f6508.py
def f(tokens, pos): index = 0 while index < len(tokens): if (tokens[index].lineno, tokens[index].column) >= pos: break index += 1 return index assert f([], (1, 0)) == 0
benchmark_functions_edited/f6171.py
def f(word1: str, word2: str) -> int: s = 0 for idx, letter in enumerate(word1): s += letter == word2[idx] return s assert f( 'apple', 'banana' ) == 0
benchmark_functions_edited/f11982.py
def f(name): if (name == 'rock'): return 0 elif (name == 'spock'): return 1 elif (name == 'paper'): return 2 elif (name == 'lizard'): return 3 elif (name == 'scissors'): return 4 else: return -1 assert f('lizard') == 3
benchmark_functions_edited/f12408.py
def f(b, mdata): line_counts = [1, 1, 1, 1, 1, 4, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0] if b == 5: # for transformer if mdata[0][2] == 0: # two-winding transformer return 4 else: # three-winding transformer return 5 return line_counts[b] assert f(7, [[]]) == 0
benchmark_functions_edited/f12105.py
def f(argument1, argument2): result = argument1 + argument2 return result assert f(3, 3) == 6
benchmark_functions_edited/f8820.py
def f(res, obs): if res < 0: res += 360 if obs < 0: obs += 360 if res >= obs: mu = res - obs return mu else: mu = res - obs mu += 360 return mu assert f(180, 180) == 0
benchmark_functions_edited/f5658.py
def f(events): return sorted(events, key=lambda tup: (tup[0], -tup[1]))[0][2] assert f( [(1, 1, 2), (1, 2, 3), (2, 1, 3), (3, 1, 3)] ) == 3
benchmark_functions_edited/f13080.py
def f(target_size, clust_size): if clust_size > target_size: if clust_size >= 2*target_size: clust_size = 0 else: clust_size = target_size - (clust_size - target_size) return (clust_size/target_size) assert f(100, 0) == 0
benchmark_functions_edited/f2179.py
def f(x, a, b): return a * x + b assert f(1, 2, 3) == 5
benchmark_functions_edited/f5617.py
def f(lst, idx): val = 0 for i, elem in enumerate(lst): if i < idx: val += elem else: return val return val assert f([1, 2, 3], 2) == 3
benchmark_functions_edited/f2827.py
def f(a, b): return (a + b) / 2 assert f(2, 4) == 3
benchmark_functions_edited/f3499.py
def f(str): for i, c in enumerate(str): if c != ' ': return i return len(str) assert f( 'abc ') == 0
benchmark_functions_edited/f7829.py
def f(obj: object, attribute: str) -> object: if hasattr(obj, attribute): return getattr(obj, attribute) else: raise Exception(f"{attribute} not found within {obj}") assert f(3j, "imag") == 3
benchmark_functions_edited/f3314.py
def f(prop, seq): if seq in prop: return prop[seq] else: return None assert f({1: [1, 2], 2: 1}, 2) == 1
benchmark_functions_edited/f5172.py
def f(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) assert f( (1,1), (2,2) ) == 2
benchmark_functions_edited/f5295.py
def f(inputs, x, y): if x < 0 or y < 0 or x >= len(inputs) or y >= len(inputs[0]): return None return inputs[x][y] assert f( [[1, 2, 3], [4, 5, 6], [7, 8, 9]], 0, 2) == 3
benchmark_functions_edited/f12844.py
def f(s): # Current number of upper case letters found upper = 0 # Loop through all the letters in the string and if it is upper, increase for x in s: if x.isf(): upper += 1 # Return upper return upper assert f(" \t\n") == 0
benchmark_functions_edited/f920.py
def f(n, d): return (n//d) + (n%d != 0) assert f(17, 10) == 2
benchmark_functions_edited/f6336.py
def f(categories): widest_key = 0 for key in categories: if len(key) > widest_key: widest_key = len(key) return widest_key assert f( {'A': [1, 2, 3], 'B': [1, 2, 3, 4, 5], 'C': [1, 2, 3], 'D': [1, 2, 3], 'E': [1, 2, 3]} ) == 1
benchmark_functions_edited/f12366.py
def f(n, k): # if k > n: # return 0 # if k == n or k == 0: # return 1 # return f(n - 1, k) + f(n - 1, k - 1) res = 1 for i in range(1, k + 1): res = res * (n - i + 1) // i return res assert f(1, 1) == 1
benchmark_functions_edited/f14317.py
def f(y_true, y_pred, k=20): actual = set(y_true) # precision at i is a percentage of correct # items among first i recommendations; the # correct count will be summed up by n_hit n_hit = 0 precision = 0 for i, p in enumerate(y_pred, 1): if p in actual: n_hit += 1 ...
benchmark_functions_edited/f9418.py
def f(flow_name): words = flow_name.split() index = words.index('->') return int(words[index+1]) assert f( "DataFlow: 0 -> 1") == 1
benchmark_functions_edited/f565.py
def f(a, b): return b ^ ((a ^ b) & -(a < b)) assert f(3, 5) == 3
benchmark_functions_edited/f12300.py
def f(x, y): return (x > y) - (x < y) assert f(False, False) == 0
benchmark_functions_edited/f857.py
def f(t, alpha=1, beta=1): return beta / (t + alpha + 1) ** (0.5) assert f(-1) == 1
benchmark_functions_edited/f4157.py
def f(n): if n > 0: return 1 elif n < 0: return -1 else: return 0 assert f(1e1000) == 1
benchmark_functions_edited/f3170.py
def f(flags): # horizontal averaging flag : bits 14-16 return (flags & 57344) >> 13 assert f(1) == 0
benchmark_functions_edited/f5436.py
def f(my_list, key, value): counter = (1 for item in my_list if item.get(key) == value) return sum(counter) assert f([], 'is_awesome', True) == 0
benchmark_functions_edited/f9339.py
def f(z, z0): return z + z0**2 / z assert f(2, 2) == 4
benchmark_functions_edited/f9408.py
def f(v1, v2, vH): if vH < 0: vH += 1 if vH > 1: vH -= 1 if (6 * vH) < 1: return v1 + (v2 - v1) * 6 * vH if (2 * vH) < 1: return v2 if (3 * vH) < 2: return v1 + (v2 - v1) * ((2 / 3.0) - vH) * 6 return v1 assert f(1, 2, 1) == 1
benchmark_functions_edited/f5594.py
def f(a, b, i, j): if i >= len(a) or j >= len(b): return 0 elif a[i] == b[j]: return 1 + f(a, b, i+1, j+1) else: return max(f(a, b, i+1, j), f(a, b, i, j+1)) assert f( ['G', 'C', 'A', 'T', 'T', 'T'], ['G', 'C', 'A', 'T', 'T', 'T'], 3, 3) == 3
benchmark_functions_edited/f8989.py
def f(number): binary = str(bin(number))[2:] return int(binary[-1], 2) assert f(150) == 0
benchmark_functions_edited/f6723.py
def f(value, conv): try: return conv(value) except ValueError: return None assert f('ab', lambda x: len(x)) == 2
benchmark_functions_edited/f14509.py
def f(day1: int, day2: int) -> int: max_day = max(day1, day2) min_day = min(day1, day2) days_in_between = max_day - min_day return days_in_between // 7 assert f(20, 3) == 2
benchmark_functions_edited/f1258.py
def f(Vin, R1, R2): return Vin * R2 / (R1 + R2) assert f(3, 2, 1) == 1
benchmark_functions_edited/f2980.py
def f(s: str) -> int: return len(s.splitlines()) assert f("I am a unit test", ) == 1
benchmark_functions_edited/f10569.py
def f(arg1, arg2): a = 1 a += 2 return a assert f('','something') == 3
benchmark_functions_edited/f13736.py
def f(field): count = 0 while field: field &= field - 1 count += 1 return count assert f(0b00000101) == 2
benchmark_functions_edited/f1946.py
def f(perimeter, apothem): return float((perimeter * apothem) / 2) assert f(3, 4) == 6
benchmark_functions_edited/f14081.py
def f(r1, r2, r3): return r1[0] * r2[1] * r3[2] + r1[1] * r2[2] * r3[0] + r1[2] * r2[0] * r3[ 1] - r1[2] * r2[1] * r3[0] - r1[0] * r2[2] * r3[1] - r1[1] * r2[0] * r3[2] assert f( [1, 2, 3], [1, 2, 3], [1, 2, 3]) == 0
benchmark_functions_edited/f148.py
def f(param): c = 2 + param return c assert f(-1) == 1
benchmark_functions_edited/f815.py
def f(bs) -> int: return sum(1 for b in bs if b) assert f([True, False, True, True]) == 3
benchmark_functions_edited/f7805.py
def f(s, f, c): try: res = s[f:].index(c) + f except: res = None return res assert f('test', 1, 't') == 3
benchmark_functions_edited/f9610.py
def f(word1, word2): assert len(word1) == len(word2) count = 0 for c1, c2 in zip(word1, word2): if c1 != c2: count += 1 return count assert f(u"kitten", u"kitten") == 0
benchmark_functions_edited/f5973.py
def f(xy_a, xy_b): x_a, y_a = xy_a x_b, y_b = xy_b return abs(x_a-x_b) + abs(y_a-y_b) assert f((0, 0), (1, 0)) == 1
benchmark_functions_edited/f6055.py
def f(zval): zmax = [0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 1.0] for i,z in enumerate(zmax): if zval < z: return i+1 assert f(0.11) == 2
benchmark_functions_edited/f11811.py
def f(Fmask, cloud_shadow, dilatation): cloud_shadow_Fmask = cloud_shadow * Fmask dilatation_Fmask = (dilatation - cloud_shadow) * 4 other_Mask = - (dilatation - 1) remain_Fmask = other_Mask * Fmask return cloud_shadow_Fmask + dilatation_Fmask + remain_Fmask assert f(0, 0, 0) == 0
benchmark_functions_edited/f8837.py
def f(signal): sec_diff = [] for i in range(0,len(signal)-2): sec_diff.append(abs(signal[i+2]-signal[i])) fd_sum = sum(sec_diff) delta = float(fd_sum)/(len(signal)-2) return(delta) assert f([1, 1, 1, 1, 1, 1]) == 0
benchmark_functions_edited/f1696.py
def f(nn): return ((nn / 2) * (nn + 1)) ** 2 assert f(1) == 1
benchmark_functions_edited/f12205.py
def f(array, target): left = 0 right = len(array) - 1 while left <= right: mid = int(left + (right - left) / 2) if array[mid] == target: return mid if array[mid] < target: left = mid + 1 else: right = mid - 1 return -1 assert f(list(range(10)), 9) == 9
benchmark_functions_edited/f7781.py
def f(s): seen = set() pos = 0 for atom in s: key = atom.val() if key not in seen: pos += 1 seen.add(key) return pos assert f(frozenset()) == 0
benchmark_functions_edited/f10871.py
def f(s): # Accumulator count = 0 # Loop variable for i in range(len(s)): if s[i] == '/': count= count + 1 return count assert f('//hi/how/are/you/') == 6
benchmark_functions_edited/f12739.py
def f(cv, vals): v1,v2 = vals pp = v1 + cv*(v2-v1) return pp assert f(1, [1,3]) == 3
benchmark_functions_edited/f5272.py
def f(x, y): if y < 0: fac = -1.0 else: fac = 1.0 return abs(x) * fac assert f(1, 1) == 1
benchmark_functions_edited/f4268.py
def f(p, q): if p<q: return f(q, p) if q == 0: return p return f(q, abs(p%q)) assert f(20, 25) == 5
benchmark_functions_edited/f13456.py
def f(iterable, default=None): result = next((i for i in iterable if i is not None), default) if isinstance(result, Exception): raise result return result assert f([1, None, None]) == 1
benchmark_functions_edited/f3647.py
def f(numbers): result = 1 for x in numbers: result *= x return result assert f([3, 2, 1]) == 6
benchmark_functions_edited/f5301.py
def f(cpm_value): usv_per_click = 0.1/12 return cpm_value * usv_per_click assert f(0) == 0
benchmark_functions_edited/f4135.py
def f(x, keylist): val = x for key in keylist: val = val.get(key, 0) return val assert f({1: 2}, [1]) == 2
benchmark_functions_edited/f12660.py
def f(predictions, actuals): t = [pr for pr, act in zip(predictions, actuals) if pr == act] n = predictions return len(t) / len(n) assert f(list(range(10)), list(range(10))) == 1
benchmark_functions_edited/f13196.py
def f(beta, p, pthre=0.05): pred = 1 if p < pthre else 0 real = 1 if beta != 0 else 0 if pred == 1 and real == 1: return 0 elif pred == 1 and real == 0: return 1 elif pred == 0 and real == 1: return 2 else: return 3 assert f(1, 0) == 0
benchmark_functions_edited/f11445.py
def f(motor_output, dead_zone): if abs(motor_output) < .00001: #floating point rounding error workaround. return 0 elif motor_output > 0: return (motor_output*(1-dead_zone))+dead_zone else: return (-motor_output*(dead_zone-1))-dead_zone assert f(0, 1) == 0
benchmark_functions_edited/f4503.py
def f(ll): if type(ll) is not list: return ll return f(ll[0]) assert f([[[5], [6]], [7]]) == 5
benchmark_functions_edited/f10885.py
def f(pattern, bwt, starts, occ_counts_before): # Implement this function yourself return 0 assert f(b'AAAA', b'ACGTA', [0], [1]) == 0
benchmark_functions_edited/f1652.py
def f(cube1,cube2): return (cube1 > cube2)*cube1 + (cube1 <= cube2) * cube2 assert f(1, 3) == 3
benchmark_functions_edited/f7371.py
def f(sa, ea, sb, eb): assert sa < ea and sb < eb if sa > sb: sa, sb = sb, sa ea, eb = eb, ea # sa <= sb distance = max(0, sb - ea) return distance assert f(10, 20, 15, 20) == 0
benchmark_functions_edited/f10466.py
def f(fun, value): fun(value) return value assert f(lambda x: print('x =', x), 2) == 2
benchmark_functions_edited/f7225.py
def f(r2, n, p): adj_r2 = 1 - (1 - r2) * (n - 1) / (n - p - 1) return adj_r2 assert f(1, 1000, 5) == 1
benchmark_functions_edited/f13331.py
def f(n): index = {} rem, curIndex = 1, 0 while rem > 0 and rem not in index: index[rem] = curIndex rem = rem * 10 ext = 0 while rem < n: rem = rem * 10 ext += 1 curIndex += 1 + ext rem = rem % n if rem == 0: return 0 ...
benchmark_functions_edited/f9856.py
def f(taxa_list, delim): total = 0 for taxon, abund in taxa_list.items(): tkns = taxon.split(delim) if len(tkns) == 1: total += abund return total assert f(dict(), '.') == 0
benchmark_functions_edited/f2535.py
def f(function, param1, param2): return function(param1, param2) assert f(max, 1, 2) == 2
benchmark_functions_edited/f13572.py
def f(z): if abs(z) < 0.9 and z.real >= 0: return 1 elif abs(z) <= 1 and z.real < 0: return 2 elif 0.9 <= abs(z) <= 1 and abs(1 - z) < 0.9: return 3 elif 0.9 <= abs(z) <= 1 and abs(1 - z) >= 0.9: return 4 elif 1 < abs(z) < 1.1 and abs(1 - z) >= 0.9 and z.real >= 0: ...
benchmark_functions_edited/f14328.py
def f(p, p1, p2): x = p1['x'] y = p1['y'] dx = p2['x'] - x dy = p2['y'] - y if dx != 0 or dy != 0: t = ((p['x'] - x) * dx + (p['y'] - y) * dy) / (dx * dx + dy * dy) if t > 1: x = p2['x'] y = p2['y'] elif t > 0: x += dx * t y ...
benchmark_functions_edited/f6773.py
def f(s): while len(s) > 0: if s[0] == ' ': s = s[1:] continue if s[-1] in " ,": s = s[0:-1] continue break return int(s) assert f(" 9 ") == 9
benchmark_functions_edited/f11406.py
def f(page): if isinstance(page, str) and page.isdigit(): page = int(page) if isinstance(page, int) and (page > 0): return page return 1 assert f(1.2) == 1
benchmark_functions_edited/f6874.py
def f(terms): weight_sum = sum(term[1] for term in terms) if weight_sum <= 0: return 0 return sum(float(val * weight) for weight, val in terms) / weight_sum assert f( [(1, 1), (1, 1), (1, 1), (1, 1)] ) == 1
benchmark_functions_edited/f1824.py
def f(n): a, b = 1, 1 while n: a, b = b, a + b n -= 1 return a assert f(3) == 3
benchmark_functions_edited/f4619.py
def f(int_type, offset): mask = 1 << offset return int_type ^ mask assert f(4, 2) == 0
benchmark_functions_edited/f1574.py
def f(a): return sum(a) / len(a) assert f( [2, 4, 6, 8, 10, 12] ) == 7
benchmark_functions_edited/f4485.py
def f(year_length, day): # return ((2*np.pi)/year_length) * day return (day/year_length) * 360.0 assert f(200, 0) == 0
benchmark_functions_edited/f14543.py
def f(lst, tg): top = len(lst) - 1 bottom = 0 while top > bottom: curri = (top - bottom)//2 + bottom if lst[curri] < tg: bottom = curri else: top = curri if top - bottom == 1: if abs(lst[top] - tg) < abs(lst[bottom] - tg): r...
benchmark_functions_edited/f2933.py
def f(array): total = sum(array) count = len(array) return total / count assert f(range(1, 6)) == 3
benchmark_functions_edited/f8395.py
def f(v, k, idx): return (v[idx + 2 * k - 1] - v[idx + k])**2 assert f( [1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0], 3, 1) == 0
benchmark_functions_edited/f1579.py
def f(i, j, k): mot = i if (i > j) else j return mot if (mot > k) else k assert f(1, 3, 2) == 3
benchmark_functions_edited/f6270.py
def f(p): return p/(2-p) assert f(1) == 1
benchmark_functions_edited/f14044.py
def f(x,y): m = len(x) n = len(y) c = [[0]*n]*m for i in range(1, m): c[i][0] = 0 for j in range(n): c[0][j] = 0 for i in range(1, m): for j in range(1, n): if x[i] == y[j]: c[i][j] = c[i-1][j-1] + 1 elif c[i-1][j] >= c[i][j-1]: ...
benchmark_functions_edited/f11419.py
def round_to_base (value, base=1): return int(base * round(float(value) / base)) assert f(0, 2) == 0
benchmark_functions_edited/f3646.py
def f(a,b): a = abs(a); b = abs(b) while (a > 0): b = b % a tmp=a; a=b; b=tmp return b assert f(4,0) == 4
benchmark_functions_edited/f3073.py
def f(default=None, request=None, **kwargs): return request and request.context.get("user", None) or default assert f(2) == 2
benchmark_functions_edited/f4822.py
def f(l): if l == 0: return 0 else: return (l - 12) / 2 assert f(0) == 0
benchmark_functions_edited/f2892.py
def f(x, y): assert len(x) == len(y) return sum(xi != yi for xi, yi in zip(x, y)) assert f(b'G', b'A') == 1
benchmark_functions_edited/f9867.py
def f(a, b, lattice, encoding): if lattice[a][b] == 1: return b elif lattice[b][a] == 1: return a else: entry = [a * b for a, b in zip(lattice[a], lattice[b])] return encoding.get(tuple(entry), 0) assert f(1, 0, [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], []) =...
benchmark_functions_edited/f9396.py
def f(energy,lens_configuration): focal_distance=0.0 return focal_distance assert f(1,1) == 0
benchmark_functions_edited/f9000.py
def f(wavelengths, target): idx = 0 minimum = float('inf') for (i, wl) in enumerate(wavelengths): if abs(target - wl) < minimum: minimum = abs(target - wl) idx = i return idx assert f([500, 600, 700], 800) == 2
benchmark_functions_edited/f7353.py
def f(byte_str): value = 0 size = 0 for current in byte_str: value |= (ord(current) & 0x7F) << (size * 7) size += 1 return value assert f(chr(1)) == 1
benchmark_functions_edited/f1971.py
def f(health, damage): return 0 if health - damage < 0 else health - damage assert f(50, 100) == 0
benchmark_functions_edited/f4759.py
def f(s): if s is not None: return len(s) return 0 assert f("foo") == 3
benchmark_functions_edited/f3567.py
def f(val, length): if val & (1 << (length - 1)): return val - (1 << length) return val assert f(0, 2) == 0
benchmark_functions_edited/f3875.py
def f(t, T): t1 = t % (2*T) t2 = (2*T - 1 - t) % (2*T) return min([t1, t2]) assert f(3, 5) == 3