file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f2852.py | def f(state):
return int(state['flags']['quorum'])
assert f({'flags': {'quorum': 1}}) == 1 |
benchmark_functions_edited/f6036.py | def f(x1: float, y1: float, x2: float, y2: float) -> float:
return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
assert f(1, 1, 0, 1) == 1 |
benchmark_functions_edited/f10473.py | def f(arr: list) -> int:
arr = arr or [0]
max = arr[0]
for i in arr:
if i >= 0:
return 0
elif max <= i:
max = i
return max
assert f([-2, -8, -9, 10]) == 0 |
benchmark_functions_edited/f4811.py | def f(values,iteration):
value = values[iteration]
return value
assert f( [1, 2, 3], 0) == 1 |
benchmark_functions_edited/f6838.py | def f(initialize_job_info):
return initialize_job_info["SocInfo"]["op_debug_level"]
assert f(
{"SocInfo": {"op_debug_level": 5}}
) == 5 |
benchmark_functions_edited/f11372.py | def f(x, y):
distances = []
for i in range(len(x)):
_yx = abs(y[i][1] - x[i][0])
_xy = abs(x[i][1] - y[i][0])
distances = distances + [max(_yx, _xy)]
distance = max(distances)
return distance
assert f([(0, 0), (0, 1), (1, 0)], [(1, 1), (1, 2), (2, 2)]) == 2 |
benchmark_functions_edited/f2984.py | def f(peptide, motif):
motif_ct = peptide[-6:].count(motif)
return motif_ct
assert f(
'KASDFGASDFGH', 'ASDFGASDFGG'
) == 0 |
benchmark_functions_edited/f9663.py | def f(inputmatrix, inputmin, inputmax, outputmin, outputmax):
inputrange = inputmax - inputmin
outputrange = outputmax - outputmin
OutputMatrix = (inputmatrix-inputmin) * outputrange/inputrange + outputmin
return OutputMatrix
assert f(100, 0, 100, 0.5, 1) == 1 |
benchmark_functions_edited/f895.py | def f(v, w):
return sum(v_i * w_i
for v_i, w_i in zip(v, w))
assert f((0, 0), (1, 0)) == 0 |
benchmark_functions_edited/f6867.py | def f(a, b):
while True:
if b == 0:
return a
remainder = a % b
if remainder == 0:
return b
a, b = b, remainder
assert f(1, 1) == 1 |
benchmark_functions_edited/f2346.py | def f(depth):
return (4 ** (depth + 1) - 1) // 3
assert f(0) == 1 |
benchmark_functions_edited/f13186.py | def f(organisms):
for org in organisms:
if org.fitness == len(org.genome):
return 1
# if we got here we didn't do it
return 0
assert f([]) == 0 |
benchmark_functions_edited/f12731.py | def f(text, sen_lst = ['fuck', 'nigger', 'fucking', 'shit', 'sex', 'ass', 'asshole']):
lst = text.split()
if any(word in lst for word in sen_lst):
return 1
else:
return 0
assert f("") == 0 |
benchmark_functions_edited/f4334.py | def f(it, process_error_value, i_gain_value):
it = it + process_error_value
it = it * i_gain_value
return it
assert f(0, 0, 0) == 0 |
benchmark_functions_edited/f1683.py | def f(x, a = 1.0, b = 1.0, r = 1.0):
return (x[0] - a)**2 + (x[1] - b)**2 - r**2
assert f((1, 2), 2, 2, 1) == 0 |
benchmark_functions_edited/f12749.py | def f(string: str) -> int:
i: int = 0
count: int = 0
while i < len(string):
if string[i] == ",":
count += 1
else:
count = count
i += 1
return count
assert f("a,b,c") == 2 |
benchmark_functions_edited/f11751.py | def f(psm):
hit=0
hit_key=''
score={}
#print psm.keys()
for key in psm:
if "score" in key.lower():
hit=1
hit_key=key
if hit==1:
return psm[hit_key]
else:
return "-1"
assert f({"xcorrscore": 4}) == 4 |
benchmark_functions_edited/f1766.py | def f(key, size):
return sum([i * 256 + ord(v_) for i, v_ in enumerate(str(key))]) % size
assert f('', 10) == 0 |
benchmark_functions_edited/f6841.py | def f(filename, value, mode='w'):
f = open(filename, mode)
try:
return f.write(value)
finally:
f.close()
assert f('hello.txt', 'world') == 5 |
benchmark_functions_edited/f3187.py | def f(x, count=0):
if x / 10 >= 1:
count += f(x / 10, count) + 1
return count
assert f(8) == 0 |
benchmark_functions_edited/f14230.py | def f(a, n, strict = True):
b, x, y = n, 0, 1
while a != 0:
k = int(b // a)
b, a, x, y = a, b - k*a, y, x - k*y
if strict and b not in [-1, 1]:
raise ValueError("input not invertible")
return (b*x) % n
assert f(1, 5) == 1 |
benchmark_functions_edited/f2963.py | def f(x, min_val, max_val):
return min(max_val, max(min_val, x))
assert f(4, 2, 3) == 3 |
benchmark_functions_edited/f6275.py | def f(age, bv):
a, b, n = .4, .31, .55
return a*(bv - .4)**b * (age*1e3)**n
assert f(0, 0) == 0 |
benchmark_functions_edited/f7732.py | def f(optimizer):
if optimizer is not None:
for param_group in optimizer.param_groups:
if "lr" in param_group:
return param_group["lr"]
return 0
assert f(None) == 0 |
benchmark_functions_edited/f10620.py | def f(list_:list):
if len(list_) == 1:
return list_[0]
else:
return list_
assert f([0]) == 0 |
benchmark_functions_edited/f1489.py | def f(flow, n, spot):
return flow / ((1 + spot) ** n)
assert f(0, 1, 0.08) == 0 |
benchmark_functions_edited/f2238.py | def f(x):
if(x >= 0):
return 1
else:
return -1
assert f(1) == 1 |
benchmark_functions_edited/f13740.py | def f(y, m, d):
y -= m < 3
return (y + y // 4 - y // 100 + y // 400 + ord('-bed=pen+mad.'[m]) + d) % 7
assert f(2019, 2, 2) == 6 |
benchmark_functions_edited/f1209.py | def f(t, t0, p):
hp = 0.5 * p
return (t - t0 + hp) % p - hp
assert f(10, 10, 12) == 0 |
benchmark_functions_edited/f4625.py | def f(string):
if type(string) is not str:
raise ValueError("This is not a string")
return len(string)
assert f("abc") == 3 |
benchmark_functions_edited/f782.py | def f(n: int) -> int:
return n * ( n + 1) // 2
assert f(1) == 1 |
benchmark_functions_edited/f9127.py | def f(mel):
return 700*(10**(mel/2595.0)-1)
assert f(0) == 0 |
benchmark_functions_edited/f3375.py | def f(uri):
_, _, identity = uri.rpartition("/")
return int(identity)
assert f("example.com/1") == 1 |
benchmark_functions_edited/f11309.py | def f(list_name):
long_word = [0] * len(list_name) #Stores number of items in each sublist
i = 0
for column in list_name: #counts words in each sublist
l_word = 0
for word in column:
l_word += 1
long_word[i] = l_word
i += 1
return max(long_word)
assert ... |
benchmark_functions_edited/f2915.py | def f(n):
first = 0
second = 1
for i in range(2,n+1):
tmp = first+second
first=second
second = tmp
return second
assert f(4) == 3 |
benchmark_functions_edited/f1482.py | def f(string):
return int(string.replace(",", ""))
assert f("0000") == 0 |
benchmark_functions_edited/f11851.py | def f(xs, mu, cache={}):
try:
return cache[xs, mu]
except KeyError:
ds = [(x-mu)**2 for x in xs]
total = sum(ds)
cache[xs, mu] = total
return total
assert f(tuple([4]), 4) == 0 |
benchmark_functions_edited/f3908.py | def f(num):
count = ''
return len([count for bit in bin(num)[2:] if int(bit) == 1])
assert f(13) == 3 |
benchmark_functions_edited/f13609.py | def f(perc, layer_idx):
return int(perc - layer_idx * 0.02)
assert f(1, 2) == 0 |
benchmark_functions_edited/f560.py | def f(a, b, *others):
return min(a, b, *others)
assert f(0, 1, 2) == 0 |
benchmark_functions_edited/f13279.py | def f(nxs):
largest = None
first_time = True
for e in nxs:
if type(e) == type([]):
val = f(e)
else:
val = e
if first_time or val > largest:
largest = val
first_time = False
return largest
assert f([1, 2, 3]) == 3 |
benchmark_functions_edited/f13963.py | def f(results_list):
highest_score = 0.0
highest_index = 0
index = 0
for hit in results_list:
if hit.score > highest_score:
highest_score = hit.score
highest_index = index
index = index + 1
return highest_index
assert f([]) == 0 |
benchmark_functions_edited/f7586.py | def f(array_like, idx):
if hasattr(array_like, 'iloc'):
return array_like.iloc[idx]
else:
return array_like[idx]
assert f(list(range(10)), 5) == 5 |
benchmark_functions_edited/f192.py | def f(x, to):
return (x + to)%(2*to) - to
assert f(-10, 5) == 0 |
benchmark_functions_edited/f1689.py | def f(z, i):
return (z >> i) & 0x1
assert f(4, 1) == 0 |
benchmark_functions_edited/f13252.py | def f(school_type, N_classes):
teachers = {
'primary':N_classes + int(N_classes / 2),
'primary_dc':N_classes * 2,
'lower_secondary':int(N_classes * 2.5),
'lower_secondary_dc':N_classes * 3,
'upper_secondary':int(N_classes * 2.85),
'secondary':int(N_classes * 2.5),
'secondary_dc':int(N_classes * 2.5)
}
... |
benchmark_functions_edited/f11281.py | def f(M1, M2, f1, f2):
M = f1*M1 + f2*M2
return M
assert f(2, 2, 0.5, 0.5) == 2 |
benchmark_functions_edited/f13714.py | def f(func, *args, **kwargs):
if "maxattempt" in kwargs:
maxattempt = kwargs.pop("maxattempt")
else:
maxattempt = 100
test = 1
count = 1
while test:
try:
func(*args, **kwargs)
test = 0
except (ValueError, IOError):
if count <= maxa... |
benchmark_functions_edited/f8071.py | def f(ll):
try:
return sum([ss**2 for ss in ll])**0.5
except TypeError:
pass # ll is not iterable
return ll
assert f([3,4.0]) == 5 |
benchmark_functions_edited/f14460.py | def f(nfactor: int, moles: float, volume: float) -> float:
return round(float(moles / volume) * nfactor)
assert f(4, 11.4, 5.7) == 8 |
benchmark_functions_edited/f12730.py | def f(seq1, seq2):
set1, set2 = set(seq1), set(seq2)
if float(len(set1 | set2)) == 0.0:
return 0.0
return len(set1 & set2) / float(len(set1 | set2))
assert f(set([1, 2, 3]), set([1, 2, 3])) == 1 |
benchmark_functions_edited/f13562.py | def f(bits: int) -> int:
# probably bit manipulation can be faster, but this should be ok as well
result = 1
while result < bits:
result = result * 2
return result
assert f(5) == 8 |
benchmark_functions_edited/f4694.py | def f(t, i):
return (t >> i) % 2
assert f(16,4) == 1 |
benchmark_functions_edited/f2394.py | def f(colval):
if colval > 255:
return 255
elif colval < 0:
return 0
else:
return colval
assert f(-1000) == 0 |
benchmark_functions_edited/f2307.py | def f(pos_th):
return pos_th / (1 + pos_th)
assert f(0) == 0 |
benchmark_functions_edited/f8351.py | def f(numbers):
return sum(min(x) for x in numbers)
assert f( [] ) == 0 |
benchmark_functions_edited/f7978.py | def f(sun_altitude):
day = 0
if sun_altitude > -6:
day = 1
return day
assert f(-6) == 0 |
benchmark_functions_edited/f10750.py | def f(arr, target):
left = 0
right = len(arr)
while left < right:
mid = (left + right) // 2
if arr[mid] > target:
right = mid
else:
left = mid + 1
return left
assert f([1, 2, 3, 3, 4, 5], 5) == 6 |
benchmark_functions_edited/f8501.py | def f(action):
forward, h_angle, v_angle = action[1]
cost = 0
if forward != 0:
cost += 1
if h_angle != 0:
cost += 1
if v_angle != 0:
cost += 1
return cost
assert f( ('turn', (1, 0, 0)) ) == 1 |
benchmark_functions_edited/f9561.py | def f(lambda_0, lambda_, eps_c, Delta, norm_zeta2, nu):
lmd = lambda_ / lambda_0
Q_lambda = (lmd * eps_c + Delta * (1. - lmd) +
0.5 * nu * norm_zeta2 * (1. - lmd) ** 2)
return Q_lambda
assert f(1, 1, 0, 0, 0, 0) == 0 |
benchmark_functions_edited/f13168.py | def f(func, *args):
for arg in args:
if arg is not None and func(arg):
return arg
return None
assert f(lambda x: x%3 == 0, *range(1,7)) == 3 |
benchmark_functions_edited/f6300.py | def f(values):
taken = skipped = 0
for val in values:
taken, skipped = skipped + val, max(taken, skipped)
return max(taken, skipped)
assert f( [0, 0, 0, 0] ) == 0 |
benchmark_functions_edited/f8722.py | def f(worker_id):
if "gw" in worker_id:
return int(worker_id.replace("gw", ""))
elif "master" == worker_id:
return 0
raise RuntimeError("Can not get rank from worker_id={}".format(worker_id))
assert f(**{"worker_id": "gw5"}) == 5 |
benchmark_functions_edited/f688.py | def f(text):
text = text.decode('utf-8')
return len(text)
assert f(b'abcde') == 5 |
benchmark_functions_edited/f14410.py | def f(element, *keys):
if not isinstance(element, dict):
raise AttributeError('keys_exists() expects dict as first argument.')
if len(keys) == 0:
raise AttributeError('keys_exists() expects at least two arguments, one given.')
_element = element
for key in keys:
try:
... |
benchmark_functions_edited/f13720.py | def f(nh, nv, row, col, spin):
return 2 * nh * row + col + nh * spin
assert f(3, 2, 1, 0, 0) == 6 |
benchmark_functions_edited/f4767.py | def f(bytes):
factor = 1024 ** 3
value_gb = bytes / factor
return value_gb
assert f(1073741824) == 1 |
benchmark_functions_edited/f6609.py | def f(a: int, p: int) -> int:
return pow(a, (p - 1) // 2, p)
assert f(13, 2) == 1 |
benchmark_functions_edited/f10031.py | def f(false_neg, true_pos):
try:
fnr = false_neg / float(true_pos + false_neg)
return round(fnr, 3)
except BaseException:
return None
assert f(0, 1) == 0 |
benchmark_functions_edited/f6959.py | def f(target_character, long_string):
count = 0
for character in long_string:
if target_character == character:
count += 1
return count
assert f(
'z',
'hello world'
) == 0 |
benchmark_functions_edited/f2456.py | def f(m1, L11, d_p2p, keff, Cp):
return m1 * Cp * L11 / 3 / d_p2p / keff
assert f(0, 1000, 1000, 1000, 1) == 0 |
benchmark_functions_edited/f6845.py | def f(pts):
if len(pts) <= 1:
return 0
return sum(abs(a-b) for a,b in pts)
assert f( [0] ) == 0 |
benchmark_functions_edited/f3704.py | def f(a,b):
while b:
a,b=b,a%b
return a
assert f(1, 1) == 1 |
benchmark_functions_edited/f7043.py | def f(arr):
smallest = arr[0]
smallest_i = 0
for i, val in enumerate(arr):
if val < smallest:
smallest = val
smallest_i = i
return smallest_i
assert f([0, 0, 0, 0, 0]) == 0 |
benchmark_functions_edited/f7317.py | def f(numbers):
m1, m2 = float('inf'), float('inf')
for x in numbers:
if x <= m1:
m1, m2 = x, m1
elif x < m2:
m2 = x
return m2
assert f( [1, 2, 3] ) == 2 |
benchmark_functions_edited/f2632.py | def f(i):
return (i - 1) // 2 if i > 0 else None
assert f(13) == 6 |
benchmark_functions_edited/f4560.py | def f(bytes_val):
BYTES_IN_GB = 1024 * 1024 * 1024
gbytes = bytes_val / BYTES_IN_GB
return round(gbytes, 2)
assert f(1024 * 1024) == 0 |
benchmark_functions_edited/f13173.py | def f(kernel_size, n_layers, stride, dilations=[]):
if len(dilations) == 0:
dilations = [1 for n in range(n_layers)]
receptive_field = kernel_size
for n in range(n_layers):
receptive_field += ((kernel_size-1)*stride)*dilations[n]
return receptive_field
assert f(1, 1, 1) == 1 |
benchmark_functions_edited/f10960.py | def f(var):
if type(var) == list:
return len(var)
elif type(var) == float:
return 1
else:
return len(var)
assert f([1]) == 1 |
benchmark_functions_edited/f4998.py | def f(seq: str) -> float:
if not seq:
return 0
gc = len(list(filter(lambda base: base in 'CG', seq.upper())))
return (gc * 100) / len(seq)
assert f('') == 0 |
benchmark_functions_edited/f3346.py | def f(key, left, right):
if left > right:
return left + 1
else:
return right + 1
assert f(1, 2, 1) == 3 |
benchmark_functions_edited/f9192.py | def f(lists, target):
counts = 0
for ele in lists:
if ele == target:
counts += 1
return counts
assert f(
[],
'',
) == 0 |
benchmark_functions_edited/f6851.py | def f(value_1,value_2,uncertainty,expansion_factor=1):
return (value_2-value_1)/(uncertainty*expansion_factor)
assert f(2, 2, 1) == 0 |
benchmark_functions_edited/f11889.py | def f(input):
try:
return int(input)
except (TypeError, ValueError):
raise ValueError("Unable to convert {0!r} to an integer value.".format(input))
assert f(1) == 1 |
benchmark_functions_edited/f5844.py | def f(t, base, t1, slope):
return base + ((t-t1)*slope if t>=t1 else 0)
assert f(2, 0, 2, 1) == 0 |
benchmark_functions_edited/f3080.py | def f(a, b):
if a != b:
return 1
else:
return 0
assert f(0,0) == 0 |
benchmark_functions_edited/f6826.py | def f(List, idx):
if idx < 0:
return List[0]
elif idx < len(List):
return List[idx]
else:
return List[-1]
assert f(list(range(100)), 0) == 0 |
benchmark_functions_edited/f640.py | def f(number):
return -1 if number < 0 else (1 if number else 0)
assert f(0) == 0 |
benchmark_functions_edited/f1080.py | def f(number):
return abs(number) * -1
assert f(0) == 0 |
benchmark_functions_edited/f2075.py | def f(x, n):
if n == 0:
return 1
else:
return x * f(x, n-1)
assert f(0, 3) == 0 |
benchmark_functions_edited/f12446.py | def f(n, offset=0):
m = [int(d) for d in reversed(str(n))]
result = sum(m) + sum(d + (d >= 5) for d in m[::2])
checksum = ((-result % 10) + offset) % 10
return checksum
assert f(631038205433269, 4) == 5 |
benchmark_functions_edited/f3688.py | def f(x, ndim):
return (x if ndim == 0 else
f(x[0], ndim - 1))
assert f([0, [0]], 1) == 0 |
benchmark_functions_edited/f12850.py | def f(a_float):
decimal_separator = '.'
a_str = str(a_float).replace(decimal_separator, '')
a_integer = int(a_str)
# print(type(a_integer))
# <class 'int'>
return a_integer
assert f(0.0) == 0 |
benchmark_functions_edited/f7697.py | def f(*args):
columns = [c for c in args]
requirement = 0.02
for column in columns:
if column > requirement:
return 1
if column < -requirement:
return -1
return 0
assert f(1,1,1,1,1) == 1 |
benchmark_functions_edited/f2668.py | def f(s, size):
h = 0
for c in s:
h = 31*h + ord(c)
return h % size
assert f("Hello, world!", 10) == 1 |
benchmark_functions_edited/f7786.py | def f(x, y, xmin, xmax, ymin, ymax):
center = (
.75*xmin + .25*xmax,
.50*ymin + .50*ymax
)
radius = 0.1
height = 0.5
return 1 + height * ((x-center[0])**2+(y-center[1])**2 < radius**2)
assert f(0.5, 0.5, 0, 1, 0, 1) == 1 |
benchmark_functions_edited/f3386.py | def f(p, x):
return x + p[0]
assert f((1,), 4) == 5 |
benchmark_functions_edited/f7821.py | def f(expression):
if expression:
try:
return eval(expression)
except:
pass
return expression
assert f("1 == 1") == 1 == 1 |
benchmark_functions_edited/f6184.py | def f(n: int, m: int) -> int:
if n == 0 or m == 0:
return 0
if n == 1 or m == 1:
return 1
return f(n - 1, m) + f(n, m - 1)
assert f(0, 0) == 0 |
benchmark_functions_edited/f5829.py | def f(color, overlay):
if color < 33:
return overlay - 100
elif color > 233:
return overlay + 100
else:
return overlay - 133 + color
assert f(33, 100) == 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.