From a69baf639fc27b1e9b3e9aeaa6a4c11adc9fd3e9 Mon Sep 17 00:00:00 2001 From: huzhiqiang <912790387@qq.com> Date: Fri, 11 Oct 2019 10:39:27 +0800 Subject: [PATCH] modify compose en (#20217) * modify compose en * test=develop * test=develop * test=develop * test=develop * test=develop * test=develop * test=develop * test=develop * test=develop * test=develop,test=document_fix * test=develop,test=document_fix --- paddle/fluid/API.spec | 2 +- python/paddle/reader/decorator.py | 31 ++++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index de6e39104cb..7f5db6fb631 100644 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -96,7 +96,7 @@ paddle.fluid.io.DataLoader.from_generator (ArgSpec(args=['feed_list', 'capacity' paddle.fluid.io.cache (ArgSpec(args=['reader'], varargs=None, keywords=None, defaults=None), ('document', '1676886070eb607cb608f7ba47be0d3c')) paddle.fluid.io.map_readers (ArgSpec(args=['func'], varargs='readers', keywords=None, defaults=None), ('document', '2d0903e1d2f00b4f1d6618e6b5310121')) paddle.fluid.io.buffered (ArgSpec(args=['reader', 'size'], varargs=None, keywords=None, defaults=None), ('document', '0d6186f109feceb99f60ec50a0a624cb')) -paddle.fluid.io.compose (ArgSpec(args=[], varargs='readers', keywords='kwargs', defaults=None), ('document', '884291104e1c3f37f33aae44b7deeb0d')) +paddle.fluid.io.compose (ArgSpec(args=[], varargs='readers', keywords='kwargs', defaults=None), ('document', '81c933c8da58041d91f084dcf6322349')) paddle.fluid.io.chain (ArgSpec(args=[], varargs='readers', keywords=None, defaults=None), ('document', 'e0311508658a7e741fc39feea8be0ad2')) paddle.fluid.io.shuffle (ArgSpec(args=['reader', 'buf_size'], varargs=None, keywords=None, defaults=None), ('document', 'e42ea6fee23ce26b23cb142cd1d6522d')) paddle.fluid.io.firstn (ArgSpec(args=['reader', 'n'], varargs=None, keywords=None, defaults=None), ('document', 'c5bb8f7dd4f917f1569a368aab5b8aad')) diff --git a/python/paddle/reader/decorator.py b/python/paddle/reader/decorator.py index eeb2009e60f..b50e66e4c31 100644 --- a/python/paddle/reader/decorator.py +++ b/python/paddle/reader/decorator.py @@ -207,16 +207,29 @@ def compose(*readers, **kwargs): The composed reader will output: (1, 2, 3, 4, 5) - :param readers: readers that will be composed together. - :param check_alignment: if True, will check if input readers are aligned - correctly. If False, will not check alignment and trailing outputs - will be discarded. Defaults to True. - :type check_alignment: bool - - :return: the new data reader. + Args: + readers (Reader|list of Reader): readers that will be composed together. + check_alignment(bool, optional): Indicates whether the input readers are checked for + alignment. If True, whether input readers are aligned + correctly will be checked, else alignment will not be checkout and trailing outputs + will be discarded. Defaults to True. + + Returns: + the new data reader (Reader). + + Raises: + ComposeNotAligned: outputs of readers are not aligned. This will not raise if check_alignment is set to False. + + Examples: + .. code-block:: python - :raises ComposeNotAligned: outputs of readers are not aligned. - Will not raise when check_alignment is set to False. + import paddle.fluid as fluid + def reader_creator_10(dur): + def reader(): + for i in range(10): + yield i + return reader + reader = fluid.io.compose(reader_creator_10(0), reader_creator_10(0)) """ check_alignment = kwargs.pop('check_alignment', True) -- GitLab