Exemple #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}
Exemple #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}
Exemple #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}
Exemple #5
0
 def count_by(self, key=cytoolz.functoolz.identity):
     return fdict(cytoolz.countby(key, self))
Exemple #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}