file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f1793.py | def f(value):
return int(value) if str(value).isdigit() else value
assert f('1') == 1 |
benchmark_functions_edited/f4785.py | def f(n_frames, framerate, tempo):
return (n_frames / float(framerate)) * (tempo / 60.)
assert f(3, 1, 60) == 3 |
benchmark_functions_edited/f10638.py | def f(A, memo, ind=0):
# Stop if
if ind > len(A)-1:
return 0
if ind not in memo:
memo[ind] = max(f(A, memo, ind + 2) + A[ind], f(A, memo, ind + 1))
return memo[ind]
assert f([0], {}) == 0 |
benchmark_functions_edited/f11556.py | def f(arr: list) -> int:
even = []
odd = []
for item in arr:
if str(item).isdigit():
if item % 2 == 0:
even.append(item)
else:
odd.append(item)
return len(even) - len(odd)
assert f(
[1, 2, 3, 4, 4, 4, 5, 6]
) == 2 |
benchmark_functions_edited/f12875.py | def f(v1, v2, v_h):
while v_h < 0:
v_h += 1
while v_h > 1:
v_h -= 1
if 6 * v_h < 1:
return v1 + (v2 - v1) * 6 * v_h
if 2 * v_h < 1:
return v2
if 3 * v_h < 2:
return v1 + (v2 - v1) * ((2.0 / 3) - v_h) * 6
return v1
assert f(1, 1, 1) == 1 |
benchmark_functions_edited/f7288.py | def f(obj, name, default):
try:
return getattr(obj, name)
except LookupError:
return default
assert f(1, "real", 3) == 1 |
benchmark_functions_edited/f5608.py | def f(array, idx, fallback):
try:
return array[idx]
except IndexError:
return fallback
assert f(range(5), 2, 'fallback') == 2 |
benchmark_functions_edited/f6694.py | def f(fn,xs,ys,yerrs=None):
if yerrs is None:
yerrs=[1]*len(xs)
return sum([(fn(x)-ys[i])**2./yerrs[i]**2. for i,x in enumerate(xs)])
assert f(lambda x: x, [0,1], [0,1]) == 0 |
benchmark_functions_edited/f747.py | def f(x, r, t=0):
return r*x + x**3 - x**5
assert f(1, 1) == 1 |
benchmark_functions_edited/f3205.py | def f(number: int, start: int, end: int):
return number % (1 << end) // (1 << start)
assert f(0b101, 1, 2) == 0 |
benchmark_functions_edited/f9549.py | def f(task: str) -> int:
result = 0
task = task.strip()
shift = len(task) // 2
for i, digit in enumerate(task):
if digit == task[(i + shift) % len(task)]:
result += int(digit)
return result
assert f(
) == 4 |
benchmark_functions_edited/f14547.py | def f(area_a, area_b, intersect):
eps = 1e-5
if area_a == 0 or area_b == 0:
area_a += eps
area_b += eps
print("the area of text is 0")
return max(float(intersect)/area_a, float(intersect)/area_b)
assert f(1, 0, 0) == 0 |
benchmark_functions_edited/f12145.py | def f(model, lookup):
try:
pk = int(lookup)
except (TypeError, ValueError):
# otherwise, attempt a lookup
try:
pk = model._default_manager.get(**lookup).pk
except model.DoesNotExist:
pk = None
return pk
assert f(None, '4') == 4 |
benchmark_functions_edited/f2442.py | def f(s):
return len(s.strip().split(' ')[-1]) if s else 0
assert f(' hello world ') == 5 |
benchmark_functions_edited/f9839.py | def f(sequence_numbers):
return sum(1 for (s1, s2) in zip(sequence_numbers,
sequence_numbers[1:]) if
s1 >= s2)
assert f(range(1, 10)) == 0 |
benchmark_functions_edited/f1039.py | def f(a):
i = 0
while a:
i += 1
a = a.next
return i
assert f(None) == 0 |
benchmark_functions_edited/f219.py | def f(n):
return 2*n+1
assert f(0) == 1 |
benchmark_functions_edited/f7923.py | def f(a, b):
if a > b:
return -1
elif a < b:
return 1
else:
return 0
assert f(1, 5) == 1 |
benchmark_functions_edited/f10460.py | def f(s):
if s.lower() == s:
return 0
elif s.upper() == s:
return 1
elif s[0].upper() == s[0]:
return 2
else:
return 3
assert f( 'example String' ) == 3 |
benchmark_functions_edited/f2323.py | def f(b: bytes) -> int:
return int.from_bytes(b, "little")
assert f(b"\x01") == 1 |
benchmark_functions_edited/f556.py | def f(values):
return sum(values) / len(values)
assert f((1, 2, 3, 4, 5)) == 3 |
benchmark_functions_edited/f11574.py | def f(a, b, op):
if op == "+":
return a + b
elif op == "-":
return a - b
elif op == "*":
return a * b
elif op == "/":
return round( a / b, 3 )
elif op == "%":
return a % b
else:
print("Invalida Operation, repeat please\n")
return "NA"
assert f(10, 2, "-") == 8 |
benchmark_functions_edited/f3401.py | def f(key, dic):
return dic[key] if dic and key in dic else None
assert f("2", {"1": "s", "2": 3}) == 3 |
benchmark_functions_edited/f11236.py | def f(n, x):
if n == 0:
return 1
elif n == 1:
return 2 * x
else:
return 2 * x * f(n - 1, x) - 2 * (n - 1) * f(n - 2, x)
assert f(0, 1) == 1 |
benchmark_functions_edited/f3309.py | def f(m, n):
while m % n != 0:
oldm = m
oldn = n
m = oldn
n = oldm % oldn
return n
assert f(3829, 2379) == 1 |
benchmark_functions_edited/f5225.py | def f(item, vector):
for i in range(len(vector)):
if item == vector[i]:
return i
return len(vector)
assert f(3, [1, 2, 3, 4, 5]) == 2 |
benchmark_functions_edited/f14203.py | def f(test_keys, sigma, sigma_max, sigma_step,
npoints_min, npoints_max, npoints_step):
run = 1
for key in test_keys:
if key:
while sigma < sigma_max:
npoints = npoints_min
while npoints < npoints_max:
npoints += npoints_step
run += 1
sigma += sigma_step
return run
assert f(
[True, True, False], 0, 1, 1, 0, 1, 1) == 2 |
benchmark_functions_edited/f8374.py | def f(node):
if node is not None:
return node.value + f(node.next_node) # tally those bad boys up
return 0
assert f(None) == 0 |
benchmark_functions_edited/f9285.py | def f(str1, str2):
l1 = len(str1)
l2 = len(str2)
i = 0
j = 0
if l1 > l2:
return 0
while i < l1 and j < l2:
if str1[i] == str2[j]:
i += 1
j += 1
else:
j += 1
return 100 * (i / l1)
assert f(
"apple", "melon"
) == 0 |
benchmark_functions_edited/f8983.py | def f(x, m, b):
y = m*x + b
return y
assert f(1, 1, 2) == 3 |
benchmark_functions_edited/f10254.py | def f(nums):
if len(nums) == 0:
return 0
dp = [1]
for i in range(1,len(nums)):
maxx = 0
for j in range(i):
if nums[j] < nums[i]:
maxx = max(maxx, dp[j])
dp.append(maxx+1)
return max(dp)
assert f( [ 0, 1, 0, 3, 2, 3 ] ) == 4 |
benchmark_functions_edited/f2410.py | def f(variant):
return abs(len(variant['ALT']) - len(variant['REF']))
assert f(
{'CHROM': '1', 'POS': 10, 'REF': 'A', 'ALT': ['C', 'G']}) == 1 |
benchmark_functions_edited/f7417.py | def f(ls):
res = -1
for l in ls:
res = max(res, len(l))
return res
assert f([[], []]) == 0 |
benchmark_functions_edited/f1732.py | def f(alignment, x):
a = alignment
return (x // a) * a
assert f(2, 7) == 6 |
benchmark_functions_edited/f5710.py | def f(items):
return max([(item, index) for index, item in enumerate(items)])[1]
assert f([4, 3, 2, 1]) == 0 |
benchmark_functions_edited/f9404.py | def f(value):
value = value & 0xffffffff
if value & 0x80000000:
value = ~value + 1 & 0xffffffff
return -value
else:
return value
assert f(1 << 33) == 0 |
benchmark_functions_edited/f7331.py | def f(measure_1, measure_2):
try:
return round(abs(100*(measure_1-measure_2)/((measure_1+measure_2)/2)),3)
except ZeroDivisionError:
return 0
assert f(0,0) == 0 |
benchmark_functions_edited/f3399.py | def f(val, sample_rate, chunk_size):
return int(chunk_size * val / sample_rate)
assert f(1, 2, 3) == 1 |
benchmark_functions_edited/f9042.py | def f(date1,date2):
f = lambda d: map(int,d.split(":"))
h,m,s = (d[0] - d[1] for d in zip(f(date1), f(date2)))
return h*60*60 + m*60 + s
assert f("00:00:00","00:00:00") == 0 |
benchmark_functions_edited/f7852.py | def f(normalized_coords, resolution):
return (normalized_coords * 0.5 + 0.5) * (resolution - 1)
assert f(1, 10) == 9 |
benchmark_functions_edited/f10057.py | def f(number):
sumSq = (2 * number + 1) * (number + 1) * number // 6 # Sum of the squares.
sqOfSum = (number * (number + 1) // 2) ** 2 # Square of the sum.
return sqOfSum - sumSq
assert f(0) == 0 |
benchmark_functions_edited/f7904.py | def f(score):
result = 0 # Neutral by default
if score >= 0.05: # Positive
result = 1
elif score <= -0.05: # Negative
result = -1
return result
assert f(0.51) == 1 |
benchmark_functions_edited/f7891.py | def f(x, *p):
A, x0, sigma, C = p
x_shift = x - x0
return A * sigma**2 / (x_shift**2 + sigma**2) + C
assert f(-1.5, 1, 0, 0, 0) == 0 |
benchmark_functions_edited/f5266.py | def f(frequency, bin_size):
return int(round(frequency / bin_size))
assert f(21, 10) == 2 |
benchmark_functions_edited/f13688.py | def f(bytes: int, convert_to: str) -> int:
data = {"kb": 1, "mb": 2, "gb": 3, "tb": 4}
res = float(bytes)
for _ in range(data[convert_to]):
res = res / 1024
return round(res)
assert f(1073741824, "gb") == 1 |
benchmark_functions_edited/f1353.py | def f(b:bytes):
return int().from_bytes(b,"big")
assert f(b"\x00\x00\x00\x01") == 1 |
benchmark_functions_edited/f3236.py | def f(x):
import numpy as np
return np.sqrt(np.mean(x*x))
assert f(1) == 1 |
benchmark_functions_edited/f1872.py | def f(features, mean, std):
return (features - mean) / std
assert f(4, 1, 1) == 3 |
benchmark_functions_edited/f1085.py | def f(diagonal_1, diagonal_2):
return (diagonal_1*diagonal_2)/2
assert f(0, 10) == 0 |
benchmark_functions_edited/f7613.py | def f(line):
i = 0
title = line + 'e'
while title[0] == "#":
i += 1
title = title[1:]
return i
assert f('###### title') == 6 |
benchmark_functions_edited/f8804.py | def f(column, idx, default):
if isinstance(column, list):
if idx < len(column):
return column[idx]
return default
return column.get(idx, default)
assert f(list(range(10)), 2, None) == 2 |
benchmark_functions_edited/f14228.py | def f(a,b=None):
if (b == None):
if (a == []):
return 1
g = a[0]
for i in range(1, len(a)):
g = f(g, a[i])
return g
else:
while b:
a, b = b, a % b
return a
assert f(1,10) == 1 |
benchmark_functions_edited/f13988.py | def f(centerline_id, number_of_points):
return (centerline_id / number_of_points) ** 0.2
assert f(2, 2) == 1 |
benchmark_functions_edited/f11872.py | def f(n):
result = ""
f_num = f"{n:08b}"
for el in f_num:
if el == "1":
result += el
return len(result)
assert f(0) == 0 |
benchmark_functions_edited/f1105.py | def f(soundParams):
return soundParams[3] / soundParams[2]
assert f( (1, 1, 1, 1) ) == 1 |
benchmark_functions_edited/f7481.py | def f(a, b):
while b:
a, b = b, a%b
return a
assert f(3, 0) == 3 |
benchmark_functions_edited/f466.py | def f(a, b):
while b != 0:
a, b = b, a % b
return a
assert f(9, 3) == 3 |
benchmark_functions_edited/f9638.py | def f(lista: list, elemento) -> int:
cuenta = 0
for e in lista:
if e == elemento:
cuenta += 1
return cuenta
assert f(
['a', 'b', 'c'], 'a') == 1 |
benchmark_functions_edited/f12831.py | def f(value, null, true, false):
if value is None:
return null
if value is True:
return true
if value is False:
return false
return value
assert f(3, None, None, None) == 3 |
benchmark_functions_edited/f9481.py | def f(a, b):
if b == 0:
return 0
return a / b
assert f(0, 0) == 0 |
benchmark_functions_edited/f9935.py | def f(matches, string):
starts = map(lambda m: len(string) if m is None else m.start(), matches)
return min(starts)
assert f([None, None], "foo") == 3 |
benchmark_functions_edited/f10379.py | def f(map, width, pos):
x = pos[0] % width
y = pos[1]
if map[y] != '' and map[y][x] == '#':
return 1
return 0
assert f(
['......##.', '#...#...#.', '.#....#..', '..#.#...#.', '.#...##..', '.#..#...#.', '..####...'], 10, (0, 1)) == 1 |
benchmark_functions_edited/f8992.py | def f(varname, code):
code = code.split("\n")
ret = 0
for idx, line in enumerate(code, 1):
if "=" in line and varname in line.split("=")[0]:
ret = idx
return ret
assert f("x", "x = 1") == 1 |
benchmark_functions_edited/f6796.py | def f(obj, scope=None):
if scope is None:
try:
return obj.parent.get_expr_scope()
except AttributeError:
pass
return scope
assert f(1, 0) == 0 |
benchmark_functions_edited/f5725.py | def f(x_coord, in_min, in_max, out_min, out_max):
return int((x_coord - in_min) * (out_max - out_min) /
(in_max - in_min) + out_min)
assert f(12, 12, 255, 0, 255) == 0 |
benchmark_functions_edited/f3758.py | def f( redchan, nirchan ):
redchan = 1.0*redchan
nirchan = 1.0*nirchan
result =(nirchan/redchan)
return result
assert f(1000, 1000) == 1 |
benchmark_functions_edited/f9869.py | def f(shape_values):
result = 1
for val in shape_values:
result *= val
return result
assert f([1, 2, 3]) == 6 |
benchmark_functions_edited/f4825.py | def f(tuple):
return int(tuple[1]["end_time"])
assert f(tuple([0, {"end_time": "00003"}])) == 3 |
benchmark_functions_edited/f7157.py | def f(l):
return(sum(l) / float(len(l)))
assert f([1]) == 1 |
benchmark_functions_edited/f5740.py | def f(index):
if isinstance(index, (tuple, list)) and len(index) > 1:
return list(range(len(index)))
else:
return 0
assert f(slice(5)) == 0 |
benchmark_functions_edited/f14475.py | def f(number, nb_bits):
base = 1 << nb_bits
return (base - number) % base
assert f(-5, 8) == 5 |
benchmark_functions_edited/f2581.py | def f(input_data: str) -> int:
return sum(1 if char == '(' else -1 for char in input_data)
assert f(r'(((') == 3 |
benchmark_functions_edited/f725.py | def f(b):
n = 0
for bt in b:
n += bt
n = n << 8
return n >> 8
assert f(b'\x01') == 1 |
benchmark_functions_edited/f6674.py | def f(s):
if s is None:
return s
if isinstance(s, int):
return s
if isinstance(s, float):
return s
try:
return str(s)
except Exception:
return s
assert f(0) == 0 |
benchmark_functions_edited/f7576.py | def f(obj: str) -> float:
if not isinstance(obj, str):
raise ValueError()
return float(obj)
assert f('1.0') == 1 |
benchmark_functions_edited/f2773.py | def f(x1, y1, x2, y2):
return abs(x1-x2) + abs(y1-y2)
assert f(3, 3, 3, 1) == 2 |
benchmark_functions_edited/f6896.py | def f(min_value, max_value, value):
if value not in range(min_value, max_value + 1):
value = min(value, max_value)
value = max(min_value, value)
return int(value)
assert f(1, 10, 2.5) == 2 |
benchmark_functions_edited/f6687.py | def f(x) :
import datetime
date = datetime.datetime.strptime(x,"%Y%m%d")
wday = date.weekday()
if wday != 7 : return wday+1
else : return 1
assert f( '20180619' ) == 2 |
benchmark_functions_edited/f2758.py | def f(value):
try:
return int(value)
except:
return 0
assert f('fifty') == 0 |
benchmark_functions_edited/f4298.py | def f(line):
n = 0
while n < len(line) and line[n].isspace():
n += 1
return n
assert f( " abc" ) == 5 |
benchmark_functions_edited/f2580.py | def f(n):
i = 1
if n <= 0: return 0
while not n % i:
i <<= 1
return i >> 2
assert f(8) == 4 |
benchmark_functions_edited/f7894.py | def f(tokens):
imperatives = [t for t in tokens if t.full_pos.endswith('IMP')]
for t in imperatives:
t.mode_color.append('Imperatives')
return len(imperatives)
assert f([]) == 0 |
benchmark_functions_edited/f4697.py | def f(vec1, vec2, weights):
return sum(abs(vec1[i] - vec2[i]) * 1 / weights[i] for i in range(len(vec1)))
assert f(
[1, 2, 3],
[1, 2, 3],
[2, 2, 2]
) == 0 |
benchmark_functions_edited/f2559.py | def f(x):
try:
return int(x)
except ValueError:
return float(x)
assert f(5) == 5 |
benchmark_functions_edited/f5684.py | def f(number):
check = 0
for n in number:
check = (2 * check + int(10 if n == 'X' else n)) % 11
return check
assert f(
"123456789") == 1 |
benchmark_functions_edited/f11291.py | def f(x, y):
intersection = len(set.intersection(*[set(x), set(y)]))
union = len(set.union(*[set(x), set(y)]))
return intersection / float(union)
assert f(set([1, 2, 3, 4]), set([1, 2, 3, 4])) == 1 |
benchmark_functions_edited/f12077.py | def f(input_bytes_1: bytes, input_bytes_2: bytes):
xor_result = ((a ^ b) for (a, b) in zip(input_bytes_1, input_bytes_2))
joined_binary_string = "".join([bin(num) for num in xor_result])
return joined_binary_string.count("1")
assert f(b"1011", b"1010") == 1 |
benchmark_functions_edited/f14522.py | def f(A, elemento):
primero = 0
ultimo = len(A) - 1
posicion = -1
encontrado = False
while primero <= ultimo and not encontrado:
mitad = (primero + ultimo) // 2
if A[mitad] == elemento:
encontrado = True
posicion = mitad
else:
if elemento < A[mitad]:
ultimo = mitad - 1
else:
primero = mitad + 1
return posicion
assert f(
[1, 2, 3, 4, 5], 3) == 2 |
benchmark_functions_edited/f13497.py | def f(params, sample):
acum = 0
for i in range(len(params)):
acum = acum + params[i]*sample[i] #evaluates f(x) = a+bx1+cx2+ ... nxn..
return acum
assert f(list(), [3]) == 0 |
benchmark_functions_edited/f1402.py | def f(k):
return len(k) * 4
assert f(b"") == 0 |
benchmark_functions_edited/f11874.py | def f(ascii_bytes):
assert len(ascii_bytes) >= 2
return int(ascii_bytes[0] + ascii_bytes[1], 16)
assert f('00') == 0 |
benchmark_functions_edited/f400.py | def f(n):
return int(n * (3 * n - 1) / 2)
assert f(1) == 1 |
benchmark_functions_edited/f14089.py | def f(post_proc_args):
for p in post_proc_args:
if p.startswith("skipmins"):
skipmins = int(p.split("_")[1])
return skipmins
return 0
assert f(["plot_all_individual_cdfs", "skipmins_0"]) == 0 |
benchmark_functions_edited/f2013.py | def f(adv_input, is_train, reuse):
del is_train, reuse
return adv_input
assert f(1, False, True) == 1 |
benchmark_functions_edited/f611.py | def f(n):
return 1.0 if n <= 0 else 1.0 * n * f(n - 2)
assert f(0) == 1 |
benchmark_functions_edited/f9903.py | def f(value, default=None):
try:
return value
except:
return default
assert f(5, 10) == 5 |
benchmark_functions_edited/f1227.py | def f(units):
return sum(unit['count'] for _, unit in units.items())
assert f({}) == 0 |
benchmark_functions_edited/f483.py | def f(x, a, b, c, d):
return a + x*b + c*x**2 + d*x**3
assert f(0, 1, 2, 3, 4) == 1 |
benchmark_functions_edited/f3795.py | def f(a, b):
return a if b == 0 else f(b, a % b)
assert f(7, 5) == 1 |
benchmark_functions_edited/f7069.py | def f(mu, lam):
return mu ** 3 / lam
assert f(1, 0.5) == 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.