Пример #1
0
def test_traverse():
    """To test the traverse implementation we call gc.collect() while instances
    of all the C objects are still valid."""
    acc = iteration_utilities.accumulate([])
    app = iteration_utilities.applyfunc(lambda x: x, 1)
    cha = iteration_utilities.chained(int, float)
    cla = iteration_utilities.clamp([], 0, 1)
    com = iteration_utilities.complement(int)
    con = iteration_utilities.constant(1)
    dee = iteration_utilities.deepflatten([])
    dup = iteration_utilities.duplicates([])
    fli = iteration_utilities.flip(int)
    gro = iteration_utilities.grouper([], 2)
    ine = iteration_utilities.intersperse([], 1)
    iik = iteration_utilities.ItemIdxKey(10, 2)
    ite = iteration_utilities.iter_except(int, TypeError)
    mer = iteration_utilities.merge([])
    nth = iteration_utilities.nth(1)
    pac = iteration_utilities.packed(int)
    par = iteration_utilities.partial(int, 10)
    rep = iteration_utilities.replicate([], 3)
    rou = iteration_utilities.roundrobin([])
    see = iteration_utilities.Seen()
    sid = iteration_utilities.sideeffects([], lambda x: x)
    spl = iteration_utilities.split([], lambda x: True)
    sta = iteration_utilities.starfilter(lambda x: True, [])
    suc = iteration_utilities.successive([])
    tab = iteration_utilities.tabulate(int)
    une = iteration_utilities.unique_everseen([])
    unj = iteration_utilities.unique_justseen([])
    gc.collect()
Пример #2
0
def test_constant_pickle1(protocol):
    x = pickle.dumps(constant(T(10)), protocol=protocol)
    assert pickle.loads(x)() == T(10)
Пример #3
0
def test_constant_failure1():
    # Too few arguments
    with pytest.raises(TypeError):
        constant()
Пример #4
0
def test_constant_normal2():
    one = constant(T(1))
    assert one(10, a=2) == T(1)
Пример #5
0
def test_constant_normal1():
    one = constant(T(1))
    assert one() == T(1)
Пример #6
0
def test_constant_attributes1():
    x = constant(T(2))
    assert x.item == T(2)
Пример #7
0
def test_constant_repr1():
    x = constant(2)
    r = repr(x)
    assert 'constant' in r
    assert '2' in r
Пример #8
0
# Licensed under Apache License Version 2.0 - see LICENSE

from iteration_utilities import constant, nth

__all__ = [
    "return_True", "return_False", "return_None", "first", "second", "third",
    "last"
]

return_True = constant(True)
return_False = constant(False)
return_None = constant(None)

first = nth(0)
second = nth(1)
third = nth(2)
last = nth(-1)