Skip to content

Commit

Permalink
Closes #22
Browse files Browse the repository at this point in the history
  • Loading branch information
elias committed Apr 29, 2009
1 parent 3069d0e commit 07c88b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dumbo/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def combiner(key_, values):

def statsreducer(key, values):
columns = iizip(*values)
s0 = sum(columns.next()) # n
s0 = float(sum(columns.next())) # n
s1 = sum(columns.next()) # sum(x)
s2 = sum(columns.next()) # sum(x**2)
minimum = min(columns.next())
Expand Down
8 changes: 4 additions & 4 deletions tests/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
class TestLib(unittest.TestCase):

def teststats(self):
input = [('testkey',i) for i in xrange(3)]
input = [('testkey',i) for i in xrange(10)]
input = core.itermapred(input, lib.identitymapper, lib.statscombiner)
output = dict(core.itermapred(input, lib.identitymapper, lib.statsreducer))
self.assertEqual(output['testkey'][0], 3) # n
self.assertEqual(output['testkey'][1], 1) # mean
self.assertEqual(output['testkey'][2], 1.0) # std
self.assertEqual(output['testkey'][0], 10) # n
self.assertEqual(output['testkey'][1], 4.5) # mean
self.assertAlmostEqual(output['testkey'][2], 3.02765035409749) # std

if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(TestMapReduce)
Expand Down

0 comments on commit 07c88b9

Please sign in to comment.