当前位置: 首页>>代码示例>>Python>>正文


Python image_tester.assert_image_approved函数代码示例

本文整理汇总了Python中vispy.testing.image_tester.assert_image_approved函数的典型用法代码示例。如果您正苦于以下问题:Python assert_image_approved函数的具体用法?Python assert_image_approved怎么用?Python assert_image_approved使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assert_image_approved函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_text

def test_text():
    """Test basic text support"""

    with TestingCanvas(bgcolor='w', size=(92, 92), dpi=92) as c:
        pos = [92 // 2] * 2
        text = Text('testing', font_size=20, color='k',
                    pos=pos, anchor_x='center', anchor_y='baseline',
                    parent=c.scene)
        # Test image created in Illustrator CS5, 1"x1" output @ 92 DPI
        assert_image_approved(c.render(), 'visuals/text1.png')
        
        text.text = ['foo', 'bar']
        text.pos = [10, 10]  # should auto-replicate
        try:
            text.pos = [10]
        except Exception:
            pass
        else:
            raise AssertionError('Exception not raised')
        c.update()
        c.app.process_events()
        text.pos = [[10, 10], [10, 20]]
        text.text = 'foobar'
        c.update()
        c.app.process_events()
开发者ID:Calvarez20,项目名称:vispy,代码行数:25,代码来源:test_text.py

示例2: test_reactive_draw

def test_reactive_draw():
    """Test reactive RectPolygon attributes"""
    with TestingCanvas() as c:
        rectpolygon = visuals.Rectangle(center=(50, 50, 0), height=40.,
                                        width=80., color='red',
                                        parent=c.scene)

        rectpolygon.radius = [20., 20, 0., 10.]

        assert_image_approved(c.render(),
                              'visuals/reactive_rectpolygon1.png')

        rectpolygon.center = (60, 60, 0)

        assert_image_approved(c.render(),
                              'visuals/reactive_rectpolygon2.png')

        rectpolygon.color = 'blue'

        assert_image_approved(c.render(),
                              'visuals/reactive_rectpolygon3.png')

        rectpolygon.border_color = 'yellow'

        assert_image_approved(c.render(),
                              'visuals/reactive_rectpolygon4.png')

        rectpolygon.radius = 10.

        assert_image_approved(c.render(),
                              'visuals/reactive_rectpolygon5.png')
开发者ID:Calvarez20,项目名称:vispy,代码行数:31,代码来源:test_rectangle.py

示例3: test_arrow_transform_draw

def test_arrow_transform_draw():
    """Tests the ArrowVisual when a transform is applied"""

    # TODO: fix AppVeyor - error comes up with bollu/vispy:cassowary-constaints
    # commit SHA: 29303009a76d5c6931b1991aa7bdf5192ace9c4f
    if os.getenv('APPVEYOR', '').lower() == 'true':
        raise SkipTest('AppVeyor has unknown failure')

    old_numpy = LooseVersion(np.__version__) < '1.8'
    if os.getenv('TRAVIS', 'false') == 'true' and (sys.version[:3] == '2.6' or
                                                   old_numpy):
        # TODO: Fix this (issue #1042
        raise SkipTest('Travis fails due to FB stack problem')

    with TestingCanvas() as c:
        for arrow_type in ARROW_TYPES:
            arrow = visuals.Arrow(pos=vertices, arrow_type=arrow_type,
                                  arrows=arrows, arrow_size=10, color='red',
                                  connect="segments", parent=c.scene)
            arrow.transform = transforms.STTransform(scale=(0.5, 0.75),
                                                     translate=(-20, -20))

            assert_image_approved(c.render(),
                                  'visuals/arrow_transform_type_%s.png' %
                                  arrow_type)

            arrow.parent = None
开发者ID:Calvarez20,项目名称:vispy,代码行数:27,代码来源:test_arrows.py

示例4: test_reactive_draw

def test_reactive_draw():
    """Test reactive RectPolygon attributes"""
    with TestingCanvas() as c:
        rectpolygon = visuals.Rectangle(pos=(50, 50, 0), height=40.,
                                        width=80., color='red')
        c.draw_visual(rectpolygon)

        rectpolygon.radius = [20., 20, 0., 10.]
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_rectpolygon1.png')

        rectpolygon.pos = (60, 60, 0)
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_rectpolygon2.png')

        rectpolygon.color = 'blue'
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_rectpolygon3.png')

        rectpolygon.border_color = 'yellow'
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_rectpolygon4.png')

        rectpolygon.radius = 10.
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_rectpolygon5.png')
开发者ID:astrofrog,项目名称:vispy,代码行数:31,代码来源:test_rectangle.py

示例5: test_reactive_draw

def test_reactive_draw():
    """Test reactive regular polygon attributes"""
    with TestingCanvas() as c:
        rpolygon = visuals.RegularPolygon(center=[50, 50, 0.], radius=20,
                                          sides=8,
                                          color='yellow',
                                          parent=c.scene)

        rpolygon.center = [70, 40, 0.]
        assert_image_approved(c.render(),
                              'visuals/reactive_regular_polygon1.png')

        rpolygon.radius = 25
        assert_image_approved(c.render(),
                              'visuals/reactive_regular_polygon2.png')

        rpolygon.color = 'red'
        assert_image_approved(c.render(),
                              'visuals/reactive_regular_polygon3.png')

        rpolygon.border_color = 'yellow'
        assert_image_approved(c.render(),
                              'visuals/reactive_regular_polygon4.png')

        rpolygon.sides = 6
        assert_image_approved(c.render(),
                              'visuals/reactive_regular_polygon5.png')
开发者ID:Eric89GXL,项目名称:vispy,代码行数:27,代码来源:test_regular_polygon.py

示例6: test_rectangle_draw

def test_rectangle_draw():
    """Test drawing rectpolygons without transform using RectPolygonVisual"""
    with TestingCanvas() as c:
        rectpolygon = visuals.Rectangle(pos=(50, 50, 0), height=40.,
                                        width=80., color='red')
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot", 'visuals/rectpolygon1.png')

        rectpolygon = visuals.Rectangle(pos=(50, 50, 0), height=40.,
                                        width=80., radius=10., color='red')
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot", 'visuals/rectpolygon2.png')

        rectpolygon = visuals.Rectangle(pos=(50, 50, 0), height=40.,
                                        width=80., radius=10., color='red',
                                        border_color=(0, 1, 1, 1))
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot", 'visuals/rectpolygon3.png')

        rectpolygon = visuals.Rectangle(pos=(50, 50, 0), height=40.,
                                        width=80., radius=10.,
                                        border_color='white')
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot", 'visuals/rectpolygon4.png',
                              min_corr=0.5)

        rectpolygon = visuals.Rectangle(pos=(50, 50, 0), height=60.,
                                        width=80., radius=[25, 10, 0, 15],
                                        color='red', border_color=(0, 1, 1, 1))
        c.draw_visual(rectpolygon)
        assert_image_approved("screenshot", 'visuals/rectpolygon5.png')
开发者ID:astrofrog,项目名称:vispy,代码行数:31,代码来源:test_rectangle.py

示例7: test_set_data

def test_set_data():
    """Test InfiniteLineVisual"""

    pos = 5.0
    color = [1.0, 1.0, 0.5, 0.5]
    expected_color = np.array(color, dtype=np.float32)

    for is_vertical, reference_image in [(True, 'infinite_line.png'),
                                         (False, 'infinite_line_h.png')]:

        with TestingCanvas() as c:
            # Check set_data is working correctly within visual constructor
            region = visuals.InfiniteLine(pos=pos,
                                          color=color,
                                          vertical=is_vertical,
                                          parent=c.scene)
            assert region.pos == pos
            assert np.all(region.color == expected_color)
            assert region.is_vertical == is_vertical

            # Check tuple color argument is accepted
            region.set_data(color=tuple(color))
            assert np.all(region.color == expected_color)

            assert_image_approved(c.render(), 'visuals/%s' % reference_image)

            # Check only numbers are accepted
            assert_raises(TypeError, region.set_data, pos=[[1, 2], [3, 4]])

            # Check color argument can be only a 4 length 1D array
            assert_raises(ValueError, region.set_data, color=[[1, 2], [3, 4]])
            assert_raises(ValueError, region.set_data, color=[1, 2])
开发者ID:Calvarez20,项目名称:vispy,代码行数:32,代码来源:test_infinite_line.py

示例8: test_linear_region_vertical_horizontal

def test_linear_region_vertical_horizontal():
    """Test vertical and horizontal LinearRegionVisual with a single color"""

    # Definition of the region
    pos = np.array([5, 15, 24, 36, 40, 42], dtype=np.float32)
    # Expected internal pos buffer for vertical region
    expected_pos_v = np.array([[5.0, -1.],
                               [5.0, 1.],
                               [15.0, -1.],
                               [15.0, 1.],
                               [24.0, -1.],
                               [24.0, 1.],
                               [36.0, -1.],
                               [36.0, 1.],
                               [40.0, -1.],
                               [40.0, 1.],
                               [42.0, -1.],
                               [42.0, 1.]], dtype=np.float32)
    # Expected internal pos buffer for horizontal region
    expected_pos_h = np.array([expected_pos_v[:, 1] * -1,
                               expected_pos_v[:, 0]], dtype=np.float32).T

    # Test both horizontal and vertical region
    for is_vertical, reference_image in [(True, 'linear_region1.png'),
                                         (False, 'linear_region1_h.png')]:

        expected_pos = expected_pos_v if is_vertical else expected_pos_h

        with TestingCanvas() as c:
            # Check set_data is working correctly within visual constructor
            region = visuals.LinearRegion(pos=pos,
                                          color=[0.0, 1.0, 0.0, 0.5],
                                          vertical=is_vertical,
                                          parent=c.scene)
            assert np.all(region._pos == expected_pos)
            assert np.all(region.pos == pos)
            assert region.is_vertical == is_vertical

            # Check set_data is working as expected when passing a list as
            # pos argument
            region.set_data(pos=list(pos))
            assert np.all(region._pos == expected_pos)
            assert np.all(region.pos == pos)

            # Check set_data is working as expected when passing a tuple as
            # pos argument
            region.set_data(pos=tuple(pos))
            assert np.all(region._pos == expected_pos)
            assert np.all(region.pos == pos)

            # Test with different dtypes that must be converted to float32
            for t in [np.int64, np.float64, np.int32]:
                region.set_data(pos=pos.astype(t))
                assert np.all(region._pos == expected_pos)
                assert np.all(region.pos == pos)

            assert_image_approved(c.render(), 'visuals/%s' % reference_image)

            # Check ValueError is raised when pos is not 1D
            assert_raises(ValueError, region.set_data, pos=[[1, 2], [3, 4]])
开发者ID:Calvarez20,项目名称:vispy,代码行数:60,代码来源:test_linear_region.py

示例9: test_reactive_draw

def test_reactive_draw():
    """Test reactive regular polygon attributes"""
    with TestingCanvas() as c:
        rpolygon = visuals.RegularPolygon(pos=[50, 50, 0.], radius=20, sides=8,
                                          color='yellow')
        c.draw_visual(rpolygon)

        rpolygon.pos = [70, 40, 0.]
        c.draw_visual(rpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_regular_polygon1.png')

        rpolygon.radius = 25
        c.draw_visual(rpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_regular_polygon2.png')

        rpolygon.color = 'red'
        c.draw_visual(rpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_regular_polygon3.png')

        rpolygon.border_color = 'yellow'
        c.draw_visual(rpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_regular_polygon4.png')

        rpolygon.sides = 6
        c.draw_visual(rpolygon)
        assert_image_approved("screenshot",
                              'visuals/reactive_regular_polygon5.png')
开发者ID:Lx37,项目名称:vispy,代码行数:31,代码来源:test_regular_polygon.py

示例10: test_colormap_coolwarm

def test_colormap_coolwarm():
    """Test colormap support using coolwarm preset colormap"""
    with TestingCanvas(size=size, bgcolor='w') as c:
        idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
        data = idata.reshape((size[0], size[1]))
        image = Image(cmap='coolwarm', clim='auto', parent=c.scene)
        image.set_data(data)
        assert_image_approved(c.render(), "visuals/colormap_coolwarm.png")
开发者ID:paliwalgaurav,项目名称:vispy,代码行数:8,代码来源:test_colormap.py

示例11: test_colormap_CubeHelix

def test_colormap_CubeHelix():
    """Test colormap support using cubehelix colormap in only blues"""
    with TestingCanvas(size=size, bgcolor='w') as c:
        idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
        data = idata.reshape((size[0], size[1]))
        image = Image(cmap=get_colormap('cubehelix', rot=0, start=0),
                      clim='auto', parent=c.scene)
        image.set_data(data)
        assert_image_approved(c.render(), "visuals/colormap_cubehelix.png")
开发者ID:paliwalgaurav,项目名称:vispy,代码行数:9,代码来源:test_colormap.py

示例12: test_colormap_single_hue

def test_colormap_single_hue():
    """Test colormap support using a single hue()"""
    with TestingCanvas(size=size, bgcolor='w') as c:
        idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
        data = idata.reshape((size[0], size[1]))
        image = Image(cmap=get_colormap('single_hue', 255),
                      clim='auto', parent=c.scene)
        image.set_data(data)
        assert_image_approved(c.render(), "visuals/colormap_hue.png")
开发者ID:paliwalgaurav,项目名称:vispy,代码行数:9,代码来源:test_colormap.py

示例13: test_text

def test_text():
    """Test basic text support"""
    
    with TestingCanvas(bgcolor='w', size=(92, 92), dpi=92) as c:
        pos = [92 // 2] * 2
        text = Text('testing', font_size=20, color='k',
                    pos=pos, anchor_x='center', anchor_y='baseline')
        c.draw_visual(text)
        # Test image created in Illustrator CS5, 1"x1" output @ 92 DPI
        assert_image_approved("screenshot", 'visuals/text1.png')
开发者ID:Lx37,项目名称:vispy,代码行数:10,代码来源:test_text.py

示例14: test_colormap_discrete_nu

def test_colormap_discrete_nu():
    """Test discrete colormap with non-uniformly distributed control-points"""
    with TestingCanvas(size=size, bgcolor='w') as c:
        idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
        data = idata.reshape((size[0], size[1]))
        image = Image(cmap=Colormap(np.array([[0, .75, 0], [.75, .25, .5]]),
                      [0., .25, 1.], interpolation='zero'),
                      clim='auto', parent=c.scene)
        image.set_data(data)
        assert_image_approved(c.render(), "visuals/colormap_nu.png")
开发者ID:paliwalgaurav,项目名称:vispy,代码行数:10,代码来源:test_colormap.py

示例15: test_colormap_discrete

def test_colormap_discrete():
    """Test discrete RGB colormap"""
    with TestingCanvas(size=size, bgcolor='w') as c:
        idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
        data = idata.reshape((size[0], size[1]))
        image = Image(cmap=Colormap(colors=['r', 'g', 'b'],
                      interpolation='zero'),
                      clim='auto', parent=c.scene)
        image.set_data(data)
        assert_image_approved(c.render(), "visuals/colormap_rgb.png")
开发者ID:paliwalgaurav,项目名称:vispy,代码行数:10,代码来源:test_colormap.py


注:本文中的vispy.testing.image_tester.assert_image_approved函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。