file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f2924.py | def f(new, old, field):
if field in old:
return new[field] - old[field]
else:
return new[field]
assert f(
{'a': 1, 'b': 2, 'c': 3},
{'a': 1, 'b': 2, 'c': 2},
'a',
) == 0 |
benchmark_functions_edited/f2859.py | def f(n):
counter = 0
while n:
counter += n & 1
n >>= 1
return counter
assert f(0b0) == 0 |
benchmark_functions_edited/f14305.py | def f(*values):
# Cannot simply return sum([v for v in values if v is not None])
# because it does 0 + v which will not work for v of type, e.g., VectorCost
current = 0
for v in values:
if v is not None:
current = v + current
return current
assert f(1, 2, 3) == 6 |
benchmark_functions_edited/f7937.py | def f(x):
return (x & 0x0f) + ((x & 0x30) << 6)
assert f(8) == 8 |
benchmark_functions_edited/f14185.py | def f(num_proc, a_seq):
return num_proc - a_seq * (num_proc-1)
assert f(2, 0) == 2 |
benchmark_functions_edited/f10292.py | def f(x, default=0):
try:
return int(x)
except ValueError:
return default
assert f('0.0') == 0 |
benchmark_functions_edited/f8086.py | def f(choice):
# If choice is 'rock', give me 0
# If choice is 'paper', give me 1
# If choice is 'scissors', give me 2
random_dict = {'rock': 0, 'paper': 1, 'scissors': 2}
return random_dict[choice]
assert f('scissors') == 2 |
benchmark_functions_edited/f11984.py | def f(N, n):
if n <= 1:
return n
return N*f(n-1, N)+f(n-2, N)
assert f(0, 0) == 0 |
benchmark_functions_edited/f1712.py | def f(dim_data):
return len(dim_data.get('indices', None))
assert f(
{ 'type': 'unstructured', 'data': [0,1,2,3,4,5], 'indices': [1, 3, 5] }
) == 3 |
benchmark_functions_edited/f32.py | def f(a, b):
a %= b
return a
assert f(1, 4) == 1 |
benchmark_functions_edited/f3289.py | def f(uid_set):
uids = set(uid_set)
uid = 0
while uid in uids:
uid = uid + 1
return uid
assert f({1,2,3,4,5,6,7,8}) == 0 |
benchmark_functions_edited/f2826.py | def f(val, n):
return (val % 0x100000000) >> n
assert f(1, 26) == 0 |
benchmark_functions_edited/f1324.py | def f(message):
return (len(message) // 64) + 1
assert f(b'12345678901234567890123456789012') == 1 |
benchmark_functions_edited/f6778.py | def f(obj):
try:
return obj.id
except AttributeError:
return obj
assert f(5) == 5 |
benchmark_functions_edited/f3751.py | def f(ts, timeframe_int):
return((ts // timeframe_int) * timeframe_int)
assert f(0, 3600) == 0 |
benchmark_functions_edited/f12787.py | def f(value, minx, maxx):
return max(minx, min(maxx, value))
assert f(5, 4, 7) == 5 |
benchmark_functions_edited/f6003.py | def f(n):
if n<0:
return 0
else:
return 1
assert f(-100) == 0 |
benchmark_functions_edited/f4789.py | def f(msgid, msgstr, s, line_warns):
r = 0
if msgid.count(s) != msgstr.count(s):
line_warns.append('cnt(%s)' % (s))
r += 1
return r
assert f(u'foo', u'bar foo', u'bar', []) == 1 |
benchmark_functions_edited/f4250.py | def f(x, max=3): # --DC
for n in range(max, 0, -1):
if round(x, n) != round(x, n-1):
return n
return 0
assert f(1.12345678901234567890, 2) == 2 |
benchmark_functions_edited/f104.py | def f(x):
return sum(x)**2
assert f([1]) == 1 |
benchmark_functions_edited/f6068.py | def f(root):
if root is None:
return 0
return 1 + max(f(root.l), f(root.r))
assert f(None) == 0 |
benchmark_functions_edited/f13343.py | def angle_dis (a1, a2, factor=1.0) :
d = ((a1 - a2 + 180.0) % 360.0 - 180.0) * factor
return d
assert f(10,10) == 0 |
benchmark_functions_edited/f12333.py | def f(value):
guess_len = len(str(int(value)))
return guess_len if guess_len % 2 != 0 else (guess_len - 1)
assert f(3) == 1 |
benchmark_functions_edited/f373.py | def f( argv ):
# return success
return 0
assert f( [] ) == 0 |
benchmark_functions_edited/f9563.py | def f(f, t, y, dt):
return y + dt * f(t, y)
assert f(lambda t, y: t * y, 0, 1, 1) == 1 |
benchmark_functions_edited/f8362.py | def f(obj,tokenizer):
if isinstance(obj, str):
return tokenizer.convert_tokens_to_ids(tokenizer.tokenize(obj))
elif isinstance(obj, int):
return obj
return list(f(o,tokenizer) for o in obj)
assert f(1,None) == 1 |
benchmark_functions_edited/f13984.py | def f(sz, charge, nsingle):
szmax = min(charge, nsingle-charge)
return int((szmax+sz)/2)
assert f(1, 1, 4) == 1 |
benchmark_functions_edited/f5640.py | def f(Q):
n = len(Q)
while Q:
if Q[0] in ' \t\n':
Q.popleft()
else:
break
return n - len(Q)
assert f('abc') == 0 |
benchmark_functions_edited/f109.py | def f(x, a, b):
return a*x**b
assert f(2, 0, 3) == 0 |
benchmark_functions_edited/f10429.py | def f(method):
try:
# Python 2
return method.im_func
except AttributeError:
try:
# Python 3
return method.__func__
except AttributeError:
# Not a method.
return method
assert f(1) == 1 |
benchmark_functions_edited/f7561.py | def f(values):
max_value = None
for v in values:
if max_value is None or v > max_value:
max_value = v
return max_value
assert f([1, 2, 3]) == 3 |
benchmark_functions_edited/f2420.py | def f(x, y, param_0):
return x * y * param_0
assert f(0, 0, 5) == 0 |
benchmark_functions_edited/f14441.py | def f(ir, t):
return (1+ir)**t
assert f(0, 0) == 1 |
benchmark_functions_edited/f8549.py | def f(subsystems):
number = 0
for system in subsystems.values():
number = number + f(system)
return number + len(subsystems.keys())
assert f({"a": {"b": dict()}, "c": {"d": {"e": dict()}}, "f": dict()}) == 6 |
benchmark_functions_edited/f10306.py | def f(number):
special_non_primes = [0,1,2]
if number in special_non_primes[:2]:
return 2
elif number == special_non_primes[-1]:
return 3
return all([number % i for i in range(2, number)])
assert f(1) == 2 |
benchmark_functions_edited/f6046.py | def f(byteData):
CRC = 0
for b in byteData:
CRC = CRC + b
CRC += 1
CRC &= 0xFF
return CRC
assert f(b'\x01') == 2 |
benchmark_functions_edited/f12572.py | def f(l, index, default):
try:
return l[index]
except IndexError:
return default
assert f(list(), -1, 7) == 7 |
benchmark_functions_edited/f6380.py | def f(example):
if '[PAD]' not in example['tokens']:
return len(example['tokens'])
return example['tokens'].index('[PAD]')
assert f(
{'tokens': ['[CLS]', 'A', 'Ġcat', 'Ġjumps', 'Ġover', 'Ġthe', '[SEP]']}) == 7 |
benchmark_functions_edited/f3754.py | def f(n: int) -> int:
a = 0
b = 1
for i in range(n):
a, b = b, a + b
return a
assert f(5) == 5 |
benchmark_functions_edited/f905.py | def f(threshold, dim):
out = int(dim * threshold)
return out
assert f(0.75, 5) == 3 |
benchmark_functions_edited/f9772.py | def f(root, keys):
item = root
for key in keys:
item = item[key]
return item
assert f(
{'a': [0, 1, 2, 3]},
['a', 1]
) == 1 |
benchmark_functions_edited/f11366.py | def f(number: int) -> int:
if number < 1:
raise ValueError(f"{number} is not a natural number")
_n = number
count = 0
while _n != 1:
count += 1
if _n % 2 == 0:
_n /= 2
elif _n != 1:
_n = _n*3 + 1
return count
assert f(2) == 1 |
benchmark_functions_edited/f11579.py | def f(image5d):
return 1 if image5d is None or image5d.ndim <= 4 else image5d.shape[4]
assert f(None) == 1 |
benchmark_functions_edited/f1875.py | def f(x: int) -> int:
return 1 << (x-1).bit_length()
assert f(2) == 2 |
benchmark_functions_edited/f7498.py | def f(strand_a, strand_b):
if len(strand_a) != len(strand_b):
raise ValueError("Strand length doesn't match")
return sum(1 for a,b in zip(strand_a, strand_b) if a != b)
assert f("GAGCCTACTAACGGGAT", "CATCGTAATGACGGCCT") == 7 |
benchmark_functions_edited/f2024.py | def f(fraction):
return max(0.01, min(1, 1 - fraction))
assert f(0) == 1 |
benchmark_functions_edited/f4104.py | def f(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return f(n - 1) + f(n - 2)
assert f(2) == 1 |
benchmark_functions_edited/f7169.py | def f(n):
result = 1
for i in range(1, n+1):
result *= (i*(2*i-1))
for i in range(1, n+1):
result /= i
return result
assert f(1) == 1 |
benchmark_functions_edited/f9320.py | def f(x, amp, slope):
return amp*(x**slope)
assert f(2, 1, 3) == 8 |
benchmark_functions_edited/f2492.py | def f(d):
if isinstance(d, dict):
return 1 + (max(map(depth, d.values())) if d else 0)
return 0
assert f({1: 2, 2: 3}) == 1 |
benchmark_functions_edited/f13617.py | def f(n, max_):
if n % 10 > max_: # if last ones digit > max_, replace max_
max_ = n % 10
if n//10 == 0: # base case, when n is ones digit, return max_
return max_
else: # recursion, 12345//10 = 1234
return f(n//10, max_)
assert f(123456, 0) == 6 |
benchmark_functions_edited/f9785.py | def f(n,k):
# from https://stackoverflow.com/questions/15978781/how-to-find-integer-nth-roots/15979957:
# Newton's method to find kth root of n
u, s = n, n+1
while u < s:
s = u
t = (k-1) * s + n // pow(s, k-1)
u = t // k
return s
assert f(9,2) == 3 |
benchmark_functions_edited/f1655.py | def f(line):
return len(line) - len(line.lstrip())
assert f(' Hello, world!') == 4 |
benchmark_functions_edited/f13002.py | def f(wh_data, key):
dogma_attr = wh_data.get('dogma_attributes')
return next(element for element in dogma_attr if element.get('attribute_id') == key).get('value')
assert f(
{'dogma_attributes': [
{'attribute_id': 1002, 'value': 2}
]},
1002
) == 2 |
benchmark_functions_edited/f6710.py | def f(base, exp):
res = 1 # <---- remember starting point
while exp > 0:
res *= base
exp -= 1
return res
assert f(-2, 0) == 1 |
benchmark_functions_edited/f9466.py | def f(terms1, terms2, sem_sim):
sims = []
for t1 in terms1:
for t2 in terms2:
sim = sem_sim(t1, t2)
if sim is not None:
sims.append(sim)
return round(max(sims), 3)
assert f(
[1, 2, 3, 4],
[1, 2, 3, 4],
lambda x, y: 4 if x == y else None
) == 4 |
benchmark_functions_edited/f13191.py | def f(space):
if space == 'feature':
return 1
if space == 'sample':
return 0
assert f('feature') == 1 |
benchmark_functions_edited/f5967.py | def f(lis):
return next((index for index, val in enumerate(lis) if val < 0), None)
assert f(list(range(-2, 3))) == 0 |
benchmark_functions_edited/f4608.py | def f(number : int) -> int :
factorial = 1
for i in range(1,number+1):
factorial *= i
return factorial
assert f(2) == 2 |
benchmark_functions_edited/f8303.py | def f(n):
if n < 0:
n -= 2*n
if (n // 10) == 0:
return n % 10
else:
one = n % 10
a = f(n//10)
if a > one:
return a
else:
return one
assert f(12345) == 5 |
benchmark_functions_edited/f0.py | def f(x):
return x*x+1
assert f(0) == 1 |
benchmark_functions_edited/f3133.py | def f(sack):
return 1 if sack == 1 else sack ** 2 // 2
assert f(3) == 4 |
benchmark_functions_edited/f4260.py | def f(paddle):
midpoint = int(paddle[0][1] + paddle[1][1]) / 2
return midpoint
assert f(
[(1, 2), (3, 4)]
) == 3 |
benchmark_functions_edited/f372.py | def f(x, y, a):
dy = x + a * y
return dy
assert f(0, 1, 1) == 1 |
benchmark_functions_edited/f2473.py | def f(val):
if val is None:
return val
else:
return int(val)
assert f(False) == 0 |
benchmark_functions_edited/f5137.py | def f(lecture_time, progress):
time_left = lecture_time * (100 - progress) * 6 // 10
return time_left
assert f(25, 100) == 0 |
benchmark_functions_edited/f132.py | def f(f):
return len(str(f).split('.')[1].rstrip('0'))
assert f(0.11) == 2 |
benchmark_functions_edited/f2222.py | def f(numbers):
result = 1
for number in numbers:
result *= number
return result
assert f([2, 2]) == 4 |
benchmark_functions_edited/f10187.py | def f(value, low, high):
return max(low, min(value, high))
assert f(-1, 2, 8) == 2 |
benchmark_functions_edited/f10731.py | def f(t):
return 0 #1.1 * mort_rate_mth(t)
assert f(7) == 0 |
benchmark_functions_edited/f3044.py | def f(conductors):
return sum(c.num_cmd_submissions for c in conductors)
assert f([]) == 0 |
benchmark_functions_edited/f6952.py | def f(string='covered'):
print(string)
return 0
assert f(None) == 0 |
benchmark_functions_edited/f2499.py | def f(a_list):
return float(sum(a_list)) / len(a_list)
assert f([1]) == 1 |
benchmark_functions_edited/f3443.py | def f(row: int, col: int) -> int:
return (row + col - 2) * (row + col - 1) // 2 + col - 1
assert f(1, 4) == 9 |
benchmark_functions_edited/f2839.py | def f(base_short,base_long,height):
return ((base_short+base_long)/2)*height
assert f(1,1,1) == 1 |
benchmark_functions_edited/f283.py | def f(x):
return 1 if x > 0 else 0
assert f(100000.0) == 1 |
benchmark_functions_edited/f10414.py | def f(text):
plain_text = text
while chr(27) in plain_text:
pos = plain_text.find(chr(27))
plain_text = plain_text[:pos] + plain_text[pos + 5:]
return len(plain_text)
assert f('') == 0 |
benchmark_functions_edited/f8503.py | def f(x,y):
intersection_cardinality = len(set.intersection(*[set(x), set(y)]))
union_cardinality = len(set.union(*[set(x), set(y)]))
return intersection_cardinality/float(union_cardinality)
assert f(set([1]), set([1])) == 1 |
benchmark_functions_edited/f1056.py | def f(items: list):
length = len(items) // 2
return items[length]
assert f([4, 5, 6]) == 5 |
benchmark_functions_edited/f8111.py | def f(pair):
numberofdigits = 4
if pair:
base = pair.split("_")[0]
if base in ("BTC", "BNB", "ETH"):
numberofdigits = 8
return numberofdigits
assert f("BNB_USD") == 8 |
benchmark_functions_edited/f7645.py | def f(n, minn, maxn):
return max(min(maxn, n), minn)
assert f(4, 5, 10) == 5 |
benchmark_functions_edited/f571.py | def f(book):
return sum(book.values())
assert f({'a': 1, 'b': 2, 'c': 3}) == 6 |
benchmark_functions_edited/f6197.py | def f(string, keyspace_chars):
output = 0
for char in string:
output = output * len(keyspace_chars) + keyspace_chars.index(char)
return output
assert f("B", "AB") == 1 |
benchmark_functions_edited/f2341.py | def f(x, resource):
return resource - x[1]
assert f( [1, 50], 50 ) == 0 |
benchmark_functions_edited/f8856.py | def f(target, current, Kp=1.0):
return Kp * (target - current)
assert f(5, 3) == 2 |
benchmark_functions_edited/f591.py | def f(c: int) -> float:
return 1 / 3 * (c + 1) * (c - 1)
assert f(2) == 1 |
benchmark_functions_edited/f2955.py | def f(bytes, alignment):
return (int(bytes) + int(alignment) - 1) / int(alignment) * int(alignment)
assert f(3, -2) == 0 |
benchmark_functions_edited/f9417.py | def f(string, letter, start = 0):
index = start
while index < len(string):
if string[index] == letter:
return index
index = index + 1
return -1
assert f( "aaaa", "a", 3 ) == 3 |
benchmark_functions_edited/f7004.py | def f(floor1, floor2):
return abs(int(floor1) - int(floor2))
assert f(0, 0) == 0 |
benchmark_functions_edited/f9004.py | def f(value, key_chain, default=None):
for key in key_chain:
if value is None:
return default
value = value.get(key)
return value
assert f(None, ['x'], 1) == 1 |
benchmark_functions_edited/f10606.py | def f(list_):
length_elements = [len(element) for element in list_]
return max(length_elements)
assert f(["abc", "abc"]) == 3 |
benchmark_functions_edited/f4146.py | def f(c,n):
result = 0
for x in range(n):
result += c
return result
assert f(1,0) == 0 |
benchmark_functions_edited/f3883.py | def f(item, vec):
for i, v in enumerate(vec):
if item == v:
return i
return -1
assert f(3, [3, 3, 1, 2, 3]) == 0 |
benchmark_functions_edited/f1856.py | def f(x, a, b):
return a/x + b
assert f(2, 2, 4) == 5 |
benchmark_functions_edited/f11326.py | def f(x):
try:
return x._f()
except AttributeError:
return abs(x)**2
assert f(1j) == 1 |
benchmark_functions_edited/f11564.py | def f(n: int, choices: set) -> int:
cache = [0] * (n + 1)
cache[0] = 1
for i in range(1, n + 1):
cache[i] = sum(cache[i - v] for v in choices if v <= i)
return cache[n]
assert f(3, {1, 2, 3, 4, 5}) == 4 |
benchmark_functions_edited/f4928.py | def f(name):
h = 0
for c in name:
h = (h << 4) + ord(c)
g = h & 0xf0000000
h ^= g
h ^= g >> 24
return h & 0xffffffff
assert f(b"") == 0 |
benchmark_functions_edited/f811.py | def f(some_value):
return int(round(some_value))
assert f(5.0) == 5 |
benchmark_functions_edited/f10692.py | def f(pixel):
luminance = 0.299 * pixel[0] + 0.587 * pixel[1] + 0.114 * pixel[2]
luminance /= 255
return round(luminance, 2)
assert f(
(0, 0, 0)
) == 0 |
benchmark_functions_edited/f5860.py | def f(a):
i = 0
while a > 1:
a = a / 2
i += 1
return 2 ** (i - 1)
assert f(7) == 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.