示例#1
0
def test_oplist_creation():
    l = oplist(range(10))
    assert len(l) == 10
    l = oplist([1, 2])
    assert len(l) == 2
    l = oplist((1, 2))
    assert len(l) == 2
    assert l[0] == 1
    assert l[1] == 2
示例#2
0
def test_oplist_imath(op, key):
    d = {
        1: oplist([ar.aranged(1, 10), ar.aranged(1, 10)]),
        2: 2,
    }

    l2 = d[key]
    try:
        l1 = oplist([data * 2 for data in l2])
    except:
        l1 = oplist([ar.aranged(1, 10), ar.aranged(2, 3)])
    op(l1, l2)
示例#3
0
def test_oplist_math(op, key1, key2):
    d = {
        1: oplist([ar.aranged(1, 10), ar.aranged(1, 10)]),
        2: 2,
    }

    l1 = d[key1]
    l2 = d[key2]
    op(l1, l2)
示例#4
0
 def my_func():
     return oplist([1, 2])
示例#5
0
def test_oplist_fail_imath(op):
    l1 = oplist([1, 2])
    l2 = [1, 2, 3]
    op(l1, l2)
示例#6
0
def test_oplist_fail_rmath(op):
    l1 = oplist([1, 2])
    l2 = [1, 2, 3]
    op(l2, l1)
示例#7
0
def test_oplist_fail_imath(op):
    l1 = oplist([1, 2])
    l2 = [1, 2, 3]
    with pytest.raises(ValueError):
        op(l1, l2)
示例#8
0
def test_oplist_single(op):
    d = oplist([ar.aranged(1, 10), ar.aranged(1, 10)])
    op(d)
示例#9
0
def _asoplist(arg):
    if isinstance(arg, tuple):
        return oplist(arg)
    elif isinstance(arg, list) and not isinstance(arg, oplist):
        return oplist(arg)
    return arg
示例#10
0
 def func(*args, **kwargs):
     return oplist(v for v in iter_func(*args, **kwargs))
示例#11
0
def _asoplist(arg):
    if isinstance(arg, (tuple, list)) and not isinstance(arg, oplist):
        return oplist(arg)
    return arg