Beispiel #1
0
    def testPipeline(self):
        """Test for `Pipeline` pipe"""

        # Dumb filters for testing
        def mult2(stream):
            """Dumb filter that multiply stream data by two"""
            for data in stream:
                yield data*2

        def add3(stream):
            """Dumb filter that add three to stream data"""
            for data in stream:
                yield data+3

        # Create pipeline
        pipeline = Pipeline()
        pipeline.append(mult2)
        pipeline.append(add3)

        # Exec pipeline using xrange iterator as input data
        result = pipeline(xrange(3))

        # Check pipeline result
        self.assertListEqual(result, [3,5,7])
Beispiel #2
0
    def testVectorizable_data(self):
        """Test for `vectorizable` decorator"""

        # Dumb filters for testing
        @vectorizable
        def mult2(data):
            """Dumb filter that multiply data by two"""
            return data*2

        @vectorizable
        def add3(data):
            """Dumb filter that add three to data"""
            return data+3

        # Create pipeline
        pipeline = Pipeline()
        pipeline.append(mult2)
        pipeline.append(add3)

        # Exec pipeline using xrange iterator as input data
        result = pipeline(3)

        # Check pipeline result
        self.assertEqual(result, 9)
Beispiel #3
0
import sys, os
sys.path.append(os.path.realpath('.'))
from pypeline import Pipeline
sys.argv = ['pypeline/Pipeline.py', '-f', './pipeline.yaml']
Pipeline.main()