file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f1320.py
def f(x): if isinstance(x, complex): return x.real else: return x assert f(True) == 1
benchmark_functions_edited/f1588.py
def f(lon): return (lon)%360 assert f(361) == 1
benchmark_functions_edited/f4378.py
def f(m_orig, m_new, s_orig): delta_s = s_orig * ((m_orig / m_new) - 1) return delta_s assert f(100.0, 100.0, 34.0) == 0
benchmark_functions_edited/f13756.py
def f(port_grp): return min([int(port_grp[i].rpartition('/')[-1]) for i in range(len(port_grp))]) assert f(['1/1/1', '1/1/2', '2/1/1']) == 1
benchmark_functions_edited/f13394.py
def f(s1, s2): if len(s1) != len(s2): raise ValueError("Undefined for sequences of unequal length") s1 = ''.join("{0:08b}".format(ord(c)) for c in s1) s2 = ''.join("{0:08b}".format(ord(c)) for c in s2) return sum(el1 != el2 for el1, el2 in zip(s1, s2)) assert f('ACGTACGTAGCTG', 'ACGTACGTAGCTG') == 0
benchmark_functions_edited/f8633.py
def f(scalar, variable_list): return scalar(*variable_list) assert f(lambda x, y, z: y, [1, 2, 3]) == 2
benchmark_functions_edited/f8613.py
def f(str1): sum1=0 for ch2 in str1: sum1+=int(ch2) if sum1>9: sum1=f(str(sum1)) return sum1 assert f('56') == 2
benchmark_functions_edited/f12478.py
def f(vec1, vec2): (px1, py1), (px2, py2) = vec1, vec2 return px1 * px2 + py1 * py2 assert f( (0, -1), (1, 0) ) == 0
benchmark_functions_edited/f1425.py
def f(x1: float, x2: float): return (x1 - x2) ** 2 assert f(0, 0) == 0
benchmark_functions_edited/f1529.py
def f(value: str) -> int: return int(value, 16) assert f('00000000000000') == 0
benchmark_functions_edited/f1653.py
def f(values): return sum([x * x for x in values]) assert f(range(1, 0)) == 0
benchmark_functions_edited/f8226.py
def f(radar_frequency): return 0 if (30 < radar_frequency < 40) else 1 assert f(40.1) == 1
benchmark_functions_edited/f2303.py
def f(a, b): return f(b, a % b) if b else a assert f(10, 5) == 5
benchmark_functions_edited/f213.py
def f(num, divisor): return num - (num%divisor) assert f(5,1) == 5
benchmark_functions_edited/f4710.py
def f(register, register_check, jump_by): if register.get(register_check, register_check) != 0: return jump_by assert f( {'a': 1, 'b': 1}, 'a', 1 ) == 1
benchmark_functions_edited/f1519.py
def f(n, m): return int((n * (n + 2) + m) / 2) assert f(0, 0) == 0
benchmark_functions_edited/f7121.py
def f(number): return float(number) * 2 assert f("1") == 2
benchmark_functions_edited/f3292.py
def f(bit_count: int) -> int: return (bit_count + 7) // 8 assert f(20) == 3
benchmark_functions_edited/f10877.py
def f(list, name): if list is None or name is None: return -1 index = 0 for element in list: if element.get('name') is None: continue if element['name'] == name: return index index += 1 return -1 assert f([{'name': 'b'}, {'name': 'a'}], 'b') == 0
benchmark_functions_edited/f9138.py
def f(a, b): for n in (a, b): if not isinstance(n, int) and not isinstance(n, float): raise TypeError return a + b assert f(1, 2) == 3
benchmark_functions_edited/f3173.py
def f(n): return int(100 / n) assert f(50) == 2
benchmark_functions_edited/f1822.py
def f(val): return eval(val,globals(),locals()) assert f(r"1+2*3-4") == 3
benchmark_functions_edited/f8428.py
def f(q, k, dx, U1): Ug = q / k * 2 * dx + U1 return Ug assert f(0, 1, 1, 1) == 1
benchmark_functions_edited/f2219.py
def f(n, total): if n is None: return 0 else: return (n*100)/total assert f(1, 100) == 1
benchmark_functions_edited/f3948.py
def f(n): assert n < 2**32 c = 0 while n > 0: n >>= 1 c += 1 return c assert f(255) == 8
benchmark_functions_edited/f14377.py
def f(instructions: str) -> int: floor = 0 for step, word in enumerate(instructions): if word == "(": floor += 1 elif word == ")": floor -= 1 else: raise ValueError(f"{word} is not a valid instruction") if floor == -1: return step + 1 raise ValueError(f"with the given instructions it did not reach the -1 floor") assert f( "())(" ) == 3
benchmark_functions_edited/f4143.py
def f(x): if x > 0: return +1 elif x < 0: return -1 elif x == 0: return 0 assert f(float('inf')) == 1
benchmark_functions_edited/f2804.py
def f(n: int) -> int: return sum(n ** 2 for n in range(1, n + 1) if n % 2 == 1) assert f(1) == 1
benchmark_functions_edited/f11965.py
def f(value: float) -> float: if value < -1: return -1 if value > 1: return 1 return value assert f(100) == 1
benchmark_functions_edited/f735.py
def f(*args): return int(sum(args) / len(args)) assert f(0) == 0
benchmark_functions_edited/f9911.py
def f(a, p): ls = pow(a, (p - 1) // 2, p) return -1 if ls == p - 1 else ls assert f(1, 5) == 1
benchmark_functions_edited/f9421.py
def f(value, v_min, v_max): try: return min(max(value, v_min), v_max) except TypeError: return None assert f(0, 1, 10) == 1
benchmark_functions_edited/f11819.py
def f(repo): dynamic_count = 0 if 'DYNAMIC-PATTERN' in repo['uniquePatterns']: dynamic_count += repo['uniquePatterns']['DYNAMIC-PATTERN'] return len(repo['uniquePatterns']) + dynamic_count assert f({'uniquePatterns': {}}) == 0
benchmark_functions_edited/f7708.py
def f(rgb): r = "1" if rgb[0] > 127 else "0" g = "1" if rgb[1] > 127 else "0" b = "1" if rgb[2] > 127 else "0" for i in range(8): if r + g + b == format(i, '03b'): return i assert f( (16,16,16) ) == 0
benchmark_functions_edited/f2741.py
def f(duty, top): return int(duty * top / 100) assert f(50, 5) == 2
benchmark_functions_edited/f517.py
def f(sk, c): return (c % sk) % 2 assert f(3, 3) == 0
benchmark_functions_edited/f1215.py
def f(item): return int(item.split("_")[-1].split(".")[0]) assert f(r"foo_2.txt") == 2
benchmark_functions_edited/f2188.py
def f(argv): print('This is a boilerplate') # NOTE: indented using two tabs or 4 spaces return 0 assert f(['--help']) == 0
benchmark_functions_edited/f12605.py
def f(x, y, max_iters): c = complex(x, y) z = 0.0j for i in range(max_iters): z = z * z + c if (z.real * z.real + z.imag * z.imag) >= 4: return i return max_iters assert f(-1.5, 0.5, 3) == 2
benchmark_functions_edited/f10307.py
def f(verA: str, verB: str) -> int: if verA == verB or verA == "*" or verB == "*": return 0 if int(verA) > int(verB): return 1 return -1 assert f("1.2.3.4", "1.2.3.4") == 0
benchmark_functions_edited/f12835.py
def f(ypred, thresh=0.5): if ypred > thresh: return 1 else: return 0 assert f(0.0) == 0
benchmark_functions_edited/f10314.py
def f(args, kwargs, arg_index = 0): try: model = kwargs['model'] except KeyError: model = args[arg_index] return model assert f((), {'model': 1, 'other': 2}, 0) == 1
benchmark_functions_edited/f6543.py
def f(s): return round(3600 * float(s)) / 3600. assert f('0') == 0
benchmark_functions_edited/f10145.py
def f(distribution): addition = 0.0 count = 0.0 for point, instances in distribution: addition += point * instances count += instances if count > 0: return addition / count return float('nan') assert f( [(1, 1), (1, 1), (1, 1), (1, 1)]) == 1
benchmark_functions_edited/f2194.py
def f(function, *args, **kwargs): return function(*args, **kwargs) assert f(lambda *args: sum(args), 1, 2, 3) == 6
benchmark_functions_edited/f1028.py
def f(x,kwargs): return x if x not in kwargs else kwargs[x] assert f(1,{'a':2,'b':3,'c':4}) == 1
benchmark_functions_edited/f8414.py
def f(seq): d = {} for i in seq: try: d[i] += 1 except KeyError: d[i] = 1 for key in d.keys(): if d[key] % 2 == 1: return(key) assert f([1, 1, 1, 3, 3, 3]) == 1
benchmark_functions_edited/f5932.py
def f(value, batch_size): if value % batch_size == 0: return value else: return value + batch_size - value % batch_size assert f(4, 2) == 4
benchmark_functions_edited/f2585.py
def f(a): d = {'x': 0, 'y': 1, 'z': 2} return d[a.lower()[0]] assert f('z') == 2
benchmark_functions_edited/f10506.py
def f(temp): return round((0.0000000325 * pow(temp, 3)) - (0.00005 * pow(temp, 2)) + (0.0426 * (temp))) assert f(0) == 0
benchmark_functions_edited/f3315.py
def f(a: int, b: int, c: int) -> int: return(max(a,b,c)) assert f(3, 4, 1) == 4
benchmark_functions_edited/f8947.py
def f(act, act_list): return act_list.index(act) assert f(1, [0, 1, 2, 3, 4]) == 1
benchmark_functions_edited/f2173.py
def f(a, b): a = float(a) b = float(b) c = b - a return c assert f(2, 2) == 0
benchmark_functions_edited/f10217.py
def f(dp): if dp < 20: return dp elif dp < 50: return (dp // 2) * 2 elif dp < 200: return (dp // 5) * 5 else: return 200 assert f(1) == 1
benchmark_functions_edited/f8579.py
def f(T, r, J): return (T * r) / J assert f(10, 1, 2) == 5
benchmark_functions_edited/f6280.py
def f(num, elem): countNum = 0 for i in range(len(num)): if elem == num[i]: countNum += 1 return countNum assert f( [1, 1, 1, 2], 1) == 3
benchmark_functions_edited/f12373.py
def f(item, args): try: return int(item[args[0]]) except: return 0 assert f({}, ['col(VALUECOL)']) == 0
benchmark_functions_edited/f8436.py
def f(a, b, p): assert 0 <= p and p <= 1 return a * (1.0 - p) + b * p assert f(2, 1, 1) == 1
benchmark_functions_edited/f1035.py
def f(a,b): if(a != b): return 1 else: return 0 assert f(False,0) == 0
benchmark_functions_edited/f12880.py
def f(a, b): if not isinstance(a, int) == isinstance(b, int) == True: raise TypeError('a and b should both be integers.') return None if b < 0: return 0 result = 1 while (b != 0): if b & 1 == 1: result *= a b >>= 1 a *= a return result assert f(0, 1000000) == 0
benchmark_functions_edited/f11016.py
def f(keyword_matrix: list) -> int: longest_keyword_list = 0 for lists in keyword_matrix: if len(lists) > longest_keyword_list: longest_keyword_list = len(lists) return longest_keyword_list assert f( [ [ "keyword 1", "keyword 2", "keyword 3", "keyword 4", "keyword 5", "keyword 6", "keyword 7", ], [ "keyword 8", "keyword 9", "keyword 10", "keyword 11", "keyword 12", ], [ "keyword 13", "keyword 14", "keyword 15", "keyword 16", "keyword 17", ], [ "keyword 18", "keyword 19", "keyword 20", "keyword 21", "keyword 22", ], ] ) == 7
benchmark_functions_edited/f8551.py
def f(frame, _bytes_like=(bytes, bytearray)): if isinstance(frame, _bytes_like): return len(frame) else: try: return frame.nbytes except AttributeError: return len(frame) assert f(bytearray(b'x')) == 1
benchmark_functions_edited/f13794.py
def f(arr, k): n = len(arr) if n < k: return -1 max_sum = -float("inf") # 1st window window_sum = 0 for i in range(k): window_sum = window_sum + arr[i] # Start from k and slide the window # to get new sums. Store max and return for i in range(n - k): window_sum = window_sum - arr[i] + arr[i + k] max_sum = max(max_sum, window_sum) return max_sum assert f( [1, 2, 3, 4, 5], 1) == 5
benchmark_functions_edited/f4620.py
def f(pt1,pt2): tmp_slope=0 tmp_slope = (pt2[1]-pt1[1])/(pt2[0]-pt1[0]) return tmp_slope assert f((2, 3), (1, 2)) == 1
benchmark_functions_edited/f12659.py
def f(dr=None): if dr is None: dr = 2 print(f'dr is not provided, using default dr={dr}') else: pass return dr assert f(1) == 1
benchmark_functions_edited/f9247.py
def f(gridWidth, gridHeight, abortLimit=None): return gridWidth * (gridWidth + 1) * gridHeight * (gridHeight + 1) // 4 assert f(1, 1) == 1
benchmark_functions_edited/f10526.py
def f(file_path): count = 0 with open(file_path, "r") as fobj: for line in fobj: count += 1 return count assert f("foo.txt") == 0
benchmark_functions_edited/f5385.py
def f(data): _data = list(data) length = len(_data) if length > 0: return sum(_data)/length else: return 0 assert f([1, 2, 3, 4, 5]) == 3
benchmark_functions_edited/f186.py
def f(x, r): return r * x - x ** 3 assert f(1, 1) == 0
benchmark_functions_edited/f3668.py
def f(numbers): result = numbers[0] for number in numbers[1:]: result /= number return result assert f([1] * 10) == 1
benchmark_functions_edited/f11115.py
def f(v: float, d_hyd: float, kin_visco: float) -> float: return v * d_hyd / kin_visco assert f(1, 1, 1) == 1
benchmark_functions_edited/f8534.py
def f(i, j, k, l): ij = max(i, j) * (max(i, j) + 1) / 2 + min(i, j) kl = max(k, l) * (max(k, l) + 1) / 2 + min(k, l) return max(ij, kl) * (max(ij, kl) + 1) / 2 + min(ij, kl) assert f(0, 0, 0, 0) == 0
benchmark_functions_edited/f9506.py
def f(x, a=-0.5): if abs(x) <= 1: return (a + 2)*abs(x)**3 - (a + 3)*abs(x)**2 + 1 elif 1 < abs(x) and abs(x) < 2: return a*abs(x)**3 - 5*a*abs(x)**2 + 8*a*abs(x) - 4*a else: return 0 assert f(2.5) == 0
benchmark_functions_edited/f4245.py
def f(item, vec): for i in range(len(vec)): if item == vec[i]: return i return -1 assert f(2, [1, 2, 3, 1]) == 1
benchmark_functions_edited/f3635.py
def f(string): try: return int(string) except ValueError: return None assert f("2") == 2
benchmark_functions_edited/f2661.py
def f(x: int) -> int: return int(x) if isinstance(x, int) and x != 0 else 1 assert f(1 / 1 + 0) == 1
benchmark_functions_edited/f5757.py
def f(byte, offset, value): if value: return byte | (1 << offset) else: return byte & ~(1 << offset) assert f(1, 2, 1) == 5
benchmark_functions_edited/f6648.py
def f(row, i): length = len(row) return row[i - 1] * 4 + row[i] * 2 + row[(i + 1) % length] assert f( [0,0,0,0,0,0,0,0], 1) == 0
benchmark_functions_edited/f4289.py
def f(num): if num < 0: return -num else: return num assert f(-5) == 5
benchmark_functions_edited/f2048.py
def f(obj): if hasattr(obj, 'to_dense'): return obj.to_dense() return obj assert f(1) == 1
benchmark_functions_edited/f9190.py
def f(a, b, D=1, D2=1): dx = abs(a[0] - b[0]) dy = abs(a[1] - b[1]) return D * (dx + dy) + (D2 - 2 * D) * min(dx, dy) assert f( (1,1), (1,1) ) == 0
benchmark_functions_edited/f13552.py
def f(ini_val, new_val): if not new_val == 0: if new_val < ini_val: ret = ((ini_val - new_val) / ini_val) * (-1) else: ret = (new_val - ini_val) / new_val else: ret = 0 return ret assert f(-10, -10) == 0
benchmark_functions_edited/f4909.py
def f(x_sep: float) -> int: percent_sep = int(100 - 100 * (x_sep / 12800)) return percent_sep assert f(12800) == 0
benchmark_functions_edited/f6480.py
def f(x): formula = x**2 + 6*x + 9 return formula assert f(0) == 9
benchmark_functions_edited/f4010.py
def f(x1,y1,z1,x2,y2,z2,x3,y3,z3): return (x1*y2*z3 + y1*z2*x3 + z1*x2*y3 - x1*z2*y3 - y1*x2*z3 - z1*y2*x3) assert f(0, 0, 0, 0, 0, 0, 0, 0, 1) == 0
benchmark_functions_edited/f11551.py
def f(a): n = 0 while a > 0: n += 1 a >>= 1 return n assert f(24) == 5
benchmark_functions_edited/f13116.py
def f(f, x, deltax=1e-12): # the following formula is the average between the slopes using # the right limit [(f(x + deltax) - f(x)) / deltax] and # the left limit [(f(x) - f(x - deltax)) / deltax] return (f(x + deltax) - f(x - deltax)) / (2 * deltax) assert f(lambda x: x**2, 0) == 0
benchmark_functions_edited/f12235.py
def f(mapping, value): if value in mapping["labels"]: return mapping["labels"].index(value) else: raise KeyError('Label "' + str(value) + '" not known.') assert f( {"labels": ["a", "b", "c"], "mapping": [[1], [2], [3]]}, "c" ) == 2
benchmark_functions_edited/f8986.py
def f(grades): maximum_grade = 0 for key in grades.keys(): if grades[key] > maximum_grade: maximum_grade = grades[key] return maximum_grade assert f({}) == 0
benchmark_functions_edited/f12795.py
def f(order_items): JOINT = 0.4 # Todo: add correct order line for 0.5 and 2.5 prices = {"0,5 gram": 0.5, "1 gram": 1, "2,5 gram": 2.5, "5 gram": 5, "joint": JOINT} total = 0 for item in order_items: if item.description in prices: total = total + (prices[item.description] * item.quantity) return total assert f([]) == 0
benchmark_functions_edited/f1200.py
def f(args=None): # click.echo("See the 'screenshots' command.") return 0 assert f([]) == 0
benchmark_functions_edited/f6084.py
def f(weights): # NOTE: Include this in report # https://math.stackexchange.com/questions/2792390/derivative-of- # euclidean-norm-l2-norm return weights assert f(0) == 0
benchmark_functions_edited/f1436.py
def f(a, b): if a == 1: return b return b + f(a-1, b) assert f(3, 3) == 9
benchmark_functions_edited/f7970.py
def f( p, a ): if pow(a,p-1,p) == 1 : return 1 # could be prime else: return 0 assert f( 5, 3 ) == 1
benchmark_functions_edited/f11986.py
def f(n): if n < 1: return 0 fibs = [0, 1] + (n - 2) * [-1] def fib_inner(n): if fibs[n] == -1: fibs[n] = fib_inner(n - 1) + fib_inner(n - 2) return fibs[n] # note the n - 1, because the indexing starts at zero. return fib_inner(n - 1) assert f(0) == 0
benchmark_functions_edited/f9702.py
def f(latency, bandwidth, queue): queue_count = len(queue) buffered_size = sum([p['size'] for p in queue]) max_buffer_size = 9 * 1024 * 1024 return 0 return (0.5 + random.random()) * latency * (1 + buffered_size / max_buffer_size) assert f(1000, 1024000, [{'size': 10240000}, {'size': 10240000}]) == 0
benchmark_functions_edited/f12133.py
def f(x): fall = range(80, 172) winter = range(172, 264) spring = range(264, 355) if x in spring: return 3 if x in winter: return 2 if x in fall: return 1 else: return 4 assert f(400) == 4
benchmark_functions_edited/f14270.py
def f(value): if isinstance(value, int): return value elif isinstance(value, str) and value.isdigit(): return int(value) else: raise TypeError( "an int or int-like string is required (got %s)" % (type(value).__name__) ) assert f("1") == 1
benchmark_functions_edited/f8481.py
def f(a, b): return max(0, min(a[1], b[1]) - max(a[0], b[0])) assert f( (0, 5), (0, 2) ) == 2
benchmark_functions_edited/f10242.py
def f(fs, nyq): if nyq is None and fs is None: fs = 2 elif nyq is not None: if fs is not None: raise ValueError("Values cannot be given for both 'nyq' and 'fs'.") fs = 2 * nyq return fs assert f(None, 2) == 4