コード例 #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
ファイル: _brillouinzone_apply.py プロジェクト: bosonie/sisl
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
ファイル: _brillouinzone_apply.py プロジェクト: bosonie/sisl
 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