MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testZipDataset

Method testZipDataset

tensorflow/python/data/kernel_tests/zip_test.py:33–68  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

31class ZipTest(test_base.DatasetTestBase):
32
33 def testZipDataset(self):
34
35 def dataset_fn(components):
36 datasets = tuple([
37 dataset_ops.Dataset.from_tensor_slices(component)
38 for component in components
39 ])
40 return dataset_ops.Dataset.zip(datasets)
41
42 equal_length_components = [
43 np.tile(np.array([[1], [2], [3], [4]]), 20),
44 np.tile(np.array([[12], [13], [14], [15]]), 22),
45 np.array([37.0, 38.0, 39.0, 40.0])
46 ]
47
48 get_next = self.getNext(dataset_fn(equal_length_components))
49 for i in range(4):
50 results = self.evaluate(get_next())
51 for component, result_component in zip(equal_length_components, results):
52 self.assertAllEqual(component[i], result_component)
53 with self.assertRaises(errors.OutOfRangeError):
54 self.evaluate(get_next())
55 with self.assertRaises(errors.OutOfRangeError):
56 self.evaluate(get_next())
57
58 variable_length_components = [[1, 2, 3, 4], [1, 2, 3, 4, 5], [1.0, 2.0]]
59 get_next = self.getNext(dataset_fn(variable_length_components))
60 for i in range(2):
61 results = self.evaluate(get_next())
62 for component, result_component in zip(variable_length_components,
63 results):
64 self.assertAllEqual(component[i], result_component)
65 with self.assertRaises(errors.OutOfRangeError):
66 self.evaluate(get_next())
67 with self.assertRaises(errors.OutOfRangeError):
68 self.evaluate(get_next())
69
70 def testNestedZipDataset(self):
71

Callers

nothing calls this directly

Calls 6

dataset_fnFunction · 0.85
tileMethod · 0.80
getNextMethod · 0.80
rangeFunction · 0.50
evaluateMethod · 0.45
assertAllEqualMethod · 0.45

Tested by

no test coverage detected