File: test_histogram.py

package info (click to toggle)
python-vispy 0.14.3-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,840 kB
  • sloc: python: 59,436; javascript: 6,800; makefile: 69; sh: 6
file content (24 lines) | stat: -rw-r--r-- 814 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
import numpy as np

from vispy.visuals.transforms import STTransform
from vispy.scene.visuals import Histogram
from vispy.testing import (requires_application, TestingCanvas,
                           run_tests_if_main)
from vispy.testing.image_tester import assert_image_approved


@requires_application()
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")


run_tests_if_main()