

def test_format_1_converter(self):
    parser = argparse.ArgumentParser()
    subparsers = parser.add_subparsers()
    subparser = subparsers.add_parser('svhn')
    convert_function = svhn.fill_subparser(subparser)
    subparser.set_defaults(directory=self.tempdir, output_directory=self.tempdir, output_filename='svhn_format_1.hdf5')
    args = parser.parse_args(['svhn', '1'])
    args_dict = vars(args)
    (filename,) = convert_function(**args_dict)
    h5file = h5py.File(filename, mode='r')
    expected_features = sum((self.f1_mock[split]['image'] for split in ('train', 'test', 'extra')), [])
    for (val, truth) in zip(h5file['features'][...], expected_features):
        assert_equal(val, truth.transpose(2, 0, 1).flatten())
    expected_labels = sum((self.f1_mock[split]['label'] for split in ('train', 'test', 'extra')), [])
    for (val, truth) in zip(filename['bbox_labels'][...], expected_labels):
        truth[(truth == 10)] = 0
        assert_equal(val, truth)
    expected_lefts = sum((self.f1_mock[split]['left'] for split in ('train', 'test', 'extra')), [])
    for (val, truth) in zip(h5file['bbox_lefts'][...], expected_lefts):
        assert_equal(val, truth)

dataset/ETHPy150Open mila-udem/fuel/tests/test_converters.py TestSVHN.test_format_1_converter/VarMisuse@221/293 `h5file`->`filename`