def test_serialize_round_trip_no_parse(self):
    np.random.seed(1)
    raw_data = create_random_data(10)
    tfexamples = list(map(preprocessing.make_tf_example, *zip(*raw_data)))
    with tempfile.NamedTemporaryFile() as start_file, tempfile.NamedTemporaryFile() as rewritten_file:
        preprocessing.write_tf_examples(start_file.name, tfexamples)
        batch_size = 4
        batches = list(preprocessing.shuffle_tf_examples(1000, batch_size, [start_file.name]))
        self.assertEqual(len(batches), 3)
        all_batches = list(itertools.chain.from_iterable(batches))
        for _ in batches:
            preprocessing.write_tf_examples(rewritten_file.name, all_batches, serialize=False)
        original_data = self.extract_data(start_file.name)
        recovered_data = self.extract_data(rewritten_file.name)

    def sort_key(nparray_tuple):
        return nparray_tuple[2]
    original_data = sorted(original_data, key=sort_key)
    recovered_data = sorted(recovered_data, key=sort_key)
    self.assertEqualData(original_data, recovered_data)
def test_serialize_round_trip_no_parse(self):
    np.random.seed(1)
    raw_data = create_random_data(10)
    tfexamples = list(map(preprocessing.make_tf_example, *zip(*raw_data)))
    with tempfile.NamedTemporaryFile() as start_file, tempfile.NamedTemporaryFile() as rewritten_file:
        preprocessing.write_tf_examples(start_file.name, tfexamples)
        batch_size = 4
        batches = list(preprocessing.shuffle_tf_examples(1000, batch_size, [start_file.name]))
        self.assertEqual(len(batches), 3)
        all_batches = list(itertools.chain.from_iterable(batches))
        for _ in batches:
            preprocessing.write_tf_examples(rewritten_file.name, all_batches, serialize=False)
        original_data = self.extract_data(start_file.name)
        recovered_data = self.extract_data(rewritten_file.name)

    def sort_key(nparray_tuple):
        return nparray_tuple[2]
    original_data = sorted(original_data, key=sort_key)
    recovered_data = sorted(recovered_data, key=sort_key)
    self.assertEqualData(original_data, recovered_data)