def test_add(self): obj = Summarizer(Summary=Sum) obj.add('A', (12, )) expected = {'A': Sum(contents=np.array((12, )))} self.assertEqual(expected, obj.results()) obj.add('A', (23, )) expected = {'A': Sum(contents=np.array((35, )))} self.assertEqual(expected, obj.results()) obj.add('A', (10, ), weight=2) expected = {'A': Sum(contents=np.array((55, )))} self.assertEqual(expected, obj.results()) obj.add('B', (20, ), weight=3.2) expected = { 'A': Sum(contents=np.array((55, ))), 'B': Sum(contents=np.array((64.0, ))), } self.assertEqual(expected, obj.results()) return
def test_to_tuple_list_key_not_tuple(self): obj = Summarizer(Summary=Sum) obj.add('A', (12, )) # the keys are not a tuple obj.add(2, (20, )) # self.assertEqual([(2, 20), ('A', 12)], obj.to_tuple_list())
def test_to_tuple_list(self): obj = Summarizer(Summary=Sum) obj.add(('A', ), (12, )) obj.add(('B', ), (20, )) self.assertEqual([('A', 12), ('B', 20)], obj.to_tuple_list())