@parameterized.named_parameters(('1', None, np.int32([]), dtypes.bool), ('2', None, np.int32([]), dtypes.int32), ('3', None, np.int32([]), dtypes.float32), ('4', None, np.int32([]), dtypes.string), ('5', None, np.int32([2]), dtypes.int32), ('6', None, np.int32([2, 2]), dtypes.int32), ('7', (None, None, None), np.int32([]), dtypes.int32), ('8', (None, (None, None)), np.int32([]), dtypes.int32))
def testWindowDatasetFlatMap(self, structure, shape, dtype):
    'Tests windowing by chaining it with flat map.\n\n    Args:\n      structure: the input structure\n      shape: the input shape\n      dtype: the input data type\n    '

    def fn(*args):
        if ((len(args) == 1) and (not isinstance(args[0], tuple))):
            return args[0]
        return dataset_ops.Dataset.zip(tuple([(fn(*arg) if isinstance(arg, tuple) else arg) for arg in args]))
    dataset = self._structuredDataset(structure, shape, dtype).repeat(5).apply(grouping.window_dataset(5)).flat_map(fn)
    get_next = dataset.make_one_shot_iterator().get_next()
    with self.cached_session() as sess:
        expected = sess.run(self._structuredElement(structure, shape, dtype))
        for _ in range(5):
            actual = sess.run(get_next)
            self._assertEqual(expected, actual)
Tests windowing by chaining it with flat map.

Args:
  structure: the input structure
  shape: the input shape
  dtype: the input data type
@parameterized.named_parameters(('1', None, np.int32([]), dtypes.bool), ('2', None, np.int32([]), dtypes.int32), ('3', None, np.int32([]), dtypes.float32), ('4', None, np.int32([]), dtypes.string), ('5', None, np.int32([2]), dtypes.int32), ('6', None, np.int32([2, 2]), dtypes.int32), ('7', (None, None, None), np.int32([]), dtypes.int32), ('8', (None, (None, None)), np.int32([]), dtypes.int32))
def testWindowDatasetFlatMap(self, structure, shape, dtype):
    'Tests windowing by chaining it with flat map.\n\n    Args:\n      structure: the input structure\n      shape: the input shape\n      dtype: the input data type\n    '

    def fn(*args):
        if ((len(args) == 1) and (not isinstance(args[0], tuple))):
            return args[0]
        return dataset_ops.Dataset.zip(tuple([(fn(*arg) if isinstance(arg, tuple) else arg) for arg in args]))
    dataset = self._structuredDataset(structure, shape, dtype).repeat(5).apply(grouping.window_dataset(5)).flat_map(fn)
    get_next = dataset.make_one_shot_iterator().get_next()
    with self.cached_session() as sess:
        expected = sess.run(self._structuredElement(structure, shape, dtype))
        for _ in range(5):
            actual = sess.run(get_next)
            self._assertEqual(expected, actual)