Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ianj-als/pypeline.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Johnson <ian.johnson@appliedlanguage.com>2013-03-14 21:22:33 +0400
committerIan Johnson <ian.johnson@appliedlanguage.com>2013-03-14 21:22:33 +0400
commit8ca8954d3cbfac0227740c6005f98e3c2cdfdb65 (patch)
tree67a936e86080efcf3f1af46d968b3a03b7e8dd20
parent67c1f446a17fd7111fa4ad2cad9078a80ce31194 (diff)
Fixed bug in parallel wire construction function.
-rw-r--r--setup.py2
-rw-r--r--src/pypeline/helpers/helpers.py1
-rw-r--r--src/pypeline/helpers/parallel_helpers.py12
-rw-r--r--src/pypeline/helpers/tests/parallel_helper_pipeline_tests.py14
4 files changed, 16 insertions, 13 deletions
diff --git a/setup.py b/setup.py
index dcc18a1..30ce627 100644
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@ from setuptools import setup, find_packages
setup(
name = "pypeline",
- version = "0.2",
+ version = "0.2.1",
packages = find_packages("src", exclude = ["*tests"]),
package_dir = {'': 'src'},
diff --git a/src/pypeline/helpers/helpers.py b/src/pypeline/helpers/helpers.py
index 61085d8..47ce878 100644
--- a/src/pypeline/helpers/helpers.py
+++ b/src/pypeline/helpers/helpers.py
@@ -119,4 +119,3 @@ def exec_pipeline(state_monad, state):
def get_dictionary_conversion_function(conversions):
"""Returns a function that completes the dictionary conversions as part of a wire."""
return lambda a, _: {conversions[key]: a[key] for key in conversions}
-
diff --git a/src/pypeline/helpers/parallel_helpers.py b/src/pypeline/helpers/parallel_helpers.py
index 9a49ed3..a47e85a 100644
--- a/src/pypeline/helpers/parallel_helpers.py
+++ b/src/pypeline/helpers/parallel_helpers.py
@@ -78,17 +78,7 @@ def cons_wire(schema_conv_function):
def cons_dictionary_wire(conversions):
"""Construct a wire that converts between two dictionaries. The keys of the conversions dictionary are keys in the output dictionary, of the preceeding component, whose values will be used to populate a dictionary whose keys are the value of the conversions dictionary.\n\nE.g., output = {'int': 9, 'string': 'hello'}, and conversions = {'int': 'int_two', 'string': 'string_two'}, yields an input dictionary, to the next component, input = {'int_two': 9, 'string_two': 'hello'}."""
- def get_dictionary_wire_wrapper(conversion_function):
- def dictionary_wire_wrapper(f, s):
- new_value = conversion_function(f.result(), None)
- nf = Future()
- nf.set_result(new_value)
- return nf
-
- return dictionary_wire_wrapper
-
- function = helpers.get_dictionary_conversion_function(conversions)
- return helpers.cons_dictionary_wire(get_dictionary_conversion_function(function))
+ return cons_wire(helpers.get_dictionary_conversion_function(conversions))
def cons_split_wire():
diff --git a/src/pypeline/helpers/tests/parallel_helper_pipeline_tests.py b/src/pypeline/helpers/tests/parallel_helper_pipeline_tests.py
index c148a9b..c16c892 100644
--- a/src/pypeline/helpers/tests/parallel_helper_pipeline_tests.py
+++ b/src/pypeline/helpers/tests/parallel_helper_pipeline_tests.py
@@ -135,3 +135,17 @@ class ParallelPypelineHelperUnitTest(unittest.TestCase):
result = ParallelPypelineHelperUnitTest.test(1, pipeline, value, state, exec_pipeline)
target = state_func(state)
self.assertEquals(target, result)
+
+
+ def test_parallel_wire(self):
+ value = {'PI' : 3.141, 'E' : 2.718}
+ pipeline = cons_wire(lambda a, s: {'pi' : a['PI'], 'e' : a['E']})
+ result = ParallelPypelineHelperUnitTest.test(1, pipeline, value, None, eval_pipeline)
+ self.assertEquals({'pi' : 3.141, 'e' : 2.718}, result)
+
+
+ def test_parallel_dictionary_wire(self):
+ value = {'pi' : 3.141, 'e' : 2.718}
+ pipeline = cons_dictionary_wire({'pi' : 'PI', 'e' : 'E'})
+ result = ParallelPypelineHelperUnitTest.test(1, pipeline, value, None, eval_pipeline)
+ self.assertEquals({'PI' : 3.141, 'E' : 2.718}, result)