コード例 #1
0
def merge_sort(unsorted):
    global app_count
    print "sorting %d unsorted files" % (len(unsorted))
    # Sort all the individual files
    sorted = [sort(f) for f in unsorted]
    app_count += len(sorted)
    return treereduce(merge, sorted)

    # Note: could also code as below:.
    # Merge them all hierarchically
    """
コード例 #2
0
ファイル: mergesort.py プロジェクト: horacepan/pydflow
def merge_sort(unsorted):
    global app_count
    print "sorting %d unsorted files" % (len(unsorted))
    # Sort all the individual files
    sorted = [sort(f) for f in unsorted]
    app_count += len(sorted)
    return treereduce(merge, sorted)

    # Note: could also code as below:.
    # Merge them all hierarchically
    """
コード例 #3
0
ファイル: TestReduce.py プロジェクト: horacepan/pydflow
 def testSum(self):
     import random
     nums, boundnums = red.genlist()
     tot = sum(nums)
     print "Total of %s is %d" % (repr(nums), tot)
     
     treeres = treereduce(red.add, boundnums).get()
     print "treereduce(add, bound).get() = %d" % treeres
 
     dynres = dynreduce(red.add, boundnums).get()
     print "dynreduce(add, bound).get() = %d" % dynres
     
     self.assertEqual(treeres, tot)
     self.assertEqual(dynres, tot)
コード例 #4
0
ファイル: TestReduce.py プロジェクト: plb-formation/pydflow
    def testSum(self):
        import random
        nums, boundnums = red.genlist()
        tot = sum(nums)
        print "Total of %s is %d" % (repr(nums), tot)

        treeres = treereduce(red.add, boundnums).get()
        print "treereduce(add, bound).get() = %d" % treeres

        dynres = dynreduce(red.add, boundnums).get()
        print "dynreduce(add, bound).get() = %d" % dynres

        self.assertEqual(treeres, tot)
        self.assertEqual(dynres, tot)
コード例 #5
0
ファイル: TestReduce.py プロジェクト: horacepan/pydflow
 def testAssociative(self):
     """
     Test reductions which are associative
     """
     import itertools
     str = ["aaa", "bb", "c", "dd", "e", "fff"]
     bound = map(String, str)
     exp = ''.join(str)
     
     
     @func((String),(String, String))
     def concat(a, b):
         return a + b
     foldres = foldl(concat, String(""), bound).get()
     
     treeres = treereduce(concat, bound).get()
     self.assertEquals(exp, foldres)
     self.assertEquals(exp, treeres)
コード例 #6
0
ファイル: TestReduce.py プロジェクト: plb-formation/pydflow
    def testAssociative(self):
        """
        Test reductions which are associative
        """
        import itertools
        str = ["aaa", "bb", "c", "dd", "e", "fff"]
        bound = map(String, str)
        exp = ''.join(str)

        @func((String), (String, String))
        def concat(a, b):
            return a + b

        foldres = foldl(concat, String(""), bound).get()

        treeres = treereduce(concat, bound).get()
        self.assertEquals(exp, foldres)
        self.assertEquals(exp, treeres)