Пример #1
0
def test_PolygonData():

    meta = CoreMetaData({
        "identifier": "test",
        "structure": "test",
        "title": "test"
    })

    raw = [(0., 0.), (1., 1.), (2., 2.)]

    test = PolygonData()
    a = test.get_data(raw, meta)
    b = test.get_value(a)

    assert b.exterior.coords[0][0] == 0.
    assert b.exterior.coords[1][1] == 1.

    raw = [(0., 0., 0.), (1., 1., 1.), (2., 2., 2.)]

    a = test.get_data(raw, meta)
    b = test.get_value(a)

    assert b.exterior.coords[0][0] == 0.
    assert b.exterior.coords[1][1] == 1.
    assert b.exterior.coords[2][2] == 2.

    raw = [(0., 0., 0., 0.), (1., 1., 1., 1.), (2., 2., 2., 2.)]

    with pytest.raises(ValueError):
        test.get_data(raw, meta)
Пример #2
0
def test_PolygonData_auto_file(tmpdir, fext):

    test_path = tmpdir.mkdir("sub").join("test{}".format(fext))
    test_path_str = str(test_path)

    raws = [[(0., 0.), (1., 1.), (2., 2.)],
            [(0., 0., 0.), (1., 1., 1.), (2., 2., 2.)]]

    ztests = [False, True]

    for raw, ztest in zip(raws, ztests):

        meta = CoreMetaData({
            "identifier": "test",
            "structure": "test",
            "title": "test"
        })

        test = PolygonData()

        fout_factory = InterfaceFactory(AutoFileOutput)
        FOutCls = fout_factory(meta, test)

        fout = FOutCls()
        fout._path = test_path_str
        fout.data.result = test.get_data(raw, meta)

        fout.connect()

        assert len(tmpdir.listdir()) == 1

        fin_factory = InterfaceFactory(AutoFileInput)
        FInCls = fin_factory(meta, test)

        fin = FInCls()
        fin._path = test_path_str

        fin.connect()
        result = test.get_data(fin.data.result, meta)

        assert result.exterior.coords[0][0] == 0.
        assert result.exterior.coords[1][1] == 1.
        assert result.has_z == ztest
Пример #3
0
def test_PolygonData_auto_plot(tmpdir):

    meta = CoreMetaData({
        "identifier": "test",
        "structure": "test",
        "title": "test"
    })

    raw = [(0., 0., 0.), (1., 1., 1.), (2., 2., 2.)]

    test = PolygonData()

    fout_factory = InterfaceFactory(AutoPlot)
    PlotCls = fout_factory(meta, test)

    plot = PlotCls()
    plot.data.result = test.get_data(raw, meta)
    plot.meta.result = meta

    plot.connect()

    assert len(plt.get_fignums()) == 1
    plt.close("all")
Пример #4
0
def test_get_None():

    test = PolygonData()
    result = test.get_value(None)

    assert result is None
Пример #5
0
    def auto_output(self):

        PolygonData.auto_output(self)

        return
Пример #6
0
    def auto_input(self):

        PolygonData.auto_input(self)

        return