示例#1
0
    def test_figure_io(self):
        vpl.close()
        self.assertIs(vpl.gcf(False), None)

        vpl.auto_figure(False)
        self.assertIs(vpl.gcf(), None)

        with self.assertRaises(vpl.figures.figure_manager.NoFigureError):
            vpl.screenshot_fig()

        fig = vpl.figure()
        self.assertIs(vpl.gcf(), None)
        del fig

        vpl.auto_figure(True)
        fig = vpl.gcf()
        self.assertTrue(fig is not None)

        self.assertIs(fig, vpl.gcf())
        vpl.close()
        self.assertIs(vpl.gcf(False), None)
        vpl.scf(fig)
        self.assertIs(fig, vpl.gcf())

        vpl.close()
        fig = vpl.figure()
        self.assertIs(fig, vpl.gcf())
        vpl.close()
示例#2
0
def test_figure_io():
    vpl.close()
    assert vpl.gcf(False) is None

    vpl.auto_figure(False)
    assert vpl.gcf() is None

    with pytest.raises(vpl.figures.figure_manager.NoFigureError):
        vpl.screenshot_fig()

    fig = vpl.figure()
    assert vpl.gcf() is None
    del fig

    vpl.auto_figure(True)
    fig = vpl.gcf()
    assert fig is not None

    assert fig is vpl.gcf()
    vpl.close()
    assert vpl.gcf(False) is None
    vpl.scf(fig)
    assert fig is vpl.gcf()

    vpl.close()
    fig = vpl.figure()
    assert fig is vpl.gcf()
    vpl.close()
示例#3
0
def test_view():
    vpl.auto_figure(True)
    vpl.close()
    grads = np.array(vpl.geometry.orthogonal_bases(np.random.rand(3)))
    point = np.random.uniform(-10, 10, 3)
    vpl.quiver(np.broadcast_to(point, (3, 3)), grads, color=np.eye(3))

    vpl.view(focal_point=point, camera_position=point - grads[0],
             up_view=grads[1])
    vpl.reset_camera()

    vpl.text("Should be looking in the direction of the red arrow, "
             "with the green arrow pointing up")
    # Linux seems to need an extra prod to render this for some reason.
    vpl.show(block=False)
示例#4
0
    def test_multi_figures(self):
        vpl.close()

        vpl.auto_figure(False)

        plot = vpl.plot(np.random.uniform(-10, 10, (10, 3)), join_ends=True)
        figs = []
        for i in range(1, 4):
            fig = vpl.figure("figure {}".format(i))
            fig += plot
            vpl.view(camera_direction=np.random.uniform(-1, 1, 3), fig=fig)
            vpl.reset_camera(fig)

            fig.show(False)
            figs.append(fig)
        fig.show()

        vpl.auto_figure(True)
示例#5
0
    def test_view(self):
        vpl.auto_figure(True)
        vpl.close()
        grads = np.array(vpl.geometry.orthogonal_bases(np.random.rand(3)))
        point = np.random.uniform(-10, 10, 3)
        vpl.quiver(np.broadcast_to(point, (3, 3)), grads, color=np.eye(3))

        vpl.view(focal_point=point,
                 camera_position=point - grads[0],
                 up_view=grads[1])
        #        vpl.view(camera_direction=grads[0],
        #                 up_view=grads[1],
        #                 )
        #
        vpl.reset_camera()
        #        vpl.view(point)

        vpl.text(
            "Should be looking in the direction of the red arrow, with the green arrow pointing up"
        )
        vpl.show()