file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f3679.py | def f(n_samples, n_clusters):
return (n_samples + n_clusters - 1) // n_clusters
assert f(10, 3) == 4 |
benchmark_functions_edited/f7335.py | def f(nm, prevs):
if nm not in prevs:
return nm
i = 1
while True:
if nm + str(i) not in prevs:
return nm + str(i)
i += 1
assert f(1, []) == 1 |
benchmark_functions_edited/f12116.py | def f(dataset, colors):
colorsDict = colors
try:
colorVal = colorsDict[dataset][4:-1].split(',')[2]
return int(colorVal)
except KeyError:
return 0
assert f(3, {'3': '#000000,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0'}) == 0 |
benchmark_functions_edited/f6409.py | def f(position_of_card, deck):
# print(deck[position_of_card])
value_int = deck[position_of_card][1]
return value_int
assert f(0, [(1, 2)]) == 2 |
benchmark_functions_edited/f1711.py | def f(x, y):
if y == 0:
return 0
return x / y
assert f(1, 0) == 0 |
benchmark_functions_edited/f13558.py | def f(x, y, s_w, s_h):
if x < s_w / 3:
return 0 if y < s_h / 2 else 3
if s_w / 3 < x < s_w * 2 / 3:
return 1 if y < s_h / 2 else 4
if x > s_w * 2 / 3:
return 2 if y < s_h / 2 else 5
assert f(20, 10, 10, 10) == 5 |
benchmark_functions_edited/f11923.py | def f(rule_string: str) -> int:
n_conditions = rule_string.count("X['")
return n_conditions
assert f(
"IF X['A']>0.50 THEN 0 IF X['B']>0.50 THEN 1 ELSE 2") == 2 |
benchmark_functions_edited/f6570.py | def f(func, iterable):
for elem in iterable:
if func(elem):
return elem
assert f(lambda x: x % 11 == 0, range(101)) == 0 |
benchmark_functions_edited/f10996.py | def f(dict, key_list):
x = dict
if isinstance(key_list, str) or isinstance(key_list, tuple):
x = x[key_list]
elif isinstance(key_list, list):
for k in key_list:
x = x[k]
return x
assert f(
{"a": {"b": 1, "c": {"d": 2}}},
["a", "b"]
) == 1 |
benchmark_functions_edited/f1555.py | def f(x):
return x.real * x.real + x.imag * x.imag
assert f(1 + 1j) == 2 |
benchmark_functions_edited/f13120.py | def f(temp, pressure, gas_constant):
return pressure / (temp * gas_constant)
assert f(1, 2, 1) == 2 |
benchmark_functions_edited/f13250.py | def f(byte: int, index: int) -> int:
assert 0 <= byte <= 255
assert 0 <= index <= 7
# Python guarantees the ~ operator will return the 2s complement
# signed integer with the same bit pattern, AKA, ~128 is -129, not 127.
# However, the & operator with the resulting value will use the sign bit,
... |
benchmark_functions_edited/f3228.py | def f(x, alpha, gamma):
return x**alpha / (x ** alpha + gamma ** alpha)
assert f(0, 1, 1) == 0 |
benchmark_functions_edited/f2837.py | def f(liveness, args):
return sum(liveness["alwaysLive"]["bytesByTile"])
assert f({"alwaysLive": {"bytesByTile": []}}, 1) == 0 |
benchmark_functions_edited/f2954.py | def f(wrapped, instance, args, kwargs):
return wrapped(*args, **kwargs)
assert f(lambda x, y=42: x + y, None, [1], {'y': 4}) == 5 |
benchmark_functions_edited/f819.py | def f(A: int, D: int) -> int:
return A * A + D
assert f(2, 1) == 5 |
benchmark_functions_edited/f2747.py | def f(bits, length):
return sum(bits[i] * 2**(-i-1) for i in range(length))
assert f((0,), 1) == 0 |
benchmark_functions_edited/f8588.py | def f(a: int, b: int) -> int:
while a != 0:
a, b = b % a, a
return b
assert f(14, 21) == 7 |
benchmark_functions_edited/f2085.py | def f(audio):
assert len(audio) % 2 == 0
return len(audio) // 2
assert f(list(range(1, 13))) == 6 |
benchmark_functions_edited/f10894.py | def f(x,y,x1,x2,y1,y2,m11,m12,m21,m22):
first_xs = ((x2-x)/(x2-x1))
second_xs = ((x-x1)/(x2-x1))
first_ys = ((y2-y)/(y2-y1))
second_ys = ((y-y1)/(y2-y1))
m11 *= first_xs
m12 *= second_xs
m21 *= first_xs
m22 *= second_xs
return (m11 + m12)*first_ys + (m21 + m22)*second_ys
assert f(3,... |
benchmark_functions_edited/f13721.py | def f(r):
if isinstance(r, list) or type(r) == int or type(r) == float:
return r
else:
if r.find('[') != -1:
if r.find(',') != -1:
values = map(int, r.strip('[').strip(']').split(','))
else:
values = map(int, r.strip('[').strip(']').split()... |
benchmark_functions_edited/f1505.py | def f(h=0, m=0, s=0):
return h * 3600 + m * 60 + s
assert f(0, 0, 0) == 0 |
benchmark_functions_edited/f9763.py | def f(epsilon1 = 0.9,epsilon2= 0.9):
result = 1.0/(1/epsilon1+1/epsilon2-1) # here I just implement the epsilon effective formula
return result
assert f(1, 1) == 1 |
benchmark_functions_edited/f9802.py | def f(dictionary, *args, **kwargs):
for key in args:
try:
return dictionary[key]
except KeyError:
pass
if 'default' in kwargs:
return kwargs['default']
else:
raise KeyError
assert f( {'a': 1}, 'a') == 1 |
benchmark_functions_edited/f628.py | def f(a, b, c):
return a + b + c
assert f(1, 2, 3) == 6 |
benchmark_functions_edited/f6642.py | def f(neighborhood_size, feature_size):
return (neighborhood_size + 1)**(feature_size + 1) - neighborhood_size**(
feature_size + 1)
assert f(0, 1) == 1 |
benchmark_functions_edited/f11660.py | def f(current, previous):
if current == previous:
return 0
try:
return ((current - previous) / previous) * 100.0
except ZeroDivisionError:
return float('inf')
assert f(100, 100) == 0 |
benchmark_functions_edited/f3302.py | def f(prop, seq):
if seq in prop:
return prop[seq]
else:
return None
assert f(
{1: 0, 2: 1, 3: 0},
2
) == 1 |
benchmark_functions_edited/f603.py | def f(x):
if x > 0:
return 1
else:
return 0
assert f(-100) == 0 |
benchmark_functions_edited/f3992.py | def f(p, q, r):
return (q[1] - p[1]) * (r[0] - p[0]) - (q[0] - p[0]) * (r[1] - p[1])
assert f( (1, 1), (2, 2), (2, 2) ) == 0 |
benchmark_functions_edited/f6345.py | def f(dit):
return dit.items() if hasattr(dit, 'items') else dit
assert f(1) == 1 |
benchmark_functions_edited/f12433.py | def f(json_object, attribute_name, caller):
if json_object.__contains__(attribute_name):
return json_object[attribute_name]
raise Exception('Cannot find attribute {} in {}.'.format(attribute_name, caller))
assert f(
{"a": 1},
"a",
"_get_json_entry"
) == 1 |
benchmark_functions_edited/f4158.py | def f(list_nums):
return sum(list(filter(lambda x: x % 2 == 0, list_nums)))
assert f([]) == 0 |
benchmark_functions_edited/f644.py | def f(x, y, z):
return (x+y+z)/3
assert f(1, 2, 3) == 2 |
benchmark_functions_edited/f1963.py | def f(n, t):
n1 = n - 1
return n1 - abs(t % (2*n1) - n1)
assert f(3, 5) == 1 |
benchmark_functions_edited/f11541.py | def f(dct, keys):
o = dct
for k in keys:
o = o.get(k)
if o is None:
return None
return o
assert f(
{'a': {'aa': {'aaa': {'b': 1, 'c': 2}}}},
['a', 'aa', 'aaa', 'b']
) == 1 |
benchmark_functions_edited/f11679.py | def f(exp: int):
level = int(((exp + 1) * 2) ** (1 / 3))
if level == 0:
level += 1
return level
assert f(0) == 1 |
benchmark_functions_edited/f5192.py | def f(n: int) -> int:
if n == 0: return 0
if n == 1: return 1
return f(n-1) + f(n-2)
assert f(3) == 2 |
benchmark_functions_edited/f5002.py | def f(string):
(hhs,mms,sss) = string.split(':')
return (int(hhs)*60 + int(mms))*60 + int(sss)
assert f( "00:00:00" ) == 0 |
benchmark_functions_edited/f14266.py | def f(L, i):
# The index of the smallest item so far
index_of_smallest = i
end = len(L)
for j in range(i + 1, end):
if L[j] < L[index_of_smallest]:
index_of_smallest = j
return index_of_smallest
assert f(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 8) == 8 |
benchmark_functions_edited/f5874.py | def f(pmt, interest_rate, years, m=1):
i = interest_rate
return pmt * ((1 + interest_rate / m) ** (years * m) - 1) / (i / m)
assert f(1000, 0.03, 0, 1) == 0 |
benchmark_functions_edited/f6525.py | def f(A):
my_max = A[0]
for idx in range(1, len(A)):
if my_max < A[idx]:
my_max = A[idx]
return my_max
assert f([1, 2, 3, 4, 5]) == 5 |
benchmark_functions_edited/f184.py | def f(args) -> int:
print('hello!')
return 0
assert f(1) == 0 |
benchmark_functions_edited/f7487.py | def f(A):
count = 0
for i in A:
if(i == 1):
count += 1
return count
assert f( [1, 1, 1, 1, 1, 1, 1] ) == 7 |
benchmark_functions_edited/f4690.py | def f(var):
return int(var[1:])
assert f( "t9" ) == 9 |
benchmark_functions_edited/f11617.py | def f(number, discreteSet):
if number < 0:
return False
discreteSet.sort()
for item in discreteSet:
if number <= item:
return item
return False
assert f(4, [1, 2, 3, 4, 5]) == 4 |
benchmark_functions_edited/f11931.py | def f(x, y):
return (x - y)
assert f(1, 1) == 0 |
benchmark_functions_edited/f1987.py | def f(s):
return None if not s else int(s)
assert f(1.0) == 1 |
benchmark_functions_edited/f10998.py | def f(message_level):
result = 0
if message_level == "error(parsing)":
result = 1
if message_level == "error(2)":
result = 2
if message_level == "error(mac)":
result = 2
if message_level == "error(3)":
result = 3
return result
assert f("error(mac)") == 2 |
benchmark_functions_edited/f12858.py | def f(feedback: str) -> int:
total_matches = feedback.count("Matched")
class_matches = feedback.count("Class Matched")
attr_matches = feedback.count("Attribute Match") + feedback.count("Attribute Misplaced Match")
return max(0, total_matches - class_matches - attr_matches)
assert f(
) == 3 |
benchmark_functions_edited/f5056.py | def f(a : int, b : int, op : str) -> int:
o = {'+' : a + b, '-' : a - b, '*' : a * b, '/' : a / b, '^' : a**b}
return o[op]
assert f(10, 10, '-') == 0 |
benchmark_functions_edited/f3648.py | def f(entry):
return entry['total time (s)'] / float(entry['correct answers'] + entry['wrong answers'])
assert f(
{'total time (s)': 2, 'correct answers': 1, 'wrong answers': 1}) == 1 |
benchmark_functions_edited/f2133.py | def f(list, item):
try:
i = list.index(item)
except:
return 0
else:
return 1
assert f(range(5), 3) == 1 |
benchmark_functions_edited/f11775.py | def f(tokens_per_epoch, seq_length, num_samples):
num_epochs = 0
total_tokens = 0
while True:
num_epochs += 1
total_tokens += tokens_per_epoch
if ((total_tokens - 1) // seq_length) >= num_samples:
return num_epochs
assert f(250, 30, 25) == 4 |
benchmark_functions_edited/f7168.py | def f(filename):
try:
with open(filename, "r") as handle:
return float(handle.read().strip())
except FileNotFoundError:
return 0
assert f(
"docs/img/docker-push-age/2021-02-27T01:00:00.invalid.txt"
) == 0 |
benchmark_functions_edited/f3258.py | def f(x):
from struct import pack,unpack
(x,) = unpack("I", pack("f", x))
return x
assert f(0) == 0 |
benchmark_functions_edited/f7038.py | def f(p1, p2):
p = 0
while p2:
if p2 & 0b1:
p ^= p1
p1 <<= 1
if p1 & 0b10000:
p1 ^= 0b11
p2 >>= 1
return p & 0b1111
assert f(1, 0) == 0 |
benchmark_functions_edited/f3619.py | def f(vector_one, vector_two):
return(vector_two[1] - vector_one[1])/(vector_two[0] - vector_one[0])
assert f(
(-100, 50), (100, 50)) == 0 |
benchmark_functions_edited/f13194.py | def f(capcha_str):
capcha = [int(cc) for cc in list(capcha_str)]
total = 0
for ii in range(len(capcha)):
if capcha[ii] == capcha[ii - 1]:
total += capcha[ii]
return total
assert f( "91212129" ) == 9 |
benchmark_functions_edited/f9693.py | def f(i,j,n):
return i+j*n
assert f(0,1,3) == 3 |
benchmark_functions_edited/f8964.py | def f(key, length):
step = 1 << (length - 1)
while key & step:
step >>= 1
return (key & (step - 1)) + step
assert f(65534, 16) == 1 |
benchmark_functions_edited/f8378.py | def f(data, min_screen, max_screen, min_data, max_data):
return ((data - min_data) / (max_data - min_data)) * (max_screen - min_screen) + min_screen
assert f(0, 1, 100, 0, 100) == 1 |
benchmark_functions_edited/f4037.py | def f(n: int) -> int:
x = n
y = (x + 1) // 2
while y < x:
x = y
y = (x + n // x) // 2
return x
assert f(9) == 3 |
benchmark_functions_edited/f11710.py | def f(true_val, pred_val):
return abs(true_val - pred_val)
assert f(-0.5, -0.5) == 0 |
benchmark_functions_edited/f6752.py | def f(s, value):
total = 0
for elem in s:
if elem == value:
total = total + 1
return total
assert f((), 0) == 0 |
benchmark_functions_edited/f3631.py | def f(value: float, minimum: float, maximum: float) -> float:
return min(maximum, max(minimum, value))
assert f(0, 1, 5) == 1 |
benchmark_functions_edited/f8120.py | def f(dic):
total = 1
for key, value in dic.items():
total *= len(value)
return total
assert f(
{
"a": ["x"],
"b": ["x", "y"]
}
) == 2 |
benchmark_functions_edited/f2877.py | def f(ic50, ic50_threshold):
if ic50 <= ic50_threshold:
return 1
return 0
assert f(1.0, 3.0) == 1 |
benchmark_functions_edited/f7505.py | def f(tensor_name):
return int(tensor_name.split(':')[1])
assert f('a:0') == 0 |
benchmark_functions_edited/f11404.py | def f(n, k):
# Just put all three return possibilities into one statement. Could use parentheses if it
# seems clearer.
return 1 if k==0 else 0 if n==0 else f(n-1, k) + f(n-1, k-1)
assert f(4, 4) == 1 |
benchmark_functions_edited/f5388.py | def f( n ) : ## ceil( log_2 ( n )) [Used by LZ.py]
assert n>=1
c = 0
while 2**c<n :
c += 1
return c
assert f(28) == 5 |
benchmark_functions_edited/f11439.py | def f(n: int) -> int:
c = 0
while n:
n &= n - 1
c += 1
return c
assert f(0b1) == 1 |
benchmark_functions_edited/f2257.py | def f(n):
sqrt_5 = 5**0.5
return round(((1 + sqrt_5) / 2)**n / sqrt_5)
assert f(4) == 3 |
benchmark_functions_edited/f7962.py | def f(argumentValues):
if 0 in argumentValues:
outcome = 0
else:
outcome = 1
return outcome
assert f( [0, 1] ) == 0 |
benchmark_functions_edited/f11128.py | def f(len1: float,
len2: float) -> float:
scale = len1 / len2
if scale <= 1:
return scale
else:
return 1 / scale
assert f(1, 1) == 1 |
benchmark_functions_edited/f11132.py | def f(input_data):
return input_data * (input_data > 0)
assert f(-4) == 0 |
benchmark_functions_edited/f3316.py | def f(prevsum, prevmean, mean, x):
newsum = prevsum + (x - prevmean) * (x - mean)
return newsum
assert f(1, 1, 1, 2) == 2 |
benchmark_functions_edited/f3362.py | def f(coord1, coord2):
return abs(coord1[0] - coord2[0]) + abs(coord1[1] - coord2[1])
assert f( (0,0), (3,4) ) == 7 |
benchmark_functions_edited/f1674.py | def f(s, N):
return bin(s).count('1')
assert f(0b1111, 4) == 4 |
benchmark_functions_edited/f10084.py | def f(hour_out, check_out, tolerance):
if hour_out > check_out:
if (hour_out - check_out) < tolerance:
result = ' '
else:
result = hour_out - check_out
else:
result = ' '
return result
assert f(14, 12, 2) == 2 |
benchmark_functions_edited/f11479.py | def f(a: str, b: str) -> int:
if not len(a):
return len(b)
if not len(b):
return len(a)
if a[0] == b[0]:
return f(a[1:], b[1:])
return 1 + min(
f(a[1:], b),
f(a, b[1:]),
f(a[1:], b[1:])
)
assert f(b"a", b"b") == 1 |
benchmark_functions_edited/f10055.py | def f(numerator, denominator):
assert numerator % denominator == 0, \
'{} is not divisible by {}'.format(numerator, denominator)
return numerator // denominator
assert f(6, 3) == 2 |
benchmark_functions_edited/f6830.py | def f(roi):
def slice_center(s):
return (s.start + s.stop)*0.5
if isinstance(roi, slice):
return slice_center(roi)
return tuple(slice_center(s) for s in roi)
assert f(slice(1, 3)) == 2 |
benchmark_functions_edited/f2345.py | def f(a, b):
c = a + b
return c
assert f(-2, 2) == 0 |
benchmark_functions_edited/f3005.py | def f(arg):
if getattr(arg,'_is_Handler',False):
return arg.solve
else: return arg
assert f(1) == 1 |
benchmark_functions_edited/f98.py | def f(d):
return int(d**2/4)+d
assert f(1) == 1 |
benchmark_functions_edited/f7828.py | def f(phi):
So = (1 - phi) / (1 + phi / 2)
return So
assert f(0) == 1 |
benchmark_functions_edited/f11002.py | def f(base, exp):
if exp == 0:
return 1
if exp % 2 == 1:
return base * f(base * base, exp // 2)
return f(base * base, exp // 2)
assert f(5, 1) == 5 |
benchmark_functions_edited/f5059.py | def f(all_actions):
return (len(all_actions) - 1)
assert f(["up"]) == 0 |
benchmark_functions_edited/f4012.py | def f(bits):
return bits/(8*1024*1024)
assert f(0) == 0 |
benchmark_functions_edited/f7375.py | def f(sequence):
it = iter(sequence)
try:
return next(it)
except StopIteration:
raise ValueError()
assert f([3, 5, 9, 7, 8]) == 3 |
benchmark_functions_edited/f5173.py | def f(S):
n = len(S)
total = 0
for j in range(0, n, 2): # note the increment of 2
total += S[j]
return total
assert f([]) == 0 |
benchmark_functions_edited/f2938.py | def f(nodes, i):
if nodes[i] != i:
nodes[i] = f(nodes, nodes[i])
return nodes[i]
assert f(list(range(30)), 5) == 5 |
benchmark_functions_edited/f5989.py | def f(a):
print("valeur de a dans test2",a,id(a))
a=4
print("nouvelle valeur de a dans test2",a,id(a))
return a
assert f(-10) == 4 |
benchmark_functions_edited/f12975.py | def f(severity):
if severity in ('Critical', 'High'):
return 3
elif severity in ('Medium', 'Low'):
return 2
return 0
assert f('High') == 3 |
benchmark_functions_edited/f13687.py | def f(list_a: list):
if not isinstance(list_a, list):
raise TypeError('The argument given is not of `list` type.')
return len(list_a)
assert f([1, 2, 3]) == 3 |
benchmark_functions_edited/f7694.py | def f(A, ind=0, summ=0):
# Stop if
if ind > len(A)-1:
return summ
return max(f(A, ind+2, summ+A[ind]), f(A, ind+1, summ))
assert f([1, 2, 3, 1]) == 4 |
benchmark_functions_edited/f6489.py | def f(a, b):
if b == 0:
return a
else:
return f(b, a % b)
assert f(20, 8) == 4 |
benchmark_functions_edited/f13586.py | def f(left, right, operation):
if operation == '+':
return left + right
if operation == '-':
return left - right
if operation == '*':
return left * right
if operation == '/':
return left / right
if operation == '**':
return left ** right
if operation == '^... |
benchmark_functions_edited/f7672.py | def f(nums):
if nums == []:
return 0
min_number = nums[0]
for i in range(len(nums) - 1):
if nums[i + 1] < nums[i]:
return nums[i + 1]
return min_number
assert f(
[1, 2, 3, 4, 5]) == 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.