file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f11654.py
def f(index: tuple, shape: tuple) -> int: return index[0] * shape[0] + index[1] assert f((0, 0), (3, 5)) == 0
benchmark_functions_edited/f6341.py
def f(val, idx): return (val >> idx) & 1 assert f(1, 1) == 0
benchmark_functions_edited/f12275.py
def f(pl: str) -> int: total = 0 for l0 in pl: if isinstance(l0, list): for l1 in l0: if isinstance(l1, list): for l2 in l1: total += 1 else: total += 1 else: total += 1 return total assert f([['Hello', 2.4], 'there']) == 3
benchmark_functions_edited/f12711.py
def f(level): if level==0: return 1 else: return 2**level+1 assert f(1) == 3
benchmark_functions_edited/f9383.py
def f(x, y): #return np.min(x, y) return y assert f(2, 1) == 1
benchmark_functions_edited/f2334.py
def f(cartX, cartY): return cartX**2 + cartY**2 assert f(-1,-1) == 2
benchmark_functions_edited/f1902.py
def f(a, b): return a / float(b) if b else 0.0 assert f(10, 0) == 0
benchmark_functions_edited/f13088.py
def f(x: int, y: int, fld: list) -> int: mw, mh = len(fld), len(fld[0]) return fld[(x-1) % mw][(y-1)% mh] + fld[x][(y-1)% mh] + fld[(x+1) % mw][(y-1)% mh] +\ fld[(x-1) % mw][y] + fld[(x+1) % mw][y] +\ fld[(x-1) % mw][(y+1)% mh] + fld[x][(y+1)% mh] + fld[(x+1) % mw][(y+1)% mh] assert f(1, 1, [[1, 0, 0], [1, 1, 0], [1, 0, 0]]) == 3
benchmark_functions_edited/f7125.py
def f(x, amp): return amp + 0 * x assert f(1, 0) == 0
benchmark_functions_edited/f7176.py
def f(pointA, pointB): return ((pointA[0] - pointB[0]) ** 2 + (pointA[1] - pointB[1]) ** 2) ** 0.5 assert f( (3,4), (0,0) ) == 5
benchmark_functions_edited/f2662.py
def f(num_list, num): return min(num_list, key=lambda x: abs(x - num)) assert f([0, 1, 5], -2) == 0
benchmark_functions_edited/f4434.py
def f(l: list) -> int: _l = list(l) min1 = min(_l) _l.remove(min1) min2 = min(_l) return min1 + min2 assert f( [1,2,3] ) == 3
benchmark_functions_edited/f13913.py
def f(number, series): if len(number) < series or series < 0: raise ValueError if not series: return 1 maximum = 0 for i in range(len(number) + 1 - series): partial_sum = int(number[i]) for j in number[i + 1:i + series]: partial_sum *= int(j) maximum = max(maximum, partial_sum) return maximum assert f( "123456789", 0 ) == 1
benchmark_functions_edited/f3982.py
def f(argument, default): if argument is None: return default else: return argument assert f(None, 2) == 2
benchmark_functions_edited/f12562.py
def f(number: int) -> int: if not number % 2: return number // 2 else: return 3 * number + 1 assert f(8) == 4
benchmark_functions_edited/f1477.py
def f(x): return (x - 255 / 2) / 255 assert f(127.5) == 0
benchmark_functions_edited/f13409.py
def f(segmentation, stroke_id): for i, symbol in enumerate(segmentation): for sid in symbol: if sid == stroke_id: return i return -1 assert f( [[0, 1, 2, 3, 4, 5, 6, 7, 8], [31, 32, 33, 34, 35, 36, 37, 38, 39]], 1 ) == 0
benchmark_functions_edited/f5716.py
def f(mask): return sum(bin(int(x)).count("1") for x in mask.split(".")) assert f( "0.0.0.0") == 0
benchmark_functions_edited/f137.py
def f(n): return int(round(n)) assert f(0.25) == 0
benchmark_functions_edited/f4199.py
def f(f): return getattr(f, 'im_func', getattr(f, '__func__', f)) assert f(1) == 1
benchmark_functions_edited/f8456.py
def f(list1,list2): s1 = set(list1) s2 = set(list2) return (len(s1.intersection(s2)) / len(s1.union(s2))) assert f( ['<NAME>','<NAME>','<NAME>','<NAME>','<NAME>'], ['<NAME>','<NAME>','<NAME>','<NAME>','<NAME>'] ) == 1
benchmark_functions_edited/f2139.py
def f(x, y): while y: x, y = y, x % y return x assert f(2, 4) == 2
benchmark_functions_edited/f1292.py
def f(value): if value is None: return None return int(value) assert f(1) == 1
benchmark_functions_edited/f14450.py
def f(num_attributes, sensitivity, epsilon): return (num_attributes - 1) * sensitivity / epsilon assert f(4, 1, 1) == 3
benchmark_functions_edited/f13911.py
def f(M, logg): if not isinstance(M, (int, float)): raise TypeError('Mass must be int or float. {} type given'.format(type(M))) if not isinstance(logg, (int, float)): raise TypeError('logg must be int or float. {} type given'.format(type(logg))) if M < 0: raise ValueError('Only positive stellar masses allowed.') M = float(M) return M/(10**(logg-4.44)) assert f(0, 0) == 0
benchmark_functions_edited/f9942.py
def f(pattern1, pattern2): if len(pattern1) == len(pattern2): return sum([ pattern1[index] != pattern2[index] for index in range(len(pattern1)) ]) raise Exception('Length of both reads do not match') assert f( 'GAGCCTACTAACGGGAT', 'CATCGTAATGACGGCCC', ) == 8
benchmark_functions_edited/f5238.py
def f(shape, value): if shape: return tuple([f(shape[1:], value) for _ in range(shape[0])]) return value assert f((), 1) == 1
benchmark_functions_edited/f7803.py
def f(chain, start=0): non_zeros = filter(lambda x: x, chain[start:]) value = next(non_zeros, None) return chain.index(value, start) if value else -1 assert f([0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 9
benchmark_functions_edited/f10650.py
def f(arr): max_thus_far = 0 max_ending_here = 0 for elt in arr: max_ending_here += elt if max_ending_here < 0: max_ending_here = 0 max_thus_far = max(max_ending_here, max_thus_far) return max_thus_far assert f([2, -1, 2]) == 3
benchmark_functions_edited/f8397.py
def f(arr, x): lo = 0 hi = len(arr) while lo < hi: mid = (lo + hi) // 2 if x > arr[mid]: hi = mid else: lo = mid + 1 return lo assert f(list(range(5, 0, -1)), 3) == 3
benchmark_functions_edited/f642.py
def f(level: int) -> int: return (level + 1) ** 3 assert f(0) == 1
benchmark_functions_edited/f9768.py
def f(list_of_values): return sum(list_of_values) / len(list_of_values) assert f([1, 2, 3]) == 2
benchmark_functions_edited/f3485.py
def f(value: int) -> int: return value << 1 if value >= 0 else (value << 1) ^ (~0) assert f(-1) == 1
benchmark_functions_edited/f13674.py
def f(pDetect, pGener, tol_limit): expectedToleranceplus = pDetect+tol_limit*0.01*pDetect expectedToleranceminus = pDetect-tol_limit*0.01*pDetect if (pGener <= expectedToleranceplus and pGener >= expectedToleranceminus): deviation = 0 print('within tolerance range, not penalized') else: deviation = abs(expectedToleranceminus-pGener) return deviation assert f(0.1, 0.1, 0.01) == 0
benchmark_functions_edited/f14277.py
def f(wind_speed, fract_water, max_wat_cont = 0.8, c1 = 2e-6): return c1 * (wind_speed+1)**2*(1-fract_water/max_wat_cont) assert f(0, 0.8, 0.8) == 0
benchmark_functions_edited/f7817.py
def f(v): if v > 100: return int(round(v)) elif v > 0 and v < 100: return round(v, 1) elif v >= 0.1 and v < 1: return round(v, 1) elif v >= 0 and v < 0.1: return round(v, 3) assert f(1.999) == 2
benchmark_functions_edited/f2312.py
def f(input): lens = [len(x) for x in input.split()] return sum(lens) / len(lens) assert f('This is a test.') == 3
benchmark_functions_edited/f405.py
def f(x, func): return func(x).real assert f(0, lambda x: x * x) == 0
benchmark_functions_edited/f3687.py
def f(str, prefix): return str[:len(prefix)] == prefix assert f( "aaaa", "" ) == 1
benchmark_functions_edited/f7707.py
def f(x, mu, sig): return (-2.0 * x + mu) / (2 * sig ** 2) assert f(0, 0, 1) == 0
benchmark_functions_edited/f10861.py
def f(numbers): return numbers[0] % numbers[1] assert f([-2, 2]) == 0
benchmark_functions_edited/f10837.py
def f(list_of_sentences, raw_word): raw_word_count = 0 for sentence in list_of_sentences: raw_word_count = raw_word_count + sentence.word_counts[raw_word] return raw_word_count assert f([], "a") == 0
benchmark_functions_edited/f12713.py
def f(tdur, cadence): n_intransit = tdur//cadence return n_intransit assert f(10.456789, 10) == 1
benchmark_functions_edited/f5766.py
def f(l): n = len(l) l = sorted(l) if n%2 == 1: return l[int((n-1)/2)] return (l[int(n/2)-1] + l[int(n/2)]) / 2 assert f([1, 1, 5, 3, 4]) == 3
benchmark_functions_edited/f11945.py
def f(len0, len1, diag): return min(len0 - diag, len1) + min(diag, 0) assert f(10, 3, 0) == 3
benchmark_functions_edited/f13947.py
def f(model, data): return eval(model.replace('variable_', ''), globals(), data) #return DataFrame.from_records(data).eval(model.replace('variable_', '')) assert f(u'a*b+c', {'a':1, 'b':2, 'c':3}) == 5
benchmark_functions_edited/f3075.py
def f(a, b): if b == 0: return a return f(b, a % b) assert f(10000000000000000000, 2) == 2
benchmark_functions_edited/f6809.py
def f(name): score = 1 return score assert f('Greg') == 1
benchmark_functions_edited/f10619.py
def f(sink, distList): for i in range(len(distList)): if sink in distList[i]: return i ###else return len(distList) + 1 assert f(3, [[1, 2]]) == 2
benchmark_functions_edited/f8966.py
def f(repo, tree, dfile): tloc = 0 try: blob = repo[tree[dfile.path].id] tloc = len(str(blob.data).split('\\n')) except Exception as _: return tloc return tloc assert f(None, None, None) == 0
benchmark_functions_edited/f9997.py
def f(n): from math import frexp signif,exponent = frexp(n) if (signif < 0): return 1 if (signif == 0.5): exponent -= 1 return (1) << exponent assert f(-11) == 1
benchmark_functions_edited/f7638.py
def f(x, y): if x>0 and y>0: return f(x-1, y) + f(x, y-1) if x>0: return f(x-1, y) if y>0: return f(x, y-1) return 1 assert f(0,1) == 1
benchmark_functions_edited/f9587.py
def f(pixel_group, base): f_value = 0 for i in range(len(pixel_group)): f_value = (f_value + pixel_group[i] * (i + 1)) % base return f_value assert f([1, 2, 3], 1) == 0
benchmark_functions_edited/f6142.py
def f(x, y, sn): rack = x + 10 val = (rack * y + sn) * rack return ((val % 1000) // 100) - 5 assert f(101, 153, 71) == 4
benchmark_functions_edited/f1374.py
def f(text): try: return int(text) except ValueError: return text assert f(1) == 1
benchmark_functions_edited/f14145.py
def f(sortedCollection, item, key=lambda x: x): lo = 0 hi = len(sortedCollection) while lo < hi: mid = (lo + hi) // 2 if item < key(sortedCollection[mid]): hi = mid else: lo = mid + 1 return lo assert f( [1], 0) == 0
benchmark_functions_edited/f9251.py
def f(singles, chao1): s = float(singles) return s*(s-1)/2 + s*(2*s-1)**2/4 - s**4/(4*chao1) assert f(0, 3) == 0
benchmark_functions_edited/f6660.py
def f(x0, y0, x1, y1, x): return (y1 * (x - x0) + y0 * (x1 - x)) // (x1 - x0) assert f(0, 0, 1, 1, 0.125) == 0
benchmark_functions_edited/f4326.py
def f(address, align): return (address+(align-1))&(~(align-1)) assert f(0, 128) == 0
benchmark_functions_edited/f2567.py
def f(n): i, a, b = 0, 0, 1 while i != n: a, b = b, a+b i += 1 return a assert f(5) == 5
benchmark_functions_edited/f6935.py
def f(v1,v2): p1 = v1 is None p2 = v2 is None if p1 and p2: return None elif p1: return v2 elif p2: return v1 else: return v1 + v2 assert f(None, 5) == 5
benchmark_functions_edited/f4868.py
def f(chars): if chars: return sum([(x * 2 + 1) ** 2 for x in range(len(chars))]) else: return -1 assert f("A") == 1
benchmark_functions_edited/f14302.py
def f(n_mismatches, n_ins, n_del, read_length): x = 1 - ((n_mismatches + n_ins + n_del) / read_length) if isinstance(x, float): return max(0, x) else: # numpy arrays x[x < 0] = 0 return x assert f(0, 0, 0, 100) == 1
benchmark_functions_edited/f5213.py
def f(name): return len(name) - name.count('~') assert f('ab') == 2
benchmark_functions_edited/f9537.py
def f(citations): c = list(citations) c.sort(reverse=True) for i in range(len(c)): if i > c[i]: return i return len(c) assert f([1, 0]) == 1
benchmark_functions_edited/f275.py
def f(number: int) -> int: return 0 if number < 0 else number assert f(-5.5) == 0
benchmark_functions_edited/f2673.py
def f(n): return n * (n + 1) // 2 assert f(3) == 6
benchmark_functions_edited/f4808.py
def f(x): if x < 0.5: return 4 * x**3 else: return 1/2 * ((2*x - 2)**3 + 2) assert f(0) == 0
benchmark_functions_edited/f11729.py
def f(code: str, globals_: dict, ret): locals_ = {} exec(code, globals_, locals_) assert ret in locals_, ( f'The lambda code block didn\'t contain `{ret} = <some_function>` ' f'statement!' ) return locals_[ret] assert f( 'x = 0; y = 0; x = 1; y = 2', { 'x': 5, 'y': 2 }, 'x' ) == 1
benchmark_functions_edited/f8717.py
def f(diffeq, y0, t, h): k1 = h*diffeq(y0, t) # get dy/dt at t first k2 = h*diffeq(y0+0.5*k1, t + h/2) # get dy/dt at t+h/2, return y0 + k2 # calc. y1 = y(t+h) assert f(lambda y, t: 1, 2, 0, 1) == 3
benchmark_functions_edited/f14133.py
def f(args): # Attempt to convert the first argument to an integer try: int(args[1]) except: return 1 if len(args) == 0: return 2 else: return 0 assert f(['500', '1000']) == 0
benchmark_functions_edited/f13820.py
def f(vsh,vsv): return (vsh+vsv)*0.5 assert f(2,2) == 2
benchmark_functions_edited/f1939.py
def f(st, ave): return (st+ave)*(st+ave+1)//2 + ave assert f(0, 0) == 0
benchmark_functions_edited/f13311.py
def f(publications): publications = sorted(publications) N = len(publications) if N > 1: maxrange = min([N, max(publications)]) + 1 for h in range(1, maxrange)[::-1]: if publications[-h:][0] >= h >= publications[:N - h][-1]: return h return 1 else: return 1 assert f([3, 2, 3, 0, 6]) == 3
benchmark_functions_edited/f8145.py
def f(card): prefix = card[:len(card) - 1] names = {'A': 1, 'J': 11, 'Q': 12, 'K': 13} if prefix in names: return names.get(prefix) else: return int(prefix) assert f('4D') == 4
benchmark_functions_edited/f14442.py
def f(L: list, b: int) -> int: smallest = b # The index of the smallest so far i = b + 1 while i != len(L): if L[i] < L[smallest]: # W e found a smaller item at L[i] smallest = i i = i + 1 return smallest assert f([3, -1, 7, 5, 2, 1], 4) == 5
benchmark_functions_edited/f6571.py
def f(address, alignment): rest = address % alignment if rest: # We need padding bytes: return alignment - rest return 0 assert f(1, 8) == 7
benchmark_functions_edited/f4178.py
def f(instruction_bytes): op = (instruction_bytes & 0xFC000000) >> (3 * 8 + 2) return op assert f(0x00000000) == 0
benchmark_functions_edited/f617.py
def f(tp, fp): return tp/(tp+fp) assert f(0, 1) == 0
benchmark_functions_edited/f9516.py
def f(measured, base): if measured == base: return 0 try: return (abs(measured - base) / base) * 100.0 except ZeroDivisionError: # It means base and only base is 0. return 100.0 assert f(100, 100.0) == 0
benchmark_functions_edited/f14349.py
def f(*args): args = list(args) arg = args.pop(0) while arg is None and len(args) > 0: arg = args.pop(0) return arg assert f(None, 2) == 2
benchmark_functions_edited/f2270.py
def f(seq): return next(iter(seq), None) assert f(iter({1,2,3,4,5})) == 1
benchmark_functions_edited/f13934.py
def f(freqs, delt): return ( delt[0] + delt[1] * freqs + delt[2] * freqs ** 2 + delt[3] * freqs ** 3 + delt[4] * freqs ** 4 ) assert f(0, [0, 0, 0, 0, 0]) == 0
benchmark_functions_edited/f13058.py
def f(x, n = 2): try: return [round(i,n) for i in x] except: return x assert f(1) == 1
benchmark_functions_edited/f10875.py
def f(__n): import sys if not isinstance(__n, (int, long) if sys.version_info[0] == 2 else int): raise TypeError("integer expected") if __n < 0: raise ValueError("non-negative integer expected") return (__n + 7) // 8 assert f(71) == 9
benchmark_functions_edited/f8280.py
def f(x): ## # D ( e^x ) = ( e^x ) - ( e^x )^2 # - --------- --------- --------- # Dx (1 + e^x) (1 + e^x) (1 + e^x)^2 ## return x * (1 - x) assert f(0) == 0
benchmark_functions_edited/f6145.py
def f(value): if value == 0: newvalue = 1 else: newvalue = value -1 if value % 2 == 0 else value return newvalue assert f(1.0) == 1
benchmark_functions_edited/f1409.py
def f(mixed, default=None): try: return int(mixed) except: return default assert f(1.4) == 1
benchmark_functions_edited/f4933.py
def f(filename="", text=""): with open(filename, "w") as my_file: nb_char = my_file.write(str(text)) my_file.close() return (nb_char) assert f("test.txt", "bar") == 3
benchmark_functions_edited/f8149.py
def f(n) -> int: n = abs(n) i = 2 NumberOfDivisors = 0 while i < n: if n % i == 0: NumberOfDivisors += 1 i += 1 return NumberOfDivisors assert f(20) == 4
benchmark_functions_edited/f3590.py
def f(n: int) -> int: ds = n % 9 if ds: return ds return 9 assert f(9875) == 2
benchmark_functions_edited/f125.py
def f(inp): return float(len(inp[0])) assert f( ((1, 2, 3, 4),)) == 4
benchmark_functions_edited/f11805.py
def f(x,n): if x%n == 0: return 1 else: return 0 assert f(31,31) == 1
benchmark_functions_edited/f7397.py
def f(x, encoding="utf-8"): if isinstance(x, str): if not isinstance(x, str): x = str(x, encoding) return x else: return x assert f(1) == 1
benchmark_functions_edited/f9518.py
def f(n, cond1, cond2): d1 = [cond1[x] - cond2[x] for x in range(n)] d21 = [x**2 for x in d1] sumd1 = sum(d1) sumd21 = sum(d21) d_ = sumd1 / n sd = ((sumd21 - (n * (d_**2))) / (n - 1))**0.5 sd_error = sd / (n**0.5) d = d_ / sd_error return d assert f(3, (0, 0, 1), (1, 0, 0)) == 0
benchmark_functions_edited/f3929.py
def f(p,u,w,v): return p[0]*u+p[1]*w+v assert f( (0,1), 0, 1, 0) == 1
benchmark_functions_edited/f9640.py
def f(x): try: flattened_array = [item for sub in x for item in sub] except TypeError: flattened_array = x return flattened_array assert f(0) == 0
benchmark_functions_edited/f2934.py
def f(i, default_value=1): return i if isinstance(i, int) and i > 0 else default_value assert f(1.5, 1) == 1
benchmark_functions_edited/f5619.py
def f(acc, w1, w2): return acc + max(w1, w2) assert f(0, 1, 2) == 2
benchmark_functions_edited/f11871.py
def f(endpoints: list) -> int: zones = {e['locality']['zone'] for e in endpoints} return len(zones) assert f([ { 'locality': { 'zone': 'us-west-1' } } ]) == 1