Example #1
0
def test_countby():
    assert countby(iseven, [1, 2, 3]) == {True: 1, False: 2}
    assert countby(len, ['cat', 'dog', 'mouse']) == {3: 2, 5: 1}
    assert countby(0, ('ab', 'ac', 'bc')) == {'a': 2, 'b': 1}
    assert countby([0], ('ab', 'ac', 'bc')) == {('a',): 2, ('b',): 1}
    assert countby([0, 0], ('ab', 'ac', 'bc')) == {('a', 'a'): 2, ('b', 'b'): 1}
Example #2
0
def test_countby():
    assert countby(iseven, [1, 2, 3]) == {True: 1, False: 2}
    assert countby(len, ['cat', 'dog', 'mouse']) == {3: 2, 5: 1}
Example #3
0
def test_countby():
    assert countby(iseven, [1, 2, 3]) == {True: 1, False: 2}
    assert countby(len, ['cat', 'dog', 'mouse']) == {3: 2, 5: 1}
def test_countby():
    assert countby(iseven, [1, 2, 3]) == {True: 1, False: 2}
    assert countby(len, ["cat", "dog", "mouse"]) == {3: 2, 5: 1}
    assert countby(0, ("ab", "ac", "bc")) == {"a": 2, "b": 1}
Example #5
0
 def count_by(self, key=cytoolz.functoolz.identity):
     return fdict(cytoolz.countby(key, self))
Example #6
0
def test_countby():
    assert countby(iseven, [1, 2, 3]) == {True: 1, False: 2}
    assert countby(len, ['cat', 'dog', 'mouse']) == {3: 2, 5: 1}
    assert countby(0, ('ab', 'ac', 'bc')) == {'a': 2, 'b': 1}