file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f8620.py
|
def f(c, r, comp_period, n, adj='end'):
r /= comp_period
s = 1 if adj == 'end' else 0
coef = 1 / ((1 + r) ** s) * (1 - (1 / (1 + r)) ** n) / (1 - 1 / (1 + r))
res = c * coef
return res
assert f(1, 1, 1, 1, 'begin') == 1
|
benchmark_functions_edited/f5825.py
|
def f(fm, fmp, fmpp):
return (fm / fmp) - (fm / fmpp)
assert f(1, 1, 1) == 0
|
benchmark_functions_edited/f340.py
|
def f(time_s):
return int(time_s * 1e9)
assert f(0) == 0
|
benchmark_functions_edited/f12327.py
|
def f(senti_value):
label = None
if 0.0 <= senti_value <= 0.2:
label = 1
if 0.2 < senti_value <= 0.4:
label = 2
if 0.4 < senti_value <= 0.6:
label = 3
if 0.6 < senti_value <= 0.8:
label = 4
if 0.8 < senti_value <= 1.0:
label = 5
return label
assert f(0.0) == 1
|
benchmark_functions_edited/f1350.py
|
def f(beta, x):
return (x[0]-beta[0])**2 + (x[1]-beta[1])**2 -beta[2]**2
assert f( [1,1,1], [1,0]) == 0
|
benchmark_functions_edited/f234.py
|
def f(p, a, n):
return p * a * n
assert f(1, 2, 3) == 6
|
benchmark_functions_edited/f11302.py
|
def f(a: float, b: float) -> float:
if b == 0:
raise ZeroDivisionError("division by zero")
return a / b
assert f(6, 3) == 2
|
benchmark_functions_edited/f11941.py
|
def f(hospital, hospital_prefs_dict, matched_dict):
idxs = []
for res in hospital_prefs_dict[hospital]:
if res in matched_dict[hospital]:
idxs.append(hospital_prefs_dict[hospital].index(res))
return max(idxs)
assert f(
"H1",
{"H1": ["R1", "R2", "R3"], "H2": ["R1", "R2", "R3"], "H3": ["R1", "R2", "R3"],
"H4": ["R1", "R2", "R3"], "H5": ["R1", "R2", "R3"]},
{"H1": ["R1", "R2"], "H2": ["R1"], "H3": [], "H4": [], "H5": []}
) == 1
|
benchmark_functions_edited/f1912.py
|
def f(logits_dict, labels, stats):
del logits_dict
del labels
return stats["rpn_scores_entropy"]
assert f(None, None, {"rpn_scores_entropy": 2}) == 2
|
benchmark_functions_edited/f12903.py
|
def f(*args):
if len(args) == 1:
return args[0]
elif len(args) == 2:
return 60*args[0]+args[1]
elif len(args) ==3:
return 3600*args[0]+60*args[1]+args[2]
assert f(0, 0, 5) == 5
|
benchmark_functions_edited/f3318.py
|
def f(alist):
product = 1
for fact in alist:
product *= fact
return product
assert f([0, 1, 2, 3, 4]) == 0
|
benchmark_functions_edited/f1001.py
|
def f(pop):
return sum(p.is_infected() for p in pop)
assert f([]) == 0
|
benchmark_functions_edited/f4954.py
|
def f(nums, target):
num=[i for i in nums if i<target]
return len(num)
assert f(list(), 0) == 0
|
benchmark_functions_edited/f12716.py
|
def f(trueCoops, inferredCoops):
numCorrects = 0
if trueCoops['AC'] == inferredCoops['AC']:
numCorrects += 1
if trueCoops['AB'] == inferredCoops['AB']:
numCorrects += 1
if trueCoops['BC'] == inferredCoops['BC']:
numCorrects += 1
return numCorrects
assert f({'AC': 10, 'AB': 15, 'BC': 1},
{'AC': 10, 'AB': 15, 'BC': 1}) == 3
|
benchmark_functions_edited/f9593.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 > 0, 1, 0, 0, 0, 0) == 1
|
benchmark_functions_edited/f7273.py
|
def f(a, b):
c = a + b
return c
assert f(*(1, 2)) == 3
|
benchmark_functions_edited/f10119.py
|
def f(coord, spatial_res, spatial_sigfigs):
index = int(round((coord / spatial_res), spatial_sigfigs))
return index
assert f(2, 1, 4) == 2
|
benchmark_functions_edited/f1407.py
|
def f(quolity):
return ord(quolity) - 33
assert f(chr(35)) == 2
|
benchmark_functions_edited/f11696.py
|
def f(word, letter):
return word.lower().count(letter.lower())
assert f( "Hello World", "e" ) == 1
|
benchmark_functions_edited/f2155.py
|
def f(values):
return sum([x ** 2 for x in values])
assert f([0, 1]) == 1
|
benchmark_functions_edited/f2681.py
|
def f(some_dict, key):
return some_dict.get(key, key)
assert f(dict(), 1) == 1
|
benchmark_functions_edited/f6696.py
|
def f(att: str) -> int:
return int(att[1:4])
assert f('U001') == 1
|
benchmark_functions_edited/f5420.py
|
def f(c):
if c < 0:
return 0
elif (c >= 0 and c < 31):
return 1
elif (c >= 31 and c < 366):
return 2
else:
return 3
assert f(31) == 2
|
benchmark_functions_edited/f1608.py
|
def f(p1, p2):
return max(abs(p1[0]-p2[0]), abs(p1[1]-p2[1]))
assert f( (0, 0), (0, 0) ) == 0
|
benchmark_functions_edited/f14438.py
|
def f(field_names, field_name):
try:
return [str(i).lower() for i in field_names].index(str(field_name).lower())
# Make iter items lower case to get right time field index.
except:
print("Couldn't retrieve index for {0}, check arguments.".format(str(field_name)))
return None
assert f(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], 'e') == 4
|
benchmark_functions_edited/f11180.py
|
def f(val, default=None):
try:
return int(val)
except (ValueError, TypeError):
return default
assert f(1, 2) == 1
|
benchmark_functions_edited/f9460.py
|
def f(genome: str, pattern: str) -> int:
count = 0
for i in range(0, len(genome) + 1 - len(pattern)):
if genome[i: i + len(pattern)] == pattern:
count += 1
return count
assert f(
"GATATATGCATATACTT", "ATAT") == 3
|
benchmark_functions_edited/f625.py
|
def f(dollars):
cents = dollars * 100
return cents
assert f(0.00) == 0
|
benchmark_functions_edited/f11371.py
|
def f(x):
if x: return int(x)
return False
assert f(3) == 3
|
benchmark_functions_edited/f3555.py
|
def f(bytes_) -> int:
output = 0
for i in range(0, len(bytes_)):
output += bytes_[i] * (2**(8*i))
return output
assert f(bytes([0, 0, 0, 0])) == 0
|
benchmark_functions_edited/f4556.py
|
def f(d):
result = 0
for value in d.values():
if type(value) == int:
result += value
return result
assert f({}) == 0
|
benchmark_functions_edited/f6333.py
|
def f(ab, x):
return ab[0] + ab[1] * x
assert f([1, 2], 2) == 5
|
benchmark_functions_edited/f780.py
|
def f(x):
x_aft = x[0] + x[2]
return x_aft
assert f((0,1,2)) == 2
|
benchmark_functions_edited/f10989.py
|
def f(nums):
n=len(nums)
start=-1
end=-2
small=nums[n-1]
big=nums[0]
for i in range(1,n):
big = nums[i] if big < nums[i] else big
small = nums[n-1-i] if small > nums[n-1-i] else small
if nums[i] < big:
end=i
if nums[n-1-i] > small:
start=n-1-i
return end-start+1
assert f( [ 2, 1 ] ) == 2
|
benchmark_functions_edited/f11920.py
|
def f(diffeq, y0, t, h):
k1 = h*diffeq(y0, t) # dy/dt at t
k2 = h*diffeq(y0+0.5*k1, t + h/2.) # dy/dt at t+h/2
k3 = h*diffeq(y0+0.5*k2, t + h/2.) # dy/dt at t+h/2
k4 = h*diffeq(y0+k3, t + h) # dy/dt at t+h
return y0 + (k1+k4)/6.0 + (k2+k3)/3.0
assert f(lambda y,t: 0, 1, 0, 2) == 1
|
benchmark_functions_edited/f9727.py
|
def f(L, reverse=False):
digits = reversed(L) if reverse else L
n = 0
for i, d in enumerate(digits):
n += d * (10 ** i)
return n
assert f([0, 0, 0, 0, 0]) == 0
|
benchmark_functions_edited/f10010.py
|
def f(x,N,sign_ptr,args):
shift = args[0] # translate state by shift sites
period = N # periodicity/cyclicity of translation
xmax = args[1]
#
l = (shift+period)%period
x1 = (x >> (period - l))
x2 = ((x << l) & xmax)
#
return (x2 | x1)
assert f(1,4,1, [1,2]) == 2
|
benchmark_functions_edited/f9308.py
|
def f(lst):
if lst:
return lst[-1]
# we don't need to do anything else; functions
# return None by default
assert f([1, 2, 3, 4, 5, 6]) == 6
|
benchmark_functions_edited/f12727.py
|
def f(v):
n = len(v)
sorted_v = sorted(v)
midpoint = n//2
if n % 2 ==1:
#Se for impar, retorna o valor do meio
return sorted_v[midpoint]
else:
#Se for par, retorna a media dos valores do meio
lo = midpoint - 1
hi = midpoint
return (sorted_v[lo] + sorted_v[hi]) /2
assert f( [2, 2, 3, 4, 5] ) == 3
|
benchmark_functions_edited/f11322.py
|
def f(sig_info, error):
if 'description' not in sig_info.keys():
print('ERROR! description is a required field')
error += 1
else:
print('Check description: PASS')
return error
assert f(
{
'description': 'This is a sample description',
'foo': 'bar'
},
1
) == 1
|
benchmark_functions_edited/f1313.py
|
def f(names):
if len(names) == 1:
if names[0]=="END":
return 1
return 0
assert f( ["START", "JUNK"] ) == 0
|
benchmark_functions_edited/f1591.py
|
def f(string, char):
return string.count(char)
assert f(
"hello world", "d"
) == 1
|
benchmark_functions_edited/f7070.py
|
def f(list_of_faceoffs, player_id):
return len(list(
filter(lambda d: d['winner']['id'] == player_id, list_of_faceoffs)))
assert f(
[], 'foo') == 0
|
benchmark_functions_edited/f14367.py
|
def f(board, pieces, player):
player_num = 1 if player else -1
other_num = -player_num
pieces_player, pieces_opp = 0, 0
for y, x in pieces:
piece = board[y][x]
if piece == player_num:
pieces_player += 1
elif piece == other_num:
pieces_opp += 1
diff = pieces_player - pieces_opp
return 1 if diff > 0 else -1 if diff else 0
assert f(
[[1, 1, 1],
[1, 0, 1],
[1, 1, 1]],
{(1, 1), (2, 2)},
True) == 1
|
benchmark_functions_edited/f5933.py
|
def f(t, b, c, d):
t /= d/2
if t < 1:
return c / 2 * t * t + b
t -= 1
return -c / 2 * (t * (t - 2) - 1) + b
assert f(3, 1, 2, 3) == 3
|
benchmark_functions_edited/f10705.py
|
def f(a, b):
return (1 if a == b else 0)
assert f('a', 'b') == 0
|
benchmark_functions_edited/f14127.py
|
def f(L):
if (len(L) == 0):
return float('NaN')
sumVals = 0
for s in L:
sumVals += len(s)
meanVals = sumVals / len(L)
sumDevSquared = 0
for s in L:
sumDevSquared += (len(s) - meanVals)**2
variance = sumDevSquared / len(L)
stdDev = variance**(.5)
return stdDev
assert f(list('abcdefghijklmnopqrstuvwxyz' * 10000)) == 0
|
benchmark_functions_edited/f12788.py
|
def f(list_str, substring):
for i, s in enumerate(list_str):
if substring in s:
return i
return -1
assert f(
["dog"], "") == 0
|
benchmark_functions_edited/f12583.py
|
def f(input_data):
if isinstance(input_data, (list, tuple)):
return len(input_data[0])
return len(input_data)
assert f(((1, 2), [2, 3])) == 2
|
benchmark_functions_edited/f10955.py
|
def f(value, default_value):
try:
if value:
return value
except RuntimeError: # bool(torch.tensor) throws RuntimeError for lists with len > 1
return value
return default_value
assert f(1, None) == 1
|
benchmark_functions_edited/f12396.py
|
def f(string, params):
try:
return string % params
except TypeError: # Not all arguments converted ...
return string
assert f(1, (2,)) == 1
|
benchmark_functions_edited/f3064.py
|
def f(x, y):
return sum([abs(xx - yy) for xx, yy in zip(x, y)])
assert f( (0, 0), (1, 1) ) == 2
|
benchmark_functions_edited/f5633.py
|
def f(frame, key, default_value=-1):
try:
return frame[key]
except KeyError:
return default_value
assert f(range(3), 1, 2) == 1
|
benchmark_functions_edited/f10507.py
|
def f(state):
state = state.lower()
if "online" in state or "jobd" in state:
return 0
elif "rebuild" in state:
return 5
elif "failed" in state:
return 10
elif "unconfigured" in state:
return 15
else:
return 100
assert f(
"jobd"
) == 0
|
benchmark_functions_edited/f12703.py
|
def f(x, y, p):
p = float(p)
return y * p + (1 - p) * x
assert f(10, 0, 1.0) == 0
|
benchmark_functions_edited/f5443.py
|
def f(t):
m, s = t.split(':')
seconds = int(m) * 60 + float(s)
return seconds
assert f('0:00') == 0
|
benchmark_functions_edited/f6523.py
|
def f(n):
assert n > 0
a, b = 1, 1
for _i in range(n - 1):
a, b = b, a + b
return a
assert f(4) == 3
|
benchmark_functions_edited/f1254.py
|
def f(a, b, t):
assert a <= t <= b and a != b
return (t - a) / (b - a)
assert f(0, 10, 10) == 1
|
benchmark_functions_edited/f12451.py
|
def f(cenhisp: str):
assert cenhisp in [
"1",
"2",
], f"CEF CENHISP variable must be either 1 or 2, found {cenhisp}"
return int(cenhisp) - 1
assert f("1") == 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.