@parameterized.named_parameters(('1', None, np.int32([[1], [2], [3]]), dtypes.bool, [(- 1)]), ('2', None, np.int32([[1], [2], [3]]), dtypes.int32, [(- 1)]), ('3', None, np.int32([[1], [2], [3]]), dtypes.float32, [(- 1)]), ('4', None, np.int32([[1], [2], [3]]), dtypes.string, [(- 1)]), ('5', None, np.int32([[1, 3], [2, 2], [3, 1]]), dtypes.int32, [(- 1), (- 1)]), ('6', None, np.int32([[3, 1, 3], [1, 3, 1]]), dtypes.int32, [(- 1), (- 1), (- 1)]), ('7', (None, None, None), np.int32([[1], [2], [3]]), dtypes.int32, [(- 1)]), ('8', (None, (None, None)), np.int32([[1], [2], [3]]), dtypes.int32, [(- 1)]), ('9', None, np.int32([[1], [2], [3]]), dtypes.int32, [(- 1)]), ('10', None, np.int32([[1], [2], [3]]), dtypes.int32, np.int32([10])))
def testWindowDatasetPaddedBatchDense(self, structure, shapes, dtype, padded_shape):
    'Tests padded batching of dense tensor windows.\n\n    Args:\n      structure: the input structure\n      shapes: the input shapes\n      dtype: the input data type\n      padded_shape: the shape to pad the output to\n    '

    def fn(*args):
        if ((len(args) == 1) and (not isinstance(args[0], tuple))):
            return batching.padded_batch_window(args[0], padded_shape)
        return tuple([(fn(*arg) if isinstance(arg, tuple) else batching.padded_batch_window(arg, padded_shape)) for arg in args])
    dataset = self._structuredRaggedDataset(structure, shapes, dtype).apply(grouping.window_dataset(len(shapes))).apply(grouping._map_x_dataset(fn))
    get_next = dataset.make_one_shot_iterator().get_next()
    with self.cached_session() as sess:
        expected_shape = np.maximum(np.amax(shapes, axis=0), padded_shape)
        expected = sess.run(self._structuredElement(structure, np.concatenate((np.int32([len(shapes)]), expected_shape)), dtype))
        actual = sess.run(get_next)
        self._assertEqual(expected, actual)
Tests padded batching of dense tensor windows.

Args:
  structure: the input structure
  shapes: the input shapes
  dtype: the input data type
  padded_shape: the shape to pad the output to
@parameterized.named_parameters(('1', None, np.int32([[1], [2], [3]]), dtypes.bool, [(- 1)]), ('2', None, np.int32([[1], [2], [3]]), dtypes.int32, [(- 1)]), ('3', None, np.int32([[1], [2], [3]]), dtypes.float32, [(- 1)]), ('4', None, np.int32([[1], [2], [3]]), dtypes.string, [(- 1)]), ('5', None, np.int32([[1, 3], [2, 2], [3, 1]]), dtypes.int32, [(- 1), (- 1)]), ('6', None, np.int32([[3, 1, 3], [1, 3, 1]]), dtypes.int32, [(- 1), (- 1), (- 1)]), ('7', (None, None, None), np.int32([[1], [2], [3]]), dtypes.int32, [(- 1)]), ('8', (None, (None, None)), np.int32([[1], [2], [3]]), dtypes.int32, [(- 1)]), ('9', None, np.int32([[1], [2], [3]]), dtypes.int32, [(- 1)]), ('10', None, np.int32([[1], [2], [3]]), dtypes.int32, np.int32([10])))
def testWindowDatasetPaddedBatchDense(self, structure, shapes, dtype, padded_shape):
    'Tests padded batching of dense tensor windows.\n\n    Args:\n      structure: the input structure\n      shapes: the input shapes\n      dtype: the input data type\n      padded_shape: the shape to pad the output to\n    '

    def fn(*args):
        if ((len(args) == 1) and (not isinstance(args[0], tuple))):
            return batching.padded_batch_window(args[0], padded_shape)
        return tuple([(fn(*arg) if isinstance(arg, tuple) else batching.padded_batch_window(arg, padded_shape)) for arg in args])
    dataset = self._structuredRaggedDataset(structure, shapes, dtype).apply(grouping.window_dataset(len(shapes))).apply(grouping._map_x_dataset(fn))
    get_next = dataset.make_one_shot_iterator().get_next()
    with self.cached_session() as sess:
        expected_shape = np.maximum(np.amax(shapes, axis=0), padded_shape)
        expected = sess.run(self._structuredElement(structure, np.concatenate((np.int32([len(shapes)]), expected_shape)), dtype))
        actual = sess.run(get_next)
        self._assertEqual(expected, actual)