uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
98201890dc1f15a81157a2a7
train
class
class IsAdminOrReadOnlyTests(TestCase): def setUp(self): self.user = get_user_model().objects.create_user( email="test@gmail.com", password="test1234", name="Test User" ) self.user_superuser = get_user_model().objects.create_superuser( email=...
class IsAdminOrReadOnlyTests(TestCase):
def setUp(self): self.user = get_user_model().objects.create_user( email="test@gmail.com", password="test1234", name="Test User" ) self.user_superuser = get_user_model().objects.create_superuser( email="superuser@gmail.com", passwo...
import MyProfile from core.models_project import ProjectModel, IssueModel CHARITIES_URL = reverse("charity:charities-list") PROJECTS_URL = reverse("projects:projects-list") TEAM_REQUIREMENTS_URL = reverse("projects:team-requirements", kwargs={'pk': 1}) ISSUE_FIXED_URL = reverse("projects:issue-fixed", kwargs={'id': 1...
109
109
364
10
99
tpriyanshu90/Project-Dashboard-with-Django
app/core/tests/test_permissions.py
Python
IsAdminOrReadOnlyTests
IsAdminOrReadOnlyTests
18
60
18
19
231a410e546517a3780307745d59d67ecafbaf5a
bigcode/the-stack
train
3d2317efedb2693092d00d7c
train
function
@login_required(login_url='/login/') def index(request): template = loader.get_template('consumers.html') context = { 'project_version': PROJECT_VERSION, 'project_name': PROJECT_NAME, 'zone_name': get_zone(request), 'current_period': get_current_month_fr(), 'water_outlets...
@login_required(login_url='/login/') def index(request):
template = loader.get_template('consumers.html') context = { 'project_version': PROJECT_VERSION, 'project_name': PROJECT_NAME, 'zone_name': get_zone(request), 'current_period': get_current_month_fr(), 'water_outlets': get_outlets(request), 'consumer_groups': get_a...
from django.contrib.auth.decorators import login_required from django.http import HttpResponse from django.template import loader from haitiwater.settings import PROJECT_VERSION, PROJECT_NAME from ..utils.get_data import * @login_required(login_url='/login/') def index(request):
52
64
133
11
41
exavince/HaitiWater
code/haitiwater/apps/consumers/views.py
Python
index
index
9
22
9
10
92f8634fb6e0fd79e41a1f8457fb0939993b9938
bigcode/the-stack
train
ca22ec2ed13daabe4bd21cd8
train
function
def test_serial_tasks_reading_same_signal(shutdown_only): ray.init(num_cpus=2) @ray.remote def send_signal(value): signal.send(UserSignal(value)) a = send_signal.remote(0) @ray.remote def f(sources): return ray.experimental.signal.receive(sources, timeout=1) result_list =...
def test_serial_tasks_reading_same_signal(shutdown_only):
ray.init(num_cpus=2) @ray.remote def send_signal(value): signal.send(UserSignal(value)) a = send_signal.remote(0) @ray.remote def f(sources): return ray.experimental.signal.receive(sources, timeout=1) result_list = ray.get(f.remote([a])) assert len(result_list) == 1 ...
results = ray.experimental.signal.receive([x, y]) assert ((x == results[0][0] and y == results[1][0]) or (x == results[1][0] and y == results[0][0])) def test_serial_tasks_reading_same_signal(shutdown_only):
63
64
135
12
51
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_serial_tasks_reading_same_signal
test_serial_tasks_reading_same_signal
338
356
338
338
a08ec21f92b7327b9a03029d553c8ab26c0b0817
bigcode/the-stack
train
c9d00de83e94be8bb22a2ba6
train
function
def test_task_crash(ray_start_regular): # Get an error when ray.get() is called on the return of a failed task. @ray.remote def crashing_function(): raise Exception("exception message") object_id = crashing_function.remote() try: ray.get(object_id) except Exception as e: ...
def test_task_crash(ray_start_regular): # Get an error when ray.get() is called on the return of a failed task. @ray.remote
def crashing_function(): raise Exception("exception message") object_id = crashing_function.remote() try: ray.get(object_id) except Exception as e: assert type(e) == ray.exceptions.RayTaskError finally: result_list = signal.receive([object_id], timeout=5) ass...
.receive([a], timeout=5) received_count += len(result_list) if (received_count == count): break assert True def test_task_crash(ray_start_regular): # Get an error when ray.get() is called on the return of a failed task. @ray.remote
64
64
123
33
30
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_task_crash
test_task_crash
89
104
89
92
ed9c68177e86f2fb1e378fcca2d15e3ca0ee05e3
bigcode/the-stack
train
259253d17c4a046faceb4a50
train
function
def test_task_crash_without_get(ray_start_regular): # Get an error when task failed. @ray.remote def crashing_function(): raise Exception("exception message") object_id = crashing_function.remote() result_list = signal.receive([object_id], timeout=5) assert len(result_list) == 1 as...
def test_task_crash_without_get(ray_start_regular): # Get an error when task failed. @ray.remote
def crashing_function(): raise Exception("exception message") object_id = crashing_function.remote() result_list = signal.receive([object_id], timeout=5) assert len(result_list) == 1 assert type(result_list[0][1]) == signal.ErrorSignal
result_list = signal.receive([object_id], timeout=5) assert len(result_list) == 1 assert type(result_list[0][1]) == signal.ErrorSignal def test_task_crash_without_get(ray_start_regular): # Get an error when task failed. @ray.remote
64
64
84
25
38
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_task_crash_without_get
test_task_crash_without_get
107
117
107
110
1b4d2defe2a7eb0c04148485e53ad67a4403a553
bigcode/the-stack
train
ade562e3793242641d3b65e6
train
function
def test_actor_crash_init3(ray_start_regular): # Get errors when (1) __init__ fails, and (2) subsequently when # another method of the actor is invoked. @ray.remote class ActorCrashInit(object): def __init__(self): raise Exception("exception message") def method(self): ...
def test_actor_crash_init3(ray_start_regular): # Get errors when (1) __init__ fails, and (2) subsequently when # another method of the actor is invoked. @ray.remote
class ActorCrashInit(object): def __init__(self): raise Exception("exception message") def method(self): return 1 a = ActorCrashInit.remote() a.method.remote() # Wait for a.method.remote() to finish and generate an error. time.sleep(10) result_list = sig...
2 assert type(result_list[0][1]) == signal.ErrorSignal def test_actor_crash_init3(ray_start_regular): # Get errors when (1) __init__ fails, and (2) subsequently when # another method of the actor is invoked. @ray.remote
64
64
149
46
17
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_actor_crash_init3
test_actor_crash_init3
185
203
185
189
bce21b305cb86dc2547c88ca862b159ee27a2983
bigcode/the-stack
train
b8ed0234684d08018131cea5
train
function
def test_send_signal_from_two_tasks_to_driver(ray_start_regular): # Define a remote function that sends a user-defined signal. @ray.remote def send_signal(value): signal.send(UserSignal(value)) a = send_signal.remote(0) b = send_signal.remote(0) ray.get([a, b]) result_list = ray.e...
def test_send_signal_from_two_tasks_to_driver(ray_start_regular): # Define a remote function that sends a user-defined signal. @ray.remote
def send_signal(value): signal.send(UserSignal(value)) a = send_signal.remote(0) b = send_signal.remote(0) ray.get([a, b]) result_list = ray.experimental.signal.receive([a]) assert len(result_list) == 1 # Call again receive on "a" with no new signal. result_list = ray.experime...
actor], timeout=10) assert len(result_list) == 1 assert type(result_list[0][1]) == signal.ActorDiedSignal def test_send_signal_from_two_tasks_to_driver(ray_start_regular): # Define a remote function that sends a user-defined signal. @ray.remote
64
64
128
31
32
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_send_signal_from_two_tasks_to_driver
test_send_signal_from_two_tasks_to_driver
304
319
304
306
9516ddd1a16368f735cf088d587b78d3e7ae78c0
bigcode/the-stack
train
521bf206b54aa8fd5f838496
train
function
def test_actor_crash_init(ray_start_regular): # Get an error when an actor's __init__ failed. @ray.remote class ActorCrashInit(object): def __init__(self): raise Exception("exception message") def m(self): return 1 # Do not catch the exception in the __init__. ...
def test_actor_crash_init(ray_start_regular): # Get an error when an actor's __init__ failed. @ray.remote
class ActorCrashInit(object): def __init__(self): raise Exception("exception message") def m(self): return 1 # Do not catch the exception in the __init__. a = ActorCrashInit.remote() result_list = signal.receive([a], timeout=5) assert len(result_list) == 1 ...
= signal.receive([a], timeout=5) assert len(result_list) == 1 assert type(result_list[0][1]) == signal.ErrorSignal def test_actor_crash_init(ray_start_regular): # Get an error when an actor's __init__ failed. @ray.remote
64
64
119
29
34
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_actor_crash_init
test_actor_crash_init
143
158
143
146
5665f13030c7735c87fe3d4c711998c63694f030
bigcode/the-stack
train
e9460079a95ca37773a030b5
train
function
def receive_all_signals(sources, timeout): # Get all signals from sources, until there is no signal for a time # period of timeout. results = [] while True: r = signal.receive(sources, timeout=timeout) if len(r) == 0: return results else: results.extend(r...
def receive_all_signals(sources, timeout): # Get all signals from sources, until there is no signal for a time # period of timeout.
results = [] while True: r = signal.receive(sources, timeout=timeout) if len(r) == 0: return results else: results.extend(r)
import ray import ray.experimental.signal as signal class UserSignal(signal.Signal): def __init__(self, value): self.value = value def receive_all_signals(sources, timeout): # Get all signals from sources, until there is no signal for a time # period of timeout.
64
64
74
33
30
mikewlange/ray
python/ray/tests/test_signal.py
Python
receive_all_signals
receive_all_signals
12
22
12
15
8470edaeae15b81a6904ca7a737ef087a4919fe9
bigcode/the-stack
train
542ff4627173b7a8f5af0046
train
function
def test_signal_on_node_failure(two_node_cluster): """Test actor checkpointing on a remote node.""" class ActorSignal(object): def __init__(self): pass def node_id(self): return ray.worker.global_worker.node.unique_id # Place the actor on the remote node. clust...
def test_signal_on_node_failure(two_node_cluster):
"""Test actor checkpointing on a remote node.""" class ActorSignal(object): def __init__(self): pass def node_id(self): return ray.worker.global_worker.node.unique_id # Place the actor on the remote node. cluster, remote_node = two_node_cluster actor_cls = ...
(a.send_signals.remote(signal_value, count)) signal.forget([a]) ray.get(a.send_signals.remote(signal_value, count)) result_list = receive_all_signals([a], timeout=5) assert len(result_list) == count def test_signal_on_node_failure(two_node_cluster):
64
64
198
10
53
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_signal_on_node_failure
test_signal_on_node_failure
277
301
277
277
42807d9706ebc172750d43b763683d1396f29182
bigcode/the-stack
train
5ccf0e7b21f6c8af072f1a78
train
function
def test_forget(ray_start_regular): # Send "count" signals on behalf of an actor, then ignore all these # signals, and then send anther "count" signals on behalf of the same # actor. Then show that the driver only gets the last "count" signals. @ray.remote class ActorSendSignals(object): de...
def test_forget(ray_start_regular): # Send "count" signals on behalf of an actor, then ignore all these # signals, and then send anther "count" signals on behalf of the same # actor. Then show that the driver only gets the last "count" signals. @ray.remote
class ActorSendSignals(object): def __init__(self): pass def send_signals(self, value, count): for i in range(count): signal.send(UserSignal(value + str(i))) a = ActorSendSignals.remote() signal_value = "simple signal" count = 5 ray.get(a.sen...
def test_forget(ray_start_regular): # Send "count" signals on behalf of an actor, then ignore all these # signals, and then send anther "count" signals on behalf of the same # actor. Then show that the driver only gets the last "count" signals. @ray.remote
68
64
192
68
0
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_forget
test_forget
253
274
253
258
c9707227c911075bb9567ed0bf1f776139a7663a
bigcode/the-stack
train
daeb07c9c7495b7cb13a4614
train
function
def test_actor_crash_init2(ray_start_regular): # Get errors when (1) __init__ fails, and (2) subsequently when # ray.get() is called on the return parameter of another method # of the actor. @ray.remote class ActorCrashInit(object): def __init__(self): raise Exception("exception...
def test_actor_crash_init2(ray_start_regular): # Get errors when (1) __init__ fails, and (2) subsequently when # ray.get() is called on the return parameter of another method # of the actor. @ray.remote
class ActorCrashInit(object): def __init__(self): raise Exception("exception message") def method(self): return 1 a = ActorCrashInit.remote() try: ray.get(a.method.remote()) except Exception as e: assert type(e) == ray.exceptions.RayTaskError ...
1]) == signal.ErrorSignal def test_actor_crash_init2(ray_start_regular): # Get errors when (1) __init__ fails, and (2) subsequently when # ray.get() is called on the return parameter of another method # of the actor. @ray.remote
64
64
168
57
6
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_actor_crash_init2
test_actor_crash_init2
161
182
161
166
ae0b3be1319bce0aad61e413d773ceb50cb99ea5
bigcode/the-stack
train
ec076996bd42ed440e72a8f2
train
function
def test_non_integral_receive_timeout(ray_start_regular): @ray.remote def send_signal(value): signal.send(UserSignal(value)) a = send_signal.remote(0) # make sure send_signal had a chance to execute ray.get(a) result_list = ray.experimental.signal.receive([a], timeout=0.1) assert ...
def test_non_integral_receive_timeout(ray_start_regular): @ray.remote
def send_signal(value): signal.send(UserSignal(value)) a = send_signal.remote(0) # make sure send_signal had a chance to execute ray.get(a) result_list = ray.experimental.signal.receive([a], timeout=0.1) assert len(result_list) == 1
_list) == 1 result_list = ray.get(f.remote([a])) assert len(result_list) == 1 result_list = ray.get(f.remote([a])) assert len(result_list) == 1 def test_non_integral_receive_timeout(ray_start_regular): @ray.remote
64
64
82
16
47
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_non_integral_receive_timeout
test_non_integral_receive_timeout
359
370
359
360
0611de6f243642f847c7c9ddaa45d253396620ce
bigcode/the-stack
train
ad15a72c78f8a86a349d3de8
train
function
def test_actor_crash(ray_start_regular): # Get an error when ray.get() is called on a return parameter # of a method that failed. @ray.remote class Actor(object): def __init__(self): pass def crash(self): raise Exception("exception message") a = Actor.remot...
def test_actor_crash(ray_start_regular): # Get an error when ray.get() is called on a return parameter # of a method that failed. @ray.remote
class Actor(object): def __init__(self): pass def crash(self): raise Exception("exception message") a = Actor.remote() try: ray.get(a.crash.remote()) except Exception as e: assert type(e) == ray.exceptions.RayTaskError finally: result...
) assert len(result_list) == 1 assert type(result_list[0][1]) == signal.ErrorSignal def test_actor_crash(ray_start_regular): # Get an error when ray.get() is called on a return parameter # of a method that failed. @ray.remote
64
64
142
38
25
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_actor_crash
test_actor_crash
120
140
120
124
e504ae4b2c27d332f7a67d2e101f27323a2d0e79
bigcode/the-stack
train
673793e9a856c181f9a6060d
train
function
def test_send_signal_from_actor_to_driver(ray_start_regular): # Send several signals from an actor, and receive them in the driver. @ray.remote class ActorSendSignal(object): def __init__(self): pass def send_signal(self, value): signal.send(UserSignal(value)) ...
def test_send_signal_from_actor_to_driver(ray_start_regular): # Send several signals from an actor, and receive them in the driver. @ray.remote
class ActorSendSignal(object): def __init__(self): pass def send_signal(self, value): signal.send(UserSignal(value)) a = ActorSendSignal.remote() signal_value = "simple signal" count = 6 for i in range(count): ray.get(a.send_signal.remote(signal_valu...
_list = signal.receive([object_id], timeout=10) print(result_list[0][1]) assert len(result_list) == 1 def test_send_signal_from_actor_to_driver(ray_start_regular): # Send several signals from an actor, and receive them in the driver. @ray.remote
64
64
155
33
30
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_send_signal_from_actor_to_driver
test_send_signal_from_actor_to_driver
40
60
40
43
c185799f9e894f447e49f2cd7a7e42564a0c9d4d
bigcode/the-stack
train
cac4b5f8f110141d82c76cf9
train
function
def test_task_to_driver(ray_start_regular): # Send a signal from a task to the driver. @ray.remote def task_send_signal(value): signal.send(UserSignal(value)) return signal_value = "simple signal" object_id = task_send_signal.remote(signal_value) result_list = signal.receive([o...
def test_task_to_driver(ray_start_regular): # Send a signal from a task to the driver. @ray.remote
def task_send_signal(value): signal.send(UserSignal(value)) return signal_value = "simple signal" object_id = task_send_signal.remote(signal_value) result_list = signal.receive([object_id], timeout=10) print(result_list[0][1]) assert len(result_list) == 1
[] while True: r = signal.receive(sources, timeout=timeout) if len(r) == 0: return results else: results.extend(r) def test_task_to_driver(ray_start_regular): # Send a signal from a task to the driver. @ray.remote
64
64
95
26
38
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_task_to_driver
test_task_to_driver
25
37
25
28
b01edda15c16e623353a5ba224fe72185a6b28bb
bigcode/the-stack
train
cf3a8a5f7dca48e443e85e96
train
class
class UserSignal(signal.Signal): def __init__(self, value): self.value = value
class UserSignal(signal.Signal):
def __init__(self, value): self.value = value
import time import ray import ray.experimental.signal as signal class UserSignal(signal.Signal):
19
64
21
6
12
mikewlange/ray
python/ray/tests/test_signal.py
Python
UserSignal
UserSignal
7
9
7
7
ff635277f4700221731f62497dbad852cecdf279
bigcode/the-stack
train
c6c2889256a6b0da0297e0ea
train
function
def test_small_receive_timeout(ray_start_regular): """ Test that receive handles timeout smaller than the 1ms min """ # 0.1 ms small_timeout = 1e-4 @ray.remote def send_signal(value): signal.send(UserSignal(value)) a = send_signal.remote(0) # make sure send_signal had a chance ...
def test_small_receive_timeout(ray_start_regular):
""" Test that receive handles timeout smaller than the 1ms min """ # 0.1 ms small_timeout = 1e-4 @ray.remote def send_signal(value): signal.send(UserSignal(value)) a = send_signal.remote(0) # make sure send_signal had a chance to execute ray.get(a) result_list = ray.ex...
(value)) a = send_signal.remote(0) # make sure send_signal had a chance to execute ray.get(a) result_list = ray.experimental.signal.receive([a], timeout=0.1) assert len(result_list) == 1 def test_small_receive_timeout(ray_start_regular):
64
64
114
9
54
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_small_receive_timeout
test_small_receive_timeout
373
389
373
373
3c8dd7aee4b3e822133b58d05475154002513504
bigcode/the-stack
train
5ad4c60e20021e525bc17d25
train
function
def test_receiving_on_two_returns(ray_start_regular): @ray.remote(num_return_vals=2) def send_signal(value): signal.send(UserSignal(value)) return 1, 2 x, y = send_signal.remote(0) ray.get([x, y]) results = ray.experimental.signal.receive([x, y]) assert ((x == results[0][0] a...
def test_receiving_on_two_returns(ray_start_regular): @ray.remote(num_return_vals=2)
def send_signal(value): signal.send(UserSignal(value)) return 1, 2 x, y = send_signal.remote(0) ray.get([x, y]) results = ray.experimental.signal.receive([x, y]) assert ((x == results[0][0] and y == results[1][0]) or (x == results[1][0] and y == results[0][0]))
_list) == 1 # Call again receive on "a" with no new signal. result_list = ray.experimental.signal.receive([a, b]) assert len(result_list) == 1 def test_receiving_on_two_returns(ray_start_regular): @ray.remote(num_return_vals=2)
64
64
113
21
42
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_receiving_on_two_returns
test_receiving_on_two_returns
322
335
322
323
a5b218bef9934680025398bb9d317f8f8c660a5a
bigcode/the-stack
train
84744953aaf69d667f27bc89
train
function
def test_send_signals_from_actor_to_driver(ray_start_regular): # Send "count" signal at intervals from an actor and get # these signals in the driver. @ray.remote class ActorSendSignals(object): def __init__(self): pass def send_signals(self, value, count): for ...
def test_send_signals_from_actor_to_driver(ray_start_regular): # Send "count" signal at intervals from an actor and get # these signals in the driver. @ray.remote
class ActorSendSignals(object): def __init__(self): pass def send_signals(self, value, count): for i in range(count): signal.send(UserSignal(value + str(i))) a = ActorSendSignals.remote() signal_value = "simple signal" count = 20 a.send_signa...
for i in range(count): assert signal_value + str(i) == result_list[i][1].value def test_send_signals_from_actor_to_driver(ray_start_regular): # Send "count" signal at intervals from an actor and get # these signals in the driver. @ray.remote
64
64
166
41
22
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_send_signals_from_actor_to_driver
test_send_signals_from_actor_to_driver
63
86
63
67
b6c1de64cc3edfc60838a47bde9bfd340fa27b8e
bigcode/the-stack
train
1030d5426fbf2a12bb8fc05d
train
function
def test_send_signals_from_actor_to_actor(ray_start_regular): # Send "count" signal at intervals of 100ms from two actors and get # these signals in another actor. @ray.remote class ActorSendSignals(object): def __init__(self): pass def send_signals(self, value, count): ...
def test_send_signals_from_actor_to_actor(ray_start_regular): # Send "count" signal at intervals of 100ms from two actors and get # these signals in another actor. @ray.remote
class ActorSendSignals(object): def __init__(self): pass def send_signals(self, value, count): for i in range(count): signal.send(UserSignal(value + str(i))) @ray.remote class ActorGetSignalsAll(object): def __init__(self): self.r...
for a.method.remote() to finish and generate an error. time.sleep(10) result_list = signal.receive([a], timeout=5) assert len(result_list) == 2 assert type(result_list[0][1]) == signal.ErrorSignal def test_send_signals_from_actor_to_actor(ray_start_regular): # Send "count" signal at intervals of 10...
101
101
338
45
55
mikewlange/ray
python/ray/tests/test_signal.py
Python
test_send_signals_from_actor_to_actor
test_send_signals_from_actor_to_actor
206
250
206
210
b2cff562788bd6d6dfcba40282d963302c41f75d
bigcode/the-stack
train
a83c30938f589167f2d8681a
train
function
def sum_menu_3(): cls() print( """ 1. 311 2. 321 4. 341 5. 353 6. 363 7. 373 8. 381 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): retu...
def sum_menu_3():
cls() print( """ 1. 311 2. 321 4. 341 5. 353 6. 363 7. 373 8. 381 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): return elif case ...
== ord('1'): task211_main() elif case == ord('2'): task221_main() elif case == ord('3'): task231_main() elif case == ord('4'): task241_main() else: return pause() def sum_menu_3():
64
64
215
6
58
Pavel-Innokentevich-Galanin/3-sem_YP-part1
lab4/src/option5/src/task_7.py
Python
sum_menu_3
sum_menu_3
156
204
156
156
2168a7591b9259a05902c15044fd3c348efc98a8
bigcode/the-stack
train
9df71e45e60c8bfc091d5682
train
function
def sum_menu_6(): cls() print( """ 1. 61 2. 62 3. 63 4. 64 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): return elif case == ord(...
def sum_menu_6():
cls() print( """ 1. 61 2. 62 3. 63 4. 64 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): return elif case == ord('1'): task...
== ord('1'): task411_main() elif case == ord('2'): task421_main() elif case == ord('3'): task431_main() elif case == ord('4'): task44_main() else: return pause() def sum_menu_6():
64
64
160
6
58
Pavel-Innokentevich-Galanin/3-sem_YP-part1
lab4/src/option5/src/task_7.py
Python
sum_menu_6
sum_menu_6
244
280
244
244
47486d0d3f156df685368e0741337e335234e845
bigcode/the-stack
train
ed1624b5301169faa76b65e3
train
function
def pause(): print('Press any key to continue...') string = input()
def pause():
print('Press any key to continue...') string = input()
61_main from task_6_2_1 import task621_main from task_6_3_1 import task631_main from task_6_4_1 import task641_main def cls(): os.system('cls' if os.name=='nt' else 'clear') def pause():
64
64
17
3
61
Pavel-Innokentevich-Galanin/3-sem_YP-part1
lab4/src/option5/src/task_7.py
Python
pause
pause
34
36
34
34
b16bcd93c44ba12a87ef908ff3410e8c2d7c5d4a
bigcode/the-stack
train
daed7e7feadc21338f4a080d
train
function
def cls(): os.system('cls' if os.name=='nt' else 'clear')
def cls():
os.system('cls' if os.name=='nt' else 'clear')
_4_4 import task44_main from task_6_1 import task61_main from task_6_2_1 import task621_main from task_6_3_1 import task631_main from task_6_4_1 import task641_main def cls():
64
64
19
3
60
Pavel-Innokentevich-Galanin/3-sem_YP-part1
lab4/src/option5/src/task_7.py
Python
cls
cls
31
32
31
31
2e67faea4ec15261e5c2cd8b9ceedac7494af1dd
bigcode/the-stack
train
c804c39ad7ad2fea098bab9e
train
function
def sum_menu_2(): cls() print( """ 1. 211 2. 221 3. 231 4. 241 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): return elif case == ...
def sum_menu_2():
cls() print( """ 1. 211 2. 221 3. 231 4. 241 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): return elif case == ord('1'): ...
ord('1'): task111_main() elif case == ord('2'): task121_main() elif case == ord('3'): task131_main() elif case == ord('4'): task141_main() else: return pause() def sum_menu_2():
64
64
160
6
58
Pavel-Innokentevich-Galanin/3-sem_YP-part1
lab4/src/option5/src/task_7.py
Python
sum_menu_2
sum_menu_2
118
154
118
118
c44c96f00964c75fc79ceec56417f81b122e286e
bigcode/the-stack
train
dd37638fd06fa7f600790e92
train
function
def sum_menu_1(): cls() print( """ 1. 111 2. 121 3. 131 4. 141 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): return elif case == ...
def sum_menu_1():
cls() print( """ 1. 111 2. 121 3. 131 4. 141 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): return elif case == ord('1'): ...
() elif case == ord('3'): sum_menu_3() menu() elif case == ord('4'): sum_menu_4() menu() elif case == ord('6'): sum_menu_6() menu() else: menu() def sum_menu_1():
64
64
161
6
58
Pavel-Innokentevich-Galanin/3-sem_YP-part1
lab4/src/option5/src/task_7.py
Python
sum_menu_1
sum_menu_1
80
116
80
80
c756182bdfd22e595fb25a82e1fc1cf576a1e8e1
bigcode/the-stack
train
19489d89d9f253e6bcdf7c10
train
function
def sum_menu_4(): cls() print( """ 1. 411 2. 421 3. 431 4. 44 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): return elif case == o...
def sum_menu_4():
cls() print( """ 1. 411 2. 421 3. 431 4. 44 0. Выход в главное меню """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число cls() if case == ord('0'): return elif case == ord('1'): t...
ord('5'): task353_main() elif case == ord('6'): task363_main() elif case == ord('7'): task373_main() elif case == ord('8'): task381_main() else: return pause() def sum_menu_4():
64
64
160
6
58
Pavel-Innokentevich-Galanin/3-sem_YP-part1
lab4/src/option5/src/task_7.py
Python
sum_menu_4
sum_menu_4
206
242
206
206
f55efb96533d8258aa20745ef4ce5e4834325ae0
bigcode/the-stack
train
005e1578f4bfa08646ec2cd3
train
function
def menu(): cls() print( """ 1. Задание 1 2. Задание 2 3. Задание 3 4. Задание 4 6. Задание 6 0. Выход из из программы """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число if case == ord('0'): ...
def menu():
cls() print( """ 1. Задание 1 2. Задание 2 3. Задание 3 4. Задание 4 6. Задание 6 0. Выход из из программы """ ) case = input() # запись строки case = case[0] # взятие первого символа со строки case = ord(case) # перевод символа в число if case == ord('0'): return ...
task_6_3_1 import task631_main from task_6_4_1 import task641_main def cls(): os.system('cls' if os.name=='nt' else 'clear') def pause(): print('Press any key to continue...') string = input() def menu():
64
64
204
3
61
Pavel-Innokentevich-Galanin/3-sem_YP-part1
lab4/src/option5/src/task_7.py
Python
menu
menu
38
78
38
38
1b4fcc7b6ff17f6be05733f00aea6a8db8cd8531
bigcode/the-stack
train
c22aa35f132ac6e553bf12f0
train
function
def validate_file(fpath, file_hash, algorithm='auto', chunk_size=65535): """Validates a file against a sha256 or md5 hash. Arguments: fpath: path to the file being validated file_hash: The expected hash string of the file. The sha256 and md5 hash algorithms are both supported. algorith...
def validate_file(fpath, file_hash, algorithm='auto', chunk_size=65535):
"""Validates a file against a sha256 or md5 hash. Arguments: fpath: path to the file being validated file_hash: The expected hash string of the file. The sha256 and md5 hash algorithms are both supported. algorithm: Hash algorithm, one of 'auto', 'sha256', or 'md5'. The defau...
() with open(fpath, 'rb') as fpath_file: for chunk in iter(lambda: fpath_file.read(chunk_size), b''): hasher.update(chunk) return hasher.hexdigest() def validate_file(fpath, file_hash, algorithm='auto', chunk_size=65535):
64
64
210
19
45
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
validate_file
validate_file
317
339
317
317
a7bdee737dd9788d6ff9341b0ab63f794162fcff
bigcode/the-stack
train
ec5a47aa0291e7ac861dccf5
train
class
@keras_export('keras.utils.SequenceEnqueuer') class SequenceEnqueuer(object): """Base class to enqueue inputs. The task of an Enqueuer is to use parallelism to speed up preprocessing. This is done with processes or threads. Example: ```python enqueuer = SequenceEnqueuer(...) enqueuer.start() ...
@keras_export('keras.utils.SequenceEnqueuer') class SequenceEnqueuer(object):
"""Base class to enqueue inputs. The task of an Enqueuer is to use parallelism to speed up preprocessing. This is done with processes or threads. Example: ```python enqueuer = SequenceEnqueuer(...) enqueuer.start() datas = enqueuer.get() for data in datas: # Use the inputs...
# workers reporting False for is_alive and no longer appearing in the # list of active children. Once again, we sleep for a small grace period. # This prevents false positives from workers which are simply still in the # process of spinning down. time.sleep(grace_period) # Finally we remove ...
256
256
856
18
238
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
SequenceEnqueuer
SequenceEnqueuer
654
780
654
655
b09f60c0db8ee1e3485f91b5950458035cfc7857
bigcode/the-stack
train
70f79559939c38151fd2e46d
train
function
def iter_sequence_infinite(seq): """Iterates indefinitely over a Sequence. Arguments: seq: Sequence instance. Yields: Batches of data from the Sequence. """ while True: for item in seq: yield item
def iter_sequence_infinite(seq):
"""Iterates indefinitely over a Sequence. Arguments: seq: Sequence instance. Yields: Batches of data from the Sequence. """ while True: for item in seq: yield item
_end(self): """Method called at the end of every epoch. """ pass def __iter__(self): """Create a generator that iterate over the Sequence.""" for item in (self[i] for i in range(len(self))): yield item def iter_sequence_infinite(seq):
64
64
54
7
56
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
iter_sequence_infinite
iter_sequence_infinite
464
475
464
464
eddaf65e5e835fac18bb82d0e42e84e05d3dcacc
bigcode/the-stack
train
d1c4e59bbd4c3ef0745f8f36
train
function
def get_worker_id_queue(): """Lazily create the queue to track worker ids.""" global _WORKER_ID_QUEUE if _WORKER_ID_QUEUE is None: _WORKER_ID_QUEUE = multiprocessing.Queue() return _WORKER_ID_QUEUE
def get_worker_id_queue():
"""Lazily create the queue to track worker ids.""" global _WORKER_ID_QUEUE if _WORKER_ID_QUEUE is None: _WORKER_ID_QUEUE = multiprocessing.Queue() return _WORKER_ID_QUEUE
: return multiprocessing.dummy.Pool # ThreadPool logging.warning( 'multiprocessing can interact badly with TensorFlow, causing ' 'nondeterministic deadlocks. For high performance data pipelines tf.data ' 'is recommended.') return multiprocessing.Pool def get_worker_id_queue():
64
64
55
6
57
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
get_worker_id_queue
get_worker_id_queue
517
522
517
517
a5fc4333b930b8d0e3c5915272e4839e190c9bb7
bigcode/the-stack
train
6d9ec78734227b8e0214ad53
train
class
@keras_export('keras.utils.OrderedEnqueuer') class OrderedEnqueuer(SequenceEnqueuer): """Builds a Enqueuer from a Sequence. Used in `fit_generator`, `evaluate_generator`, `predict_generator`. Arguments: sequence: A `tf.keras.utils.data_utils.Sequence` object. use_multiprocessing: use multiprocessing...
@keras_export('keras.utils.OrderedEnqueuer') class OrderedEnqueuer(SequenceEnqueuer):
"""Builds a Enqueuer from a Sequence. Used in `fit_generator`, `evaluate_generator`, `predict_generator`. Arguments: sequence: A `tf.keras.utils.data_utils.Sequence` object. use_multiprocessing: use multiprocessing if True, otherwise threading shuffle: whether to shuffle the data at the beginn...
self.stop() @abstractmethod def _run(self): """Submits request to the executor and queue the `Future` objects.""" raise NotImplementedError @abstractmethod def _get_executor_init(self, workers): """Gets the Pool initializer for multiprocessing. Arguments: workers: Number of workers. ...
178
178
595
23
154
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
OrderedEnqueuer
OrderedEnqueuer
783
869
783
784
a71fe06c03160f1ae126e3cea3d799376e2b7237
bigcode/the-stack
train
f15d3aa4893bd93afbc7fdf9
train
function
@keras_export('keras.experimental.terminate_keras_multiprocessing_pools') def terminate_keras_multiprocessing_pools(grace_period=0.1, use_sigkill=False): """Destroy Keras' multiprocessing pools to prevent deadlocks. In general multiprocessing.Pool can interact quite badly with other, seemingly unrelated, parts o...
@keras_export('keras.experimental.terminate_keras_multiprocessing_pools') def terminate_keras_multiprocessing_pools(grace_period=0.1, use_sigkill=False):
"""Destroy Keras' multiprocessing pools to prevent deadlocks. In general multiprocessing.Pool can interact quite badly with other, seemingly unrelated, parts of a codebase due to Pool's reliance on fork. This method cleans up all pools which are known to belong to Keras (and thus can be safely terminated). ...
old_force_threadpool, _FORCE_THREADPOOL = _FORCE_THREADPOOL, True out = f(*args, **kwargs) _FORCE_THREADPOOL = old_force_threadpool return out return wrapped def get_pool_class(use_multiprocessing): global _FORCE_THREADPOOL if not use_multiprocessing or _FORCE_THREADPOOL: return multiproc...
256
256
932
38
217
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
terminate_keras_multiprocessing_pools
terminate_keras_multiprocessing_pools
530
634
530
531
6e6bde6cff4c1001957f79f1fa195e9b2dc25f91
bigcode/the-stack
train
b546ab16ccc3fd4a10b7564a
train
function
def _extract_archive(file_path, path='.', archive_format='auto'): """Extracts an archive if it matches tar, tar.gz, tar.bz, or zip formats. Arguments: file_path: path to the archive file path: path to extract the archive file archive_format: Archive format to try for extracting the file. ...
def _extract_archive(file_path, path='.', archive_format='auto'):
"""Extracts an archive if it matches tar, tar.gz, tar.bz, or zip formats. Arguments: file_path: path to the archive file path: path to extract the archive file archive_format: Archive format to try for extracting the file. Options are 'auto', 'tar', 'zip', and None. 'tar' incl...
urllib.request import urlretrieve def is_generator_or_sequence(x): """Check if `x` is a Keras generator type.""" builtin_iterators = (str, list, tuple, dict, set, frozenset) if isinstance(x, (ops.Tensor, np.ndarray) + builtin_iterators): return False return tf_inspect.isgenerator(x) or isinstance(x, Seque...
103
103
345
15
88
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
_extract_archive
_extract_archive
117
160
117
117
15a3078f9d6f2afee3885c7b6ce53b1497cce219
bigcode/the-stack
train
978a7fd06c1bd92054441b98
train
function
def threadsafe_generator(f): @functools.wraps(f) def g(*a, **kw): return ThreadsafeIter(f(*a, **kw)) return g
def threadsafe_generator(f): @functools.wraps(f)
def g(*a, **kw): return ThreadsafeIter(f(*a, **kw)) return g
.lock: if self._exception: raise self._exception # pylint: disable=raising-bad-type try: return next(self.it) except Exception as e: self._exception = e raise def threadsafe_generator(f): @functools.wraps(f)
64
64
40
15
48
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
threadsafe_generator
threadsafe_generator
376
382
376
378
4ecf545e22c18232e4c7943e87d4f7010a49b557
bigcode/the-stack
train
eff93cd1ba8b65e7ba532e2d
train
class
class ThreadsafeIter(object): """Wrap an iterator with a lock and propagate exceptions to all threads.""" def __init__(self, it): self.it = it self.lock = threading.Lock() # After a generator throws an exception all subsequent next() calls raise a # StopIteration Exception. This, however, presents...
class ThreadsafeIter(object):
"""Wrap an iterator with a lock and propagate exceptions to all threads.""" def __init__(self, it): self.it = it self.lock = threading.Lock() # After a generator throws an exception all subsequent next() calls raise a # StopIteration Exception. This, however, presents an issue when mixing # ge...
or (algorithm == 'auto' and len(file_hash) == 64): hasher = 'sha256' else: hasher = 'md5' if str(_hash_file(fpath, hasher, chunk_size)) == str(file_hash): return True else: return False class ThreadsafeIter(object):
72
72
243
6
65
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
ThreadsafeIter
ThreadsafeIter
342
373
342
342
c82199028b8265ef90cc3f6d3c2b8a626bb0f023
bigcode/the-stack
train
91ee72b8a1e5c7cb8558dc6c
train
function
def is_generator_or_sequence(x): """Check if `x` is a Keras generator type.""" builtin_iterators = (str, list, tuple, dict, set, frozenset) if isinstance(x, (ops.Tensor, np.ndarray) + builtin_iterators): return False return tf_inspect.isgenerator(x) or isinstance(x, Sequence) or is_iterator(x)
def is_generator_or_sequence(x):
"""Check if `x` is a Keras generator type.""" builtin_iterators = (str, list, tuple, dict, set, frozenset) if isinstance(x, (ops.Tensor, np.ndarray) + builtin_iterators): return False return tf_inspect.isgenerator(x) or isinstance(x, Sequence) or is_iterator(x)
else: break response = urlopen(url, data) with open(filename, 'wb') as fd: for chunk in chunk_read(response, reporthook=reporthook): fd.write(chunk) else: from six.moves.urllib.request import urlretrieve def is_generator_or_sequence(x):
64
64
82
7
56
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
is_generator_or_sequence
is_generator_or_sequence
109
114
109
109
a6b2734d5275a2e12a65480926c9c2ba4674ca4f
bigcode/the-stack
train
f4fb3af08e12ed3e5477417c
train
function
def get_index(uid, i): """Get the value from the Sequence `uid` at index `i`. To allow multiple Sequences to be used at the same time, we use `uid` to get a specific one. A single Sequence would cause the validation to overwrite the training Sequence. Arguments: uid: int, Sequence identifier i: ...
def get_index(uid, i):
"""Get the value from the Sequence `uid` at index `i`. To allow multiple Sequences to be used at the same time, we use `uid` to get a specific one. A single Sequence would cause the validation to overwrite the training Sequence. Arguments: uid: int, Sequence identifier i: index Returns: ...
case that a # pid is reused. _WORKER_IDS.difference_update(visited_workers) gc.collect() for pool in _DATA_POOLS: errors.append('pool still exists: {}, hash={}'.format(pool, hash(pool))) return errors def get_index(uid, i):
64
64
107
7
56
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
get_index
get_index
637
651
637
637
90250762ec2a86a4859ad1a73d74c82d44a4be1d
bigcode/the-stack
train
095b6b3af8ad17cbe45c6651
train
function
def _hash_file(fpath, algorithm='sha256', chunk_size=65535): """Calculates a file sha256 or md5 hash. Example: ```python _hash_file('/path/to/file.zip') 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' ``` Arguments: fpath: path to the file being validated algorithm: hash ...
def _hash_file(fpath, algorithm='sha256', chunk_size=65535):
"""Calculates a file sha256 or md5 hash. Example: ```python _hash_file('/path/to/file.zip') 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' ``` Arguments: fpath: path to the file being validated algorithm: hash algorithm, one of 'auto', 'sha256', or 'md5'. The d...
: if not os.path.exists(untar_fpath): _extract_archive(fpath, datadir, archive_format='tar') return untar_fpath if extract: _extract_archive(fpath, datadir, archive_format) return fpath def _hash_file(fpath, algorithm='sha256', chunk_size=65535):
74
74
249
18
55
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
_hash_file
_hash_file
286
314
286
286
9a9f429e8825aa97dea5cd20a229b5b0dfd6ac74
bigcode/the-stack
train
288009b2f5efdcc327d35fdc
train
class
@keras_export('keras.utils.Sequence') class Sequence(object): """Base object for fitting to a sequence of data, such as a dataset. Every `Sequence` must implement the `__getitem__` and the `__len__` methods. If you want to modify your dataset between epochs you may implement `on_epoch_end`. The method `__get...
@keras_export('keras.utils.Sequence') class Sequence(object):
"""Base object for fitting to a sequence of data, such as a dataset. Every `Sequence` must implement the `__getitem__` and the `__len__` methods. If you want to modify your dataset between epochs you may implement `on_epoch_end`. The method `__getitem__` should return a complete batch. Notes: `Sequence...
an exception we continue to throw the same exception. self._exception = None def __iter__(self): return self def __next__(self): return self.next() def next(self): with self.lock: if self._exception: raise self._exception # pylint: disable=raising-bad-type try: re...
149
149
499
12
136
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
Sequence
Sequence
385
461
385
386
070873f5ef8f31190346485a8cb85fc2e85f9194
bigcode/the-stack
train
ebcd14c420534c44ca507a74
train
function
def get_pool_class(use_multiprocessing): global _FORCE_THREADPOOL if not use_multiprocessing or _FORCE_THREADPOOL: return multiprocessing.dummy.Pool # ThreadPool logging.warning( 'multiprocessing can interact badly with TensorFlow, causing ' 'nondeterministic deadlocks. For high performance data ...
def get_pool_class(use_multiprocessing):
global _FORCE_THREADPOOL if not use_multiprocessing or _FORCE_THREADPOOL: return multiprocessing.dummy.Pool # ThreadPool logging.warning( 'multiprocessing can interact badly with TensorFlow, causing ' 'nondeterministic deadlocks. For high performance data pipelines tf.data ' 'is recommended...
FORCE_THREADPOOL old_force_threadpool, _FORCE_THREADPOOL = _FORCE_THREADPOOL, True out = f(*args, **kwargs) _FORCE_THREADPOOL = old_force_threadpool return out return wrapped def get_pool_class(use_multiprocessing):
64
64
88
9
54
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
get_pool_class
get_pool_class
506
514
506
506
5745f8b7b8b62b7f59033ad6fc7c46ad1f977889
bigcode/the-stack
train
dbffddfbeec66fc5a010b32f
train
function
def init_pool_generator(gens, random_seed=None, id_queue=None): """Initializer function for pool workers. Args: gens: State which should be made available to worker processes. random_seed: An optional value with which to seed child processes. id_queue: A multiprocessing Queue of worker ids. This is use...
def init_pool_generator(gens, random_seed=None, id_queue=None):
"""Initializer function for pool workers. Args: gens: State which should be made available to worker processes. random_seed: An optional value with which to seed child processes. id_queue: A multiprocessing Queue of worker ids. This is used to indicate that a worker process was created by Keras a...
self.queue.get(block=True).get() self.queue.task_done() if inputs is not None: yield inputs except Exception: # pylint: disable=broad-except self.stop() six.reraise(*sys.exc_info()) def init_pool_generator(gens, random_seed=None, id_queue=None):
68
68
229
15
53
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
init_pool_generator
init_pool_generator
872
896
872
872
878770a15eeadbd7acde86603c215b67305a0d5d
bigcode/the-stack
train
ee07b2fc516b4ddd926b4eea
train
function
def dont_use_multiprocessing_pool(f): @functools.wraps(f) def wrapped(*args, **kwargs): with _FORCE_THREADPOOL_LOCK: global _FORCE_THREADPOOL old_force_threadpool, _FORCE_THREADPOOL = _FORCE_THREADPOOL, True out = f(*args, **kwargs) _FORCE_THREADPOOL = old_force_threadpool return o...
def dont_use_multiprocessing_pool(f): @functools.wraps(f)
def wrapped(*args, **kwargs): with _FORCE_THREADPOOL_LOCK: global _FORCE_THREADPOOL old_force_threadpool, _FORCE_THREADPOOL = _FORCE_THREADPOOL, True out = f(*args, **kwargs) _FORCE_THREADPOOL = old_force_threadpool return out return wrapped
create. _DATA_POOLS = weakref.WeakSet() _WORKER_ID_QUEUE = None # Only created if needed. _WORKER_IDS = set() _FORCE_THREADPOOL = False _FORCE_THREADPOOL_LOCK = threading.RLock() def dont_use_multiprocessing_pool(f): @functools.wraps(f)
64
64
94
18
46
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
dont_use_multiprocessing_pool
dont_use_multiprocessing_pool
494
503
494
495
73666921f999100e2770175780e541678d550b77
bigcode/the-stack
train
84786d1921f7c91b5af5b280
train
function
@keras_export('keras.utils.get_file') def get_file(fname, origin, untar=False, md5_hash=None, file_hash=None, cache_subdir='datasets', hash_algorithm='auto', extract=False, archive_format='auto', cache_d...
@keras_export('keras.utils.get_file') def get_file(fname, origin, untar=False, md5_hash=None, file_hash=None, cache_subdir='datasets', hash_algorithm='auto', extract=False, archive_format='auto', cache_d...
"""Downloads a file from a URL if it not already in the cache. By default the file at the url `origin` is downloaded to the cache_dir `~/.keras`, placed in the cache_subdir `datasets`, and given the filename `fname`. The final location of a file `example.txt` would therefore be `~/.keras/datasets/example.txt...
. """ if archive_format is None: return False if archive_format == 'auto': archive_format = ['tar', 'zip'] if isinstance(archive_format, six.string_types): archive_format = [archive_format] for archive_type in archive_format: if archive_type == 'tar': open_fn = tarfile.open is_mat...
256
256
1,106
61
194
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
get_file
get_file
163
283
163
173
4fe5745637b3db06fc6f55bafebf20a73f3768aa
bigcode/the-stack
train
f68cc78e94b7197d10802cb9
train
function
def init_pool(seqs): global _SHARED_SEQUENCES _SHARED_SEQUENCES = seqs
def init_pool(seqs):
global _SHARED_SEQUENCES _SHARED_SEQUENCES = seqs
.Pool def get_worker_id_queue(): """Lazily create the queue to track worker ids.""" global _WORKER_ID_QUEUE if _WORKER_ID_QUEUE is None: _WORKER_ID_QUEUE = multiprocessing.Queue() return _WORKER_ID_QUEUE def init_pool(seqs):
64
64
26
6
57
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
init_pool
init_pool
525
527
525
525
ea292b57e3c9a86ca5407db9ab606fa05a5f1729
bigcode/the-stack
train
c65178bf35b1f6816ce53eaa
train
class
@keras_export('keras.utils.GeneratorEnqueuer') class GeneratorEnqueuer(SequenceEnqueuer): """Builds a queue out of a data generator. The provided generator can be finite in which case the class will throw a `StopIteration` exception. Used in `fit_generator`, `evaluate_generator`, `predict_generator`. Argum...
@keras_export('keras.utils.GeneratorEnqueuer') class GeneratorEnqueuer(SequenceEnqueuer):
"""Builds a queue out of a data generator. The provided generator can be finite in which case the class will throw a `StopIteration` exception. Used in `fit_generator`, `evaluate_generator`, `predict_generator`. Arguments: generator: a generator function which yields data use_multiprocessing: u...
processes. worker_proc.name = 'Keras_worker_{}'.format(worker_proc.name) if random_seed is not None: np.random.seed(random_seed + worker_proc.ident) if id_queue is not None: # If a worker dies during init, the pool will just create a replacement. id_queue.put(worker_proc.ident, block=True, timeout=...
198
198
660
23
175
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
GeneratorEnqueuer
GeneratorEnqueuer
915
1,002
915
916
d575a5980f38fdf2dc2bc23ad58d284d57d43302
bigcode/the-stack
train
f58460d156d8951c612a70d8
train
function
def next_sample(uid): """Gets the next value from the generator `uid`. To allow multiple generators to be used at the same time, we use `uid` to get a specific one. A single generator would cause the validation to overwrite the training generator. Arguments: uid: int, generator identifier Returns: ...
def next_sample(uid):
"""Gets the next value from the generator `uid`. To allow multiple generators to be used at the same time, we use `uid` to get a specific one. A single generator would cause the validation to overwrite the training generator. Arguments: uid: int, generator identifier Returns: The next value o...
random_seed is not None: np.random.seed(random_seed + worker_proc.ident) if id_queue is not None: # If a worker dies during init, the pool will just create a replacement. id_queue.put(worker_proc.ident, block=True, timeout=0.1) def next_sample(uid):
64
64
96
5
59
Elizaaaaa/tensorflow
tensorflow/python/keras/utils/data_utils.py
Python
next_sample
next_sample
899
912
899
899
e1ba302f8ed94e803ef51f2aaab9780db2518c71
bigcode/the-stack
train
dbba28e175a8cd8b6368ad11
train
class
class zhihu(): def __init__(self): self.headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36', 'Authorization': 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20' } self.video_url = 'https://lens.zhihu.com/api/videos/{}...
class zhihu():
def __init__(self): self.headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36', 'Authorization': 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20' } self.video_url = 'https://lens.zhihu.com/api/videos/{}' '''外部调用''' ...
''' Function: 知乎视频下载: https://www.zhihu.com/ Author: Charles 微信公众号: Charles的皮卡丘 ''' import re import json import requests from utils.utils import * ''' Input: --url: 视频地址 --savepath: 视频下载后保存的路径 Output: --is_success: 下载是否成功的BOOL值 ''' class zhihu():
85
156
523
4
81
DeathGodBXX/Video-Downloader
platforms/zhihu.py
Python
zhihu
zhihu
22
68
22
22
205693fd715aa57b6540e3c732c857aa66b9588e
bigcode/the-stack
train
0d9d34ff329054b5aa00f0f1
train
function
def alphabetized(s): filter_string="" for i in s: if i.isalpha(): filter_string+=i if not filter_string: return "" temp=list(filter_string) solution="" while temp: index=255 for i in temp: index=min(ord(i.lower()), index) for i...
def alphabetized(s):
filter_string="" for i in s: if i.isalpha(): filter_string+=i if not filter_string: return "" temp=list(filter_string) solution="" while temp: index=255 for i in temp: index=min(ord(i.lower()), index) for i in temp: if ...
def alphabetized(s):
6
64
102
6
0
mwk0408/codewars_solutions
6 kyu/Alphabetized.py
Python
alphabetized
alphabetized
1
19
1
1
5a6900aa7c5b981e7784ed09609ad9dca8509820
bigcode/the-stack
train
0bb56f9241ae0459efa22f61
train
class
class Creds: """ Handles Google Docs credentials and scopes. Can be used to load credentials from a file, save them to a file, to renew them, and to verify their integrity. """ def __init__(self, creds=None): self.SCOPES = ['https://www.googleapis.com/auth/spreadsheets'] self.cr...
class Creds:
""" Handles Google Docs credentials and scopes. Can be used to load credentials from a file, save them to a file, to renew them, and to verify their integrity. """ def __init__(self, creds=None): self.SCOPES = ['https://www.googleapis.com/auth/spreadsheets'] self.creds = creds ...
import json import os.path from google.auth.transport.requests import Request from google.oauth2.credentials import Credentials from google_auth_oauthlib.flow import InstalledAppFlow from google.auth.exceptions import RefreshError class Creds:
47
256
1,070
4
42
Chromeilion/DiscordMovies
discordmovies/outputmodules/googleutils/credentials.py
Python
Creds
Creds
10
138
10
10
6319bec0cbd8c4460f2780c2b8dfe21fa8eba701
bigcode/the-stack
train
28fca2f418256d63d815923a
train
class
class TvStore: def __init__(self, tvdir): self._storedir = tvdir / "ours" def _path(self, cipher): return self._storedir / cipher.name() / f"{cipher.variant_name()}.json" def write(self, cipher, tvs): hexjson.write_using_hex(self._path(cipher), tvs) def iter_read(self, cipher)...
class TvStore:
def __init__(self, tvdir): self._storedir = tvdir / "ours" def _path(self, cipher): return self._storedir / cipher.name() / f"{cipher.variant_name()}.json" def write(self, cipher, tvs): hexjson.write_using_hex(self._path(cipher), tvs) def iter_read(self, cipher): yield...
#!/usr/bin/env python3 # # Copyright 2021 Google LLC # # Use of this source code is governed by an MIT-style # license that can be found in the LICENSE file or at # https://opensource.org/licenses/MIT. import hexjson class TvStore:
60
64
99
4
55
google/hctr2
python/tvstore.py
Python
TvStore
TvStore
12
23
12
12
030900ef93721fee24f79661392befb0a85df96d
bigcode/the-stack
train
3512d8d74a66b0e556d927cb
train
function
def check_error(res, s=''): if (type(res) is int and res < 0): error = res msg = f'Keysight error: {keysightSD1.SD_Error.getErrorMessage(error)} ({error}) {s}' logging.error(msg) return res
def check_error(res, s=''):
if (type(res) is int and res < 0): error = res msg = f'Keysight error: {keysightSD1.SD_Error.getErrorMessage(error)} ({error}) {s}' logging.error(msg) return res
import function for hvi2 downsampler FPGA image from keysight_fpga.sd1.dig_iq import config_channel, \ is_iq_image_loaded, dig_set_lo, dig_set_input_channel, dig_set_downsampler import numpy as np def check_error(res, s=''):
64
64
64
8
55
opietx/core_tools
core_tools/drivers/M3102A.py
Python
check_error
check_error
26
31
26
26
e8cd248edc9c5e4af02d6af10150d1a022a810aa
bigcode/the-stack
train
3edc185c3b75795de7ed4eab
train
class
class line_trace(MultiParameter): """ class that defines the parameter for the measured data. """ def __init__(self, name, instrument, inst_name , raw=False): self.my_instrument = instrument super().__init__(name=inst_name, names = (name +'_ch1', name +'_ch2'), ...
class line_trace(MultiParameter):
""" class that defines the parameter for the measured data. """ def __init__(self, name, instrument, inst_name , raw=False): self.my_instrument = instrument super().__init__(name=inst_name, names = (name +'_ch1', name +'_ch2'), shapes=((1...
_IQ_OUT = 4 IQ_INPUT_SHIFTED_I_OUT = 5 class OPERATION_MODES: """ Modes for operation SOFT_TRG : use software triggers (does call start and trigger in software) ANALOG_TRG : use external triggering (does call start digitizer) HVI_TRG : use HVI for triggering (no calls done) """...
256
256
3,671
7
248
opietx/core_tools
core_tools/drivers/M3102A.py
Python
line_trace
line_trace
84
473
84
84
3979dc39811131f1b9fc19fb655478b4dd4ea300
bigcode/the-stack
train
5907568be982950e90f1cb02
train
class
@dataclass class channel_properties: """ structure to save relevant information about marker data. """ name : str number : int active : bool = False acquisition_mode : MODES = MODES.NORMAL data_mode : DATA_MODE = DATA_MODE.FULL points_per_cycle : int = 1 cycles : int = 0 full...
@dataclass class channel_properties:
""" structure to save relevant information about marker data. """ name : str number : int active : bool = False acquisition_mode : MODES = MODES.NORMAL data_mode : DATA_MODE = DATA_MODE.FULL points_per_cycle : int = 1 cycles : int = 0 full_scale : float = 0 #peak voltage ...
_mode == MODES.NORMAL or properties.points_per_cycle > 1)): n = properties.points_per_cycle shape += (n, ) setpoints += ((tuple(np.linspace(properties.t_measure/n, properties.t_measure, n)), )) self.shapes += (shape, ) ...
75
75
250
7
68
opietx/core_tools
core_tools/drivers/M3102A.py
Python
channel_properties
channel_properties
476
503
476
477
31c9d6d13379b6ed1278413306ccdc1d4795ee1f
bigcode/the-stack
train
283c561ca7cc261cba7ef453
train
class
class OPERATION_MODES: """ Modes for operation SOFT_TRG : use software triggers (does call start and trigger in software) ANALOG_TRG : use external triggering (does call start digitizer) HVI_TRG : use HVI for triggering (no calls done) """ SOFT_TRG = 0 ANALOG_TRG = 1 HVI_...
class OPERATION_MODES:
""" Modes for operation SOFT_TRG : use software triggers (does call start and trigger in software) ANALOG_TRG : use external triggering (does call start digitizer) HVI_TRG : use HVI for triggering (no calls done) """ SOFT_TRG = 0 ANALOG_TRG = 1 HVI_TRG = 2
""" NORMAL = 0 AVERAGE = 1 IQ_DEMODULATION = 2 IQ_DEMOD_I_ONLY = 3 IQ_INPUT_SHIFTED_IQ_OUT = 4 IQ_INPUT_SHIFTED_I_OUT = 5 class OPERATION_MODES:
64
64
92
6
57
opietx/core_tools
core_tools/drivers/M3102A.py
Python
OPERATION_MODES
OPERATION_MODES
58
67
58
58
c94e48a596325ea67d70acb9069e52880c8c0d7c
bigcode/the-stack
train
b93c1af1a83b9dd3e44ef9dc
train
class
class MODES: """ Modes to be operating in: NORMAL : normal / raw data AVERAGE : averaging / downsampling of traces IQ_DEMODULATION : IQ demodulation IQ_DEMOD_I_ONLY : IQ demodulation output I-only IQ_INPUT_SHIFTED_IQ_OUT : IQ input pair (1+2 or 3+4), phase shift and compl...
class MODES:
""" Modes to be operating in: NORMAL : normal / raw data AVERAGE : averaging / downsampling of traces IQ_DEMODULATION : IQ demodulation IQ_DEMOD_I_ONLY : IQ demodulation output I-only IQ_INPUT_SHIFTED_IQ_OUT : IQ input pair (1+2 or 3+4), phase shift and complex output on ...
error: {keysightSD1.SD_Error.getErrorMessage(error)} ({error}) {s}' logging.error(msg) return res """ Minimalistic qcodes driver for the Keysight digizer card (M3102A) Author : Stephan Philips (TuDelft) """ class MODES:
64
64
192
4
60
opietx/core_tools
core_tools/drivers/M3102A.py
Python
MODES
MODES
38
55
38
38
ef44de6fedb2e7a177f1165caf0480cd3a4a17a2
bigcode/the-stack
train
8c568a3661982ce909d3ef1d
train
class
class DATA_MODE: """ Mode of handling data. Determines what will be saved. FULL : no averaging at all, get back full output data AVERAGE_TIME : average on x axis --> average a full trace to a single point AVERAGE_CYCLES : average on y axis --> average over all the iterations AVER...
class DATA_MODE:
""" Mode of handling data. Determines what will be saved. FULL : no averaging at all, get back full output data AVERAGE_TIME : average on x axis --> average a full trace to a single point AVERAGE_CYCLES : average on y axis --> average over all the iterations AVERAGE_TIME_AND_CYCL...
ANALOG_TRG : use external triggering (does call start digitizer) HVI_TRG : use HVI for triggering (no calls done) """ SOFT_TRG = 0 ANALOG_TRG = 1 HVI_TRG = 2 class DATA_MODE:
64
64
139
4
59
opietx/core_tools
core_tools/drivers/M3102A.py
Python
DATA_MODE
DATA_MODE
70
81
70
70
75e1069f37eeb1c21387e42f082a94f168241659
bigcode/the-stack
train
8f2035623542802cd0c286ca
train
class
class SD_DIG(Instrument): """docstring for SD_DIG""" def __init__(self, name, chassis, slot, n_channels = 4): super().__init__(name) """ init keysight digitizer Args: name (str) : name of the digitizer chassis (int) : chassis number slot (int)...
class SD_DIG(Instrument):
"""docstring for SD_DIG""" def __init__(self, name, chassis, slot, n_channels = 4): super().__init__(name) """ init keysight digitizer Args: name (str) : name of the digitizer chassis (int) : chassis number slot (int) : slot in the chassis whe...
@dataclass class channel_properties: """ structure to save relevant information about marker data. """ name : str number : int active : bool = False acquisition_mode : MODES = MODES.NORMAL data_mode : DATA_MODE = DATA_MODE.FULL points_per_cycle : int = 1 cycles : int = 0 full...
256
256
6,072
6
249
opietx/core_tools
core_tools/drivers/M3102A.py
Python
SD_DIG
SD_DIG
506
1,129
506
506
93deefb84b6d2e6f480634f517d5d45f9b288f38
bigcode/the-stack
train
9274d3de5900a79cc3a6a329
train
class
class ConvertEndpointParamsTests(unittest.TestCase): def test_simple(self): assert convert_endpoint_params( { "project_id": [1, 2, 3], "start": datetime.datetime(2015, 5, 18, 10, 15, 1, tzinfo=timezone.utc), "end": datetime.datetime(2015, 5, 19, 10...
class ConvertEndpointParamsTests(unittest.TestCase):
def test_simple(self): assert convert_endpoint_params( { "project_id": [1, 2, 3], "start": datetime.datetime(2015, 5, 18, 10, 15, 1, tzinfo=timezone.utc), "end": datetime.datetime(2015, 5, 19, 10, 15, 1, tzinfo=timezone.utc), } ...
= {"project_id": [p1.id, p2.id]} assert get_snuba_query_args("project.name:{}".format(p1.slug), params) == { "conditions": [["project_id", "=", p1.id]], "filter_keys": {"project_id": [p1.id, p2.id]}, } class ConvertEndpointParamsTests(unittest.TestCase):
78
78
260
9
69
viteksafronov/sentry
tests/sentry/api/test_event_search.py
Python
ConvertEndpointParamsTests
ConvertEndpointParamsTests
1,048
1,076
1,048
1,048
90b013eb4cb74c3186f50ee830612efcf2bc05af
bigcode/the-stack
train
b7459e74d7c1fb5160b13cfc
train
class
class GetReferenceEventConditionsTest(SnubaTestCase, TestCase): def setUp(self): super(GetReferenceEventConditionsTest, self).setUp() self.conditions = {"filter_keys": {"project_id": [self.project.id]}} def test_bad_slug_format(self): with pytest.raises(InvalidSearchQuery): ...
class GetReferenceEventConditionsTest(SnubaTestCase, TestCase):
def setUp(self): super(GetReferenceEventConditionsTest, self).setUp() self.conditions = {"filter_keys": {"project_id": [self.project.id]}} def test_bad_slug_format(self): with pytest.raises(InvalidSearchQuery): get_reference_event_conditions(self.conditions, "lol") def...
_field_alias(self): fields = ["last_seen"] snuba_args = {"orderby": "-last_seen"} result = resolve_field_list(fields, snuba_args) assert result["selected_columns"] == [] assert result["aggregations"] == [ ["max", "timestamp", "last_seen"], ["argMax", ["id"...
255
256
1,391
15
240
viteksafronov/sentry
tests/sentry/api/test_event_search.py
Python
GetReferenceEventConditionsTest
GetReferenceEventConditionsTest
1,239
1,388
1,239
1,239
36d68144eb6b148dca6ae1c357bbed3c89a92bb6
bigcode/the-stack
train
5fe02b1e7ecfc186c6e89410
train
class
class ResolveFieldListTest(unittest.TestCase): def test_non_string_field_error(self): fields = [["any", "thing", "lol"]] with pytest.raises(InvalidSearchQuery) as err: resolve_field_list(fields, {}) assert "Field names" in six.text_type(err) def test_automatic_fields_no_aggr...
class ResolveFieldListTest(unittest.TestCase):
def test_non_string_field_error(self): fields = [["any", "thing", "lol"]] with pytest.raises(InvalidSearchQuery) as err: resolve_field_list(fields, {}) assert "Field names" in six.text_type(err) def test_automatic_fields_no_aggregates(self): fields = ["event.type", "...
): assert convert_endpoint_params( { "project_id": [1, 2, 3], "start": datetime.datetime(2015, 5, 18, 10, 15, 1, tzinfo=timezone.utc), "end": datetime.datetime(2015, 5, 19, 10, 15, 1, tzinfo=timezone.utc), } ) == [ Searc...
255
256
1,413
9
246
viteksafronov/sentry
tests/sentry/api/test_event_search.py
Python
ResolveFieldListTest
ResolveFieldListTest
1,079
1,236
1,079
1,079
7847a37fc9f0a9f96dec57a033ac07e31e2ec946
bigcode/the-stack
train
d878b4fbb7d1c90cab0923ff
train
class
class ParseBooleanSearchQueryTest(unittest.TestCase): def setUp(self): super(ParseBooleanSearchQueryTest, self).setUp() self.term1 = SearchFilter( key=SearchKey(name="user.email"), operator="=", value=SearchValue(raw_value="foo@example.com"), ) sel...
class ParseBooleanSearchQueryTest(unittest.TestCase):
def setUp(self): super(ParseBooleanSearchQueryTest, self).setUp() self.term1 = SearchFilter( key=SearchKey(name="user.email"), operator="=", value=SearchValue(raw_value="foo@example.com"), ) self.term2 = SearchFilter( key=SearchKey(name...
, etc. queries = [ ("random:<hello", self._build_search_filter("random", "=", "<hello")), ("random:<512.1.0", self._build_search_filter("random", "=", "<512.1.0")), ("random:2018-01-01", self._build_search_filter("random", "=", "2018-01-01")), ("random:+7d", self....
255
256
2,106
10
245
viteksafronov/sentry
tests/sentry/api/test_event_search.py
Python
ParseBooleanSearchQueryTest
ParseBooleanSearchQueryTest
566
830
566
566
5138e965eeb92a35011f2ae2f075d471feb20f58
bigcode/the-stack
train
111d7d5e70c64a0ae4012640
train
class
class ParseSearchQueryTest(unittest.TestCase): def test_simple(self): # test with raw search query at the end assert parse_search_query("user.email:foo@example.com release:1.2.1 hello") == [ SearchFilter( key=SearchKey(name="user.email"), operator="=", ...
class ParseSearchQueryTest(unittest.TestCase):
def test_simple(self): # test with raw search query at the end assert parse_search_query("user.email:foo@example.com release:1.2.1 hello") == [ SearchFilter( key=SearchKey(name="user.email"), operator="=", value=SearchValue(raw_value="foo@e...
from __future__ import absolute_import import datetime import pytest import six import unittest from datetime import timedelta from django.utils import timezone from freezegun import freeze_time from sentry.api.event_search import ( convert_endpoint_params, event_search_grammar, get_snuba_query_args, ...
153
256
4,216
9
143
viteksafronov/sentry
tests/sentry/api/test_event_search.py
Python
ParseSearchQueryTest
ParseSearchQueryTest
31
563
31
31
9a1efe06391f6e58a0e046e3e0cda5c3c9b9b881
bigcode/the-stack
train
f186c9e9416fafd4efe1c0ea
train
class
class GetSnubaQueryArgsTest(TestCase): def test_simple(self): assert get_snuba_query_args( "user.email:foo@example.com release:1.2.1 fruit:apple hello", { "project_id": [1, 2, 3], "start": datetime.datetime(2015, 5, 18, 10, 15, 1, tzinfo=timezone.utc),...
class GetSnubaQueryArgsTest(TestCase):
def test_simple(self): assert get_snuba_query_args( "user.email:foo@example.com release:1.2.1 fruit:apple hello", { "project_id": [1, 2, 3], "start": datetime.datetime(2015, 5, 18, 10, 15, 1, tzinfo=timezone.utc), "end": datetime.dateti...
'search' (column 57). This is commonly caused by unmatched-parentheses. Enclose any text in double quotes." ) with pytest.raises(InvalidSearchQuery) as error: parse_search_query( "(user.email:foo@example.com OR user.email:bar@example.com AND user.email:bar@example.com))" ...
256
256
1,908
10
246
viteksafronov/sentry
tests/sentry/api/test_event_search.py
Python
GetSnubaQueryArgsTest
GetSnubaQueryArgsTest
833
1,045
833
833
408e280ba1972a63c1fec0332c74da73e544f0d4
bigcode/the-stack
train
80844670a4d3b4f1ff7364b4
train
class
class YakuhaiOfPlace(Yaku): def __init__(self, yaku_id=None): super(YakuhaiOfPlace, self).__init__(yaku_id) def set_attributes(self): self.tenhou_id = 10 self.name = 'Yakuhai (wind of place)' self.english = 'Value Tiles (Seat)' self.japanese = '自風' self.han_op...
class YakuhaiOfPlace(Yaku):
def __init__(self, yaku_id=None): super(YakuhaiOfPlace, self).__init__(yaku_id) def set_attributes(self): self.tenhou_id = 10 self.name = 'Yakuhai (wind of place)' self.english = 'Value Tiles (Seat)' self.japanese = '自風' self.han_open = 1 self.han_close...
# -*- coding: utf-8 -*- from mahjong.hand_calculating.yaku import Yaku class YakuhaiOfPlace(Yaku):
30
64
129
9
20
paulzzh/mahjong
mahjong/hand_calculating/yaku_list/yakuhai_place.py
Python
YakuhaiOfPlace
YakuhaiOfPlace
5
23
5
6
a0f2dc453407801640f2139418bc32179f081206
bigcode/the-stack
train
b0da08e63ddaf35aadbc9452
train
class
class Test_Rule_Engine_Plugin_Passthrough(session.make_sessions_mixin([('otherrods', 'rods')], []), unittest.TestCase): plugin_name = IrodsConfig().default_rule_engine_plugin def setUp(self): super(Test_Rule_Engine_Plugin_Passthrough, self).setUp() self.admin = self.admin_sessions[0] def ...
class Test_Rule_Engine_Plugin_Passthrough(session.make_sessions_mixin([('otherrods', 'rods')], []), unittest.TestCase):
plugin_name = IrodsConfig().default_rule_engine_plugin def setUp(self): super(Test_Rule_Engine_Plugin_Passthrough, self).setUp() self.admin = self.admin_sessions[0] def tearDown(self): super(Test_Rule_Engine_Plugin_Passthrough, self).tearDown() @unittest.skipIf(plugin_name == ...
from __future__ import print_function import os import sys import mmap if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest from . import session from .. import test from .. import lib from .. import paths from ..configuration import IrodsConfig class Test_Rule_Engine_Plugin_Passth...
104
204
682
34
69
mbwatson/irods
scripts/irods/test/test_rule_engine_plugin_passthrough.py
Python
Test_Rule_Engine_Plugin_Passthrough
Test_Rule_Engine_Plugin_Passthrough
17
75
17
18
c58c19749d82d7cae361b19b198a18159ac2cddc
bigcode/the-stack
train
ae660754e95473079148dd67
train
class
class RRcpp(RPackage): """Seamless R and C++ Integration. The 'Rcpp' package provides R functions as well as C++ classes which; offer a seamless integration of R and C++. Many R data types and objects can be; mapped back and forth to C++ equivalents which facilitates both writing of new; code as we...
class RRcpp(RPackage):
"""Seamless R and C++ Integration. The 'Rcpp' package provides R functions as well as C++ classes which; offer a seamless integration of R and C++. Many R data types and objects can be; mapped back and forth to C++ equivalents which facilitates both writing of new; code as well as easier integratio...
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack.package import * class RRcpp(RPackage):
61
256
1,192
6
55
jeanbez/spack
var/spack/repos/builtin/packages/r-rcpp/package.py
Python
RRcpp
RRcpp
9
47
9
9
3fa03bb899529551f004e03c47d47c9fb525182c
bigcode/the-stack
train
30aa22aaf96c8f324f1e0f22
train
function
def pick_installer(config, default, plugins, question="How would you like to install certificates?"): """Pick installer plugin.""" return pick_plugin( config, default, plugins, question, (interfaces.IInstaller,))
def pick_installer(config, default, plugins, question="How would you like to install certificates?"):
"""Pick installer plugin.""" return pick_plugin( config, default, plugins, question, (interfaces.IInstaller,))
to authenticate and install " "certificates?"): """Pick configurator plugin.""" return pick_plugin( config, default, plugins, question, (interfaces.IAuthenticator, interfaces.IInstaller)) def pick_installer(config, default, plugins, question="How would you li...
64
64
47
22
42
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
pick_installer
pick_installer
27
31
27
28
6b340acdd6fe17dbefbcef43c029c8202a0e3df6
bigcode/the-stack
train
e67704a6a3689d6cef965c83
train
function
def get_unprepared_installer(config, plugins): """ Get an unprepared interfaces.IInstaller object. :param certbot.interfaces.IConfig config: Configuration :param certbot._internal.plugins.disco.PluginsRegistry plugins: All plugins registered as entry points. :returns: Unprepared installer ...
def get_unprepared_installer(config, plugins):
""" Get an unprepared interfaces.IInstaller object. :param certbot.interfaces.IConfig config: Configuration :param certbot._internal.plugins.disco.PluginsRegistry plugins: All plugins registered as entry points. :returns: Unprepared installer plugin or None :rtype: IPlugin or None ...
(interfaces.IInstaller,)) def pick_authenticator( config, default, plugins, question="How would you " "like to authenticate with the ACME CA?"): """Pick authentication plugin.""" return pick_plugin( config, default, plugins, question, (interfaces.IAuthenticator,)) def get_unprepared_i...
71
72
241
10
62
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
get_unprepared_installer
get_unprepared_installer
41
69
41
41
83d8a1dbbf1782f06a40076302a34b4ff2298fdd
bigcode/the-stack
train
244c8d7caebfebdda54454d0
train
function
def choose_plugin(prepared, question): """Allow the user to choose their plugin. :param list prepared: List of `~.PluginEntryPoint`. :param str question: Question to be presented to the user. :returns: Plugin entry point chosen by the user. :rtype: `~.PluginEntryPoint` """ opts = [plugin_...
def choose_plugin(prepared, question):
"""Allow the user to choose their plugin. :param list prepared: List of `~.PluginEntryPoint`. :param str question: Question to be presented to the user. :returns: Plugin entry point chosen by the user. :rtype: `~.PluginEntryPoint` """ opts = [plugin_ep.description_with_name + ...
prepared) plugin_ep = choose_plugin(list(six.itervalues(prepared)), question) if plugin_ep is None: return None return plugin_ep.init() elif len(prepared) == 1: plugin_ep = list(prepared.values())[0] logger.debug("Single candidate plugin: %s", plugin_ep) ...
112
112
376
8
103
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
choose_plugin
choose_plugin
125
162
125
125
0c9203263985f2821c0279afea9b4ee02e0404c2
bigcode/the-stack
train
a40f163f881ccd6e1d627da3
train
function
def record_chosen_plugins(config, plugins, auth, inst): "Update the config entries to reflect the plugins we actually selected." config.authenticator = plugins.find_init(auth).name if auth else None config.installer = plugins.find_init(inst).name if inst else None logger.info("Plugins selected: Authenti...
def record_chosen_plugins(config, plugins, auth, inst):
"Update the config entries to reflect the plugins we actually selected." config.authenticator = plugins.find_init(auth).name if auth else None config.installer = plugins.find_init(inst).name if inst else None logger.info("Plugins selected: Authenticator %s, Installer %s", config.authenticator, ...
n", "dns-google", "dns-linode", "dns-luadns", "dns-nsone", "dns-ovh", "dns-rfc2136", "dns-route53", "dns-sakuracloud"] def record_chosen_plugins(config, plugins, auth, inst):
64
64
84
13
51
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
record_chosen_plugins
record_chosen_plugins
169
174
169
169
75d9df3537ceca8d96967a49fd03028098d01d3c
bigcode/the-stack
train
eda8ab8e76223e9960dc54db
train
function
def set_configurator(previously, now): """ Setting configurators multiple ways is okay, as long as they all agree :param str previously: previously identified request for the installer/authenticator :param str requested: the request currently being processed """ if not now: # we're not a...
def set_configurator(previously, now):
""" Setting configurators multiple ways is okay, as long as they all agree :param str previously: previously identified request for the installer/authenticator :param str requested: the request currently being processed """ if not now: # we're not actually setting anything return...
_configurator_problem("installer", req_inst, plugins) if need_auth and not authenticator: diagnose_configurator_problem("authenticator", req_auth, plugins) record_chosen_plugins(config, plugins, authenticator, installer) return installer, authenticator def set_configurator(previously, now):
64
64
125
9
54
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
set_configurator
set_configurator
240
253
240
240
942f129a26440d6b2e3a8ed481dd3bb21ba5c57b
bigcode/the-stack
train
4bdd17dc55319eccc6aac125
train
function
def cli_plugin_requests(config): """ Figure out which plugins the user requested with CLI and config options :returns: (requested authenticator string or None, requested installer string or None) :rtype: tuple """ req_inst = req_auth = config.configurator req_inst = set_configurator(req_ins...
def cli_plugin_requests(config):
""" Figure out which plugins the user requested with CLI and config options :returns: (requested authenticator string or None, requested installer string or None) :rtype: tuple """ req_inst = req_auth = config.configurator req_inst = set_configurator(req_inst, config.installer) req_auth...
) if need_auth and not authenticator: diagnose_configurator_problem("authenticator", req_auth, plugins) record_chosen_plugins(config, plugins, authenticator, installer) return installer, authenticator def set_configurator(previously, now): """ Setting configurators multiple ways is okay, ...
176
176
588
6
169
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
cli_plugin_requests
cli_plugin_requests
256
308
256
256
36e69ee32f662e959b9effdc548cbc0d025989b1
bigcode/the-stack
train
4cbe2b6ed276bf0390263f00
train
function
def pick_authenticator( config, default, plugins, question="How would you " "like to authenticate with the ACME CA?"): """Pick authentication plugin.""" return pick_plugin( config, default, plugins, question, (interfaces.IAuthenticator,))
def pick_authenticator( config, default, plugins, question="How would you " "like to authenticate with the ACME CA?"):
"""Pick authentication plugin.""" return pick_plugin( config, default, plugins, question, (interfaces.IAuthenticator,))
would you like to install certificates?"): """Pick installer plugin.""" return pick_plugin( config, default, plugins, question, (interfaces.IInstaller,)) def pick_authenticator( config, default, plugins, question="How would you " "like to authenticate with the ACME CA?"):
63
64
55
30
34
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
pick_authenticator
pick_authenticator
34
39
34
36
cd8fb09f2bd4eaabcfcd1e2eee56bf7d6515e306
bigcode/the-stack
train
3f89ad6cb2401879f0c56283
train
function
def choose_configurator_plugins(config, plugins, verb): """ Figure out which configurator we're going to use, modifies config.authenticator and config.installer strings to reflect that choice if necessary. :raises errors.PluginSelectionError if there was a problem :returns: (an `IAuthenticator...
def choose_configurator_plugins(config, plugins, verb):
""" Figure out which configurator we're going to use, modifies config.authenticator and config.installer strings to reflect that choice if necessary. :raises errors.PluginSelectionError if there was a problem :returns: (an `IAuthenticator` or None, an `IInstaller` or None) :rtype: tuple ...
", "dns-digitalocean", "dns-dnsimple", "dns-dnsmadeeasy", "dns-gehirn", "dns-google", "dns-linode", "dns-luadns", "dns-nsone", "dns-ovh", "dns-rfc2136", "dns-route53", "dns-sakuracloud"] def record_chosen_plugins(config, plugins, auth, inst): ...
173
173
577
11
162
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
choose_configurator_plugins
choose_configurator_plugins
177
237
177
177
be63d4a0c1c771ec21db1cf680d5227b5d49c406
bigcode/the-stack
train
230fd5ff1b109948e8b96ced
train
function
def pick_configurator( config, default, plugins, question="How would you like to authenticate and install " "certificates?"): """Pick configurator plugin.""" return pick_plugin( config, default, plugins, question, (interfaces.IAuthenticator, interfaces.IInstaller...
def pick_configurator( config, default, plugins, question="How would you like to authenticate and install " "certificates?"):
"""Pick configurator plugin.""" return pick_plugin( config, default, plugins, question, (interfaces.IAuthenticator, interfaces.IInstaller))
from certbot.compat import os from certbot.display import util as display_util logger = logging.getLogger(__name__) z_util = zope.component.getUtility def pick_configurator( config, default, plugins, question="How would you like to authenticate and install " "certificates?"):
64
64
61
30
33
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
pick_configurator
pick_configurator
17
24
17
20
71fa8cdb2c6ef0bf7f5d1b3a4b5acdb4b45c602a
bigcode/the-stack
train
17afeb1bebe14e291746f74a
train
function
def pick_plugin(config, default, plugins, question, ifaces): """Pick plugin. :param certbot.interfaces.IConfig: Configuration :param str default: Plugin name supplied by user or ``None``. :param certbot._internal.plugins.disco.PluginsRegistry plugins: All plugins registered as entry points. ...
def pick_plugin(config, default, plugins, question, ifaces):
"""Pick plugin. :param certbot.interfaces.IConfig: Configuration :param str default: Plugin name supplied by user or ``None``. :param certbot._internal.plugins.disco.PluginsRegistry plugins: All plugins registered as entry points. :param str question: Question to be presented to the user in...
= installers.verify((interfaces.IInstaller,)) if len(installers) > 1: raise errors.PluginSelectionError( "Found multiple installers with the name %s, Certbot is unable to " "determine which one to use. Skipping." % req_inst) if installers: inst = list(installers.values()...
133
133
445
14
119
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
pick_plugin
pick_plugin
71
122
71
71
2197d660fb9dd97889d16de47504fd882b5117b1
bigcode/the-stack
train
1b49b74d73e8aeb34881d034
train
function
def diagnose_configurator_problem(cfg_type, requested, plugins): """ Raise the most helpful error message about a plugin being unavailable :param str cfg_type: either "installer" or "authenticator" :param str requested: the plugin that was requested :param .PluginsRegistry plugins: available plugin...
def diagnose_configurator_problem(cfg_type, requested, plugins):
""" Raise the most helpful error message about a plugin being unavailable :param str cfg_type: either "installer" or "authenticator" :param str requested: the plugin that was requested :param .PluginsRegistry plugins: available plugins :raises error.PluginSelectionError: if there was a problem...
.dns_route53: req_auth = set_configurator(req_auth, "dns-route53") if config.dns_sakuracloud: req_auth = set_configurator(req_auth, "dns-sakuracloud") logger.debug("Requested authenticator %s and installer %s", req_auth, req_inst) return req_auth, req_inst def diagnose_configurator_problem(c...
87
87
291
12
74
RConn12/certbot
certbot/certbot/_internal/plugins/selection.py
Python
diagnose_configurator_problem
diagnose_configurator_problem
311
338
311
311
3d1b035a188cd164d282e9a5f6efa35a02787136
bigcode/the-stack
train
7a1865d8327e01b6d7c72226
train
class
class ModbusInputRegister(ModbusRegister): def __init__(self, address, value=0, unit=0x01): ModbusRegister.__init__(self, INPUT_REGISTER, address, value=value, unit=unit)
class ModbusInputRegister(ModbusRegister):
def __init__(self, address, value=0, unit=0x01): ModbusRegister.__init__(self, INPUT_REGISTER, address, value=value, unit=unit)
=value class ModbusDiscreteInput(ModbusSingle): def __init__(self, address, value=False, unit=0x01): ModbusSingle.__init__(self, DISCRETE_INPUT, address, value=value, unit=unit) class ModbusInputRegister(ModbusRegister):
64
64
51
10
54
fieldcloud/ModbusService
FlclModbusService/src/FlclModbus/FlclModbusRegister.py
Python
ModbusInputRegister
ModbusInputRegister
113
118
113
115
457e55f1d621facd5cfb28e9f80954d8e60c30da
bigcode/the-stack
train
c123baa6f3e595e8964b10ea
train
class
class ModbusSingle(ModbusData): def __init__(self, type, address, value=False, unit=0x01): ModbusData.__init__(self, type, address, value, unit=0x01)
class ModbusSingle(ModbusData):
def __init__(self, type, address, value=False, unit=0x01): ModbusData.__init__(self, type, address, value, unit=0x01)
return -1 def set_value(self, value): self.bin_value= str(value) if value<=1 else bin(value>>1)+str(value&1) self.bin_value= self.bin_value.lstrip('0b') self.value=value class ModbusSingle(ModbusData):
64
64
50
9
54
fieldcloud/ModbusService
FlclModbusService/src/FlclModbus/FlclModbusRegister.py
Python
ModbusSingle
ModbusSingle
86
90
86
88
2b90877c96decef14aadb59b3e55319fac73a186
bigcode/the-stack
train
a526f14706431247d73f8554
train
class
class ModbusHoldingRegister(ModbusRegister): def __init__(self, address, value=0, unit=0x01): ModbusRegister.__init__(self, HOLDING_REGISTER, address, value=value, unit=unit) def set_bit_value(self, pos, val): p = 0 prev = self.bin_value ...
class ModbusHoldingRegister(ModbusRegister):
def __init__(self, address, value=0, unit=0x01): ModbusRegister.__init__(self, HOLDING_REGISTER, address, value=value, unit=unit) def set_bit_value(self, pos, val): p = 0 prev = self.bin_value new = '' while p < 16: if p...
=unit) class ModbusInputRegister(ModbusRegister): def __init__(self, address, value=0, unit=0x01): ModbusRegister.__init__(self, INPUT_REGISTER, address, value=value, unit=unit) class ModbusHoldingRegister(ModbusRegister):
64
64
143
10
54
fieldcloud/ModbusService
FlclModbusService/src/FlclModbus/FlclModbusRegister.py
Python
ModbusHoldingRegister
ModbusHoldingRegister
121
141
121
123
12c8f1cd0224d13d2e2b054b1e343089306cd6b2
bigcode/the-stack
train
876213c896d8f34fe0fcccda
train
class
class ModbusRegister(ModbusData): def __init__(self, type, address, value=0, unit=0x01): ModbusData.__init__(self, type, address, value, unit=0x01) self.bin_value= str(value) if value<=1 else bin(value>>1)+str(value&1) self.bin_value= self.bin_value.lstrip('0b') def get_bit_at(self,p...
class ModbusRegister(ModbusData):
def __init__(self, type, address, value=0, unit=0x01): ModbusData.__init__(self, type, address, value, unit=0x01) self.bin_value= str(value) if value<=1 else bin(value>>1)+str(value&1) self.bin_value= self.bin_value.lstrip('0b') def get_bit_at(self,pos=0): if pos >= 0 and pos <...
=address self.value=value self.unit=unit self.number=self.address+REGISTER_TYPES.get(type).get('offset') def get_type_description(self): return REGISTER_TYPES.get(self.type) def get_number(self): return self.number class ModbusRegister(ModbusData):
64
64
179
9
54
fieldcloud/ModbusService
FlclModbusService/src/FlclModbus/FlclModbusRegister.py
Python
ModbusRegister
ModbusRegister
63
82
63
65
e1ceca36fda91e737ec167655ac11321d8957aab
bigcode/the-stack
train
e38919a388c7770c89bd0bc0
train
class
class ModbusRegisterFormatter(object): @staticmethod def set_int_in_register(value, register): register.set_value(value) return register @staticmethod def set_int_in_register_list(value, registers): il=int_to_bytes(value, len(registers)) for i in range(0, len(register...
class ModbusRegisterFormatter(object): @staticmethod
def set_int_in_register(value, register): register.set_value(value) return register @staticmethod def set_int_in_register_list(value, registers): il=int_to_bytes(value, len(registers)) for i in range(0, len(registers)): registers[i].value=il[i] return re...
): ModbusRegister.__init__(self, HOLDING_REGISTER, address, value=value, unit=unit) def set_bit_value(self, pos, val): p = 0 prev = self.bin_value new = '' while p < 16: if p == abs(pos-15): v = val ...
127
127
424
12
115
fieldcloud/ModbusService
FlclModbusService/src/FlclModbus/FlclModbusRegister.py
Python
ModbusRegisterFormatter
ModbusRegisterFormatter
144
227
144
147
713e1d35105b83ca9b72645298ecc4d308565463
bigcode/the-stack
train
a991234ecdac70944ce81410
train
class
class ModbusData(object): def __init__(self, type, address, value, unit=0x01): self.type=type self.address=address self.value=value self.unit=unit self.number=self.address+REGISTER_TYPES.get(type).get('offset') def get_type_description(self): return REGISTER_T...
class ModbusData(object):
def __init__(self, type, address, value, unit=0x01): self.type=type self.address=address self.value=value self.unit=unit self.number=self.address+REGISTER_TYPES.get(type).get('offset') def get_type_description(self): return REGISTER_TYPES.get(self.type) de...
ING_REGISTER: { 'offset':40001, 'read_one': 'read_holding_registers', 'write_one': 'write_register', 'read_multi': 'read_holding_registers', 'write_multi': 'write_registers' } } class ModbusData(object):
64
64
90
7
57
fieldcloud/ModbusService
FlclModbusService/src/FlclModbus/FlclModbusRegister.py
Python
ModbusData
ModbusData
44
60
44
46
78a330fd4df9769773676a601cbc165dd9665545
bigcode/the-stack
train
e9592c1e84a9149c5ea84f34
train
class
class ModbusCoil(ModbusSingle): def __init__(self, address, value=False, unit=0x01): ModbusSingle.__init__(self, COIL, address, value=value, unit=unit) def set_value(self, value): self.value=value
class ModbusCoil(ModbusSingle):
def __init__(self, address, value=False, unit=0x01): ModbusSingle.__init__(self, COIL, address, value=value, unit=unit) def set_value(self, value): self.value=value
self.value=value class ModbusSingle(ModbusData): def __init__(self, type, address, value=False, unit=0x01): ModbusData.__init__(self, type, address, value, unit=0x01) class ModbusCoil(ModbusSingle):
64
64
63
10
54
fieldcloud/ModbusService
FlclModbusService/src/FlclModbus/FlclModbusRegister.py
Python
ModbusCoil
ModbusCoil
93
102
93
95
daadcba7805734144d68b75daa2f971cf7039c13
bigcode/the-stack
train
9a25ddbe16c22dfb5d72d534
train
class
class ModbusDiscreteInput(ModbusSingle): def __init__(self, address, value=False, unit=0x01): ModbusSingle.__init__(self, DISCRETE_INPUT, address, value=value, unit=unit)
class ModbusDiscreteInput(ModbusSingle):
def __init__(self, address, value=False, unit=0x01): ModbusSingle.__init__(self, DISCRETE_INPUT, address, value=value, unit=unit)
def __init__(self, address, value=False, unit=0x01): ModbusSingle.__init__(self, COIL, address, value=value, unit=unit) def set_value(self, value): self.value=value class ModbusDiscreteInput(ModbusSingle):
64
64
52
10
53
fieldcloud/ModbusService
FlclModbusService/src/FlclModbus/FlclModbusRegister.py
Python
ModbusDiscreteInput
ModbusDiscreteInput
105
110
105
107
098a0f4c0529d258a4a4ebb30745b9ec49383e28
bigcode/the-stack
train
6cbac7dea2e94876450106c7
train
class
class SVDRecommender: """ Singular Value Decomposition is an important technique used in recommendation systems. Using SVD, the complete utility matrix is decomposed into user and item features. Thus the dimensionality of the matrix is reduced and we get the most important features neglecting the w...
class SVDRecommender:
""" Singular Value Decomposition is an important technique used in recommendation systems. Using SVD, the complete utility matrix is decomposed into user and item features. Thus the dimensionality of the matrix is reduced and we get the most important features neglecting the weaker ones. The ut...
import numpy as np import pandas as pd from .utils import super_str, convert_to_array, special_sort, dissimilarity from math import sqrt class SVDRecommender:
40
256
2,080
7
32
shenghuiliuu/recsys
recsys/recommender/svd.py
Python
SVDRecommender
SVDRecommender
16
291
16
17
5e829ff2ec5a76d9bc026f3857715a04b7b8ecf5
bigcode/the-stack
train
a7b20155a76a6a6432cd6718
train
class
class Transpiler(object): """ Transpiler class We use this class to transpile Akashic rule into the CLIPS rule. """ def __init__(self, env_provider, is_assistance_session=False, debug=True): """ Transpiler constructor method Details ------- 1. Imports created d...
class Transpiler(object):
""" Transpiler class We use this class to transpile Akashic rule into the CLIPS rule. """ def __init__(self, env_provider, is_assistance_session=False, debug=True): """ Transpiler constructor method Details ------- 1. Imports created data_providers. 2. ...
import uuid from os.path import join, dirname from textx import metamodel_from_file, metamodel_from_str from textx.export import metamodel_export, model_export from textx.model import get_model from textx.exceptions import TextXSyntaxError, TextXSemanticError from akashic.arules.variable_table import VariableTable, V...
201
256
14,529
6
194
Akashic-Projects/akashic
akashic/arules/transpiler.py
Python
Transpiler
Transpiler
24
1,945
24
24
35a2b0922082a9a722ca013303be6b69344cebf0
bigcode/the-stack
train
076b6e701a94440105085902
train
class
class MatrixMethods(object): def __init__(ctx): # XXX: subclass ctx.matrix = type('matrix', (_matrix,), {}) ctx.matrix.ctx = ctx ctx.matrix.convert = ctx.convert def eye(ctx, n, **kwargs): """ Create square identity matrix n x n. """ A = ctx.matr...
class MatrixMethods(object):
def __init__(ctx): # XXX: subclass ctx.matrix = type('matrix', (_matrix,), {}) ctx.matrix.ctx = ctx ctx.matrix.convert = ctx.convert def eye(ctx, n, **kwargs): """ Create square identity matrix n x n. """ A = ctx.matrix(n, **kwargs) for i ...
') def __getcols(self): return self.__cols def __setcols(self, value): for key in self.__data.copy(): if key[1] >= value: del self.__data[key] self.__cols = value cols = property(__getcols, __setcols, doc='number of columns') def transpose(self): ...
256
256
2,100
5
250
cap11235/sympy
sympy/mpmath/matrices/matrices.py
Python
MatrixMethods
MatrixMethods
735
989
735
736
2a1649580f0c1b02a110d09e6252589cd18a4858
bigcode/the-stack
train
854275a7b2da516e4da5635c
train
class
class _matrix(object): """ Numerical matrix. Specify the dimensions or the data as a nested list. Elements default to zero. Use a flat list to create a column vector easily. By default, only mpf is used to store the data. You can specify another type using force_type=type. It's possible to...
class _matrix(object):
""" Numerical matrix. Specify the dimensions or the data as a nested list. Elements default to zero. Use a flat list to create a column vector easily. By default, only mpf is used to store the data. You can specify another type using force_type=type. It's possible to specify None. Make...
from ..libmp.backend import xrange # TODO: interpret list as vectors (for multiplication) rowsep = '\n' colsep = ' ' class _matrix(object):
36
256
6,056
5
31
cap11235/sympy
sympy/mpmath/matrices/matrices.py
Python
_matrix
_matrix
8
733
8
8
d6d0fbde83bc070c928c027b522d32d4f61cb3bb
bigcode/the-stack
train
7948066068f4efa229b4702c
train
class
class HDFSDailyCache(FileDailyCache): def __init__(self, hdfs_client:Client, cache_dir:pathlib.Path, data_source:DailyDataSource, cache_date:date=None): assert isinstance(hdfs_client, Client) self.client = hdfs_client super(HDFSDailyCache, self).__init__(cache_dir, data_source, cache_date) ...
class HDFSDailyCache(FileDailyCache):
def __init__(self, hdfs_client:Client, cache_dir:pathlib.Path, data_source:DailyDataSource, cache_date:date=None): assert isinstance(hdfs_client, Client) self.client = hdfs_client super(HDFSDailyCache, self).__init__(cache_dir, data_source, cache_date) def get_data(self) -> Optional[dic...
import json import pathlib from datetime import date from typing import Optional from hdfs import InsecureClient from hdfs import Client from utils.oos.FileDailyCache import FileDailyCache from utils.oos.Server import DailyDataSource class HDFSDailyCache(FileDailyCache):
62
95
317
10
51
IevgenV/edu-robots-dataeng-project
utils/oos/HDFSDailyCache.py
Python
HDFSDailyCache
HDFSDailyCache
13
40
13
14
1ebc5d9c73029a2cfc0c7c4ea72991de9f6bc007
bigcode/the-stack
train
60f31d37c294bc258096b196
train
class
class Karpet: quick_search_data = None def __init__(self, start=None, end=None): """ Constructor. :param datetime.date start: History data begining. :param datetime.date end: History data end. """ self.start = start self.end = end def get_quick_se...
class Karpet:
quick_search_data = None def __init__(self, start=None, end=None): """ Constructor. :param datetime.date start: History data begining. :param datetime.date end: History data end. """ self.start = start self.end = end def get_quick_search_data(self)...
try: from pytrends.request import TrendReq except: pass import asyncio from datetime import date, datetime, timedelta import time import aiohttp from bs4 import BeautifulSoup import numpy as np import pandas as pd import requests import hashlib class Karpet:
63
256
5,299
4
58
HK-Mattew/karpet
karpet/core.py
Python
Karpet
Karpet
18
780
18
19
884328048da33f0eda76f449d954bcd5c6afe2d5
bigcode/the-stack
train
820b2b955f2a3a7282dca940
train
function
def add(x, y): """Add two numbers""" return x + y
def add(x, y):
"""Add two numbers""" return x + y
def add(x, y):
6
64
18
6
0
pyvsc/pyvsc
pyvsc/arith.py
Python
add
add
1
3
1
1
6c66be6f668435c501d5671790f84deee2dcfa47
bigcode/the-stack
train
c2e18b045a37809bccd8259b
train
function
def apply(log, parameters=None): """ Gets the roles (group of different activities done by similar resources) out of the log Parameters ------------- log Log object parameters Possible parameters of the algorithm Returns ------------ roles List of differ...
def apply(log, parameters=None):
""" Gets the roles (group of different activities done by similar resources) out of the log Parameters ------------- log Log object parameters Possible parameters of the algorithm Returns ------------ roles List of different roles inside the log """ ...
py.util import exec_utils from enum import Enum from pm4py.util import constants class Parameters(Enum): ROLES_THRESHOLD_PARAMETER = "roles_threshold_parameter" RESOURCE_KEY = constants.PARAMETER_CONSTANT_RESOURCE_KEY ACTIVITY_KEY = constants.PARAMETER_CONSTANT_ACTIVITY_KEY def apply(log, parameters=None)...
64
64
197
7
56
Malekhy/ws2122-lspm
ws2122-lspm/Lib/site-packages/pm4py/algo/enhancement/roles/variants/log.py
Python
apply
apply
32
59
32
32
2524cbfc40a11e2802de739833cced207ce62864
bigcode/the-stack
train
5d132965e8c4d398f2e5cb4d
train
class
class Parameters(Enum): ROLES_THRESHOLD_PARAMETER = "roles_threshold_parameter" RESOURCE_KEY = constants.PARAMETER_CONSTANT_RESOURCE_KEY ACTIVITY_KEY = constants.PARAMETER_CONSTANT_ACTIVITY_KEY
class Parameters(Enum):
ROLES_THRESHOLD_PARAMETER = "roles_threshold_parameter" RESOURCE_KEY = constants.PARAMETER_CONSTANT_RESOURCE_KEY ACTIVITY_KEY = constants.PARAMETER_CONSTANT_ACTIVITY_KEY
ancement.roles.common import algorithm from pm4py.objects.conversion.log import converter as log_converter from pm4py.util import xes_constants as xes from collections import Counter from pm4py.util import exec_utils from enum import Enum from pm4py.util import constants class Parameters(Enum):
64
64
38
4
59
Malekhy/ws2122-lspm
ws2122-lspm/Lib/site-packages/pm4py/algo/enhancement/roles/variants/log.py
Python
Parameters
Parameters
26
29
26
26
9dfb03dbfb1beb1d5c6c6dc6d3636cb2cb34334d
bigcode/the-stack
train
e60c66d21d9b4ab545ef8591
train
class
class ConvertLike(Op): op = 'ConvertLike' enabled = False def __init__(self, graph: Graph, attrs: dict): mandatory_props = { 'op': self.op, 'type': self.op, 'version': 'opset1', 'infer': copy_shape_infer, 'type_infer': self.type_infer, ...
class ConvertLike(Op):
op = 'ConvertLike' enabled = False def __init__(self, graph: Graph, attrs: dict): mandatory_props = { 'op': self.op, 'type': self.op, 'version': 'opset1', 'infer': copy_shape_infer, 'type_infer': self.type_infer, 'in_ports_co...
# Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from mo.front.common.partial_infer.elemental import copy_shape_infer from mo.graph.graph import Node, Graph from mo.ops.op import Op class ConvertLike(Op):
61
64
180
5
55
monroid/openvino
model-optimizer/extensions/ops/ConvertLike.py
Python
ConvertLike
ConvertLike
9
31
9
9
1638fcda6d56fee4b3566ca9e418cfeeb44bb173
bigcode/the-stack
train
dc9ccd2ff4d624b7611cb96d
train
function
@app.route("/symbol/<symbol>+<trend1>+<trend2>") def results(symbol, trend1, trend2): data = web.DataReader(symbol, data_source='yahoo') data['Trend 1'] = pd.rolling_mean(data['Adj Close'], window=int(trend1)) data['Trend 2'] = pd.rolling_mean(data['Adj Close'], window=int(trend2)) layout = Layout( ...
@app.route("/symbol/<symbol>+<trend1>+<trend2>") def results(symbol, trend1, trend2):
data = web.DataReader(symbol, data_source='yahoo') data['Trend 1'] = pd.rolling_mean(data['Adj Close'], window=int(trend1)) data['Trend 2'] = pd.rolling_mean(data['Adj Close'], window=int(trend2)) layout = Layout( xaxis=XAxis(showgrid=True, gridcolor='#bdbdbd', gridwidth=2), yaxis=YAxis(...
results', symbol=request.form['symbol'], trend1=request.form['trend1'], trend2=request.form['trend2'])) return render_template('selection.html', form=form) @app.route("/symbol/<symbol>+<trend1>+<trend2>") def results(symbol, trend1, trend2):
64
64
210
27
37
yhilpisch/rpi
doc/build/html/_downloads/stock_interactive.py
Python
results
results
57
71
57
58
34f70d71f63ba703498763e2f65d6235986ecb35
bigcode/the-stack
train
deb027b27a37dac7664a0a06
train
function
def df_to_plotly(df): ''' Converting a pandas DataFrame to plotly compatible format. ''' if df.index.__class__.__name__=="DatetimeIndex": x = df.index.format() else: x = df.index.values lines = {} for key in df: lines[key] = {} lines[key]['x'] = x lin...
def df_to_plotly(df):
''' Converting a pandas DataFrame to plotly compatible format. ''' if df.index.__class__.__name__=="DatetimeIndex": x = df.index.format() else: x = df.index.values lines = {} for key in df: lines[key] = {} lines[key]['x'] = x lines[key]['y'] = df[key]...
from plotly.graph_objs import Figure, Layout, XAxis, YAxis from flask import Flask, request, render_template, redirect, url_for from forms import SymbolSearch # # Needed for plotly usage # ply.sign_in('yves', 'token') def df_to_plotly(df):
64
64
120
7
57
yhilpisch/rpi
doc/build/html/_downloads/stock_interactive.py
Python
df_to_plotly
df_to_plotly
25
40
25
25
797f460eaf6ffcd0bd54bc47bfe0891cfb28dfb7
bigcode/the-stack
train