def test_append_pipeline_map2(self): """Test append pipe map opeartion.""" pipeline = Pipeline().append_map(lambda x: x * 2) pipeline2 = Pipeline() \ .append_transform(lambda x: x + 10) \ .append_transform(lambda x: x / 2) pipeline.append_pipe_map(pipeline2) # for each element ((x * 2) + 10) / 2 self.assertEqual(pipeline.feed([10, 20]), [15, 25])
def test_prepend_flatten(self): """Test prepend flatten opeartion.""" pipeline = Pipeline() \ .append_transform(lambda x: x * 3) self.assertEqual(pipeline.feed([[10]]), [[10], [10], [10]]) pipeline.pre_flatten() self.assertEqual(pipeline.feed([[10]]), [10, 10, 10]) pipeline2 = Pipeline() \ .append_transform(lambda x: x + 20) \ .append_transform(lambda x: x / 2) pipeline.append_pipe_map(pipeline2) self.assertEqual(pipeline.feed([[10]]), [15, 15, 15])