예제 #1
0
 def create():
     pfh = self.test_obs.pipe(pairwise_buffer, ops.map(lambda x: x[0]))
     w = pfh.pipe(
         ops.window(
             self.test_obs.pipe(pairwise_buffer,
                                ops.filter(lambda x: x[0] != x[1]))))
     return w.pipe(ops.flat_map(lambda x: x.pipe(ops.to_list())))
예제 #2
0
 def create():
     def mapper(w, i):
         return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))
     return xs.pipe(
             ops.window(ys),
             ops.map_indexed(mapper),
             ops.merge_all(),
             )
예제 #3
0
파일: test_window.py 프로젝트: wolf937/RxPY
        def create():
            def mapper(w, i):
                return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))

            return xs.pipe(
                ops.window(ys),
                ops.map_indexed(mapper),
                ops.merge_all(),
            )
예제 #4
0
파일: test_window.py 프로젝트: wolf937/RxPY
        def create():
            def closing(x):
                raise Exception(ex)

            def mapper(w, i):
                return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))

            return xs.pipe(
                ops.window(ys, closing),
                ops.map_indexed(mapper),
                ops.merge_all(),
            )
예제 #5
0
파일: test_window.py 프로젝트: wolf937/RxPY
        def create():
            def closing():
                return rx.throw(ex)

            def mapper(w, i):
                return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))

            return xs.pipe(
                ops.window(closing),
                ops.map_indexed(mapper),
                ops.merge_all(),
            )
예제 #6
0
        def create():
            def closing(x):
                raise Exception(ex)

            def mapper(w, i):
                return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))

            return xs.pipe(
                    ops.window(ys, closing),
                    ops.map_indexed(mapper),
                    ops.merge_all(),
                    )
예제 #7
0
        def create():
            def closing():
                return rx.throw(ex)

            def mapper(w, i):
                return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))

            return xs.pipe(
                    ops.window(closing),
                    ops.map_indexed(mapper),
                    ops.merge_all(),
                    )
예제 #8
0
파일: test_window.py 프로젝트: wolf937/RxPY
        def create():
            def closing():
                curr = window[0]
                window[0] += 1
                return rx.timer(curr * 100)

            def mapper(w, i):
                return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))

            return xs.pipe(
                ops.window(closing),
                ops.map_indexed(mapper),
                ops.merge_all(),
            )
예제 #9
0
파일: test_window.py 프로젝트: wolf937/RxPY
        def create():
            def closings():
                w = window[0]
                window[0] += 1
                return rx.timer(w * 100)

            def mapper(w, i):
                return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))

            return xs.pipe(
                ops.window(window_closing_mapper=closings),
                ops.map_indexed(mapper),
                ops.merge_all(),
            )
예제 #10
0
        def create():
            def closing():
                curr = window[0]
                window[0] += 1
                return rx.timer(curr * 100)

            def mapper(w, i):
                return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))

            return xs.pipe(
                    ops.window(closing),
                    ops.map_indexed(mapper),
                    ops.merge_all(),
                    )
예제 #11
0
        def create():
            def closings():
                w = window[0]
                window[0] += 1
                return rx.timer(w * 100)

            def mapper(w, i):
                return w.pipe(ops.map(lambda x: str(i) + ' ' + str(x)))

            return xs.pipe(
                    ops.window(window_closing_mapper=closings),
                    ops.map_indexed(mapper),
                    ops.merge_all(),
                    )
예제 #12
0
파일: buffer.py 프로젝트: wolf937/RxPY
def _buffer(buffer_openings=None,
            buffer_closing_mapper=None) -> Callable[[Observable], Observable]:
    """Projects each element of an observable sequence into zero or more
    buffers.

    Args:
        buffer_openings -- Observable sequence whose elements denote the
            creation of windows.
        buffer_closing_mapper -- [optional] A function invoked to define
            the closing of each produced window. If a closing mapper
            function is specified for the first parameter, this parameter is
            ignored.

    Returns:
        A function that takes an observable source and retuerns an
        observable sequence of windows.
    """

    return pipe(ops.window(buffer_openings, buffer_closing_mapper),
                ops.flat_map(pipe(ops.to_iterable(), ops.map(list))))
예제 #13
0
파일: buffer.py 프로젝트: ReactiveX/RxPY
def _buffer(buffer_openings=None, buffer_closing_mapper=None) -> Callable[[Observable], Observable]:
    """Projects each element of an observable sequence into zero or more
    buffers.

    Args:
        buffer_openings -- Observable sequence whose elements denote the
            creation of windows.
        buffer_closing_mapper -- [optional] A function invoked to define
            the closing of each produced window. If a closing mapper
            function is specified for the first parameter, this parameter is
            ignored.

    Returns:
        A function that takes an observable source and retuerns an
        observable sequence of windows.
    """

    return pipe(
        ops.window(buffer_openings, buffer_closing_mapper),
        ops.flat_map(pipe(ops.to_iterable(), ops.map(list)))
    )
예제 #14
0
def _buffer(boundaries: Observable) -> Callable[[Observable], Observable]:
    return pipe(ops.window(boundaries),
                ops.flat_map(pipe(ops.to_iterable(), ops.map(list))))