Beispiel #1
0
def test_throw_if_unsufficient_version():
    scop = Scoping()
    ids = range(1, int(2e6))
    with pytest.raises(dpf_errors.DpfVersionNotSupported):
        scop.ids = ids
    ids = range(1, int(3e6))
    with pytest.raises(dpf_errors.DpfVersionNotSupported):
        scop.ids = ids
    ids = range(1, 2000)
    scop.ids = ids
    ids_check = scop.ids
    assert np.allclose(ids, ids_check)
Beispiel #2
0
def elshape_body_sc():
    """Returns a scopings continer with 20 scoping split on body and elshape"""
    sc = ScopingsContainer()
    sc.labels = ["elshape", "body"]
    for i in range(0, 20):
        mscop = {"elshape": i + 1, "body": 0}
        scop = Scoping()
        scop.ids = range(0, i + 1)
        sc.add_scoping(mscop, scop)
    return sc
Beispiel #3
0
def test_set_get_entity_data_scoping():
    scop = Scoping()
    ids = [1, 2, 3, 5, 8, 9, 10]
    scop.ids = ids
    scop.set_id(0, 11)
    assert scop._get_id(0) == 11
    assert scop._get_index(11) == 0
    scop.set_id(1, 12)
    assert scop._get_id(1) == 12
    assert scop._get_index(12) == 1
Beispiel #4
0
def test_set_get_scoping_scopings_container_new_label(elshape_body_sc):
    sc = elshape_body_sc
    assert sc.get_available_ids_for_label("elshape") == list(range(1, 21))
    for i in range(0, 20):
        scopingid = sc.get_scoping({"elshape": i + 1, "body": 0})._message.id
        assert scopingid != 0
        assert sc.get_scoping(i)._message.id != 0
        assert sc.get_scoping({"elshape": i + 1, "body": 0})._message.id != 0
        assert sc[i]._message.id != 0
        assert sc.get_label_space(i) == {"elshape": i + 1, "body": 0}
        assert sc.get_scoping({
            "elshape": i + 1,
            "body": 0
        }).ids == list(range(0, i + 1))
    sc.add_label("time")
    for i in range(0, 20):
        mscop = {"elshape": i + 1, "body": 0, "time": 1}
        scop = Scoping()
        scop.ids = range(0, i + 10)
        sc.add_scoping(mscop, scop)
    assert len(sc.get_scopings({"elshape": i + 1, "body": 0})) == 2
    for i in range(0, 20):
        scopingid = sc.get_scoping({
            "elshape": i + 1,
            "body": 0,
            "time": 1
        })._message.id
        assert scopingid != 0
        assert sc.get_scoping(i + 20)._message.id != 0
        assert sc[i]._message.id != 0
        assert sc.get_label_space(i + 20) == {
            "elshape": i + 1,
            "body": 0,
            "time": 1
        }
        assert sc.get_scoping({
            "elshape": i + 1,
            "body": 0,
            "time": 1
        }).ids == list(range(0, i + 10))
        assert sc.get_scoping({
            "elshape": i + 1,
            "time": 1
        }).ids == list(range(0, i + 10))
Beispiel #5
0
def test_iter_scoping():
    scop = Scoping()
    ids = [1, 2, 3, 5, 8, 9, 10]
    scop.ids = ids
    for i, id in enumerate(scop):
        assert id == ids[i]
Beispiel #6
0
def test_print_scoping():
    scop = Scoping()
    ids = [1, 2, 3, 5, 8, 9, 10]
    scop.ids = ids
    print(scop)
Beispiel #7
0
def test_count_scoping():
    scop = Scoping()
    ids = [1, 2, 3, 5, 8, 9, 10]
    scop.ids = ids
    assert scop._count() == len(ids)
Beispiel #8
0
def test_set_get_ids_long_scoping():
    scop = Scoping()
    ids = range(1, 1000000)
    scop.ids = ids
    assert np.allclose(scop.ids, ids)
Beispiel #9
0
def test_set_get_ids_scoping():
    scop = Scoping()
    ids = [1, 2, 3, 5, 8, 9, 10]
    scop.ids = ids
    assert scop.ids == ids