예제 #1
0
파일: test_oplist.py 프로젝트: silsgs/sisl
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
파일: test_oplist.py 프로젝트: silsgs/sisl
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
파일: test_oplist.py 프로젝트: silsgs/sisl
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
파일: test_oplist.py 프로젝트: silsgs/sisl
 def my_func():
     return oplist([1, 2])
예제 #5
0
파일: test_oplist.py 프로젝트: silsgs/sisl
def test_oplist_fail_imath(op):
    l1 = oplist([1, 2])
    l2 = [1, 2, 3]
    op(l1, l2)
예제 #6
0
파일: test_oplist.py 프로젝트: silsgs/sisl
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