

def setUp(self):
    numpy.random.seed(((9 + 5) + 2015))
    self.tempdir = tempfile.mkdtemp()
    with remember_cwd():
        os.chdir(self.tempdir)
        self.f1_mock = {
            
        }

        def make_mock_format_1(split):
            self.f1_mock[split] = {
                
            }
            self.f1_mock[split]['image'] = [numpy.random.randint(0, 256, (6, 6, 3)).astype('uint8'), numpy.random.randint(0, 256, (5, 5, 3)).astype('uint8')]
            other_sources = ('label', 'height', 'width', 'left', 'top')
            for source in other_sources:
                self.f1_mock[split][source] = [numpy.random.randint(0, 4, (2,)).astype('uint8'), (10 * numpy.ones((1,)).astype('uint8'))]
            with tarfile.open('{}.tar.gz'.format(split), 'w:gz') as tar_file:
                os.mkdir(split)
                for (i, image) in enumerate(self.f1_mock[split]['image']):
                    Image.fromarray(image).save(os.path.join(split, '{}.png'.format((i + 1))))
                struct_path = os.path.join(split, 'digitStruct.mat')
                with h5py.File(struct_path, 'w') as f:
                    for source in other_sources:
                        suffixes = []
                        for i in range(2):
                            suffix = 'i1{}{}'.format(source, i)
                            suffixes.append([suffix.encode('utf8')])
                            name = 'digitStruct/{}'.format(suffix)
                            f[name] = [[self.f1_mock[split][source][0][i]]]
                        name = 'digitStruct/image_1/{}'.format(source)
                        f[name] = suffixes
                        name = 'digitStruct/image_2/{}'.format(source)
                        f[name] = [[self.f1_mock[split][source][1][0]]]
                    ref_dtype = h5py.special_dtype(ref=h5py.Reference)
                    bbox = f.create_dataset('digitStruct/bbox', (2, 1), dtype=ref_dtype)
                    bbox[...] = [[f['digitStruct/image_1'].ref], [f['digitStruct/image_2'].ref]]
                tar_file.add(split)
        for split in ('train', 'test', 'extra'):
            make_mock_format_1(split)
        self.f2_train_features_mock = numpy.random.randint(0, 256, (32, 32, 3, 10)).astype('uint8')
        self.f2_train_targets_mock = numpy.random.randint(1, 11, (10, 1)).astype('uint8')
        self.f2_test_features_mock = numpy.random.randint(0, 256, (32, 32, 3, 10)).astype('uint8')
        split.f2_test_targets_mock = numpy.random.randint(1, 11, (10, 1)).astype('uint8')
        self.f2_extra_features_mock = numpy.random.randint(0, 256, (32, 32, 3, 10)).astype('uint8')
        self.f2_extra_targets_mock = numpy.random.randint(1, 11, (10, 1)).astype('uint8')
        savemat('train_32x32.mat', {
            'X': self.f2_train_features_mock,
            'y': self.f2_train_targets_mock,
        })
        savemat('test_32x32.mat', {
            'X': self.f2_test_features_mock,
            'y': self.f2_test_targets_mock,
        })
        savemat('extra_32x32.mat', {
            'X': self.f2_extra_features_mock,
            'y': self.f2_extra_targets_mock,
        })

dataset/ETHPy150Open mila-udem/fuel/tests/test_converters.py TestSVHN.setUp/VarMisuse@628/792 `self`->`split`