file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f7347.py
def f(row): if not row: return None if len(row.keys()) == 1: # print(row.keys()) key = list(row.keys())[0] return row[key] return row assert f({"count(*)": 3}) == 3
benchmark_functions_edited/f14425.py
def f(code: str) -> int: codestr = code.split("-")[-1] # Get the part of the string we care about return ( len(codestr) - (codestr.count("0")) + 2 ) assert f("46-2222") == 6
benchmark_functions_edited/f9948.py
def f(dictionary, key): # pragma: no cover return dictionary.get(key) assert f( { 'one': 1, 'two': 2, 'three': 3, }, 'one', ) == 1
benchmark_functions_edited/f11229.py
def f(peal_minutes: float, num_bells: int) -> float: peal_speed_seconds = peal_minutes * 60 seconds_per_whole_pull = peal_speed_seconds / 2520 # 2520 whole pulls = 5040 rows return seconds_per_whole_pull / (num_bells * 2 + 1) assert f(0, 0) == 0
benchmark_functions_edited/f14229.py
def f(responses, derived): try: amount_1 = float(responses.get('your_child_support_paid_c', 0)) except ValueError: amount_1 = 0 try: amount_2 = float(responses.get('your_spouse_child_support_paid_c', 0)) except ValueError: amount_2 = 0 return abs(amount_1 - amount_2...
benchmark_functions_edited/f11725.py
def f(num_vars): for x in range(10): if num_vars <= 2 ** x: return x assert f(11) == 4
benchmark_functions_edited/f6878.py
def f(*args, **kwargs): print("\nmock> f({}) ==> 0".format(args)) # pragma: no cover return 0 # pragma: no cover assert f(1, 2, 3, 4, 5) == 0
benchmark_functions_edited/f5191.py
def printd (msg): #for debug #print msg return 0 f= open(Config.MONITOR_LOG,'r+') f.seek(0, 2) f.write(str(msg)+"\n") f.close() assert f(u'hello world') == 0
benchmark_functions_edited/f4067.py
def f(items): if len(items): res = items[0] for item in items[1:]: res = res * item return res else: return 1 assert f([]) == 1
benchmark_functions_edited/f5003.py
def f(a, b): ab = str(a) + str(b) ba = str(b) + str(a) if ab > ba: return a else: return b assert f(3, 0) == 3
benchmark_functions_edited/f12249.py
def f(connection): try: return int(connection.split('PFI', 1)[1]) except (ValueError, IndexError): msg = "PFI connection string %s does not match format 'PFI<N>' for integer N" raise ValueError(msg % str(connection)) assert f('PFI0') == 0
benchmark_functions_edited/f12357.py
def f(code, aname): if code[:-1] == '15900' or code == '511880' or code == '511990' or code == '131810' or code == '204001': return 1000000 else: if aname == 'a1': return 0 # 10000#0 means except money fund, no other trades are allowed elif aname == 'a2': return ...
benchmark_functions_edited/f9505.py
def f(n): squares = 0 for num in range(1, n, 2): squares += num ** 2 return squares assert f(1) == 0
benchmark_functions_edited/f2142.py
def f(n): if n == 1: return n else: return n*f(n - 1) assert f(3) == 6
benchmark_functions_edited/f6483.py
def f(entropy_bits: int) -> int: return int(entropy_bits / 32) assert f(256) == 8
benchmark_functions_edited/f8372.py
def f( text, ignore_spaces=True): if ignore_spaces: text = text.replace(" ", "") return len(text) assert f( "hello") == 5
benchmark_functions_edited/f10238.py
def f(n, k): if 0 <= k <= n: ntok = 1 ktok = 1 for t in range(1, min(k, n - k) + 1): ntok *= n ktok *= t n -= 1 return ntok // ktok else: return 0 assert f(100, 100) == 1
benchmark_functions_edited/f9575.py
def f(an_iterable): # innitialize product variable product = 1 # multiply by elements of iterables for num in an_iterable: product *= num return product assert f(range(1, 4)) == 6
benchmark_functions_edited/f827.py
def f(string): if string is not None: r = 1 else: r = 0 return r assert f(1) == 1
benchmark_functions_edited/f6833.py
def f(f, v, i, h): w = [v_j + (h if j== i else 0) # add h to just the ith element of h for j, v_j in enumerate(v)] return (f(w) - f(v)) / h assert f(lambda x: x[0]**2, [1, 1, 2], 1, 1e-6) == 0
benchmark_functions_edited/f7286.py
def f(A, i0): i_max = i0 for i in range(i0 + 1, len(A)): if abs(A[i]) > abs(A[i_max]): i_max = i return i_max assert f([1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000], 0) == 0
benchmark_functions_edited/f1451.py
def f(config: dict) -> int: return config["proc"] assert f( { "proc": 0, }, ) == 0
benchmark_functions_edited/f8271.py
def f(wav, v): c = 299792458. # m/s if isinstance(v, (int, float)): return (v / c) * wav else: deltalambda = [(v / c) * lmda for lmda in wav] return deltalambda assert f(500e-9, 0) == 0
benchmark_functions_edited/f4167.py
def f(obj, default=0): try: obj_int = int(obj) except ValueError: obj_int = default return obj_int assert f(0.1) == 0
benchmark_functions_edited/f6614.py
def f( dispX, dispY, radius ): maskX = dispX <= radius maskY = dispY <= radius maskXY = maskX & maskY return maskXY/ float(radius *radius) assert f(1,2,1) == 0
benchmark_functions_edited/f586.py
def f(array): return min([a for a in array if a==a]) assert f([1,2,3]) == 1
benchmark_functions_edited/f11621.py
def f(data, funcs): for f in funcs: try: func = eval("lambda x: "+f) data = func(data) except Exception as e: print("Function "+f+" did not evaluate correctly:") print(e) print("Skipping.\n"+"-"*79) return(data) assert f(5, ["x-x"]) ==...
benchmark_functions_edited/f1753.py
def f(n1, n2): if n1 == 0: return n2 return f(n2 % n1, n1) assert f(12, 30) == 6
benchmark_functions_edited/f4447.py
def f(value): return value - 6 * (value >> 4) assert f(0x05) == 5
benchmark_functions_edited/f2678.py
def f(s): try: return int(s) except ValueError: return float(s) assert f(5) == 5
benchmark_functions_edited/f14262.py
def f(w_param, price_div): return price_div * ((w_param + price_div**2)**(-0.5)) assert f(1, 0) == 0
benchmark_functions_edited/f3507.py
def f(a, b): if a % b < b / 2: return a // b else: return (a // b) + 1 assert f(5, 3) == 2
benchmark_functions_edited/f9299.py
def f(song_dict: dict) -> int: total_duration = 0 for k, v in song_dict.items(): total_duration += v.length return total_duration assert f({}) == 0
benchmark_functions_edited/f10285.py
def f(val, minimum, maximum): return round((val - minimum) / float(maximum - minimum)) assert f(0.0000000001, 1, 100) == 0
benchmark_functions_edited/f5320.py
def f(fn, args, kwargs): if fn is None: return args[0] try: return fn(*args, **kwargs) except TypeError: return fn(*args) assert f(lambda: 1, [], {}) == 1
benchmark_functions_edited/f6369.py
def f(sym): return {'H': 1, 'HE': 2, 'C': 6, 'N': 7, 'O': 8, 'S': 16, 'F': 9, 'CL': 17, 'NE': 10, 'AR': 18}[sym.upper()] assert f('H') == 1
benchmark_functions_edited/f6460.py
def f(queryset): try: return queryset[:1][0] except IndexError: return None assert f([1]) == 1
benchmark_functions_edited/f7318.py
def f(player_pos, current_move): player_pos = (player_pos - current_move) % 10 if player_pos == 0: return 10 return player_pos assert f(10, 2) == 8
benchmark_functions_edited/f6693.py
def f(x): # Example distribution = [99, 198, 297, 396, 495] x_class = 0 for i in range(len(distribution)): if x > distribution[i]: x_class += 1 return x_class assert f(0.99) == 0
benchmark_functions_edited/f4042.py
def f(obj): return obj() if hasattr(obj, "__call__") else obj assert f(lambda: 3) == 3
benchmark_functions_edited/f6344.py
def f(thing, operation = None): try: return len(thing) except: return 0 assert f({1, 2, 3}) == 3
benchmark_functions_edited/f3264.py
def f(bytearr): csum = 0 for b in bytearr: csum += b return csum % 256 assert f(bytes([1, 2, 3])) == 6
benchmark_functions_edited/f13224.py
def f(x): # Check that x is positive if x < 0: print("Error: Invalid Number") return -1 else: print("Correct number") # initial guess value of sqrt z = x / 2 # continiously improve guess # adapted from https://tour.golang.org/flowcontrol/8 while abs(x - (z*...
benchmark_functions_edited/f5729.py
def f(a, b): if a is None: if b is None: return None else: return 1 / b elif b is None: return a return a / b assert f(1, None) == 1
benchmark_functions_edited/f7475.py
def f(string): while (len(string.split(":")) < 3): string = "00:" + string return sum(secs * int(digit) for secs,digit in zip([3600, 60, 1], string.split(":"))) assert f( "00:00:00" ) == 0
benchmark_functions_edited/f5472.py
def f(coinFlips: str) -> int: heads = 0 for flip in coinFlips: if flip == "H": heads += 1 return heads assert f("HHHHH") == 5
benchmark_functions_edited/f14140.py
def f(curve_points): area = 0.0 for i in range(1, len(curve_points)): area += (curve_points[i][0] - curve_points[i - 1][0]) * \ ((curve_points[i][1] + curve_points[i - 1][1]) / 2) return area assert f([(0, 0)]) == 0
benchmark_functions_edited/f4644.py
def f(contingency_table, i): return sum([contingency_table[i][j] for j in range(len(contingency_table))]) assert f( [[1, 0, 0, 0], [0, 1, 1, 0], [0, 0, 0, 1], [0, 0, 1, 0]], 3) == 1
benchmark_functions_edited/f10428.py
def f(x, a=0., b=0., c=0.): return a * x ** 2 + b * x + c assert f(1, 1, 0, 0) == 1
benchmark_functions_edited/f3782.py
def f(num, n, base=10): return int(num / base**n) % base assert f(1234, 0, 10) == 4
benchmark_functions_edited/f12519.py
def f(key, h): if '.' in key: keys = key.split('.') return h.get(keys[0]).get(keys[1]) else: return h.get(key) assert f('physics.tyre_wear', {'physics': {'max_speed': 10000,'max_fuel': 10000, 'tyre_wear': 2}}) == 2
benchmark_functions_edited/f971.py
def f(p): return (p & 0xF) + 3 assert f(0b11010001) == 4
benchmark_functions_edited/f10222.py
def f(millis, return_with_seconds=True): if return_with_seconds: return (millis/1000) % 60 + " sekunder" else: return (millis/1000) % 60 assert f(1000, False) == 1
benchmark_functions_edited/f10086.py
def f(lst): if lst: return max(lst) - min(lst) return 0 assert f([-1, 1, 1, 1]) == 2
benchmark_functions_edited/f11827.py
def f(speed_list): speed_mb = 0 if speed_list: for port in speed_list: if port.get_speed_mb(): speed_mb += port.get_speed_mb() return speed_mb assert f(None) == 0
benchmark_functions_edited/f2909.py
def f(n): # bin(n) returns 0b.... # bin(n)[2:] trims "ob" return sum(int(x) for x in bin(n)[2:]) % 2 assert f(31) == 1
benchmark_functions_edited/f13124.py
def f(g, k, p): u = g y = 1 while k != 0: if k % 2 == 1: y = y * u % p u = u * u % p k //= 2 return y assert f(2, 1, 5) == 2
benchmark_functions_edited/f10312.py
def f(variable, orig_img, mode): # Apply the shrinkage-thresholding update element-wise. z = variable - orig_img if mode == "PP": return (z <= 0) * variable + (z > 0) * orig_img return (z > 0) * variable + (z <= 0) * orig_img assert f(0, 0, "P") == 0
benchmark_functions_edited/f10006.py
def f(binList): # initialize number and counter n = 0 k = 0 for b in reversed(binList): n += b * (2 ** k) k += 1 return n assert f( [1, 0, 0] ) == 4
benchmark_functions_edited/f10361.py
def f(integer: int) -> int: if integer in {0, 1}: return 1 return integer * f(integer - 1) assert f(1) == 1
benchmark_functions_edited/f776.py
def f(y, f, t, h): return y + h * f(t, y) assert f(1, lambda t,y: 1, 0.0, 0) == 1
benchmark_functions_edited/f733.py
def f(r1, c1, r2, c2): return (r2 + 1 - r1) * (c2 + 1 - c1) assert f(0, 0, 1, 0) == 2
benchmark_functions_edited/f1165.py
def f(v1, v2): if v1 < v2: return -1 elif v1 > v2: return 1 return 0 assert f(1, 1) == 0
benchmark_functions_edited/f4820.py
def f(a, b): return max((abs(i-j) for i, j in zip(a,b))) assert f(bytearray(b'abc'), b'abc') == 0
benchmark_functions_edited/f6555.py
def f(s): total_sum = 0 for char in s: try: char = int(char) total_sum += char except ValueError: pass return total_sum assert f("5 ") == 5
benchmark_functions_edited/f3697.py
def f(first, second): result = first + second return result assert f(-10, 10) == 0
benchmark_functions_edited/f6967.py
def f(data): possible_values = set(range(len(data) + 1)) new_key = min(possible_values - set(data)) return new_key assert f([0, 1, 2, 3, 4]) == 5
benchmark_functions_edited/f13326.py
def f(n: int) -> int: def sum_multiples(divisor: int, terms: int) -> int: return divisor * (terms * (terms + 1)) // 2 fizzsum = sum_multiples( 3, (n-1) // 3) buzzsum = sum_multiples( 5, (n-1) // 5) intersectsum = sum_multiples(15, (n-1) // 15) return fizzsum + buzzsum - intersect...
benchmark_functions_edited/f3373.py
def f(grid): if not grid: return 0 pos = grid.find('\n') if pos < 0: return 1 return pos assert f("... ...") == 1
benchmark_functions_edited/f10773.py
def f(tensor_tuple: tuple): tensor_list = list(tensor_tuple) if None in tensor_list: tensor_list.remove(None) if len(tensor_list) == 0: return 0 s = tensor_list[0] for i in range(1, len(tensor_list)): s *= tensor_list[i] return s assert f( (None, 2, 3) ) == 6
benchmark_functions_edited/f8681.py
def f(bits): # We assume bits are given in high to low order. For example, # the bits [1, 1, 0] will produce the value 6. return sum(v * (1 << (len(bits)-i-1)) for i, v in enumerate(bits)) assert f( [1, 1, 1] ) == 7
benchmark_functions_edited/f4980.py
def f(cb: float, cs: float) -> float: if cb == 0: return 0 elif cs == 1: return 1 else: return min(1, cb / (1 - cs)) assert f(0.5, 0.5) == 1
benchmark_functions_edited/f13412.py
def f(dataset, geneid, colors): colorsDict = colors try: colorVal = colorsDict[dataset][4:-1].split(',')[2] return int(colorVal) except KeyError: return 0 assert f(1, 1, {'d1': (0, 0, 0, 255, 0, 0)}) == 0
benchmark_functions_edited/f2846.py
def f(p, val): r = 0 for c in p: r = r*val + c return r assert f((), 2) == 0
benchmark_functions_edited/f5457.py
def f(verse_id: int) -> int: return int(verse_id % 1000000 / 1000) assert f(4004001) == 4
benchmark_functions_edited/f10243.py
def f(input_str): try: ret = int(input_str) except ValueError: # try float. try: ret = float(input_str) except ValueError: ret = input_str return ret assert f(1) == 1
benchmark_functions_edited/f4726.py
def f(n): count = 0 for i in range(1, n+1): count += str(i).count('1') return count assert f(3) == 1
benchmark_functions_edited/f6732.py
def f(exception): if exception is None: return 0 if isinstance(exception[1], SystemExit): return exception[1].code return 1 assert f([Exception, SystemExit(2)]) == 2
benchmark_functions_edited/f4964.py
def f(section, name): try: return float(section[name]) except (ValueError, TypeError, KeyError): return float(0) assert f({ 'foo': 0 }, 'foo') == 0
benchmark_functions_edited/f5417.py
def f(number): check = 5 for n in number: check = (((check or 10) * 2) % 11 + int(n)) % 10 return check assert f(list('123456')) == 7
benchmark_functions_edited/f14411.py
def f(num_attributes, sensitivity, epsilon): return (num_attributes - 1) * sensitivity / epsilon assert f(4, 1, 1) == 3
benchmark_functions_edited/f9386.py
def f(file_name): try: item = (0, None) with open(file_name) as file_handler: for item in enumerate(file_handler): pass return item[0] + 1 except IOError: return 0 assert f('test.txt') == 0
benchmark_functions_edited/f7556.py
def f(str): if not isinstance(str, list): str = str.splitlines(True) for line in reversed(str): if line.strip(): return len(line) - len(line.lstrip()) return 0 assert f('\n') == 0
benchmark_functions_edited/f7480.py
def f(row: int, column: int) -> int: boxrow = row // 3 boxcol = column // 3 return boxrow * 3 + boxcol assert f(0, 5) == 1
benchmark_functions_edited/f13904.py
def f(x, y): if x is not None and y is not None: return x + y elif x is not None: return x elif y is not None: return y else: return None assert f(2, 3) == 5
benchmark_functions_edited/f2506.py
def f(termA, termB): vertice = ((-termB)/(2*termA)) return vertice assert f(1,0) == 0
benchmark_functions_edited/f9511.py
def f(rank, rmax): perc = 100 * float(rank)/float(rmax) if float(rank) < 0: return 2 # red if rank == 0: rank = 1 if perc >= 75: return 7 # cyan if perc >= 50: return 3 # green if perc >= 25: return 4 # yellow return 8 assert f(75, 100) == 7
benchmark_functions_edited/f3076.py
def f(possible_moves): if 5 in possible_moves: return 5 assert f(range(1, 8)) == 5
benchmark_functions_edited/f8352.py
def f(a, b): tp = 0 for item in a: if item in b: tp += 1 return tp assert f(set(['A', 'B', 'C']), set([])) == 0
benchmark_functions_edited/f7684.py
def f(s): if (s is None or s == "" or s == "None"): return None return (int(s)) assert f(2.2) == 2
benchmark_functions_edited/f10088.py
def f(graph: dict, from_node: str) -> int: def _inner(graph, node, acc): if not graph[node]: return for (n, nxt) in graph[node]: acc.add(nxt) _inner(graph, nxt, acc) acc = set() _inner(graph, from_node, acc) return len(acc) assert f( { ...
benchmark_functions_edited/f10874.py
def f(x, n): # if all(v == 0 for v in n): # return 1 res = 1 for i in reversed(n): if i % 2 == 1: res = res * x x = x * x return res assert f(2, [0, 1]) == 2
benchmark_functions_edited/f55.py
def f(x, y): print(x, y) return x + y assert f(2, -2) == 0
benchmark_functions_edited/f13374.py
def f(a, n): if a == 0: return 0 elif a == 1: return 1 elif a == 2: if (n % 8) in set([3, 5]): return -1 else: return 1 elif a % 2 == 0: return f(2, n) * f(a // 2, n) elif a >= n: return f(a % n, n) elif a % 4 == n % 4 == 3:...
benchmark_functions_edited/f12094.py
def f(hcount_str): if not hcount_str: return 0 if hcount_str == 'H': return 1 return int(hcount_str[1:]) assert f('H2') == 2
benchmark_functions_edited/f7362.py
def f(prev_emo, current_emo): if prev_emo == current_emo: return 0 else: x = current_emo - prev_emo return x assert f(2, 4) == 2
benchmark_functions_edited/f11619.py
def f(pos1: tuple, pos2: tuple): distance = 0 for ind in range(len(pos1)): distance += abs(pos1[ind] - pos2[ind]) return distance assert f( (1, 1), (0, 0) ) == 2
benchmark_functions_edited/f10965.py
def f(pos,L,move): pos += move # if pos == L: #moved off right or bottom # return(0) # if pos == -1:#moved off top or left # return(L-1) return(pos) assert f(4, 5, -1) == 3
benchmark_functions_edited/f3760.py
def f(t,r_i): s = 0 for x in t: s *= 2 if r_i == 1: if x.real>0: s+=1 else: if x.imag>0: s+=1 r_i = 1 -r_i return s assert f( (1,0), 0) == 0
benchmark_functions_edited/f4036.py
def f(obj): try: return obj() except (TypeError): return obj assert f(5) == 5