file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f5286.py
def f(line, tag, namespace, default=0): try: val = float(line.find(namespace + tag).text) except: val = default return val assert f( "some string", 'tag2', 'http://example.com/ns/', 0) == 0
benchmark_functions_edited/f13406.py
def f(my_list): return sorted(my_list)[len(my_list) // 2] return utils.format_genomic_distance(window_size, precision=0) assert f(list(range(1, 10))) == 5
benchmark_functions_edited/f4058.py
def f(base1, base2, height): return 1 / 2 * (base1 + base2) * height assert f(20, 10, 0) == 0
benchmark_functions_edited/f2701.py
def f(x, a, b): return 255 * (x-float(a))/(b-a) assert f(1, 1, 3) == 0
benchmark_functions_edited/f3882.py
def f(V, w, c): term1 = c['a']*(V-c['E']) term2 = w return w + (c['dt']/c['tau'])*(term1-term2) assert f(0, 0, {'a': 1, 'E': 0, 'dt': 1, 'tau': 1}) == 0
benchmark_functions_edited/f9128.py
def f(arg): if arg is None: return None if not isinstance(arg, int): raise ValueError(f"Invalid value for gpu: {repr(arg)}") if 0 <= arg <= 4: return arg raise ValueError(f"Invalid value for gpu: {repr(arg)}") assert f(0) == 0
benchmark_functions_edited/f458.py
def f(a, b): a += b return a assert f(1, 2) == 3
benchmark_functions_edited/f13966.py
def f(processesClass): minorValue = [0, 999999] for i in range(len(processesClass)): if processesClass[i][-1] <= minorValue[1]: minorValue[0] = i minorValue[1] = processesClass[i][-1] return minorValue[0] assert f( [ [1, 5, 4, 2, 1], [1, 2, 5, 3, 1], [1, 3, 5, 5, 2], [4, 4, 4, 4, 3], [3, 1, 1, 1, 1], ] ) == 4
benchmark_functions_edited/f8576.py
def f(x): if isinstance(x, list) and len(x) == 3: return x[1] if x[0] else x[2] raise ArithmeticError("`ifthenelse` is only supported for 3-dimensional vectors") assert f([False, 2, 3]) == 3
benchmark_functions_edited/f1819.py
def f(num): try: return int(num) + 5 except ValueError as err: return err assert f('2') == 7
benchmark_functions_edited/f4308.py
def f(rgb_idx, n_ir, n_rgb): ir_idx = round(n_ir*float(rgb_idx)/n_rgb) return ir_idx assert f(2, 10, 20) == 1
benchmark_functions_edited/f8423.py
def f(iRes, posTM):# {{{ for i in range(len(posTM)): (b, e) = posTM[i] if iRes >= b and iRes < e: return i return -1 # }}} assert f(2, [(1, 20)]) == 0
benchmark_functions_edited/f7799.py
def f(a, b, c): if b ==0: return c return a + f(a,b-1,c) assert f(2, 2, 0) == 4
benchmark_functions_edited/f2304.py
def f(i): n = 0 while (2**n) < i: n += 1 return n assert f(33) == 6
benchmark_functions_edited/f12163.py
def f(dataset, colors): colorsDict = colors try: colorVal = colorsDict[dataset][4:-1].split(',')[2] return int(colorVal) except KeyError: return 0 assert f(1, {}) == 0
benchmark_functions_edited/f1905.py
def f(n): res = 1 while (n > 0): res *= n n -= 2 return res assert f(0) == 1
benchmark_functions_edited/f4977.py
def f(s): if s.strip() == '': return 0 list_ = s.strip().split(" ") for i in range(list_.count('')): list_.remove('') return len(list_[-1]) assert f( 'l') == 1
benchmark_functions_edited/f12784.py
def f(x): # check that x is positive if x < 0: print("Error: negative value entered") return -1 else: print("Here we go...") # initial guess for square root z = x / 2.0 # continuously improve the guess # adapted from https://tour.golang.org/flowcontrol/8 while abs(x - (z*z)) > 0.000001: z -= (z*z - x) / (2 * z) return z assert f(0) == 0
benchmark_functions_edited/f12403.py
def f(string, byte_index): for idx, char in enumerate(string): char_size = len(char.encode('utf-8')) if char_size > byte_index: return idx byte_index -= char_size return len(string) assert f(u'abcde', 4) == 4
benchmark_functions_edited/f4624.py
def f(similar_list): if not None in similar_list: found_matches = len(similar_list) else: found_matches = 0 return found_matches assert f(['b', None]) == 0
benchmark_functions_edited/f2361.py
def f(mode): return len([i for i in mode if i.isupper()]) assert f('I1') == 1
benchmark_functions_edited/f11834.py
def f(ssq, sz): return int((ssq-abs(sz))/2) assert f(4, 3) == 0
benchmark_functions_edited/f5964.py
def f(x0: float, x1: float, p: float): return x0 if p < 0.5 else x1 assert f(5, 10, 0.3) == 5
benchmark_functions_edited/f2114.py
def f(prevmean, n, x): newmean = prevmean + int(round((x - prevmean) / n)) return newmean assert f(0, 1, 1) == 1
benchmark_functions_edited/f9435.py
def f(doc: str, end: int, start: int = 0): return (doc.count('\n', start, end) + 1) assert f( "a\nb\nc\nd", 10) == 4
benchmark_functions_edited/f9620.py
def f(TP, pos): if pos == 0: return 0 else: return TP / pos assert f(2, 0) == 0
benchmark_functions_edited/f6869.py
def f(points): count = 0 for pointset in points: if pointset[0] is not None and pointset[1] is not None: count += 1 return count assert f([]) == 0
benchmark_functions_edited/f8.py
def f(a,b): return 0.5 * (a+b) assert f(5, 7) == 6
benchmark_functions_edited/f3544.py
def f(objects: list) -> object: return max(set(objects), key=objects.count) assert f([1, 2, 3]) == 1
benchmark_functions_edited/f11471.py
def f(s): return len(s) / 100.0 assert f("") == 0
benchmark_functions_edited/f6420.py
def f(p1,p2): from numpy import asarray p1,p2 = asarray(p1),asarray(p2) from numpy.linalg import norm return norm(p2-p1) assert f( (0,0,0), (0,0,0)) == 0
benchmark_functions_edited/f6024.py
def f(xs): n = len(xs) if n < 1: return None elif n % 2 == 1: return sorted(xs)[n//2] else: return sum(sorted(xs)[n//2-1:n//2+1])/2.0 assert f((1,2,3,4,5)) == 3
benchmark_functions_edited/f10034.py
def f(square): tot_sum = 0 # Calculate sum of all teh pixels in a 3*3 matrix for i in range(3): for j in range(3): tot_sum += square[i][j] return tot_sum//9 assert f( [[0, 1, 0], [0, 1, 0], [0, 0, 0]]) == 0
benchmark_functions_edited/f5890.py
def f(index, input_ranges): return next(i for i, input in enumerate(input_ranges) if input['start'] <= index < input['end']) assert f(0, [{ "start": 0, "end": 4 }]) == 0
benchmark_functions_edited/f5270.py
def f(msb, lsb=None): if lsb is None: lsb = msb return (1 << (msb - lsb + 1)) - 1 assert f(1, 1) == 1
benchmark_functions_edited/f14156.py
def f(count1, count2, sum1, sum2): # check input if not (sum1 and sum2): print("got empty sums for F scores") return 0 if sum1 < count1 or sum2 < count2: print("got empty sums for F scores") return 0 # calculate precision = count2 / sum2 recall = count1 / sum1 if precision + recall == 0: return 0 return 2 * (precision * recall) / (precision + recall) assert f(10, 20, 0, 100) == 0
benchmark_functions_edited/f12010.py
def f(number1: int, number2: int) -> int: if number1 == 0: return number2 return f(number2 % number1, number1) assert f(10, 5) == 5
benchmark_functions_edited/f2195.py
def f(types, tokens): return round(float(len(types)) / float(len(tokens)), 4) assert f(set([1, 2, 3, 4, 5]), set([1, 2, 3, 4, 5])) == 1
benchmark_functions_edited/f13125.py
def f(click_time_one, click_time_two): delta_time = abs(click_time_one - click_time_two) total_sec = 60 * 60 * 24 delta_time = delta_time / total_sec return 1 / (1 + delta_time) assert f(1, 1) == 1
benchmark_functions_edited/f1611.py
def f(tile): v = 2 ** 16 * int(tile[0] / 8) + int(tile[1] / 8) return v assert f( (0, 0) ) == 0
benchmark_functions_edited/f6897.py
def f(num, border): if num < 0: return 0 if num > border: return border return num assert f(4, 4) == 4
benchmark_functions_edited/f7463.py
def f(kernel_size, stride, sidesize): return (sidesize - (kernel_size - 1) - 1) // stride + 1 assert f(2, 1, 2) == 1
benchmark_functions_edited/f13601.py
def f(n): return int(n) if n is not None else None assert f(3.0) == 3
benchmark_functions_edited/f14275.py
def f(timedatestamp): timedatestamp = int(timedatestamp) past_hours = timedatestamp / 3600 past_days = past_hours / 24 past_years = past_days // 365 year_of_compile = 1370 + past_years if 2019 > year_of_compile > 1980: return 0 else: return 1 assert f(0xFFFFFFFF) == 1
benchmark_functions_edited/f8543.py
def f(s): h = {} for i, c in enumerate(s): if c in h: h[c] = -1 else: h[c] = i for c in s: if h[c] != -1: return h[c] return -1 assert f("a") == 0
benchmark_functions_edited/f8984.py
def f(mode, memory, ptr): # position mode if mode == 0: return memory[memory[ptr]] # immediate mode elif mode == 1: return memory[ptr] else: raise Exception assert f(0, [3, 0, 4, 0, 99], 1) == 3
benchmark_functions_edited/f865.py
def f(arg): if not arg: return None return int(arg) assert f('2') == 2
benchmark_functions_edited/f12409.py
def f(text): return text.f("{") - text.f("}") assert f('{Hello} world') == 0
benchmark_functions_edited/f7578.py
def f(n): N = {} N[0] = 1 N[1] = 1 for i in range(2, n + 1): N[i] = 0 for j in range(0, i): N[i] += N[j] * N[i - j - 1] return N[n] assert f(0) == 1
benchmark_functions_edited/f10995.py
def f(precision: float, recall: float): if precision + recall == 0: return 0 return 2 * ((precision * recall) / (precision + recall)) assert f(0, 0) == 0
benchmark_functions_edited/f10519.py
def f(generation, fis): for _ in range(generation): spawn = fis.pop(0) fis.append(spawn) fis[6] += spawn return sum(fis) assert f(0, [1, 1, 1, 1, 1, 1, 1, 1]) == 8
benchmark_functions_edited/f10110.py
def f(list): if len(list) < 1: return -1 min = 0 for idx, val in enumerate(list): if val < list[min]: min= idx return min assert f(list((1, 2, 3, 4, 5, 6))) == 0
benchmark_functions_edited/f4829.py
def f(hand): return sum(hand.values()) assert f({'a':1}) == 1
benchmark_functions_edited/f6979.py
def f(n): if n <= 2: return n else: return n * f(n - 2) assert f(2) == 2
benchmark_functions_edited/f1186.py
def f(A, i, j): return (i + j) // 2 assert f(list(range(10)), 2, 6) == 4
benchmark_functions_edited/f2748.py
def f(p0, p1, p2, t): return p1 + (1-t)**2*(p0-p1) + t**2*(p2-p1) assert f(1,2,3,0) == 1
benchmark_functions_edited/f4691.py
def f(I, w): K = 0.5*I*w**2 return K assert f(2, 0) == 0
benchmark_functions_edited/f3691.py
def f(value, arg): try: return float(value) * float(arg) except (ValueError, TypeError): return '' assert f(1, 2) == 2
benchmark_functions_edited/f13614.py
def f(bitarray): bitstring = "".join([str(i) for i in bitarray]) return int(bitstring,2) assert f( [0, 0, 1, 1,0] ) == 6
benchmark_functions_edited/f765.py
def f(x, threshold): return 2 * threshold * x assert f(3, 0) == 0
benchmark_functions_edited/f8040.py
def f(keyword, the_comments): count = 0 for comment in the_comments: if keyword.lower() in comment.body.lower(): count += 1 return count assert f(None, []) == 0
benchmark_functions_edited/f1481.py
def f(code): return (code - 301) % 255 + 1 assert f(301) == 1
benchmark_functions_edited/f14141.py
def f(testObj, firstElementValue): assert isinstance(testObj, list), 'The provided object is not a list!' for itemIndex in range(len(testObj)): if len(testObj[itemIndex]) > 0 and testObj[itemIndex][0] == firstElementValue: return itemIndex return len(testObj) assert f([], 'hi') == 0
benchmark_functions_edited/f6273.py
def f(payload): sum = 0 for i in range(len(payload)): sum += ord(payload[i]) return (~sum + 1) & 0xFF assert f(b'') == 0
benchmark_functions_edited/f3268.py
def f(n): Cn = 0 for k in range(1, int(n)+1): k = float(k) Cn += k**(-4.0) Cn *= 90.0 Cn **= .25 return Cn assert f(0) == 0
benchmark_functions_edited/f6176.py
def f(li, x) -> int: for i in reversed(range(len(li))): if li[i] == x: return i raise ValueError("{} is not in list".format(x)) assert f([1, 2, 3, 3, 2, 1], 3) == 3
benchmark_functions_edited/f2558.py
def f(x0, y0, x1, y1): return abs(x0 - x1) + abs(y0 - y1) assert f(1, 2, 3, 4) == 4
benchmark_functions_edited/f7661.py
def f(color, data): return sum( inside_count * (1 + f(inside_color, data)) for inside_color, inside_count in data[color].items() ) assert f( "shiny gold", { "light red": {"bright white": 1, "muted yellow": 2}, "dark orange": {"bright white": 3, "muted yellow": 4}, "bright white": {"shiny gold": 1, "muted yellow": 2}, "muted yellow": {"shiny gold": 2, "faded blue": 9}, "shiny gold": {}, "dark olive": {"faded blue": 3, "dotted black": 4}, "vibrant plum": {"faded blue": 5, "dotted black": 6}, "faded blue": {}, "dotted black": {}, } ) == 0
benchmark_functions_edited/f11227.py
def f(bin_string: str, *, zero: str = "0", one: str = "1") -> int: return int(bin_string.replace(zero, "0").replace(one, "1"), base=2) assert f(str(bin(1))) == 1
benchmark_functions_edited/f3431.py
def f(x, resx, resy): return x * resx * resy / 10000 assert f(0, 2000, 1000) == 0
benchmark_functions_edited/f4631.py
def f(list_, num_tweets): if num_tweets < 1: return 0 return 1.0*len(list_)/num_tweets assert f([], 3) == 0
benchmark_functions_edited/f10272.py
def f(B, t, N0): return ((B*t)/(B*t + 2))**N0 assert f(1, 2, 0) == 1
benchmark_functions_edited/f6457.py
def f(obj, path): for part in path: try: obj = obj[part] except(KeyError, IndexError): return None return obj assert f([1, 2, 3], [2]) == 3
benchmark_functions_edited/f9296.py
def f(a, p, n): result = a % n remainders = [] while p != 1: remainders.append(p & 1) p = p >> 1 while remainders: rem = remainders.pop() result = ((a ** rem) * result ** 2) % n return result assert f(2, 100, 4) == 0
benchmark_functions_edited/f4609.py
def f(value, vector): for i, v in enumerate(vector): if value == v: return i return -1 assert f(1, [1, 2, 3, 4]) == 0
benchmark_functions_edited/f2816.py
def f(minVal, val, maxVal): return max(minVal, min(maxVal, val)) assert f(3, 100, 7) == 7
benchmark_functions_edited/f11807.py
def f(a, b): if b == 0: return a if b > a: tmp = b b = a a = tmp return f(b, a % b) assert f(7, 6) == 1
benchmark_functions_edited/f1351.py
def f(r): return abs(r)**2 assert f(0) == 0
benchmark_functions_edited/f4464.py
def f(x: int) -> int: rev = 0 while x > 0: rev = (rev * 10) + x % 10 x = int(x / 10) return rev assert f(10) == 1
benchmark_functions_edited/f3933.py
def f(item, seq): if item in seq: return seq.f(item) else: return -1 assert f(1, [1, 2]) == 0
benchmark_functions_edited/f13868.py
def f(seq1, seq2): set1, set2 = set(seq1), set(seq2) return 1 - len(set1 & set2) / float(len(set1 | set2)) assert f([1, 2], [1, 2]) == 0
benchmark_functions_edited/f9328.py
def f(flag_bit: int) -> int: if flag_bit % 2 == 0: return flag_bit + 1 else: return flag_bit - 1 assert f(1) == 0
benchmark_functions_edited/f3307.py
def f(depth,depth_data): return int((depth - depth_data['depth_start']) / depth_data['depth_per_pixel'] - 0.5) assert f(1.5, {'depth_start': 1, 'depth_per_pixel': 0.5}) == 0
benchmark_functions_edited/f2583.py
def f(value): return sum([1 for c in value if c in [".", ":"]]) assert f("foo") == 0
benchmark_functions_edited/f12114.py
def f(num): if not isinstance(num, int): raise TypeError("Please provide an int argument.") ANSWER_TO_ULTIMATE_QUESTION = 42 return num * ANSWER_TO_ULTIMATE_QUESTION assert f(0) == 0
benchmark_functions_edited/f13283.py
def f(value): check_digit=0 odd_pos=True for char in str(value)[::-1]: if odd_pos: check_digit+=int(char)*3 else: check_digit+=int(char) odd_pos=not odd_pos #alternate check_digit=check_digit % 10 check_digit=10-check_digit check_digit=check_digit % 10 return check_digit assert f(17) == 8
benchmark_functions_edited/f2223.py
def f(h): return sum((v>>4) << i*4 for i,v in enumerate(sorted(h))) assert f(set([13, 12, 11, 10, 9, 8, 7, 6, 5])) == 0
benchmark_functions_edited/f7678.py
def f(score): if score >= 0.9: return 1 elif score <= -0.9: return -1 else: return score assert f(0.0) == 0
benchmark_functions_edited/f6623.py
def f(signature): return_value = 0 while signature.find((return_value + 1) * 'a') != -1: return_value += 1 return return_value assert f('f') == 0
benchmark_functions_edited/f14405.py
def f(checkboxes, rect): search = [x for x in checkboxes if x[4] == rect[4]] for y in sorted(search, key=lambda x: (x[1]))[::-1]: if rect[1] > y[1]: return y[5] return max([x[5] for x in checkboxes]) assert f( [(10, 10, 20, 20, 'a', 0), (15, 10, 25, 20, 'a', 0)], (10, 10, 20, 20, 'a', 0) ) == 0
benchmark_functions_edited/f8595.py
def f(data_structure, keys): curr_data_structure = data_structure for curr_key in keys: curr_data_structure = curr_data_structure[curr_key] return curr_data_structure assert f( {"foo": {"bar": 1}}, ["foo", "bar"] ) == 1
benchmark_functions_edited/f3071.py
def f(operador): if operador == "+" or operador == "-": return 1 else: return 2 assert f("+") == 1
benchmark_functions_edited/f1046.py
def f(c): return ord(c) - ord('A') + 1 assert f('F') == 6
benchmark_functions_edited/f14421.py
def f(binary_str): ones = binary_str.split("0") max_n_1s = max(list(map(lambda x: len(x), ones))) return max_n_1s assert f("00000000") == 0
benchmark_functions_edited/f14391.py
def f(a, b): if (a <= 0 and b <= 0): return("NaN") if (a == 0 or b == 0): return (0) while (a != b): if (a > b): if (b == 0): return (a) a = a % b # use mod operator not subtraction else: if (a == 0): return (b) b = b % a # ditto return a assert f(2, 0) == 0
benchmark_functions_edited/f7518.py
def f(size, chunk_size=1048576): if size % chunk_size == 0: return size // chunk_size return size // chunk_size + 1 assert f(5242880) == 5
benchmark_functions_edited/f6889.py
def f(m): ft = m * (12 * 25.4 / 1000) ** -1 return ft assert f(0) == 0
benchmark_functions_edited/f318.py
def f(line): r, _ = line return r assert f((3, 4)) == 3
benchmark_functions_edited/f10718.py
def f(name, index, args, kwargs, default=None): param = kwargs.get(name) if len(args) > index: if param: raise TypeError("Parameter '%s' is specified twice" % name) param = args[index] return param or default assert f( "foo", 0, tuple(), dict(), 1, ) == 1
benchmark_functions_edited/f7893.py
def f(values, numbers): total = 0 for i in numbers: total += values[i] return total assert f( [1, 2, 3, 4, 5], [] ) == 0