File: test_ErrorBarItem.py

package info (click to toggle)
python-pyqtgraph 0.13.7-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,072 kB
  • sloc: python: 54,043; makefile: 127; ansic: 40; sh: 2
file content (44 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import numpy as np

import pyqtgraph as pg

app = pg.mkQApp()


def test_ErrorBarItem_defer_data():
    plot = pg.PlotWidget()
    plot.show()

    # plot some data away from the origin to set the view rect
    x = np.arange(5) + 10
    curve = pg.PlotCurveItem(x=x, y=x)
    plot.addItem(curve)
    app.processEvents()
    app.processEvents()
    r_no_ebi = plot.viewRect()

    # ErrorBarItem with no data shouldn't affect the view rect
    err = pg.ErrorBarItem()
    plot.addItem(err)
    app.processEvents()
    app.processEvents()
    r_empty_ebi = plot.viewRect()

    assert r_no_ebi.height() == r_empty_ebi.height()

    err.setData(x=x, y=x, bottom=x, top=x)
    app.processEvents()
    app.processEvents()
    r_ebi = plot.viewRect()

    assert r_ebi.height() > r_empty_ebi.height()

    # unset data, ErrorBarItem disappears and view rect goes back to original
    err.setData(x=None, y=None)
    app.processEvents()
    app.processEvents()
    r_clear_ebi = plot.viewRect()

    assert r_clear_ebi.height() == r_empty_ebi.height()

    plot.close()