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
0cadecc781cbaffb5708d30f
train
class
class EType(SteamIntEnum): Invalid = 0 Individual = 1 #: single user account Multiseat = 2 #: multiseat (e.g. cybercafe) account GameServer = 3 #: game server account AnonGameServer = 4 #: anonymous game server account Pending = 5 #: pending ContentServer = 6 #: co...
class EType(SteamIntEnum):
Invalid = 0 Individual = 1 #: single user account Multiseat = 2 #: multiseat (e.g. cybercafe) account GameServer = 3 #: game server account AnonGameServer = 4 #: anonymous game server account Pending = 5 #: pending ContentServer = 6 #: content server Clan = 7 ...
class EUniverse(SteamIntEnum): Invalid = 0 Public = 1 Beta = 2 Internal = 3 Dev = 4 # RC = 5 #: doesn't exit anymore Max = 6 class EType(SteamIntEnum):
64
64
148
8
55
gosuai/steam
steam/enums/common.py
Python
EType
EType
128
140
128
128
33ca4cd7aad78371077f8c89bcce23174c97185f
bigcode/the-stack
train
eb31943b385117fbacfbd4a4
train
class
class EChatEntryType(SteamIntEnum): Invalid = 0 ChatMsg = 1 #: Normal text message from another user Typing = 2 #: Another user is typing (not used in multi-user chat) InviteGame = 3 #: Invite from other user into that users current game Emote = 4 #: t...
class EChatEntryType(SteamIntEnum):
Invalid = 0 ChatMsg = 1 #: Normal text message from another user Typing = 2 #: Another user is typing (not used in multi-user chat) InviteGame = 3 #: Invite from other user into that users current game Emote = 4 #: text emote message (deprecated, shoul...
2 TimeMilliSeconds = 3 class ELeaderboardUploadScoreMethod(SteamIntEnum): NONE = 0 KeepBest = 1 ForceUpdate = 2 class ETwoFactorTokenType(SteamIntEnum): NONE = 0 ValveMobileApp = 1 ThirdParty = 2 class EChatEntryType(SteamIntEnum):
84
84
282
10
73
gosuai/steam
steam/enums/common.py
Python
EChatEntryType
EChatEntryType
460
475
460
460
33561f348ac3bf808c92736fab3c14d220cf6cf9
bigcode/the-stack
train
f0795c25fc99e173e5ab8d69
train
class
class EPersonaState(SteamIntEnum): Offline = 0 Online = 1 Busy = 2 Away = 3 Snooze = 4 LookingToTrade = 5 LookingToPlay = 6 Max = 7
class EPersonaState(SteamIntEnum):
Offline = 0 Online = 1 Busy = 2 Away = 3 Snooze = 4 LookingToTrade = 5 LookingToPlay = 6 Max = 7
RequestingFriendship = 128 RequestingInfo = 256 Ignored = 512 IgnoredFriend = 1024 Suggested = 2048 ChatMember = 4096 FlagAll = 65535 class EPersonaState(SteamIntEnum):
64
64
62
9
54
gosuai/steam
steam/enums/common.py
Python
EPersonaState
EPersonaState
387
395
387
387
68fdfb9dab325db7fa9959f4bdf9734a848927ab
bigcode/the-stack
train
9e662e27afb396de4e383b52
train
class
class ELeaderboardSortMethod(SteamIntEnum): NONE = 0 Ascending = 1 Descending = 2
class ELeaderboardSortMethod(SteamIntEnum):
NONE = 0 Ascending = 1 Descending = 2
512 ClanTag = 1024 Facebook = 2048 class ELeaderboardDataRequest(SteamIntEnum): Global = 0 GlobalAroundUser = 1 Friends = 2 Users = 3 class ELeaderboardSortMethod(SteamIntEnum):
64
64
30
10
53
gosuai/steam
steam/enums/common.py
Python
ELeaderboardSortMethod
ELeaderboardSortMethod
435
438
435
435
82be8ea5ccc565dd4314b83665bb378a83ace718
bigcode/the-stack
train
eeb92f436311bbdafaef7657
train
class
class ELeaderboardUploadScoreMethod(SteamIntEnum): NONE = 0 KeepBest = 1 ForceUpdate = 2
class ELeaderboardUploadScoreMethod(SteamIntEnum):
NONE = 0 KeepBest = 1 ForceUpdate = 2
0 Ascending = 1 Descending = 2 class ELeaderboardDisplayType(SteamIntEnum): NONE = 0 Numeric = 1 TimeSeconds = 2 TimeMilliSeconds = 3 class ELeaderboardUploadScoreMethod(SteamIntEnum):
64
64
31
11
52
gosuai/steam
steam/enums/common.py
Python
ELeaderboardUploadScoreMethod
ELeaderboardUploadScoreMethod
448
451
448
448
daf68cd2550677173c9f46201346d255a9b212fc
bigcode/the-stack
train
5009dbf2b1f68a634fb6ff76
train
class
class ELeaderboardDisplayType(SteamIntEnum): NONE = 0 Numeric = 1 TimeSeconds = 2 TimeMilliSeconds = 3
class ELeaderboardDisplayType(SteamIntEnum):
NONE = 0 Numeric = 1 TimeSeconds = 2 TimeMilliSeconds = 3
= 0 GlobalAroundUser = 1 Friends = 2 Users = 3 class ELeaderboardSortMethod(SteamIntEnum): NONE = 0 Ascending = 1 Descending = 2 class ELeaderboardDisplayType(SteamIntEnum):
64
64
37
10
53
gosuai/steam
steam/enums/common.py
Python
ELeaderboardDisplayType
ELeaderboardDisplayType
441
445
441
441
eb4bfe8813e4fd6d232fa69593353502d761fee5
bigcode/the-stack
train
190fddc75c96516cea7b2056
train
class
class EPersonaStateFlag(SteamIntEnum): HasRichPresence = 1 InJoinableGame = 2 HasGoldenProfile = 4 # OnlineUsingWeb = 256 obsolete "renamed to ClientTypeWeb" ClientTypeWeb = 256 # OnlineUsingMobile = 512 obsolete "renamed to ClientTypeMobile" ClientTypeMobile = 512 # OnlineUsingBigPicture = 10...
class EPersonaStateFlag(SteamIntEnum):
HasRichPresence = 1 InJoinableGame = 2 HasGoldenProfile = 4 # OnlineUsingWeb = 256 obsolete "renamed to ClientTypeWeb" ClientTypeWeb = 256 # OnlineUsingMobile = 512 obsolete "renamed to ClientTypeMobile" ClientTypeMobile = 512 # OnlineUsingBigPicture = 1024 obsolete "renamed to ClientTypeTenfo...
): Offline = 0 Online = 1 Busy = 2 Away = 3 Snooze = 4 LookingToTrade = 5 LookingToPlay = 6 Max = 7 class EPersonaStateFlag(SteamIntEnum):
64
64
152
10
53
gosuai/steam
steam/enums/common.py
Python
EPersonaStateFlag
EPersonaStateFlag
398
410
398
398
1242d2cecc3e0030a6f5aefe98a1c6edb22b7465
bigcode/the-stack
train
84a9bfd2b4e4968486e9ed9c
train
class
class EInstanceFlag(SteamIntEnum): MMSLobby = 0x20000 Lobby = 0x40000 Clan = 0x80000
class EInstanceFlag(SteamIntEnum):
MMSLobby = 0x20000 Lobby = 0x40000 Clan = 0x80000
Clan = 7 Chat = 8 ConsoleUser = 9 #: Fake SteamID for local PSN account on PS3 or Live account on 360, etc. AnonUser = 10 Max = 11 class EInstanceFlag(SteamIntEnum):
64
64
37
9
54
gosuai/steam
steam/enums/common.py
Python
EInstanceFlag
EInstanceFlag
143
146
143
143
792798b408ffe5d1ee684e155076d1cefa07ffea
bigcode/the-stack
train
4114d0a3ad158c6c9a55792a
train
class
class EUniverse(SteamIntEnum): Invalid = 0 Public = 1 Beta = 2 Internal = 3 Dev = 4 # RC = 5 #: doesn't exit anymore Max = 6
class EUniverse(SteamIntEnum):
Invalid = 0 Public = 1 Beta = 2 Internal = 3 Dev = 4 # RC = 5 #: doesn't exit anymore Max = 6
Pending = 108 #: There are too many of this thing pending already NoSiteLicensesFound = 109 #: No site licenses found WGNetworkSendExceeded = 110 #: the WG couldn't send a response because we exceeded max network send size class EUniverse(SteamIntEnum):
64
64
56
8
55
gosuai/steam
steam/enums/common.py
Python
EUniverse
EUniverse
118
125
118
118
1b83be60a7e7304aa04a6e698f4a8637eb121ed8
bigcode/the-stack
train
ed40b1f8929c85fdd74b6b5d
train
class
class EAccountFlags(SteamIntEnum): NormalUser = 0 PersonaNameSet = 1 Unbannable = 2 PasswordSet = 4 Support = 8 Admin = 16 Supervisor = 32 AppEditor = 64 HWIDSet = 128 PersonalQASet = 256 VacBeta = 512 Debug = 1024 Disabled = 2048 LimitedUser = 4096 LimitedUse...
class EAccountFlags(SteamIntEnum):
NormalUser = 0 PersonaNameSet = 1 Unbannable = 2 PasswordSet = 4 Support = 8 Admin = 16 Supervisor = 32 AppEditor = 64 HWIDSet = 128 PersonalQASet = 256 VacBeta = 512 Debug = 1024 Disabled = 2048 LimitedUser = 4096 LimitedUserForce = 8192 EmailValidated = ...
Max = 26 class EFriendRelationship(SteamIntEnum): NONE = 0 Blocked = 1 RequestRecipient = 2 Friend = 3 RequestInitiator = 4 Ignored = 5 IgnoredFriend = 6 SuggestedFriend = 7 Max = 8 class EAccountFlags(SteamIntEnum):
87
87
293
9
77
gosuai/steam
steam/enums/common.py
Python
EAccountFlags
EAccountFlags
336
368
336
336
de7d10cc7dff80324c5c4647cee1aaa42008d2a3
bigcode/the-stack
train
da51806b4df5f95db960c913
train
function
def group_update(context, data_dict): group = logic_auth.get_group_object(context, data_dict) user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org(group.id, user, ...
def group_update(context, data_dict):
group = logic_auth.get_group_object(context, data_dict) user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org(group.id, user, 'update') if not auth...
data_dict) if not authorized: return { 'success': False, 'msg': _('User %s not authorized to change state of package %s') % (str(user), package.id) } else: return {'success': True} def group_update(context, data_dict):
64
64
98
8
56
nigelbabu/ckan
ckan/logic/auth/update.py
Python
group_update
group_update
105
116
105
105
face19412a19d26c1ace93272c2796d3ec2e51b3
bigcode/the-stack
train
38837d1e3a454c758a88d629
train
function
def group_edit_permissions(context, data_dict): user = context['user'] group = logic_auth.get_group_object(context, data_dict) authorized = new_authz.has_user_permission_for_group_or_org(group.id, user, ...
def group_edit_permissions(context, data_dict):
user = context['user'] group = logic_auth.get_group_object(context, data_dict) authorized = new_authz.has_user_permission_for_group_or_org(group.id, user, 'update') if not au...
_dict) if not authorized: return { 'success': False, 'msg': _('User %s not authorized to change state of group %s') % (str(user), group.id) } else: return {'success': True} def group_edit_permissions(context, data_dict):
64
64
101
9
55
nigelbabu/ckan
ckan/logic/auth/update.py
Python
group_edit_permissions
group_edit_permissions
172
185
172
172
275f49634757bb2f225a5719f7780161ce474e47
bigcode/the-stack
train
ca44cd516760336e87747dd5
train
function
def task_status_update(context, data_dict): # sysadmins only user = context['user'] return { 'success': False, 'msg': _('User %s not authorized to update task_status table') % user }
def task_status_update(context, data_dict): # sysadmins only
user = context['user'] return { 'success': False, 'msg': _('User %s not authorized to update task_status table') % user }
): # FIXME currently only sysadmins can change state user = context['user'] return { 'success': False, 'msg': _('User %s not authorized to change state of revision') % user } def task_status_update(context, data_dict): # sysadmins only
64
64
52
15
49
nigelbabu/ckan
ckan/logic/auth/update.py
Python
task_status_update
task_status_update
240
246
240
241
ca4bd4d60909f25af3c72e37a9e8d0472a9ac5b8
bigcode/the-stack
train
3b64f81a4b8018e0b636f728
train
function
def package_change_state(context, data_dict): user = context['user'] package = logic_auth.get_package_object(context, data_dict) # use the logic for package_update authorized = new_authz.is_authorized_boolean('package_update', context, ...
def package_change_state(context, data_dict):
user = context['user'] package = logic_auth.get_package_object(context, data_dict) # use the logic for package_update authorized = new_authz.is_authorized_boolean('package_update', context, data_dict) ...
def resource_view_reorder(context, data_dict): return resource_update(context, {'id': data_dict['resource_id']}) def package_relationship_update(context, data_dict): return new_authz.is_authorized('package_relationship_create', context, data...
64
64
112
9
55
nigelbabu/ckan
ckan/logic/auth/update.py
Python
package_change_state
package_change_state
87
102
87
87
351346eeec3717b7547dce79450462961ea98bc2
bigcode/the-stack
train
2ccb9690406190c2d51e9ea5
train
function
def group_change_state(context, data_dict): user = context['user'] group = logic_auth.get_group_object(context, data_dict) # use logic for group_update authorized = new_authz.is_authorized_boolean('group_update', context, ...
def group_change_state(context, data_dict):
user = context['user'] group = logic_auth.get_group_object(context, data_dict) # use logic for group_update authorized = new_authz.is_authorized_boolean('group_update', context, data_dict) if not autho...
featured' in data_dict and data_dict['featured'] != related.featured): return {'success': False, 'msg': _('You must be a sysadmin to change a related item\'s ' 'featured field.')} return {'success': True} def group_change_state(context, data_dict):
64
64
111
9
55
nigelbabu/ckan
ckan/logic/auth/update.py
Python
group_change_state
group_change_state
154
169
154
154
60690aa5876460b6e69c1f15b63322193788a75a
bigcode/the-stack
train
5c7c5ff449dad566b87501ad
train
function
def bulk_update_delete(context, data_dict): org_id = data_dict.get('org_id') user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( org_id, user, 'update') if not authorized: return {'success': False} return {'success': True}
def bulk_update_delete(context, data_dict):
org_id = data_dict.get('org_id') user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( org_id, user, 'update') if not authorized: return {'success': False} return {'success': True}
_dict.get('org_id') user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( org_id, user, 'update') if not authorized: return {'success': False} return {'success': True} def bulk_update_delete(context, data_dict):
64
64
69
9
55
nigelbabu/ckan
ckan/logic/auth/update.py
Python
bulk_update_delete
bulk_update_delete
321
328
321
321
9d083b27081430f0ab17238c10daa6572fe2552f
bigcode/the-stack
train
a93e23a4408b71a8e4775e0b
train
function
def send_email_notifications(context, data_dict): # Only sysadmins are authorized to send email notifications. return {'success': False}
def send_email_notifications(context, data_dict): # Only sysadmins are authorized to send email notifications.
return {'success': False}
authorized to update term_translation table') % user } def dashboard_mark_activities_old(context, data_dict): return new_authz.is_authorized('dashboard_activity_list', context, data_dict) def send_email_notifications(context, data_dict): ...
64
64
28
21
43
nigelbabu/ckan
ckan/logic/auth/update.py
Python
send_email_notifications
send_email_notifications
269
271
269
270
50656e07d62973258025466012c39aaf9a68912d
bigcode/the-stack
train
ce2b3043b03f3e42cb525e50
train
function
def term_translation_update(context, data_dict): # sysadmins only user = context['user'] return { 'success': False, 'msg': _('User %s not authorized to update term_translation table') % user }
def term_translation_update(context, data_dict): # sysadmins only
user = context['user'] return { 'success': False, 'msg': _('User %s not authorized to update term_translation table') % user }
{ 'success': False, 'msg': _('User %s not authorized to update task_status table') % user } def vocabulary_update(context, data_dict): # sysadmins only return {'success': False} def term_translation_update(context, data_dict): # sysadmins only
64
64
52
15
49
nigelbabu/ckan
ckan/logic/auth/update.py
Python
term_translation_update
term_translation_update
254
260
254
255
619cde6ae77c0b5b59bb1bd462066def55284df9
bigcode/the-stack
train
ce54d8e17458fd64fdf9cd5e
train
function
def bulk_update_private(context, data_dict): org_id = data_dict.get('org_id') user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( org_id, user, 'update') if not authorized: return {'success': False} return {'success': True}
def bulk_update_private(context, data_dict):
org_id = data_dict.get('org_id') user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( org_id, user, 'update') if not authorized: return {'success': False} return {'success': True}
: return {'success': False, 'msg': _('Valid API key needed to edit a group')} return group_update(context, data_dict) def package_owner_org_update(context, data_dict): # sysadmins only return {'success': False} def bulk_update_private(context, data_dict):
64
64
69
9
55
nigelbabu/ckan
ckan/logic/auth/update.py
Python
bulk_update_private
bulk_update_private
301
308
301
301
92fb8b63a9e7a64d21ee38fd414425a67b351236
bigcode/the-stack
train
92c4f986a4ae9c681ee1d59c
train
function
def package_owner_org_update(context, data_dict): # sysadmins only return {'success': False}
def package_owner_org_update(context, data_dict): # sysadmins only
return {'success': False}
'] if user in (model.PSEUDO_USER__VISITOR, ''): return {'success': False, 'msg': _('Valid API key needed to edit a group')} return group_update(context, data_dict) def package_owner_org_update(context, data_dict): # sysadmins only
64
64
23
16
48
nigelbabu/ckan
ckan/logic/auth/update.py
Python
package_owner_org_update
package_owner_org_update
296
298
296
297
78f53764fd069fd71105fd5b6b9218c5a748e1df
bigcode/the-stack
train
2af8e0b369ba13b2906f56a5
train
function
def resource_update(context, data_dict): model = context['model'] user = context.get('user') resource = logic_auth.get_resource_object(context, data_dict) # check authentication against package pkg = model.Package.get(resource.package_id) if not pkg: raise logic.NotFound( _(...
def resource_update(context, data_dict):
model = context['model'] user = context.get('user') resource = logic_auth.get_resource_object(context, data_dict) # check authentication against package pkg = model.Package.get(resource.package_id) if not pkg: raise logic.NotFound( _('No package found for this resource, cann...
%s not authorized to edit these groups') % (str(user))} return {'success': True} def package_resource_reorder(context, data_dict): ## the action function runs package update so no need to run it twice return {'success': True} def resource_update(context, data_dict):
64
64
158
8
56
nigelbabu/ckan
ckan/logic/auth/update.py
Python
resource_update
resource_update
52
72
52
52
df10e7aaa1e25c3b6b26d0ba3043ef978b2f659d
bigcode/the-stack
train
60832cd936f58460fe4ac559
train
function
@logic.auth_allow_anonymous_access def user_update(context, data_dict): user = context['user'] # FIXME: We shouldn't have to do a try ... except here, validation should # have ensured that the data_dict contains a valid user id before we get to # authorization. try: user_obj = logic_auth.ge...
@logic.auth_allow_anonymous_access def user_update(context, data_dict):
user = context['user'] # FIXME: We shouldn't have to do a try ... except here, validation should # have ensured that the data_dict contains a valid user id before we get to # authorization. try: user_obj = logic_auth.get_user_object(context, data_dict) except logic.NotFound: ret...
new_authz.has_user_permission_for_group_or_org(group.id, user, 'update') if not authorized: return {'success': False, 'msg': _('User %s not authorized to edit per...
85
85
286
16
69
nigelbabu/ckan
ckan/logic/auth/update.py
Python
user_update
user_update
188
218
188
189
7be13b186933382dcf9d27191c85787de3bb86a9
bigcode/the-stack
train
76c8b1142753cf9d2304353d
train
function
def revision_change_state(context, data_dict): # FIXME currently only sysadmins can change state user = context['user'] return { 'success': False, 'msg': _('User %s not authorized to change state of revision') % user }
def revision_change_state(context, data_dict): # FIXME currently only sysadmins can change state
user = context['user'] return { 'success': False, 'msg': _('User %s not authorized to change state of revision') % user }
user accounts. return {'success': True} return {'success': False, 'msg': _('User {0} not authorized to update user' ' {1}'.format(user, user_obj.id))} def revision_change_state(context, data_dict): # FIXME currently only sysadmins can change state
63
64
57
20
44
nigelbabu/ckan
ckan/logic/auth/update.py
Python
revision_change_state
revision_change_state
231
237
231
232
a5dd537fd023660480c13bc3839d5204ef88f46c
bigcode/the-stack
train
96c2e67ed59f14b6f471f6d2
train
function
def resource_view_update(context, data_dict): return resource_update(context, {'id': data_dict['resource_id']})
def resource_view_update(context, data_dict):
return resource_update(context, {'id': data_dict['resource_id']})
, pkg_dict).get('success') if not authorized: return {'success': False, 'msg': _('User %s not authorized to edit resource %s') % (str(user), resource.id)} else: return {'success': True} def resource_view_update(context, data_dict):
64
64
25
9
55
nigelbabu/ckan
ckan/logic/auth/update.py
Python
resource_view_update
resource_view_update
75
76
75
75
cb18a9533952e9814937db114a1cd17c686a04e1
bigcode/the-stack
train
1b95408b086fb368c77c253a
train
function
def vocabulary_update(context, data_dict): # sysadmins only return {'success': False}
def vocabulary_update(context, data_dict): # sysadmins only
return {'success': False}
_status_update(context, data_dict): # sysadmins only user = context['user'] return { 'success': False, 'msg': _('User %s not authorized to update task_status table') % user } def vocabulary_update(context, data_dict): # sysadmins only
64
64
21
14
50
nigelbabu/ckan
ckan/logic/auth/update.py
Python
vocabulary_update
vocabulary_update
249
251
249
250
59aa326bae2fca925a9f3ece2e7d0bd4071172b0
bigcode/the-stack
train
31bee0a3f210eac789e09df6
train
function
def bulk_update_public(context, data_dict): org_id = data_dict.get('org_id') user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( org_id, user, 'update') if not authorized: return {'success': False} return {'success': True}
def bulk_update_public(context, data_dict):
org_id = data_dict.get('org_id') user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( org_id, user, 'update') if not authorized: return {'success': False} return {'success': True}
_dict.get('org_id') user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( org_id, user, 'update') if not authorized: return {'success': False} return {'success': True} def bulk_update_public(context, data_dict):
64
64
69
9
55
nigelbabu/ckan
ckan/logic/auth/update.py
Python
bulk_update_public
bulk_update_public
311
318
311
311
0e192f4361c5c2e8f86cbf8b598125cb7f7e2f1a
bigcode/the-stack
train
d1df48ba5d9e9d619fa1aca9
train
function
def organization_update(context, data_dict): group = logic_auth.get_group_object(context, data_dict) user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( group.id, user, 'update') if not authorized: return {'success': False, 'msg': _('User %...
def organization_update(context, data_dict):
group = logic_auth.get_group_object(context, data_dict) user = context['user'] authorized = new_authz.has_user_permission_for_group_or_org( group.id, user, 'update') if not authorized: return {'success': False, 'msg': _('User %s not authorized to edit organization %s') % ...
.id, user, 'update') if not authorized: return {'success': False, 'msg': _('User %s not authorized to edit group %s') % (str(user), group.id...
64
64
97
8
56
nigelbabu/ckan
ckan/logic/auth/update.py
Python
organization_update
organization_update
119
129
119
119
e292c8b6b0a67728c5e89011dc934e7970124729
bigcode/the-stack
train
9e0525332ed4268ec2d8ebd0
train
function
def resource_view_reorder(context, data_dict): return resource_update(context, {'id': data_dict['resource_id']})
def resource_view_reorder(context, data_dict):
return resource_update(context, {'id': data_dict['resource_id']})
%s not authorized to edit resource %s') % (str(user), resource.id)} else: return {'success': True} def resource_view_update(context, data_dict): return resource_update(context, {'id': data_dict['resource_id']}) def resource_view_reorder(context, data_dict):
64
64
26
10
54
nigelbabu/ckan
ckan/logic/auth/update.py
Python
resource_view_reorder
resource_view_reorder
78
79
78
78
08c666d591c892e1d63a07ac815edc0432f159d6
bigcode/the-stack
train
0855b839845628b6c0bbbe1d
train
function
def dashboard_mark_activities_old(context, data_dict): return new_authz.is_authorized('dashboard_activity_list', context, data_dict)
def dashboard_mark_activities_old(context, data_dict):
return new_authz.is_authorized('dashboard_activity_list', context, data_dict)
} def term_translation_update(context, data_dict): # sysadmins only user = context['user'] return { 'success': False, 'msg': _('User %s not authorized to update term_translation table') % user } def dashboard_mark_activities_old(context, data_dict):
64
64
31
11
53
nigelbabu/ckan
ckan/logic/auth/update.py
Python
dashboard_mark_activities_old
dashboard_mark_activities_old
263
266
263
263
c98224cc4dd10fcccb4365c924cc3a03e9d25638
bigcode/the-stack
train
960a00747bab98f638b9b746
train
function
def package_resource_reorder(context, data_dict): ## the action function runs package update so no need to run it twice return {'success': True}
def package_resource_reorder(context, data_dict): ## the action function runs package update so no need to run it twice
return {'success': True}
2: return {'success': False, 'msg': _('User %s not authorized to edit these groups') % (str(user))} return {'success': True} def package_resource_reorder(context, data_dict): ## the action function runs package update so no need to run it twice
64
64
33
26
38
nigelbabu/ckan
ckan/logic/auth/update.py
Python
package_resource_reorder
package_resource_reorder
48
50
48
49
666f7ecaf10f7c0a8ca15e8df4e995119bcacb96
bigcode/the-stack
train
5e13b0d766ff8de577902898
train
function
def package_relationship_update(context, data_dict): return new_authz.is_authorized('package_relationship_create', context, data_dict)
def package_relationship_update(context, data_dict):
return new_authz.is_authorized('package_relationship_create', context, data_dict)
success': True} def resource_view_update(context, data_dict): return resource_update(context, {'id': data_dict['resource_id']}) def resource_view_reorder(context, data_dict): return resource_update(context, {'id': data_dict['resource_id']}) def package_relationship_update(context, data_dict):
64
64
29
9
55
nigelbabu/ckan
ckan/logic/auth/update.py
Python
package_relationship_update
package_relationship_update
81
84
81
81
9427ff57b0ea79a564c852580ae746db7fd32376
bigcode/the-stack
train
0a355592ab808dafe2075ac2
train
function
def group_update_rest(context, data_dict): model = context['model'] user = context['user'] if user in (model.PSEUDO_USER__VISITOR, ''): return {'success': False, 'msg': _('Valid API key needed to edit a group')} return group_update(context, data_dict)
def group_update_rest(context, data_dict):
model = context['model'] user = context['user'] if user in (model.PSEUDO_USER__VISITOR, ''): return {'success': False, 'msg': _('Valid API key needed to edit a group')} return group_update(context, data_dict)
if user in (model.PSEUDO_USER__VISITOR, ''): return {'success': False, 'msg': _('Valid API key needed to edit a package')} return new_authz.is_authorized('package_update', context, data_dict) def group_update_rest(context, data_dict):
64
64
70
9
55
nigelbabu/ckan
ckan/logic/auth/update.py
Python
group_update_rest
group_update_rest
286
293
286
286
b0171cbf8c277ab7cff011f17616b2eb9f17138b
bigcode/the-stack
train
1ed4509a1f39b82c67b0a9c6
train
function
def related_update(context, data_dict): model = context['model'] user = context['user'] if not user: return {'success': False, 'msg': _('Only the owner can update a related item')} related = logic_auth.get_related_object(context, data_dict) userobj = model.User.get(user) ...
def related_update(context, data_dict):
model = context['model'] user = context['user'] if not user: return {'success': False, 'msg': _('Only the owner can update a related item')} related = logic_auth.get_related_object(context, data_dict) userobj = model.User.get(user) if not userobj or userobj.id != related...
( group.id, user, 'update') if not authorized: return {'success': False, 'msg': _('User %s not authorized to edit organization %s') % (user, group.id)} else: return {'success': True} def related_update(context, data_dict):
64
64
176
8
56
nigelbabu/ckan
ckan/logic/auth/update.py
Python
related_update
related_update
132
151
132
132
2781a2e8052e2a9fbc3174fc4f553a29a0803cab
bigcode/the-stack
train
ca807e4b777ab719c09350c7
train
function
@logic.auth_allow_anonymous_access def package_update(context, data_dict): user = context.get('user') package = logic_auth.get_package_object(context, data_dict) if package.owner_org: # if there is an owner org then we must have update_dataset # permission for that organization chec...
@logic.auth_allow_anonymous_access def package_update(context, data_dict):
user = context.get('user') package = logic_auth.get_package_object(context, data_dict) if package.owner_org: # if there is an owner org then we must have update_dataset # permission for that organization check1 = new_authz.has_user_permission_for_group_or_org( package.ow...
import ckan.logic as logic import ckan.new_authz as new_authz import ckan.logic.auth as logic_auth from ckan.common import _ # FIXME this import is evil and should be refactored from ckan.logic.auth.create import _check_group_auth @logic.auth_allow_anonymous_access def package_update(context, data_dict):
75
95
319
16
58
nigelbabu/ckan
ckan/logic/auth/update.py
Python
package_update
package_update
10
46
10
11
ee707035813d96a283b23f8caba6b063fbbf1a46
bigcode/the-stack
train
ce3d6ef90e7ab960aa7f82cc
train
function
def user_generate_apikey(context, data_dict): user = context['user'] user_obj = logic_auth.get_user_object(context, data_dict) if user == user_obj.name: # Allow users to update only their own user accounts. return {'success': True} return {'success': False, 'msg': _('User {0} not authori...
def user_generate_apikey(context, data_dict):
user = context['user'] user_obj = logic_auth.get_user_object(context, data_dict) if user == user_obj.name: # Allow users to update only their own user accounts. return {'success': True} return {'success': False, 'msg': _('User {0} not authorized to update user' ' {1}'.format(...
return {'success': True} else: # Don't allow users to update other users' accounts. return {'success': False, 'msg': _('User %s not authorized to edit user %s') % (user, user_obj.id)} def user_generate_apikey(context, data_dict):
63
64
91
10
53
nigelbabu/ckan
ckan/logic/auth/update.py
Python
user_generate_apikey
user_generate_apikey
221
228
221
221
f409dd099fc87a8a273d48999b45d6c3b3e54d44
bigcode/the-stack
train
6f8c4ae189ab49be4220eb82
train
function
def package_update_rest(context, data_dict): model = context['model'] user = context['user'] if user in (model.PSEUDO_USER__VISITOR, ''): return {'success': False, 'msg': _('Valid API key needed to edit a package')} return new_authz.is_authorized('package_update', context, data_...
def package_update_rest(context, data_dict):
model = context['model'] user = context['user'] if user in (model.PSEUDO_USER__VISITOR, ''): return {'success': False, 'msg': _('Valid API key needed to edit a package')} return new_authz.is_authorized('package_update', context, data_dict)
return new_authz.is_authorized('dashboard_activity_list', context, data_dict) def send_email_notifications(context, data_dict): # Only sysadmins are authorized to send email notifications. return {'success': False} ## Modifications fo...
64
64
78
9
54
nigelbabu/ckan
ckan/logic/auth/update.py
Python
package_update_rest
package_update_rest
276
283
276
276
9f8a5ceff3300ef2c5edb528b05b8e6cdbff8873
bigcode/the-stack
train
24147086ada2ee8cf7e67227
train
function
def square(a): return float(a) ** 2
def square(a):
return float(a) ** 2
def square(a):
4
64
13
4
0
kefsaj/PythonCalculator
src/square.py
Python
square
square
2
3
2
2
5382958473e9a84d0bd488cdae663cefa4a28e00
bigcode/the-stack
train
c70fe14a6c7bd23d5851eacf
train
class
class Solution: def removeElement(self, nums: List[int], val: int) -> int: # check empty input if not nums: return 0 # initialize index element_index = 0 # loop until out of range while element_index < len(nums): # remove the item if nums[elem...
class Solution:
def removeElement(self, nums: List[int], val: int) -> int: # check empty input if not nums: return 0 # initialize index element_index = 0 # loop until out of range while element_index < len(nums): # remove the item if nums[element_index] == va...
# 2020.07.30 # Problem Statement: # https://leetcode.com/problems/remove-element/ class Solution:
25
64
112
3
22
ljn1999/LeetCode-problems
q26-50/q27.py
Python
Solution
Solution
5
21
5
5
4139d8e2da8c38073ae913bdc22dbb89089685e4
bigcode/the-stack
train
f6f017c610c1a91800bca2ae
train
function
def get_predictor(net, brs_mode, device, prob_thresh=0.49, with_flip=True, zoom_in_params=dict(), predictor_params=None, brs_opt_func_params=None, lbfgs_params=None): lbfgs_params_ = { 'm': 20, ...
def get_predictor(net, brs_mode, device, prob_thresh=0.49, with_flip=True, zoom_in_params=dict(), predictor_params=None, brs_opt_func_params=None, lbfgs_params=None):
lbfgs_params_ = { 'm': 20, 'factr': 0, 'pgtol': 1e-8, 'maxfun': 20, } predictor_params_ = { 'optimize_after_n_clicks': 1 } #if zoom_in_params is not None: # zoom_in = ZoomIn(**zoom_in_params) #else: # zoom_in = None zoom_in = None ...
from .base import BasePredictor from .brs import InputBRSPredictor, FeatureBRSPredictor, HRNetFeatureBRSPredictor from .brs_functors import InputOptimizer, ScaleBiasOptimizer from isegm.inference.transforms import ZoomIn from isegm.model.is_hrnet_model import HRNetModel def get_predictor(net, brs_mode, device, ...
123
222
740
51
71
supervisely-ecosystem/ritm-interactive-segmentation
isegm/inference/predictors/__init__.py
Python
get_predictor
get_predictor
8
99
8
14
1b67c64257639173c7a638b0e4b8c938a05bbf4a
bigcode/the-stack
train
db99ded68f21dcc8bf81cc3b
train
class
class StokesFrame(CoordinateFrame): """ A coordinate frame for representing stokes polarisation states Parameters ---------- name : str Name of this frame. """ def __init__(self, axes_order=(0,), name=None): self._stokes_components = ['I', 'Q', 'U', 'V'] super(Stoke...
class StokesFrame(CoordinateFrame):
""" A coordinate frame for representing stokes polarisation states Parameters ---------- name : str Name of this frame. """ def __init__(self, axes_order=(0,), name=None): self._stokes_components = ['I', 'Q', 'U', 'V'] super(StokesFrame, self).__init__(1, ["STOKES"]...
number of arguments") qs = [] for _frame, arg in zip(self.frames, args): ret = _frame.coordinate_to_quantity(arg) if isinstance(ret, tuple): qs += list(ret) else: qs.append(ret) return qs class StokesFrame(CoordinateFrame):
64
64
213
8
55
cshanahan1/gwcs
gwcs/coordinate_frames.py
Python
StokesFrame
StokesFrame
516
543
516
516
2e92bdcc2cbb55deac05beab275a4b5779e3c84f
bigcode/the-stack
train
466b6368e9698ede99bd6a76
train
class
class CelestialFrame(CoordinateFrame): """ Celestial Frame Representation Parameters ---------- axes_order : tuple of int A dimension in the input data that corresponds to this axis. reference_frame : astropy.coordinates.builtin_frames A reference frame. unit : str or units....
class CelestialFrame(CoordinateFrame):
""" Celestial Frame Representation Parameters ---------- axes_order : tuple of int A dimension in the input data that corresponds to this axis. reference_frame : astropy.coordinates.builtin_frames A reference frame. unit : str or units.Unit instance or iterable of those ...
. """ return getattr(self, "_reference_position", None) @property def axes_type(self): """ Type of this frame : 'SPATIAL', 'SPECTRAL', 'TIME'. """ return self._axes_type def coordinates(self, *args): """ Create world coordinates object""" args = [args[i] for i in se...
190
190
634
8
181
cshanahan1/gwcs
gwcs/coordinate_frames.py
Python
CelestialFrame
CelestialFrame
236
323
236
236
c779424843d5f450085f58440f0a8e996b9b256f
bigcode/the-stack
train
48cdb33bb4e8a214c43a16fb
train
class
class SpectralFrame(CoordinateFrame): """ Represents Spectral Frame Parameters ---------- axes_order : tuple or int A dimension in the input data that corresponds to this axis. reference_frame : astropy.coordinates.builtin_frames Reference frame (usually used with output_frame t...
class SpectralFrame(CoordinateFrame):
""" Represents Spectral Frame Parameters ---------- axes_order : tuple or int A dimension in the input data that corresponds to this axis. reference_frame : astropy.coordinates.builtin_frames Reference frame (usually used with output_frame to convert to world coordinate objects)...
= arg.transform_to(self._reference_frame) try: lon = arg.data.lon lat = arg.data.lat except AttributeError: lon = arg.spherical.lon lat = arg.spherical.lat return lon, lat elif all(isinstance(a, u.Quantity) fo...
103
103
345
8
95
cshanahan1/gwcs
gwcs/coordinate_frames.py
Python
SpectralFrame
SpectralFrame
326
368
326
326
74d17d81e40497d724020d8dad5b6675d99e571c
bigcode/the-stack
train
6dd603dd582f89252ba97bdf
train
class
class TemporalFrame(CoordinateFrame): """ A coordinate frame for time axes. Parameters ---------- axes_order : tuple or int A dimension in the input data that corresponds to this axis. reference_frame : `object` The object to instantiate to represent the time coordinate. Default...
class TemporalFrame(CoordinateFrame):
""" A coordinate frame for time axes. Parameters ---------- axes_order : tuple or int A dimension in the input data that corresponds to this axis. reference_frame : `object` The object to instantiate to represent the time coordinate. Defaults to `astropy.time.Time`. Use ...
reference_position=reference_position, axis_physical_types=axis_physical_types) def coordinates(self, *args, equivalencies=[]): if hasattr(args[0], 'unit'): return args[0].to(self.unit[0], equivalenc...
140
140
467
7
133
cshanahan1/gwcs
gwcs/coordinate_frames.py
Python
TemporalFrame
TemporalFrame
371
430
371
371
88274755456cf25a28431c9af5630a6cd9105ebe
bigcode/the-stack
train
ee8f441a9704e743d15a8271
train
class
class CompositeFrame(CoordinateFrame): """ Represents one or more frames. Parameters ---------- frames : list List of frames (TemporalFrame, CelestialFrame, SpectralFrame, CoordinateFrame). name : str Name for this frame. """ def __init__(self, frames, name=None): ...
class CompositeFrame(CoordinateFrame):
""" Represents one or more frames. Parameters ---------- frames : list List of frames (TemporalFrame, CelestialFrame, SpectralFrame, CoordinateFrame). name : str Name for this frame. """ def __init__(self, frames, name=None): self._frames = frames[:] na...
dt = args[0] if self.reference_position: if not hasattr(dt, 'unit'): dt = dt * self.unit[0] return self.reference_position + dt else: return self.reference_frame(dt) def coordinate_to_quantity(self, *coords): if isinstance(c...
179
180
600
7
172
cshanahan1/gwcs
gwcs/coordinate_frames.py
Python
CompositeFrame
CompositeFrame
433
513
433
433
585c010d473dfeb252ca4f99766dc8789f4c9087
bigcode/the-stack
train
8a6a6cd3bfba53e38e3968a6
train
class
class CoordinateFrame: """ Base class for Coordinate Frames. Parameters ---------- naxes : int Number of axes. axes_type : str One of ["SPATIAL", "SPECTRAL", "TIME"] axes_order : tuple of int A dimension in the input data that corresponds to this axis. reference_...
class CoordinateFrame:
""" Base class for Coordinate Frames. Parameters ---------- naxes : int Number of axes. axes_type : str One of ["SPATIAL", "SPECTRAL", "TIME"] axes_order : tuple of int A dimension in the input data that corresponds to this axis. reference_frame : astropy.coordin...
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Defines coordinate frames and ties them to data axes. """ import numpy as np from astropy.utils.misc import isiterable import astropy.time from astropy import units as u from astropy import utils as astutil from astropy import coordinates as coord fro...
203
256
1,661
4
199
cshanahan1/gwcs
gwcs/coordinate_frames.py
Python
CoordinateFrame
CoordinateFrame
27
233
27
27
df599e1e2b147425d0a7fbf1597aec1ad9ce6fcb
bigcode/the-stack
train
d92f70d6613037e07a359c4e
train
class
class Frame2D(CoordinateFrame): """ A 2D coordinate frame. Parameters ---------- axes_order : tuple of int A dimension in the input data that corresponds to this axis. unit : list of astropy.units.Unit Unit for each axis. axes_names : list Names of the axes in this f...
class Frame2D(CoordinateFrame):
""" A 2D coordinate frame. Parameters ---------- axes_order : tuple of int A dimension in the input data that corresponds to this axis. unit : list of astropy.units.Unit Unit for each axis. axes_names : list Names of the axes in this frame. name : str Nam...
(self, *args): if hasattr(args[0], 'value'): arg = args[0].value else: arg = args[0] return self._stokes_components[int(arg)] def coordinate_to_quantity(self, *coords): if isinstance(coords[0], str): if coords[0] in self._stokes_components: ...
109
109
366
8
101
cshanahan1/gwcs
gwcs/coordinate_frames.py
Python
Frame2D
Frame2D
546
589
546
546
0a2b0d6998f5ff4f07fa8428319a3d95dbc41b72
bigcode/the-stack
train
67c20750aff0cbb041402c8f
train
class
class Solution(object): def combinationSum3(self, k, n): """ :type k: int :type n: int :rtype: List[List[int]] """ return self.combinationSum3_helper(k, n) def combinationSum3_helper(self, k, n, prev_num=0, track=[]): if k == 1 and prev_num < n < 10: ...
class Solution(object):
def combinationSum3(self, k, n): """ :type k: int :type n: int :rtype: List[List[int]] """ return self.combinationSum3_helper(k, n) def combinationSum3_helper(self, k, n, prev_num=0, track=[]): if k == 1 and prev_num < n < 10: return [track+[...
class Solution(object):
4
64
137
4
0
xuychen/Leetcode
201-300/211-220/216-combinationSum3/combinationSum3.py
Python
Solution
Solution
1
19
1
1
13dd43b7e578082327b4b860d0d9fbb1ca518fb3
bigcode/the-stack
train
10c36ec481e94c091ab6a60a
train
function
@bp.route('/<path:path>', methods=['GET']) def any_root_path(path): """Rendering the React template.""" return render_template('index.html')
@bp.route('/<path:path>', methods=['GET']) def any_root_path(path):
"""Rendering the React template.""" return render_template('index.html')
Public section.""" from flask import Blueprint, render_template bp = Blueprint('public', __name__) @bp.route('/', methods=['GET']) def index(): """Rendering the React template.""" return render_template('index.html') @bp.route('/<path:path>', methods=['GET']) def any_root_path(path):
64
64
33
18
46
myles/api.mylesb.ca
api/public/views.py
Python
any_root_path
any_root_path
14
17
14
15
bfe64c8c1915cf418eecc0ddc2a3cb586a6a70fd
bigcode/the-stack
train
98107c46ef4146a7280cda9b
train
function
@bp.route('/', methods=['GET']) def index(): """Rendering the React template.""" return render_template('index.html')
@bp.route('/', methods=['GET']) def index():
"""Rendering the React template.""" return render_template('index.html')
# -*- coding: utf-8 -*- """Public section.""" from flask import Blueprint, render_template bp = Blueprint('public', __name__) @bp.route('/', methods=['GET']) def index():
40
64
26
11
29
myles/api.mylesb.ca
api/public/views.py
Python
index
index
8
11
8
9
a8dc5e0d374b42a2fa2e31f43813505fea449ce6
bigcode/the-stack
train
d2197b302e7e18e74e6d6f3d
train
class
class BasketPage(BasePage): def basket_should_be_empty(self): basket_status = self.browser.find_element(*BasketPageLocators.BASKET_STATUS).text assert 'Your basket is empty.' in basket_status, "Basket is not empty!"
class BasketPage(BasePage):
def basket_should_be_empty(self): basket_status = self.browser.find_element(*BasketPageLocators.BASKET_STATUS).text assert 'Your basket is empty.' in basket_status, "Basket is not empty!"
from .base_page import BasePage from .locators import BasketPageLocators class BasketPage(BasePage):
24
64
52
6
17
OlegM8/selenium_test_project
pages/basket_page.py
Python
BasketPage
BasketPage
5
9
5
6
e6e88543b039a0eb9660a25ae97137e9dbfd7d56
bigcode/the-stack
train
7ca22de958463f85f7ba829c
train
class
class TemplatesService(object): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ def __init__(self, api_client=None): # noqa: E501,D401,D403 """TemplatesService - a operation defined in OpenAPI.""" ...
class TemplatesService(object):
"""NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ def __init__(self, api_client=None): # noqa: E501,D401,D403 """TemplatesService - a operation defined in OpenAPI.""" if api_client is None: ...
# coding: utf-8 """ InfluxDB OSS API Service. The InfluxDB v2 API provides a programmatic interface for all interactions with InfluxDB. Access the InfluxDB API using the `/api/v2/` endpoint. # noqa: E501 OpenAPI spec version: 2.0.0 Generated by: https://openapi-generator.tech """ from __future__ import absolute_...
117
256
7,191
5
111
MASIFAYUB/influxdb-client-python
influxdb_client/service/templates_service.py
Python
TemplatesService
TemplatesService
21
863
21
21
20c9dd2a0a3ffcbd44384c0ca9b8d43421e7fd5e
bigcode/the-stack
train
1e2d428ccc40746ce05f228c
train
class
class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Question', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ...
class Migration(migrations.Migration):
initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Question', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('question_text', models.CharField(max_l...
# Generated by Django 3.0.2 on 2020-01-13 18:26 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration):
45
64
168
7
37
G3Code-CS/Django-tutorial
pollster/polls/migrations/0001_initial.py
Python
Migration
Migration
7
31
7
8
fb0fde3c4f64ac23de4702c6bb0d4417a12f900d
bigcode/the-stack
train
6dd405c2a4956bab14db5182
train
function
def get_products(): try: if server == False: credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIALS_FILEPATH, AUTH_SCOPE) else: credentials = ServiceAccountCredentials._from_parsed_json_keyfile(json.loads(GOOGLE_API_CREDENTIALS), AUTH_SCOPE) client...
def get_products():
try: if server == False: credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIALS_FILEPATH, AUTH_SCOPE) else: credentials = ServiceAccountCredentials._from_parsed_json_keyfile(json.loads(GOOGLE_API_CREDENTIALS), AUTH_SCOPE) client = gspread.authorize...
REDENTIALS") AUTH_SCOPE = [ "https://www.googleapis.com/auth/spreadsheets", #> Allows read/write access to the user's sheets and their properties. "https://www.googleapis.com/auth/drive.file" #> Per-file access to files created or opened by the app. ] def get_products():
64
64
192
4
60
colin-mills/Daily-Debrief-notification-service
app/spreadsheet.py
Python
get_products
get_products
34
52
34
34
b8a40106f529558e5f0379b69e27568d8ded5f32
bigcode/the-stack
train
ffd310c36eb3980db5c4a267
train
function
def PDFsplit(pdf, splits=None): # clean temp folder for filename in os.listdir(config.TEMPS_PDF_FOLDER): os.remove(filename) if not splits: splits = SPLIT_PAGES # creating input pdf file object pdfFileObj = open(pdf, 'rb') # creating pdf reader object pdfReader = PyPDF2.PdfFileReader(pdfFileObj)...
def PDFsplit(pdf, splits=None): # clean temp folder
for filename in os.listdir(config.TEMPS_PDF_FOLDER): os.remove(filename) if not splits: splits = SPLIT_PAGES # creating input pdf file object pdfFileObj = open(pdf, 'rb') # creating pdf reader object pdfReader = PyPDF2.PdfFileReader(pdfFileObj) # starting index of first slice start = 0 # ...
# importing the required modules import PyPDF2 # global config from . import skiconfig # config from . import config # system tools import os SPLIT_PAGES = [1, 2] def PDFsplit(pdf, splits=None): # clean temp folder
64
113
378
15
49
NathBangwa/SkimindFoot
skimind/kernel/pdfManag/page_spliter.py
Python
PDFsplit
PDFsplit
16
73
16
17
f9e98da282a8244dc932edf2004f4226aaa11b9e
bigcode/the-stack
train
054c33bdaebd92e5bc4a629b
train
function
def call(*args): from subprocess import Popen, PIPE, STDOUT path = dirname(args[-1]) p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True, cwd=path) exitcode = p.wait() if exitcode != 0: raise Exception('Exitcode %s: %s' % (exitcode, ...
def call(*args):
from subprocess import Popen, PIPE, STDOUT path = dirname(args[-1]) p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True, cwd=path) exitcode = p.wait() if exitcode != 0: raise Exception('Exitcode %s: %s' % (exitcode, p.stderr.read()))...
import remove, makedirs from os.path import abspath, basename, dirname, exists, splitext from glob import glob NESASM_C_BIN = abspath('tools/nesasm/bin/nesasm') NESASM_PY_BIN = abspath('bin/nesasm') def call(*args):
64
64
92
5
59
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
call
call
11
20
11
11
96542e18d38a5af51dbdbd91096a9944742248ce
bigcode/the-stack
train
e91a6cf60c7018cf69339c7f
train
class
class Background3Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/background/background3.asm'
class Background3Test(NESAsmCiSuite, HexFileTestCase):
fixture = 'nerdynights/background/background3.asm'
(NESAsmCiSuite, HexFileTestCase): fixture = 'movingsprite/movingsprite.asm' class BackgroundTest(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/background/background.asm' class Background3Test(NESAsmCiSuite, HexFileTestCase):
64
64
27
15
49
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
Background3Test
Background3Test
121
122
121
121
e866b464ce5d68a2988c2273b675b398cfb553fc
bigcode/the-stack
train
7b5d435738798761df451752
train
class
class Scrolling2Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/scrolling/scrolling2.asm'
class Scrolling2Test(NESAsmCiSuite, HexFileTestCase):
fixture = 'nerdynights/scrolling/scrolling2.asm'
FileTestCase): fixture = 'nerdynights/background/background3.asm' class Scrolling1Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/scrolling/scrolling1.asm' class Scrolling2Test(NESAsmCiSuite, HexFileTestCase):
64
64
32
16
48
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
Scrolling2Test
Scrolling2Test
129
130
129
129
eb9e062b723a3ee411b28b20af2fa66cb585abf1
bigcode/the-stack
train
c0a442691e862b567a33f8ec
train
function
def prepare_scenario(_input, _output): from distutils.dir_util import copy_tree from shutil import rmtree if exists(_output): rmtree(_output) makedirs(_output) path = dirname(abspath(_input)) filename = basename(_input) copy_tree(path, _output) for f in glob(_output + '/*.nes'):...
def prepare_scenario(_input, _output):
from distutils.dir_util import copy_tree from shutil import rmtree if exists(_output): rmtree(_output) makedirs(_output) path = dirname(abspath(_input)) filename = basename(_input) copy_tree(path, _output) for f in glob(_output + '/*.nes'): remove(f) return _output ...
: %s' % (exitcode, p.stderr.read())) def nesasm_c(_input): call(NESASM_C_BIN, _input) def nesasm_py(_input): call(NESASM_PY_BIN, 'asm', _input) def prepare_scenario(_input, _output):
64
64
95
10
54
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
prepare_scenario
prepare_scenario
31
44
31
31
e7547e4a13de1ce2fd497fcdbbb0ecba7687caed
bigcode/the-stack
train
a2236bb4dc76c34410ea83dc
train
class
class Scrolling1Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/scrolling/scrolling1.asm'
class Scrolling1Test(NESAsmCiSuite, HexFileTestCase):
fixture = 'nerdynights/scrolling/scrolling1.asm'
ESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/background/background.asm' class Background3Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/background/background3.asm' class Scrolling1Test(NESAsmCiSuite, HexFileTestCase):
64
64
32
16
48
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
Scrolling1Test
Scrolling1Test
125
126
125
125
68377731210bb9afd2e37a63783cf0b5a2a075ba
bigcode/the-stack
train
87dd9ff9cf02fde2fceba9e3
train
class
class NESAsmCiSuite(object): @classmethod def setUpClass(cls): if not exists(NESASM_C_BIN): return _input = 'fixtures/%s' % cls.fixture _filename = splitext(basename(_input))[0] from sys import version_info version = '_'.join([str(c) for c in version_info[:...
class NESAsmCiSuite(object): @classmethod
def setUpClass(cls): if not exists(NESASM_C_BIN): return _input = 'fixtures/%s' % cls.fixture _filename = splitext(basename(_input))[0] from sys import version_info version = '_'.join([str(c) for c in version_info[:3]]) c_out = '/tmp/nesasm/%s/%s/nesasm_...
Exitcode %s: %s' % (exitcode, p.stderr.read())) def nesasm_c(_input): call(NESASM_C_BIN, _input) def nesasm_py(_input): call(NESASM_PY_BIN, 'asm', _input) def prepare_scenario(_input, _output): from distutils.dir_util import copy_tree from shutil import rmtree if exists(_output): rmtre...
164
164
548
11
152
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
NESAsmCiSuite
NESAsmCiSuite
47
110
47
49
56e77c684e943dc31de40c9bf767704ad9b95999
bigcode/the-stack
train
3ed1fc0ac9ccb2528de377a3
train
class
class Scrolling4Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/scrolling/scrolling4.asm'
class Scrolling4Test(NESAsmCiSuite, HexFileTestCase):
fixture = 'nerdynights/scrolling/scrolling4.asm'
fixture = 'nerdynights/scrolling/scrolling2.asm' class Scrolling3Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/scrolling/scrolling3.asm' class Scrolling4Test(NESAsmCiSuite, HexFileTestCase):
64
64
32
16
48
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
Scrolling4Test
Scrolling4Test
137
138
137
137
0d67b3f911874e9db94b70bd007688acf223327b
bigcode/the-stack
train
09c69be82e4a8c6f019def12
train
class
class Scrolling5Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/scrolling/scrolling5.asm'
class Scrolling5Test(NESAsmCiSuite, HexFileTestCase):
fixture = 'nerdynights/scrolling/scrolling5.asm'
fixture = 'nerdynights/scrolling/scrolling3.asm' class Scrolling4Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/scrolling/scrolling4.asm' class Scrolling5Test(NESAsmCiSuite, HexFileTestCase):
64
64
32
16
48
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
Scrolling5Test
Scrolling5Test
141
142
141
141
20a1acfb184b3ae738843bf16f7bae81ce8437d9
bigcode/the-stack
train
e88985d43740d4dccf43645e
train
function
def nesasm_py(_input): call(NESASM_PY_BIN, 'asm', _input)
def nesasm_py(_input):
call(NESASM_PY_BIN, 'asm', _input)
path) exitcode = p.wait() if exitcode != 0: raise Exception('Exitcode %s: %s' % (exitcode, p.stderr.read())) def nesasm_c(_input): call(NESASM_C_BIN, _input) def nesasm_py(_input):
64
64
22
7
57
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
nesasm_py
nesasm_py
27
28
27
27
4175bb496337515eeddc9c52bc823e50c2c002eb
bigcode/the-stack
train
31073bb13c9f66fa1f1798f3
train
function
def nesasm_c(_input): call(NESASM_C_BIN, _input)
def nesasm_c(_input):
call(NESASM_C_BIN, _input)
, stdout=PIPE, stderr=PIPE, close_fds=True, cwd=path) exitcode = p.wait() if exitcode != 0: raise Exception('Exitcode %s: %s' % (exitcode, p.stderr.read())) def nesasm_c(_input):
63
64
18
7
56
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
nesasm_c
nesasm_c
23
24
23
23
0d7503e9d564ed67189803e1e394442ecce319b9
bigcode/the-stack
train
6e293299f57a569d0d8127de
train
class
class MovingspriteTest(NESAsmCiSuite, HexFileTestCase): fixture = 'movingsprite/movingsprite.asm'
class MovingspriteTest(NESAsmCiSuite, HexFileTestCase):
fixture = 'movingsprite/movingsprite.asm'
except AttributeError: _items = get_labels(ast).items labels_py = {k: '${:02X}'.format(v) for k, v in _items()} self.assertEquals(labels_c, labels_py) class MovingspriteTest(NESAsmCiSuite, HexFileTestCase):
64
64
29
16
48
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
MovingspriteTest
MovingspriteTest
113
114
113
113
813639df13a777360fab5c675b7bcece7c7200dd
bigcode/the-stack
train
1e63b72e8836a9d32af32049
train
class
class Scrolling3Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/scrolling/scrolling3.asm'
class Scrolling3Test(NESAsmCiSuite, HexFileTestCase):
fixture = 'nerdynights/scrolling/scrolling3.asm'
fixture = 'nerdynights/scrolling/scrolling1.asm' class Scrolling2Test(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/scrolling/scrolling2.asm' class Scrolling3Test(NESAsmCiSuite, HexFileTestCase):
64
64
32
16
48
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
Scrolling3Test
Scrolling3Test
133
134
133
133
52a70f9fe9e7a431273436b90b8a089a8cdffa23
bigcode/the-stack
train
d8eea670f039e9a3a23f4673
train
class
class BackgroundTest(NESAsmCiSuite, HexFileTestCase): fixture = 'nerdynights/background/background.asm'
class BackgroundTest(NESAsmCiSuite, HexFileTestCase):
fixture = 'nerdynights/background/background.asm'
(v) for k, v in _items()} self.assertEquals(labels_c, labels_py) class MovingspriteTest(NESAsmCiSuite, HexFileTestCase): fixture = 'movingsprite/movingsprite.asm' class BackgroundTest(NESAsmCiSuite, HexFileTestCase):
64
64
25
14
50
gutomaia/nesasm_py
nesasm/tests/nesasm_ci_test.py
Python
BackgroundTest
BackgroundTest
117
118
117
117
934481faa86d178140ccfb4441427d37eafa53c4
bigcode/the-stack
train
787e3e790387e86f702766cf
train
function
@app.on_message( filters.regex(r"s([{}]).*?\1.*".format("".join(DELIMITERS))), group=regex_group, ) async def sed(_, message): if not message.text: return sed_result = separate_sed(message.text) if message.reply_to_message: if message.reply_to_message.text: to_fix = messa...
@app.on_message( filters.regex(r"s([{}]).*?\1.*".format("".join(DELIMITERS))), group=regex_group, ) async def sed(_, message):
if not message.text: return sed_result = separate_sed(message.text) if message.reply_to_message: if message.reply_to_message.text: to_fix = message.reply_to_message.text elif message.reply_to_message.caption: to_fix = message.reply_to_message.caption e...
g_bot/modules/sed.py import re import sre_constants from pyrogram import filters from wbb import app from wbb.utils.filter_groups import regex_group #__MODULE__ = "Sed" #__HELP__ = "**Usage:**\ns/foo/bar" DELIMITERS = ("/", ":", "|", "_") @app.on_message( filters.regex(r"s([{}]).*?\1.*".format("".join(DELIMITER...
107
107
358
39
68
REYANxD/WilliamButcherBot-1
wbb/modules/regex.py
Python
sed
sed
16
66
16
20
ffdd0ff03d152b60d4580637c53d1b29bbb3c332
bigcode/the-stack
train
9edd7be741d3da520600c3c7
train
function
def separate_sed(sed_string): if ( len(sed_string) >= 3 and sed_string[1] in DELIMITERS and sed_string.count(sed_string[1]) >= 2 ): delim = sed_string[1] start = counter = 2 while counter < len(sed_string): if sed_string[counter] == "\\": ...
def separate_sed(sed_string):
if ( len(sed_string) >= 3 and sed_string[1] in DELIMITERS and sed_string.count(sed_string[1]) >= 2 ): delim = sed_string[1] start = counter = 2 while counter < len(sed_string): if sed_string[counter] == "\\": counter += 1 ...
,}\{\d(,)?\}[\)\]]\{\d(,)?\}", r"\(.{1,}\)\{.{1,}(,)?\}\(.*\)(\+|\* |\{.*\})", ] for match in regex: status = re.search(match, repl) return bool(status) def separate_sed(sed_string):
82
82
274
8
74
REYANxD/WilliamButcherBot-1
wbb/modules/regex.py
Python
separate_sed
separate_sed
80
122
80
80
716a0621f5df7234f5813a51b0e78099f381e236
bigcode/the-stack
train
29364b54d237be1e9e2c823f
train
function
def infinite_checker(repl): regex = [ r"\((.{1,}[\+\*]){1,}\)[\+\*].", r"[\(\[].{1,}\{\d(,)?\}[\)\]]\{\d(,)?\}", r"\(.{1,}\)\{.{1,}(,)?\}\(.*\)(\+|\* |\{.*\})", ] for match in regex: status = re.search(match, repl) return bool(status)
def infinite_checker(repl):
regex = [ r"\((.{1,}[\+\*]){1,}\)[\+\*].", r"[\(\[].{1,}\{\d(,)?\}[\)\]]\{\d(,)?\}", r"\(.{1,}\)\{.{1,}(,)?\}\(.*\)(\+|\* |\{.*\})", ] for match in regex: status = re.search(match, repl) return bool(status)
return # empty string errors -_- if len(text) >= 4096: await message.reply_text( "The result of the sed command was too long for \ telegram!" ) elif text: await message.reply_to_message.reply_t...
64
64
114
6
58
REYANxD/WilliamButcherBot-1
wbb/modules/regex.py
Python
infinite_checker
infinite_checker
69
77
69
69
42fda4ffc0fa3e4ee90efc5d0ba913ca6c29cf17
bigcode/the-stack
train
326560bf34ba67807b71a100
train
function
def _assert_files_are_equal(file, expected_file): with open(file, "r") as f, open(expected_file, "r") as exp_f: expected_file_content = exp_f.read() expected_file_content = expected_file_content.replace("<DIR>", os.path.dirname(file)) assert_that(f.read()).is_equal_to(expected_file_content)
def _assert_files_are_equal(file, expected_file):
with open(file, "r") as f, open(expected_file, "r") as exp_f: expected_file_content = exp_f.read() expected_file_content = expected_file_content.replace("<DIR>", os.path.dirname(file)) assert_that(f.read()).is_equal_to(expected_file_content)
test_datadir / "expected_outputs" / file) _assert_files_are_equal( tmpdir / "pcluster/instance_name_type_mappings.json", test_datadir / "expected_outputs/pcluster/instance_name_type_mappings.json", ) def _assert_files_are_equal(file, expected_file):
64
64
72
11
53
pinak-p/aws-parallelcluster-cookbook
test/unit/slurm/test_slurm_config_generator.py
Python
_assert_files_are_equal
_assert_files_are_equal
42
46
42
42
be0792133fca0f71126d108439411ba5e915ef4e
bigcode/the-stack
train
23130748e9602e3b0467285d
train
function
@pytest.mark.parametrize( "no_gpu", [False, True], ) def test_generate_slurm_config_files(mocker, test_datadir, tmpdir, no_gpu): input_file = str(test_datadir / "sample_input.yaml") instance_types_data = str(test_datadir / "sample_instance_types_data.json") mocker.patch("slurm.pcluster_slurm_config...
@pytest.mark.parametrize( "no_gpu", [False, True], ) def test_generate_slurm_config_files(mocker, test_datadir, tmpdir, no_gpu):
input_file = str(test_datadir / "sample_input.yaml") instance_types_data = str(test_datadir / "sample_instance_types_data.json") mocker.patch("slurm.pcluster_slurm_config_generator.gethostname", return_value="ip-1-0-0-0", autospec=True) mocker.patch( "slurm.pcluster_slurm_config_generator._get_...
import os import pytest import slurm from assertpy import assert_that from slurm.pcluster_slurm_config_generator import generate_slurm_config_files @pytest.mark.parametrize( "no_gpu", [False, True], ) def test_generate_slurm_config_files(mocker, test_datadir, tmpdir, no_gpu):
69
119
397
36
32
pinak-p/aws-parallelcluster-cookbook
test/unit/slurm/test_slurm_config_generator.py
Python
test_generate_slurm_config_files
test_generate_slurm_config_files
9
39
9
13
e9e1fc2f4c529ceaf2a3000ff37bf40725b9cea1
bigcode/the-stack
train
705ab55314539e9b146cc27a
train
class
class TaskDetailView(LoginRequiredMixin, DetailView): queryset = Task.objects.all() template_name = 'tasks/task_detail.html'
class TaskDetailView(LoginRequiredMixin, DetailView):
queryset = Task.objects.all() template_name = 'tasks/task_detail.html'
from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import TemplateView, DetailView from .models import Task class TaskManagement(LoginRequiredMixin, TemplateView): template_name = 'tasks/management.html' class TaskDetailView(LoginRequiredMixin, DetailView):
59
64
28
11
48
binfeng1018/competitions-v2
src/apps/tasks/views.py
Python
TaskDetailView
TaskDetailView
11
13
11
11
18014721d29a9c496c0c011de05b13f060e350f8
bigcode/the-stack
train
2ee838af98729edbc78dfbdb
train
class
class TaskManagement(LoginRequiredMixin, TemplateView): template_name = 'tasks/management.html'
class TaskManagement(LoginRequiredMixin, TemplateView):
template_name = 'tasks/management.html'
from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import TemplateView, DetailView from .models import Task class TaskManagement(LoginRequiredMixin, TemplateView):
38
64
20
10
27
binfeng1018/competitions-v2
src/apps/tasks/views.py
Python
TaskManagement
TaskManagement
7
8
7
7
a98d6f1dbd58255663fd0aaefdd1f2a10efdb845
bigcode/the-stack
train
4fa721f2617defc6970bbec5
train
class
class TestTracking(APITestCase): def test_tracking_shipment(self): url = reverse( 'purpleserver.proxy:shipment-tracking', kwargs=dict(tracking_number="1Z12345E6205277936", carrier_name="ups_package") ) with patch("purpleserver.core.gateway.identity") as mock: ...
class TestTracking(APITestCase):
def test_tracking_shipment(self): url = reverse( 'purpleserver.proxy:shipment-tracking', kwargs=dict(tracking_number="1Z12345E6205277936", carrier_name="ups_package") ) with patch("purpleserver.core.gateway.identity") as mock: mock.return_value = RETURNED...
import json from unittest.mock import patch, ANY from django.urls import reverse from rest_framework import status from purplship.core.models import TrackingDetails, TrackingEvent from purpleserver.core.tests import APITestCase class TestTracking(APITestCase):
54
64
126
7
46
blueprin4/purplship-server
src/apps/proxy/purpleserver/proxy/tests/test_tracking.py
Python
TestTracking
TestTracking
9
23
9
10
56bf47b9252866df3cc60694d8a6c97f1e0fd9eb
bigcode/the-stack
train
5dd89f8ccd237f424be0e98f
train
class
class MaxPooling2D(ModuleNative): def __init__(self, pool_size=(2, 2), stride=None): """ A NxN max pooling layer. Computes the max of a NxN region with stride S. This divides the feature map size by S. :param pool_size: Size of the region over which is pooled. :...
class MaxPooling2D(ModuleNative):
def __init__(self, pool_size=(2, 2), stride=None): """ A NxN max pooling layer. Computes the max of a NxN region with stride S. This divides the feature map size by S. :param pool_size: Size of the region over which is pooled. :param stride: The stride defines h...
.stride) @RunOnlyOnce def _build_tf(self, features): from tensorflow.keras.layers import MaxPooling1D as MaxPooling1D self.pool = _MaxPooling1D(pool_size=self.pool_size, strides=self.stride) def _call_tf(self, features): return self.pool(features) # Cell: 3 class MaxP...
85
85
284
8
76
penguinmenac3/babilim
babilim/model/layers/pooling.py
Python
MaxPooling2D
MaxPooling2D
51
82
51
51
d5dfd2d0a838954885bbfde84ed0183a34c5f1f7
bigcode/the-stack
train
5907e76efe4a674415b0c7d3
train
class
class GlobalAveragePooling2D(ModuleNative): def __init__(self): """ A global average pooling layer. This computes the global average in W, H dimension, so that the result is of shape (B, C). """ super().__init__() @RunOnlyOnce def _build_pytorch(self, fe...
class GlobalAveragePooling2D(ModuleNative):
def __init__(self): """ A global average pooling layer. This computes the global average in W, H dimension, so that the result is of shape (B, C). """ super().__init__() @RunOnlyOnce def _build_pytorch(self, features): from babilim.model.layers.f...
, features): from tensorflow.keras.layers import GlobalAveragePooling1D as _GlobalAveragePooling1D self.pool = _GlobalAveragePooling1D() def _call_tf(self, features): return self.pool(features) # Cell: 5 class GlobalAveragePooling2D(ModuleNative):
64
64
198
9
54
penguinmenac3/babilim
babilim/model/layers/pooling.py
Python
GlobalAveragePooling2D
GlobalAveragePooling2D
114
138
114
114
a1570d3ab35d31b8d3706284d30da8ca9b511eb0
bigcode/the-stack
train
b777d0ee29c546f0a37ca853
train
class
class GlobalAveragePooling1D(ModuleNative): def __init__(self): """ A global average pooling layer. This computes the global average in N dimension (B, N, C), so that the result is of shape (B, C). """ super().__init__() @RunOnlyOnce def _build_pytorch(s...
class GlobalAveragePooling1D(ModuleNative):
def __init__(self): """ A global average pooling layer. This computes the global average in N dimension (B, N, C), so that the result is of shape (B, C). """ super().__init__() @RunOnlyOnce def _build_pytorch(self, features): from babilim.model.l...
.keras.layers import MaxPooling2D as MaxPooling2D self.pool = _MaxPooling2D(pool_size=self.pool_size, strides=self.stride) def _call_tf(self, features): return self.pool(features) # Cell: 4 class GlobalAveragePooling1D(ModuleNative):
64
64
202
9
54
penguinmenac3/babilim
babilim/model/layers/pooling.py
Python
GlobalAveragePooling1D
GlobalAveragePooling1D
86
110
86
86
7667e8fe0b2fb35e8b74feaf413f0d9a77682d66
bigcode/the-stack
train
9d6aaa57145d69fc8a7cd34e
train
class
class MaxPooling1D(ModuleNative): def __init__(self, pool_size=2, stride=None): """ A N max pooling layer. Computes the max of a N region with stride S. This divides the feature map size by S. :param pool_size: Size of the region over which is pooled. :param str...
class MaxPooling1D(ModuleNative):
def __init__(self, pool_size=2, stride=None): """ A N max pooling layer. Computes the max of a N region with stride S. This divides the feature map size by S. :param pool_size: Size of the region over which is pooled. :param stride: The stride defines how the to...
OGENERATED FROM: babilim/model/layers/pooling.ipynb # Cell: 0 """doc # babilim.model.layers.pooling > Pooling operations. """ # Cell: 1 from babilim.core.annotations import RunOnlyOnce from babilim.core.module_native import ModuleNative # Cell: 2 class MaxPooling1D(ModuleNative):
83
83
279
8
74
penguinmenac3/babilim
babilim/model/layers/pooling.py
Python
MaxPooling1D
MaxPooling1D
16
47
16
16
994568381907e647191a759f7906c8d4ed6f5238
bigcode/the-stack
train
5450419e6614842301d08dec
train
function
def test_strategy(): run_tests()
def test_strategy():
run_tests()
_buy_close_code_new")) tasks.append((future_api_config, test_sell_close_code_new, "test_sell_close_code_new")) for cfg, source_code, name in tasks: print("running", name) run(cfg, source_code) print(u"API test ends.") def test_strategy():
63
64
8
4
59
mysky528/rqalpha
test.py
Python
test_strategy
test_strategy
287
288
287
287
d8b8039d82eddd55933eb7d73449db42a10f203d
bigcode/the-stack
train
fbd9605f5705051d1d20fed6
train
function
def run_test(filename): config = { "base": { "strategy_file": os.path.join(TEST_DIR, filename) } } print(u"Start test: " + str(config["base"]["strategy_file"])) result_dict = run(config)['sys_analyser'] df = result_dict["portfolio"] # del df['positions'] old_pick...
def run_test(filename):
config = { "base": { "strategy_file": os.path.join(TEST_DIR, filename) } } print(u"Start test: " + str(config["base"]["strategy_file"])) result_dict = run(config)['sys_analyser'] df = result_dict["portfolio"] # del df['positions'] old_pickle_file = os.path.join(T...
u"*" * 20) if isinstance(result_data, Exception): system_log.error(result_data) else: df, old_df, result = result_data # print("+" * 10, "old test Dataframe: ", "+" * 10) # print(old_df.drop(result.columns[result.all()], axis=1)) # print("+" *...
157
157
524
5
152
mysky528/rqalpha
test.py
Python
run_test
run_test
69
133
69
69
08c94fa3e413e990c9cedba01269338cef13cfd4
bigcode/the-stack
train
d24ea7b7e68c8f0fd93bbd6c
train
function
def is_enable_coverage(): return os.environ.get('COVERAGE') == "enabled"
def is_enable_coverage():
return os.environ.get('COVERAGE') == "enabled"
del old_df['strategy_file'] del df['strategy_file'] except: pass result = df.eq(old_df) if not result.all().all(): return result.all(), (old_result_dict, result_dict, result) return None, None def is_enable_coverage():
64
64
20
6
57
mysky528/rqalpha
test.py
Python
is_enable_coverage
is_enable_coverage
136
137
136
136
ada100ff47ecd64a872a189a7b113af29a90b577
bigcode/the-stack
train
023ca852d81317a14bf52c51
train
function
def write_csv(path, fields): old_test_times = [] if not os.path.exists(path): with open(path, 'w') as csv_file: writer = csv.DictWriter(csv_file, fieldnames=fields) writer.writeheader() with open(path) as csv_file: reader = csv.DictReader(csv_file) for row in ...
def write_csv(path, fields):
old_test_times = [] if not os.path.exists(path): with open(path, 'w') as csv_file: writer = csv.DictWriter(csv_file, fieldnames=fields) writer.writeheader() with open(path) as csv_file: reader = csv.DictReader(csv_file) for row in reader: old_test_...
_code_new")) # =================== Test Future API =================== tasks.append((future_api_config, test_buy_open_code_new, "test_buy_open_code_new")) tasks.append((future_api_config, test_sell_open_code_new, "test_sell_open_code_new")) tasks.append((future_api_config, test_buy_close_code_new, "tes...
145
145
485
7
138
mysky528/rqalpha
test.py
Python
write_csv
write_csv
291
324
291
291
2472425671387d60514b846cd1cc4325589279e6
bigcode/the-stack
train
33ff43d0922d08adc8655887
train
function
def run_tests(file_path=None): if file_path is not None: files = [file_path] else: files = [f for f in os.listdir(TEST_DIR) if f.find("test") == 0] error_map = {} for filename in files: try: r, result_data = run_test(filename) if r is not None: ...
def run_tests(file_path=None):
if file_path is not None: files = [file_path] else: files = [f for f in os.listdir(TEST_DIR) if f.find("test") == 0] error_map = {} for filename in files: try: r, result_data = run_test(filename) if r is not None: error_map[filename.replace...
. import pickle import sys from datetime import datetime import os import csv from six import iteritems import pandas as pd import numpy as np import coverage from rqalpha import run from rqalpha.utils.logger import system_log TEST_DIR = os.path.abspath("./tests/") TEST_OUT = os.path.abspath("./tests/outs/") pd.s...
90
90
303
7
83
mysky528/rqalpha
test.py
Python
run_tests
run_tests
39
66
39
39
3004ca5f8c243cfe1695335f4b5f97dfafb761fb
bigcode/the-stack
train
590881226e68e5215dac70c3
train
function
def test_api(): # FIXME Error msg is hard to understand @zjuguxi # return print(u"Testing API......") from rqalpha import run from tests.api.test_api_base import ( test_get_order_code_new, test_get_open_order_code_new, test_cancel_order_code_new, test_update_univers...
def test_api(): # FIXME Error msg is hard to understand @zjuguxi # return
print(u"Testing API......") from rqalpha import run from tests.api.test_api_base import ( test_get_order_code_new, test_get_open_order_code_new, test_cancel_order_code_new, test_update_universe_code_new, test_subscribe_code_new, test_unsubscribe_code_new, ...
(), (df, old_df, result) # 比较 summary old_df = pd.DataFrame(data=[{"val": val} for val in old_result_dict["summary"].values()], index=old_result_dict["summary"].keys()).sort_index().T.fillna(0) df = pd.DataFrame(data=[{"val": val} for val in result_dict["summary"]....
256
256
1,300
23
233
mysky528/rqalpha
test.py
Python
test_api
test_api
140
284
140
143
75e0b734b39e4af4f56156f142dc96521a2744ad
bigcode/the-stack
train
8dac9027cde6bc6b33603723
train
function
def logErrorAndReturnOK(error_msg='Error found in Task'): """Logs the given error message and returns a HTTP OK response. Args: error_msg: Error message to log """ logging.error(error_msg) return http.HttpResponse()
def logErrorAndReturnOK(error_msg='Error found in Task'):
"""Logs the given error message and returns a HTTP OK response. Args: error_msg: Error message to log """ logging.error(error_msg) return http.HttpResponse()
# limitations under the License. """Module for handling errors while running a Task. """ __authors__ = [ '"Lennard de Rijk" <ljvderijk@gmail.com>', ] import logging from django import http def logErrorAndReturnOK(error_msg='Error found in Task'):
64
64
54
14
49
MatthewWilkes/mw4068-packaging
src/melange/src/soc/tasks/helper/error_handler.py
Python
logErrorAndReturnOK
logErrorAndReturnOK
30
37
30
30
a3963a6f9a5e7ab2e3899a49421f766536982c72
bigcode/the-stack
train
ffb467591574c1e45ccdf3a3
train
function
def get_preset_models_softclass(path, hyperparameters, num_classes=None, hyperparameter_tune=False, name_suffix=''): model_types_standard = ['GBM','NN','CAT'] hyperparameters = copy.deepcopy(hyperparameters) hyperparameters_standard = copy.deepcopy(hyperparameters) hyperparameters_rf = copy.deepcopy(hyp...
def get_preset_models_softclass(path, hyperparameters, num_classes=None, hyperparameter_tune=False, name_suffix=''):
model_types_standard = ['GBM','NN','CAT'] hyperparameters = copy.deepcopy(hyperparameters) hyperparameters_standard = copy.deepcopy(hyperparameters) hyperparameters_rf = copy.deepcopy(hyperparameters) default_level_key = 'default' if default_level_key in hyperparameters: hyperparameters_...
opping_metric, num_classes=num_classes, hyperparameters=model_params) models.append(model_init) for model in models: model.rename(model.name + name_suffix) return models def get_preset_stacker_model(path, problem_type, eval_metric, num_classes=None, hyperparamete...
237
237
792
26
210
kaixinbaba/autogluon
tabular/src/autogluon/tabular/trainer/model_presets/presets.py
Python
get_preset_models_softclass
get_preset_models_softclass
191
241
191
191
af6397d4cff21421e4703561122216fbeb72ab4d
bigcode/the-stack
train
e20803e12ebe8886881a0443
train
function
def get_preset_stacker_model(path, problem_type, eval_metric, num_classes=None, hyperparameters={'NN': {}, 'GBM': {}}, hyperparameter_tune=False): # TODO: Expand options to RF and NN if problem_type == REGRESSION: model = RFModel(path=path, name='LinearRegression', model=Lin...
def get_preset_stacker_model(path, problem_type, eval_metric, num_classes=None, hyperparameters={'NN': {}, 'GBM': {}}, hyperparameter_tune=False): # TODO: Expand options to RF and NN
if problem_type == REGRESSION: model = RFModel(path=path, name='LinearRegression', model=LinearRegression(), problem_type=problem_type, eval_metric=eval_metric) else: model = RFModel(path=path, name='LogisticRegression', model=LogisticRegression( solver='libli...
models: model.rename(model.name + name_suffix) return models def get_preset_stacker_model(path, problem_type, eval_metric, num_classes=None, hyperparameters={'NN': {}, 'GBM': {}}, hyperparameter_tune=False): # TODO: Expand options to RF and NN
64
64
173
49
14
kaixinbaba/autogluon
tabular/src/autogluon/tabular/trainer/model_presets/presets.py
Python
get_preset_stacker_model
get_preset_stacker_model
178
188
178
180
daddb556a909311231f00012c6706ddd5663a41d
bigcode/the-stack
train
4db827a0dd07695c19513055
train
function
def _dd_classifier(): return 'Classifier'
def _dd_classifier():
return 'Classifier'
KNeighbors', LGBModel: 'LightGBM', CatboostModel: 'Catboost', TabularNeuralNetModel: 'NeuralNet', LinearModel: 'LinearModel', NNFastAiTabularModel: 'FastAINeuralNet', } def _dd_classifier():
64
64
10
5
59
kaixinbaba/autogluon
tabular/src/autogluon/tabular/trainer/model_presets/presets.py
Python
_dd_classifier
_dd_classifier
77
78
77
77
a5c0a9edf446b191229e756e2434b0dd69f07512
bigcode/the-stack
train
5b31f653cb0a4f536d383a0e
train
function
def _dd_regressor(): return 'Regressor'
def _dd_regressor():
return 'Regressor'
M', CatboostModel: 'Catboost', TabularNeuralNetModel: 'NeuralNet', LinearModel: 'LinearModel', NNFastAiTabularModel: 'FastAINeuralNet', } def _dd_classifier(): return 'Classifier' def _dd_regressor():
64
64
12
6
58
kaixinbaba/autogluon
tabular/src/autogluon/tabular/trainer/model_presets/presets.py
Python
_dd_regressor
_dd_regressor
81
82
81
81
16d521c85e7adbbb778091aafedde1fc235bbe3f
bigcode/the-stack
train
5fba049092700f2455bb7ced
train
function
def get_preset_models(path, problem_type, eval_metric, hyperparameters, stopping_metric=None, num_classes=None, hyperparameter_tune=False, level='default', extra_ag_args_fit=None, name_suffix='', default_priorities=None): if problem_type not in [BINARY, MULTICLASS, REGRESSION, SOFTCLASS]: ...
def get_preset_models(path, problem_type, eval_metric, hyperparameters, stopping_metric=None, num_classes=None, hyperparameter_tune=False, level='default', extra_ag_args_fit=None, name_suffix='', default_priorities=None):
if problem_type not in [BINARY, MULTICLASS, REGRESSION, SOFTCLASS]: raise NotImplementedError if default_priorities is None: default_priorities = copy.deepcopy(DEFAULT_MODEL_PRIORITY) if problem_type in PROBLEM_TYPE_MODEL_PRIORITY: default_priorities.update(PROBLEM_TYPE_MODEL...
lists, concatenate hyperparameter sets together. # TODO: Consider adding special optional AG args for #cores,#gpus,num_early_stopping_iterations,etc. # DONE: Consider adding special optional AG args for max train time, max memory size, etc. # TODO: Consider adding special optional AG args for use_original_features,fea...
245
245
817
49
196
kaixinbaba/autogluon
tabular/src/autogluon/tabular/trainer/model_presets/presets.py
Python
get_preset_models
get_preset_models
109
175
109
110
95cd3b0eee65e70941f381d4cc3967e3837d33d6
bigcode/the-stack
train
c54c900c2f4a9e1e74479e92
train
class
class Migration(migrations.Migration): dependencies = [ ('flights', '0001_initial'), ] operations = [ migrations.RemoveField( model_name='seat', name='passenger', ), migrations.AddField( model_name='passenger', name='flight', ...
class Migration(migrations.Migration):
dependencies = [ ('flights', '0001_initial'), ] operations = [ migrations.RemoveField( model_name='seat', name='passenger', ), migrations.AddField( model_name='passenger', name='flight', field=models.ForeignKey(defa...
# Generated by Django 2.2.4 on 2019-08-21 00:03 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration):
45
64
151
7
37
python-snakes-on-a-plane/api
flights/migrations/0002_auto_20190821_0003.py
Python
Migration
Migration
7
28
7
8
454a9ff9a54a4c7e22f0e3668fd4e6fa3fb7a120
bigcode/the-stack
train
6128a0473535e47d20429298
train
function
def test_compare_symbols_L(): N, C, H, W = 2,3,4,5 a = np.random.random((N, C, H, W)) b = np.random.random((N, C, H, W)) [la, lb] = L.Data([a,b]) eq = M.equal(la, lb) ne = M.not_equal(la, lb) ge = (la >= b) gt = (la > b) le = (la <= b) lt = (la < b) lops = [eq,ne,ge,gt,l...
def test_compare_symbols_L():
N, C, H, W = 2,3,4,5 a = np.random.random((N, C, H, W)) b = np.random.random((N, C, H, W)) [la, lb] = L.Data([a,b]) eq = M.equal(la, lb) ne = M.not_equal(la, lb) ge = (la >= b) gt = (la > b) le = (la <= b) lt = (la < b) lops = [eq,ne,ge,gt,le,lt] ops = [operator.eq, ...
lops = [eq,ne,ge,gt,le,lt] ops = [operator.eq, operator.ne, operator.ge, operator.gt, operator.le, operator.lt] for l, op in zip(lops, ops): assert l.op == op def test_compare_symbols_L():
64
64
179
6
57
wkcn/mobula
tests/test_ops/test_compare.py
Python
test_compare_symbols_L
test_compare_symbols_L
43
58
43
43
40f2465d4bd75e1d9558de17a84f871176911769
bigcode/the-stack
train
168b94ebbd9ed2c9f6e7c55b
train
function
def test_compare_symbols(): N, C, H, W = 2,3,4,5 a = np.random.random((N, C, H, W)) b = np.random.random((N, C, H, W)) [la, lb] = L.Data([a,b]) eq = M.equal(la, lb) ne = M.not_equal(la, lb) ge = (la >= lb) gt = (la > lb) le = (la <= lb) lt = (la < lb) lops = [eq,ne,ge,gt...
def test_compare_symbols():
N, C, H, W = 2,3,4,5 a = np.random.random((N, C, H, W)) b = np.random.random((N, C, H, W)) [la, lb] = L.Data([a,b]) eq = M.equal(la, lb) ne = M.not_equal(la, lb) ge = (la >= lb) gt = (la > lb) le = (la <= lb) lt = (la < lb) lops = [eq,ne,ge,gt,le,lt] ops = [operator....
[1], np.zeros(l.X[1].shape)) assert np.allclose(l2.dX[0], np.zeros(l2.X[0].shape)) assert np.allclose(l2.dX[1], np.zeros(l2.X[1].shape)) def test_compare_symbols():
63
64
178
5
58
wkcn/mobula
tests/test_ops/test_compare.py
Python
test_compare_symbols
test_compare_symbols
26
41
26
26
c7ae2d5570b74d87be2194dee9847f4f1da0e7cd
bigcode/the-stack
train
13b914cd097dda0489b6199d
train
function
def test_compare(): N, C, H, W = 2,3,4,5 a = np.random.random((N, C, H, W)) b = np.random.random((N, C, H, W)) a_copy = a.copy() [la, lb, lac] = L.Data([a,b,a_copy]) ops = [operator.ge, operator.gt, operator.le, operator.lt] for op in ops: l = op(la, lb) l2 = op(la, lac) ...
def test_compare():
N, C, H, W = 2,3,4,5 a = np.random.random((N, C, H, W)) b = np.random.random((N, C, H, W)) a_copy = a.copy() [la, lb, lac] = L.Data([a,b,a_copy]) ops = [operator.ge, operator.gt, operator.le, operator.lt] for op in ops: l = op(la, lb) l2 = op(la, lac) assert np.allc...
import mobula as M import mobula.layers as L import numpy as np import operator def test_compare():
25
72
241
4
20
wkcn/mobula
tests/test_ops/test_compare.py
Python
test_compare
test_compare
6
24
6
6
57d7e826aa9f0316ffc2973ba5188ed2832821ed
bigcode/the-stack
train
e2a16a37cce0fcf2a4d72d0c
train
class
class second_layer(layers.Layer): def __init__(self, units=5,input_dim=5, activation = None): super(second_layer, self).__init__() self.units = units self.activation = activation def build(self, input_shape): initializer = tf.keras.initializers.GlorotNormal() self.p_contr...
class second_layer(layers.Layer):
def __init__(self, units=5,input_dim=5, activation = None): super(second_layer, self).__init__() self.units = units self.activation = activation def build(self, input_shape): initializer = tf.keras.initializers.GlorotNormal() self.p_control = self.add_weight(shape=(self.u...
self.w[0][i]*(f(inputs)**i)*(g(inputs)**(n-1-i)) for i in range(n)] out= tf.reshape(u/np.sum(np.array(u)),(1,self.units)) return layers.Activation(self.activation)(out) class second_layer(layers.Layer):
63
64
159
7
56
BeatrizRubio/Article_Mathematics_2020
Experiments_table/Cycloid/Basis2/basis2.py
Python
second_layer
second_layer
47
60
47
47
a6152a2bbbe4f53a6b418f001d8e0a382360056e
bigcode/the-stack
train
c2d5558b0bce0691d1852288
train
function
def g(t): return (1-t**2)
def g(t):
return (1-t**2)
1) return numer / denom def normalize(xs): min_xs = np.min(xs) max_xs = np.max(xs) return (xs-min_xs)/(max_xs-min_xs) # BASE def f(t): return (t**2) def g(t):
64
64
12
4
60
BeatrizRubio/Article_Mathematics_2020
Experiments_table/Cycloid/Basis2/basis2.py
Python
g
g
29
30
29
29
50cb8ce274dc42fa79df8938c8780c7a85313320
bigcode/the-stack
train
25e3b6277a33632a8fe02f7e
train
function
def f(t): return (t**2)
def f(t):
return (t**2)
(op.mul, range(1, r+1), 1) return numer / denom def normalize(xs): min_xs = np.min(xs) max_xs = np.max(xs) return (xs-min_xs)/(max_xs-min_xs) # BASE def f(t):
64
64
11
4
59
BeatrizRubio/Article_Mathematics_2020
Experiments_table/Cycloid/Basis2/basis2.py
Python
f
f
27
28
27
27
0ced7cce54be96a589372d9ff59cbe2b8c71653a
bigcode/the-stack
train
9a187b190e4f32e70ec70d0c
train
function
def ncr(n, r): r = min(r, n-r) numer = reduce(op.mul, range(n, n-r, -1), 1) denom = reduce(op.mul, range(1, r+1), 1) return numer / denom
def ncr(n, r):
r = min(r, n-r) numer = reduce(op.mul, range(n, n-r, -1), 1) denom = reduce(op.mul, range(1, r+1), 1) return numer / denom
import tensorflow as tf from tensorflow.keras import layers from tensorflow.keras import Input from tensorflow.keras import Model import numpy as np import operator as op from functools import reduce import numpy as np import math #AUXILIAR FUNCTIONS def ncr(n, r):
60
64
59
7
52
BeatrizRubio/Article_Mathematics_2020
Experiments_table/Cycloid/Basis2/basis2.py
Python
ncr
ncr
14
18
14
14
a5483c39b309004e3a2125e7b6371dd659c33604
bigcode/the-stack
train
44fd424f858ed0782c4c581d
train
class
class first_layer(layers.Layer): def __init__(self, units=5,input_dim=1, activation = None): super(first_layer, self).__init__() self.units = units self.activation = activation def build(self, input_shape): initializer1 = tf.keras.initializers.RandomUniform(0,1) self.w = ...
class first_layer(layers.Layer):
def __init__(self, units=5,input_dim=1, activation = None): super(first_layer, self).__init__() self.units = units self.activation = activation def build(self, input_shape): initializer1 = tf.keras.initializers.RandomUniform(0,1) self.w = self.add_weight(shape=(1,self.uni...
np.min(xs) max_xs = np.max(xs) return (xs-min_xs)/(max_xs-min_xs) # BASE def f(t): return (t**2) def g(t): return (1-t**2) # MODEL class first_layer(layers.Layer):
64
64
173
7
56
BeatrizRubio/Article_Mathematics_2020
Experiments_table/Cycloid/Basis2/basis2.py
Python
first_layer
first_layer
34
46
34
34
69208d2729b2801ff7c223897e98b3e4ef404309
bigcode/the-stack
train