Esempio n. 1
0
def test_histogram():
    """Test histogram visual"""
    size = (200, 100)
    with TestingCanvas(size=size, bgcolor='w') as c:
        np.random.seed(2397)
        data = np.random.normal(size=100)
        hist = Histogram(data, bins=20, color='k', parent=c.scene)
        hist.transform = STTransform((size[0] // 10, -size[1] // 20, 1),
                                     (100, size[1]))
        assert_image_approved(c.render(), "visuals/histogram.png")
Esempio n. 2
0
def test_histogram():
    """Test histogram visual"""
    size = (200, 100)
    with TestingCanvas(size=size, bgcolor='w') as c:
        np.random.seed(2397)
        data = np.random.normal(size=100)
        hist = Histogram(data, bins=20, color='k')
        hist.transform = STTransform((size[0] // 10, -size[1] // 20, 1),
                                     (100, size[1]))
        c.draw_visual(hist)
        assert_image_approved("screenshot", "visuals/histogram.png")
Esempio n. 3
0
def test_histogram():
    """Test histogram visual"""
    size = (200, 100)
    with TestingCanvas(size=size, bgcolor='w') as c:
        data = np.array([0., 0., 1.])
        hist = Histogram(data, bins=2, color='k')
        # the result should be 2 high by 1 wide, so we scale it up
        hist.transform = STTransform((size[0], -size[1] // 2, 1), (0, size[1]))
        c.draw_visual(hist)
        expected = np.zeros(size[::-1] + (3, ))
        expected[:size[1] // 2, -size[0] // 2:] = 1.
        assert_image_equal("screenshot", expected)