예제 #1
0
def test_save_figures():
    """Test file naming when saving figures. Requires mayavi."""
    try:
        from mayavi import mlab
    except ImportError:
        raise nose.SkipTest('Mayavi not installed')
    mlab.options.offscreen = True
    examples_dir = tempfile.mkdtemp()

    gallery_conf = {'find_mayavi_figures': True}
    mlab.test_plot3d()
    plt.plot(1, 1)
    fname_template = os.path.join(examples_dir, 'image{0}.png')
    fig_list, _ = sg.save_figures(fname_template, 0, gallery_conf)
    assert_equal(len(fig_list), 2)
    assert fig_list[0].endswith('image1.png')
    assert fig_list[1].endswith('image2.png')

    mlab.test_plot3d()
    plt.plot(1, 1)
    fig_list, _ = sg.save_figures(fname_template, 2, gallery_conf)
    assert_equal(len(fig_list), 2)
    assert fig_list[0].endswith('image3.png')
    assert fig_list[1].endswith('image4.png')

    shutil.rmtree(examples_dir)
예제 #2
0
def test_save_figures():
    """Test file naming when saving figures. Requires mayavi."""
    try:
        from mayavi import mlab
    except ImportError:
        raise nose.SkipTest('Mayavi not installed')
    mlab.options.offscreen = True
    examples_dir = tempfile.mkdtemp()

    gallery_conf = {'find_mayavi_figures': True}
    mlab.test_plot3d()
    plt.plot(1, 1)
    fname_template = os.path.join(examples_dir, 'image{0}.png')
    fig_list = sg.save_figures(fname_template, 0, gallery_conf)
    assert_equal(len(fig_list), 2)
    assert fig_list[0].endswith('image1.png')
    assert fig_list[1].endswith('image2.png')

    mlab.test_plot3d()
    plt.plot(1, 1)
    fig_list = sg.save_figures(fname_template, 2, gallery_conf)
    assert_equal(len(fig_list), 2)
    assert fig_list[0].endswith('image3.png')
    assert fig_list[1].endswith('image4.png')

    shutil.rmtree(examples_dir)
예제 #3
0
def test_save_figures(gallery_conf):
    """Test file naming when saving figures. Requires mayavi."""
    try:
        from mayavi import mlab
    except ImportError:
        raise pytest.skip('Mayavi not installed')
    mlab.options.offscreen = True

    gallery_conf.update(find_mayavi_figures=True)

    mlab.test_plot3d()
    plt.plot(1, 1)
    fname_template = os.path.join(gallery_conf['gallery_dir'], 'image{0}.png')
    image_rst, fig_num = sg.save_figures(fname_template, 0, gallery_conf)
    assert fig_num == 2
    assert '/image1.png' in image_rst
    assert '/image2.png' in image_rst

    mlab.test_plot3d()
    plt.plot(1, 1)
    image_rst, fig_num = sg.save_figures(fname_template, 2, gallery_conf)
    assert fig_num == 2
    assert '/image2.png' not in image_rst
    assert '/image3.png' in image_rst
    assert '/image4.png' in image_rst

    shutil.rmtree(gallery_conf['gallery_dir'])