

def test_countby(self):
    parity = _.countBy([1, 2, 3, 4, 5], (lambda num, *args: ((num % 2) == 0)))
    self.assertEqual(parity[True], 2)
    self.assertEqual(parity[False], 3)
    self.assertEqual(_.countBy([1], (lambda num, *args: num)), 1)
    llist = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']
    grouped = _.countBy(llist, (lambda x, *args: len(x)))
    self.assertEqual(grouped[3], 4)
    self.assertEqual(grouped[4], 3)
    self.assertEqual(grouped[5], 3)

dataset/ETHPy150Open serkanyersen/underscore.py/tests/test_collections.py TestCollections.test_countby/original