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
9601d8cf4798611b48192bde
train
class
class Sweep_wave_familiarity(Sweep_wave): """ This modulated version of the sweep wave is as per the Sweep wave but the reverse in direction of the sweep wave can be instigated based on the state of the visual processing function. Here torf is used to evaluate the view familiarity and the duration of th...
class Sweep_wave_familiarity(Sweep_wave):
""" This modulated version of the sweep wave is as per the Sweep wave but the reverse in direction of the sweep wave can be instigated based on the state of the visual processing function. Here torf is used to evaluate the view familiarity and the duration of the sweepback is calculated based on the loc...
2.0) self.preconditions_satisfied = True def set_new_heading_timer(self, duration): self.new_heading_timer = rospy.Timer(rospy.Duration(duration), self.new_heading_callback, oneshot=True) def new_heading_callback(self, event): """ callback from new heading timer creates and eve...
256
256
2,671
10
245
jannsta1/torf
src/flight_states.py
Python
Sweep_wave_familiarity
Sweep_wave_familiarity
110
364
110
110
c2307ec86cb854d9a07eaa5d432bb5cbd985359c
bigcode/the-stack
train
257aee170085ab817b8b061e
train
class
class MinimalPublisher(Node): def __init__(self): super().__init__('minimal_publisher') self.publisher_ = self.create_publisher(String, 'topic') timer_period = 0.5 # seconds self.timer = self.create_timer(timer_period, self.timer_callback) self.i = 0 def timer_callback...
class MinimalPublisher(Node):
def __init__(self): super().__init__('minimal_publisher') self.publisher_ = self.create_publisher(String, 'topic') timer_period = 0.5 # seconds self.timer = self.create_timer(timer_period, self.timer_callback) self.i = 0 def timer_callback(self): msg = String() ...
an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import rclpy from rclpy.node import Node from std_msgs.msg import String class MinimalPublisher(Node):
64
64
124
5
58
anasarrak/examples
rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py
Python
MinimalPublisher
MinimalPublisher
21
35
21
22
ed612fe2cbad1caf4f3847fcacdcd7d1b733eabb
bigcode/the-stack
train
50efe06a7c68503295527d6d
train
function
def main(args=None): rclpy.init(args=args) minimal_publisher = MinimalPublisher() rclpy.spin(minimal_publisher) # Destroy the node explicitly # (optional - otherwise it will be done automatically # when the garbage collector destroys the node object) minimal_publisher.destroy_node() r...
def main(args=None):
rclpy.init(args=args) minimal_publisher = MinimalPublisher() rclpy.spin(minimal_publisher) # Destroy the node explicitly # (optional - otherwise it will be done automatically # when the garbage collector destroys the node object) minimal_publisher.destroy_node() rclpy.shutdown()
0 def timer_callback(self): msg = String() msg.data = 'Hello World: %d' % self.i self.publisher_.publish(msg) self.get_logger().info('Publishing: "%s"' % msg.data) self.i += 1 def main(args=None):
64
64
74
5
58
anasarrak/examples
rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py
Python
main
main
38
49
38
38
8a234ebc84142dcba55f0dfe312cf0a1d06954ae
bigcode/the-stack
train
62923ca5a456afc6b1de6883
train
function
@asyncio.coroutine def func2(): while True: print("func2") yield from asyncio.sleep(1)
@asyncio.coroutine def func2():
while True: print("func2") yield from asyncio.sleep(1)
import asyncio @asyncio.coroutine def func1(): while True: print("func1") yield from asyncio.sleep(10) @asyncio.coroutine def func2():
41
64
28
10
31
taijiji/python-memo
async.py
Python
func2
func2
11
15
11
12
e73fa37068d74a583735775aa3546da1e71f4c4a
bigcode/the-stack
train
9b4c79044c2eb82d13a000b5
train
function
@asyncio.coroutine def func1(): while True: print("func1") yield from asyncio.sleep(10)
@asyncio.coroutine def func1():
while True: print("func1") yield from asyncio.sleep(10)
import asyncio @asyncio.coroutine def func1():
13
64
28
10
2
taijiji/python-memo
async.py
Python
func1
func1
4
8
4
5
930e7c45d3a9239a52bdf4d1f39786a9a68be925
bigcode/the-stack
train
3fbcfab78adc6c9446c9b529
train
class
class Migration(migrations.Migration): dependencies = [ ('nslc', '0009_auto_20210429_2335'), ] operations = [ migrations.AlterField( model_name='channel', name='name', field=models.CharField(blank=True, max_length=255), ), ]
class Migration(migrations.Migration):
dependencies = [ ('nslc', '0009_auto_20210429_2335'), ] operations = [ migrations.AlterField( model_name='channel', name='name', field=models.CharField(blank=True, max_length=255), ), ]
# Generated by Django 3.1.13 on 2022-05-25 17:29 from django.db import migrations, models class Migration(migrations.Migration):
38
64
68
7
30
pnsn/squac_api
app/nslc/migrations/0010_auto_20220525_1729.py
Python
Migration
Migration
6
18
6
7
8c3e579744588144de923a7ac8ddc9456fe322ee
bigcode/the-stack
train
798a893fc2854be58fdd6c3d
train
class
class CtcDecoder(object): """ CTC decoder (to decode a sequence of labels to words). Parameters: ---------- vocabulary : list of str Vocabulary of the dataset. """ def __init__(self, vocabulary): super().__init__() self.blank_id = len(vocabulary) ...
class CtcDecoder(object):
""" CTC decoder (to decode a sequence of labels to words). Parameters: ---------- vocabulary : list of str Vocabulary of the dataset. """ def __init__(self, vocabulary): super().__init__() self.blank_id = len(vocabulary) self.labels_map = dic...
_pl', 'oth_quartznet15x5_ru', 'oth_jasperdr10x5_en', 'oth_jasperdr10x5_en_nr', 'oth_quartznet15x5_ru34'] import torch.nn as nn # import torch.nn.functional as F # import editdistance class CtcDecoder(object):
70
70
235
6
63
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
CtcDecoder
CtcDecoder
12
52
12
12
796b05a3acbba6e84d6a0d75a1632321063a9da5
bigcode/the-stack
train
4eaa1d43510d7443049a917e
train
function
def oth_quartznet15x5_de(pretrained=False, num_classes=32, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_de_quartznet15x5_6ae5d87d.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_...
def oth_quartznet15x5_de(pretrained=False, num_classes=32, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_de_quartznet15x5_6ae5d87d.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_de(pretrained=False, num_classes=32, **kwargs):
64
64
112
21
42
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_de
oth_quartznet15x5_de
163
169
163
163
d6226a7a7fa71dd78298e05aab87cfcb6bc03422
bigcode/the-stack
train
2f82de63696dafb64feab524
train
function
def oth_quartznet15x5_es(pretrained=False, num_classes=36, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_es_quartznet15x5_f2083912.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_...
def oth_quartznet15x5_es(pretrained=False, num_classes=36, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_es_quartznet15x5_f2083912.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_es(pretrained=False, num_classes=36, **kwargs):
64
64
109
21
42
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_es
oth_quartznet15x5_es
181
187
181
181
65e2578660f9a9c590442f07c7ad4634dfe942f8
bigcode/the-stack
train
158ca0830a1f62752c469e91
train
function
def _test(): import numpy as np import torch pretrained = True audio_features = 64 models = [ # oth_quartznet5x5_en_ls, # oth_quartznet15x5_en, # oth_quartznet15x5_en_nr, # oth_quartznet15x5_fr, # oth_quartznet15x5_de, # oth_quartznet15x5_it, ...
def _test():
import numpy as np import torch pretrained = True audio_features = 64 models = [ # oth_quartznet5x5_en_ls, # oth_quartznet15x5_en, # oth_quartznet15x5_en_nr, # oth_quartznet15x5_fr, # oth_quartznet15x5_de, # oth_quartznet15x5_it, # oth_quartz...
artznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_ru34(pretrained=False, num_classes=34, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "QuartzNet15x5_golos_1a...
206
206
688
4
201
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
_test
_test
253
311
253
253
567b403108733b6e80c8f9f63093ea6e5b23c31e
bigcode/the-stack
train
61abd654e10933864e1bc309
train
function
def oth_quartznet15x5_ru34(pretrained=False, num_classes=34, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "QuartzNet15x5_golos_1a63a2d8.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num...
def oth_quartznet15x5_ru34(pretrained=False, num_classes=34, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "QuartzNet15x5_golos_1a63a2d8.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
DecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_ru34(pretrained=False, num_classes=34, **kwargs):
64
64
112
22
41
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_ru34
oth_quartznet15x5_ru34
235
241
235
235
013b2b7d59d37ac9cc3644aac08d52aec2d95e4b
bigcode/the-stack
train
2c0c28a4e93fe019bb672243
train
function
def oth_quartznet15x5_fr(pretrained=False, num_classes=43, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_fr_quartznet15x5_a3fdb084.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_...
def oth_quartznet15x5_fr(pretrained=False, num_classes=43, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_fr_quartznet15x5_a3fdb084.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_fr(pretrained=False, num_classes=43, **kwargs):
64
64
110
21
42
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_fr
oth_quartznet15x5_fr
154
160
154
154
b61bec8c05cb3053a8cb78ff0231a5777baab391
bigcode/the-stack
train
88c84df99c5017505f62fa1f
train
function
def oth_quartznet15x5_en(pretrained=False, num_classes=29, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "QuartzNet15x5Base-En_3dbcc2ff.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_...
def oth_quartznet15x5_en(pretrained=False, num_classes=29, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "QuartzNet15x5Base-En_3dbcc2ff.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_en(pretrained=False, num_classes=29, **kwargs):
64
64
109
21
42
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_en
oth_quartznet15x5_en
136
142
136
136
5fc9aae20ada579b4d3ae66c764448b34f630fc2
bigcode/the-stack
train
0fd500e93a5a60247ce27ebe
train
function
def oth_jasperdr10x5_en(pretrained=False, num_classes=29, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "Jasper10x5Dr-En_2b94c9d1.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classe...
def oth_jasperdr10x5_en(pretrained=False, num_classes=29, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "Jasper10x5Dr-En_2b94c9d1.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_jasperdr10x5_en(pretrained=False, num_classes=29, **kwargs):
64
64
111
21
42
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_jasperdr10x5_en
oth_jasperdr10x5_en
217
223
217
217
8340d5090e4815d5645a4a7d19edaddc5ae5bd43
bigcode/the-stack
train
4e0c006a9c800174173b5f90
train
function
def oth_quartznet15x5_it(pretrained=False, num_classes=39, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_it_quartznet15x5_0f6e4537.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_...
def oth_quartznet15x5_it(pretrained=False, num_classes=39, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_it_quartznet15x5_0f6e4537.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_it(pretrained=False, num_classes=39, **kwargs):
64
64
112
21
42
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_it
oth_quartznet15x5_it
172
178
172
172
3532e90292cefa3786d50d03b7590812b753ec03
bigcode/the-stack
train
1b184ab9d3228b62bf0b1a54
train
function
def oth_quartznet15x5_en_nr(pretrained=False, num_classes=29, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "QuartzNet15x5NR-En_b05e34f3.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num...
def oth_quartznet15x5_en_nr(pretrained=False, num_classes=29, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "QuartzNet15x5NR-En_b05e34f3.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
DecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_en_nr(pretrained=False, num_classes=29, **kwargs):
64
64
110
22
41
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_en_nr
oth_quartznet15x5_en_nr
145
151
145
145
2eee49d83ccf8d98307afa0095d1142471663035
bigcode/the-stack
train
399399a0d6e6e37d1fd9eef5
train
function
def oth_jasperdr10x5_en_nr(pretrained=False, num_classes=29, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_en_jasper10x5dr_0d5ebc6c.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num...
def oth_jasperdr10x5_en_nr(pretrained=False, num_classes=29, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_en_jasper10x5dr_0d5ebc6c.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
DecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_jasperdr10x5_en_nr(pretrained=False, num_classes=29, **kwargs):
64
64
114
22
41
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_jasperdr10x5_en_nr
oth_jasperdr10x5_en_nr
226
232
226
226
b3dc18e8833816eaf7b9e0407fa697bb0b0ece6a
bigcode/the-stack
train
9fbd2ae5d101f51e2e5ce8d8
train
function
def _calc_width(net): import numpy as np net_params = filter(lambda p: p.requires_grad, net.parameters()) weight_count = 0 for param in net_params: weight_count += np.prod(param.size()) return weight_count
def _calc_width(net):
import numpy as np net_params = filter(lambda p: p.requires_grad, net.parameters()) weight_count = 0 for param in net_params: weight_count += np.prod(param.size()) return weight_count
_1a63a2d8.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def _calc_width(net):
64
64
55
6
57
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
_calc_width
_calc_width
244
250
244
244
00211311e5dd960feef4da7007dfac59f049e45d
bigcode/the-stack
train
49eccb0f7750c9a4354c4768
train
function
def oth_quartznet15x5_ru(pretrained=False, num_classes=35, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_ru_quartznet15x5_88a3e5aa.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_...
def oth_quartznet15x5_ru(pretrained=False, num_classes=35, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_ru_quartznet15x5_88a3e5aa.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_ru(pretrained=False, num_classes=35, **kwargs):
64
64
112
21
42
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_ru
oth_quartznet15x5_ru
208
214
208
208
e428656dd1425086807a8180c03b44ca4f7f65d9
bigcode/the-stack
train
7d2cdbe2b4b74c3f5ed4d107
train
function
def oth_quartznet15x5_pl(pretrained=False, num_classes=34, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_pl_quartznet15x5_9dd685f7.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_...
def oth_quartznet15x5_pl(pretrained=False, num_classes=34, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_pl_quartznet15x5_9dd685f7.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_pl(pretrained=False, num_classes=34, **kwargs):
64
64
111
21
42
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_pl
oth_quartznet15x5_pl
199
205
199
199
8da1813a9164f22bf4f9685bb36d4708ae3a10cb
bigcode/the-stack
train
5ec7846e359b97529f5e6b29
train
function
def oth_quartznet15x5_ca(pretrained=False, num_classes=39, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_ca_quartznet15x5_b1a4fa3c.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_...
def oth_quartznet15x5_ca(pretrained=False, num_classes=39, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "stt_ca_quartznet15x5_b1a4fa3c.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net def oth_quartznet15x5_ca(pretrained=False, num_classes=39, **kwargs):
64
64
112
21
42
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet15x5_ca
oth_quartznet15x5_ca
190
196
190
190
b1f26819bf4876404c11f9e506f195c5c27d54f6
bigcode/the-stack
train
9e6d255f99ded3ce0810133f
train
class
class QuartzNet(nn.Module): def __init__(self, raw_net, num_classes): super(QuartzNet, self).__init__() self.in_size = None self.num_classes = num_classes self.preprocessor = raw_net.preprocessor self.encoder = raw_net.encoder self.d...
class QuartzNet(nn.Module):
def __init__(self, raw_net, num_classes): super(QuartzNet, self).__init__() self.in_size = None self.num_classes = num_classes self.preprocessor = raw_net.preprocessor self.encoder = raw_net.encoder self.decoder = raw_net.decoder ...
.split() # words += len(r_list) # scores += editdistance.eval(h_list, r_list) # # self.scores += scores # self.words += words # # def compute(self): # return float(self.scores) / self.words class QuartzNet(nn.Module):
64
64
197
6
57
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
QuartzNet
QuartzNet
92
120
92
92
24d809aa80034ae9650b19e039eb4281e65ef8e4
bigcode/the-stack
train
b6d7bd5852b7bab108dbe434
train
function
def oth_quartznet5x5_en_ls(pretrained=False, num_classes=29, **kwargs): from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "QuartzNet5x5LS-En_08ecf82a.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_c...
def oth_quartznet5x5_en_ls(pretrained=False, num_classes=29, **kwargs):
from nemo.collections.asr.models import EncDecCTCModel quartznet_nemo_path = path_pref + "QuartzNet5x5LS-En_08ecf82a.nemo" raw_net = EncDecCTCModel.restore_from(quartznet_nemo_path) net = QuartzNet(raw_net=raw_net, num_classes=num_classes) net = net.cpu() return net#, raw_net
lens) x = self.decoder(x) return x, lens # path_pref = "../../../../../imgclsmob_data/nemo/" path_pref = "../imgclsmob_data/nemo/" def oth_quartznet5x5_en_ls(pretrained=False, num_classes=29, **kwargs):
63
64
110
22
41
naviocean/imgclsmob
pytorch/pytorchcv/models/others/oth_quartznet.py
Python
oth_quartznet5x5_en_ls
oth_quartznet5x5_en_ls
127
133
127
127
9445bdc99077ff398296f4a8f854d1bf2cc612df
bigcode/the-stack
train
eb4c2ad47153725290e74fe0
train
function
def sorted_values(dictionary): algo = list(dictionary.values()) algo.sort() return algo
def sorted_values(dictionary):
algo = list(dictionary.values()) algo.sort() return algo
#Write a function that accepts a dictionary as input and returns a sorted list of all the values in the dictionary. #Assume that the values of this dictionary are just integers. dictionary = {"juan": 3, "pedro": 1, "carlos": 2} def sorted_values(dictionary):
64
64
19
5
59
chars32/edx_python
Weeks/Week7/Dictionaries/Excercise2.py
Python
sorted_values
sorted_values
6
12
6
7
46cdde4205213947dc9f1b794b38378bbbb3f751
bigcode/the-stack
train
7a7e24da3bd7c664f13348c7
train
function
def get_version(): sys.path.insert(0, ".") vers = importlib.import_module('version') return vers.VERSION
def get_version():
sys.path.insert(0, ".") vers = importlib.import_module('version') return vers.VERSION
_NAME) base_formatter = logging.Formatter( "%(asctime)s %(name)s:%(levelname)s %(message)s") hdlr.setFormatter(base_formatter) logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) def pick_grp(name): return name.split('-')[1] def get_version():
64
64
28
4
60
auth0/oidctest
test_tool/cp/test_op/op_test_tool.py
Python
get_version
get_version
49
52
49
49
a8430ad1775d7612d96239f9aeb6df286df64155
bigcode/the-stack
train
465cfb7153cd9aa14f281b77
train
function
def pick_grp(name): return name.split('-')[1]
def pick_grp(name):
return name.split('-')[1]
op_test.log' hdlr = logging.FileHandler(LOGFILE_NAME) base_formatter = logging.Formatter( "%(asctime)s %(name)s:%(levelname)s %(message)s") hdlr.setFormatter(base_formatter) logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) def pick_grp(name):
64
64
13
5
59
auth0/oidctest
test_tool/cp/test_op/op_test_tool.py
Python
pick_grp
pick_grp
45
46
45
45
7a388252368f933c5cb65f29358d0a90be31305b
bigcode/the-stack
train
645d2979623b454eb7bbacd0
train
function
def make_webenv(config, rest): if args.tag: qtag = quote_plus(args.tag) else: qtag = 'default' ent_conf = None try: ent_conf = rest.construct_config(quote_plus(args.issuer), qtag) except Exception as err: print('iss:{}, tag:{}'.format(quote_plus(args.issuer), qtag)) ...
def make_webenv(config, rest):
if args.tag: qtag = quote_plus(args.tag) else: qtag = 'default' ent_conf = None try: ent_conf = rest.construct_config(quote_plus(args.issuer), qtag) except Exception as err: print('iss:{}, tag:{}'.format(quote_plus(args.issuer), qtag)) for m in traceback.form...
Formatter(base_formatter) logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) def pick_grp(name): return name.split('-')[1] def get_version(): sys.path.insert(0, ".") vers = importlib.import_module('version') return vers.VERSION def make_webenv(config, rest):
67
67
226
9
57
auth0/oidctest
test_tool/cp/test_op/op_test_tool.py
Python
make_webenv
make_webenv
55
85
55
55
904c19372b66e6015e73ba37a29ac88b4e73f988
bigcode/the-stack
train
5625115607169a6462229799
train
function
def inc_dict(key): global dict_data try: dict_data[key] = dict_data[key]+1 except KeyError: dict_data[key] = 1
def inc_dict(key):
global dict_data try: dict_data[key] = dict_data[key]+1 except KeyError: dict_data[key] = 1
glob import numpy as np # lists for values repository = "dbGAP" xmlpath = "./data/" # functions def parse(xmlpath): phs = ET.parse(xmlpath) root = phs.getroot() return(root) dict_data = dict() def inc_dict(key):
64
64
39
5
59
social-link-analytics-group-bsc/biohackathon-project-35
dbpgap/archived/explore_keys.py
Python
inc_dict
inc_dict
26
31
26
26
cd4cd9b97220d4b419a1b0d744de2ff1c1f990d3
bigcode/the-stack
train
51efa0ed334e43412b1e946c
train
function
def parse(xmlpath): phs = ET.parse(xmlpath) root = phs.getroot() return(root)
def parse(xmlpath):
phs = ET.parse(xmlpath) root = phs.getroot() return(root)
xml.etree.ElementTree as ET from xml.etree.ElementTree import ParseError import pandas as pd import xml.etree as etree import glob import numpy as np # lists for values repository = "dbGAP" xmlpath = "./data/" # functions def parse(xmlpath):
64
64
26
5
58
social-link-analytics-group-bsc/biohackathon-project-35
dbpgap/archived/explore_keys.py
Python
parse
parse
18
21
18
18
903ffd7cadd8b312b9325da22f93f7badb44c64a
bigcode/the-stack
train
d963f5a06d6b344409f3e7b2
train
class
class InvalidMarkerError(Exception): """Error raised with marker is invalid""" pass
class InvalidMarkerError(Exception):
"""Error raised with marker is invalid""" pass
", "centos8", "awsbatch"), ("*", "*", "ubuntu1804", "awsbatch"), ("*", "*", "ubuntu1604", "awsbatch"), ("us-gov-east-1", "*", "c4.xlarge", "*"), ] class InvalidMarkerError(Exception):
64
64
18
6
58
Takuya-Miyazaki/aws-parallelcluster
tests/integration-tests/conftest_markers.py
Python
InvalidMarkerError
InvalidMarkerError
29
32
29
29
912ec3c5451d998161f962c7421ff66fa5080f28
bigcode/the-stack
train
bcc97a87d635747c15615862
train
function
def _validate_marker(marker_name, expected_args, args_count): if args_count != len(expected_args): logging.error( "Marker {marker_name} requires the following args: {args}".format( marker_name=marker_name, args=expected_args ) ) raise InvalidMarkerErro...
def _validate_marker(marker_name, expected_args, args_count):
if args_count != len(expected_args): logging.error( "Marker {marker_name} requires the following args: {args}".format( marker_name=marker_name, args=expected_args ) ) raise InvalidMarkerError
" values: {allowed_values}".format( test_name=item.name, test_args_value=test_args_value, marker=marker_name, allowed_values=allowed_values, ) ) logging.debug(skip_message) items.remove(i...
64
64
65
13
51
Takuya-Miyazaki/aws-parallelcluster
tests/integration-tests/conftest_markers.py
Python
_validate_marker
_validate_marker
234
241
234
234
b1b5868065840f1573679b8120eeaf18709e7971
bigcode/the-stack
train
24bbdb1a933757a61a43056f
train
function
def check_marker_dimensions(items): """ Execute all tests that are annotated with @pytest.mark.dimensions and have the args (region, instance, os, scheduler) match those specified in the marker. "*" can be used to identify all values for a specific argument. Example: @pytest.mark.dimension...
def check_marker_dimensions(items):
""" Execute all tests that are annotated with @pytest.mark.dimensions and have the args (region, instance, os, scheduler) match those specified in the marker. "*" can be used to identify all values for a specific argument. Example: @pytest.mark.dimensions("a", "b", "*", "d") def te...
raise ValueError dimensions_match = _compare_dimension_lists(args_values, marker.args) if dimensions_match: skip_message = ( "Skipping test {test_name} because dimensions {args_values} match {marker}: " "{skip_values}".format( ...
100
100
336
6
93
Takuya-Miyazaki/aws-parallelcluster
tests/integration-tests/conftest_markers.py
Python
check_marker_dimensions
check_marker_dimensions
191
231
191
191
c473283348457cccd0e9a9fac673ba4f9f255144
bigcode/the-stack
train
8304446074306716e4ccbcce
train
function
def _compare_dimension_lists(list1, list2): if len(list1) != len(list2): return False for d1, d2 in zip(list1, list2): if d1 != "*" and d2 != "*" and d1 != d2: return False return True
def _compare_dimension_lists(list1, list2):
if len(list1) != len(list2): return False for d1, d2 in zip(list1, list2): if d1 != "*" and d2 != "*" and d1 != d2: return False return True
): if args_count != len(expected_args): logging.error( "Marker {marker_name} requires the following args: {args}".format( marker_name=marker_name, args=expected_args ) ) raise InvalidMarkerError def _compare_dimension_lists(list1, list2):
64
64
67
11
52
Takuya-Miyazaki/aws-parallelcluster
tests/integration-tests/conftest_markers.py
Python
_compare_dimension_lists
_compare_dimension_lists
244
250
244
244
49a3a50c8e3e3c46c4580b7740de2e71e61ef4f6
bigcode/the-stack
train
474dd3a5ab67bef9273f63c5
train
function
def check_marker_list(items, marker_name, arg_name): """ Skip all tests that are annotated with marker marker_name and have the arg value corresponding to arg_name not listed in the list passed as first argument to the marker. Example: @pytest.mark.marker_name(["value1", "value2"]) def ...
def check_marker_list(items, marker_name, arg_name):
""" Skip all tests that are annotated with marker marker_name and have the arg value corresponding to arg_name not listed in the list passed as first argument to the marker. Example: @pytest.mark.marker_name(["value1", "value2"]) def test(arg_name) The test is executed only if ...
def add_default_markers(items): """ Add default markers for dimensions that need to be skipped by default for all tests. :param items: pytest Item object markers are applied to. """ _add_unsupported_arm_dimensions() for item in items: for dimensions in UNSUPPORTED_DIMENSIONS: ...
90
90
302
12
78
Takuya-Miyazaki/aws-parallelcluster
tests/integration-tests/conftest_markers.py
Python
check_marker_list
check_marker_list
75
110
75
75
f52ca427c7dcdba931e19228ccbea1f7f41ba50b
bigcode/the-stack
train
225ca348a310b9b3faa0ee60
train
function
def add_default_markers(items): """ Add default markers for dimensions that need to be skipped by default for all tests. :param items: pytest Item object markers are applied to. """ _add_unsupported_arm_dimensions() for item in items: for dimensions in UNSUPPORTED_DIMENSIONS: ...
def add_default_markers(items):
""" Add default markers for dimensions that need to be skipped by default for all tests. :param items: pytest Item object markers are applied to. """ _add_unsupported_arm_dimensions() for item in items: for dimensions in UNSUPPORTED_DIMENSIONS: item.add_marker(pytest.mark.sk...
_os in oses_unsupported_by_arm: UNSUPPORTED_DIMENSIONS.append(("*", instance_type, unsupported_os, "*")) for unsupported_region in regions_unsupported_by_arm: UNSUPPORTED_DIMENSIONS.append((unsupported_region, instance_type, "*", "*")) def add_default_markers(items):
63
64
77
7
56
Takuya-Miyazaki/aws-parallelcluster
tests/integration-tests/conftest_markers.py
Python
add_default_markers
add_default_markers
63
72
63
63
2c88f884c5326bdc4d03e23021e8640db9c8e7f2
bigcode/the-stack
train
90519d8aaff485803623a863
train
function
def _add_unsupported_arm_dimensions(): """Add invalid dimensions due to lack of ARM instance types in some regions and ARM AMIs for certain OSes.""" arm_instance_types = ["m6g.xlarge"] oses_unsupported_by_arm = ["centos7", "alinux", "ubuntu1604"] regions_unsupported_by_arm = [ "us-west-1", ...
def _add_unsupported_arm_dimensions():
"""Add invalid dimensions due to lack of ARM instance types in some regions and ARM AMIs for certain OSes.""" arm_instance_types = ["m6g.xlarge"] oses_unsupported_by_arm = ["centos7", "alinux", "ubuntu1604"] regions_unsupported_by_arm = [ "us-west-1", "ca-central-1", "eu-west-2",...
", "awsbatch"), ("*", "*", "ubuntu1804", "awsbatch"), ("*", "*", "ubuntu1604", "awsbatch"), ("us-gov-east-1", "*", "c4.xlarge", "*"), ] class InvalidMarkerError(Exception): """Error raised with marker is invalid""" pass def _add_unsupported_arm_dimensions():
79
79
264
8
70
Takuya-Miyazaki/aws-parallelcluster
tests/integration-tests/conftest_markers.py
Python
_add_unsupported_arm_dimensions
_add_unsupported_arm_dimensions
35
60
35
35
5bff2ac71e72e893cb6d02934eb4a2e85112413e
bigcode/the-stack
train
041f3afb37de347a5d68ceb4
train
function
def check_marker_skip_list(items, marker_name, arg_name): """ Skip all tests that are annotated with marker marker_name and have the arg value corresponding to arg_name listed in the list passed as first argument to the marker. Example: @pytest.mark.marker_name(["value1", "value2"]) def...
def check_marker_skip_list(items, marker_name, arg_name):
""" Skip all tests that are annotated with marker marker_name and have the arg value corresponding to arg_name listed in the list passed as first argument to the marker. Example: @pytest.mark.marker_name(["value1", "value2"]) def test(arg_name) The test is executed only if arg_...
because {arg_name} {arg_value} is not in {marker} allowed values: " "{allowed_values}".format( test_name=item.name, arg_name=arg_name, arg_value=arg_value, marker=marker_name, allowed_values=allowed_values, ) ...
87
87
290
13
74
Takuya-Miyazaki/aws-parallelcluster
tests/integration-tests/conftest_markers.py
Python
check_marker_skip_list
check_marker_skip_list
113
145
113
113
39334b8178c616d7ef5c178f16ce4f420c805634
bigcode/the-stack
train
0880fbf28eebb7bc61113a86
train
function
def check_marker_skip_dimensions(items): """ Skip all tests that are annotated with @pytest.mark.skip_dimensions and have the args (region, instance, os, scheduler) match those specified in the marker. "*" can be used to identify all values for a specific argument. Example: @pytest.mark.sk...
def check_marker_skip_dimensions(items):
""" Skip all tests that are annotated with @pytest.mark.skip_dimensions and have the args (region, instance, os, scheduler) match those specified in the marker. "*" can be used to identify all values for a specific argument. Example: @pytest.mark.skip_dimensions("a", "b", "*", "d") ...
skip_values = marker.args[0] if arg_value in skip_values: skip_message = ( "Skipping test {test_name} because {arg_name} {arg_value} is in {marker} allowed values:" "{skip_values}".format( test_name=item.name, ...
108
108
360
7
101
Takuya-Miyazaki/aws-parallelcluster
tests/integration-tests/conftest_markers.py
Python
check_marker_skip_dimensions
check_marker_skip_dimensions
148
188
148
148
a6cb5b21826714dcea402f4888d9491d4f41b05a
bigcode/the-stack
train
62dd1f6c8023ac09e13ee2cd
train
class
class Server: """Server class for auto-complete system This class defines application server for performing auto-complete functionality. The main API search(str) searches a term in server and returns top results to the user. New servers can be established from Neo4j database which stores search history...
class Server:
"""Server class for auto-complete system This class defines application server for performing auto-complete functionality. The main API search(str) searches a term in server and returns top results to the user. New servers can be established from Neo4j database which stores search history. Attribu...
""" Main module for auto-complete server """ from collections import deque, Counter import logging import logging.config import yaml import csv from typing import List # from nltk.corpus import words as en_corpus from py2neo import Node from src.Trienode import TrieNode from src.Spell import Spell from . import D...
108
256
3,647
3
105
weihesdlegend/Auto_complete_system
src/Server.py
Python
Server
Server
24
521
24
24
b977e8e03aff34c709db2c18519c9b96532ee59c
bigcode/the-stack
train
24198c2ef9588a99b49d1a04
train
function
def is_fare_code_valid(fare_code): return fare_code in AVAILABLE_FARE_CODES
def is_fare_code_valid(fare_code):
return fare_code in AVAILABLE_FARE_CODES
doubles for group_code, group_name in FARE_CODE_GROUPS._doubles } fare_codes[SOCIAL_EVENT_FARE_CODE] = "Social Event" return fare_codes AVAILABLE_FARE_CODES = available_fare_codes() def is_fare_code_valid(fare_code):
64
64
20
10
54
judy2k/epcon
conference/fares.py
Python
is_fare_code_valid
is_fare_code_valid
69
70
69
69
7ddcc4449944d3cafaae7668c44ad1d855c91559
bigcode/the-stack
train
6c6b2d24b27aeba51015a403
train
function
def create_fare_for_conference(code, conference, price, start_validity, end_validity, vat_rate): assert is_fare_code_valid(code) assert isinstance(conference, str), "conference should be a string" assert isinstance(vat_rate, Vat) assert star...
def create_fare_for_conference(code, conference, price, start_validity, end_validity, vat_rate):
assert is_fare_code_valid(code) assert isinstance(conference, str), "conference should be a string" assert isinstance(vat_rate, Vat) assert start_validity <= end_validity if code == SOCIAL_EVENT_FARE_CODE: ticket_type = FARE_TICKET_TYPES.event else: ticket_type = FARE_TICKET_TYP...
in FARE_CODE_GROUPS._doubles } fare_codes[SOCIAL_EVENT_FARE_CODE] = "Social Event" return fare_codes AVAILABLE_FARE_CODES = available_fare_codes() def is_fare_code_valid(fare_code): return fare_code in AVAILABLE_FARE_CODES def create_fare_for_conference(code, conference, price, ...
89
89
297
26
62
judy2k/epcon
conference/fares.py
Python
create_fare_for_conference
create_fare_for_conference
73
112
73
76
eef1cea8bd7067cd15d0f9ca63f11f35c4d36139
bigcode/the-stack
train
c7cdcf9ab58dd50f069eb3a1
train
function
def available_fare_codes(): fare_codes = { "T" + type_code + variant_code + group_code: "%s %s %s" % (type_name, variant_name, group_name) for type_code, type_name in FARE_CODE_TYPES._doubles for variant_code, variant_name in FARE_CODE_VARIANTS._doubles for group_code,...
def available_fare_codes():
fare_codes = { "T" + type_code + variant_code + group_code: "%s %s %s" % (type_name, variant_name, group_name) for type_code, type_name in FARE_CODE_TYPES._doubles for variant_code, variant_name in FARE_CODE_VARIANTS._doubles for group_code, group_name in FARE_CODE...
"groups": { FARE_CODE_GROUPS.STUDENT: "^T..S$", FARE_CODE_GROUPS.PERSONAL: "^T..P$", FARE_CODE_GROUPS.COMPANY: "^T..C$", } } def available_fare_codes():
64
64
119
6
58
judy2k/epcon
conference/fares.py
Python
available_fare_codes
available_fare_codes
52
63
52
52
38f11e06a8d6e6d36cffcc6c605042c7c8f6d85f
bigcode/the-stack
train
01c08fa3f430b948c934c097
train
function
def set_regular_fare_dates(conference, start_date, end_date): fares = Fare.objects.filter( conference=conference, code__regex=FARE_CODE_REGEXES['types'][FARE_CODE_TYPES.REGULAR] ) assert fares.count() == 9 # 3**2 fares.update(start_validity=start_date, end_validity=end_date)
def set_regular_fare_dates(conference, start_date, end_date):
fares = Fare.objects.filter( conference=conference, code__regex=FARE_CODE_REGEXES['types'][FARE_CODE_TYPES.REGULAR] ) assert fares.count() == 9 # 3**2 fares.update(start_validity=start_date, end_validity=end_date)
['types'][FARE_CODE_TYPES.EARLY_BIRD] ) assert early_birds.count() == 9 # 3**2 early_birds.update(start_validity=start_date, end_validity=end_date) def set_regular_fare_dates(conference, start_date, end_date):
64
64
79
15
49
judy2k/epcon
conference/fares.py
Python
set_regular_fare_dates
set_regular_fare_dates
143
149
143
143
9f16e57eaeed8fd520d3d8bcd3cd149ad3376f6d
bigcode/the-stack
train
1552e119439f4361a1b2fad5
train
function
def set_early_bird_fare_dates(conference, start_date, end_date): early_birds = Fare.objects.filter( conference=conference, code__regex=FARE_CODE_REGEXES['types'][FARE_CODE_TYPES.EARLY_BIRD] ) assert early_birds.count() == 9 # 3**2 early_birds.update(start_validity=start_date, end_validi...
def set_early_bird_fare_dates(conference, start_date, end_date):
early_birds = Fare.objects.filter( conference=conference, code__regex=FARE_CODE_REGEXES['types'][FARE_CODE_TYPES.EARLY_BIRD] ) assert early_birds.count() == 9 # 3**2 early_birds.update(start_validity=start_date, end_validity=end_date)
start_validity=None, end_validity=None, vat_rate=vat_rate, ) if print_output: print("Created fare %s" % fare) fares.append(fare) return fares def set_early_bird_fare_dates(conference, start_date, end_date):
64
64
91
18
45
judy2k/epcon
conference/fares.py
Python
set_early_bird_fare_dates
set_early_bird_fare_dates
134
140
134
134
3c68d732c58db6a78ae04b99968840b23e796b83
bigcode/the-stack
train
b43951fdca4ea38723c8823a
train
function
def pre_create_typical_fares_for_conference(conference, vat_rate, print_output=False): fares = [] for fare_code in AVAILABLE_FARE_CODES.keys(): fare = create_fare_for_conference( code=fare_code, conference=conference, price...
def pre_create_typical_fares_for_conference(conference, vat_rate, print_output=False):
fares = [] for fare_code in AVAILABLE_FARE_CODES.keys(): fare = create_fare_for_conference( code=fare_code, conference=conference, price=210, # random price, we'll change it later (div. by 3) start_validity=None, end_validity=None, vat_rate=v...
_type, start_validity=start_validity, end_validity=end_validity, ) ) VatFare.objects.get_or_create(fare=fare, vat=vat_rate) return fare def pre_create_typical_fares_for_conference(conference, vat_rate, print_output=False):
64
64
124
21
42
judy2k/epcon
conference/fares.py
Python
pre_create_typical_fares_for_conference
pre_create_typical_fares_for_conference
115
131
115
116
88d96afe058a8768fc909231ed1ea51f363acf43
bigcode/the-stack
train
53ca7b3a05357962fcc617c1
train
class
class FIDInceptionA(models.inception.InceptionA): """InceptionA block patched for FID computation""" def __init__(self, in_channels, pool_features): super(FIDInceptionA, self).__init__(in_channels, pool_features) def forward(self, x): branch1x1 = self.branch1x1(x) branch5x5 = self...
class FIDInceptionA(models.inception.InceptionA):
"""InceptionA block patched for FID computation""" def __init__(self, in_channels, pool_features): super(FIDInceptionA, self).__init__(in_channels, pool_features) def forward(self, x): branch1x1 = self.branch1x1(x) branch5x5 = self.branch5x5_1(x) branch5x5 = self.branch5x5...
) if os.path.exists(LOCAL_FID_WEIGHTS): state_dict = torch.load(LOCAL_FID_WEIGHTS, map_location=lambda storage, loc: storage) else: state_dict = load_url(FID_WEIGHTS_URL, progress=True) inception.load_state_dict(state_dict) return inception class FIDInceptionA(models.inception.Inceptio...
78
78
263
13
64
Cospel/BasicSR
basicsr/archs/inception.py
Python
FIDInceptionA
FIDInceptionA
189
211
189
189
66cb87176c8579d2c8240a1b5f54aa1b3baba5f8
bigcode/the-stack
train
895afbec27f3cff3e2e7fe13
train
class
class FIDInceptionE_1(models.inception.InceptionE): """First InceptionE block patched for FID computation""" def __init__(self, in_channels): super(FIDInceptionE_1, self).__init__(in_channels) def forward(self, x): branch1x1 = self.branch1x1(x) branch3x3 = self.branch3x3_1(x) ...
class FIDInceptionE_1(models.inception.InceptionE):
"""First InceptionE block patched for FID computation""" def __init__(self, in_channels): super(FIDInceptionE_1, self).__init__(in_channels) def forward(self, x): branch1x1 = self.branch1x1(x) branch3x3 = self.branch3x3_1(x) branch3x3 = [ self.branch3x3_2a(bran...
not use the padded zero's in # its average calculation branch_pool = F.avg_pool2d(x, kernel_size=3, stride=1, padding=1, count_include_pad=False) branch_pool = self.branch_pool(branch_pool) outputs = [branch1x1, branch7x7, branch7x7dbl, branch_pool] return torch.cat(outputs, 1)...
100
100
336
15
85
Cospel/BasicSR
basicsr/archs/inception.py
Python
FIDInceptionE_1
FIDInceptionE_1
242
272
242
242
22b6a94eaa4b3b4019f62bfad58df967f2fcf5f6
bigcode/the-stack
train
a1f6a8c24713eeeea4ad23e9
train
class
class FIDInceptionE_2(models.inception.InceptionE): """Second InceptionE block patched for FID computation""" def __init__(self, in_channels): super(FIDInceptionE_2, self).__init__(in_channels) def forward(self, x): branch1x1 = self.branch1x1(x) branch3x3 = self.branch3x3_1(x) ...
class FIDInceptionE_2(models.inception.InceptionE):
"""Second InceptionE block patched for FID computation""" def __init__(self, in_channels): super(FIDInceptionE_2, self).__init__(in_channels) def forward(self, x): branch1x1 = self.branch1x1(x) branch3x3 = self.branch3x3_1(x) branch3x3 = [ self.branch3x3_2a(bra...
# Patch: Tensorflow's average pool does not use the padded zero's in # its average calculation branch_pool = F.avg_pool2d(x, kernel_size=3, stride=1, padding=1, count_include_pad=False) branch_pool = self.branch_pool(branch_pool) outputs = [branch1x1, branch3x3, branch3x3dbl, branch_po...
109
109
364
15
94
Cospel/BasicSR
basicsr/archs/inception.py
Python
FIDInceptionE_2
FIDInceptionE_2
275
307
275
275
aebf4b2788f99c4f289b48eec0f1e5dbecd1f49d
bigcode/the-stack
train
806980c5b74524c1fe2314dd
train
class
class FIDInceptionC(models.inception.InceptionC): """InceptionC block patched for FID computation""" def __init__(self, in_channels, channels_7x7): super(FIDInceptionC, self).__init__(in_channels, channels_7x7) def forward(self, x): branch1x1 = self.branch1x1(x) branch7x7 = self.b...
class FIDInceptionC(models.inception.InceptionC):
"""InceptionC block patched for FID computation""" def __init__(self, in_channels, channels_7x7): super(FIDInceptionC, self).__init__(in_channels, channels_7x7) def forward(self, x): branch1x1 = self.branch1x1(x) branch7x7 = self.branch7x7_1(x) branch7x7 = self.branch7x7_2...
not use the padded zero's in # its average calculation branch_pool = F.avg_pool2d(x, kernel_size=3, stride=1, padding=1, count_include_pad=False) branch_pool = self.branch_pool(branch_pool) outputs = [branch1x1, branch5x5, branch3x3dbl, branch_pool] return torch.cat(outputs, 1)...
98
98
329
13
85
Cospel/BasicSR
basicsr/archs/inception.py
Python
FIDInceptionC
FIDInceptionC
214
239
214
214
684a6aa4e84d529b30b8ee417cc00a96fce7ee38
bigcode/the-stack
train
bcaef7d9a20c3d178c3e6a35
train
function
def fid_inception_v3(): """Build pretrained Inception model for FID computation. The Inception model for FID computation uses a different set of weights and has a slightly different structure than torchvision's Inception. This method first constructs torchvision's Inception and then patches the ne...
def fid_inception_v3():
"""Build pretrained Inception model for FID computation. The Inception model for FID computation uses a different set of weights and has a slightly different structure than torchvision's Inception. This method first constructs torchvision's Inception and then patches the necessary parts that are d...
output = [] if self.resize_input: x = F.interpolate(x, size=(299, 299), mode='bilinear', align_corners=False) if self.normalize_input: x = 2 * x - 1 # Scale from range (0, 1) to range (-1, 1) for idx, block in enumerate(self.blocks): x = block(x) ...
120
120
403
7
112
Cospel/BasicSR
basicsr/archs/inception.py
Python
fid_inception_v3
fid_inception_v3
155
186
155
155
2ca7ea60e959146c74d446e6007470e588c66dd9
bigcode/the-stack
train
a052c27b1eb51cacb627024c
train
class
class InceptionV3(nn.Module): """Pretrained InceptionV3 network returning feature maps""" # Index of default block of inception to return, # corresponds to output of final average pooling DEFAULT_BLOCK_INDEX = 3 # Maps feature dimensionality to their output blocks indices BLOCK_INDEX_BY_DIM = ...
class InceptionV3(nn.Module):
"""Pretrained InceptionV3 network returning feature maps""" # Index of default block of inception to return, # corresponds to output of final average pooling DEFAULT_BLOCK_INDEX = 3 # Maps feature dimensionality to their output blocks indices BLOCK_INDEX_BY_DIM = { 64: 0, # First max ...
# Modified from https://github.com/mseitzer/pytorch-fid/blob/master/pytorch_fid/inception.py # noqa: E501 # For FID metric import os import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.model_zoo import load_url from torchvision import models # Inception weights ported to Pytorch from #...
198
256
1,205
8
189
Cospel/BasicSR
basicsr/archs/inception.py
Python
InceptionV3
InceptionV3
17
152
17
17
4d577b9279dc88fc6c5c35effdb1e17e62954771
bigcode/the-stack
train
0251d323c0074f4756d32715
train
class
class SentryAppInstallationToken(Model): __core__ = False api_token = FlexibleForeignKey('sentry.ApiToken') sentry_app_installation = FlexibleForeignKey('sentry.SentryAppInstallation') class Meta: app_label = 'sentry' db_table = 'sentry_sentryappinstallationtoken' unique_togeth...
class SentryAppInstallationToken(Model):
__core__ = False api_token = FlexibleForeignKey('sentry.ApiToken') sentry_app_installation = FlexibleForeignKey('sentry.SentryAppInstallation') class Meta: app_label = 'sentry' db_table = 'sentry_sentryappinstallationtoken' unique_together = (('sentry_app_installation', 'api_to...
.utils import timezone from sentry.constants import SentryAppInstallationStatus from sentry.db.models import ( BoundedPositiveIntegerField, FlexibleForeignKey, ParanoidModel, Model, ) def default_uuid(): return six.binary_type(uuid.uuid4()) class SentryAppInstallationToken(Model):
64
64
89
8
56
lauryndbrown/sentry
src/sentry/models/sentryappinstallation.py
Python
SentryAppInstallationToken
SentryAppInstallationToken
22
31
22
22
b9b44a72f4a7a3b5c6b1a317f60e22ca7056815c
bigcode/the-stack
train
64a1073035dad3d2ce1ba2ee
train
class
class SentryAppInstallation(ParanoidModel): __core__ = True sentry_app = FlexibleForeignKey('sentry.SentryApp', related_name='installations') # SentryApp's are installed and scoped to an Organization. They will have # access, defined by their scopes, to Teams, Proje...
class SentryAppInstallation(ParanoidModel):
__core__ = True sentry_app = FlexibleForeignKey('sentry.SentryApp', related_name='installations') # SentryApp's are installed and scoped to an Organization. They will have # access, defined by their scopes, to Teams, Projects, etc. under that # Organization, imp...
oundedPositiveIntegerField, FlexibleForeignKey, ParanoidModel, Model, ) def default_uuid(): return six.binary_type(uuid.uuid4()) class SentryAppInstallationToken(Model): __core__ = False api_token = FlexibleForeignKey('sentry.ApiToken') sentry_app_installation = FlexibleForeignKey('sent...
131
131
438
10
121
lauryndbrown/sentry
src/sentry/models/sentryappinstallation.py
Python
SentryAppInstallation
SentryAppInstallation
34
86
34
34
3c0c8d2c7905eccfd7b7a69f2902ec7ceac3a379
bigcode/the-stack
train
9e000bf7fcb8ea1f9c916c09
train
function
def default_uuid(): return six.binary_type(uuid.uuid4())
def default_uuid():
return six.binary_type(uuid.uuid4())
absolute_import import six import uuid from django.db import models from django.utils import timezone from sentry.constants import SentryAppInstallationStatus from sentry.db.models import ( BoundedPositiveIntegerField, FlexibleForeignKey, ParanoidModel, Model, ) def default_uuid():
64
64
13
4
60
lauryndbrown/sentry
src/sentry/models/sentryappinstallation.py
Python
default_uuid
default_uuid
18
19
18
18
6af4eef7d95d0c5a9646d5c19e5a1ec199783cc9
bigcode/the-stack
train
dc6fb55d1fce2d144519f438
train
class
class PartialDateTimeField(models.Field): """ A django model field for storing partial datetimes. Accepts None, a partial_date.PartialDate object, or a formatted string such as YYYY, YYYY-MM, YYYY-MM-DD, YYYY-MM-DDTHH, YYYY-MM-DDTHH:mm. In the database it saves the date in a column of type DateTimeF...
class PartialDateTimeField(models.Field):
""" A django model field for storing partial datetimes. Accepts None, a partial_date.PartialDate object, or a formatted string such as YYYY, YYYY-MM, YYYY-MM-DD, YYYY-MM-DDTHH, YYYY-MM-DDTHH:mm. In the database it saves the date in a column of type DateTimeField and uses the seconds to save the ...
ision == other.precision else: return NotImplemented def __gt__(self, other): if isinstance(other, PartialDate): return self.__ge__(other) and not self.__eq__(other) else: return NotImplemented def __ge__(self, other): if isinstance(other, Pa...
104
104
348
8
95
JamesBisese/django_partial_datetime
partial_date/fields.py
Python
PartialDateTimeField
PartialDateTimeField
144
188
144
144
312675ad9a84e8d119d7f82d4e0429f9120c6b72
bigcode/the-stack
train
e3e7f8bd48e8a80f958596a6
train
class
class PartialDateTime(object): YEAR = 0 MONTH = 1 DAY = 2 HOUR = 3 MINUTE = 4 _date = None _precision = None DATE_FORMATS = {YEAR: "%Y", MONTH: "%Y-%m", DAY: "%Y-%m-%d", HOUR: "%Y-%m-%d %H:00", MINUTE: "%Y-%m-%d %H:%M"} def __init__(self, date, precision=DAY): if isinstanc...
class PartialDateTime(object):
YEAR = 0 MONTH = 1 DAY = 2 HOUR = 3 MINUTE = 4 _date = None _precision = None DATE_FORMATS = {YEAR: "%Y", MONTH: "%Y-%m", DAY: "%Y-%m-%d", HOUR: "%Y-%m-%d %H:00", MINUTE: "%Y-%m-%d %H:%M"} def __init__(self, date, precision=DAY): if isinstance(date, six.text_type): ...
# -*- coding: utf-8 -*- from __future__ import unicode_literals import datetime import re import six from django.core import exceptions from django.db import models from django.utils.translation import gettext_lazy as _ # I have to figure out the regex for this. It's already kind of scary. Use 'T' to start any timep...
149
256
869
6
143
JamesBisese/django_partial_datetime
partial_date/fields.py
Python
PartialDateTime
PartialDateTime
18
141
18
18
4809db547be1243580a2dc1044fef8a293650e20
bigcode/the-stack
train
e84c099fed361d9ecf25cf11
train
function
def minimum_spanning_tree(adjacency_list): """ Get minimum spanning tree for graph represented as adjacency list """ remain_vertices = adjacency_list.copy() edges_by_vertex = {} mst = UndirectedGraph() for vertex in remain_vertices.keys(): edges_by_vertex[vertex] = None while re...
def minimum_spanning_tree(adjacency_list):
""" Get minimum spanning tree for graph represented as adjacency list """ remain_vertices = adjacency_list.copy() edges_by_vertex = {} mst = UndirectedGraph() for vertex in remain_vertices.keys(): edges_by_vertex[vertex] = None while remain_vertices: (vertex, adjacent_ed...
graph is of minimum overall weight (sum of all edges) among all such subgraphs. - It is also required that there is exactly one, exclusive path between any two nodes of the subgraph. """ import math from src.graph import UndirectedGraph def minimum_spanning_tree(adjacency_list):
64
64
207
10
53
CarnaViire/training
python/src/minimum_spanning_tree.py
Python
minimum_spanning_tree
minimum_spanning_tree
15
39
15
15
bb8c117f6a8d48a95b0d25a4141aa542ad864763
bigcode/the-stack
train
9f63c1f19bf0ad48557c44ca
train
function
def __get_lighter_vertex(edges_by_vertex, v1, v2): v1_weight = __get_weight_or_inf(edges_by_vertex[v1]) v2_weight = __get_weight_or_inf(edges_by_vertex[v2]) return v1 if v1_weight < v2_weight else v2
def __get_lighter_vertex(edges_by_vertex, v1, v2):
v1_weight = __get_weight_or_inf(edges_by_vertex[v1]) v2_weight = __get_weight_or_inf(edges_by_vertex[v2]) return v1 if v1_weight < v2_weight else v2
for vertex in vertices: if min_weight_vertex is None: min_weight_vertex = vertex min_weight_vertex = __get_lighter_vertex( edges_by_vertex, vertex, min_weight_vertex) return min_weight_vertex def __get_lighter_vertex(edges_by_vertex, v1, v2):
64
64
64
16
47
CarnaViire/training
python/src/minimum_spanning_tree.py
Python
__get_lighter_vertex
__get_lighter_vertex
58
61
58
58
faec85561e29dabc29464f80b7ea775d1f342599
bigcode/the-stack
train
815bdef46ea9acc29dd849e6
train
function
def __get_weight_or_inf(edge): return math.inf if not edge else edge.weight
def __get_weight_or_inf(edge):
return math.inf if not edge else edge.weight
_vertex, v1, v2): v1_weight = __get_weight_or_inf(edges_by_vertex[v1]) v2_weight = __get_weight_or_inf(edges_by_vertex[v2]) return v1 if v1_weight < v2_weight else v2 def __get_weight_or_inf(edge):
64
64
19
8
55
CarnaViire/training
python/src/minimum_spanning_tree.py
Python
__get_weight_or_inf
__get_weight_or_inf
64
65
64
64
14862e6a6458ae778f741c56c03e8c01490c4760
bigcode/the-stack
train
c733f8d9cd3d705d413bf1b6
train
function
def __extract_next_vertex_with_edges(remain_vertices, edges_by_vertex): vertex_with_min_weight = __find_vertex_with_min_weight(remain_vertices.keys(), edges_by_vertex) return vertex_with_min_weight, remain_vertices.pop(vertex_with_min_weight)
def __extract_next_vertex_with_edges(remain_vertices, edges_by_vertex):
vertex_with_min_weight = __find_vertex_with_min_weight(remain_vertices.keys(), edges_by_vertex) return vertex_with_min_weight, remain_vertices.pop(vertex_with_min_weight)
is_lighter = edge.weight < __get_weight_or_inf( edges_by_vertex[adjacent_vertex]) if is_not_visited and is_lighter: edges_by_vertex[adjacent_vertex] = edge return mst def __extract_next_vertex_with_edges(remain_vertices, edges_by_vertex):
64
64
52
15
48
CarnaViire/training
python/src/minimum_spanning_tree.py
Python
__extract_next_vertex_with_edges
__extract_next_vertex_with_edges
42
45
42
42
397e5b865672eb6497ef5e23b34942d439aab71d
bigcode/the-stack
train
08181b4803b75a517d838231
train
function
def __find_vertex_with_min_weight(vertices, edges_by_vertex): min_weight_vertex = None for vertex in vertices: if min_weight_vertex is None: min_weight_vertex = vertex min_weight_vertex = __get_lighter_vertex( edges_by_vertex, vertex, min_weight_vertex) return min_wei...
def __find_vertex_with_min_weight(vertices, edges_by_vertex):
min_weight_vertex = None for vertex in vertices: if min_weight_vertex is None: min_weight_vertex = vertex min_weight_vertex = __get_lighter_vertex( edges_by_vertex, vertex, min_weight_vertex) return min_weight_vertex
__extract_next_vertex_with_edges(remain_vertices, edges_by_vertex): vertex_with_min_weight = __find_vertex_with_min_weight(remain_vertices.keys(), edges_by_vertex) return vertex_with_min_weight, remain_vertices.pop(vertex_with_min_weight) def __find_ve...
64
64
69
13
51
CarnaViire/training
python/src/minimum_spanning_tree.py
Python
__find_vertex_with_min_weight
__find_vertex_with_min_weight
48
55
48
48
0e478a1a3b51d5fd9cfd923d2e8c601e3ed13488
bigcode/the-stack
train
6911a3f329e6a6cd5690e526
train
function
def check_syntax_warning(testcase, statement, errtext='', *, lineno=1, offset=None): # Test also that a warning is emitted only once. from test.support import check_syntax_error with warnings.catch_warnings(record=True) as warns: warnings.simplefilter('always', SyntaxWarning...
def check_syntax_warning(testcase, statement, errtext='', *, lineno=1, offset=None): # Test also that a warning is emitted only once.
from test.support import check_syntax_error with warnings.catch_warnings(record=True) as warns: warnings.simplefilter('always', SyntaxWarning) compile(statement, '<testcase>', 'exec') testcase.assertEqual(len(warns), 1, warns) warn, = warns testcase.assertTrue(issubclass(warn.catego...
import contextlib import functools import re import sys import warnings def check_syntax_warning(testcase, statement, errtext='', *, lineno=1, offset=None): # Test also that a warning is emitted only once.
52
82
274
36
15
shawwn/cpython
Lib/test/support/warnings_helper.py
Python
check_syntax_warning
check_syntax_warning
8
35
8
10
4d0385fe8a32f083b4678e945c9b7fa094716da2
bigcode/the-stack
train
21022dc4bb6f42467f0a3aa9
train
class
class WarningsRecorder(object): """Convenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. """ def __init__(self, warnings_list): self._warnings = warnings_list self._last = 0 def __getattr__(self, attr): if len(self._...
class WarningsRecorder(object):
"""Convenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. """ def __init__(self, warnings_list): self._warnings = warnings_list self._last = 0 def __getattr__(self, attr): if len(self._warnings) > self._last: ...
): @functools.wraps(test) def wrapper(self, *args, **kwargs): with warnings.catch_warnings(): warnings.simplefilter('ignore', category=category) return test(self, *args, **kwargs) return wrapper return decorator class WarningsRecorder(object):
64
64
157
6
57
shawwn/cpython
Lib/test/support/warnings_helper.py
Python
WarningsRecorder
WarningsRecorder
54
74
54
54
a18fd04c63e822fad3156db2a8d0f66a2294dc07
bigcode/the-stack
train
15bb8ecb6be7d5228a7e3fbe
train
function
@contextlib.contextmanager def save_restore_warnings_filters(): old_filters = warnings.filters[:] try: yield finally: warnings.filters[:] = old_filters
@contextlib.contextmanager def save_restore_warnings_filters():
old_filters = warnings.filters[:] try: yield finally: warnings.filters[:] = old_filters
if reraise: raise AssertionError("unhandled warning %s" % reraise[0]) if missing: raise AssertionError("filter (%r, %s) did not catch any warning" % missing[0]) @contextlib.contextmanager def save_restore_warnings_filters():
64
64
38
13
51
shawwn/cpython
Lib/test/support/warnings_helper.py
Python
save_restore_warnings_filters
save_restore_warnings_filters
183
189
183
184
2f6995b74bcd220dbbea194540c58b6b45f0db20
bigcode/the-stack
train
6f3f2132be36f15b82082046
train
function
@contextlib.contextmanager def check_warnings(*filters, **kwargs): """Context manager to silence warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default True w...
@contextlib.contextmanager def check_warnings(*filters, **kwargs):
"""Context manager to silence warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default True without argument, default False if some filters are defined...
Error("%r has no attribute %r" % (self, attr)) @property def warnings(self): return self._warnings[self._last:] def reset(self): self._last = len(self._warnings) @contextlib.contextmanager def check_warnings(*filters, **kwargs):
64
64
149
16
48
shawwn/cpython
Lib/test/support/warnings_helper.py
Python
check_warnings
check_warnings
77
98
77
78
3518a6e204fa399c930f9eba02f0fa945b81487e
bigcode/the-stack
train
2c8450785f2932c4bf7e5617
train
function
def _filterwarnings(filters, quiet=False): """Catch the warnings, then check if all the expected warnings have been raised and re-raise unexpected warnings. If 'quiet' is True, only re-raise the unexpected warnings. """ # Clear the warning registry of the calling module # in order to re-raise th...
def _filterwarnings(filters, quiet=False):
"""Catch the warnings, then check if all the expected warnings have been raised and re-raise unexpected warnings. If 'quiet' is True, only re-raise the unexpected warnings. """ # Clear the warning registry of the calling module # in order to re-raise the warnings. frame = sys._getframe(2) ...
@contextlib.contextmanager def check_no_resource_warning(testcase): """Context manager to check that no ResourceWarning is emitted. Usage: with check_no_resource_warning(self): f = open(...) ... del f You must remove the object which may emit ResourceWarning be...
102
102
343
9
92
shawwn/cpython
Lib/test/support/warnings_helper.py
Python
_filterwarnings
_filterwarnings
144
180
144
144
a9f8f97e0cf9d691c6b44553427e700a2b9c3c24
bigcode/the-stack
train
812f3878c434b1489c3a8a0f
train
function
@contextlib.contextmanager def check_no_warnings(testcase, message='', category=Warning, force_gc=False): """Context manager to check that no warnings are emitted. This context manager enables a given warning within its scope and checks that no warnings are emitted even with that warning enabled. ...
@contextlib.contextmanager def check_no_warnings(testcase, message='', category=Warning, force_gc=False):
"""Context manager to check that no warnings are emitted. This context manager enables a given warning within its scope and checks that no warnings are emitted even with that warning enabled. If force_gc is True, a garbage collection is attempted before checking for warnings. This may help to ...
') if not filters: filters = (("", Warning),) # Preserve backward compatibility if quiet is None: quiet = True return _filterwarnings(filters, quiet) @contextlib.contextmanager def check_no_warnings(testcase, message='', category=Warning, force_gc=False):
64
64
172
24
40
shawwn/cpython
Lib/test/support/warnings_helper.py
Python
check_no_warnings
check_no_warnings
101
123
101
102
6b468b8123cc20b27e533e8adbb919d04040b17e
bigcode/the-stack
train
96bd788910b0585e7dabb96c
train
function
@contextlib.contextmanager def check_no_resource_warning(testcase): """Context manager to check that no ResourceWarning is emitted. Usage: with check_no_resource_warning(self): f = open(...) ... del f You must remove the object which may emit ResourceWarning be...
@contextlib.contextmanager def check_no_resource_warning(testcase):
"""Context manager to check that no ResourceWarning is emitted. Usage: with check_no_resource_warning(self): f = open(...) ... del f You must remove the object which may emit ResourceWarning before the end of the context manager. """ with check_no_w...
with warnings.catch_warnings(record=True) as warns: warnings.filterwarnings('always', message=message, category=category) yield if force_gc: gc_collect() testcase.assertEqual(warns, []) @contextlib.contextmanager...
63
64
93
14
49
shawwn/cpython
Lib/test/support/warnings_helper.py
Python
check_no_resource_warning
check_no_resource_warning
126
141
126
127
18bb88b8904eb5adc5bb95fab14c7bdb84661f31
bigcode/the-stack
train
61095453cd3261cfae21f788
train
function
def ignore_warnings(*, category): """Decorator to suppress deprecation warnings. Use of context managers to hide warnings make diffs more noisy and tools like 'git blame' less useful. """ def decorator(test): @functools.wraps(test) def wrapper(self, *args, **kwargs): wit...
def ignore_warnings(*, category):
"""Decorator to suppress deprecation warnings. Use of context managers to hide warnings make diffs more noisy and tools like 'git blame' less useful. """ def decorator(test): @functools.wraps(test) def wrapper(self, *args, **kwargs): with warnings.catch_warnings(): ...
warnings.simplefilter('error', SyntaxWarning) check_syntax_error(testcase, statement, errtext, lineno=lineno, offset=offset) # No warnings are leaked when a SyntaxError is raised. testcase.assertEqual(warns, []) def ignore_warnings(*, category):
63
64
106
8
55
shawwn/cpython
Lib/test/support/warnings_helper.py
Python
ignore_warnings
ignore_warnings
38
51
38
38
c2e2a032a0cc65a6851a0b978a74d8b33474b60c
bigcode/the-stack
train
75b2dfdac7b3fb0ec09606b8
train
function
@pytest.mark.parametrize("version", [114, 117, 118, 119, None]) def test_chunked_categorical(version): df = DataFrame({"cats": Series(["a", "b", "a", "b", "c"], dtype="category")}) df.index.name = "index" with tm.ensure_clean() as path: df.to_stata(path, version=version) reader = StataReader...
@pytest.mark.parametrize("version", [114, 117, 118, 119, None]) def test_chunked_categorical(version):
df = DataFrame({"cats": Series(["a", "b", "a", "b", "c"], dtype="category")}) df.index.name = "index" with tm.ensure_clean() as path: df.to_stata(path, version=version) reader = StataReader(path, chunksize=2, order_categoricals=False) for i, block in enumerate(reader): bl...
[0])) else: fp = path reread = read_stata(fp, index_col="index") tm.assert_frame_equal(reread, df) @pytest.mark.parametrize("version", [114, 117, 118, 119, None]) def test_chunked_categorical(version):
64
64
157
28
36
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_chunked_categorical
test_chunked_categorical
1,938
1,948
1,938
1,939
410482e3542a77df937080512976254847c81314
bigcode/the-stack
train
974dea91fb882d679700bed6
train
function
@pytest.mark.parametrize("version", [114, 117, 118, 119, None]) @pytest.mark.parametrize("use_dict", [True, False]) @pytest.mark.parametrize("infer", [True, False]) def test_compression(compression, version, use_dict, infer): file_name = "dta_inferred_compression.dta" if compression: file_ext = "gz" if ...
@pytest.mark.parametrize("version", [114, 117, 118, 119, None]) @pytest.mark.parametrize("use_dict", [True, False]) @pytest.mark.parametrize("infer", [True, False]) def test_compression(compression, version, use_dict, infer):
file_name = "dta_inferred_compression.dta" if compression: file_ext = "gz" if compression == "gzip" and not use_dict else compression file_name += f".{file_ext}" compression_arg = compression if infer: compression_arg = "infer" if use_dict: compression_arg = {"method"...
, f"stata-compat-{version}.dta") expected = pd.read_stata(ref) old_dta = pd.read_stata(old) tm.assert_frame_equal(old_dta, expected, check_dtype=False) @pytest.mark.parametrize("version", [114, 117, 118, 119, None]) @pytest.mark.parametrize("use_dict", [True, False]) @pytest.mark.parametrize("infer", [True,...
104
104
349
57
47
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_compression
test_compression
1,881
1,914
1,881
1,884
2b977c00403e690b5adf71e4aba3b71bfc4769db
bigcode/the-stack
train
fea918e882b1f922cf76347d
train
function
def test_iterator_value_labels(): # GH 31544 values = ["c_label", "b_label"] + ["a_label"] * 500 df = DataFrame({f"col{k}": pd.Categorical(values, ordered=True) for k in range(2)}) with tm.ensure_clean() as path: df.to_stata(path, write_index=False) expected = pd.Index(["a_label", "b_lab...
def test_iterator_value_labels(): # GH 31544
values = ["c_label", "b_label"] + ["a_label"] * 500 df = DataFrame({f"col{k}": pd.Categorical(values, ordered=True) for k in range(2)}) with tm.ensure_clean() as path: df.to_stata(path, write_index=False) expected = pd.Index(["a_label", "b_label", "c_label"], dtype="object") with pd....
match="chunksize must be a positive"): StataReader(dta_file, chunksize=0) with pytest.raises(ValueError, match="chunksize must be a positive"): StataReader(dta_file, chunksize="apple") def test_iterator_value_labels(): # GH 31544
64
64
172
13
51
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_iterator_value_labels
test_iterator_value_labels
1,980
1,991
1,980
1,981
956b639b3469b59e1350b2ca15c94633839851b9
bigcode/the-stack
train
38b67ee183bc382892101f99
train
function
def test_precision_loss(): df = DataFrame( [[sum(2 ** i for i in range(60)), sum(2 ** i for i in range(52))]], columns=["big", "little"], ) with tm.ensure_clean() as path: with tm.assert_produces_warning( PossiblePrecisionLoss, match="Column converted from int64 to float6...
def test_precision_loss():
df = DataFrame( [[sum(2 ** i for i in range(60)), sum(2 ** i for i in range(52))]], columns=["big", "little"], ) with tm.ensure_clean() as path: with tm.assert_produces_warning( PossiblePrecisionLoss, match="Column converted from int64 to float64" ): d...
) as reader: for j, chunk in enumerate(reader): for i in range(2): tm.assert_index_equal(chunk.dtypes[i].categories, expected) tm.assert_frame_equal(chunk, df.iloc[j * 100 : (j + 1) * 100]) def test_precision_loss():
64
64
180
5
59
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_precision_loss
test_precision_loss
1,994
2,008
1,994
1,994
fddf0d576b3fdec62850bac2e22ee4510d97be29
bigcode/the-stack
train
e0e98f74037ca200c3d739db
train
function
@pytest.fixture def parsed_114(dirpath): dta14_114 = os.path.join(dirpath, "stata5_114.dta") parsed_114 = read_stata(dta14_114, convert_dates=True) parsed_114.index.name = "index" return parsed_114
@pytest.fixture def parsed_114(dirpath):
dta14_114 = os.path.join(dirpath, "stata5_114.dta") parsed_114 = read_stata(dta14_114, convert_dates=True) parsed_114.index.name = "index" return parsed_114
27.0, 81.0], "c": ["Atlanta", "Birmingham", "Cincinnati", "Detroit"], } ) @pytest.fixture def dirpath(datapath): return datapath("io", "data", "stata") @pytest.fixture def parsed_114(dirpath):
64
64
65
10
54
oricou/pandas
pandas/tests/io/test_stata.py
Python
parsed_114
parsed_114
57
62
57
58
2a536a53ddafed94b6a04ec909ea9c09a767207d
bigcode/the-stack
train
619a4056c02809f138d0d86f
train
function
@pytest.fixture def dirpath(datapath): return datapath("io", "data", "stata")
@pytest.fixture def dirpath(datapath):
return datapath("io", "data", "stata")
2, 3, 4], "b": [1.0, 3.0, 27.0, 81.0], "c": ["Atlanta", "Birmingham", "Cincinnati", "Detroit"], } ) @pytest.fixture def dirpath(datapath):
64
64
23
10
54
oricou/pandas
pandas/tests/io/test_stata.py
Python
dirpath
dirpath
52
54
52
53
72175eb3b0fbd685938a898587e120a46df59907
bigcode/the-stack
train
189f0a9bdf76d00d82894fd5
train
function
def test_compression_roundtrip(compression): df = DataFrame( [[0.123456, 0.234567, 0.567567], [12.32112, 123123.2, 321321.2]], index=["A", "B"], columns=["X", "Y", "Z"], ) df.index.name = "index" with tm.ensure_clean() as path: df.to_stata(path, compression=compression)...
def test_compression_roundtrip(compression):
df = DataFrame( [[0.123456, 0.234567, 0.567567], [12.32112, 123123.2, 321321.2]], index=["A", "B"], columns=["X", "Y", "Z"], ) df.index.name = "index" with tm.ensure_clean() as path: df.to_stata(path, compression=compression) reread = read_stata(path, compressio...
tm.assert_series_equal(reread.dtypes, expected_dt) assert reread.loc[0, "little"] == df.loc[0, "little"] assert reread.loc[0, "big"] == float(df.loc[0, "big"]) def test_compression_roundtrip(compression):
63
64
185
9
54
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_compression_roundtrip
test_compression_roundtrip
2,011
2,029
2,011
2,011
ad7074cad681a0eaa5ad257ca0cb7229c21d261f
bigcode/the-stack
train
9bb2da62b5426f48eeab99b7
train
function
@pytest.mark.parametrize("version", [105, 108, 111, 113, 114]) def test_backward_compat(version, datapath): data_base = datapath("io", "data", "stata") ref = os.path.join(data_base, "stata-compat-118.dta") old = os.path.join(data_base, f"stata-compat-{version}.dta") expected = pd.read_stata(ref) old...
@pytest.mark.parametrize("version", [105, 108, 111, 113, 114]) def test_backward_compat(version, datapath):
data_base = datapath("io", "data", "stata") ref = os.path.join(data_base, "stata-compat-118.dta") old = os.path.join(data_base, f"stata-compat-{version}.dta") expected = pd.read_stata(ref) old_dta = pd.read_stata(old) tm.assert_frame_equal(old_dta, expected, check_dtype=False)
as path: with pytest.raises(ValueError, match="You must use version 119"): StataWriterUTF8(path, df, version=118) @pytest.mark.parametrize("version", [105, 108, 111, 113, 114]) def test_backward_compat(version, datapath):
64
64
119
31
33
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_backward_compat
test_backward_compat
1,871
1,878
1,871
1,872
194b656453e01d87bbd9d30a5ecdf21af5d690e9
bigcode/the-stack
train
cb03ae9575e8ea467fc13adb
train
function
@pytest.mark.parametrize("method", ["zip", "infer"]) @pytest.mark.parametrize("file_ext", [None, "dta", "zip"]) def test_compression_dict(method, file_ext): file_name = f"test.{file_ext}" archive_name = "test.dta" df = DataFrame(np.random.randn(10, 2), columns=list("AB")) df.index.name = "index" wit...
@pytest.mark.parametrize("method", ["zip", "infer"]) @pytest.mark.parametrize("file_ext", [None, "dta", "zip"]) def test_compression_dict(method, file_ext):
file_name = f"test.{file_ext}" archive_name = "test.dta" df = DataFrame(np.random.randn(10, 2), columns=list("AB")) df.index.name = "index" with tm.ensure_clean(file_name) as path: compression = {"method": method, "archive_name": archive_name} df.to_stata(path, compression=compressio...
= path reread = read_stata(fp, index_col="index") tm.assert_frame_equal(reread, df) @pytest.mark.parametrize("method", ["zip", "infer"]) @pytest.mark.parametrize("file_ext", [None, "dta", "zip"]) def test_compression_dict(method, file_ext):
67
67
225
39
28
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_compression_dict
test_compression_dict
1,917
1,935
1,917
1,919
101948726e5c2403142337a6bd3bee343cbe99e9
bigcode/the-stack
train
f49849c186e762426602b37a
train
function
def test_chunked_categorical_partial(dirpath): dta_file = os.path.join(dirpath, "stata-dta-partially-labeled.dta") values = ["a", "b", "a", "b", 3.0] with StataReader(dta_file, chunksize=2) as reader: with tm.assert_produces_warning(CategoricalConversionWarning): for i, block in enumerat...
def test_chunked_categorical_partial(dirpath):
dta_file = os.path.join(dirpath, "stata-dta-partially-labeled.dta") values = ["a", "b", "a", "b", 3.0] with StataReader(dta_file, chunksize=2) as reader: with tm.assert_produces_warning(CategoricalConversionWarning): for i, block in enumerate(reader): assert list(block.ca...
) for i, block in enumerate(reader): block = block.set_index("index") assert "cats" in block tm.assert_series_equal(block.cats, df.cats.iloc[2 * i : 2 * (i + 1)]) def test_chunked_categorical_partial(dirpath):
64
65
219
10
54
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_chunked_categorical_partial
test_chunked_categorical_partial
1,951
1,967
1,951
1,951
4ea7e135eeae906e2668934219b6978db59e1375
bigcode/the-stack
train
b8961891422d96b1683bb63e
train
function
def test_iterator_errors(dirpath): dta_file = os.path.join(dirpath, "stata-dta-partially-labeled.dta") with pytest.raises(ValueError, match="chunksize must be a positive"): StataReader(dta_file, chunksize=-1) with pytest.raises(ValueError, match="chunksize must be a positive"): StataReader(d...
def test_iterator_errors(dirpath):
dta_file = os.path.join(dirpath, "stata-dta-partially-labeled.dta") with pytest.raises(ValueError, match="chunksize must be a positive"): StataReader(dta_file, chunksize=-1) with pytest.raises(ValueError, match="chunksize must be a positive"): StataReader(dta_file, chunksize=0) with pyte...
tm.assert_produces_warning(CategoricalConversionWarning): with StataReader(dta_file, chunksize=5) as reader: large_chunk = reader.__next__() direct = read_stata(dta_file) tm.assert_frame_equal(direct, large_chunk) def test_iterator_errors(dirpath):
64
64
116
7
57
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_iterator_errors
test_iterator_errors
1,970
1,977
1,970
1,970
c1fc82f011616bd1a7433dba93692fb4ba4bfc70
bigcode/the-stack
train
2e753e5c808889bbdb5a6a00
train
function
@pytest.mark.parametrize("to_infer", [True, False]) @pytest.mark.parametrize("read_infer", [True, False]) def test_stata_compression(compression_only, read_infer, to_infer): compression = compression_only ext = "gz" if compression == "gzip" else compression filename = f"test.{ext}" df = DataFrame( ...
@pytest.mark.parametrize("to_infer", [True, False]) @pytest.mark.parametrize("read_infer", [True, False]) def test_stata_compression(compression_only, read_infer, to_infer):
compression = compression_only ext = "gz" if compression == "gzip" else compression filename = f"test.{ext}" df = DataFrame( [[0.123456, 0.234567, 0.567567], [12.32112, 123123.2, 321321.2]], index=["A", "B"], columns=["X", "Y", "Z"], ) df.index.name = "index" to_co...
reread = pd.read_stata(contents, index_col="index") tm.assert_frame_equal(df, reread) @pytest.mark.parametrize("to_infer", [True, False]) @pytest.mark.parametrize("read_infer", [True, False]) def test_stata_compression(compression_only, read_infer, to_infer):
68
68
228
44
24
oricou/pandas
pandas/tests/io/test_stata.py
Python
test_stata_compression
test_stata_compression
2,032
2,053
2,032
2,034
13161dbb45cf7fa3886fa23e539576bd3de64637
bigcode/the-stack
train
d7c52e28bb084f81becd07f0
train
class
class TestStata: @pytest.fixture(autouse=True) def setup_method(self, datapath): self.dirpath = datapath("io", "data", "stata") self.dta1_114 = os.path.join(self.dirpath, "stata1_114.dta") self.dta1_117 = os.path.join(self.dirpath, "stata1_117.dta") self.dta2_113 = os.path.join(...
class TestStata: @pytest.fixture(autouse=True)
def setup_method(self, datapath): self.dirpath = datapath("io", "data", "stata") self.dta1_114 = os.path.join(self.dirpath, "stata1_114.dta") self.dta1_117 = os.path.join(self.dirpath, "stata1_117.dta") self.dta2_113 = os.path.join(self.dirpath, "stata2_113.dta") self.dta2_1...
.io.stata import ( CategoricalConversionWarning, InvalidColumnName, PossiblePrecisionLoss, StataMissingValue, StataReader, StataWriterUTF8, read_stata, ) # TODO(ArrayManager) the stata code relies on BlockManager internals (eg blknos) pytestmark = td.skip_array_manager_not_yet_implemented ...
256
256
18,056
14
241
oricou/pandas
pandas/tests/io/test_stata.py
Python
TestStata
TestStata
65
1,868
65
66
4fe2b2586492298877e876fdd25a4393e600dcd5
bigcode/the-stack
train
9e744e355e8845e73087c76b
train
function
@pytest.fixture() def mixed_frame(): return DataFrame( { "a": [1, 2, 3, 4], "b": [1.0, 3.0, 27.0, 81.0], "c": ["Atlanta", "Birmingham", "Cincinnati", "Detroit"], } )
@pytest.fixture() def mixed_frame():
return DataFrame( { "a": [1, 2, 3, 4], "b": [1.0, 3.0, 27.0, 81.0], "c": ["Atlanta", "Birmingham", "Cincinnati", "Detroit"], } )
StataMissingValue, StataReader, StataWriterUTF8, read_stata, ) # TODO(ArrayManager) the stata code relies on BlockManager internals (eg blknos) pytestmark = td.skip_array_manager_not_yet_implemented @pytest.fixture() def mixed_frame():
64
64
76
7
56
oricou/pandas
pandas/tests/io/test_stata.py
Python
mixed_frame
mixed_frame
41
49
41
42
5056d9b5d2f00f791e1f88ce3e786a2ee3c0758d
bigcode/the-stack
train
e0e17fa5d25f414d092dcbcf
train
class
class TestGMean(TestCase): def test_1D_list(self): a = (1,2,3,4) actual = stats.gmean(a) desired = power(1*2*3*4,1./4.) assert_almost_equal(actual, desired,decimal=14) desired1 = stats.gmean(a,axis=-1) assert_almost_equal(actual, desired1, decimal=14) def test_...
class TestGMean(TestCase):
def test_1D_list(self): a = (1,2,3,4) actual = stats.gmean(a) desired = power(1*2*3*4,1./4.) assert_almost_equal(actual, desired,decimal=14) desired1 = stats.gmean(a,axis=-1) assert_almost_equal(actual, desired1, decimal=14) def test_1D_array(self): a = ...
0.16666667])) # test for namedtuple attribute results attributes = ('frequency', 'lowerlimit', 'binsize', 'extrapoints') res = stats.relfreq(a, numbins=4) check_named_results(res, attributes) # check array_like input is accepted relfreqs2, lowlim, binsize, extrapoints = stats.relfreq([1, 4, 2,...
130
130
435
7
123
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestGMean
TestGMean
957
1,000
957
958
6b76e22f04b5521ac1393eb4a3f1574acf7f3de6
bigcode/the-stack
train
9b66e7333dc08bd1ad26376d
train
function
def test_normalitytests(): yield (assert_raises, ValueError, stats.skewtest, 4.) yield (assert_raises, ValueError, stats.kurtosistest, 4.) yield (assert_raises, ValueError, stats.normaltest, 4.) # numbers verified with R: dagoTest in package fBasics st_normal, st_skew, st_kurt = (3.92371918, 1.9807...
def test_normalitytests():
yield (assert_raises, ValueError, stats.skewtest, 4.) yield (assert_raises, ValueError, stats.kurtosistest, 4.) yield (assert_raises, ValueError, stats.normaltest, 4.) # numbers verified with R: dagoTest in package fBasics st_normal, st_skew, st_kurt = (3.92371918, 1.98078826, -0.01403734) pv_n...
)))) # expected values e_nobs, e_minmax = (20, (1.0, 2.0)) e_mean = 1.3999999999999999 e_var = 0.25263157894736848 e_skew = 0.4082482904638634 e_kurt = -1.8333333333333333 # actual values a = stats.describe(x, axis=None) assert_equal(a.nobs, e_n...
211
212
709
6
205
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_normalitytests
test_normalitytests
2,614
2,667
2,614
2,614
c0cd61ca2e4d42160bf77f845330eed97fb04f3b
bigcode/the-stack
train
26a5854a8ad7650b467b5679
train
class
class TestMoments(TestCase): """ Comparison numbers are found using R v.1.5.1 note that length(testcase) = 4 testmathworks comes from documentation for the Statistics Toolbox for Matlab and can be found at both http://www.mathworks.com/access/helpdesk/help/toolbox/stats/kurto...
class TestMoments(TestCase):
""" Comparison numbers are found using R v.1.5.1 note that length(testcase) = 4 testmathworks comes from documentation for the Statistics Toolbox for Matlab and can be found at both http://www.mathworks.com/access/helpdesk/help/toolbox/stats/kurtosis.shtml http://www....
2, -t2, -t2, np.sqrt(3.)], [1.0, -1.0, 1.0, -1.0]] assert_array_almost_equal(z0, z0_expected) assert_array_almost_equal(z1, z1_expected) def test_zscore_ddof(self): # Test use of 'ddof' keyword in zscore. x = np.array([[0.0, 0.0, 1.0, 1.0], ...
256
256
1,616
7
249
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestMoments
TestMoments
1,427
1,555
1,427
1,427
830ff223a0c3ad755b52fdd5636fa4b98a75d175
bigcode/the-stack
train
035b5bced39895cd7aceb677
train
class
class TestVariability(TestCase): testcase = [1,2,3,4] scalar_testcase = 4. def test_signaltonoise(self): # This is not in R, so used: # mean(testcase, axis=0) / (sqrt(var(testcase) * 3/4)) # y = stats.signaltonoise(self.shoes[0]) # assert_approx_equal(y,4.5709967) ...
class TestVariability(TestCase):
testcase = [1,2,3,4] scalar_testcase = 4. def test_signaltonoise(self): # This is not in R, so used: # mean(testcase, axis=0) / (sqrt(var(testcase) * 3/4)) # y = stats.signaltonoise(self.shoes[0]) # assert_approx_equal(y,4.5709967) with warnings.catch_warnings()...
_warnings(): warnings.filterwarnings('ignore', category=RuntimeWarning) vals = stats.mode(arr) assert_equal(vals[0][0], Point(2)) assert_equal(vals[1][0], 4) def test_mode_result_attributes(self): data1 = [3, 5, 1, 10, 23, 3, 2, 6, 8, 6, 10, 6] actual = stat...
256
256
1,607
7
249
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestVariability
TestVariability
1,302
1,424
1,302
1,303
6454036a21313ae7ef85ae9e3a0368d4464c2dda
bigcode/the-stack
train
6f8ce02c08e323fb7a39ae51
train
class
class TestDescribe(TestCase): def test_describe_scalar(self): with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=RuntimeWarning) n, mm, m, v, sk, kurt = stats.describe(4.) assert_equal(n, 1) assert_equal(mm, (4.0, 4.0)) assert_equal(m, ...
class TestDescribe(TestCase):
def test_describe_scalar(self): with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=RuntimeWarning) n, mm, m, v, sk, kurt = stats.describe(4.) assert_equal(n, 1) assert_equal(mm, (4.0, 4.0)) assert_equal(m, 4.0) assert_(np.isnan(...
3,p3 = stats.ttest_1samp(rvn1[0,0,:], 1) assert_array_almost_equal(t1,t2, decimal=14) assert_almost_equal(t1[0,0],t3, decimal=14) assert_equal(t1.shape, (n1,n2)) # test zero division problem with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=RuntimeWarning) t...
256
256
1,201
6
250
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestDescribe
TestDescribe
2,514
2,611
2,514
2,514
0a6932811bcecfea55d926ad85f4c79f82e6919b
bigcode/the-stack
train
9402026da50781ba9dab54b1
train
function
def test_ttest_ind_with_uneq_var(): # check vs. R a = (1, 2, 3) b = (1.1, 2.9, 4.2) pr = 0.53619490753126731 tr = -0.68649512735572582 t, p = stats.ttest_ind(a, b, equal_var=False) assert_array_almost_equal([t,p], [tr, pr]) # test from desc stats API assert_array_almost_equal(stats.t...
def test_ttest_ind_with_uneq_var(): # check vs. R
a = (1, 2, 3) b = (1.1, 2.9, 4.2) pr = 0.53619490753126731 tr = -0.68649512735572582 t, p = stats.ttest_ind(a, b, equal_var=False) assert_array_almost_equal([t,p], [tr, pr]) # test from desc stats API assert_array_almost_equal(stats.ttest_ind_from_stats(*_desc_stats(a, b), ...
, nan_policy='omit'), (0.24779670949091914, 0.80434267337517906)) assert_raises(ValueError, stats.ttest_ind, x, y, nan_policy='raise') assert_raises(ValueError, stats.ttest_ind, x, y, nan_policy='foobar') # test zero division problem t, p = stats.ttest_...
256
256
1,388
17
239
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_ttest_ind_with_uneq_var
test_ttest_ind_with_uneq_var
2,352
2,460
2,352
2,353
afb0628e59d9c6d7767160163224f0895143b27d
bigcode/the-stack
train
80e0279f0af75205c0671243
train
function
def test_binomtest3(): # test added for issue #2384 # test when x == n*p and neighbors res3 = [stats.binom_test(v, v*k, 1./k) for v in range(1, 11) for k in range(2, 11)] assert_equal(res3, np.ones(len(res3), int)) #> bt=c() #> for(i in as.single(1:10)...
def test_binomtest3(): # test added for issue #2384 # test when x == n*p and neighbors
res3 = [stats.binom_test(v, v*k, 1./k) for v in range(1, 11) for k in range(2, 11)] assert_equal(res3, np.ones(len(res3), int)) #> bt=c() #> for(i in as.single(1:10)){for(k in as.single(2:10)){bt = c(bt, binom.test(i-1, k*i,(1/k))$p.value); print(c(i+1, k*i,(1...
7265625,1.0000000,0.7265625,0.2890625, 0.0703125,0.0078125], [0.00390625,0.03906250,0.17968750,0.50781250,1.00000000,1.00000000, 0.50781250,0.17968750,0.03906250,0.00390625], [0.001953125,0.021484375,0.109375000,0.343750000,0.753906250,1.000000000, 0.753906250,0.343750000,0.109375000,0.021484375,...
256
256
2,073
28
228
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_binomtest3
test_binomtest3
3,140
3,221
3,140
3,142
e9269694037612c34d31559fe13c1e57d00a8e32
bigcode/the-stack
train
d0776727756d2300657cd006
train
function
def test_friedmanchisquare(): # see ticket:113 # verified with matlab and R # From Demsar "Statistical Comparisons of Classifiers over Multiple Data Sets" # 2006, Xf=9.28 (no tie handling, tie corrected Xf >=9.28) x1 = [array([0.763, 0.599, 0.954, 0.628, 0.882, 0.936, 0.661, 0.583, ...
def test_friedmanchisquare(): # see ticket:113 # verified with matlab and R # From Demsar "Statistical Comparisons of Classifiers over Multiple Data Sets" # 2006, Xf=9.28 (no tie handling, tie corrected Xf >=9.28)
x1 = [array([0.763, 0.599, 0.954, 0.628, 0.882, 0.936, 0.661, 0.583, 0.775, 1.0, 0.94, 0.619, 0.972, 0.957]), array([0.768, 0.591, 0.971, 0.661, 0.888, 0.931, 0.668, 0.583, 0.838, 1.0, 0.962, 0.666, 0.981, 0.978]), array([0.771, 0.590, 0.968, 0.654, 0.886, 0.916...
34.0, -1.0, 29.5, -0.5, 26.5, 0.0, 24.6, 0.5, 23.4, 0.67, 23.1, 1.0, 22.7, 1.5, 22.6, 2.0, 22.9, 3.0, 24.8, 5.0, 35.5, 10.0, 21.4e1, ]).reshape(-1, 2) for lambda_, expected_stat in table5: stat, p = stats.power_...
256
256
1,081
67
189
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_friedmanchisquare
test_friedmanchisquare
2,064
2,114
2,064
2,068
20087e13bb253a48b70c3420cb170e4ff6491d2d
bigcode/the-stack
train
f1ee4bd70c5bf2ff23ab8448
train
class
class TestThreshold(TestCase): def test_basic(self): a = [-1, 2, 3, 4, 5, -1, -2] with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=DeprecationWarning) assert_array_equal(stats.threshold(a), a) assert_array_equal(stats.threshold(a, 3, None...
class TestThreshold(TestCase):
def test_basic(self): a = [-1, 2, 3, 4, 5, -1, -2] with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=DeprecationWarning) assert_array_equal(stats.threshold(a), a) assert_array_equal(stats.threshold(a, 3, None, 0), ...
accurate numpy.power() implementation. tc_no_mean = self.testcase_moment_accuracy - \ np.mean(self.testcase_moment_accuracy) assert_allclose(np.power(tc_no_mean, 42).mean(), stats.moment(self.testcase_moment_accuracy, 42)) class TestThreshold(TestCase):
64
64
182
6
58
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestThreshold
TestThreshold
1,558
1,569
1,558
1,558
07dcfc1de618ed4d93e7e7f272a6d3f39c1f10de
bigcode/the-stack
train
15027672d714af891ff5f5ee
train
function
def test_kendalltau(): # with some ties x1 = [12, 2, 1, 12, 2] x2 = [1, 4, 7, 1, 0] expected = (-0.47140452079103173, 0.24821309157521476) res = stats.kendalltau(x1, x2) assert_approx_equal(res[0], expected[0]) assert_approx_equal(res[1], expected[1]) # test for namedtuple attribute res...
def test_kendalltau(): # with some ties
x1 = [12, 2, 1, 12, 2] x2 = [1, 4, 7, 1, 0] expected = (-0.47140452079103173, 0.24821309157521476) res = stats.kendalltau(x1, x2) assert_approx_equal(res[0], expected[0]) assert_approx_equal(res[1], expected[1]) # test for namedtuple attribute results attributes = ('correlation', 'pvalu...
, 4.0] yr = [1.0, 2.5, 2.5, 4.0] # Result of spearmanr should be the same as applying # pearsonr to the ranks. sr = stats.spearmanr(x, y) pr = stats.pearsonr(xr, yr) assert_almost_equal(sr, pr) # W.II.E. Tabulate X against X, using BIG as a case weight. The values ...
212
212
707
13
199
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_kendalltau
test_kendalltau
567
620
567
568
dcebd7e9903de0a62b90e1cfb35e04d0f7bdebda
bigcode/the-stack
train
55f187f5862de0153c29ff73
train
class
class TestFOneWay(TestCase): def test_trivial(self): # A trivial test of stats.f_oneway, with F=0. F, p = stats.f_oneway([0,2], [0,2]) assert_equal(F, 0.0) def test_basic(self): # Despite being a floating point calculation, this data should # result in F being exactly 2....
class TestFOneWay(TestCase):
def test_trivial(self): # A trivial test of stats.f_oneway, with F=0. F, p = stats.f_oneway([0,2], [0,2]) assert_equal(F, 0.0) def test_basic(self): # Despite being a floating point calculation, this data should # result in F being exactly 2.0. F, p = stats.f_one...
,-50,3))) fact = 1.8 c, low, upp = stats.sigmaclip(a, fact, fact) assert_(c.min() > low) assert_(c.max() < upp) assert_equal(low, c.mean() - fact*c.std()) assert_equal(upp, c.mean() + fact*c.std()) assert_equal(c, np.linspace(9.5,10.5,11)) def test_sigmaclip_...
186
186
623
8
178
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestFOneWay
TestFOneWay
3,339
3,394
3,339
3,339
b922b50fab1c9d1aea5c8ef6f92a39729ecbc2e9
bigcode/the-stack
train
091c91f0981722b62bc7e3cb
train
function
def test_binomtest(): # precision tests compared to R for ticket:986 pp = np.concatenate((np.linspace(0.1,0.2,5), np.linspace(0.45,0.65,5), np.linspace(0.85,0.95,5))) n = 501 x = 450 results = [0.0, 0.0, 1.0159969301994141e-304, 2.9752418572150531e-275, 7.76683829225352...
def test_binomtest(): # precision tests compared to R for ticket:986
pp = np.concatenate((np.linspace(0.1,0.2,5), np.linspace(0.45,0.65,5), np.linspace(0.85,0.95,5))) n = 501 x = 450 results = [0.0, 0.0, 1.0159969301994141e-304, 2.9752418572150531e-275, 7.7668382922535275e-250, 2.3381250925167094e-099, 7.8284591587323951e-081, 9.9155...
) finally: np.seterr(**olderr) class TestGeoMean(GeoMeanTestCase, TestCase): def do(self, a, b, axis=None, dtype=None): # Note this doesn't test when axis is not specified x = stats.gmean(a, axis=axis, dtype=dtype) assert_almost_equal(b, x) assert_equal(x.dtype,...
103
103
346
18
85
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_binomtest
test_binomtest
3,095
3,114
3,095
3,096
b30277bf9cccfd8346817d44d242ccadb5a46c41
bigcode/the-stack
train
3356f0eae6ebc017ed82b191
train
class
class TestCorrSpearmanrTies(TestCase): """Some tests of tie-handling by the spearmanr function.""" def test_tie1(self): # Data x = [1.0, 2.0, 3.0, 4.0] y = [1.0, 2.0, 2.0, 3.0] # Ranks of the data, with tie-handling. xr = [1.0, 2.0, 3.0, 4.0] yr = [1.0, 2.5, 2.5,...
class TestCorrSpearmanrTies(TestCase):
"""Some tests of tie-handling by the spearmanr function.""" def test_tie1(self): # Data x = [1.0, 2.0, 3.0, 4.0] y = [1.0, 2.0, 2.0, 3.0] # Ranks of the data, with tie-handling. xr = [1.0, 2.0, 3.0, 4.0] yr = [1.0, 2.5, 2.5, 4.0] # Result of spearmanr sho...
assert_approx_equal(r,1.0) def test_spearmanr_result_attributes(self): res = stats.spearmanr(X, X) attributes = ('correlation', 'pvalue') check_named_results(res, attributes) class TestCorrSpearmanrTies(TestCase):
64
64
200
11
53
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestCorrSpearmanrTies
TestCorrSpearmanrTies
540
554
540
540
920def69d8d522722d66e7e3aa1f0eff12bcaba7
bigcode/the-stack
train
35d3e28161d34c1d16b5d8e1
train
class
class HarMeanTestCase: def test_1dlist(self): # Test a 1d list a = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] b = 34.1417152147 self.do(a, b) def test_1darray(self): # Test a 1d array a = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) b = 34.1417152...
class HarMeanTestCase:
def test_1dlist(self): # Test a 1d list a = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] b = 34.1417152147 self.do(a, b) def test_1darray(self): # Test a 1d array a = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) b = 34.1417152147 self.do(a, ...
result = np.array( [[5.41666667, 1.04166667, -0.41666667, 1.04166667, 5.41666667], [21.66666667, 4.16666667, -1.66666667, 4.16666667, 21.66666667]]) assert_array_almost_equal(stats.obrientransform(x1, 2*x1), result, decimal=8) # Example from "O'Brien Test for Homogeneity of Variance" # by ...
256
256
993
6
250
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
HarMeanTestCase
HarMeanTestCase
2,901
2,968
2,901
2,901
aee4abff90553a0a1d2beea75e229b90868976bc
bigcode/the-stack
train
6f2bbba4b2ff8739375b47f3
train
class
class TestMannWhitneyU(TestCase): X = [19.8958398126694, 19.5452691647182, 19.0577309166425, 21.716543054589, 20.3269502208702, 20.0009273294025, 19.3440043632957, 20.4216806548105, 19.0649894736528, 18.7808043120398, 19.3680942943298, 19.4848044069953, 20.7514611265663, 19.0894948874598,...
class TestMannWhitneyU(TestCase):
X = [19.8958398126694, 19.5452691647182, 19.0577309166425, 21.716543054589, 20.3269502208702, 20.0009273294025, 19.3440043632957, 20.4216806548105, 19.0649894736528, 18.7808043120398, 19.3680942943298, 19.4848044069953, 20.7514611265663, 19.0894948874598, 19.4975522356628, 18.997117073427...
.normal(0, 1, 100000) JB1, p1 = stats.jarque_bera(list(x)) JB2, p2 = stats.jarque_bera(tuple(x)) JB3, p3 = stats.jarque_bera(x.reshape(2, 50000)) assert_(JB1 == JB2 == JB3) assert_(p1 == p2 == p3) def test_jarque_bera_size(self): assert_raises(ValueError, stats.jar...
256
256
2,559
10
246
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestMannWhitneyU
TestMannWhitneyU
2,717
2,839
2,717
2,717
286a4424fe89b81e8ebd2f6fc779ed91d35aa309
bigcode/the-stack
train
734f2c095f13f2d3e680ffc4
train
function
def test_skewtest_too_few_samples(): # Regression test for ticket #1492. # skewtest requires at least 8 samples; 7 should raise a ValueError. x = np.arange(7.0) assert_raises(ValueError, stats.skewtest, x)
def test_skewtest_too_few_samples(): # Regression test for ticket #1492. # skewtest requires at least 8 samples; 7 should raise a ValueError.
x = np.arange(7.0) assert_raises(ValueError, stats.skewtest, x)
test_jarque_bera_size(self): assert_raises(ValueError, stats.jarque_bera, []) def test_skewtest_too_few_samples(): # Regression test for ticket #1492. # skewtest requires at least 8 samples; 7 should raise a ValueError.
63
64
64
40
23
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
test_skewtest_too_few_samples
test_skewtest_too_few_samples
2,703
2,707
2,703
2,705
a208ddd81f8c964716864a747b29d8076d135cfa
bigcode/the-stack
train
7902aedf2ea07c4a0904abcd
train
class
class TestCorrPearsonr(TestCase): """ W.II.D. Compute a correlation matrix on all the variables. All the correlations, except for ZERO and MISS, shoud be exactly 1. ZERO and MISS should have undefined or missing correlations with the other variables. The same should go for SPEARMAN corelat...
class TestCorrPearsonr(TestCase):
""" W.II.D. Compute a correlation matrix on all the variables. All the correlations, except for ZERO and MISS, shoud be exactly 1. ZERO and MISS should have undefined or missing correlations with the other variables. The same should go for SPEARMAN corelations, if your program has ...
(x, upperlimit=9, inclusive=False), [8, 7]) assert_equal(stats.tmax(x, axis=1), [1, 3, 5, 7, 9]) assert_equal(stats.tmax(x, axis=None), 9) x = np.arange(10.) x[6] = np.nan assert_equal(stats.tmax(x), np.nan) assert_equal(stats.tmax(x, nan_policy='omit'), 9.) asse...
256
256
1,127
9
247
zeehio/scipy
scipy/stats/tests/test_stats.py
Python
TestCorrPearsonr
TestCorrPearsonr
135
269
135
135
25428f51148ca3a791d70cec85bb7b8ca26a7613
bigcode/the-stack
train