2019-06-09 02:57:53 +00:00
|
|
|
import pyqtgraph as pg
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
app = pg.mkQApp()
|
|
|
|
|
|
|
|
|
2019-06-09 16:12:01 +00:00
|
|
|
def test_ErrorBarItem_defer_data():
|
2019-06-09 02:57:53 +00:00
|
|
|
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()
|
2021-05-02 01:05:33 +00:00
|
|
|
app.processEvents()
|
2019-06-09 02:57:53 +00:00
|
|
|
r_no_ebi = plot.viewRect()
|
|
|
|
|
|
|
|
# ErrorBarItem with no data shouldn't affect the view rect
|
|
|
|
err = pg.ErrorBarItem()
|
|
|
|
plot.addItem(err)
|
|
|
|
app.processEvents()
|
2021-05-02 01:05:33 +00:00
|
|
|
app.processEvents()
|
2019-06-09 02:57:53 +00:00
|
|
|
r_empty_ebi = plot.viewRect()
|
|
|
|
|
2020-06-24 05:22:51 +00:00
|
|
|
assert r_no_ebi.height() == r_empty_ebi.height()
|
2019-06-09 02:57:53 +00:00
|
|
|
|
|
|
|
err.setData(x=x, y=x, bottom=x, top=x)
|
|
|
|
app.processEvents()
|
2021-05-02 01:05:33 +00:00
|
|
|
app.processEvents()
|
2019-06-09 02:57:53 +00:00
|
|
|
r_ebi = plot.viewRect()
|
|
|
|
|
2020-06-24 05:22:51 +00:00
|
|
|
assert r_ebi.height() > r_empty_ebi.height()
|
2019-06-09 02:57:53 +00:00
|
|
|
|
|
|
|
# unset data, ErrorBarItem disappears and view rect goes back to original
|
|
|
|
err.setData(x=None, y=None)
|
|
|
|
app.processEvents()
|
2021-05-02 01:05:33 +00:00
|
|
|
app.processEvents()
|
2019-06-09 02:57:53 +00:00
|
|
|
r_clear_ebi = plot.viewRect()
|
|
|
|
|
2020-06-24 05:22:51 +00:00
|
|
|
assert r_clear_ebi.height() == r_empty_ebi.height()
|
2019-09-27 20:37:40 +00:00
|
|
|
|
|
|
|
plot.close()
|