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
7016f1d93edf015dced496de
train
class
class SyncAccountsTask(Task): def __repr__(self): return '<SyncAccountsTask>' def __eq__(self, other): if other.__class__ == self.__class__: return True return False def run(self, sync): app = sync.app with app.db.getSession() as session: for...
class SyncAccountsTask(Task):
def __repr__(self): return '<SyncAccountsTask>' def __eq__(self, other): if other.__class__ == self.__class__: return True return False def run(self, sync): app = sync.app with app.db.getSession() as session: for a in session.getAccounts(): ...
with app.db.getSession() as session: account = session.getAccountByID(remote['id'], remote.get('name'), remote.get('login'), remote.get('email')) session...
64
64
123
6
58
pierreprinetti/hubtty
hubtty/sync.py
Python
SyncAccountsTask
SyncAccountsTask
208
225
208
208
a1adb5b2bbbb4846a093ed99536b2b7531839e2d
bigcode/the-stack
train
c6612c56a56d6e78986cd645
train
class
class ChangeUpdatedEvent(UpdateEvent): def __repr__(self): return '<ChangeUpdatedEvent project_key:%s change_key:%s review_flag_changed:%s status_changed:%s>' % ( self.project_key, self.change_key, self.review_flag_changed, self.status_changed) def __init__(self, change): self.proje...
class ChangeUpdatedEvent(UpdateEvent):
def __repr__(self): return '<ChangeUpdatedEvent project_key:%s change_key:%s review_flag_changed:%s status_changed:%s>' % ( self.project_key, self.change_key, self.review_flag_changed, self.status_changed) def __init__(self, change): self.project_key = change.project.key sel...
def __init__(self, change): self.project_key = change.project.key self.change_key = change.key self.related_change_keys = set() self.review_flag_changed = True self.status_changed = True self.held_changed = False class ChangeUpdatedEvent(UpdateEvent):
64
64
115
7
56
pierreprinetti/hubtty
hubtty/sync.py
Python
ChangeUpdatedEvent
ChangeUpdatedEvent
154
165
154
154
0dc14a4c09c95d08e2a12b3fa44986e787f5e142
bigcode/the-stack
train
654a88f3e2c6efa044689e8e
train
class
class SetSyncQueryUpdatedTask(Task): def __init__(self, query_name, updated, priority=NORMAL_PRIORITY): super(SetSyncQueryUpdatedTask, self).__init__(priority) self.query_name = query_name self.updated = updated def __repr__(self): return '<SetSyncQueryUpdatedTask %s %s>' % (sel...
class SetSyncQueryUpdatedTask(Task):
def __init__(self, query_name, updated, priority=NORMAL_PRIORITY): super(SetSyncQueryUpdatedTask, self).__init__(priority) self.query_name = query_name self.updated = updated def __repr__(self): return '<SetSyncQueryUpdatedTask %s %s>' % (self.query_name, self.updated) def ...
if c['id'] in change_ids or (c['status'] not in CLOSED_STATUSES): sync.submitTask(SyncChangeTask(c['id'], priority=self.priority)) sync.submitTask(SetSyncQueryUpdatedTask(self.query_name, now, priority=self.priority)) class SetSyncQueryUpdatedTask(Task):
64
64
175
8
56
pierreprinetti/hubtty
hubtty/sync.py
Python
SetSyncQueryUpdatedTask
SetSyncQueryUpdatedTask
462
482
462
462
8aae7f1193ff24e37ffd32beadd0bc03f1c4f324
bigcode/the-stack
train
22f95377932bb4d4aed137e6
train
class
class CheckReposTask(Task): # on startup, check all projects # for any subscribed project withot a local repo or if # --fetch-missing-refs is supplied, check all local changes for # missing refs, and sync the associated changes def __repr__(self): return '<CheckReposTask>' def __e...
class CheckReposTask(Task): # on startup, check all projects # for any subscribed project withot a local repo or if # --fetch-missing-refs is supplied, check all local changes for # missing refs, and sync the associated changes
def __repr__(self): return '<CheckReposTask>' def __eq__(self, other): if (other.__class__ == self.__class__): return True return False def run(self, sync): app = sync.app with app.db.getSession() as session: projects = session.getProjects(su...
(url, ref)) repo.fetch(url, ref) class CheckReposTask(Task): # on startup, check all projects # for any subscribed project withot a local repo or if # --fetch-missing-refs is supplied, check all local changes for # missing refs, and sync the associated changes
72
72
240
60
12
pierreprinetti/hubtty
hubtty/sync.py
Python
CheckReposTask
CheckReposTask
950
982
950
954
454dc8cfdee9fdd21b20a883e515fdfd370520af
bigcode/the-stack
train
fed2fa831e47d26ec8f67411
train
class
class UploadReviewTask(Task): def __init__(self, message_key, priority=NORMAL_PRIORITY): super(UploadReviewTask, self).__init__(priority) self.message_key = message_key def __repr__(self): return '<UploadReviewTask %s>' % (self.message_key,) def __eq__(self, other): if (oth...
class UploadReviewTask(Task):
def __init__(self, message_key, priority=NORMAL_PRIORITY): super(UploadReviewTask, self).__init__(priority) self.message_key = message_key def __repr__(self): return '<UploadReviewTask %s>' % (self.message_key,) def __eq__(self, other): if (other.__class__ == self.__class__...
other.revision_key == self.revision_key): return True return False def run(self, sync): app = sync.app with app.db.getSession() as session: revision = session.getCommit(self.revision_key) revision.pending_message = False data = dict(message=r...
185
185
617
6
179
pierreprinetti/hubtty
hubtty/sync.py
Python
UploadReviewTask
UploadReviewTask
1,233
1,309
1,233
1,233
d9fcec0ebd017d1a0eea4509e2d3717c702197c9
bigcode/the-stack
train
98359c79eb8479915d7dc54c
train
class
class SyncProjectListTask(Task): def __repr__(self): return '<SyncProjectListTask>' def __eq__(self, other): if other.__class__ == self.__class__: return True return False def run(self, sync): app = sync.app page = 1 remote = set() remot...
class SyncProjectListTask(Task):
def __repr__(self): return '<SyncProjectListTask>' def __eq__(self, other): if other.__class__ == self.__class__: return True return False def run(self, sync): app = sync.app page = 1 remote = set() remote_keys = set() remote_des...
return False def run(self, sync): app = sync.app with app.db.getSession() as session: for a in session.getAccounts(): remote = sync.get('users/' + a.username) account = session.getAccountByID(remote['id'], ...
84
84
280
7
77
pierreprinetti/hubtty
hubtty/sync.py
Python
SyncProjectListTask
SyncProjectListTask
227
264
227
227
026ad970e1d89e630e1c0adfaa970bfd8afa4a0f
bigcode/the-stack
train
0178d30d66c0e01695df9cbd
train
class
class UpdateEvent(object): def updateRelatedChanges(self, session, change): related_change_keys = set() related_change_keys.add(change.key) for revision in change.revisions: parent = session.getCommitBySha(revision.parent) if parent: related_change_key...
class UpdateEvent(object):
def updateRelatedChanges(self, session, change): related_change_keys = set() related_change_keys.add(change.key) for revision in change.revisions: parent = session.getCommitBySha(revision.parent) if parent: related_change_keys.add(parent.change.key) ...
(item, klass): results.append(item) finally: self.condition.release() return results def complete(self, item): self.condition.acquire() try: if item in self.incomplete: self.incomplete.remove(item) finally: ...
64
64
97
5
59
pierreprinetti/hubtty
hubtty/sync.py
Python
UpdateEvent
UpdateEvent
121
131
121
121
753bf554c54f6647b5ba6cbd79076bbf451cb5f8
bigcode/the-stack
train
97a721e027aab9fcb3b002e1
train
class
class SendCherryPickTask(Task): def __init__(self, cp_key, priority=NORMAL_PRIORITY): super(SendCherryPickTask, self).__init__(priority) self.cp_key = cp_key def __repr__(self): return '<SendCherryPickTask %s>' % (self.cp_key,) def __eq__(self, other): if (other.__class__ =...
class SendCherryPickTask(Task):
def __init__(self, cp_key, priority=NORMAL_PRIORITY): super(SendCherryPickTask, self).__init__(priority) self.cp_key = cp_key def __repr__(self): return '<SendCherryPickTask %s>' % (self.cp_key,) def __eq__(self, other): if (other.__class__ == self.__class__ and ...
== 'NEW': sync.post('changes/%s/restore' % (change.id,), data) elif change.status == 'SUBMITTED': sync.post('changes/%s/submit' % (change.id,), {}) sync.submitTask(SyncChangeTask(change.id, priority=self.priority)) class SendCherryPickTa...
69
69
232
7
62
pierreprinetti/hubtty
hubtty/sync.py
Python
SendCherryPickTask
SendCherryPickTask
1,175
1,201
1,175
1,175
3c7e25a25282cce5b7457d0f1d110037af1fc99e
bigcode/the-stack
train
fddfd95babc31e85e2072a59
train
class
class SyncProjectTask(Task): def __init__(self, project_keys, priority=NORMAL_PRIORITY): super(SyncProjectTask, self).__init__(priority) if type(project_keys) == int: project_keys = [project_keys] self.project_keys = project_keys def __repr__(self): return '<SyncProj...
class SyncProjectTask(Task):
def __init__(self, project_keys, priority=NORMAL_PRIORITY): super(SyncProjectTask, self).__init__(priority) if type(project_keys) == int: project_keys = [project_keys] self.project_keys = project_keys def __repr__(self): return '<SyncProjectTask %s>' % (self.project_...
:i+10], self.priority) self.tasks.append(t) sync.submitTask(t) # t = SyncQueriedChangesTask('owner', 'is:owner', self.priority) # self.tasks.append(t) # sync.submitTask(t) # t = SyncQueriedChangesTask('starred', 'is:starred', self.priority) # self.tasks.ap...
95
95
317
6
89
pierreprinetti/hubtty
hubtty/sync.py
Python
SyncProjectTask
SyncProjectTask
341
377
341
341
7a3aa3b7de7028e615aa2c4600b3c11f8571a433
bigcode/the-stack
train
b49e794ad5084c24e2e3e36e
train
class
class Sync(object): def __init__(self, app, disable_background_sync): self.user_agent = 'Hubtty/%s %s' % (hubtty.version.version_info.release_string(), requests.utils.default_user_agent()) self.offline = False self.account_id = None self.ap...
class Sync(object):
def __init__(self, app, disable_background_sync): self.user_agent = 'Hubtty/%s %s' % (hubtty.version.version_info.release_string(), requests.utils.default_user_agent()) self.offline = False self.account_id = None self.app = app self...
.project.name, change.number, change.status, change.updated)) change_ref = None for revision in change.revisions: if change_ref is None: change_ref = '/'.join(revision.fetch_ref.split('/')[:-1]) self.log.info("Deleting %s ref %s" % ( ...
256
256
1,819
4
252
pierreprinetti/hubtty
hubtty/sync.py
Python
Sync
Sync
1,394
1,606
1,394
1,394
c85b6811a98816ab1ec8046b0ff76aec1149cd76
bigcode/the-stack
train
39c26e3cf3ab0ac7c2b4c696
train
class
class SyncChangeTask(Task): def __init__(self, change_id, force_fetch=False, priority=NORMAL_PRIORITY): super(SyncChangeTask, self).__init__(priority) self.change_id = change_id self.force_fetch = force_fetch def __repr__(self): return '<SyncChangeTask %s>' % (self.change_id,) ...
class SyncChangeTask(Task):
def __init__(self, change_id, force_fetch=False, priority=NORMAL_PRIORITY): super(SyncChangeTask, self).__init__(priority) self.change_id = change_id self.force_fetch = force_fetch def __repr__(self): return '<SyncChangeTask %s>' % (self.change_id,) def __eq__(self, other):...
True return False def run(self, sync): query = '%s' % self.number changes = sync.get('changes/?q=%s' % query) self.log.debug('Query: %s ' % (query,)) for c in changes: task = SyncChangeTask(c['id'], priority=self.priority) self.tasks.append(task) ...
256
256
4,098
6
250
pierreprinetti/hubtty
hubtty/sync.py
Python
SyncChangeTask
SyncChangeTask
557
948
557
557
3ac3fc0489e6d91c5cc117c507b8bdc3bb27db27
bigcode/the-stack
train
de0e5c391c06ccb88094c73f
train
class
class OfflineError(Exception): pass
class OfflineError(Exception):
pass
from six.moves.urllib import parse as urlparse import hubtty.version from hubtty import gitrepo HIGH_PRIORITY=0 NORMAL_PRIORITY=1 LOW_PRIORITY=2 TIMEOUT=30 CLOSED_STATUSES = ['MERGED', 'ABANDONED'] class OfflineError(Exception):
64
64
8
5
59
pierreprinetti/hubtty
hubtty/sync.py
Python
OfflineError
OfflineError
50
51
50
50
d51fc9932ec18f48fda557ca67ac2f95fc975335
bigcode/the-stack
train
099379c81b7a209955d784e5
train
class
class SyncChangesByCommitsTask(Task): def __init__(self, commits, priority=NORMAL_PRIORITY): super(SyncChangesByCommitsTask, self).__init__(priority) self.commits = commits def __repr__(self): return '<SyncChangesByCommitsTask %s>' % (self.commits,) def __eq__(self, other): ...
class SyncChangesByCommitsTask(Task):
def __init__(self, commits, priority=NORMAL_PRIORITY): super(SyncChangesByCommitsTask, self).__init__(priority) self.commits = commits def __repr__(self): return '<SyncChangesByCommitsTask %s>' % (self.commits,) def __eq__(self, other): if (other.__class__ == self.__class__...
other.query_name == self.query_name and other.updated == self.updated): return True return False def run(self, sync): app = sync.app with app.db.getSession() as session: sync_query = session.getSyncQueryByName(self.query_name) syn...
80
80
269
9
70
pierreprinetti/hubtty
hubtty/sync.py
Python
SyncChangesByCommitsTask
SyncChangesByCommitsTask
484
513
484
484
5a6139b74cb3fd4244215f82f76ef6d18733462b
bigcode/the-stack
train
3ef07c3f4029b5b105bcbc00
train
class
class ChangeAddedEvent(UpdateEvent): def __repr__(self): return '<ChangeAddedEvent project_key:%s change_key:%s>' % ( self.project_key, self.change_key) def __init__(self, change): self.project_key = change.project.key self.change_key = change.key self.related_change...
class ChangeAddedEvent(UpdateEvent):
def __repr__(self): return '<ChangeAddedEvent project_key:%s change_key:%s>' % ( self.project_key, self.change_key) def __init__(self, change): self.project_key = change.project.key self.change_key = change.key self.related_change_keys = set() self.review_fla...
_change_keys = related_change_keys class ProjectAddedEvent(UpdateEvent): def __repr__(self): return '<ProjectAddedEvent project_key:%s>' % ( self.project_key,) def __init__(self, project): self.project_key = project.key class ChangeAddedEvent(UpdateEvent):
64
64
97
7
56
pierreprinetti/hubtty
hubtty/sync.py
Python
ChangeAddedEvent
ChangeAddedEvent
141
152
141
141
dfd7d2071adfd237fe7d1d90d6b597934a358a86
bigcode/the-stack
train
d8d973328bcf3a27d5707995
train
class
class SyncChangeByNumberTask(Task): def __init__(self, number, priority=NORMAL_PRIORITY): super(SyncChangeByNumberTask, self).__init__(priority) self.number = number def __repr__(self): return '<SyncChangeByNumberTask %s>' % (self.number,) def __eq__(self, other): if (other...
class SyncChangeByNumberTask(Task):
def __init__(self, number, priority=NORMAL_PRIORITY): super(SyncChangeByNumberTask, self).__init__(priority) self.number = number def __repr__(self): return '<SyncChangeByNumberTask %s>' % (self.number,) def __eq__(self, other): if (other.__class__ == self.__class__ and ...
addCommit(self, commit): if commit in self.commits: return True # 100 should be under the URL length limit if len(self.commits) >= 100: return False self.commits.append(commit) return True class SyncChangeByNumberTask(Task):
64
64
208
8
55
pierreprinetti/hubtty
hubtty/sync.py
Python
SyncChangeByNumberTask
SyncChangeByNumberTask
515
537
515
515
860063d5306a6decf296f738e71afedb919465cd
bigcode/the-stack
train
4c70d2d5abf1727767bac298
train
class
class MultiQueue(object): def __init__(self, priorities): try: self.queues = collections.OrderedDict() except AttributeError: self.queues = ordereddict.OrderedDict() for key in priorities: self.queues[key] = collections.deque() self.condition = thr...
class MultiQueue(object):
def __init__(self, priorities): try: self.queues = collections.OrderedDict() except AttributeError: self.queues = ordereddict.OrderedDict() for key in priorities: self.queues[key] = collections.deque() self.condition = threading.Condition() ...
import dateutil.parser try: import ordereddict except: pass import requests import requests.utils import six from six.moves import queue from six.moves.urllib import parse as urlparse import hubtty.version from hubtty import gitrepo HIGH_PRIORITY=0 NORMAL_PRIORITY=1 LOW_PRIORITY=2 TIMEOUT=30 CLOSED_STATUSES...
105
105
352
5
99
pierreprinetti/hubtty
hubtty/sync.py
Python
MultiQueue
MultiQueue
53
118
53
53
ce9a27a718fdde039e1527e3fbc4915e9e739214
bigcode/the-stack
train
8e400885269861dcee6ed15d
train
class
class SyncOutdatedChangesTask(Task): def __init__(self, priority=NORMAL_PRIORITY): super(SyncOutdatedChangesTask, self).__init__(priority) def __eq__(self, other): if other.__class__ == self.__class__: return True return False def __repr__(self): return '<SyncOu...
class SyncOutdatedChangesTask(Task):
def __init__(self, priority=NORMAL_PRIORITY): super(SyncOutdatedChangesTask, self).__init__(priority) def __eq__(self, other): if other.__class__ == self.__class__: return True return False def __repr__(self): return '<SyncOutdatedChangesTask>' def run(self...
for c in changes: task = SyncChangeTask(c['id'], priority=self.priority) self.tasks.append(task) sync.submitTask(task) self.log.debug("Sync change %s because it is number %s" % (c['id'], self.number)) class SyncOutdatedChangesTask(Task):
64
64
141
8
56
pierreprinetti/hubtty
hubtty/sync.py
Python
SyncOutdatedChangesTask
SyncOutdatedChangesTask
539
555
539
539
d23742e1e1bcafa35ee9e50ebb73c4f42898adc3
bigcode/the-stack
train
2667e0fbee2ffa57db5ae0e0
train
class
class PruneDatabaseTask(Task): def __init__(self, age, priority=NORMAL_PRIORITY): super(PruneDatabaseTask, self).__init__(priority) self.age = age def __repr__(self): return '<PruneDatabaseTask %s>' % (self.age,) def __eq__(self, other): if (other.__class__ == self.__class_...
class PruneDatabaseTask(Task):
def __init__(self, age, priority=NORMAL_PRIORITY): super(PruneDatabaseTask, self).__init__(priority) self.age = age def __repr__(self): return '<PruneDatabaseTask %s>' % (self.age,) def __eq__(self, other): if (other.__class__ == self.__class__ and other.age == ...
change = session.getChangeByID(change_id) change.pending_status = False change.pending_status_message = None sync.post('changes/%s/submit' % (change_id,), {}) sync.submitTask(SyncChangeTask(change_id, priority=self.priority)) class PruneDatabaseTas...
64
64
201
7
57
pierreprinetti/hubtty
hubtty/sync.py
Python
PruneDatabaseTask
PruneDatabaseTask
1,311
1,336
1,311
1,311
d3de386307275c9f6424e9c13e61f04c74c4e4a4
bigcode/the-stack
train
dc43f7377685a7230db337e4
train
class
class SyncProjectBranchesTask(Task): def __init__(self, project_name, priority=NORMAL_PRIORITY): super(SyncProjectBranchesTask, self).__init__(priority) self.project_name = project_name def __repr__(self): return '<SyncProjectBranchesTask %s>' % (self.project_name,) def __eq__(self...
class SyncProjectBranchesTask(Task):
def __init__(self, project_name, priority=NORMAL_PRIORITY): super(SyncProjectBranchesTask, self).__init__(priority) self.project_name = project_name def __repr__(self): return '<SyncProjectBranchesTask %s>' % (self.project_name,) def __eq__(self, other): if (other.__class__...
eq__(self, other): if other.__class__ == self.__class__: return True return False def run(self, sync): app = sync.app with app.db.getSession() as session: projects = session.getProjects(subscribed=True) for p in projects: sync.submitTask(S...
87
87
291
7
80
pierreprinetti/hubtty
hubtty/sync.py
Python
SyncProjectBranchesTask
SyncProjectBranchesTask
282
315
282
282
0a806befe15b91cb98582fd24a23ac2d667b13ef
bigcode/the-stack
train
74e0cf122b9d44de27accf9b
train
function
def test_version() -> None: runner = CliRunner() result = runner.invoke(seaport, ["--version"]) assert result.exit_code == 0 assert result.output == f"seaport, version {__version__}\n"
def test_version() -> None:
runner = CliRunner() result = runner.invoke(seaport, ["--version"]) assert result.exit_code == 0 assert result.output == f"seaport, version {__version__}\n"
from click.testing import CliRunner from seaport import __version__ from seaport.init import seaport def test_version() -> None:
29
64
52
7
21
fossabot/seaport
tests/test_cli.py
Python
test_version
test_version
7
11
7
7
ad90b33a96f54c14a61b314cece497321dce9861
bigcode/the-stack
train
43f887f02445e05cc98394eb
train
function
def test_help() -> None: runner = CliRunner() result = runner.invoke(seaport, ["--help"]) assert result.exit_code == 0 assert "Show this message and exit" in result.output assert "Show the version and exit" in result.output
def test_help() -> None:
runner = CliRunner() result = runner.invoke(seaport, ["--help"]) assert result.exit_code == 0 assert "Show this message and exit" in result.output assert "Show the version and exit" in result.output
.init import seaport def test_version() -> None: runner = CliRunner() result = runner.invoke(seaport, ["--version"]) assert result.exit_code == 0 assert result.output == f"seaport, version {__version__}\n" def test_help() -> None:
64
64
60
7
57
fossabot/seaport
tests/test_cli.py
Python
test_help
test_help
14
19
14
14
24cf52a004bdf253334975d4ac021b482ee45fe7
bigcode/the-stack
train
572ff663873703a9615daf9e
train
function
def basic_sigmoid_test(target): x = 1 expected_output = 0.7310585786300049 test_cases = [ { "name": "datatype_check", "input": [x], "expected": float, "error": "Datatype mismatch." }, { "name": "equation_output_check", ...
def basic_sigmoid_test(target):
x = 1 expected_output = 0.7310585786300049 test_cases = [ { "name": "datatype_check", "input": [x], "expected": float, "error": "Datatype mismatch." }, { "name": "equation_output_check", "input": [x], ...
import numpy as np from test_utils import test def basic_sigmoid_test(target):
18
64
111
7
10
fabiogaiera/neural-networks-deep-learning
W2A1/public_tests.py
Python
basic_sigmoid_test
basic_sigmoid_test
5
23
5
5
9d201be2254edd07f871d92d072420455d9621f1
bigcode/the-stack
train
9d37d78a60245eb90adff352
train
function
def softmax_test(target): x = np.array([[9, 2, 5, 0, 0], [7, 5, 0, 0 ,0]]) expected_output = np.array([[ 9.80897665e-01, 8.94462891e-04, 1.79657674e-02, 1.21052389e-04, 1.21052389e-04], ...
def softmax_test(target):
x = np.array([[9, 2, 5, 0, 0], [7, 5, 0, 0 ,0]]) expected_output = np.array([[ 9.80897665e-01, 8.94462891e-04, 1.79657674e-02, 1.21052389e-04, 1.21052389e-04], [ 8...
"shape_check", "input": [x], "expected": expected_output, "error": "Wrong shape" }, { "name": "equation_output_check", "input": [x], "expected": expected_output, "error": "Wrong output" } ] test(te...
81
83
278
6
75
fabiogaiera/neural-networks-deep-learning
W2A1/public_tests.py
Python
softmax_test
softmax_test
166
197
166
166
1767cc325b6cf9010ab35b70c1d704052efbd5cf
bigcode/the-stack
train
c0cb6442903440eeb774ac0b
train
function
def normalizeRows_test(target): x = np.array([[0, 3, 4], [1, 6, 4]]) expected_output = np.array([[ 0., 0.6, 0.8 ], [ 0.13736056, 0.82416338, 0.54944226]]) test_cases = [ { "name":"datatype_check", "input": [x], ...
def normalizeRows_test(target):
x = np.array([[0, 3, 4], [1, 6, 4]]) expected_output = np.array([[ 0., 0.6, 0.8 ], [ 0.13736056, 0.82416338, 0.54944226]]) test_cases = [ { "name":"datatype_check", "input": [x], "expected": np.ndarray, ...
, "error": "Wrong shape" }, { "name": "equation_output_check", "input": [image], "expected": expected_output, "error": "Wrong output" } ] test(test_cases, target) def normalizeRows_test(target):
64
64
198
6
58
fabiogaiera/neural-networks-deep-learning
W2A1/public_tests.py
Python
normalizeRows_test
normalizeRows_test
137
164
137
137
5f97af97c795d5f99eef16b9498cfae3e2d1cba5
bigcode/the-stack
train
c7a2fc001605e9f790a1e5e2
train
function
def sigmoid_test(target): x = np.array([1, 2, 3]) expected_output = np.array([0.73105858, 0.88079708, 0.95257413]) test_cases = [ { "name":"datatype_check", "input": [x], "expected": np.ndarray, ...
def sigmoid_test(target):
x = np.array([1, 2, 3]) expected_output = np.array([0.73105858, 0.88079708, 0.95257413]) test_cases = [ { "name":"datatype_check", "input": [x], "expected": np.ndarray, "error":"Datatype m...
float, "error": "Datatype mismatch." }, { "name": "equation_output_check", "input": [x], "expected": expected_output, "error": "Wrong output." } ] test(test_cases, target) def sigmoid_test(target):
63
64
165
5
58
fabiogaiera/neural-networks-deep-learning
W2A1/public_tests.py
Python
sigmoid_test
sigmoid_test
25
51
25
25
8b441ffd3b102075603915d73601cfc7ad9fa172
bigcode/the-stack
train
49987fec30a11e4f3d49586f
train
function
def L1_test(target): yhat = np.array([.9, 0.2, 0.1, .4, .9]) y = np.array([1, 0, 0, 1, 1]) expected_output = 1.1 test_cases = [ { "name":"datatype_check", "input": [yhat, y], "expected": float, "error":"The function should return a float." ...
def L1_test(target):
yhat = np.array([.9, 0.2, 0.1, .4, .9]) y = np.array([1, 0, 0, 1, 1]) expected_output = 1.1 test_cases = [ { "name":"datatype_check", "input": [yhat, y], "expected": float, "error":"The function should return a float." }, { ...
, "error": "Wrong shape" }, { "name": "equation_output_check", "input": [x], "expected": expected_output, "error": "Wrong output" } ] test(test_cases, target) def L1_test(target):
64
64
154
6
58
fabiogaiera/neural-networks-deep-learning
W2A1/public_tests.py
Python
L1_test
L1_test
199
218
199
199
bfb7554b862b183b9425220eb877b711336675fe
bigcode/the-stack
train
90a48c64cf1ced8929ecf937
train
function
def L2_test(target): yhat = np.array([.9, 0.2, 0.1, .4, .9]) y = np.array([1, 0, 0, 1, 1]) expected_output = 0.43 test_cases = [ { "name":"datatype_check", "input": [yhat, y], "expected": float, "error":"The function should return a float." ...
def L2_test(target):
yhat = np.array([.9, 0.2, 0.1, .4, .9]) y = np.array([1, 0, 0, 1, 1]) expected_output = 0.43 test_cases = [ { "name":"datatype_check", "input": [yhat, y], "expected": float, "error":"The function should return a float." }, { ...
should return a float." }, { "name": "equation_output_check", "input": [yhat, y], "expected": expected_output, "error": "Wrong output" } ] test(test_cases, target) def L2_test(target):
63
64
154
6
57
fabiogaiera/neural-networks-deep-learning
W2A1/public_tests.py
Python
L2_test
L2_test
220
240
220
220
929cbb1e086642d8a8f650a3cfa6c1eb9b8387af
bigcode/the-stack
train
e52db8cf0319ef495b8f92fe
train
function
def image2vector_test(target): image = np.array([[[ 0.67826139, 0.29380381], [ 0.90714982, 0.52835647], [ 0.4215251 , 0.45017551]], [[ 0.92814219, 0.96677647], [ 0.85304703, 0.52351845], [ 0.19981397, ...
def image2vector_test(target):
image = np.array([[[ 0.67826139, 0.29380381], [ 0.90714982, 0.52835647], [ 0.4215251 , 0.45017551]], [[ 0.92814219, 0.96677647], [ 0.85304703, 0.52351845], [ 0.19981397, 0.27417313]], ...
0.04517666]) test_cases = [ { "name":"datatype_check", "input": [x], "expected": np.ndarray, "error":"The function should return a numpy array." }, { "name": "shape_check", "input": [x], ...
137
137
459
7
130
fabiogaiera/neural-networks-deep-learning
W2A1/public_tests.py
Python
image2vector_test
image2vector_test
83
135
83
83
d7b090ce73c417bcb4f4ea3023d626d80a8575f8
bigcode/the-stack
train
ce9cb314d28d97fcf10810b0
train
function
def sigmoid_derivative_test(target): x = np.array([1, 2, 3]) expected_output = np.array([0.19661193, 0.10499359, 0.04517666]) test_cases = [ { "name":"datatype_check", "input": [x], "expected": np.nda...
def sigmoid_derivative_test(target):
x = np.array([1, 2, 3]) expected_output = np.array([0.19661193, 0.10499359, 0.04517666]) test_cases = [ { "name":"datatype_check", "input": [x], "expected": np.ndarray, "error":"The functi...
error": "Wrong shape." }, { "name": "equation_output_check", "input": [x], "expected": expected_output, "error": "Wrong output." } ] test(test_cases, target) def sigmoid_derivative_test(target):
61
64
172
7
54
fabiogaiera/neural-networks-deep-learning
W2A1/public_tests.py
Python
sigmoid_derivative_test
sigmoid_derivative_test
55
81
55
55
09f07d39939228ba316253db7e1ab5ec39b72f4b
bigcode/the-stack
train
4f5883903cd8c75e95bb4be5
train
function
def image_chosen(request, image_id): image = get_object_or_404(get_image_model(), id=image_id) return render_modal_workflow( request, None, 'wagtailimages/chooser/image_chosen.js', {'image_json': get_image_json(image)} )
def image_chosen(request, image_id):
image = get_object_or_404(get_image_model(), id=image_id) return render_modal_workflow( request, None, 'wagtailimages/chooser/image_chosen.js', {'image_json': get_image_json(image)} )
'uploadform': uploadform, 'searchform': searchform, 'is_searching': False, 'query_string': q, 'will_select_format': request.GET.get('select_format'), 'popular_tags': Image.popular_tags(), }) def image_chosen(request, image_id):
64
64
61
9
55
yohanlebret/wagtail
wagtail/wagtailimages/views/chooser.py
Python
image_chosen
image_chosen
94
100
94
94
8c4d67cb45ea11d81d1b2b425963996576c3a9ec
bigcode/the-stack
train
27cd8d10f6a8af320e0cdf84
train
function
def chooser(request): Image = get_image_model() if permission_policy.user_has_permission(request.user, 'add'): ImageForm = get_image_form(Image) uploadform = ImageForm() else: uploadform = None images = Image.objects.order_by('-created_at') q = None if 'q' in request.G...
def chooser(request):
Image = get_image_model() if permission_policy.user_has_permission(request.user, 'add'): ImageForm = get_image_form(Image) uploadform = ImageForm() else: uploadform = None images = Image.objects.order_by('-created_at') q = None if 'q' in request.GET or 'p' in request.G...
function: given an image, return the json to pass back to the image chooser panel """ preview_image = image.get_rendition('max-165x165') return json.dumps({ 'id': image.id, 'edit_link': reverse('wagtailimages:edit', args=(image.id,)), 'title': image.title, 'preview': { ...
114
114
382
4
110
yohanlebret/wagtail
wagtail/wagtailimages/views/chooser.py
Python
chooser
chooser
40
91
40
40
4af4482bf63aae6d9fa5b15b6ae3933d71f7c2d4
bigcode/the-stack
train
371a718580da3c68d5063b51
train
function
@permission_checker.require('add') def chooser_upload(request): Image = get_image_model() ImageForm = get_image_form(Image) searchform = SearchForm() if request.POST: image = Image(uploaded_by_user=request.user) form = ImageForm(request.POST, request.FILES, instance=image) if ...
@permission_checker.require('add') def chooser_upload(request):
Image = get_image_model() ImageForm = get_image_form(Image) searchform = SearchForm() if request.POST: image = Image(uploaded_by_user=request.user) form = ImageForm(request.POST, request.FILES, instance=image) if form.is_valid(): form.save() # Reindex ...
('select_format'), 'popular_tags': Image.popular_tags(), }) def image_chosen(request, image_id): image = get_object_or_404(get_image_model(), id=image_id) return render_modal_workflow( request, None, 'wagtailimages/chooser/image_chosen.js', {'image_json': get_image_json(image)} ...
89
89
298
12
77
yohanlebret/wagtail
wagtail/wagtailimages/views/chooser.py
Python
chooser_upload
chooser_upload
103
141
103
104
ef0134740e31747350648dfedd55a5ebb3e8a0f7
bigcode/the-stack
train
91e7742aec358f4d46b37b55
train
function
def chooser_select_format(request, image_id): image = get_object_or_404(get_image_model(), id=image_id) if request.POST: form = ImageInsertionForm(request.POST, initial={'alt_text': image.default_alt_text}) if form.is_valid(): format = get_image_format(form.cleaned_data['format']) ...
def chooser_select_format(request, image_id):
image = get_object_or_404(get_image_model(), id=image_id) if request.POST: form = ImageInsertionForm(request.POST, initial={'alt_text': image.default_alt_text}) if form.is_valid(): format = get_image_format(form.cleaned_data['format']) preview_image = image.get_renditio...
get_image_json(image)} ) else: form = ImageForm() images = Image.objects.order_by('title') return render_modal_workflow( request, 'wagtailimages/chooser/chooser.html', 'wagtailimages/chooser/chooser.js', {'images': images, 'uploadform': form, 'searchform': searchfo...
88
88
296
9
79
yohanlebret/wagtail
wagtail/wagtailimages/views/chooser.py
Python
chooser_select_format
chooser_select_format
144
179
144
144
54207f219c451afb70480f72f2736dd69baa0f20
bigcode/the-stack
train
88e3a289f7d6a131d0b9ab1b
train
function
def get_image_json(image): """ helper function: given an image, return the json to pass back to the image chooser panel """ preview_image = image.get_rendition('max-165x165') return json.dumps({ 'id': image.id, 'edit_link': reverse('wagtailimages:edit', args=(image.id,)), ...
def get_image_json(image):
""" helper function: given an image, return the json to pass back to the image chooser panel """ preview_image = image.get_rendition('max-165x165') return json.dumps({ 'id': image.id, 'edit_link': reverse('wagtailimages:edit', args=(image.id,)), 'title': image.title, ...
.models import get_image_model from wagtail.wagtailimages.forms import get_image_form, ImageInsertionForm from wagtail.wagtailimages.formats import get_image_format from wagtail.wagtailimages.permissions import permission_policy permission_checker = PermissionPolicyChecker(permission_policy) def get_image_json(image)...
64
64
120
6
58
yohanlebret/wagtail
wagtail/wagtailimages/views/chooser.py
Python
get_image_json
get_image_json
21
37
21
21
8e6b17ab467ea59f5eb45d320b8cf5008a1cdacb
bigcode/the-stack
train
a957accf444f5b4aeea5d2a3
train
class
class TestAuditConf: @pytest.fixture(autouse=True) def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.usage = ssh_audit.usage self.process_commandline = process_commandline @staticmethod def _test_conf(conf, **kwargs): options = { 'host': ''...
class TestAuditConf: @pytest.fixture(autouse=True)
def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.usage = ssh_audit.usage self.process_commandline = process_commandline @staticmethod def _test_conf(conf, **kwargs): options = { 'host': '', 'port': 22, 'ssh1': True, ...
import pytest from ssh_audit.ssh_audit import process_commandline # pylint: disable=attribute-defined-outside-init class TestAuditConf: @pytest.fixture(autouse=True)
41
256
1,895
14
26
rubo77/ssh-audit
test/test_auditconf.py
Python
TestAuditConf
TestAuditConf
6
198
6
7
c12b126bcbe58772853785c605d5c8759f2be030
bigcode/the-stack
train
b6c138aaefedc6ec190abb24
train
function
def dms2dd_infoaguas(coord_dms): """ Para usar eum uma coluna df.loc[:, 'latitude_dd'] = df['latitude_dms'].astype(str).apply(lambda x: dms2dd(x)) :param coord_dms: :return: """ coord_dms = coord_dms.strip() try: coord_deg = float(coord_dms.split(' ', maxsplit=2)[0])...
def dms2dd_infoaguas(coord_dms):
""" Para usar eum uma coluna df.loc[:, 'latitude_dd'] = df['latitude_dms'].astype(str).apply(lambda x: dms2dd(x)) :param coord_dms: :return: """ coord_dms = coord_dms.strip() try: coord_deg = float(coord_dms.split(' ', maxsplit=2)[0]) coord_min = float(coord_...
/ 60) + (segundos / 3600) # Converter parâmetro textual if direction in ('S', 's', 'O', 'o'): return coord_dm * -1 else: return coord_dm def dms2dd_infoaguas(coord_dms):
64
64
178
12
51
traquitanas/traquitanas
src/traquitanas/geo/converts.py
Python
dms2dd_infoaguas
dms2dd_infoaguas
32
50
32
32
9fcc63c949e74f8dbc01a18ee57af7cda3963c06
bigcode/the-stack
train
7c9e30d564d52ae7cddb8fb9
train
function
def df2geojson(df, lat='latitude', long='longitude', remove_coords_properties=True): """ Convert um dataframe, com colunas de latitude e longitude, em um objeto geojson de pontos https://notebook.community/gnestor/jupyter-renderers/notebooks/nteract/pandas-to-geojson # Usage feature_collectio...
def df2geojson(df, lat='latitude', long='longitude', remove_coords_properties=True):
""" Convert um dataframe, com colunas de latitude e longitude, em um objeto geojson de pontos https://notebook.community/gnestor/jupyter-renderers/notebooks/nteract/pandas-to-geojson # Usage feature_collection = dataframe2geojson(df, lat='latitude_dd', long='longitude_dd', remove_coords_proper...
: coord_deg = float(coord_dms.split(' ', maxsplit=2)[0]) coord_min = float(coord_dms.split(' ', maxsplit=2)[1]) coord_sec = float(coord_dms.split(' ', maxsplit=2)[2]) coord_dd = coord_deg + (coord_min / 60) + (coord_sec / 3600) coord_dd = coord_dd * -1 except: ...
123
123
411
20
102
traquitanas/traquitanas
src/traquitanas/geo/converts.py
Python
df2geojson
df2geojson
53
102
53
53
23d878f7e1cecdfa0bf24926edb171440f1390ca
bigcode/the-stack
train
81ad46a45f73516eff350630
train
function
def dms2dd(coord): """ Convert geographic coordinates in format degrees, minutes and seconds (23°06’12,48”S) in decimal degrees (e.g. -23.10346666666667) Estilo Informações Técnicas CETESB :param coord: string 23°06’12,48”S :return: float -23.10346666666667 """ # Splitar...
def dms2dd(coord):
""" Convert geographic coordinates in format degrees, minutes and seconds (23°06’12,48”S) in decimal degrees (e.g. -23.10346666666667) Estilo Informações Técnicas CETESB :param coord: string 23°06’12,48”S :return: float -23.10346666666667 """ # Splitar coordenada gra...
import random import requests def dms2dd(coord):
13
74
247
7
5
traquitanas/traquitanas
src/traquitanas/geo/converts.py
Python
dms2dd
dms2dd
5
29
5
5
3d9e83a547b343366664f97274a71bbaf1e9f128
bigcode/the-stack
train
0dd0e7e14f5bea7f264072d5
train
function
def test_additional_properties_schema(): response = client.get("/openapi.json") assert response.status_code == 200 assert response.json() == openapi_schema
def test_additional_properties_schema():
response = client.get("/openapi.json") assert response.status_code == 200 assert response.json() == openapi_schema
type": "object", "properties": { "detail": { "title": "Detail", "type": "array", "items": {"$ref": "#/components/schemas/ValidationError"}, } }, }, } },...
64
64
36
7
57
jfunez/fastapi
tests/test_additional_properties.py
Python
test_additional_properties_schema
test_additional_properties_schema
101
104
101
101
e5dbf33b2bd8e3f282693d2311f7ef5139d36851
bigcode/the-stack
train
a61be465be89971051ddeada
train
function
def test_additional_properties_post(): response = client.post("/foo", json={"items": {"foo": 1, "bar": 2}}) assert response.status_code == 200 assert response.json() == {"foo": 1, "bar": 2}
def test_additional_properties_post():
response = client.post("/foo", json={"items": {"foo": 1, "bar": 2}}) assert response.status_code == 200 assert response.json() == {"foo": 1, "bar": 2}
": "#/components/schemas/ValidationError"}, } }, }, } }, } def test_additional_properties_schema(): response = client.get("/openapi.json") assert response.status_code == 200 assert response.json() == openapi_schema def test_additional_properties_...
64
64
58
7
56
jfunez/fastapi
tests/test_additional_properties.py
Python
test_additional_properties_post
test_additional_properties_post
107
110
107
107
2453305817e133688ae99b50207e867fbbc57c61
bigcode/the-stack
train
01f15d7a7933701efb24de85
train
function
@app.post("/foo") def foo(items: Items): return items.items
@app.post("/foo") def foo(items: Items):
return items.items
from typing import Dict from fastapi import FastAPI from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() class Items(BaseModel): items: Dict[str, int] @app.post("/foo") def foo(items: Items):
58
64
16
11
47
jfunez/fastapi
tests/test_additional_properties.py
Python
foo
foo
14
16
14
15
43e1118a10ba6a02133cce3f77d62b539f17e1dc
bigcode/the-stack
train
f0eed9d355ae3ceffc30483e
train
class
class Items(BaseModel): items: Dict[str, int]
class Items(BaseModel):
items: Dict[str, int]
from typing import Dict from fastapi import FastAPI from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() class Items(BaseModel):
39
64
13
5
34
jfunez/fastapi
tests/test_additional_properties.py
Python
Items
Items
10
11
10
10
9210bdc3db33023d7def3b754f9c2229bac8f0bf
bigcode/the-stack
train
b0cdd3289cb1d537df91d9a3
train
function
def patched_prompt(questions, text, **kwargs): """Create a prompt where the input and output are predefined.""" inp = create_pipe_input() try: # noinspection PyUnresolvedReferences inp.send_text(text) result = prompt(questions, input=inp, output=DummyOutput(), **kwargs) ret...
def patched_prompt(questions, text, **kwargs):
"""Create a prompt where the input and output are predefined.""" inp = create_pipe_input() try: # noinspection PyUnresolvedReferences inp.send_text(text) result = prompt(questions, input=inp, output=DummyOutput(), **kwargs) return result finally: inp.close()
.sleep(sleep_time)) result = loop.run_until_complete(future_result) else: for text in texts: inp.send_text(text) result = application.unsafe_ask() return result, application finally: inp.close() def patched_prompt(questions, text, **kwargs...
64
64
79
11
53
qualichat/questionary
tests/utils.py
Python
patched_prompt
patched_prompt
68
80
68
68
c2902e7c781c62816d21c5e86b5b932564002690
bigcode/the-stack
train
5f1dee47adee19df18f1fc22
train
function
def feed_cli_with_input(_type, message, texts, sleep_time=1, **kwargs): """ Create a Prompt, feed it with the given user input and return the CLI object. You an provide multiple texts, the feeder will async sleep for `sleep_time` This returns a (result, Application) tuple. """ if not isin...
def feed_cli_with_input(_type, message, texts, sleep_time=1, **kwargs):
""" Create a Prompt, feed it with the given user input and return the CLI object. You an provide multiple texts, the feeder will async sleep for `sleep_time` This returns a (result, Application) tuple. """ if not isinstance(texts, list): texts = [texts] inp = create_pipe_inpu...
ESCAPE = "\x1b" CONTROLC = "\x03" BACK = "\x7f" SPACE = " " TAB = "\x09" ONE = "1" TWO = "2" THREE = "3" def feed_cli_with_input(_type, message, texts, sleep_time=1, **kwargs):
76
76
256
20
56
qualichat/questionary
tests/utils.py
Python
feed_cli_with_input
feed_cli_with_input
28
65
28
28
83604aff582c23aa9a82523099a97c6b4af349b6
bigcode/the-stack
train
ce83908ff829a8bacfac6067
train
class
class KeyInputs: DOWN = "\x1b[B" UP = "\x1b[A" LEFT = "\x1b[D" RIGHT = "\x1b[C" ENTER = "\r" ESCAPE = "\x1b" CONTROLC = "\x03" BACK = "\x7f" SPACE = " " TAB = "\x09" ONE = "1" TWO = "2" THREE = "3"
class KeyInputs:
DOWN = "\x1b[B" UP = "\x1b[A" LEFT = "\x1b[D" RIGHT = "\x1b[C" ENTER = "\r" ESCAPE = "\x1b" CONTROLC = "\x03" BACK = "\x7f" SPACE = " " TAB = "\x09" ONE = "1" TWO = "2" THREE = "3"
# -*- coding: utf-8 -*- import asyncio from prompt_toolkit.input.defaults import create_pipe_input from prompt_toolkit.output import DummyOutput from questionary import prompt from questionary.prompts import prompt_by_name from questionary.utils import is_prompt_toolkit_3 class KeyInputs:
63
64
102
4
58
qualichat/questionary
tests/utils.py
Python
KeyInputs
KeyInputs
12
25
12
12
555b2e6e31ac27bf70832360007151aae4e1bc43
bigcode/the-stack
train
fe0d55f986db651a9fa33158
train
class
class CreateAgentConfigMap(base.BaseTestCase): def test_create_agent_config_map_succeeds(self): self.assertTrue(ovs_neutron_agent.create_agent_config_map(cfg.CONF)) def test_create_agent_config_map_fails_for_invalid_tunnel_config(self): # An ip address is required for tunneling but there is no...
class CreateAgentConfigMap(base.BaseTestCase):
def test_create_agent_config_map_succeeds(self): self.assertTrue(ovs_neutron_agent.create_agent_config_map(cfg.CONF)) def test_create_agent_config_map_fails_for_invalid_tunnel_config(self): # An ip address is required for tunneling but there is no default, # verify this for both gre and...
neutron.agent.linux import async_process from neutron.agent.linux import ip_lib from neutron.agent.linux import ovs_lib from neutron.agent.linux import utils from neutron.common import constants as n_const from neutron.openstack.common import log from neutron.plugins.common import constants as p_const from neutron.plu...
187
187
625
10
177
armando-migliaccio/neutron-1
neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py
Python
CreateAgentConfigMap
CreateAgentConfigMap
44
94
44
45
176dd7dba60c5d9ce32823473b27f27cad407631
bigcode/the-stack
train
cad9ffad2c6adf4ea7fcbf66
train
class
class TestOvsNeutronAgent(base.BaseTestCase): def setUp(self): super(TestOvsNeutronAgent, self).setUp() notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() notifier_cls.return_value = self.notifier cfg.CONF.set_default('fir...
class TestOvsNeutronAgent(base.BaseTestCase):
def setUp(self): super(TestOvsNeutronAgent, self).setUp() notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() notifier_cls.return_value = self.notifier cfg.CONF.set_default('firewall_driver', 'ne...
unnel_type(self): cfg.CONF.set_override('tunnel_types', ['foobar'], group='AGENT') with testtools.ExpectedException(ValueError): ovs_neutron_agent.create_agent_config_map(cfg.CONF) def test_create_agent_config_map_multiple_tunnel_types(self): cfg.CONF.set_override('local_ip', '1...
256
256
13,959
12
244
armando-migliaccio/neutron-1
neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py
Python
TestOvsNeutronAgent
TestOvsNeutronAgent
97
1,387
97
98
43f82150ec39e72eb06ec5e65dba39f9649afb46
bigcode/the-stack
train
4f008d0d662d4f8731bdbe86
train
class
class AncillaryBridgesTest(base.BaseTestCase): def setUp(self): super(AncillaryBridgesTest, self).setUp() notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() notifier_cls.return_value = self.notifier cfg.CONF.set_default('f...
class AncillaryBridgesTest(base.BaseTestCase):
def setUp(self): super(AncillaryBridgesTest, self).setUp() notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() notifier_cls.return_value = self.notifier cfg.CONF.set_default('firewall_driver', 'n...
try: self.agent.daemon_loop() except Exception: pass scan_ports.assert_has_calls([ mock.call(set(), set()), mock.call(set(), set()) ]) process_network_ports.assert_has_calls([ mock.call({'current': set(['tap0']), ...
168
168
560
11
157
armando-migliaccio/neutron-1
neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py
Python
AncillaryBridgesTest
AncillaryBridgesTest
1,390
1,444
1,390
1,391
cf71f9ef7f9349bc6280dd283a01f2159058e786
bigcode/the-stack
train
7ceac00511b7f64ce6ac95c2
train
function
def getting_cytoact() : cytoact_file = open("TCGA_methylation_cowork_1.txt", 'r') header = cytoact_file.readline().split() # header 읽기 id_posit = header.index("id") # sample ID positioning cytoact_posit = header.index("CytAct") # CytAct positioning cytodata = cytoact_file.readlines() # 데이터 테이블 통째로 ...
def getting_cytoact() :
cytoact_file = open("TCGA_methylation_cowork_1.txt", 'r') header = cytoact_file.readline().split() # header 읽기 id_posit = header.index("id") # sample ID positioning cytoact_posit = header.index("CytAct") # CytAct positioning cytodata = cytoact_file.readlines() # 데이터 테이블 통째로 읽어들임 cytoact_file.cl...
from scipy import stats import numpy as np betavalue_arr = [] cytoact_arr = [] probe_name = [] sample_id = [] start_number = 432000 SEP_NAME = ".SEP_8.2." probe_count = 6000 sample_count = 0 probe_separation_number = 1000 probe_iteration = 0 #######################################################################...
86
86
289
7
78
JoonHyeongPark/IMMethyl
CpG site Correlation/Separation Version/P_Code_Server8_PANCANCER_2.py
Python
getting_cytoact
getting_cytoact
26
49
26
26
c80fa1cd1c494b0cbe29dccf7c792b26c5a8bcfa
bigcode/the-stack
train
e3bfe22d6babdfe37702ca0a
train
function
def mean(x): sum = 0.0 for i in x: sum += i return sum / len(x)
def mean(x):
sum = 0.0 for i in x: sum += i return sum / len(x)
("CytAct_Completed") ###################################################################################################################################################### def reset_betavalue() : del betavalue_arr[:] for reset_x in range(0, probe_separation_number) : betavalue_arr.append({}) ret...
64
64
30
4
59
JoonHyeongPark/IMMethyl
CpG site Correlation/Separation Version/P_Code_Server8_PANCANCER_2.py
Python
mean
mean
68
71
68
68
a7abfee7acea7d0fc83e3fb8dce751b8059d3199
bigcode/the-stack
train
fcf4d74844249fa8a9bf461b
train
function
def getting_betavalue(name) : tumor_pearson_output = open(name + SEP_NAME + "Tumor_Cor_CpGsite&CytAct_pearson.txt", 'w'); tumor_spearman_output = open(name + SEP_NAME + ".Tumor_Cor_CpGSite&CytAct_spearman.txt", 'w') tumor_pearson_output.write("CpGsite\t%s\tP_value\n" % name); tumor_spearman_output.write("C...
def getting_betavalue(name) :
tumor_pearson_output = open(name + SEP_NAME + "Tumor_Cor_CpGsite&CytAct_pearson.txt", 'w'); tumor_spearman_output = open(name + SEP_NAME + ".Tumor_Cor_CpGSite&CytAct_spearman.txt", 'w') tumor_pearson_output.write("CpGsite\t%s\tP_value\n" % name); tumor_spearman_output.write("CpGsite\t%s\tP_value\n" % name) ...
return; ###################################################################################################################################################### getting_cytoact() print("CytAct_Completed") #################################################################################################################...
256
256
1,345
10
245
JoonHyeongPark/IMMethyl
CpG site Correlation/Separation Version/P_Code_Server8_PANCANCER_2.py
Python
getting_betavalue
getting_betavalue
90
195
90
91
607e9bfcbd2419a4334de7141d7c98a40468db6c
bigcode/the-stack
train
fc4d39154c770eca23c6a1e7
train
function
def sampleStandardDeviation(x): sumv = 0.0 for i in x: sumv += (i - mean(x)) ** 2 return math.sqrt(sumv / (len(x) - 1))
def sampleStandardDeviation(x):
sumv = 0.0 for i in x: sumv += (i - mean(x)) ** 2 return math.sqrt(sumv / (len(x) - 1))
in range(0, probe_separation_number) : betavalue_arr.append({}) return ###################################################################################################################################################### import math def mean(x): sum = 0.0 for i in x: sum += i return sum / len(x...
63
64
50
6
57
JoonHyeongPark/IMMethyl
CpG site Correlation/Separation Version/P_Code_Server8_PANCANCER_2.py
Python
sampleStandardDeviation
sampleStandardDeviation
73
77
73
73
996489af69ec6300e00f13650309c17bcb1f0247
bigcode/the-stack
train
8df5b55544ce2fd8fcbef8db
train
function
def reset_betavalue() : del betavalue_arr[:] for reset_x in range(0, probe_separation_number) : betavalue_arr.append({}) return
def reset_betavalue() :
del betavalue_arr[:] for reset_x in range(0, probe_separation_number) : betavalue_arr.append({}) return
posit].replace('_', '')) cytoact_arr[sample_posit] = float(line[cytoact_posit]) # 저장한다 return; ###################################################################################################################################################### getting_cytoact() print("CytAct_Completed") ###########...
64
64
42
9
54
JoonHyeongPark/IMMethyl
CpG site Correlation/Separation Version/P_Code_Server8_PANCANCER_2.py
Python
reset_betavalue
reset_betavalue
58
63
58
59
2928e08bf2253ca01925a2ace43fc5a1497c61ec
bigcode/the-stack
train
ea3fae9753f9cf145e3f7911
train
function
def pearson(x, y): scorex = [] scorey = [] for i in x: scorex.append((i - mean(x)) / sampleStandardDeviation(x)) for j in y: scorey.append((j - mean(y)) / sampleStandardDeviation(y)) return (sum([i * j for i, j in zip(scorex, scorey)])) / (len(x) - 1)
def pearson(x, y):
scorex = [] scorey = [] for i in x: scorex.append((i - mean(x)) / sampleStandardDeviation(x)) for j in y: scorey.append((j - mean(y)) / sampleStandardDeviation(y)) return (sum([i * j for i, j in zip(scorex, scorey)])) / (len(x) - 1)
return sum / len(x) def sampleStandardDeviation(x): sumv = 0.0 for i in x: sumv += (i - mean(x)) ** 2 return math.sqrt(sumv / (len(x) - 1)) def pearson(x, y):
64
64
90
7
57
JoonHyeongPark/IMMethyl
CpG site Correlation/Separation Version/P_Code_Server8_PANCANCER_2.py
Python
pearson
pearson
79
86
79
79
4c795a25889c97be61e5a7589c31d1b7e1e15cc6
bigcode/the-stack
train
d63c91f4c1dcf97d3b7f049d
train
function
def process(cancer_name) : reset_betavalue() getting_betavalue(cancer_name) return
def process(cancer_name) :
reset_betavalue() getting_betavalue(cancer_name) return
paration_number print(i, probe_separation_number, "We are processing %s" % SEP_NAME) input_file1.close(); #input_file2.close() tumor_pearson_output.close(); tumor_spearman_output.close() return def process(cancer_name) :
64
64
29
8
55
JoonHyeongPark/IMMethyl
CpG site Correlation/Separation Version/P_Code_Server8_PANCANCER_2.py
Python
process
process
197
202
197
198
de19583d9f69c1bf11854bff69be6d18d6456019
bigcode/the-stack
train
5759ff9a0101c55f3ca9eb51
train
function
def send_qotd_request(position_list : df,question_user_id : int, g_id : int, g_name : str,total_react_list : List[int]): if 'player_d_id' not in position_list or 'player_position' not in position_list: raise ValueError("player_d_id and player_position need to exist in Dataframe.") send_dict = {'result' ...
def send_qotd_request(position_list : df,question_user_id : int, g_id : int, g_name : str,total_react_list : List[int]):
if 'player_d_id' not in position_list or 'player_position' not in position_list: raise ValueError("player_d_id and player_position need to exist in Dataframe.") send_dict = {'result' : []} for p in position_list.iterrows(): p = p[1] send_dict['result'].append([int(p.player_d_id),int(...
as df import requests import json from typing import List from BotIntercom.settings import port,qotd_post,punisher_post def send_qotd_request(position_list : df,question_user_id : int, g_id : int, g_name : str,total_react_list : List[int]):
64
64
207
34
29
MarcoMuellner/BotIntercom
commands.py
Python
send_qotd_request
send_qotd_request
8
23
8
8
d8bb03a73f4f331ae62a474d6bd0973f9ee51bce
bigcode/the-stack
train
52a810d9d8835f7f51ae1a6f
train
function
def send_punisher_request(player_id : int, punisher_points : int , g_id : int, g_name : str,undo=False): send_dict = {} send_dict['player_id'] = player_id send_dict['punisher_points'] = punisher_points send_dict['guild_id'] = g_id send_dict['guild_name'] = g_name send_dict['post_source'] = punis...
def send_punisher_request(player_id : int, punisher_points : int , g_id : int, g_name : str,undo=False):
send_dict = {} send_dict['player_id'] = player_id send_dict['punisher_points'] = punisher_points send_dict['guild_id'] = g_id send_dict['guild_name'] = g_name send_dict['post_source'] = punisher_post send_dict['undo'] = undo try: r = requests.post(f'http://localhost:{port}',data=...
= total_react_list try: r = requests.post(f'http://localhost:{port}',data=json.dumps(send_dict)) except: pass def send_punisher_request(player_id : int, punisher_points : int , g_id : int, g_name : str,undo=False):
64
64
130
30
33
MarcoMuellner/BotIntercom
commands.py
Python
send_punisher_request
send_punisher_request
26
37
26
26
003ea14f6d1209201bda8f4acc6fc1ea225a6faa
bigcode/the-stack
train
37462a63a49a3a1176a8ead2
train
class
class SRRes(nn.Module): def __init__(self, wkdim=64, num_block=16): super(SRRes, self).__init__() self.head = nn.Sequential(nn.Conv2d(3, wkdim, 3, 1, 1), nn.PReLU(), nn.Conv2d(wkdim, wkdim, 3, 1,1)) self.resblock = sel...
class SRRes(nn.Module):
def __init__(self, wkdim=64, num_block=16): super(SRRes, self).__init__() self.head = nn.Sequential(nn.Conv2d(3, wkdim, 3, 1, 1), nn.PReLU(), nn.Conv2d(wkdim, wkdim, 3, 1,1)) self.resblock = self._make_resblocks(wkdim, ...
self, indim=64, scale=2): super(UPN, self).__init__() self.conv = nn.Conv2d(indim, indim*(scale**2), 3, 1, 1) self.Upsample = nn.PixelShuffle(scale) self.active = nn.PReLU() def forward(self, input): current = self.conv(input) current = self.Upsample(current)...
109
109
365
6
102
huang-junhong/SIRSRGAN
unit.py
Python
SRRes
SRRes
36
68
36
36
9e596078a4ed3e1b533d7386d23cf87e109be0a3
bigcode/the-stack
train
3023d9d370f551f5a2c6098f
train
class
class Stander_Discriminator(nn.Module): def __init__(self): super(Stander_Discriminator,self).__init__() self.layer_1 = nn.Sequential(nn.Conv2d(3, 64, 3, 1, 1), nn.PReLU(), nn.Conv2d(64, 64, 4, 2, 1), ...
class Stander_Discriminator(nn.Module):
def __init__(self): super(Stander_Discriminator,self).__init__() self.layer_1 = nn.Sequential(nn.Conv2d(3, 64, 3, 1, 1), nn.PReLU(), nn.Conv2d(64, 64, 4, 2, 1), nn.InstanceNorm2d(64), ...
dim, 3, 1, 1), nn.PReLU(), nn.Conv2d(wkdim, 3, 3, 1, 1)) def _make_resblocks(self, wkdim, num_block): layers = [] for i in range(1, num_block+1): layers.append(ResUnit(wkdim=wkdim)) return nn...
181
181
604
8
172
huang-junhong/SIRSRGAN
unit.py
Python
Stander_Discriminator
Stander_Discriminator
71
119
71
71
f61c8d7cf252eb3eb7cdb7f73975b8edf19b51b8
bigcode/the-stack
train
23a84153d815bc13400a15a5
train
class
class Stander_Ranker(nn.Module): def __init__(self): super(Stander_Ranker,self).__init__() self.layer_1 = nn.Sequential(nn.Conv2d(3, 64, 3, 1, 1), nn.PReLU(), nn.Conv2d(64, 64, 4, 2, 1), ...
class Stander_Ranker(nn.Module):
def __init__(self): super(Stander_Ranker,self).__init__() self.layer_1 = nn.Sequential(nn.Conv2d(3, 64, 3, 1, 1), nn.PReLU(), nn.Conv2d(64, 64, 4, 2, 1), nn.InstanceNorm2d(64), ...
nn.PReLU(), nn.Conv2d(512, 512, 3, 1, 1), nn.PReLU(), nn.Conv2d(512, 512, 3, 1, 1), nn.AdaptiveAvgPool2d((1,1)), nn.Conv2d(512, 5...
183
183
610
8
174
huang-junhong/SIRSRGAN
unit.py
Python
Stander_Ranker
Stander_Ranker
121
170
121
121
8bf00b060f3c03307b5bda6f43a9ac637b3cc258
bigcode/the-stack
train
e3b658c59a4b2d881420b376
train
class
class ResUnit(nn.Module): def __init__(self, ksize=3, wkdim=64): super(ResUnit, self).__init__() self.conv1 = nn.Conv2d(wkdim, wkdim, ksize, 1, int(ksize/2)) self.active = nn.PReLU() self.conv2 = nn.Conv2d(wkdim, wkdim, ksize, 1, int(ksize/2)) def forward(self, input): ...
class ResUnit(nn.Module):
def __init__(self, ksize=3, wkdim=64): super(ResUnit, self).__init__() self.conv1 = nn.Conv2d(wkdim, wkdim, ksize, 1, int(ksize/2)) self.active = nn.PReLU() self.conv2 = nn.Conv2d(wkdim, wkdim, ksize, 1, int(ksize/2)) def forward(self, input): current = self.con...
import torch.nn as nn import torch from torch.nn import functional as F import pywt import numpy as np class ResUnit(nn.Module):
32
64
143
6
25
huang-junhong/SIRSRGAN
unit.py
Python
ResUnit
ResUnit
7
19
7
7
afca2a22f8440103d392a210715cbb27d19592a2
bigcode/the-stack
train
1885d3470a8c1546fc9551aa
train
class
class Self_Match(nn.Module): def __init__(self, ksize=5, stride=5, Model='DotP'): super(Self_Match,self).__init__() self.ksize = ksize self.stride= stride self.unfold= nn.Unfold(ksize,1,0,stride) self.Model = Model def reduce_sum(self, x, axis=None, kee...
class Self_Match(nn.Module):
def __init__(self, ksize=5, stride=5, Model='DotP'): super(Self_Match,self).__init__() self.ksize = ksize self.stride= stride self.unfold= nn.Unfold(ksize,1,0,stride) self.Model = Model def reduce_sum(self, x, axis=None, keepdim=False): if not a...
, input): with torch.no_grad(): current= input.unsqueeze(2) current = torch.split(current, [1]*int(current.size()[1]),1) current = torch.cat([x for x in current], 2) current = F.pad(current, (0,1,0,1), 'constant', 0.) output_3d = F.conv3d(curre...
171
171
570
7
163
huang-junhong/SIRSRGAN
unit.py
Python
Self_Match
Self_Match
265
332
265
265
5f0bd823596fcd2fe4e7a13e0d05947f52bbc052
bigcode/the-stack
train
4ba6af63a232fe7f59b8b981
train
class
class PT_DWT(nn.Module): def __init__(self, wave_model='haar', POOL=False, Drop_LL=False, VH_Only=False, LL_Only=False): super(PT_DWT, self).__init__() self.wave = pywt.Wavelet(wave_model) self.Drop_LL = Drop_LL self.VH_Only = VH_Only self.LL_Only = LL_Only sel...
class PT_DWT(nn.Module):
def __init__(self, wave_model='haar', POOL=False, Drop_LL=False, VH_Only=False, LL_Only=False): super(PT_DWT, self).__init__() self.wave = pywt.Wavelet(wave_model) self.Drop_LL = Drop_LL self.VH_Only = VH_Only self.LL_Only = LL_Only self.filter = self._init_filt...
Norm2d(inchannel*2), nn.LeakyReLU(), nn.Conv2d(inchannel*2, inchannel*2, 4, 2, 1), nn.InstanceNorm2d(inchannel*2), nn.LeakyReLU(), nn.C...
218
218
729
7
210
huang-junhong/SIRSRGAN
unit.py
Python
PT_DWT
PT_DWT
203
263
203
203
9ac463522892009d32a90ba7fbe4f97585bbcb86
bigcode/the-stack
train
9e236503c8b3e4d2b45184ac
train
class
class UPN(nn.Module): def __init__(self, indim=64, scale=2): super(UPN, self).__init__() self.conv = nn.Conv2d(indim, indim*(scale**2), 3, 1, 1) self.Upsample = nn.PixelShuffle(scale) self.active = nn.PReLU() def forward(self, input): current = self.conv(input) ...
class UPN(nn.Module):
def __init__(self, indim=64, scale=2): super(UPN, self).__init__() self.conv = nn.Conv2d(indim, indim*(scale**2), 3, 1, 1) self.Upsample = nn.PixelShuffle(scale) self.active = nn.PReLU() def forward(self, input): current = self.conv(input) current = self....
, wkdim, ksize, 1, int(ksize/2)) def forward(self, input): current = self.conv1(input) current = self.active(current) current = self.conv2(current) current = input + current return current class UPN(nn.Module):
64
64
114
6
57
huang-junhong/SIRSRGAN
unit.py
Python
UPN
UPN
22
33
22
22
3dbadfbdb0f3f67ab13c521dd3c58d5f42b5d97e
bigcode/the-stack
train
4035aeb8086cd2dcedc451b8
train
class
class Feature_Ranker(nn.Module): def __init__(self, inchannel=512): super(Feature_Ranker, self).__init__() self.layers = nn.Sequential(nn.Conv2d(inchannel, inchannel, 3, 1, 1), nn.LeakyReLU(), nn.Conv2d(inchannel, inchannel...
class Feature_Ranker(nn.Module):
def __init__(self, inchannel=512): super(Feature_Ranker, self).__init__() self.layers = nn.Sequential(nn.Conv2d(inchannel, inchannel, 3, 1, 1), nn.LeakyReLU(), nn.Conv2d(inchannel, inchannel, 3, 1, 1), ...
, 1, 0), nn.PReLU(), nn.Conv2d(512, 1, 1, 1, 0)) def forward(self, input): current = self.layer_1(input) current = self.layer_2(current) current = self.layer_3(current) current = self.layer_4(current) ...
111
111
371
7
103
huang-junhong/SIRSRGAN
unit.py
Python
Feature_Ranker
Feature_Ranker
172
201
172
172
d7156daae7d7f1821a65231ce9a0a4f9ca08281b
bigcode/the-stack
train
59c8311e447409948f483056
train
class
class DWT_MATCH(nn.Module): def __init__(self, ksize=3, stride=3, Model='DotP'): super(DWT_MATCH, self).__init__() self.kszie = ksize self.stride = stride self.DWT = PT_DWT(POOL=True, VH_Only=True) self.SELF_MATCH = Self_Match(ksize, stride, Model) def forward(se...
class DWT_MATCH(nn.Module):
def __init__(self, ksize=3, stride=3, Model='DotP'): super(DWT_MATCH, self).__init__() self.kszie = ksize self.stride = stride self.DWT = PT_DWT(POOL=True, VH_Only=True) self.SELF_MATCH = Self_Match(ksize, stride, Model) def forward(self, input, target=None, VHSpl...
, 0) else: xi = torch.split(target, 1, 0) score = [] for i in range(n): if self.Model == 'DotP': match = self._Dot_Point(wi[i].squeeze(0), xi[i], sigmoid) elif self.Model == 'L1': match = self._L1(wi[i].squeeze(0), xi[...
115
115
384
7
107
huang-junhong/SIRSRGAN
unit.py
Python
DWT_MATCH
DWT_MATCH
334
372
334
334
e4042184a802578e47f729b97373b264331d3a7e
bigcode/the-stack
train
aa0ad824e4455d7d46b7b000
train
class
class VCF_mpileup_4dot1(VCFBase): """VCF filter dedicated to version 4.1 and mpileup This filter can be used to filter VCF created with mpileup. By default, no filters are applied. One need to define the filters. There are 3 hard-coded filters that can be applied by settings these attributes...
class VCF_mpileup_4dot1(VCFBase):
"""VCF filter dedicated to version 4.1 and mpileup This filter can be used to filter VCF created with mpileup. By default, no filters are applied. One need to define the filters. There are 3 hard-coded filters that can be applied by settings these attributes to True: * apply_af1_filter ...
cf_filter import VCF_freebayes self.vcf = VCF_freebayes(filename, **kwargs) else: print(vcf.version) print(vcf.source) msg = """This VCF file is not recognised. So far we handle version v4.1 with mpileup and v4.2 with freebayes. You may use the force option but no...
256
256
3,003
15
241
vladsaveliev/sequana
sequana/vcf_filter.py
Python
VCF_mpileup_4dot1
VCF_mpileup_4dot1
102
469
102
102
28836129df842f6c4c07730c47ae1431d5ce3c15
bigcode/the-stack
train
0decae60de344aeabdec89d8
train
class
class VCF(object): """A factory to read and filter VCF files for different formats VCF provides a way of storing variants. However the formats is very flexible and leads to different versions (e.g. 4.1, 4.2) and can be generated by different tools (e.g. mpileup, freebayes) leading to heterogeneous VCF...
class VCF(object):
"""A factory to read and filter VCF files for different formats VCF provides a way of storing variants. However the formats is very flexible and leads to different versions (e.g. 4.1, 4.2) and can be generated by different tools (e.g. mpileup, freebayes) leading to heterogeneous VCF files. VC...
# -*- coding: utf-8 -*- # # This file is part of Sequana software # # Copyright (c) 2016 - Sequana Development Team # # File author(s): # Thomas Cokelaer <thomas.cokelaer@pasteur.fr> # Dimitri Desvillechabrol <dimitri.desvillechabrol@pasteur.fr>, # <d.desvillechabrol@gmail.com> # # Distributed un...
220
251
838
5
215
vladsaveliev/sequana
sequana/vcf_filter.py
Python
VCF
VCF
28
99
28
28
ae182e2a8867f94721f2fb4406180ccd3a02ee84
bigcode/the-stack
train
51a56394701834f0a0cc6ff9
train
class
class IteratorKeysWrapper(IEnumerator): def __init__(self, iterator: IIterator): self.it = iterator def next(self) -> bool: return self.it.next() def value(self) -> vm.StackItem: return self.it.key()
class IteratorKeysWrapper(IEnumerator):
def __init__(self, iterator: IIterator): self.it = iterator def next(self) -> bool: return self.it.next() def value(self) -> vm.StackItem: return self.it.key()
.index = next_index return True def value(self) -> vm.StackItem: if self.index < 0: raise ValueError("Cannot call 'value' without having advanced the iterator at least once") return vm.IntegerStackItem(self.array[self.index]) class IteratorKeysWrapper(IEnumerator):
64
64
56
7
57
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
IteratorKeysWrapper
IteratorKeysWrapper
118
126
118
118
e330638ac04a084d3c618d5b5fbe8051e4dea42e
bigcode/the-stack
train
f806c0af3c1bcba3ef5288b6
train
class
class IEnumerator(abc.ABC): @abc.abstractmethod def next(self) -> bool: """ Advance the iterator """ @abc.abstractmethod def value(self) -> vm.StackItem: """ Get the current value """
class IEnumerator(abc.ABC): @abc.abstractmethod
def next(self) -> bool: """ Advance the iterator """ @abc.abstractmethod def value(self) -> vm.StackItem: """ Get the current value """
from __future__ import annotations import abc from typing import Union from neo3 import vm, contracts from neo3.contracts.interop import register class IEnumerator(abc.ABC): @abc.abstractmethod
46
64
50
13
32
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
IEnumerator
IEnumerator
8
15
8
9
39953f21cb8c784604d5982e6ed2946a80309015
bigcode/the-stack
train
1a4e784c76bae0eab9696a90
train
function
@register("System.Enumerator.Value", 400, contracts.native.CallFlags.NONE, False, [IEnumerator]) def enumerator_value(engine: contracts.ApplicationEngine, it: IEnumerator) -> vm.StackItem: return it.value()
@register("System.Enumerator.Value", 400, contracts.native.CallFlags.NONE, False, [IEnumerator]) def enumerator_value(engine: contracts.ApplicationEngine, it: IEnumerator) -> vm.StackItem:
return it.value()
]) def enumerator_next(engine: contracts.ApplicationEngine, it: IEnumerator) -> bool: return it.next() @register("System.Enumerator.Value", 400, contracts.native.CallFlags.NONE, False, [IEnumerator]) def enumerator_value(engine: contracts.ApplicationEngine, it: IEnumerator) -> vm.StackItem:
64
64
46
41
23
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
enumerator_value
enumerator_value
198
200
198
199
625e70c1e9d8a7af23569daa1a2eac9cfa332d78
bigcode/the-stack
train
4e714c75e576513cc0f22dec
train
function
@register("System.Iterator.Values", 400, contracts.native.CallFlags.NONE, False, [IIterator]) def iterator_values(engine: contracts.ApplicationEngine, iterator: IIterator) -> IEnumerator: return IteratorValuesWrapper(iterator)
@register("System.Iterator.Values", 400, contracts.native.CallFlags.NONE, False, [IIterator]) def iterator_values(engine: contracts.ApplicationEngine, iterator: IIterator) -> IEnumerator:
return IteratorValuesWrapper(iterator)
_keys(engine: contracts.ApplicationEngine, iterator: IIterator) -> IEnumerator: return IteratorKeysWrapper(iterator) @register("System.Iterator.Values", 400, contracts.native.CallFlags.NONE, False, [IIterator]) def iterator_values(engine: contracts.ApplicationEngine, iterator: IIterator) -> IEnumerator:
64
64
48
41
23
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
iterator_values
iterator_values
230
232
230
231
c8d5ed70c882cfd566cacc6a9e5495dcf0b31fcc
bigcode/the-stack
train
94c1d74521fdf0eb8ba32fc4
train
class
class StorageIterator(IIterator): def __init__(self, generator): self.it = generator self._pair = None def next(self) -> bool: try: self._pair = next(self.it) return True except StopIteration: self._pair = None return False de...
class StorageIterator(IIterator):
def __init__(self, generator): self.it = generator self._pair = None def next(self) -> bool: try: self._pair = next(self.it) return True except StopIteration: self._pair = None return False def value(self) -> vm.StackItem: ...
itiveType: return self.current.key() def value(self) -> vm.StackItem: return self.current.value() def next(self) -> bool: if self.current.next(): return True self.current = self.second return self.current.next() class StorageIterator(IIterator):
64
64
176
8
56
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
StorageIterator
StorageIterator
159
180
159
159
372d5c93ea2aad95223c93d2be87b99fb7528150
bigcode/the-stack
train
5d6b084dcb06882d5ab1b595
train
function
@register("System.Enumerator.Concat", 400, contracts.native.CallFlags.NONE, False, [IEnumerator, IEnumerator]) def enumerator_concat(engine: contracts.ApplicationEngine, first: IEnumerator, second: IEnumerator) -> IEnumerator: return ConcatenatedEnumerator(first, second)
@register("System.Enumerator.Concat", 400, contracts.native.CallFlags.NONE, False, [IEnumerator, IEnumerator]) def enumerator_concat(engine: contracts.ApplicationEngine, first: IEnumerator, second: IEnumerator) -> IEnumerator:
return ConcatenatedEnumerator(first, second)
: contracts.ApplicationEngine, it: IEnumerator) -> vm.StackItem: return it.value() @register("System.Enumerator.Concat", 400, contracts.native.CallFlags.NONE, False, [IEnumerator, IEnumerator]) def enumerator_concat(engine: contracts.ApplicationEngine, first: IEnumerator, second: IEnumerator) -> IEnumerator:
64
64
55
45
19
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
enumerator_concat
enumerator_concat
203
205
203
204
839101df00dfcff9c0050140f7412287c0e13624
bigcode/the-stack
train
2fa4b845bd2752abbad8a857
train
function
@register("System.Iterator.Key", 400, contracts.native.CallFlags.NONE, False, [IIterator]) def iterator_key(engine: contracts.ApplicationEngine, iterator: IIterator) -> vm.PrimitiveType: return iterator.key()
@register("System.Iterator.Key", 400, contracts.native.CallFlags.NONE, False, [IIterator]) def iterator_key(engine: contracts.ApplicationEngine, iterator: IIterator) -> vm.PrimitiveType:
return iterator.key()
raise ValueError(f"Cannot create iterator from unsupported type: {type(stack_item)}") @register("System.Iterator.Key", 400, contracts.native.CallFlags.NONE, False, [IIterator]) def iterator_key(engine: contracts.ApplicationEngine, iterator: IIterator) -> vm.PrimitiveType:
64
64
50
45
19
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
iterator_key
iterator_key
220
222
220
221
b82666d37ef67db7279f64938317360345ceba71
bigcode/the-stack
train
cd6abf04841f81d96c2cf9de
train
function
@register("System.Enumerator.Next", 1000000, contracts.native.CallFlags.NONE, False, [IEnumerator]) def enumerator_next(engine: contracts.ApplicationEngine, it: IEnumerator) -> bool: return it.next()
@register("System.Enumerator.Next", 1000000, contracts.native.CallFlags.NONE, False, [IEnumerator]) def enumerator_next(engine: contracts.ApplicationEngine, it: IEnumerator) -> bool:
return it.next()
) else: raise ValueError(f"Cannot create iterator from unsupported type: {type(stack_item)}") @register("System.Enumerator.Next", 1000000, contracts.native.CallFlags.NONE, False, [IEnumerator]) def enumerator_next(engine: contracts.ApplicationEngine, it: IEnumerator) -> bool:
64
64
46
41
23
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
enumerator_next
enumerator_next
193
195
193
194
9db02ba131698f71283384fc02580c0cf1836b0e
bigcode/the-stack
train
efc7a172ce3ef27f30a66e1c
train
class
class MapWrapper(IIterator): def __init__(self, map_item: vm.MapStackItem): super(MapWrapper, self).__init__() self.it = iter(map_item) self._key = None self._value = None def key(self) -> vm.PrimitiveType: if self._key is None: raise ValueError("Cannot call ...
class MapWrapper(IIterator):
def __init__(self, map_item: vm.MapStackItem): super(MapWrapper, self).__init__() self.it = iter(map_item) self._key = None self._value = None def key(self) -> vm.PrimitiveType: if self._key is None: raise ValueError("Cannot call 'key' without having advanced...
self.index = next_index return True def value(self) -> vm.StackItem: if self.index < 0: raise ValueError("Cannot call 'value' without having advanced the iterator at least once") return self.array[self.index] class MapWrapper(IIterator):
64
64
193
8
56
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
MapWrapper
MapWrapper
66
91
66
66
86fbfff63941c06c0d21a3d34077e38833b08807
bigcode/the-stack
train
d5030f93cb9dfb1e1b6646a5
train
class
class ArrayWrapper(IIterator): def __init__(self, array: vm.ArrayStackItem): super(ArrayWrapper, self).__init__() self.array = array self.index = -1 def key(self) -> vm.PrimitiveType: if self.index < 0: raise ValueError("Cannot call 'key' without having advanced the ...
class ArrayWrapper(IIterator):
def __init__(self, array: vm.ArrayStackItem): super(ArrayWrapper, self).__init__() self.array = array self.index = -1 def key(self) -> vm.PrimitiveType: if self.index < 0: raise ValueError("Cannot call 'key' without having advanced the iterator at least once") ...
: return self.current.value() class IIterator(IEnumerator, abc.ABC): @abc.abstractmethod def key(self) -> vm.PrimitiveType: """ Get the key value (e.g. for a map) or index for arrays """ class ArrayWrapper(IIterator):
63
64
178
8
55
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
ArrayWrapper
ArrayWrapper
41
63
41
41
08c221a56a1eafe5caee28ed31667d93c1c706e6
bigcode/the-stack
train
f7b34339a5ec3c857b62357c
train
class
class ConcatenatedEnumerator(IEnumerator): def __init__(self, first: IEnumerator, second: IEnumerator): super(ConcatenatedEnumerator, self).__init__() self.first = first self.second = second self.current = self.first def next(self) -> bool: if self.current.next(): ...
class ConcatenatedEnumerator(IEnumerator):
def __init__(self, first: IEnumerator, second: IEnumerator): super(ConcatenatedEnumerator, self).__init__() self.first = first self.second = second self.current = self.first def next(self) -> bool: if self.current.next(): return True self.current = se...
.interop import register class IEnumerator(abc.ABC): @abc.abstractmethod def next(self) -> bool: """ Advance the iterator """ @abc.abstractmethod def value(self) -> vm.StackItem: """ Get the current value """ class ConcatenatedEnumerator(IEnumerator):
63
64
101
8
55
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
ConcatenatedEnumerator
ConcatenatedEnumerator
18
32
18
18
589be07fd4409cefdbc52e0695e3ea535c5676d1
bigcode/the-stack
train
cc7789d94488cfbd7b3806e5
train
class
class ConcatenatedIterator(IIterator): def __init__(self, first: IIterator, second: IIterator): self.first = first self.second = second self.current = self.first def key(self) -> vm.PrimitiveType: return self.current.key() def value(self) -> vm.StackItem: return sel...
class ConcatenatedIterator(IIterator):
def __init__(self, first: IIterator, second: IIterator): self.first = first self.second = second self.current = self.first def key(self) -> vm.PrimitiveType: return self.current.key() def value(self) -> vm.StackItem: return self.current.value() def next(self) -...
ValuesWrapper(IEnumerator): def __init__(self, iterator: IIterator): self.it = iterator def next(self) -> bool: return self.it.next() def value(self) -> vm.StackItem: return self.it.value() class ConcatenatedIterator(IIterator):
64
64
113
10
54
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
ConcatenatedIterator
ConcatenatedIterator
140
156
140
140
f944a15beba4aa4d4b5f85a04d2c949631c3980a
bigcode/the-stack
train
d39bfdeea274907d90c930f6
train
function
@register("System.Iterator.Concat", 400, contracts.native.CallFlags.NONE, False, [IIterator, IIterator]) def iterator_concat(engine: contracts.ApplicationEngine, first: IIterator, second: IIterator) -> IIterator: return ConcatenatedIterator(first, second)
@register("System.Iterator.Concat", 400, contracts.native.CallFlags.NONE, False, [IIterator, IIterator]) def iterator_concat(engine: contracts.ApplicationEngine, first: IIterator, second: IIterator) -> IIterator:
return ConcatenatedIterator(first, second)
) -> IEnumerator: return IteratorValuesWrapper(iterator) @register("System.Iterator.Concat", 400, contracts.native.CallFlags.NONE, False, [IIterator, IIterator]) def iterator_concat(engine: contracts.ApplicationEngine, first: IIterator, second: IIterator) -> IIterator:
64
64
63
53
11
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
iterator_concat
iterator_concat
235
237
235
236
6f2205b4cdbca14c6eb17d137f8db6fb227afc1f
bigcode/the-stack
train
38ce6f3c7e78cb9328a5ad06
train
class
class IIterator(IEnumerator, abc.ABC): @abc.abstractmethod def key(self) -> vm.PrimitiveType: """ Get the key value (e.g. for a map) or index for arrays """
class IIterator(IEnumerator, abc.ABC): @abc.abstractmethod
def key(self) -> vm.PrimitiveType: """ Get the key value (e.g. for a map) or index for arrays """
def next(self) -> bool: if self.current.next(): return True self.current = self.second return self.current.next() def value(self) -> vm.StackItem: return self.current.value() class IIterator(IEnumerator, abc.ABC): @abc.abstractmethod
64
64
48
17
47
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
IIterator
IIterator
35
38
35
36
cedaec93005cf2c991455ca316f254889bb5420d
bigcode/the-stack
train
a3ef7cac3525d87d8e8b7962
train
class
class ByteArrayWrapper(IIterator): def __init__(self, value: Union[vm.BufferStackItem, vm.PrimitiveType]): self.array = value.to_array() self.index = -1 def key(self) -> vm.PrimitiveType: if self.index < 0: raise ValueError("Cannot call 'key' without having advanced the iter...
class ByteArrayWrapper(IIterator):
def __init__(self, value: Union[vm.BufferStackItem, vm.PrimitiveType]): self.array = value.to_array() self.index = -1 def key(self) -> vm.PrimitiveType: if self.index < 0: raise ValueError("Cannot call 'key' without having advanced the iterator at least once") retur...
self._value def next(self) -> bool: try: self._key, self._value = next(self.it) except StopIteration: self._key = None self._value = None return False return True class ByteArrayWrapper(IIterator):
64
64
184
9
54
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
ByteArrayWrapper
ByteArrayWrapper
94
115
94
94
2952455dc0ec9d73015e8cb656233f38b840e310
bigcode/the-stack
train
d70a825b7fa097d447eba609
train
function
@register("System.Enumerator.Create", 400, contracts.native.CallFlags.NONE, False, [vm.StackItem]) def enumerator_create(engine: contracts.ApplicationEngine, stack_item: vm.StackItem) -> IEnumerator: if isinstance(stack_item, vm.ArrayStackItem): return ArrayWrapper(stack_item) elif isinstance(stack_item...
@register("System.Enumerator.Create", 400, contracts.native.CallFlags.NONE, False, [vm.StackItem]) def enumerator_create(engine: contracts.ApplicationEngine, stack_item: vm.StackItem) -> IEnumerator:
if isinstance(stack_item, vm.ArrayStackItem): return ArrayWrapper(stack_item) elif isinstance(stack_item, (vm.BufferStackItem, vm.PrimitiveType)): return ByteArrayWrapper(stack_item) else: raise ValueError(f"Cannot create iterator from unsupported type: {type(stack_item)}")
iterator at least once") return vm.ByteStringStackItem(self._pair[0].key) @register("System.Enumerator.Create", 400, contracts.native.CallFlags.NONE, False, [vm.StackItem]) def enumerator_create(engine: contracts.ApplicationEngine, stack_item: vm.StackItem) -> IEnumerator:
64
64
110
44
20
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
enumerator_create
enumerator_create
183
190
183
184
6b7c9268ac8a8c88b3d5ef419abf0f7b98455cff
bigcode/the-stack
train
0d4e52781f76fc158beb92a7
train
function
@register("System.Iterator.Create", 400, contracts.native.CallFlags.NONE, False, [vm.StackItem]) def iterator_create(engine: contracts.ApplicationEngine, stack_item: vm.StackItem) -> IIterator: if isinstance(stack_item, vm.ArrayStackItem): return ArrayWrapper(stack_item) elif isinstance(stack_item, vm.M...
@register("System.Iterator.Create", 400, contracts.native.CallFlags.NONE, False, [vm.StackItem]) def iterator_create(engine: contracts.ApplicationEngine, stack_item: vm.StackItem) -> IIterator:
if isinstance(stack_item, vm.ArrayStackItem): return ArrayWrapper(stack_item) elif isinstance(stack_item, vm.MapStackItem): return MapWrapper(stack_item) elif isinstance(stack_item, (vm.BufferStackItem, vm.PrimitiveType)): return ByteArrayWrapper(stack_item) else: raise V...
: IEnumerator, second: IEnumerator) -> IEnumerator: return ConcatenatedEnumerator(first, second) @register("System.Iterator.Create", 400, contracts.native.CallFlags.NONE, False, [vm.StackItem]) def iterator_create(engine: contracts.ApplicationEngine, stack_item: vm.StackItem) -> IIterator:
64
64
128
44
20
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
iterator_create
iterator_create
208
217
208
209
57ee2f05da841cb6ef52e5ba40a9a51fbaa5ec1c
bigcode/the-stack
train
6333911d34cde95ab5cf4509
train
function
@register("System.Iterator.Keys", 400, contracts.native.CallFlags.NONE, False, [IIterator]) def iterator_keys(engine: contracts.ApplicationEngine, iterator: IIterator) -> IEnumerator: return IteratorKeysWrapper(iterator)
@register("System.Iterator.Keys", 400, contracts.native.CallFlags.NONE, False, [IIterator]) def iterator_keys(engine: contracts.ApplicationEngine, iterator: IIterator) -> IEnumerator:
return IteratorKeysWrapper(iterator)
: contracts.ApplicationEngine, iterator: IIterator) -> vm.PrimitiveType: return iterator.key() @register("System.Iterator.Keys", 400, contracts.native.CallFlags.NONE, False, [IIterator]) def iterator_keys(engine: contracts.ApplicationEngine, iterator: IIterator) -> IEnumerator:
64
64
48
41
23
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
iterator_keys
iterator_keys
225
227
225
226
f28db600871428277a22c50f4e22b8a04b6067d2
bigcode/the-stack
train
eabc02cdb305e2e39dcf67cc
train
class
class IteratorValuesWrapper(IEnumerator): def __init__(self, iterator: IIterator): self.it = iterator def next(self) -> bool: return self.it.next() def value(self) -> vm.StackItem: return self.it.value()
class IteratorValuesWrapper(IEnumerator):
def __init__(self, iterator: IIterator): self.it = iterator def next(self) -> bool: return self.it.next() def value(self) -> vm.StackItem: return self.it.value()
]) class IteratorKeysWrapper(IEnumerator): def __init__(self, iterator: IIterator): self.it = iterator def next(self) -> bool: return self.it.next() def value(self) -> vm.StackItem: return self.it.key() class IteratorValuesWrapper(IEnumerator):
64
64
56
7
57
ixje/neo-mamba
neo3/contracts/interop/enumerator.py
Python
IteratorValuesWrapper
IteratorValuesWrapper
129
137
129
129
cc4cac6e3d3443a7687ae6a3cb7e97097f591bf2
bigcode/the-stack
train
31152d09836e6a9073a01b17
train
class
class State: def __init__(self, encoder_output=None, encoder_mask=None, **kwargs): """ 每个Decoder都有对应的State对象用来承载encoder的输出以及当前时刻之前的decode状态。 :param Union[torch.Tensor, list, tuple] encoder_output: 如果不为None,内部元素需要为torch.Tensor, 默认其中第一维是batch 维度 :param Union[torch.Tensor, ...
class State:
def __init__(self, encoder_output=None, encoder_mask=None, **kwargs): """ 每个Decoder都有对应的State对象用来承载encoder的输出以及当前时刻之前的decode状态。 :param Union[torch.Tensor, list, tuple] encoder_output: 如果不为None,内部元素需要为torch.Tensor, 默认其中第一维是batch 维度 :param Union[torch.Tensor, list, tuple] ...
r""" 每个Decoder都有对应的State用来记录encoder的输出以及Decode的历史记录 """ __all__ = [ 'State', "LSTMState", "TransformerState" ] from typing import Union import torch class State:
54
159
530
3
50
Chillee/benchmark
torchbenchmark/models/fastNLP/fastNLP/modules/decoder/seq2seq_state.py
Python
State
State
16
78
16
16
89638105ec0114685bb52772ea3985ee5fce0a19
bigcode/the-stack
train
9e3b34a709e07570afeaa3eb
train
class
class LSTMState(State): def __init__(self, encoder_output, encoder_mask, hidden, cell): """ LSTMDecoder对应的State,保存encoder的输出以及LSTM解码过程中的一些中间状态 :param torch.FloatTensor encoder_output: bsz x src_seq_len x encode_output_size,encoder的输出 :param torch.BoolTensor encoder_mask: bsz x src_s...
class LSTMState(State):
def __init__(self, encoder_output, encoder_mask, hidden, cell): """ LSTMDecoder对应的State,保存encoder的输出以及LSTM解码过程中的一些中间状态 :param torch.FloatTensor encoder_output: bsz x src_seq_len x encode_output_size,encoder的输出 :param torch.BoolTensor encoder_mask: bsz x src_seq_len, 为0的地方是padding ...
is not None tmp_list.append(self._reorder_state(state[i], indices, dim)) state = tuple(tmp_list) else: raise TypeError(f"Cannot reorder data of type:{type(state)}") return state def reorder_state(self, indices: torch.LongTensor): if self.encoder_mas...
118
118
394
6
112
Chillee/benchmark
torchbenchmark/models/fastNLP/fastNLP/modules/decoder/seq2seq_state.py
Python
LSTMState
LSTMState
81
114
81
81
1569d308fa75d5d9045febf6cdf30be7948259f3
bigcode/the-stack
train
10492f44ce292e92913145bb
train
class
class TransformerState(State): def __init__(self, encoder_output, encoder_mask, num_decoder_layer): """ 与TransformerSeq2SeqDecoder对应的State, :param torch.FloatTensor encoder_output: bsz x encode_max_len x encoder_output_size, encoder的输出 :param torch.ByteTensor encoder_mask: bsz x enc...
class TransformerState(State):
def __init__(self, encoder_output, encoder_mask, num_decoder_layer): """ 与TransformerSeq2SeqDecoder对应的State, :param torch.FloatTensor encoder_output: bsz x encode_max_len x encoder_output_size, encoder的输出 :param torch.ByteTensor encoder_mask: bsz x encode_max_len 为1的地方需要attend ...
_feed(self, value): self._input_feed = value def reorder_state(self, indices: torch.LongTensor): super().reorder_state(indices) self.hidden = self._reorder_state(self.hidden, indices, dim=1) self.cell = self._reorder_state(self.cell, indices, dim=1) if self.input_feed is not...
103
103
345
5
98
Chillee/benchmark
torchbenchmark/models/fastNLP/fastNLP/modules/decoder/seq2seq_state.py
Python
TransformerState
TransformerState
117
143
117
117
1aac954d7c8e75d77518b1b7ed0522b328a225ef
bigcode/the-stack
train
7689e441124ad0147aae5a26
train
function
def test_wait_for_task(): with common.mock_requests( [ ( "get", "tasks", [ mock_responses.RUNNING_TASK, # First poll response mock_responses.SUCCESSFUL_TASK, # Second poll response ], ...
def test_wait_for_task():
with common.mock_requests( [ ( "get", "tasks", [ mock_responses.RUNNING_TASK, # First poll response mock_responses.SUCCESSFUL_TASK, # Second poll response ], ) ] ): ...
with common.mock_requests( [ ("get", "images", mock_responses.TASKS), ("post", "start_task", mock_responses.REQUEST_ERROR), ] ): with pytest.raises(exceptions.RequestError): PPA.start_task_async("Dummy Task") def test_wait_for_task():
64
64
75
6
58
tomguyatt/ppa-api
tests/test_tasks.py
Python
test_wait_for_task
test_wait_for_task
240
253
240
240
ab11a21d2be42e0d835923f50847b4f11a0e818a
bigcode/the-stack
train
e79342fa0c9654ea5ead6114
train
function
@pytest.mark.parametrize( "mocker, mock_response, instance_method, return_tests, query_string, request_body, expected_exception, exception_pattern", [ [ common.TASKS_MOCKER, mock_responses.TASKS, lambda instance: instance.tasks(), [lambda x: all([isinstanc...
@pytest.mark.parametrize( "mocker, mock_response, instance_method, return_tests, query_string, request_body, expected_exception, exception_pattern", [ [ common.TASKS_MOCKER, mock_responses.TASKS, lambda instance: instance.tasks(), [lambda x: all([isinstanc...
with mocker(mock_response) as mock_adapter: if expected_exception: raises_kwargs = {"match": exception_pattern} if exception_pattern else {} with pytest.raises(expected_exception, **raises_kwargs): instance_method(PPA) else: result = instance_metho...
@pytest.mark.parametrize( "mocker, mock_response, instance_method, return_tests, query_string, request_body, expected_exception, exception_pattern", [ [ common.TASKS_MOCKER, mock_responses.TASKS, lambda instance: instance.tasks(), [lambda x: all([isinstanc...
1,044
256
1,161
1,044
0
tomguyatt/ppa-api
tests/test_tasks.py
Python
test_task_requests
test_task_requests
20
202
20
190
88586aab02e5d64af3f34ce8f094b1b5c743a130
bigcode/the-stack
train
f8cd684a173c5537c7068b34
train
function
def test_start_task(): with common.mock_requests( [ ("get", "images", mock_responses.IMAGES), ("get", "tasks", mock_responses.TASKS), ("post", "start_task", mock_responses.TASK_STARTED), ] ): PPA.start_task("Dummy Task", timeout=0)
def test_start_task():
with common.mock_requests( [ ("get", "images", mock_responses.IMAGES), ("get", "tasks", mock_responses.TASKS), ("post", "start_task", mock_responses.TASK_STARTED), ] ): PPA.start_task("Dummy Task", timeout=0)
) assert all([test(result) for test in return_tests]) if query_string: assert mock_adapter.request_history[0].qs == query_string if request_body: assert mock_adapter.request_history[0]._request.body.decode("utf-8") == request_body def test_start_task()...
64
64
72
5
58
tomguyatt/ppa-api
tests/test_tasks.py
Python
test_start_task
test_start_task
205
213
205
205
88205511be2e425759e7e4e159dfa88f426cc372
bigcode/the-stack
train
29685a69d96c0d4383a9fc67
train
function
def test_must_be_deployed(): with common.mock_requests( [ ("get", "images", mock_responses.TASKS), ("post", "start_task", mock_responses.TASK_MUST_BE_DEPLOYED), ] ): with pytest.raises( exceptions.ImageNotDeployed, match="The task cannot be...
def test_must_be_deployed():
with common.mock_requests( [ ("get", "images", mock_responses.TASKS), ("post", "start_task", mock_responses.TASK_MUST_BE_DEPLOYED), ] ): with pytest.raises( exceptions.ImageNotDeployed, match="The task cannot be started as image 'Dummy Task...
", "images", mock_responses.IMAGES), ("get", "tasks", mock_responses.TASKS), ("post", "start_task", mock_responses.TASK_STARTED), ] ): PPA.start_task("Dummy Task", timeout=0) def test_must_be_deployed():
64
64
175
8
56
tomguyatt/ppa-api
tests/test_tasks.py
Python
test_must_be_deployed
test_must_be_deployed
216
237
216
216
a998f2acce721d8c92814c20be4b2249f8e47ac2
bigcode/the-stack
train
50bf1030b8c8ca2f9e974dd7
train
class
class Migration(migrations.Migration): dependencies = [ ('team', '0009_auto_20170203_1719'), ] operations = [ migrations.AlterField( model_name='manualbooking', name='inward_payment_status', field=models.CharField(blank=True, choices=[('no_payment', 'No ...
class Migration(migrations.Migration):
dependencies = [ ('team', '0009_auto_20170203_1719'), ] operations = [ migrations.AlterField( model_name='manualbooking', name='inward_payment_status', field=models.CharField(blank=True, choices=[('no_payment', 'No Payment Received'), ('partial_received',...
# -*- coding: utf-8 -*- # Generated by Django 1.10.3 on 2017-02-03 13:18 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration):
54
64
109
7
46
manibhushan05/transiq
web/transiq/team/migrations/0010_auto_20170203_1848.py
Python
Migration
Migration
8
20
8
9
615ca572a3089d335140dbd2fc713c9180e567a6
bigcode/the-stack
train
33a05d4b7ba212fcfcd67065
train
function
def create(kernel): result = Intangible() result.template = "object/draft_schematic/food/shared_dessert_pastebread.iff" result.attribute_template_id = -1 result.stfName("string_id_table","") #### BEGIN MODIFICATIONS #### #### END MODIFICATIONS #### return result
def create(kernel):
result = Intangible() result.template = "object/draft_schematic/food/shared_dessert_pastebread.iff" result.attribute_template_id = -1 result.stfName("string_id_table","") #### BEGIN MODIFICATIONS #### #### END MODIFICATIONS #### return result
#### NOTICE: THIS FILE IS AUTOGENERATED #### MODIFICATIONS MAY BE LOST IF DONE IMPROPERLY #### PLEASE SEE THE ONLINE DOCUMENTATION FOR EXAMPLES from swgpy.object import * def create(kernel):
46
64
69
4
42
obi-two/GameServer
data/scripts/templates/object/draft_schematic/food/shared_dessert_pastebread.py
Python
create
create
7
17
7
7
843960162ea2fe87a6a04298f80b7df604d09486
bigcode/the-stack
train
56625d01d7fe05708d604d54
train
function
def find_binary_multiply(left: ParseAtom, right: ParseAtom): if isinstance(left, ParseFloat): if isinstance(right, ParseFloat): return ParseBinaryMultiplyFloatFloat(left, right) elif isinstance(right, ParseInteger): return ParseBinaryMultiplyFloatInteger(left, right) ...
def find_binary_multiply(left: ParseAtom, right: ParseAtom):
if isinstance(left, ParseFloat): if isinstance(right, ParseFloat): return ParseBinaryMultiplyFloatFloat(left, right) elif isinstance(right, ParseInteger): return ParseBinaryMultiplyFloatInteger(left, right) else: return None elif isinstance(left, Parse...
f"Multiply({self._left!r}, {self._right!r})" def eval(self, vars: Dict[str, ParseAtom]) -> int: return self._left.eval(vars) * self._right.eval(vars) def find_binary_multiply(left: ParseAtom, right: ParseAtom):
64
64
128
15
49
jesopo/scpl
scpl/parser/operators/multiply.py
Python
find_binary_multiply
find_binary_multiply
32
48
32
32
1c93b9ef53ecbf0c4e0aa89aff0ea49251dc5849
bigcode/the-stack
train
84e6de6f1d16c007740aa5bf
train
class
class ParseBinaryMultiplyFloatFloat(ParseBinaryOperator, ParseFloat): def __init__(self, left: ParseFloat, right: ParseFloat): super().__init__(left, right) self._left = left self._right = right def __repr__(self) -> str: return f"Multiply({self._left!r}, {self._right!r})" de...
class ParseBinaryMultiplyFloatFloat(ParseBinaryOperator, ParseFloat):
def __init__(self, left: ParseFloat, right: ParseFloat): super().__init__(left, right) self._left = left self._right = right def __repr__(self) -> str: return f"Multiply({self._left!r}, {self._right!r})" def eval(self, vars: Dict[str, ParseAtom]) -> float: return self...
from typing import Dict from .common import ParseBinaryOperator from ..operands import ParseAtom, ParseFloat, ParseInteger from .cast import ParseCastIntegerFloat class ParseBinaryMultiplyFloatFloat(ParseBinaryOperator, ParseFloat):
49
64
114
13
35
jesopo/scpl
scpl/parser/operators/multiply.py
Python
ParseBinaryMultiplyFloatFloat
ParseBinaryMultiplyFloatFloat
6
14
6
6
85e0a3973137a1345872af39c1ff64fa79795196
bigcode/the-stack
train
d88a6883bea72f30b792e3b0
train
class
class ParseBinaryMultiplyFloatInteger(ParseBinaryMultiplyFloatFloat): def __init__(self, left: ParseFloat, right: ParseInteger): super().__init__(left, ParseCastIntegerFloat(right))
class ParseBinaryMultiplyFloatInteger(ParseBinaryMultiplyFloatFloat):
def __init__(self, left: ParseFloat, right: ParseInteger): super().__init__(left, ParseCastIntegerFloat(right))
: return f"Multiply({self._left!r}, {self._right!r})" def eval(self, vars: Dict[str, ParseAtom]) -> float: return self._left.eval(vars) * self._right.eval(vars) class ParseBinaryMultiplyFloatInteger(ParseBinaryMultiplyFloatFloat):
64
64
42
12
52
jesopo/scpl
scpl/parser/operators/multiply.py
Python
ParseBinaryMultiplyFloatInteger
ParseBinaryMultiplyFloatInteger
15
17
15
15
aa0072b4212b2c9a1525a9660574fdf3ba1fa1d1
bigcode/the-stack
train
44e4ea3b86893a7277f6f600
train
class
class ParseBinaryMultiplyIntegerFloat(ParseBinaryMultiplyFloatFloat): def __init__(self, left: ParseInteger, right: ParseFloat): super().__init__(ParseCastIntegerFloat(left), right)
class ParseBinaryMultiplyIntegerFloat(ParseBinaryMultiplyFloatFloat):
def __init__(self, left: ParseInteger, right: ParseFloat): super().__init__(ParseCastIntegerFloat(left), right)
.eval(vars) * self._right.eval(vars) class ParseBinaryMultiplyFloatInteger(ParseBinaryMultiplyFloatFloat): def __init__(self, left: ParseFloat, right: ParseInteger): super().__init__(left, ParseCastIntegerFloat(right)) class ParseBinaryMultiplyIntegerFloat(ParseBinaryMultiplyFloatFloat):
64
64
42
12
52
jesopo/scpl
scpl/parser/operators/multiply.py
Python
ParseBinaryMultiplyIntegerFloat
ParseBinaryMultiplyIntegerFloat
18
20
18
18
f3500f221c5bb215e57162ae03de9dabe9b9fa6d
bigcode/the-stack
train