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
5c0a4d9919f6bd25188fafbd
train
function
def _gen_mixnet_m(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **kwargs): """Creates a MixNet Medium-Large model. Ref impl: https://github.com/tensorflow/tpu/tree/master/models/official/mnasnet/mixnet Paper: https://arxiv.org/abs/1907.09595 """ arch_def = [ # sta...
def _gen_mixnet_m(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **kwargs):
"""Creates a MixNet Medium-Large model. Ref impl: https://github.com/tensorflow/tpu/tree/master/models/official/mnasnet/mixnet Paper: https://arxiv.org/abs/1907.09595 """ arch_def = [ # stage 0, 112x112 in ['ds_r1_k3_s1_e1_c24'], # relu # stage 1, 112x112 in ['ir_r1...
_k3.5.7.9.11_s2_e6_c200_se0.5_nsw', 'ir_r2_k3.5.7.9_p1.1_s1_e6_c200_se0.5_nsw'], # swish # 7x7 ] model_kwargs = dict( block_args=decode_arch_def(arch_def), num_features=1536, stem_size=16, channel_multiplier=channel_multiplier, norm_kwargs=resolve_bn_args(kwargs)...
168
168
563
29
138
ndhung/TestNet
timm/models/efficientnet.py
Python
_gen_mixnet_m
_gen_mixnet_m
893
923
893
893
28ab1e71564f976fe2ceacc8f880d4d0c7f46349
bigcode/the-stack
train
4c376792d8193c3eece8ab58
train
function
@register_model def efficientnet_b3_pruned(pretrained=False, **kwargs): """ EfficientNet-B3 Pruned. The pruning has been obtained using https://arxiv.org/pdf/2002.08258.pdf """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'efficientnet_b3_pruned', c...
@register_model def efficientnet_b3_pruned(pretrained=False, **kwargs):
""" EfficientNet-B3 Pruned. The pruning has been obtained using https://arxiv.org/pdf/2002.08258.pdf """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'efficientnet_b3_pruned', channel_multiplier=1.2, depth_multiplier=1.4, pretrained=pretrained, **kw...
same' model = _gen_efficientnet( 'efficientnet_b2_pruned', channel_multiplier=1.1, depth_multiplier=1.2, pretrained=pretrained, **kwargs) return model @register_model def efficientnet_b3_pruned(pretrained=False, **kwargs):
64
64
115
18
45
ndhung/TestNet
timm/models/efficientnet.py
Python
efficientnet_b3_pruned
efficientnet_b3_pruned
1,275
1,282
1,275
1,276
f793b0a3b8d8d8044faeec5db65ca80c119556e3
bigcode/the-stack
train
a6b0e5d91f152fdde76f4847
train
function
@register_model def tf_efficientnet_b6_ap(pretrained=False, **kwargs): """ EfficientNet-B6 AdvProp. Tensorflow compatible variant """ # NOTE for train, drop_rate should be 0.5 kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'tf_efficientnet_b6_ap',...
@register_model def tf_efficientnet_b6_ap(pretrained=False, **kwargs):
""" EfficientNet-B6 AdvProp. Tensorflow compatible variant """ # NOTE for train, drop_rate should be 0.5 kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'tf_efficientnet_b6_ap', channel_multiplier=1.8, depth_multiplier=2.6, pretrained=pretrained, *...
model = _gen_efficientnet( 'tf_efficientnet_b5_ap', channel_multiplier=1.6, depth_multiplier=2.2, pretrained=pretrained, **kwargs) return model @register_model def tf_efficientnet_b6_ap(pretrained=False, **kwargs):
64
64
117
19
44
ndhung/TestNet
timm/models/efficientnet.py
Python
tf_efficientnet_b6_ap
tf_efficientnet_b6_ap
1,438
1,446
1,438
1,439
705f6ed15993273730e6ef3f1574f148c70b2dc9
bigcode/the-stack
train
213128fbebd689f61592d31b
train
function
@register_model def semnasnet_075(pretrained=False, **kwargs): """ MNASNet A1 (w/ SE), depth multiplier of 0.75. """ model = _gen_mnasnet_a1('semnasnet_075', 0.75, pretrained=pretrained, **kwargs) return model
@register_model def semnasnet_075(pretrained=False, **kwargs):
""" MNASNet A1 (w/ SE), depth multiplier of 0.75. """ model = _gen_mnasnet_a1('semnasnet_075', 0.75, pretrained=pretrained, **kwargs) return model
(w/ SE), depth multiplier of 0.5 """ model = _gen_mnasnet_a1('semnasnet_050', 0.5, pretrained=pretrained, **kwargs) return model @register_model def semnasnet_075(pretrained=False, **kwargs):
64
64
73
17
46
ndhung/TestNet
timm/models/efficientnet.py
Python
semnasnet_075
semnasnet_075
967
971
967
968
12f3de43ed42b2d4839cd95975e066c1481dbb8f
bigcode/the-stack
train
13897c80667c511d310adf7b
train
function
@register_model def tf_mixnet_s(pretrained=False, **kwargs): """Creates a MixNet Small model. Tensorflow compatible variant """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_mixnet_s( 'tf_mixnet_s', channel_multiplier=1.0, pretrained=pretrained, **kwargs) ...
@register_model def tf_mixnet_s(pretrained=False, **kwargs):
"""Creates a MixNet Small model. Tensorflow compatible variant """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_mixnet_s( 'tf_mixnet_s', channel_multiplier=1.0, pretrained=pretrained, **kwargs) return model
/ depth scaling. """ model = _gen_mixnet_m( 'mixnet_xxl', channel_multiplier=2.4, depth_multiplier=1.3, pretrained=pretrained, **kwargs) return model @register_model def tf_mixnet_s(pretrained=False, **kwargs):
64
64
91
16
47
ndhung/TestNet
timm/models/efficientnet.py
Python
tf_mixnet_s
tf_mixnet_s
1,742
1,750
1,742
1,743
651d5479816322324a2cda33e25e73d70556db2e
bigcode/the-stack
train
49854217840e830efd24b0be
train
function
@register_model def spnasnet_100(pretrained=False, **kwargs): """ Single-Path NAS Pixel1""" model = _gen_spnasnet('spnasnet_100', 1.0, pretrained=pretrained, **kwargs) return model
@register_model def spnasnet_100(pretrained=False, **kwargs):
""" Single-Path NAS Pixel1""" model = _gen_spnasnet('spnasnet_100', 1.0, pretrained=pretrained, **kwargs) return model
kwargs['bn_eps'] = BN_EPS_TF_DEFAULT model = _gen_fbnetc('fbnetc_100', 1.0, pretrained=pretrained, **kwargs) return model @register_model def spnasnet_100(pretrained=False, **kwargs):
64
64
58
17
46
ndhung/TestNet
timm/models/efficientnet.py
Python
spnasnet_100
spnasnet_100
1,041
1,045
1,041
1,042
da1edafe88e0b5bab41138ee1a6d60d88084ec1e
bigcode/the-stack
train
52dc6e24067f5ed75bf199dd
train
function
def _create_model(model_kwargs, default_cfg, pretrained=False): if model_kwargs.pop('features_only', False): load_strict = False model_kwargs.pop('num_classes', 0) model_kwargs.pop('num_features', 0) model_kwargs.pop('head_conv', None) model_class = EfficientNetFeatures e...
def _create_model(model_kwargs, default_cfg, pretrained=False):
if model_kwargs.pop('features_only', False): load_strict = False model_kwargs.pop('num_classes', 0) model_kwargs.pop('num_features', 0) model_kwargs.pop('head_conv', None) model_class = EfficientNetFeatures else: load_strict = True model_class = EfficientN...
, b in enumerate(self.blocks): x = b(x) if i in self._stage_to_feature_idx: features.append(x) return features else: self.blocks(x) return self.feature_hooks.get_output(x.device) def _create_model(model_kwargs, default_cfg, ...
64
64
190
13
51
ndhung/TestNet
timm/models/efficientnet.py
Python
_create_model
_create_model
493
515
493
493
e8d98d7608598ffc9174dc73e674869a8a4ee6e3
bigcode/the-stack
train
3cba5a9895c3cfc5851c10fd
train
function
@register_model def tf_efficientnet_b7_ap(pretrained=False, **kwargs): """ EfficientNet-B7 AdvProp. Tensorflow compatible variant """ # NOTE for train, drop_rate should be 0.5 kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'tf_efficientnet_b7_ap',...
@register_model def tf_efficientnet_b7_ap(pretrained=False, **kwargs):
""" EfficientNet-B7 AdvProp. Tensorflow compatible variant """ # NOTE for train, drop_rate should be 0.5 kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'tf_efficientnet_b7_ap', channel_multiplier=2.0, depth_multiplier=3.1, pretrained=pretrained, *...
model = _gen_efficientnet( 'tf_efficientnet_b6_ap', channel_multiplier=1.8, depth_multiplier=2.6, pretrained=pretrained, **kwargs) return model @register_model def tf_efficientnet_b7_ap(pretrained=False, **kwargs):
64
64
117
19
44
ndhung/TestNet
timm/models/efficientnet.py
Python
tf_efficientnet_b7_ap
tf_efficientnet_b7_ap
1,449
1,457
1,449
1,450
9b096165c2ce540030c8634ed17aedd1dc2d73ba
bigcode/the-stack
train
9902c52648bdd27675ada4cc
train
function
@register_model def mnasnet_075(pretrained=False, **kwargs): """ MNASNet B1, depth multiplier of 0.75. """ model = _gen_mnasnet_b1('mnasnet_075', 0.75, pretrained=pretrained, **kwargs) return model
@register_model def mnasnet_075(pretrained=False, **kwargs):
""" MNASNet B1, depth multiplier of 0.75. """ model = _gen_mnasnet_b1('mnasnet_075', 0.75, pretrained=pretrained, **kwargs) return model
Net B1, depth multiplier of 0.5. """ model = _gen_mnasnet_b1('mnasnet_050', 0.5, pretrained=pretrained, **kwargs) return model @register_model def mnasnet_075(pretrained=False, **kwargs):
64
64
68
17
46
ndhung/TestNet
timm/models/efficientnet.py
Python
mnasnet_075
mnasnet_075
933
937
933
934
cdffbe662b0bd8c52e9327627efaa00e36790205
bigcode/the-stack
train
b413b9b00de38466f523b56f
train
function
@register_model def efficientnet_l2(pretrained=False, **kwargs): """ EfficientNet-L2.""" # NOTE for train, drop_rate should be 0.5, drop_path_rate should be 0.2 model = _gen_efficientnet( 'efficientnet_l2', channel_multiplier=4.3, depth_multiplier=5.3, pretrained=pretrained, **kwargs) return mod...
@register_model def efficientnet_l2(pretrained=False, **kwargs):
""" EfficientNet-L2.""" # NOTE for train, drop_rate should be 0.5, drop_path_rate should be 0.2 model = _gen_efficientnet( 'efficientnet_l2', channel_multiplier=4.3, depth_multiplier=5.3, pretrained=pretrained, **kwargs) return model
be 0.2 model = _gen_efficientnet( 'efficientnet_b8', channel_multiplier=2.2, depth_multiplier=3.6, pretrained=pretrained, **kwargs) return model @register_model def efficientnet_l2(pretrained=False, **kwargs):
64
64
90
16
47
ndhung/TestNet
timm/models/efficientnet.py
Python
efficientnet_l2
efficientnet_l2
1,147
1,153
1,147
1,148
f38cb5c90724edfb05d9a55125a10c18577c1fc8
bigcode/the-stack
train
e2eaa02d34af3407207e0a93
train
function
def _gen_mixnet_s(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creates a MixNet Small model. Ref impl: https://github.com/tensorflow/tpu/tree/master/models/official/mnasnet/mixnet Paper: https://arxiv.org/abs/1907.09595 """ arch_def = [ # stage 0, 112x112 in ['ds...
def _gen_mixnet_s(variant, channel_multiplier=1.0, pretrained=False, **kwargs):
"""Creates a MixNet Small model. Ref impl: https://github.com/tensorflow/tpu/tree/master/models/official/mnasnet/mixnet Paper: https://arxiv.org/abs/1907.09595 """ arch_def = [ # stage 0, 112x112 in ['ds_r1_k3_s1_e1_c16'], # relu # stage 1, 112x112 in ['ir_r1_k3_a1....
ir_r3_k5_s1_e6_c112'], ['ir_r4_k5_s2_e6_c192'], ['ir_r1_k3_s1_e6_c320'], ] model_kwargs = dict( block_args=decode_arch_def(arch_def, depth_multiplier, fix_first_last=True), num_features=1280, stem_size=32, fix_stem=True, channel_multiplier=channel_multipli...
164
164
549
22
141
ndhung/TestNet
timm/models/efficientnet.py
Python
_gen_mixnet_s
_gen_mixnet_s
860
890
860
860
5b417adae2bc9af76382dd6c4750b9811627bc6a
bigcode/the-stack
train
0030ed7fca63afe84a04d388
train
function
@register_model def efficientnet_el(pretrained=False, **kwargs): """ EfficientNet-Edge-Large. """ model = _gen_efficientnet_edge( 'efficientnet_el', channel_multiplier=1.2, depth_multiplier=1.4, pretrained=pretrained, **kwargs) return model
@register_model def efficientnet_el(pretrained=False, **kwargs):
""" EfficientNet-Edge-Large. """ model = _gen_efficientnet_edge( 'efficientnet_el', channel_multiplier=1.2, depth_multiplier=1.4, pretrained=pretrained, **kwargs) return model
Net-Edge-Medium. """ model = _gen_efficientnet_edge( 'efficientnet_em', channel_multiplier=1.0, depth_multiplier=1.1, pretrained=pretrained, **kwargs) return model @register_model def efficientnet_el(pretrained=False, **kwargs):
64
64
67
15
48
ndhung/TestNet
timm/models/efficientnet.py
Python
efficientnet_el
efficientnet_el
1,172
1,177
1,172
1,173
c1bca007003545df6fcebd6b33d4539dff0b19b2
bigcode/the-stack
train
7ab74bdac668ee2602ca581b
train
function
@register_model def efficientnet_lite0(pretrained=False, **kwargs): """ EfficientNet-Lite0 """ # NOTE for train, drop_rate should be 0.2, drop_path_rate should be 0.2 model = _gen_efficientnet_lite( 'efficientnet_lite0', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=pretrained, **kwargs) ...
@register_model def efficientnet_lite0(pretrained=False, **kwargs):
""" EfficientNet-Lite0 """ # NOTE for train, drop_rate should be 0.2, drop_path_rate should be 0.2 model = _gen_efficientnet_lite( 'efficientnet_lite0', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=pretrained, **kwargs) return model
net_condconv( 'efficientnet_cc_b1_8e', channel_multiplier=1.0, depth_multiplier=1.1, experts_multiplier=2, pretrained=pretrained, **kwargs) return model @register_model def efficientnet_lite0(pretrained=False, **kwargs):
64
64
95
17
46
ndhung/TestNet
timm/models/efficientnet.py
Python
efficientnet_lite0
efficientnet_lite0
1,209
1,215
1,209
1,210
8c830aeb2a1f8843595aa91a93b73d870117c6ac
bigcode/the-stack
train
e1688437486dd374f8f00c06
train
function
@register_model def efficientnet_cc_b1_8e(pretrained=False, **kwargs): """ EfficientNet-CondConv-B1 w/ 8 Experts """ # NOTE for train, drop_rate should be 0.2, drop_path_rate should be 0.2 model = _gen_efficientnet_condconv( 'efficientnet_cc_b1_8e', channel_multiplier=1.0, depth_multiplier=1.1, expe...
@register_model def efficientnet_cc_b1_8e(pretrained=False, **kwargs):
""" EfficientNet-CondConv-B1 w/ 8 Experts """ # NOTE for train, drop_rate should be 0.2, drop_path_rate should be 0.2 model = _gen_efficientnet_condconv( 'efficientnet_cc_b1_8e', channel_multiplier=1.0, depth_multiplier=1.1, experts_multiplier=2, pretrained=pretrained, **kwargs) return m...
( 'efficientnet_cc_b0_8e', channel_multiplier=1.0, depth_multiplier=1.0, experts_multiplier=2, pretrained=pretrained, **kwargs) return model @register_model def efficientnet_cc_b1_8e(pretrained=False, **kwargs):
64
64
114
20
43
ndhung/TestNet
timm/models/efficientnet.py
Python
efficientnet_cc_b1_8e
efficientnet_cc_b1_8e
1,199
1,206
1,199
1,200
221c4062a008d011593e5e63ced3096a04e737f8
bigcode/the-stack
train
2800db7f81d16efb935a2389
train
function
@register_model def semnasnet_100(pretrained=False, **kwargs): """ MNASNet A1 (w/ SE), depth multiplier of 1.0. """ model = _gen_mnasnet_a1('semnasnet_100', 1.0, pretrained=pretrained, **kwargs) return model
@register_model def semnasnet_100(pretrained=False, **kwargs):
""" MNASNet A1 (w/ SE), depth multiplier of 1.0. """ model = _gen_mnasnet_a1('semnasnet_100', 1.0, pretrained=pretrained, **kwargs) return model
/ SE), depth multiplier of 0.75. """ model = _gen_mnasnet_a1('semnasnet_075', 0.75, pretrained=pretrained, **kwargs) return model @register_model def semnasnet_100(pretrained=False, **kwargs):
64
64
72
17
46
ndhung/TestNet
timm/models/efficientnet.py
Python
semnasnet_100
semnasnet_100
974
978
974
975
a9e3d1adac9e5fd2126bd5f48a026664d72aedbf
bigcode/the-stack
train
44392f1b794dd2346711b49d
train
function
@register_model def efficientnet_b2a(pretrained=False, **kwargs): """ EfficientNet-B2 @ 288x288 w/ 1.0 test crop""" # NOTE for train, drop_rate should be 0.3, drop_path_rate should be 0.2 model = _gen_efficientnet( 'efficientnet_b2a', channel_multiplier=1.1, depth_multiplier=1.2, pretrained=pretrain...
@register_model def efficientnet_b2a(pretrained=False, **kwargs):
""" EfficientNet-B2 @ 288x288 w/ 1.0 test crop""" # NOTE for train, drop_rate should be 0.3, drop_path_rate should be 0.2 model = _gen_efficientnet( 'efficientnet_b2a', channel_multiplier=1.1, depth_multiplier=1.2, pretrained=pretrained, **kwargs) return model
0.2 model = _gen_efficientnet( 'efficientnet_b2', channel_multiplier=1.1, depth_multiplier=1.2, pretrained=pretrained, **kwargs) return model @register_model def efficientnet_b2a(pretrained=False, **kwargs):
64
64
105
17
46
ndhung/TestNet
timm/models/efficientnet.py
Python
efficientnet_b2a
efficientnet_b2a
1,075
1,081
1,075
1,076
8015f47682efd2578102960e8a7926a57093d97c
bigcode/the-stack
train
6a69f4c924270d7f337957f6
train
function
@register_model def efficientnet_b6(pretrained=False, **kwargs): """ EfficientNet-B6 """ # NOTE for train, drop_rate should be 0.5, drop_path_rate should be 0.2 model = _gen_efficientnet( 'efficientnet_b6', channel_multiplier=1.8, depth_multiplier=2.6, pretrained=pretrained, **kwargs) return mod...
@register_model def efficientnet_b6(pretrained=False, **kwargs):
""" EfficientNet-B6 """ # NOTE for train, drop_rate should be 0.5, drop_path_rate should be 0.2 model = _gen_efficientnet( 'efficientnet_b6', channel_multiplier=1.8, depth_multiplier=2.6, pretrained=pretrained, **kwargs) return model
be 0.2 model = _gen_efficientnet( 'efficientnet_b5', channel_multiplier=1.6, depth_multiplier=2.2, pretrained=pretrained, **kwargs) return model @register_model def efficientnet_b6(pretrained=False, **kwargs):
64
64
90
16
47
ndhung/TestNet
timm/models/efficientnet.py
Python
efficientnet_b6
efficientnet_b6
1,120
1,126
1,120
1,121
602a6760b8c49d4a39db2c973d406a5c7aeeb9dc
bigcode/the-stack
train
79fc8b892f3f4aea8693752f
train
function
def _gen_mnasnet_b1(variant, channel_multiplier=1.0, pretrained=False, **kwargs): """Creates a mnasnet-b1 model. Ref impl: https://github.com/tensorflow/tpu/tree/master/models/official/mnasnet Paper: https://arxiv.org/pdf/1807.11626.pdf. Args: channel_multiplier: multiplier to number of channels...
def _gen_mnasnet_b1(variant, channel_multiplier=1.0, pretrained=False, **kwargs):
"""Creates a mnasnet-b1 model. Ref impl: https://github.com/tensorflow/tpu/tree/master/models/official/mnasnet Paper: https://arxiv.org/pdf/1807.11626.pdf. Args: channel_multiplier: multiplier to number of channels per layer. """ arch_def = [ # stage 0, 112x112 in ['ds_r1...
['ir_r1_k3_s1_e6_c320'], ] model_kwargs = dict( block_args=decode_arch_def(arch_def), stem_size=32, channel_multiplier=channel_multiplier, norm_kwargs=resolve_bn_args(kwargs), **kwargs ) model = _create_model(model_kwargs, default_cfgs[variant], pretrained) r...
105
105
350
24
80
ndhung/TestNet
timm/models/efficientnet.py
Python
_gen_mnasnet_b1
_gen_mnasnet_b1
554
587
554
554
6cc83a99b23cf40a8fd0028e7efb6c5a499de82a
bigcode/the-stack
train
d924b170485c6dd8e5de3147
train
function
@register_model def mixnet_l(pretrained=False, **kwargs): """Creates a MixNet Large model. """ model = _gen_mixnet_m( 'mixnet_l', channel_multiplier=1.3, pretrained=pretrained, **kwargs) return model
@register_model def mixnet_l(pretrained=False, **kwargs):
"""Creates a MixNet Large model. """ model = _gen_mixnet_m( 'mixnet_l', channel_multiplier=1.3, pretrained=pretrained, **kwargs) return model
, **kwargs): """Creates a MixNet Medium model. """ model = _gen_mixnet_m( 'mixnet_m', channel_multiplier=1.0, pretrained=pretrained, **kwargs) return model @register_model def mixnet_l(pretrained=False, **kwargs):
64
64
60
15
48
ndhung/TestNet
timm/models/efficientnet.py
Python
mixnet_l
mixnet_l
1,713
1,719
1,713
1,714
c8d9cd3f2f4eff34fd9a9d98eee1e10e34ea46ca
bigcode/the-stack
train
5c3c690fa94d830045696386
train
function
@register_model def tf_efficientnet_es(pretrained=False, **kwargs): """ EfficientNet-Edge Small. Tensorflow compatible variant """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet_edge( 'tf_efficientnet_es', channel_multiplier=1.0, depth_multiplier=1.0,...
@register_model def tf_efficientnet_es(pretrained=False, **kwargs):
""" EfficientNet-Edge Small. Tensorflow compatible variant """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet_edge( 'tf_efficientnet_es', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=pretrained, **kwargs) return model
same' model = _gen_efficientnet( 'tf_efficientnet_l2_ns', channel_multiplier=4.3, depth_multiplier=5.3, pretrained=pretrained, **kwargs) return model @register_model def tf_efficientnet_es(pretrained=False, **kwargs):
64
64
99
17
46
ndhung/TestNet
timm/models/efficientnet.py
Python
tf_efficientnet_es
tf_efficientnet_es
1,575
1,582
1,575
1,576
6b7a1364a2ef559a531ae9c1a05a7c9ec41b12aa
bigcode/the-stack
train
2a53941f755d5530b74a11af
train
function
def _gen_mobilenet_v2( variant, channel_multiplier=1.0, depth_multiplier=1.0, fix_stem_head=False, pretrained=False, **kwargs): """ Generate MobileNet-V2 network Ref impl: https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet_v2.py Paper: https://arxiv.org/abs/1801....
def _gen_mobilenet_v2( variant, channel_multiplier=1.0, depth_multiplier=1.0, fix_stem_head=False, pretrained=False, **kwargs):
""" Generate MobileNet-V2 network Ref impl: https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet_v2.py Paper: https://arxiv.org/abs/1801.04381 """ arch_def = [ ['ds_r1_k3_s1_c16'], ['ir_r2_k3_s2_e6_c24'], ['ir_r3_k3_s2_e6_c32'], ['ir...
block_args=decode_arch_def(arch_def), stem_size=8, channel_multiplier=channel_multiplier, norm_kwargs=resolve_bn_args(kwargs), **kwargs ) model = _create_model(model_kwargs, default_cfgs[variant], pretrained) return model def _gen_mobilenet_v2( variant, channe...
98
98
329
38
59
ndhung/TestNet
timm/models/efficientnet.py
Python
_gen_mobilenet_v2
_gen_mobilenet_v2
619
645
619
620
609a8ca1e6d8ec9d4c8ca7877ebd0c862fe8354d
bigcode/the-stack
train
d8185427e0967a8230d00741
train
function
@register_model def efficientnet_b4(pretrained=False, **kwargs): """ EfficientNet-B4 """ # NOTE for train, drop_rate should be 0.4, drop_path_rate should be 0.2 model = _gen_efficientnet( 'efficientnet_b4', channel_multiplier=1.4, depth_multiplier=1.8, pretrained=pretrained, **kwargs) return mod...
@register_model def efficientnet_b4(pretrained=False, **kwargs):
""" EfficientNet-B4 """ # NOTE for train, drop_rate should be 0.4, drop_path_rate should be 0.2 model = _gen_efficientnet( 'efficientnet_b4', channel_multiplier=1.4, depth_multiplier=1.8, pretrained=pretrained, **kwargs) return model
0.2 model = _gen_efficientnet( 'efficientnet_b3a', channel_multiplier=1.2, depth_multiplier=1.4, pretrained=pretrained, **kwargs) return model @register_model def efficientnet_b4(pretrained=False, **kwargs):
64
64
90
16
47
ndhung/TestNet
timm/models/efficientnet.py
Python
efficientnet_b4
efficientnet_b4
1,102
1,108
1,102
1,103
4fbe51e3c9cffde1b5c113d0fa9f1a3ef4bdb884
bigcode/the-stack
train
3adf347898f6d67eedf01f3d
train
function
@register_model def semnasnet_050(pretrained=False, **kwargs): """ MNASNet A1 (w/ SE), depth multiplier of 0.5 """ model = _gen_mnasnet_a1('semnasnet_050', 0.5, pretrained=pretrained, **kwargs) return model
@register_model def semnasnet_050(pretrained=False, **kwargs):
""" MNASNet A1 (w/ SE), depth multiplier of 0.5 """ model = _gen_mnasnet_a1('semnasnet_050', 0.5, pretrained=pretrained, **kwargs) return model
Net B1, depth multiplier of 1.4 """ model = _gen_mnasnet_b1('mnasnet_140', 1.4, pretrained=pretrained, **kwargs) return model @register_model def semnasnet_050(pretrained=False, **kwargs):
64
64
71
17
46
ndhung/TestNet
timm/models/efficientnet.py
Python
semnasnet_050
semnasnet_050
960
964
960
961
a7552c002832c884b889925b4dfe24e7d1c6684c
bigcode/the-stack
train
6bdd431345a511dfc1504303
train
function
def _gen_efficientnet_edge(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **kwargs): """ Creates an EfficientNet-EdgeTPU model Ref impl: https://github.com/tensorflow/tpu/tree/master/models/official/efficientnet/edgetpu """ arch_def = [ # NOTE `fc` is present to overr...
def _gen_efficientnet_edge(variant, channel_multiplier=1.0, depth_multiplier=1.0, pretrained=False, **kwargs):
""" Creates an EfficientNet-EdgeTPU model Ref impl: https://github.com/tensorflow/tpu/tree/master/models/official/efficientnet/edgetpu """ arch_def = [ # NOTE `fc` is present to override a mismatch between stem channels and in chs not # present in other models ['er_r1_k3_s1_e4_...
channel_multiplier, act_layer=resolve_act_layer(kwargs, 'swish'), norm_kwargs=resolve_bn_args(kwargs), variant=variant, **kwargs, ) model = _create_model(model_kwargs, default_cfgs[variant], pretrained) return model def _gen_efficientnet_edge(variant, channel_multiplier=1.0, ...
87
87
293
30
56
ndhung/TestNet
timm/models/efficientnet.py
Python
_gen_efficientnet_edge
_gen_efficientnet_edge
760
786
760
760
2f0a8103919aad7d2032cd533474eb2de886bb3f
bigcode/the-stack
train
245e498fd8f4bc6e04432f55
train
function
@register_model def tf_efficientnet_b0(pretrained=False, **kwargs): """ EfficientNet-B0. Tensorflow compatible variant """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'tf_efficientnet_b0', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=p...
@register_model def tf_efficientnet_b0(pretrained=False, **kwargs):
""" EfficientNet-B0. Tensorflow compatible variant """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'tf_efficientnet_b0', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=pretrained, **kwargs) return model
same' model = _gen_efficientnet( 'efficientnet_b3_pruned', channel_multiplier=1.2, depth_multiplier=1.4, pretrained=pretrained, **kwargs) return model @register_model def tf_efficientnet_b0(pretrained=False, **kwargs):
64
64
99
18
45
ndhung/TestNet
timm/models/efficientnet.py
Python
tf_efficientnet_b0
tf_efficientnet_b0
1,285
1,292
1,285
1,286
c7ca6829085800244341a5d77fcb43e8f5e6d65e
bigcode/the-stack
train
4ec0fe548fafb34cd18e2132
train
function
def _cfg(url='', **kwargs): return { 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv_stem', 'classifier': 'classifier', ...
def _cfg(url='', **kwargs):
return { 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, 'first_conv': 'conv_stem', 'classifier': 'classifier', **kwargs }
net_init_weights from .feature_hooks import FeatureHooks from .helpers import load_pretrained, adapt_model_from_file from .layers import SelectAdaptivePool2d, create_conv2d from .registry import register_model __all__ = ['EfficientNet'] def _cfg(url='', **kwargs):
64
64
108
8
56
ndhung/TestNet
timm/models/efficientnet.py
Python
_cfg
_cfg
44
51
44
44
6fd2ebe2757c9fe7e81cbde9f7581e61d86fc776
bigcode/the-stack
train
a909c0009aabbb39d026bf76
train
function
@register_model def tf_efficientnet_b5_ns(pretrained=False, **kwargs): """ EfficientNet-B5 NoisyStudent. Tensorflow compatible variant """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'tf_efficientnet_b5_ns', channel_multiplier=1.6, depth_multiplier...
@register_model def tf_efficientnet_b5_ns(pretrained=False, **kwargs):
""" EfficientNet-B5 NoisyStudent. Tensorflow compatible variant """ kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['pad_type'] = 'same' model = _gen_efficientnet( 'tf_efficientnet_b5_ns', channel_multiplier=1.6, depth_multiplier=2.2, pretrained=pretrained, **kwargs) return model
model = _gen_efficientnet( 'tf_efficientnet_b4_ns', channel_multiplier=1.4, depth_multiplier=1.8, pretrained=pretrained, **kwargs) return model @register_model def tf_efficientnet_b5_ns(pretrained=False, **kwargs):
64
64
103
19
44
ndhung/TestNet
timm/models/efficientnet.py
Python
tf_efficientnet_b5_ns
tf_efficientnet_b5_ns
1,521
1,528
1,521
1,522
9516da3c31d0e262d389b28b90259a7c1351b43d
bigcode/the-stack
train
447d2b389fe019f91d80c686
train
class
class HIPKernelGenerator(BaseKernelGenerator): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Specialise if self.ndim == 1: self._limits = 'if (_x < _nx)' else: self._limits = 'for (int _y = 0; _x < _nx && _y < _ny; _y++)' def r...
class HIPKernelGenerator(BaseKernelGenerator):
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Specialise if self.ndim == 1: self._limits = 'if (_x < _nx)' else: self._limits = 'for (int _y = 0; _x < _nx && _y < _ny; _y++)' def render(self): spec = self._render_spec()...
# -*- coding: utf-8 -*- from pyfr.backends.base.generator import BaseKernelGenerator class HIPKernelGenerator(BaseKernelGenerator):
27
137
457
8
18
YuWangTAMU/PyFR
pyfr/backends/hip/generator.py
Python
HIPKernelGenerator
HIPKernelGenerator
6
58
6
6
041c21361ff88a1c039770694b1c3b9b23d2b288
bigcode/the-stack
train
cdf6ab3921d8117cc7f7b994
train
class
class RemoteStorageGetPublishedFileDetailsResult_t: pass
class RemoteStorageGetPublishedFileDetailsResult_t:
pass
class RemoteStorageGetPublishedFileDetailsResult_t:
11
64
11
11
0
56kyle/bloons_auto
btd6_memory_info/generated/SteamNative/RemoteStorageGetPublishedFileDetailsResult_t/remote_storage_get_published_file_details_result_t.py
Python
RemoteStorageGetPublishedFileDetailsResult_t
RemoteStorageGetPublishedFileDetailsResult_t
1
1
1
1
bde8312236bcdd318c299be6390dc5bd70b3037c
bigcode/the-stack
train
b1515c4b38d3ae69808e2a25
train
class
class TestPlotUtils( object ): """ Test utilities in plots. """ def setup_method( self, method ): self.dirpath = os.path.join(os.path.dirname(__file__), '..', 'data') @pytest.mark.mpl_image_compare(baseline_dir=baseline_test_dir(), filename='plot_titles.pn...
class TestPlotUtils( object ):
""" Test utilities in plots. """ def setup_method( self, method ): self.dirpath = os.path.join(os.path.dirname(__file__), '..', 'data') @pytest.mark.mpl_image_compare(baseline_dir=baseline_test_dir(), filename='plot_titles.png') def test_plot_titles( s...
# -*- coding: utf-8 -*- """ .. codeauthor:: Jaume Bonet <jaume.bonet@gmail.com> .. affiliation:: Laboratory of Protein Design and Immunoengineering <lpdi.epfl.ch> Bruno Correia <bruno.correia@epfl.ch> """ # Standard Libraries import os import random # External Libraries import numpy as np import pandas as pd ...
168
256
2,835
7
160
sesterhe/RosettaSilentToolbox
rstoolbox/tests/misc/test_plot_utils.py
Python
TestPlotUtils
TestPlotUtils
30
258
30
30
2991e01698fd785fe0e27a24775f81bc4df1973d
bigcode/the-stack
train
c9a55e0be5c4137cc201ac0e
train
function
def main(): csvfile = open(filename) csvfile_labels = open(filename_labels) write_labels_to_dynamo(csv.DictReader(csvfile_labels)) write_to_dynamo(csv.DictReader(csvfile)) return print("Done")
def main():
csvfile = open(filename) csvfile_labels = open(filename_labels) write_labels_to_dynamo(csv.DictReader(csvfile_labels)) write_to_dynamo(csv.DictReader(csvfile)) return print("Done")
import sys import csv import boto3 dynamodb = boto3.resource('dynamodb') tableName = 'petal-stack-myDynamoDBTable-4I5GQ39UPNHW' filename = './biomimicry_predictions.csv' filename_labels = './labels.csv' def main():
64
64
49
3
61
nasa/petal-db
csv-to-db.py
Python
main
main
11
18
11
11
3a253496d92d1a30552851d3321f821ef47e0170
bigcode/the-stack
train
e4167f88d91f5c9cb9b7a871
train
function
def write_to_dynamo(rows): table = dynamodb.Table(tableName) with table.batch_writer() as batch: for row in rows: batch.put_item( Item={ 'PartitionKey': 'ARTICLE', 'SortKey': 'ARTICLE-' + row['petalID'], 'title': row...
def write_to_dynamo(rows):
table = dynamodb.Table(tableName) with table.batch_writer() as batch: for row in rows: batch.put_item( Item={ 'PartitionKey': 'ARTICLE', 'SortKey': 'ARTICLE-' + row['petalID'], 'title': row['title_full'], ...
for row in rows: batch.put_item( Item={ 'PartitionKey': row['PartitionKey'], 'SortKey': row['SortKey'], 'level2': row['Level2'], 'level3': row['Level3'] } ) def write_to_dynamo...
65
65
219
7
58
nasa/petal-db
csv-to-db.py
Python
write_to_dynamo
write_to_dynamo
35
64
35
35
6b5def4738a8972252017cf4c46fb8ff59ead18e
bigcode/the-stack
train
84e7d8ae704336b66a0f8658
train
function
def write_labels_to_dynamo(rows): table = dynamodb.Table(tableName) with table.batch_writer() as batch: for row in rows: batch.put_item( Item={ 'PartitionKey': row['PartitionKey'], 'SortKey': row['SortKey'], 'level2'...
def write_labels_to_dynamo(rows):
table = dynamodb.Table(tableName) with table.batch_writer() as batch: for row in rows: batch.put_item( Item={ 'PartitionKey': row['PartitionKey'], 'SortKey': row['SortKey'], 'level2': row['Level2'], ...
_labels) write_labels_to_dynamo(csv.DictReader(csvfile_labels)) write_to_dynamo(csv.DictReader(csvfile)) return print("Done") def slicedict(d, s): return {k:v for k,v in d.items() if k.startswith(s)} def write_labels_to_dynamo(rows):
64
64
84
8
56
nasa/petal-db
csv-to-db.py
Python
write_labels_to_dynamo
write_labels_to_dynamo
23
34
23
23
05976a9a0d15916177645a61221e6059943f39c1
bigcode/the-stack
train
bfe79b1100065acbed43edea
train
function
def slicedict(d, s): return {k:v for k,v in d.items() if k.startswith(s)}
def slicedict(d, s):
return {k:v for k,v in d.items() if k.startswith(s)}
' filename_labels = './labels.csv' def main(): csvfile = open(filename) csvfile_labels = open(filename_labels) write_labels_to_dynamo(csv.DictReader(csvfile_labels)) write_to_dynamo(csv.DictReader(csvfile)) return print("Done") def slicedict(d, s):
64
64
24
7
57
nasa/petal-db
csv-to-db.py
Python
slicedict
slicedict
20
21
20
20
41ffae6c1ab621efc13669f8bcf6f56d409790a7
bigcode/the-stack
train
99f007cd81d6babeb4d05363
train
class
class Shader: # vert, frag and geom take arrays of source strings # the arrays will be concattenated into one string by OpenGL def __init__(self, vert=[], frag=[], geom=[]): # create the program handle self.handle = glCreateProgram() # we are not linked yet self.linked = Fals...
class Shader: # vert, frag and geom take arrays of source strings # the arrays will be concattenated into one string by OpenGL
def __init__(self, vert=[], frag=[], geom=[]): # create the program handle self.handle = glCreateProgram() # we are not linked yet self.linked = False # create the vertex shader self.createShader(vert, GL_VERTEX_SHADER) # create the fragment shader s...
# # Copyright Tristam Macdonald 2008. # # Distributed under the Boost Software License, Version 1.0 # (see http://www.boost.org/LICENSE_1_0.txt) # import ctypes from pyglet.gl import * import pyglet pyglet.options['debug_gl'] = True class Shader: # vert, frag and geom take arrays of source strings # the arrays ...
100
256
1,074
32
67
NiclasEriksen/rpg_procgen
shader.py
Python
Shader
Shader
12
131
12
14
9284f82243a6ceaa074ac8c18afca8a76c9ac324
bigcode/the-stack
train
71a8c8cd339d257787fac82c
train
class
class ExpressionList(Node): """Node for an OPENQASM expression list. children are expression nodes. """ def __init__(self, children): """Create the expression list node.""" super().__init__('expression_list', children, None) def size(self): """Return the number of expressi...
class ExpressionList(Node):
"""Node for an OPENQASM expression list. children are expression nodes. """ def __init__(self, children): """Create the expression list node.""" super().__init__('expression_list', children, None) def size(self): """Return the number of expressions.""" return len(s...
0. # # Any modifications or derivative works of this code must retain this # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. """Node for an OPENQASM expression list.""" import warnings from .node import Node class ExpressionList(Node):
64
64
154
5
58
romainfd/qiskit-terra
qiskit/qasm/node/expressionlist.py
Python
ExpressionList
ExpressionList
21
40
21
21
3e73c51f4f7da95f1eda66764d3d9c3ffa6fb58c
bigcode/the-stack
train
8f3b7a56dc0be39e97e2ed0c
train
function
@contextmanager def app(): res = QApplication(sys.argv) try: yield res finally: res.exec_()
@contextmanager def app():
res = QApplication(sys.argv) try: yield res finally: res.exec_()
.QtWidgets import QApplication def connect(src, sig, dst): src.connect(src, QtCore.SIGNAL(sig), dst) def signal(): return QtCore.Signal() def wheel_angle(ev): return ev.delta() from contextlib import contextmanager import sys @contextmanager def app():
64
64
30
7
56
maxime-tournier/prout.py
snap/qt.py
Python
app
app
17
24
17
18
0550590b905c11dcc1bc28dd76938f21bd29b8e4
bigcode/the-stack
train
df3b94d77a740f9db722b725
train
function
def signal(): return QtCore.Signal()
def signal():
return QtCore.Signal()
from PySide2 import QtCore, QtGui, QtOpenGL, QtWidgets from PySide2.QtWidgets import QApplication def connect(src, sig, dst): src.connect(src, QtCore.SIGNAL(sig), dst) def signal():
51
64
9
3
48
maxime-tournier/prout.py
snap/qt.py
Python
signal
signal
7
8
7
7
3b9abff60159e0bb62e9ddadaa9323b75b212e9e
bigcode/the-stack
train
8205b2406251d55202bd1ce7
train
function
def wheel_angle(ev): return ev.delta()
def wheel_angle(ev):
return ev.delta()
from PySide2 import QtCore, QtGui, QtOpenGL, QtWidgets from PySide2.QtWidgets import QApplication def connect(src, sig, dst): src.connect(src, QtCore.SIGNAL(sig), dst) def signal(): return QtCore.Signal() def wheel_angle(ev):
62
64
10
5
57
maxime-tournier/prout.py
snap/qt.py
Python
wheel_angle
wheel_angle
10
11
10
10
da93010b67422fb322610091ea64ce090a5bd8b4
bigcode/the-stack
train
7528da79e5632eb23112f8cf
train
function
def connect(src, sig, dst): src.connect(src, QtCore.SIGNAL(sig), dst)
def connect(src, sig, dst):
src.connect(src, QtCore.SIGNAL(sig), dst)
from PySide2 import QtCore, QtGui, QtOpenGL, QtWidgets from PySide2.QtWidgets import QApplication def connect(src, sig, dst):
35
64
21
8
26
maxime-tournier/prout.py
snap/qt.py
Python
connect
connect
4
5
4
4
31ba73c441b3372d5bcf067820e727e322d336d5
bigcode/the-stack
train
8db9815075ebb29e8eb67b77
train
class
class Model(pl.LightningModule): """Abstract class handling Pytorch Lightning training flow Args: model_name (str): Network name (i.e., CAML, KimCNN, or XMLCNN). classes (list): List of class names. word_dict (torchtext.vocab.Vocab): A vocab object which maps tokens to indices. ...
class Model(pl.LightningModule):
"""Abstract class handling Pytorch Lightning training flow Args: model_name (str): Network name (i.e., CAML, KimCNN, or XMLCNN). classes (list): List of class names. word_dict (torchtext.vocab.Vocab): A vocab object which maps tokens to indices. init_weight (str, optional): Weig...
from abc import abstractmethod from argparse import Namespace import numpy as np import pytorch_lightning as pl import torch import torch.nn.functional as F import torch.optim as optim from . import networks from .utils import dump_log, argsort_top_k from .metrics import get_metrics, tabulate_metrics class Model(pl.L...
75
256
1,464
7
67
chihming/LibMultiLabel
libmultilabel/model.py
Python
Model
Model
15
194
15
15
9f54ec0f3c00125ed1de41de101acb24e84c9351
bigcode/the-stack
train
db8bdf1c36c13bdf81d72882
train
class
class Elisa(pygame.sprite.Sprite): def __init__(self, sm: StateMachine, pos): super(Elisa, self).__init__() self._state_machine = sm self._current_animation_frame = 0 self._current_state = sm.current.name self._current_sprite = None self._assets = SpriteAssetManager()...
class Elisa(pygame.sprite.Sprite):
def __init__(self, sm: StateMachine, pos): super(Elisa, self).__init__() self._state_machine = sm self._current_animation_frame = 0 self._current_state = sm.current.name self._current_sprite = None self._assets = SpriteAssetManager() self._position = pos ...
# auth: christian bitter # desc: this is based on elisa4 and 5 # we couple the state machine with animation and make movement slightly more realistic. # that is, moving right, will move the player right until an imaginary wall is hit # TODO: fix bug TypeError: 'str' object is not callable from pygame.loca...
124
183
610
8
115
christianbitter/Elisa
elisa_7_anim_statemachine.py
Python
Elisa
Elisa
15
91
15
15
90d0b8469b303715f0fda8e5bfc10b812d09005b
bigcode/the-stack
train
c5401becf94f9ab4a7167ad6
train
function
def main(): if not pygame.font: print("Pygame - fonts not loaded") if not pygame.mixer: print("Pygame - audio not loaded") # init pygame - create the main window, and a background surface pygame.init() S_WIDTH = 800 S_HEIGHT = 600 S_TITLE = "Elisa - Statemachine and GFX" ...
def main():
if not pygame.font: print("Pygame - fonts not loaded") if not pygame.mixer: print("Pygame - audio not loaded") # init pygame - create the main window, and a background surface pygame.init() S_WIDTH = 800 S_HEIGHT = 600 S_TITLE = "Elisa - Statemachine and GFX" C_WHITE =...
_fp: raise ValueError("metadata file not provided") if name in self._assets: raise ValueError("asset already registered") if not os.path.exists(metadata_fp): raise ValueError("metadata file does not exist") self._assets[name] = SpriteMap(metadata_fp) ...
256
256
909
3
253
christianbitter/Elisa
elisa_7_anim_statemachine.py
Python
main
main
143
287
143
143
a0eb533d55fd557464562512ec7228c4ff95463f
bigcode/the-stack
train
6fca23c865b83ab9f225de53
train
class
class SpriteAssetManager(object): def __init__(self): """Constructor for AssetManager""" super(SpriteAssetManager, self).__init__() self._assets = {} def __repr__(self): return "Registered Assets ({}): {}".format( len(self._assets), self._assets.keys() ) ...
class SpriteAssetManager(object):
def __init__(self): """Constructor for AssetManager""" super(SpriteAssetManager, self).__init__() self._assets = {} def __repr__(self): return "Registered Assets ({}): {}".format( len(self._assets), self._assets.keys() ) def add_sprite_map(self, name: st...
= self._sprites[self._current_state][ self._current_animation_frame ] @property def assets(self): return self._assets @property def current_state(self): return self._state_machine.current @property def current_sprite(self): return self._current_spr...
108
108
360
6
101
christianbitter/Elisa
elisa_7_anim_statemachine.py
Python
SpriteAssetManager
SpriteAssetManager
94
140
94
94
9bb940b5d320fca22e56abfbbcf6936d081b8851
bigcode/the-stack
train
e81d2981230b233ba31acc3a
train
class
class PostProcessingQueue(object): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ """ Attributes: openapi_types (dict): The key is attribute name and the value is attribute ty...
class PostProcessingQueue(object):
"""NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ """ Attributes: openapi_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The...
# coding: utf-8 """ 3Di API 3Di simulation API (latest version: 3.0) Framework release: 1.0.16 3Di core release: 2.0.11 deployed on: 07:33AM (UTC) on September 04, 2020 # noqa: E501 The version of the OpenAPI document: 3.0 Contact: info@nelen-schuurmans.nl Generated by: https://openapi-gen...
146
256
1,114
6
139
nens/threedi-api-client
openapi_client/models/post_processing_queue.py
Python
PostProcessingQueue
PostProcessingQueue
22
181
22
22
c7ebe585b44b88bef66630e282dfe1ad0f1e820f
bigcode/the-stack
train
a9bf000e5dd8c8594cea66a7
train
function
def _steppingFind(needle, haystack, step): """ TODO """ for startPos in range(0, len(haystack) - len(needle) + 1): foundMatch = True for pos in range(0, len(needle), step): if haystack[startPos + pos] != needle[pos]: foundMatch = False break ...
def _steppingFind(needle, haystack, step):
""" TODO """ for startPos in range(0, len(haystack) - len(needle) + 1): foundMatch = True for pos in range(0, len(needle), step): if haystack[startPos + pos] != needle[pos]: foundMatch = False break if foundMatch: yield star...
>= 0 and needle[matchLen] != c: startPos += shifts[matchLen] matchLen -= shifts[matchLen] matchLen += 1 if matchLen == len(needle): yield startPos def _steppingFind(needle, haystack, step):
64
64
95
13
50
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
_steppingFind
_steppingFind
521
532
521
521
0d8a99490f7c39e005c0378d21b8be84979fde0f
bigcode/the-stack
train
e1cc68787e795a814b0f26e9
train
function
def center(coords): """ Returns a `Point` object with the x and y set to an integer determined by the format of `coords`. The `coords` argument is a 4-integer tuple of (left, top, width, height). For example: >>> center((10, 10, 6, 8)) Point(x=13, y=14) >>> center((10, 10, 7, 9)) Poin...
def center(coords):
""" Returns a `Point` object with the x and y set to an integer determined by the format of `coords`. The `coords` argument is a 4-integer tuple of (left, top, width, height). For example: >>> center((10, 10, 6, 8)) Point(x=13, y=14) >>> center((10, 10, 7, 9)) Point(x=13, y=14) >>...
len(needle) + 1): foundMatch = True for pos in range(0, len(needle), step): if haystack[startPos + pos] != needle[pos]: foundMatch = False break if foundMatch: yield startPos def center(coords):
64
64
181
4
59
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
center
center
535
552
535
535
9b7be9ef8f6eacffe8d1d50688324562ef661781
bigcode/the-stack
train
ac9f17f70d1d199aad3f03fc
train
function
def locateAllOnScreen(image, **kwargs): """ TODO """ # TODO - Should this raise an exception if zero instances of the image can be found on the screen, instead of always returning a generator? screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate ...
def locateAllOnScreen(image, **kwargs):
""" TODO """ # TODO - Should this raise an exception if zero instances of the image can be found on the screen, instead of always returning a generator? screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here...
Val or time.time() - start > minSearchTime: return retVal except ImageNotFoundException: if time.time() - start > minSearchTime: if USE_IMAGE_NOT_FOUND_EXCEPTION: raise else: return None def locateAllOnScreen(ima...
64
64
156
10
53
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
locateAllOnScreen
locateAllOnScreen
378
393
378
378
dc94f9238cf57edd05438a2cbb56483a4e6db147
bigcode/the-stack
train
e10b143ef689dddf0c9295fc
train
function
def pixel(x, y): """ TODO """ if sys.platform == 'win32': # On Windows, calling GetDC() and GetPixel() is twice as fast as using our screenshot() function. with __win32_openDC(0) as hdc: # handle will be released automatically color = windll.gdi32.GetPixel(hdc, x, y) ...
def pixel(x, y):
""" TODO """ if sys.platform == 'win32': # On Windows, calling GetDC() and GetPixel() is twice as fast as using our screenshot() function. with __win32_openDC(0) as hdc: # handle will be released automatically color = windll.gdi32.GetPixel(hdc, x, y) if color < 0:...
and (abs(b - exB) <= tolerance) and (abs(a - exA) <= tolerance) else: assert False, 'Color mode was expected to be length 3 (RGB) or 4 (RGBA), but pixel is length %s and expectedRGBColor is length %s' % (len(pix), len(expectedRGBColor)) def pixel(x, y):
80
80
267
6
74
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
pixel
pixel
571
588
571
571
48dca3a34a6fbf2ef3f898bb88de233bc7914968
bigcode/the-stack
train
2cfa70642ea241d50733eac6
train
function
def _locateAll_opencv(needleImage, haystackImage, grayscale=None, limit=10000, region=None, step=1, confidence=0.999): """ TODO - rewrite this faster but more memory-intensive than pure python step 2 skips every other row and column = ~3x faster but prone to miss; ...
def _locateAll_opencv(needleImage, haystackImage, grayscale=None, limit=10000, region=None, step=1, confidence=0.999):
""" TODO - rewrite this faster but more memory-intensive than pure python step 2 skips every other row and column = ~3x faster but prone to miss; to compensate, the algorithm automatically reduces the confidence threshold by 5% (which helps but will not avoid all misses)....
# and img.shape[2] == 3: img_cv = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) else: img_cv = img elif hasattr(img, 'convert'): # assume its a PIL.Image, convert to cv format img_array = numpy.array(img.convert('RGB')) img_cv = img_array[:, :, ::-1].copy() # -1 do...
180
180
600
37
142
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
_locateAll_opencv
_locateAll_opencv
180
233
180
181
c4db9a186e2828465608ec347ba265d84e7a63af
bigcode/the-stack
train
ca34f02756bc3b555df6bb72
train
function
def locateOnScreen(image, minSearchTime=0, **kwargs): """TODO - rewrite this minSearchTime - amount of time in seconds to repeat taking screenshots and trying to locate a match. The default of 0 performs a single search. """ start = time.time() while True: try: screensho...
def locateOnScreen(image, minSearchTime=0, **kwargs):
"""TODO - rewrite this minSearchTime - amount of time in seconds to repeat taking screenshots and trying to locate a match. The default of 0 performs a single search. """ start = time.time() while True: try: screenshotIm = screenshot(region=None) # the locateAll() functi...
Image, haystackImage, **kwargs)) if len(points) > 0: return points[0] else: if USE_IMAGE_NOT_FOUND_EXCEPTION: raise ImageNotFoundException('Could not locate the image.') else: return None def locateOnScreen(image, minSearchTime=0, **kwargs):
70
70
234
15
54
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
locateOnScreen
locateOnScreen
350
375
350
350
12b890436bb717122f6e579c15240122f91cfb8c
bigcode/the-stack
train
a840ccf99ce80c3d75ecb53b
train
function
def pixelMatchesColor(x, y, expectedRGBColor, tolerance=0): """ TODO """ pix = pixel(x, y) if len(pix) == 3 or len(expectedRGBColor) == 3: #RGB mode r, g, b = pix[:3] exR, exG, exB = expectedRGBColor[:3] return (abs(r - exR) <= tolerance) and (abs(g - exG) <= tolerance) and (...
def pixelMatchesColor(x, y, expectedRGBColor, tolerance=0):
""" TODO """ pix = pixel(x, y) if len(pix) == 3 or len(expectedRGBColor) == 3: #RGB mode r, g, b = pix[:3] exR, exG, exB = expectedRGBColor[:3] return (abs(r - exR) <= tolerance) and (abs(g - exG) <= tolerance) and (abs(b - exB) <= tolerance) elif len(pix) == 4 and len(ex...
10)) Point(x=14, y=15) """ # TODO - one day, add code to handle a Box namedtuple. return Point(coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2)) def pixelMatchesColor(x, y, expectedRGBColor, tolerance=0):
78
78
263
16
62
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
pixelMatchesColor
pixelMatchesColor
555
569
555
555
e36f1b7bcec48848fa1d23531d7b12e3e99fef67
bigcode/the-stack
train
a5734c1b08891204787dd3a4
train
function
@requiresPillow def _screenshot_win32(imageFilename=None, region=None): """ TODO """ # TODO - Use the winapi to get a screenshot, and compare performance with ImageGrab.grab() # https://stackoverflow.com/a/3586280/1893164 im = ImageGrab.grab() if region is not None: assert len(region...
@requiresPillow def _screenshot_win32(imageFilename=None, region=None):
""" TODO """ # TODO - Use the winapi to get a screenshot, and compare performance with ImageGrab.grab() # https://stackoverflow.com/a/3586280/1893164 im = ImageGrab.grab() if region is not None: assert len(region) == 4, 'region argument must be a tuple of four ints' region = ...
[3] + region[1]) # convert from (left, top, right, bottom) to (left, top, width, height) draw.rectangle(region, outline=outlineColor) screenshotIm.save(filename) @requiresPillow def _screenshot_win32(imageFilename=None, region=None):
64
64
160
18
46
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
_screenshot_win32
_screenshot_win32
420
434
420
421
66bcff86ff51b74050768fccaf1df51794173018
bigcode/the-stack
train
23ebdd33f2aaae4c62d67190
train
function
def _screenshot_osx(imageFilename=None, region=None): """ TODO """ # TODO - use tmp name for this file. if imageFilename is None: tmpFilename = 'screenshot%s.png' % (datetime.datetime.now().strftime('%Y-%m%d_%H-%M-%S-%f')) else: tmpFilename = imageFilename subprocess.call(['s...
def _screenshot_osx(imageFilename=None, region=None):
""" TODO """ # TODO - use tmp name for this file. if imageFilename is None: tmpFilename = 'screenshot%s.png' % (datetime.datetime.now().strftime('%Y-%m%d_%H-%M-%S-%f')) else: tmpFilename = imageFilename subprocess.call(['screencapture', '-x', tmpFilename]) im = Image.open...
(x) for x in region] im = im.crop((region[0], region[1], region[2] + region[0], region[3] + region[1])) if imageFilename is not None: im.save(imageFilename) return im def _screenshot_osx(imageFilename=None, region=None):
70
70
234
13
56
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
_screenshot_osx
_screenshot_osx
437
461
437
437
1de34aa1b358c7ec3b14b711f9e4c9742aac58ad
bigcode/the-stack
train
c94bdaf9159dc271389ea570
train
function
def locateCenterOnScreen(image, **kwargs): """ TODO """ coords = locateOnScreen(image, **kwargs) if coords is None: return None else: return center(coords)
def locateCenterOnScreen(image, **kwargs):
""" TODO """ coords = locateOnScreen(image, **kwargs) if coords is None: return None else: return center(coords)
: # Screenshots on Windows won't have an fp since they came from # ImageGrab, not a file. Screenshots on Linux will have fp set # to None since the file has been unlinked pass return retVal def locateCenterOnScreen(image, **kwargs):
64
64
46
10
53
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
locateCenterOnScreen
locateCenterOnScreen
396
404
396
396
3565f51444ac855ec5cd7625da9f5e3c2ef1865b
bigcode/the-stack
train
4cb01d36e8f2d020eab744b4
train
class
class ImageNotFoundException(PyScreezeException): pass # This is an exception class raised when the locate functions fail to locate an image.
class ImageNotFoundException(PyScreezeException):
pass # This is an exception class raised when the locate functions fail to locate an image.
Point = collections.namedtuple('Point', 'x y') RGB = collections.namedtuple('RGB', 'red green blue') class PyScreezeException(Exception): pass # This is a generic exception class raised when a PyScreeze-related error happens. class ImageNotFoundException(PyScreezeException):
64
64
30
11
53
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
ImageNotFoundException
ImageNotFoundException
122
123
122
122
bc4c89279f97829b75a20d96faffec5b3d4dba9f
bigcode/the-stack
train
522ff9fce5803800eba6ad90
train
function
def locate(needleImage, haystackImage, **kwargs): """ TODO """ # Note: The gymnastics in this function is because we want to make sure to exhaust the iterator so that the needle and haystack files are closed in locateAll. kwargs['limit'] = 1 points = tuple(locateAll(needleImage, haystackImage, *...
def locate(needleImage, haystackImage, **kwargs):
""" TODO """ # Note: The gymnastics in this function is because we want to make sure to exhaust the iterator so that the needle and haystack files are closed in locateAll. kwargs['limit'] = 1 points = tuple(locateAll(needleImage, haystackImage, **kwargs)) if len(points) > 0: return p...
haystackFileObj is not None: haystackFileObj.close() if numMatchesFound == 0: if USE_IMAGE_NOT_FOUND_EXCEPTION: raise ImageNotFoundException('Could not locate the image.') else: return def locate(needleImage, haystackImage, **kwargs):
64
64
127
13
50
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
locate
locate
334
347
334
334
3a0b914f8edbb9b041a52326914f95784809d678
bigcode/the-stack
train
11a8916845286ca4a4642470
train
function
@requiresPillow def _locateAll_python(needleImage, haystackImage, grayscale=None, limit=None, region=None, step=1): """ TODO """ # setup all the arguments if grayscale is None: grayscale = GRAYSCALE_DEFAULT needleFileObj = None if isinstance(needleImage, (str, unicode)): # '...
@requiresPillow def _locateAll_python(needleImage, haystackImage, grayscale=None, limit=None, region=None, step=1):
""" TODO """ # setup all the arguments if grayscale is None: grayscale = GRAYSCALE_DEFAULT needleFileObj = None if isinstance(needleImage, (str, unicode)): # 'image' is a filename, load the Image object needleFileObj = open(needleImage, 'rb') needleImage = Im...
inding-a-subimage-inside-a-numpy-image/9253805#9253805 result = cv2.matchTemplate(haystackImage, needleImage, cv2.TM_CCOEFF_NORMED) match_indices = numpy.arange(result.size)[(result > confidence).flatten()] matches = numpy.unravel_index(match_indices[:limit], result.shape) if len(matches[0]) == 0: ...
256
256
1,024
32
224
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
_locateAll_python
_locateAll_python
237
331
237
238
ac39d778e4862662ed5f8b906aae85563623f060
bigcode/the-stack
train
fb363003042cc25e9cb96041
train
function
@requiresPillow def showRegionOnScreen(region, outlineColor='red', filename='_showRegionOnScreen.png'): """ TODO """ # TODO - This function is useful! Document it! screenshotIm = screenshot() draw = ImageDraw.Draw(screenshotIm) region = (region[0], region[1], region[2] + region[0], region[3]...
@requiresPillow def showRegionOnScreen(region, outlineColor='red', filename='_showRegionOnScreen.png'):
""" TODO """ # TODO - This function is useful! Document it! screenshotIm = screenshot() draw = ImageDraw.Draw(screenshotIm) region = (region[0], region[1], region[2] + region[0], region[3] + region[1]) # convert from (left, top, right, bottom) to (left, top, width, height) draw.rectangle...
**kwargs): """ TODO """ coords = locateOnScreen(image, **kwargs) if coords is None: return None else: return center(coords) @requiresPillow def showRegionOnScreen(region, outlineColor='red', filename='_showRegionOnScreen.png'):
64
64
128
25
39
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
showRegionOnScreen
showRegionOnScreen
407
417
407
408
fc5dc53340ee7a82283b3b2a56a2dd91972f1d7a
bigcode/the-stack
train
9448a3521bd8ecf0cfa64b76
train
function
def requiresPillow(wrappedFunction): """ A decorator that marks a function as requiring Pillow to be installed. This raises PyScreezeException if Pillow wasn't imported. """ @functools.wraps(wrappedFunction) def wrapper(*args, **kwargs): if _PILLOW_UNAVAILABLE: raise PyScreez...
def requiresPillow(wrappedFunction):
""" A decorator that marks a function as requiring Pillow to be installed. This raises PyScreezeException if Pillow wasn't imported. """ @functools.wraps(wrappedFunction) def wrapper(*args, **kwargs): if _PILLOW_UNAVAILABLE: raise PyScreezeException('The Pillow package is req...
ScreezeException(Exception): pass # This is a generic exception class raised when a PyScreeze-related error happens. class ImageNotFoundException(PyScreezeException): pass # This is an exception class raised when the locate functions fail to locate an image. def requiresPillow(wrappedFunction):
64
64
100
8
56
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
requiresPillow
requiresPillow
126
136
126
126
9e057a2ebbc37138096b4f6fe722687b6ccfd004
bigcode/the-stack
train
ed7b390e105edb69b5cc8f6b
train
function
def _screenshot_linux(imageFilename=None, region=None): """ TODO """ if not scrotExists: raise NotImplementedError('"scrot" must be installed to use screenshot functions in Linux. Run: sudo apt-get install scrot') if imageFilename is None: tmpFilename = '.screenshot%s.png' % (datetim...
def _screenshot_linux(imageFilename=None, region=None):
""" TODO """ if not scrotExists: raise NotImplementedError('"scrot" must be installed to use screenshot functions in Linux. Run: sudo apt-get install scrot') if imageFilename is None: tmpFilename = '.screenshot%s.png' % (datetime.datetime.now().strftime('%Y-%m%d_%H-%M-%S-%f')) el...
] + region[0], region[3] + region[1])) os.unlink(tmpFilename) # delete image of entire screen to save cropped version im.save(tmpFilename) else: # force loading before unlinking, Image.open() is lazy im.load() if imageFilename is None: os.unlink(tmpFilename) return i...
88
88
296
12
75
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
_screenshot_linux
_screenshot_linux
464
492
464
464
ce0d09c9514f92ced7912189ebd38c6e4199bbbe
bigcode/the-stack
train
435ef77925096b79a5462036
train
class
class PyScreezeException(Exception): pass # This is a generic exception class raised when a PyScreeze-related error happens.
class PyScreezeException(Exception):
pass # This is a generic exception class raised when a PyScreeze-related error happens.
raise WindowsError("windll.user32.ReleaseDC failed : return 0") Box = collections.namedtuple('Box', 'left top width height') Point = collections.namedtuple('Point', 'x y') RGB = collections.namedtuple('RGB', 'red green blue') class PyScreezeException(Exception):
64
64
28
8
56
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
PyScreezeException
PyScreezeException
119
120
119
119
175f6596decca87142a398cc8bd74b333c3bef32
bigcode/the-stack
train
8a681721e7dab89c31df95c8
train
function
def _load_cv2(img, grayscale=None): """ TODO """ # load images if given filename, or convert as needed to opencv # Alpha layer just causes failures at this point, so flatten to RGB. # RGBA: load with -1 * cv2.CV_LOAD_IMAGE_COLOR to preserve alpha # to matchTemplate, need template and image t...
def _load_cv2(img, grayscale=None):
""" TODO """ # load images if given filename, or convert as needed to opencv # Alpha layer just causes failures at this point, so flatten to RGB. # RGBA: load with -1 * cv2.CV_LOAD_IMAGE_COLOR to preserve alpha # to matchTemplate, need template and image to be the same wrt having alpha ...
zeException): pass # This is an exception class raised when the locate functions fail to locate an image. def requiresPillow(wrappedFunction): """ A decorator that marks a function as requiring Pillow to be installed. This raises PyScreezeException if Pillow wasn't imported. """ @functools.wra...
132
132
442
10
121
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
_load_cv2
_load_cv2
138
177
138
138
7c602e5567c14eff36e52ab8354e064ba86bc3b4
bigcode/the-stack
train
bee2970573618040655ec6b0
train
function
def _kmp(needle, haystack, _dummy): # Knuth-Morris-Pratt search algorithm implementation (to be used by screen capture) """ TODO """ # build table of shift amounts shifts = [1] * (len(needle) + 1) shift = 1 for pos in range(len(needle)): while shift <= pos and needle[pos] != needle[p...
def _kmp(needle, haystack, _dummy): # Knuth-Morris-Pratt search algorithm implementation (to be used by screen capture)
""" TODO """ # build table of shift amounts shifts = [1] * (len(needle) + 1) shift = 1 for pos in range(len(needle)): while shift <= pos and needle[pos] != needle[pos-shift]: shift += shifts[pos-shift] shifts[pos+1] = shift # do the actual search startPos...
raise Exception('The scrot program must be installed to take a screenshot with PyScreeze on Linux. Run: sudo apt-get install scrot') def _kmp(needle, haystack, _dummy): # Knuth-Morris-Pratt search algorithm implementation (to be used by screen capture)
63
64
202
31
32
SteevenBrunner/gmail-generator
venv/Lib/site-packages/pyscreeze/__init__.py
Python
_kmp
_kmp
496
518
496
496
2c3a798098c0d9d1e9cecddce3dd915c15336b75
bigcode/the-stack
train
17600a9ac5a9b29552c78c2c
train
class
class DepthAI: def __init__(self,file=None,camera=False): print("Loading pipeline...") self.file = file self.camera = camera self.create_pipeline() self.start_pipeline() self.fps = FPS() self.fps.start() def create_pipeline(self): print("Cre...
class DepthAI:
def __init__(self,file=None,camera=False): print("Loading pipeline...") self.file = file self.camera = camera self.create_pipeline() self.start_pipeline() self.fps = FPS() self.fps.start() def create_pipeline(self): print("Creating pipeline.....
from pathlib import Path from imutils.video import FPS from .utils import * class DepthAI:
21
256
1,378
4
17
wasauce/depthai-experiments
gen2-mask-detection/depthai_utils/gen2_depthai.py
Python
DepthAI
DepthAI
5
175
5
6
37d9e87e9b7f8b5df276dce50c007ae672efe376
bigcode/the-stack
train
6cb176e6006f035e07380dd2
train
function
def make_nn_funs(layer_sizes, L2_reg, noise_variance, nonlinearity=np.tanh): """These functions implement a standard multi-layer perceptron, vectorized over both training examples and weight samples.""" shapes = list(zip(layer_sizes[:-1], layer_sizes[1:])) num_weights = sum((m + 1) * n for m, n in shape...
def make_nn_funs(layer_sizes, L2_reg, noise_variance, nonlinearity=np.tanh):
"""These functions implement a standard multi-layer perceptron, vectorized over both training examples and weight samples.""" shapes = list(zip(layer_sizes[:-1], layer_sizes[1:])) num_weights = sum((m + 1) * n for m, n in shapes) def unpack_layers(weights): num_weight_sets = len(weights) ...
from __future__ import absolute_import from __future__ import print_function import matplotlib.pyplot as plt import csv import sys import numpy import autograd.numpy as np import autograd.numpy.random as npr from black_box_svi import black_box_variational_inference from autograd.misc.optimizers import adam import rando...
95
126
422
23
71
wang-xiaotu/autograd
examples/BNNexpand.py
Python
make_nn_funs
make_nn_funs
13
48
13
13
34ff0743bf295e2d45c879a63abb9a005672a5da
bigcode/the-stack
train
c905eefaeeb6e6412bd128ba
train
function
def build_toy_dataset(n_data=40, noise_std=0.1, type = "1", seed=0): D = 1 rs = npr.RandomState(seed) total_num = n_data * 10 overallinput = np.linspace(-8, 8, num=total_num) overalltarget = 0.7 * np.cos(overallinput) + 0.25*overallinput + rs.randn(n_data * 10) * noise_std overallinput = overall...
def build_toy_dataset(n_data=40, noise_std=0.1, type = "1", seed=0):
D = 1 rs = npr.RandomState(seed) total_num = n_data * 10 overallinput = np.linspace(-8, 8, num=total_num) overalltarget = 0.7 * np.cos(overallinput) + 0.25*overallinput + rs.randn(n_data * 10) * noise_std overallinput = overallinput / 4 if type == "1": #print("more") input_ix...
] # targets = overalltarget[input_ix] # inputs = inputs.reshape((len(inputs), D)) # targets = targets.reshape((len(targets), D)) # overallinput = overallinput.reshape((len(overallinput), D)) # overalltarget = overalltarget.reshape((len(overallinput), D)) # # return inputs, targets, overallin...
111
111
372
26
84
wang-xiaotu/autograd
examples/BNNexpand.py
Python
build_toy_dataset
build_toy_dataset
70
99
70
70
e9c2e8052362f4009d33adb6d582c1519fbb257c
bigcode/the-stack
train
5f673d042324a5541055bb09
train
class
class authenticationlocalpolicy_authenticationvserver_binding_response(base_response) : def __init__(self, length=1) : self.authenticationlocalpolicy_authenticationvserver_binding = [] self.errorcode = 0 self.message = "" self.severity = "" self.sessionid = "" self.authenticationlocalpolicy_authenticationv...
class authenticationlocalpolicy_authenticationvserver_binding_response(base_response) :
def __init__(self, length=1) : self.authenticationlocalpolicy_authenticationvserver_binding = [] self.errorcode = 0 self.message = "" self.severity = "" self.sessionid = "" self.authenticationlocalpolicy_authenticationvserver_binding = [authenticationlocalpolicy_authenticationvserver_binding() for _ in ran...
option_.filter = filter_ response = obj.getfiltered(service, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e: raise e class authenticationlocalpolicy_authenticationvserver_binding_response(base_response) :
64
64
89
14
49
guardicore/nitro-python
nssrc/com/citrix/netscaler/nitro/resource/config/authentication/authenticationlocalpolicy_authenticationvserver_binding.py
Python
authenticationlocalpolicy_authenticationvserver_binding_response
authenticationlocalpolicy_authenticationvserver_binding_response
178
185
178
178
1bcb101a0a2d45f7d20e7bef242c4a35ee652df1
bigcode/the-stack
train
a6aa8462b0c5da8641975dcf
train
class
class authenticationlocalpolicy_authenticationvserver_binding(base_resource) : """ Binding class showing the authenticationvserver that can be bound to authenticationlocalpolicy. """ def __init__(self) : self._boundto = None self._priority = None self._activepolicy = None self._name = None self.___count = ...
class authenticationlocalpolicy_authenticationvserver_binding(base_resource) :
""" Binding class showing the authenticationvserver that can be bound to authenticationlocalpolicy. """ def __init__(self) : self._boundto = None self._priority = None self._activepolicy = None self._name = None self.___count = None @property def boundto(self) : r"""The entity name to which policy is ...
, Inc. # # Licensed under the Apache License, Version 2.0 (the "License") # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # d...
256
256
1,032
13
242
guardicore/nitro-python
nssrc/com/citrix/netscaler/nitro/resource/config/authentication/authenticationlocalpolicy_authenticationvserver_binding.py
Python
authenticationlocalpolicy_authenticationvserver_binding
authenticationlocalpolicy_authenticationvserver_binding
24
176
24
24
f7c514c36b6eba5618072375d2b03a81cb82cf9f
bigcode/the-stack
train
d935cfde65f8ded732affa84
train
class
class searchContacts(Method): query = None # type: "string" limit = None # type: "int32"
class searchContacts(Method):
query = None # type: "string" limit = None # type: "int32"
from ..factory import Method class searchContacts(Method):
11
64
27
5
5
Mr-TelegramBot/python-tdlib
py_tdlib/constructors/search_contacts.py
Python
searchContacts
searchContacts
4
6
4
4
fa7bd7f9182bf86f1dc91add1a0637c8f7e76e44
bigcode/the-stack
train
e182ba6973caafaba5bd1ee0
train
class
class V8Branches(Master.Master3): base_app_url = 'https://v8-status.appspot.com' tree_status_url = base_app_url + '/status' store_revisions_url = base_app_url + '/revisions' last_good_url = base_app_url + '/lkgr' project_name = 'V8 Branches' master_port = 8046 slave_port = 8146 master_port_alt = 8246 ...
class V8Branches(Master.Master3):
base_app_url = 'https://v8-status.appspot.com' tree_status_url = base_app_url + '/status' store_revisions_url = base_app_url + '/revisions' last_good_url = base_app_url + '/lkgr' project_name = 'V8 Branches' master_port = 8046 slave_port = 8146 master_port_alt = 8246 project_url = 'http://v8.googlecod...
# Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ActiveMaster definition.""" from config_bootstrap import Master class V8Branches(Master.Master3):
58
64
171
9
48
bopopescu/chromium-build
masters/master.client.v8.branches/master_site_config.py
Python
V8Branches
V8Branches
9
22
9
9
d71bcf31f510237dd1568c9b61d1e18fb81ab8c1
bigcode/the-stack
train
22663d045fcd3a9db3d8ef1e
train
function
@pytest.mark.qiskit @pytest.mark.parametrize( ("mode", "num", "true_state_name", "decimal"), [("qubit", 1, "z0", 4)] ) def test_estimate_standard_qst_from_qiskit(mode, num, true_state_name, decimal): c_sys = generate_composite_system(mode, num) true_state = generate_state_from_name(c_sys, true_state_n...
@pytest.mark.qiskit @pytest.mark.parametrize( ("mode", "num", "true_state_name", "decimal"), [("qubit", 1, "z0", 4)] ) def test_estimate_standard_qst_from_qiskit(mode, num, true_state_name, decimal):
c_sys = generate_composite_system(mode, num) true_state = generate_state_from_name(c_sys, true_state_name) true_state_qiskit = convert_state_quara_to_qiskit(true_state) get_tester_povm_names_method_name = f"get_tester_povm_names_{int(num)}{mode}" get_tester_povm_names_method = eval(get_tester_...
ical import generate_state_from_name from quara.objects.povm_typical import generate_povm_from_name from quara.objects.gate_typical import generate_gate_from_gate_name def get_tester_state_names_1qubit(): return ["x0", "y0", "z0", "z1"] def get_tester_povm_names_1qubit(): return ["x", "y", "z"] @p...
155
156
523
62
93
tknrsgym/quara
tests/quara/interface/qiskit/test_api.py
Python
test_estimate_standard_qst_from_qiskit
test_estimate_standard_qst_from_qiskit
36
83
36
40
7885d5a90e1bdba237117bf6930fec0116ee2a5d
bigcode/the-stack
train
5895a8cdd7beb18ed007903e
train
function
def get_tester_povm_names_1qubit(): return ["x", "y", "z"]
def get_tester_povm_names_1qubit():
return ["x", "y", "z"]
_povm_from_name from quara.objects.gate_typical import generate_gate_from_gate_name def get_tester_state_names_1qubit(): return ["x0", "y0", "z0", "z1"] def get_tester_povm_names_1qubit():
63
64
24
13
50
tknrsgym/quara
tests/quara/interface/qiskit/test_api.py
Python
get_tester_povm_names_1qubit
get_tester_povm_names_1qubit
32
33
32
32
3f8e4d0533db7ec731d6144c7051b913934544c3
bigcode/the-stack
train
6b40f859fb679dd1f27e22cb
train
function
@pytest.mark.qiskit @pytest.mark.parametrize( ("mode", "num", "true_povm_name", "decimal"), [("qubit", 1, "z", 4)] ) def test_estimate_standard_povmt_from_qiskit(mode, num, true_povm_name, decimal): c_sys = generate_composite_system(mode, num) true_povm = generate_povm_from_name(true_povm_name, c_sys)...
@pytest.mark.qiskit @pytest.mark.parametrize( ("mode", "num", "true_povm_name", "decimal"), [("qubit", 1, "z", 4)] ) def test_estimate_standard_povmt_from_qiskit(mode, num, true_povm_name, decimal):
c_sys = generate_composite_system(mode, num) true_povm = generate_povm_from_name(true_povm_name, c_sys) true_povm_qiskit = convert_povm_quara_to_qiskit(true_povm) get_tester_state_names_method_name = f"get_tester_state_names_{int(num)}{mode}" get_tester_state_names_method = eval(get_tester_sta...
_qiskit( mode, num, tester_povms=tester_povms_qiskit, empi_dists=empi_dists_qiskit, shots=shots, label=label, estimator_name=estimator_name, schedules="all", ) npt.assert_array_almost_equal( ...
158
159
533
66
92
tknrsgym/quara
tests/quara/interface/qiskit/test_api.py
Python
test_estimate_standard_povmt_from_qiskit
test_estimate_standard_povmt_from_qiskit
86
138
86
90
98728bf43711eb5dd350b60f10ebfbb4ca67d55d
bigcode/the-stack
train
9aaaa6a79db1ab5d3d6915dd
train
function
def get_tester_state_names_1qubit(): return ["x0", "y0", "z0", "z1"]
def get_tester_state_names_1qubit():
return ["x0", "y0", "z0", "z1"]
_typical import generate_composite_system from quara.objects.state_typical import generate_state_from_name from quara.objects.povm_typical import generate_povm_from_name from quara.objects.gate_typical import generate_gate_from_gate_name def get_tester_state_names_1qubit():
64
64
29
11
52
tknrsgym/quara
tests/quara/interface/qiskit/test_api.py
Python
get_tester_state_names_1qubit
get_tester_state_names_1qubit
28
29
28
28
0e392d9c8f83939438a012b07fa2495121ce9fc4
bigcode/the-stack
train
1203eef29a2b088cac6dc38d
train
function
@pytest.mark.qiskit @pytest.mark.parametrize( ("mode", "num", "true_gate_name", "decimal"), [("qubit", 1, "identity", 4)] ) def test_estimate_standard_qpt_from_qiskit(mode, num, true_gate_name, decimal): dim = 2 ** num c_sys = generate_composite_system(mode, num) true_gate = generate_gate_from_ga...
@pytest.mark.qiskit @pytest.mark.parametrize( ("mode", "num", "true_gate_name", "decimal"), [("qubit", 1, "identity", 4)] ) def test_estimate_standard_qpt_from_qiskit(mode, num, true_gate_name, decimal):
dim = 2 ** num c_sys = generate_composite_system(mode, num) true_gate = generate_gate_from_gate_name(true_gate_name, c_sys) true_gate_qiskit = convert_gate_quara_to_qiskit(true_gate, dim) get_tester_state_names_method_name = f"get_tester_state_names_{int(num)}{mode}" get_tester_state_name...
label = [2, 2, 2, 2] for estimator_name in ["linear", "least_squares"]: estimated_povm_qiskit = estimate_standard_povmt_from_qiskit( mode, num, tester_states=tester_states_qiskit, empi_dists=empi_dists_qiskit, shots=shots, la...
208
209
699
61
147
tknrsgym/quara
tests/quara/interface/qiskit/test_api.py
Python
test_estimate_standard_qpt_from_qiskit
test_estimate_standard_qpt_from_qiskit
141
204
141
145
46c039886d398a55dd1ed3704278d4ff910f6405
bigcode/the-stack
train
5cfa202d60e2f0eb479253b3
train
function
@pytest.mark.qiskit def test_generate_empi_dists_from_quara_label(): true_empi_dists = [[2, 2, 2], np.array([0.864, 0.136, 0.844, 0.156, 0.49, 0.51])] source = [ (1000, np.array([0.864, 0.136])), (1000, np.array([0.844, 0.156])), (1000, np.array([0.49, 0.51])), ] actual =...
@pytest.mark.qiskit def test_generate_empi_dists_from_quara_label():
true_empi_dists = [[2, 2, 2], np.array([0.864, 0.136, 0.844, 0.156, 0.49, 0.51])] source = [ (1000, np.array([0.864, 0.136])), (1000, np.array([0.844, 0.156])), (1000, np.array([0.49, 0.51])), ] actual = generate_empi_dists_from_quara(source) assert actual[0] == true_e...
estimator_name=estimator_name, schedules="all", ) npt.assert_array_almost_equal( estimated_gate_qiskit, true_gate_qiskit, decimal=decimal, ) @pytest.mark.qiskit def test_generate_empi_dists_from_quara_label():
63
64
155
18
45
tknrsgym/quara
tests/quara/interface/qiskit/test_api.py
Python
test_generate_empi_dists_from_quara_label
test_generate_empi_dists_from_quara_label
207
216
207
208
941f8f4db976e69d1454fdcb3f47fedd2085b19e
bigcode/the-stack
train
afc43d0002c9bc4ecd8a53a2
train
function
@pytest.mark.qiskit def test_generate_empi_dists_from_quara_dists(): true_empi_dists = [[2, 2, 2], np.array([0.864, 0.136, 0.844, 0.156, 0.49, 0.51])] source = [ (1000, np.array([0.864, 0.136])), (1000, np.array([0.844, 0.156])), (1000, np.array([0.49, 0.51])), ] actual =...
@pytest.mark.qiskit def test_generate_empi_dists_from_quara_dists():
true_empi_dists = [[2, 2, 2], np.array([0.864, 0.136, 0.844, 0.156, 0.49, 0.51])] source = [ (1000, np.array([0.864, 0.136])), (1000, np.array([0.844, 0.156])), (1000, np.array([0.49, 0.51])), ] actual = generate_empi_dists_from_quara(source) npt.assert_array_almost_eq...
, np.array([0.49, 0.51])), ] actual = generate_empi_dists_from_quara(source) assert actual[0] == true_empi_dists[0] @pytest.mark.qiskit def test_generate_empi_dists_from_quara_dists():
63
64
161
19
44
tknrsgym/quara
tests/quara/interface/qiskit/test_api.py
Python
test_generate_empi_dists_from_quara_dists
test_generate_empi_dists_from_quara_dists
219
228
219
220
ffc55bf8160961cf16c5695dd43f37d9d2a77935
bigcode/the-stack
train
5bd0fe431c145294d2aa4abc
train
class
class UniqueBooleanField(BooleanField): def pre_save(self, model_instance, add): objects = model_instance.__class__.objects # If True then set all others as False if getattr(model_instance, self.attname): objects.update(**{self.attname: False}) return getattr(model_insta...
class UniqueBooleanField(BooleanField):
def pre_save(self, model_instance, add): objects = model_instance.__class__.objects # If True then set all others as False if getattr(model_instance, self.attname): objects.update(**{self.attname: False}) return getattr(model_instance, self.attname)
from django.db.models import BooleanField class UniqueBooleanField(BooleanField):
15
64
70
7
7
AxioDL/axiodl-www
axiodl/fields.py
Python
UniqueBooleanField
UniqueBooleanField
4
11
4
4
60df553408179358e92926c88b5571733b031487
bigcode/the-stack
train
6f0a3d611bc5f4ae505f7297
train
class
class User(Base): __tablename__ = "users" id = Column(Integer, primary_key=True) name = Column(String(256)) fullname = Column(String(256)) nickname = Column(String(256)) comments = Column(TEXT) age = Column(Integer)
class User(Base):
__tablename__ = "users" id = Column(Integer, primary_key=True) name = Column(String(256)) fullname = Column(String(256)) nickname = Column(String(256)) comments = Column(TEXT) age = Column(Integer)
MatchRegex import ( ColumnValuesToMatchRegex, ) from metadata.orm_profiler.validations.core import validate from metadata.utils.connections import create_and_bind_session EXECUTION_DATE = datetime.strptime("2021-07-03", "%Y-%m-%d") Base = declarative_base() class User(Base):
64
64
58
4
60
TeddyCr/OpenMetadata
ingestion/tests/unit/profiler/test_session_validations.py
Python
User
User
39
46
39
39
b28e1f160b9322941ce837d2d1186a392a0d07ff
bigcode/the-stack
train
90848c991622ef4d66ff8c0b
train
class
class MetricsTest(TestCase): """ Run checks on different metrics """ engine = create_engine("sqlite+pysqlite:///:memory:", echo=False, future=True) session = create_and_bind_session(engine) @classmethod def setUpClass(cls) -> None: """ Prepare Ingredients """ ...
class MetricsTest(TestCase):
""" Run checks on different metrics """ engine = create_engine("sqlite+pysqlite:///:memory:", echo=False, future=True) session = create_and_bind_session(engine) @classmethod def setUpClass(cls) -> None: """ Prepare Ingredients """ User.__table__.create(bind=...
limitations under the License. """ Test validations that need a session configured to run """ from datetime import datetime from unittest import TestCase from sqlalchemy import TEXT, Column, Integer, String, create_engine from sqlalchemy.orm import declarative_base from metadata.generated.schema.entity.data.table i...
256
256
1,407
6
250
TeddyCr/OpenMetadata
ingestion/tests/unit/profiler/test_session_validations.py
Python
MetricsTest
MetricsTest
49
263
49
49
adf3b3e3d898ca82937d83c648ea1ae746d7a687
bigcode/the-stack
train
417c168d0abc42f5a68dafaa
train
class
class BaseClient: def __init__(self, client_id: str, **kwargs): pipe = kwargs.get('pipe', 0) loop = kwargs.get('loop', None) handler = kwargs.get('handler', None) self.isasync = kwargs.get('isasync', False) client_id = str(client_id) if sys.platform == 'linux' or sy...
class BaseClient:
def __init__(self, client_id: str, **kwargs): pipe = kwargs.get('pipe', 0) loop = kwargs.get('loop', None) handler = kwargs.get('handler', None) self.isasync = kwargs.get('isasync', False) client_id = str(client_id) if sys.platform == 'linux' or sys.platform == 'darw...
import asyncio import inspect import json import os import struct import sys import tempfile from typing import Union from .exceptions import * from .response import Response from .payloads import Payload class BaseClient:
48
256
1,052
4
43
isugimpy/pypresence
pypresence/baseclient.py
Python
BaseClient
BaseClient
15
135
15
16
89d4b1a136aae6ebabd3b44115357be59d3cb47b
bigcode/the-stack
train
168726911d9cab2ac1118db6
train
class
class SLModelView(sqla.ModelView): column_default_sort = ("id", True) column_display_pk = True can_edit = False can_create = False can_delete = False edit_modal = True def is_accessible(self): return current_user.is_authenticated and current_user.is_admin def inaccessible_call...
class SLModelView(sqla.ModelView):
column_default_sort = ("id", True) column_display_pk = True can_edit = False can_create = False can_delete = False edit_modal = True def is_accessible(self): return current_user.is_authenticated and current_user.is_admin def inaccessible_callback(self, name, **kwargs): ...
url_for, request, flash from flask_admin import expose, AdminIndexView from flask_admin.actions import action from flask_admin.contrib import sqla from flask_login import current_user from app.extensions import db from app.models import User, ManualSubscription class SLModelView(sqla.ModelView):
64
64
106
10
53
s98soni/app
app/admin_model.py
Python
SLModelView
SLModelView
12
26
12
12
9431c222aed53a8dc6ecea46f1d7ad14d03cc571
bigcode/the-stack
train
69be609f9fa0d72f93ff2c65
train
class
class SLAdminIndexView(AdminIndexView): @expose("/") def index(self): if not current_user.is_authenticated or not current_user.is_admin: return redirect(url_for("auth.login", next=request.url)) return redirect("/admin/user")
class SLAdminIndexView(AdminIndexView): @expose("/")
def index(self): if not current_user.is_authenticated or not current_user.is_admin: return redirect(url_for("auth.login", next=request.url)) return redirect("/admin/user")
(self): return current_user.is_authenticated and current_user.is_admin def inaccessible_callback(self, name, **kwargs): # redirect to login page if user doesn't have access return redirect(url_for("auth.login", next=request.url)) class SLAdminIndexView(AdminIndexView): @expose("/")
64
64
53
14
50
s98soni/app
app/admin_model.py
Python
SLAdminIndexView
SLAdminIndexView
29
35
29
30
7389431342f5e48aaba6d4ea95670d6ee9b848e8
bigcode/the-stack
train
37ec10decca8b63daf329b75
train
class
class ManualSubscriptionAdmin(SLModelView): can_edit = True column_searchable_list = ["id", "user.email"] @action( "extend_1y", "Extend for 1 year", "Extend 1 year more?", ) def extend_1y(self, ids): for ms in ManualSubscription.query.filter(ManualSubscription.id.in_...
class ManualSubscriptionAdmin(SLModelView):
can_edit = True column_searchable_list = ["id", "user.email"] @action( "extend_1y", "Extend for 1 year", "Extend 1 year more?", ) def extend_1y(self, ids): for ms in ManualSubscription.query.filter(ManualSubscription.id.in_(ids)): ms.end_at = ms.end_at.sh...
email", "mailbox.email"] class MailboxAdmin(SLModelView): column_searchable_list = ["id", "user.email", "email"] class LifetimeCouponAdmin(SLModelView): can_edit = True can_create = True class ManualSubscriptionAdmin(SLModelView):
64
64
116
9
54
s98soni/app
app/admin_model.py
Python
ManualSubscriptionAdmin
ManualSubscriptionAdmin
156
170
156
156
7ecf063164a01a39d85f300633e1ded8649eac6a
bigcode/the-stack
train
d18acec13a583ad37e7261bd
train
class
class MailboxAdmin(SLModelView): column_searchable_list = ["id", "user.email", "email"]
class MailboxAdmin(SLModelView):
column_searchable_list = ["id", "user.email", "email"]
user.email", "mailbox.email", "contact.website_email"] can_edit = False can_create = False class AliasAdmin(SLModelView): column_searchable_list = ["id", "user.email", "email", "mailbox.email"] class MailboxAdmin(SLModelView):
63
64
25
9
54
s98soni/app
app/admin_model.py
Python
MailboxAdmin
MailboxAdmin
147
148
147
147
c7143630e9ced13eb7876dc981d45acecd999864
bigcode/the-stack
train
ff5b152abe9c253eac72dc06
train
function
def manual_upgrade(way: str, ids: [int], is_giveaway: bool): query = User.query.filter(User.id.in_(ids)) for user in query.all(): manual_sub: ManualSubscription = ManualSubscription.get_by(user_id=user.id) if manual_sub: # renew existing subscription if manual_sub.end_at...
def manual_upgrade(way: str, ids: [int], is_giveaway: bool):
query = User.query.filter(User.id.in_(ids)) for user in query.all(): manual_sub: ManualSubscription = ManualSubscription.get_by(user_id=user.id) if manual_sub: # renew existing subscription if manual_sub.end_at > arrow.now(): manual_sub.end_at = manual_su...
.trial_end.shift(weeks=1) else: user.trial_end = arrow.now().shift(weeks=1) flash(f"Extend trial for {user} to {user.trial_end}", "success") db.session.commit() def manual_upgrade(way: str, ids: [int], is_giveaway: bool):
72
72
242
20
52
s98soni/app
app/admin_model.py
Python
manual_upgrade
manual_upgrade
105
132
105
105
6f8050b88ccc4ed3a6da57c5d32c27e4baed2b3d
bigcode/the-stack
train
add493c0ceb6712501486082
train
class
class AliasAdmin(SLModelView): column_searchable_list = ["id", "user.email", "email", "mailbox.email"]
class AliasAdmin(SLModelView):
column_searchable_list = ["id", "user.email", "email", "mailbox.email"]
created", "success") class EmailLogAdmin(SLModelView): column_searchable_list = ["id"] column_filters = ["id", "user.email", "mailbox.email", "contact.website_email"] can_edit = False can_create = False class AliasAdmin(SLModelView):
64
64
29
8
55
s98soni/app
app/admin_model.py
Python
AliasAdmin
AliasAdmin
143
144
143
143
0cf97562448bd94994cc2311b3e53986e459c4ab
bigcode/the-stack
train
166b57cbf9926b22cb9cda39
train
class
class UserAdmin(SLModelView): column_searchable_list = ["email", "id"] column_exclude_list = [ "salt", "password", "otp_secret", "last_otp", "fido_uuid", "profile_picture", ] can_edit = True def scaffold_list_columns(self): ret = super().scaff...
class UserAdmin(SLModelView):
column_searchable_list = ["email", "id"] column_exclude_list = [ "salt", "password", "otp_secret", "last_otp", "fido_uuid", "profile_picture", ] can_edit = True def scaffold_list_columns(self): ret = super().scaffold_list_columns() ret...
_edit = False can_create = False can_delete = False edit_modal = True def is_accessible(self): return current_user.is_authenticated and current_user.is_admin def inaccessible_callback(self, name, **kwargs): # redirect to login page if user doesn't have access return redirec...
138
138
463
8
130
s98soni/app
app/admin_model.py
Python
UserAdmin
UserAdmin
38
102
38
38
4767568d9b4d03d027ba42d8c3286a06ca7cb529
bigcode/the-stack
train
cf20684770311bdd155f1a7e
train
class
class ClientAdmin(SLModelView): column_searchable_list = ["name", "description", "user.email"] column_exclude_list = ["oauth_client_secret", "home_url"] can_edit = True
class ClientAdmin(SLModelView):
column_searchable_list = ["name", "description", "user.email"] column_exclude_list = ["oauth_client_secret", "home_url"] can_edit = True
_1y(self, ids): for ms in ManualSubscription.query.filter(ManualSubscription.id.in_(ids)): ms.end_at = ms.end_at.shift(years=1) flash(f"Extend subscription for {ms.user}", "success") db.session.commit() class ClientAdmin(SLModelView):
64
64
45
8
56
s98soni/app
app/admin_model.py
Python
ClientAdmin
ClientAdmin
173
176
173
173
af0ece0f07ca7805afb34f7da7a1022fd6085f6b
bigcode/the-stack
train
ec860ba36c3211ef098a200c
train
class
class EmailLogAdmin(SLModelView): column_searchable_list = ["id"] column_filters = ["id", "user.email", "mailbox.email", "contact.website_email"] can_edit = False can_create = False
class EmailLogAdmin(SLModelView):
column_searchable_list = ["id"] column_filters = ["id", "user.email", "mailbox.email", "contact.website_email"] can_edit = False can_create = False
=arrow.now().shift(years=1, days=1), comment=way, is_giveaway=is_giveaway, commit=True, ) flash(f"New {way} manual subscription for {user} is created", "success") class EmailLogAdmin(SLModelView):
64
64
51
9
55
s98soni/app
app/admin_model.py
Python
EmailLogAdmin
EmailLogAdmin
135
140
135
135
3710b522d66123c899ad46be53bd1c5daaef7324
bigcode/the-stack
train
6b9a55070c621709b4c2cadd
train
class
class LifetimeCouponAdmin(SLModelView): can_edit = True can_create = True
class LifetimeCouponAdmin(SLModelView):
can_edit = True can_create = True
AliasAdmin(SLModelView): column_searchable_list = ["id", "user.email", "email", "mailbox.email"] class MailboxAdmin(SLModelView): column_searchable_list = ["id", "user.email", "email"] class LifetimeCouponAdmin(SLModelView):
63
64
21
9
54
s98soni/app
app/admin_model.py
Python
LifetimeCouponAdmin
LifetimeCouponAdmin
151
153
151
151
9a910406ebee84cb38750203b3f44cf2fd4543c9
bigcode/the-stack
train
e77f826a0920a7014c938a93
train
class
class Spotify: """Represents a Spotify listening activity from Discord. This is a special case of :class:`Activity` that makes it easier to work with the Spotify integration. .. container:: operations .. describe:: x == y Checks if two activities are equal. .. describe:: x !=...
class Spotify:
"""Represents a Spotify listening activity from Discord. This is a special case of :class:`Activity` that makes it easier to work with the Spotify integration. .. container:: operations .. describe:: x == y Checks if two activities are equal. .. describe:: x != y ...
]: If provided, the twitch name of the user streaming. This corresponds to the ``large_image`` key of the :attr:`Streaming.assets` dictionary if it starts with ``twitch:``. Typically set by the Discord client. """ try: name = self.assets['large_image'] except KeyErr...
256
256
1,333
3
253
DTS-11/VectorCord
discord/activity.py
Python
Spotify
Spotify
539
707
539
539
c7aa83062a102ddda3f34741f9c3a4d582181429
bigcode/the-stack
train
c967e5e10e7fc2177e377a4b
train
class
class CustomActivity(BaseActivity): """Represents a Custom activity from Discord. .. container:: operations .. describe:: x == y Checks if two activities are equal. .. describe:: x != y Checks if two activities are not equal. .. describe:: hash(x) ...
class CustomActivity(BaseActivity):
"""Represents a Custom activity from Discord. .. container:: operations .. describe:: x == y Checks if two activities are equal. .. describe:: x != y Checks if two activities are not equal. .. describe:: hash(x) Returns the activity's hash. ...
self.track_id}' @property def start(self) -> datetime.datetime: """:class:`datetime.datetime`: When the user started playing this song in UTC.""" return datetime.datetime.fromtimestamp(self._timestamps['start'] / 1000, tz=datetime.timezone.utc) @property def end(self) -> datetime.datet...
195
196
654
6
189
DTS-11/VectorCord
discord/activity.py
Python
CustomActivity
CustomActivity
710
805
710
710
232638ada7680a8b78e12ceb7c15d90842f6e306
bigcode/the-stack
train
4aafae8bedb40caf35315d99
train
function
@overload def create_activity(data: None) -> None: ...
@overload def create_activity(data: None) -> None:
...
={self.name!r} emoji={self.emoji!r}>' ActivityTypes = Union[Activity, Game, CustomActivity, Streaming, Spotify] @overload def create_activity(data: ActivityPayload) -> ActivityTypes: ... @overload def create_activity(data: None) -> None:
64
64
16
14
50
DTS-11/VectorCord
discord/activity.py
Python
create_activity
create_activity
814
816
814
815
c634cd02f125326c53e47c3cd1f79d390c6fbf99
bigcode/the-stack
train
9a2e58c0e20e9af69f7cd88a
train
class
class Activity(BaseActivity): """Represents an activity in Discord. This could be an activity such as streaming, playing, listening or watching. For memory optimisation purposes, some activities are offered in slimmed down versions: - :class:`Game` - :class:`Streaming` Attributes ...
class Activity(BaseActivity):
"""Represents an activity in Discord. This could be an activity such as streaming, playing, listening or watching. For memory optimisation purposes, some activities are offered in slimmed down versions: - :class:`Game` - :class:`Streaming` Attributes ------------ application_...
:meth:`Client.change_presence`. The following types currently count as user-settable: - :class:`Activity` - :class:`Game` - :class:`Streaming` - :class:`CustomActivity` Note that although these types are considered user-settable by the library, Discord typically ignores certain combinati...
256
256
1,523
5
250
DTS-11/VectorCord
discord/activity.py
Python
Activity
Activity
140
325
140
140
89c10a4149e646d6ed7213085cd461bd52547e0e
bigcode/the-stack
train
0781204feb84f82271244abc
train
function
def create_activity(data: Optional[ActivityPayload]) -> Optional[ActivityTypes]: if not data: return None game_type = try_enum(ActivityType, data.get('type', -1)) if game_type is ActivityType.playing: if 'application_id' in data or 'session_id' in data: return Activity(**data) ...
def create_activity(data: Optional[ActivityPayload]) -> Optional[ActivityTypes]:
if not data: return None game_type = try_enum(ActivityType, data.get('type', -1)) if game_type is ActivityType.playing: if 'application_id' in data or 'session_id' in data: return Activity(**data) return Game(**data) elif game_type is ActivityType.custom: try...
Types = Union[Activity, Game, CustomActivity, Streaming, Spotify] @overload def create_activity(data: ActivityPayload) -> ActivityTypes: ... @overload def create_activity(data: None) -> None: ... def create_activity(data: Optional[ActivityPayload]) -> Optional[ActivityTypes]:
65
65
219
16
49
DTS-11/VectorCord
discord/activity.py
Python
create_activity
create_activity
818
842
818
818
7ea846f671033891d1a7ed510c991ab85f8d9ee9
bigcode/the-stack
train
8314c9d3d2d3dd9add643a2d
train
function
@overload def create_activity(data: ActivityPayload) -> ActivityTypes: ...
@overload def create_activity(data: ActivityPayload) -> ActivityTypes:
...
def __repr__(self) -> str: return f'<CustomActivity name={self.name!r} emoji={self.emoji!r}>' ActivityTypes = Union[Activity, Game, CustomActivity, Streaming, Spotify] @overload def create_activity(data: ActivityPayload) -> ActivityTypes:
64
64
18
16
48
DTS-11/VectorCord
discord/activity.py
Python
create_activity
create_activity
810
812
810
811
d6009721486f6ea9c1cc0a7e1679861d2067e6b8
bigcode/the-stack
train
7415f21412ab517c94dbbe16
train
class
class Streaming(BaseActivity): """A slimmed down version of :class:`Activity` that represents a Discord streaming status. This is typically displayed via **Streaming** on the official Discord client. .. container:: operations .. describe:: x == y Checks if two streams are equal. ...
class Streaming(BaseActivity):
"""A slimmed down version of :class:`Activity` that represents a Discord streaming status. This is typically displayed via **Streaming** on the official Discord client. .. container:: operations .. describe:: x == y Checks if two streams are equal. .. describe:: x != y ...
(self._end / 1000, tz=datetime.timezone.utc) return None def __str__(self) -> str: return str(self.name) def __repr__(self) -> str: return f'<Game name={self.name!r}>' def to_dict(self) -> Dict[str, Any]: timestamps: Dict[str, Any] = {} if self._start: ...
224
224
749
5
219
DTS-11/VectorCord
discord/activity.py
Python
Streaming
Streaming
431
536
431
431
de05e707ee2e9a179af9a2c3767d5bf3eda6e49f
bigcode/the-stack
train
e9aa9a556a4d766a79ceecef
train
class
class Game(BaseActivity): """A slimmed down version of :class:`Activity` that represents a Discord game. This is typically displayed via **Playing** on the official Discord client. .. container:: operations .. describe:: x == y Checks if two games are equal. .. describe:: x ...
class Game(BaseActivity):
"""A slimmed down version of :class:`Activity` that represents a Discord game. This is typically displayed via **Playing** on the official Discord client. .. container:: operations .. describe:: x == y Checks if two games are equal. .. describe:: x != y Checks i...
property def small_image_url(self) -> Optional[str]: """Optional[:class:`str`]: Returns a URL pointing to the small image asset of this activity if applicable.""" if self.application_id is None: return None try: small_image = self.assets['small_image'] except...
194
194
647
5
189
DTS-11/VectorCord
discord/activity.py
Python
Game
Game
328
428
328
328
6aad55c58c44bd35bc9800c3c8f826496020d0ea
bigcode/the-stack
train