Esempio n. 1
0
    def test_dead_lock_pipesystem(self):

        in_1 = Inlet(convert=False, name="in_1")
        sca = Scaler(scalar=1 / 255)(in_1)
        rot = Rotator([90, -90], remove_padding=False, keep_original=True)(sca)
        out_1 = Outlet(name="out_1")(rot)

        in_2 = Inlet(convert=True, name="in_2")
        cat = Categorizer(sparse=True)(in_2)
        dup = Duplicator()(cat)
        con = Concatenator()(dup)
        out_2 = Outlet(name="out_2")(con)

        dup.add_requirement(
            Requirement(rot, attribute="n_rotations", argument="n_result"))

        rot.add_requirement(
            Requirement(con,
                        attribute="ignore_index",
                        argument="remove_padding"))
        with pytest.raises(AttributeError):
            ps = PipeSystem(inlets=[in_1, in_2],
                            outlets=[out_1, out_2],
                            name="ps",
                            verbose=True)
Esempio n. 2
0
def basic_pipesystem():
    in_1 = Inlet(convert=False, name="in_1")
    out_1 = Outlet(name="out_1")(in_1)

    in_2 = Inlet(convert=True, name="in_2")
    out_2 = Outlet(name="out_2")(in_2)

    return PipeSystem(inlets=[in_1, in_2], outlets=[out_1, out_2], name="ps")
Esempio n. 3
0
    def tests_to_from_config_req(self, complex_pipe_system_req, images,
                                 labels):
        before = complex_pipe_system_req.flow(images, labels)
        after = PipeSystem.from_config(
            complex_pipe_system_req.to_config()).flow(images, labels)

        assert (before[0] == after[0]).all() and (before[1]
                                                  == after[1]).all().all()
Esempio n. 4
0
    def test_give_wrong_pipe_element(self):
        in_1 = Inlet(convert=False, name="in_1")
        out_1 = Outlet(name="out_1")(in_1)

        in_2 = Inlet(convert=True, name="in_2")
        out_2 = PipeElement(name="out_2")(in_2)

        with pytest.raises(TypeError):
            ps = PipeSystem(inlets=[in_1, in_2],
                            outlets=[out_1, out_2],
                            name="ps")
Esempio n. 5
0
def complex_pipesystem():
    in_1 = Inlet(convert=False, name="in_1")
    sca = Scaler(scalar=1 / 255)(in_1)
    rot = Rotator([90, -90], remove_padding=False, keep_original=True)(sca)
    out_1 = Outlet(name="out_1")(rot)

    in_2 = Inlet(convert=True, name="in_2")
    cat = Categorizer(sparse=True)(in_2)
    dup = Duplicator()(cat)
    con = Concatenator()(dup, dup, dup)
    out_2 = Outlet(name="out_2")(con)

    return PipeSystem(inlets=[in_1, in_2], outlets=[out_1, out_2], name="ps")
Esempio n. 6
0
def make_simple_pipesystem():
    in_1 = Inlet(convert=False, name="in_1")
    # sca = Scaler(scalar=1 / 255)(in_1)
    out_1 = Outlet(name="out_1")(in_1)

    in_2 = Inlet(convert=True, name="in_2")
    # cat = Categorizer(sparse=True)(in_2)
    out_2 = Outlet(name="out_2")(in_2)

    return PipeSystem(inlets=[in_1, in_2],
                      outlets=[out_1, out_2],
                      name="ps",
                      verbose=True)
Esempio n. 7
0
    def test_correct_outlets(self, complex_pipesystem):
        in_1 = Inlet(convert=False, name="in_1")
        sca = Scaler(scalar=1 / 255)(in_1)
        rot = Rotator([90, -90], remove_padding=False, keep_original=True)(sca)
        out_1 = Outlet(name="out_1")(rot)

        in_2 = Inlet(convert=True, name="in_2")
        cat = Categorizer(sparse=True)(in_2)
        dup = Duplicator()(cat)
        con = Concatenator()(dup, dup, dup)
        out_2 = Outlet(name="out_2")(con)

        ps = PipeSystem(inlets=[in_1, in_2], outlets=[out_1, out_2], name="ps")
        assert ps.outlets[0] == out_1 and ps.outlets[1] == out_2
Esempio n. 8
0
    def test_mismatch_inlet_outlet(self, complex_pipesystem):
        in_1 = Inlet(convert=False, name="in_1")
        out_1 = Outlet(name="out_1")(in_1)

        in_2 = Inlet(convert=True, name="in_2")
        out_2 = Outlet(name="out_2")(in_2)

        in_3 = Inlet(name="in_3")
        out_3 = Outlet(name="out_3")(in_3)
        ps = PipeSystem(inlets=[in_1, in_2, in_3],
                        outlets=[out_1, out_2, out_3],
                        name="ps")

        with pytest.raises(AttributeError):
            new_ps = ps * complex_pipesystem
Esempio n. 9
0
def pipe_system_and_elements():
    in_1 = Inlet(convert=False, name="in_1")
    sca = Scaler(scalar=1 / 255)(in_1)
    rot = Rotator([90, -90], remove_padding=False, keep_original=True)(sca)
    out_1 = Outlet(name="out_1")(rot)

    in_2 = Inlet(convert=True, name="in_2")
    cat = Categorizer(sparse=True)(in_2)
    dup = Duplicator()(cat)
    con = Concatenator()(dup, dup, dup)
    out_2 = Outlet(name="out_2")(con)

    all_elements = [in_1, sca, rot, out_1, in_2, cat, dup, con, out_2]

    return (
        PipeSystem(inlets=[in_1, in_2], outlets=[out_1, out_2], name="ps"),
        all_elements,
    )
Esempio n. 10
0
def complex_pipe_system_req():
    in_1 = Inlet(convert=False, name="in_1")
    sca = Scaler(scalar=1 / 255)(in_1)
    rot = Rotator([90, -90], remove_padding=False, keep_original=True)(sca)
    out_1 = Outlet(name="out_1")(rot)

    in_2 = Inlet(convert=True, name="in_2")
    cat = Categorizer(sparse=True)(in_2)
    dup = Duplicator()(cat)
    con = Concatenator()(dup)
    out_2 = Outlet(name="out_2")(con)

    dup.add_requirement(
        Requirement(rot, attribute="n_rotations", argument="n_result"))

    return PipeSystem(inlets=[in_1, in_2],
                      outlets=[out_1, out_2],
                      name="ps",
                      verbose=True)
Esempio n. 11
0
    def test_order(self):
        in_1 = Inlet(convert=False, name="in_1")
        sca = Scaler(scalar=1 / 255)(in_1)
        rot = Rotator([90, -90], remove_padding=False, keep_original=True)(sca)
        out_1 = Outlet(name="out_1")(rot)

        in_2 = Inlet(convert=True, name="in_2")
        cat = Categorizer(sparse=True)(in_2)
        dup = Duplicator()(cat)
        con = Concatenator()(dup)
        out_2 = Outlet(name="out_2")(con)

        dup.add_requirement(
            Requirement(rot, attribute="n_rotations", argument="n_result"))

        ps = PipeSystem(inlets=[in_1, in_2],
                        outlets=[out_1, out_2],
                        name="ps",
                        verbose=True)
        assert ps.execution_sequence.index(dup) > ps.execution_sequence.index(
            rot)
Esempio n. 12
0
def complex_pipesystem_json():
    return PipeSystem.from_json(json_file_name=PS_COMPLEX_PATH)
Esempio n. 13
0
def basic_pipesystem_json():
    return PipeSystem.from_json(json_file_name=PS_SIMPLE_PATH)
Esempio n. 14
0
def dupe_pipe_invalid():
    in_1 = Inlet(convert=True, name="in_2")
    x = Duplicator(n_result=3)(in_1)
    x = Concatenator(axis=1)(x, x)
    out_1 = Outlet(name="out_2")(x)
    return PipeSystem(inlets=[in_1], outlets=[out_1])