file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f10218.py
|
def f(genotype_type):
if genotype_type == "Hom":
return 0
elif genotype_type == "Het":
return 1
elif genotype_type == "Hom_alt":
return 2
assert f("Hom_alt") == 2
|
benchmark_functions_edited/f9147.py
|
def f(value, min_value, max_value):
if min_value > max_value:
raise ValueError("min_value must be bigger than max_value")
return float(min(max(value, min_value), max_value))
assert f(42, -100, 0) == 0
|
benchmark_functions_edited/f4795.py
|
def f(choices, value):
i = 0
for val in choices:
if val[0] == value:
return i
i += 1
return 0
assert f([['foo']], [['foo']]) == 0
|
benchmark_functions_edited/f9498.py
|
def f(pattern):
num_b = 0
for char in pattern:
if char == "B":
num_b += 1
return num_b
assert f("BBBB") == 4
|
benchmark_functions_edited/f4790.py
|
def f(x,default):
if x is None:
return default
else:
return x
assert f(3,5) == 3
|
benchmark_functions_edited/f4345.py
|
def f(low,value,high):
result = value if value >= low else low
result = value if value <= high else high
return result
assert f(2,3,4) == 3
|
benchmark_functions_edited/f13768.py
|
def f(inlistin):
inlistin = sorted(inlistin)
inlisto = 0
length = len(inlistin)
for x in range(int(length / 2) - 1):
del inlistin[0]
del inlistin[-1]
if len(inlistin) == 2:
inlisto = (int(inlistin[0] + inlistin[1]) / 2)
else:
inlisto = inlistin[1]
return inlisto
assert f([1, 4, 3, 5, 2]) == 3
|
benchmark_functions_edited/f3488.py
|
def f(shape):
try:
return shape[1]
except (IndexError, TypeError):
return 0
assert f((1, 1)) == 1
|
benchmark_functions_edited/f11568.py
|
def f(a,b):
return sorted([a,b], reverse = True)[0]
assert f(5, 5) == 5
|
benchmark_functions_edited/f10260.py
|
def f(type, valA, valB):
one = ["transmission"]
two = ["memory"]
three = ["processing"]
if type in one:
return valA + valB
if type in two:
return valA + valB
if type in three:
return valA + valB
print("type not found. Exiting.")
exit()
assert f(
"processing",
1.5,
2.5,
) == 4
|
benchmark_functions_edited/f6230.py
|
def f(orders):
totalRevenue = 0
for order in orders:
totalRevenue += order.shippingPrice if order.status == 3 else 0
return totalRevenue
assert f([]) == 0
|
benchmark_functions_edited/f10815.py
|
def f(property_name, recipe, ingredients):
score = 0
for amount, properties in zip(recipe, ingredients.values()):
value = properties[property_name]
ingredient_value = amount * value
score += ingredient_value
return score
assert f('calories', [0, 100], {'Sprinkles': {'calories': 300}}) == 0
|
benchmark_functions_edited/f6123.py
|
def f(logs):
for log in logs['job']:
if log.get('job', '') == log.get('action', '') == 'run_script':
return log['job_id']
assert False
assert f(
{
'job': [
{'job': 'not run_script', 'job_id': 1},
{'action': 'not run_script', 'job_id': 2},
{'job': 'run_script', 'action': 'run_script', 'job_id': 3},
{'job': 'not run_script', 'job_id': 4, 'action': 'run_script'},
]
}
) == 3
|
benchmark_functions_edited/f14022.py
|
def f(current_lvr, base_lvr, buffer=0.0):
return (1 - current_lvr / (base_lvr + buffer)) * 100
assert f(100000, 100000) == 0
|
benchmark_functions_edited/f6649.py
|
def f(j, number):
if number != 0:
if j % number == 0:
j *= (1.5 * number)
return j
assert f(1, 8) == 1
|
benchmark_functions_edited/f9520.py
|
def f(s):
import re
# via: https://github.com/chalk/ansi-regex/blob/master/index.js
s = re.sub("[\x1b\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]", "", s)
return len(s)
assert f(u"fo\u001b[33mo\u001b[0m\n") == 4
|
benchmark_functions_edited/f8687.py
|
def f(ctx, variants):
for value, predicate in variants:
if callable(predicate):
if predicate(ctx):
return value
elif predicate:
return value
assert f(None, (
(1, True),
(2, None),
)) == 1
|
benchmark_functions_edited/f14116.py
|
def f(individual):
# ideal vector
target = [1] * len(individual)
# hamming distance to ideal vector
distance = sum([abs(x - y) for (x,y) in zip(individual, target)]) / float(len(target))
# invert for fitness
return 1 - distance
assert f([1,1,1]) == 1
|
benchmark_functions_edited/f6500.py
|
def f(middle_of_edges, number):
return min(map(lambda middle: abs(middle - number), middle_of_edges))
assert f(range(0, 100), 0) == 0
|
benchmark_functions_edited/f6940.py
|
def f(theta, marginal, a, b):
z = theta - a - b
delta = (z ** 2 + 4 * a * marginal) ** 0.5
theta = (z + delta) / 2
return theta
assert f(0, 0, 1, 1) == 0
|
benchmark_functions_edited/f10712.py
|
def f(accumulated_mistake, standard_mistakes_threshold):
return 1 - (accumulated_mistake / standard_mistakes_threshold)
assert f(100, 100) == 0
|
benchmark_functions_edited/f757.py
|
def f(a,b):
c = (a-b)*10
return c
assert f(0,0) == 0
|
benchmark_functions_edited/f5540.py
|
def f(step):
return (5.0 - abs(float(step % 10) - 5.0)) / 10.0
assert f(0) == 0
|
benchmark_functions_edited/f2609.py
|
def f(a, b):
# Euclidean algorithm
while b > 0:
b, a = a % b, b
return a
assert f(5, 12) == 1
|
benchmark_functions_edited/f13545.py
|
def f(i, big_l_prime, small_l_prime):
length = len(big_l_prime)
assert i < length
if i == length - 1:
return 0
i += 1 # i points to leftmost matching position of P
if big_l_prime[i] > 0:
return length - big_l_prime[i]
return length - small_l_prime[i]
assert f(2, [0, 1, 2], [1, 2, 3]) == 0
|
benchmark_functions_edited/f9983.py
|
def f(list_to_search, sublist):
if len(sublist) > len(list_to_search):
return 0
count = 0
for idx in range(len(list_to_search) - len(sublist) + 1):
if list_to_search[idx:idx + len(sublist)] == sublist:
count += 1
return count
assert f(list(range(10)), list(range(12))) == 0
|
benchmark_functions_edited/f14149.py
|
def f(counts, a, b, c, d):
tilt = a + (b * counts) + (c * counts**2) + (d * counts**3)
return tilt
assert f(1000000, 0, 0, 0, 0) == 0
|
benchmark_functions_edited/f9441.py
|
def f(harm):
ret = None
if (harm == 0):
ret = 1
elif (harm == 1):
ret = 3
elif (harm == 2):
ret = 5
elif (harm == 3):
ret = 7
elif (harm == 4):
ret = 9
else:
ret = 0
return (ret)
assert f(float(3)) == 7
|
benchmark_functions_edited/f6396.py
|
def f(a:float,b:float) -> float:
#Change the code below
return a*b
assert f(-3.0, 0) == 0
|
benchmark_functions_edited/f7092.py
|
def f(c_d,A,rho,v):
return 0.5*c_d*rho*A*v**2
assert f(3, 2, 1, 0) == 0
|
benchmark_functions_edited/f3518.py
|
def f(p1, p2):
dx = p1['x'] - p2['x']
dy = p1['y'] - p2['y']
return dx * dx + dy * dy
assert f(
{'x': 1, 'y': 1}, {'x': 2, 'y': 2}) == 2
|
benchmark_functions_edited/f5278.py
|
def f(individual):
return sum(100 * (x * x - y)**2 + (1. - x)**2 \
for x, y in zip(individual[:-1], individual[1:]))
assert f([1, 1]) == 0
|
benchmark_functions_edited/f11951.py
|
def f(CurrentCourse,DestCourse):
CourseCorrection = DestCourse - CurrentCourse
if (CourseCorrection == 180):
return 180
if (CourseCorrection > 180):
return -(360 - CourseCorrection)
else:
return CourseCorrection
assert f(0,0) == 0
|
benchmark_functions_edited/f3550.py
|
def f(img):
img=img.split('.fits')
try:
nimg=int(img[0][-4:])
except:
return 0
return nimg
assert f('i000.fits') == 0
|
benchmark_functions_edited/f9562.py
|
def f(request):
if not hasattr(request, '_logging_pass'):
return 1
else:
return request._logging_pass
assert f(
'bar') == 1
|
benchmark_functions_edited/f14134.py
|
def f(x, knots, mu=None):
if mu != None:
if x >= knots[mu] and x < knots[mu+1]:
return mu
for mu in range(0, len(knots)-1):
if x >= knots[mu] and x < knots[mu+1]:
return mu
raise RuntimeError("Illegal knot vector or x value")
assert f(1.5, [0, 1, 2, 3], 1) == 1
|
benchmark_functions_edited/f1040.py
|
def f(m1, m2):
return m1 * m2 / (m1 + m2) ** 2
assert f(100, 0) == 0
|
benchmark_functions_edited/f5372.py
|
def f(img, u, v, n):
s = 0
for i in range(-n, n+1):
for j in range(-n, n+1):
s += img[u+i][v+j]
return float(s)/(2*n+1)**2
assert f(
[
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
[21, 22, 23, 24, 25],
],
0,
0,
0
) == 1
|
benchmark_functions_edited/f8495.py
|
def f(x,y,coeff):
a,b,c,d,e,f,g,h,i = coeff
return a + x*(b + x*d) + y*(c + y*f) + x*y*(e + x*g + y*h + x*y*i)
assert f(1, 1, (0, 0, 0, 0, 0, 0, 0, 0, 0)) == 0
|
benchmark_functions_edited/f3624.py
|
def f(n):
if n == 0:
return 0
else:
return n + f(n - 1)
assert f(2) == 3
|
benchmark_functions_edited/f6919.py
|
def f(d:dict) -> int:
n = 0
for k,v in d.items():
if type(v) is dict:
n += f(v)
else:
n += 1
return n
assert f({1: {'a': 1, 'b': 2}, 2: {}}) == 2
|
benchmark_functions_edited/f5060.py
|
def f(x, y, a, b):
y %= b - a
x = x + y
return x - (b - a) * (x >= b)
assert f(1, 1, 1, 10) == 2
|
benchmark_functions_edited/f11634.py
|
def f(n):
result = 0
if n >= 2:
x, y = 1, 1
for _ in range(n):
x, y = y, x + y
if x > n:
break
if x % 2 == 0:
# print(x, y)
result += x
return result
assert f(2) == 2
|
benchmark_functions_edited/f477.py
|
def f(m):
return m["sight"]
assert f(*[{"sight": 9}]) == 9
|
benchmark_functions_edited/f4333.py
|
def f(n):
pm = 2
while n != 1:
if n % pm == 0:
n = n / pm
else:
pm += 1
return pm
assert f(5) == 5
|
benchmark_functions_edited/f9200.py
|
def f(bprop, xi, redshift):
corrections = {
'rate': 1, # mesa time in observer coordinate?
'dt': 1,
'fluence': xi**2,
'peak': xi**2,
}
return corrections[bprop]
assert f('dt', 2, 3) == 1
|
benchmark_functions_edited/f8791.py
|
def f(n):
assert type(n) == int and n >= 0
if n in (0, 1):
return 1
else:
return n * f(n - 2)
assert f(1) == 1
|
benchmark_functions_edited/f2501.py
|
def f(n: int) -> int:
count = 0
while (n):
count += n & 1
n >>= 1
return count
assert f(1) == 1
|
benchmark_functions_edited/f1895.py
|
def f(value, minimum, maximum):
return max(min(value, maximum), minimum)
assert f(-5, 0, 10) == 0
|
benchmark_functions_edited/f4317.py
|
def f(v, index, x):
mask = 1 << index
if x:
v |= mask
else:
v &= ~mask
return v
assert f(3, 1, False) == 1
|
benchmark_functions_edited/f11334.py
|
def f(t, t_obs):
comparison = t > t_obs
return int(comparison)
assert f(10, 10) == 0
|
benchmark_functions_edited/f11200.py
|
def f(n: int) -> int:
return 1 + f(n // 16) if n > 512 else 0
assert f(16 * 513) == 2
|
benchmark_functions_edited/f3107.py
|
def f(interval):
return (interval[1]-interval[0])/2+(interval[1]+interval[0])/2
assert f( [4, 2] ) == 2
|
benchmark_functions_edited/f12352.py
|
def f(cart_tree):
if isinstance(cart_tree["left"], dict):
cart_tree["left"] = f(cart_tree["left"])
if isinstance(cart_tree["right"], dict):
cart_tree["right"] = f(cart_tree["right"])
return (cart_tree["left"] + cart_tree["right"]) / 2
assert f(
{'left': 5, 'right': {'left': 0, 'right': 2, 'value': 2}, 'value': 3}) == 3
|
benchmark_functions_edited/f1968.py
|
def f(n):
a, b = 0, 1
for i in range(n):
a, b = b, a+b
return a
assert f(0) == 0
|
benchmark_functions_edited/f5567.py
|
def f(vector):
list_vector = list(vector)
sum_vector = sum(list_vector)
len_vector = float(len(list_vector))
mean_final = sum_vector/len_vector
return(mean_final)
assert f([1, 1]) == 1
|
benchmark_functions_edited/f9063.py
|
def f(a: int, b: int) -> int:
return a if b == 0 else f(b, a % b)
assert f(4, 10) == 2
|
benchmark_functions_edited/f13013.py
|
def f(locations, new):
ret = 0
for loc in locations:
if loc['url'] == new['url'] and loc['metadata'] == new['metadata']:
ret += 1
return ret
assert f(
[{'url': 'url1','metadata':'metadata1'},
{'url': 'url1','metadata':'metadata2'},
{'url': 'url1','metadata':'metadata3'}],
{'url': 'url2','metadata':'metadata1'}
) == 0
|
benchmark_functions_edited/f10126.py
|
def f(s: str) -> int:
try:
n = int(s)
if n < 0:
raise ValueError
return n
except ValueError:
raise ValueError('Must be non-negative integer')
assert f(0.0) == 0
|
benchmark_functions_edited/f10321.py
|
def f(shape: tuple) -> int:
if not shape:
return 0
out = 1
for k in shape:
out *= k
return out
assert f(tuple()) == 0
|
benchmark_functions_edited/f162.py
|
def f(x):
return 1/2 * x ** 2 + 3
assert f(0) == 3
|
benchmark_functions_edited/f6863.py
|
def f(iterator):
return sum(1 for i in iterator)
assert f(["cat", [], "dog"]) == 3
|
benchmark_functions_edited/f6430.py
|
def f(c):
return (ord(c) >> 3) & 0x07
assert f(b'\x24') == 4
|
benchmark_functions_edited/f14304.py
|
def f(score):
scoreSq = score ** 2
smallestDigit = -1
while scoreSq > 0:
currentDigit = scoreSq % 10
scoreSq = scoreSq // 10
if currentDigit < smallestDigit or smallestDigit == -1:
smallestDigit = currentDigit
if smallestDigit == -1:
smallestDigit = 0
returnVal = smallestDigit + 3
return returnVal
assert f(1) == 4
|
benchmark_functions_edited/f3014.py
|
def f(nth,first_term,common_difference):
return ((nth-first_term)/common_difference)+1
assert f(6,2,2) == 3
|
benchmark_functions_edited/f11693.py
|
def f(a,b):
chrA = a[0]
chrB = b[0]
posA = int(a[1])
posB = int(b[1])
if (chrA == chrB):
if (posA == posB): return 0
if (posA < posB): return -1
if (posA > posB): return 1
if (chrA < chrB):
return -1
if (chrA > chrB):
return 1
assert f(
['2', 123456],
['1', 123456]
) == 1
|
benchmark_functions_edited/f9148.py
|
def f(read):
if read is False:
return False
mm = [int(i.split(':')[2]) for i in read[11:] if i.startswith('NM:i:')]
if len(mm) > 0:
return sum(mm)
else:
return False
assert f(['@test_1:0', 'ACCTGCTGGG', '+', 'ACCTGCTGGG', 'NM:i:0']) == 0
|
benchmark_functions_edited/f8558.py
|
def f(p, xs):
for i in (i for i, x in enumerate(xs) if p(x)):
return i
assert f(lambda x: x == 0, [1, 0, 3, 0, 5]) == 1
|
benchmark_functions_edited/f9936.py
|
def f(input_str: str) -> int:
return sum(letter in 'aeiou' for letter in input_str)
assert f('!@#$%&') == 0
|
benchmark_functions_edited/f4999.py
|
def f(x, y):
return x**2 / (x**2 + y**2)**(3/2.)
assert f(0, 1) == 0
|
benchmark_functions_edited/f14065.py
|
def f(obj: object) -> int:
if isinstance(obj, int):
return obj
if isinstance(obj, str):
return 0
if isinstance(obj, list):
return sum(map(sum_non_red, obj))
if isinstance(obj, dict):
if 'red' in obj.values():
return 0
return sum(map(sum_non_red, obj.values()))
raise TypeError('Unexpected type: {}'.format(type(obj)))
assert f([1,"red",5]) == 6
|
benchmark_functions_edited/f9524.py
|
def f(graph, node_val, target):
if node_val >= target:
return 1
total = 0
for next_node in graph[node_val]:
total += f(graph, next_node, target)
return total
assert f(
{1: [2], 2: [1, 3], 3: [2, 4], 4: [3, 5], 5: [4]},
1,
1
) == 1
|
benchmark_functions_edited/f9699.py
|
def f(val):
return max(min(val, 4.0), -4.0)
assert f(2) == 2
|
benchmark_functions_edited/f769.py
|
def f(prod_client):
client = prod_f()
return client
assert f(lambda: 5) == 5
|
benchmark_functions_edited/f1632.py
|
def f(iterator):
p = 1
for v in iterator:
p *= v
return p
assert f([3, 2, 1, 0]) == 0
|
benchmark_functions_edited/f3527.py
|
def f(R, Rin, Sig0, p):
return Sig0 * pow(R / Rin, -p)
assert f(1, 1, 1, 1) == 1
|
benchmark_functions_edited/f11974.py
|
def f(tword,codetree):
pos = 0
while True:
s = tword[pos]
if s not in codetree:
return 0
elif pos==len(tword)-1:
return codetree[s][0]
else:
pos += 1
codetree = codetree[s][1]
assert f(b"cat",{'d':(1,{})}) == 0
|
benchmark_functions_edited/f7383.py
|
def f(expected_mb):
if expected_mb < 1: # < 1 MB
expected_mb = 1
elif expected_mb > 10**7: # > 10 TB
expected_mb = 10**7
return expected_mb
assert f(0.1) == 1
|
benchmark_functions_edited/f6891.py
|
def f(exon_num):
if exon_num == 1:
return 1
elif exon_num <= 10:
return 2
else:
twenty_perc = exon_num / 5
return twenty_perc
assert f(7) == 2
|
benchmark_functions_edited/f1469.py
|
def f(mq, mS):
return (1 - 4*(mq/mS)**2)**(1/2)
assert f(0.0, 1.0) == 1
|
benchmark_functions_edited/f11105.py
|
def f(a, b, c, d=0, e=0):
print(f"Function `suba` called with arguments a={a} b={b} c={c}", end="")
if d: print(f" d={d}", end="")
if e: print(f" e={e}", end="")
print()
return a - b - c - d - e
assert f(2, 1, 1) == 0
|
benchmark_functions_edited/f2808.py
|
def f(alist):
count = 0
for item in alist:
count = count + 1
return count
assert f( ['a', 'b', 'c']) == 3
|
benchmark_functions_edited/f13766.py
|
def f(string, newline=True, interpret=False):
if interpret:
string = bytes(string, 'utf-8').decode('unicode_escape')
print(string, end='\n' if newline else '')
return 0
assert f(b'hello', True) == 0
|
benchmark_functions_edited/f6879.py
|
def f(num: int, modulus: int) -> int:
order = 1
while True:
newval = (num ** order) % modulus
if newval == 1:
return order
order += 1
return order
assert f(5, 3) == 2
|
benchmark_functions_edited/f6736.py
|
def f(n):
if n == 0:
return 0
cache = [0,1]
for i in range(n-2):
cache[0],cache[1] =cache[1], cache[0] + cache[1]
return cache[0] + cache[1]
assert f(6) == 8
|
benchmark_functions_edited/f13443.py
|
def f(input_list) -> int:
idx_max = input_list.index(max(input_list))
return idx_max
assert f( [5, 10, 10, 15, 20]) == 4
|
benchmark_functions_edited/f5210.py
|
def f(*bits):
assert len(bits) == len(set(bits))
value = 0
for b in bits:
value += 1 << b
return value
assert f(0, 1) == 3
|
benchmark_functions_edited/f7667.py
|
def f(number):
number_of_digits = 0
while (number > 0):
number_of_digits+=1
number //= 10
return number_of_digits
assert f(9999) == 4
|
benchmark_functions_edited/f4122.py
|
def f(steps):
arr = [1, 1]
for _ in range(1, steps):
arr.append(arr[-1] + arr[-2])
return arr[-1]
assert f(1) == 1
|
benchmark_functions_edited/f13939.py
|
def f(sequence):
length = len(sequence)
counts = [1 for _ in range(length)]
for i in range(1, length):
for j in range(0, i):
if sequence[i] > sequence[j]:
counts[i] = max(counts[i], counts[j] + 1)
print(counts)
return max(counts)
assert f(
[5, 4, 3, 6, 2, 1]) == 2
|
benchmark_functions_edited/f2512.py
|
def f(val, min_val, max_val):
return min(max(val, min_val), max_val)
assert f(4, 2, 4) == 4
|
benchmark_functions_edited/f12640.py
|
def f(source, body, part):
if len(body) >= part:
startOffset = body[part].start
ret = startOffset
while source[ret] != '\n':
ret -= 1
newline = ret
ret += 1
while source[ret] == ' ':
ret += 1
return ret-newline-1
else:
return 4
assert f(
'def foo(bar, baz):\n print(bar)\n',
['def foo(bar, baz):\n print(bar)\n',' print(bar)\n'],
len('def foo(bar, baz):\n print(bar)\n')
) == 4
|
benchmark_functions_edited/f199.py
|
def f(a, b):
return b if a is None else a
assert f(1, f(None, 2)) == 1
|
benchmark_functions_edited/f6521.py
|
def f(numbers):
list_digits = []
for item in numbers:
list_digits.append(int(len(str(item))))
return int(max(list_digits))
assert f([1000, 100, 10]) == 4
|
benchmark_functions_edited/f7871.py
|
def f(histo1, histo2):
s1 = set(histo1.keys())
s2 = set(histo2.keys())
return len(s1) + len(s2) - len(s1.intersection(s2))
assert f(
{'a': 1, 'b': 1, 'c': 2}, {}
) == 3
|
benchmark_functions_edited/f6962.py
|
def f(condition, true, false):
if condition:
return true
else:
return false
assert f(True, 1, 2) == 1
|
benchmark_functions_edited/f13193.py
|
def f(cmd:bytes):
return int(cmd.decode("utf-8").strip().split("\n")[1].split(':')[1].strip())
assert f(b'Input File : file.wav\nChannels : 1\nSample Rate : 24000\nPrecision : 16-bit\nEndian type : little\nDuration : 00:00:04.03 = 749 samples ~ 157.455 CDDA sectors\nFile Size : 1.54k\nBit Rate : 16k\nSample Encoding : 16-bit Signed Integer PCM') == 1
|
benchmark_functions_edited/f11332.py
|
def f(n):
n = int(n)
if n == 0 or n == 1: # base case
return n
return f(n-1) + f(n-2)
assert f(0) == 0
|
benchmark_functions_edited/f1743.py
|
def f(node, neighborhoods):
return len(neighborhoods[node]) + 1
assert f(1, [[1,2], [0, 2], [0, 1]]) == 3
|
benchmark_functions_edited/f3805.py
|
def f(n):
a, b = 0, 1
for i in range(n - 1):
a, b = b, a + b
return a
assert f(2) == 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.