2019-06-08 19:57:53 -07:00
|
|
|
import pyqtgraph as pg
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
app = pg.mkQApp()
|
|
|
|
|
|
|
|
|
2019-06-09 09:12:01 -07:00
|
|
|
def test_ErrorBarItem_defer_data():
|
2019-06-08 19:57:53 -07: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-01 18:05:33 -07:00
|
|
|
app.processEvents()
|
2019-06-08 19:57:53 -07: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-01 18:05:33 -07:00
|
|
|
app.processEvents()
|
2019-06-08 19:57:53 -07:00
|
|
|
r_empty_ebi = plot.viewRect()
|
|
|
|
|
2020-06-23 22:22:51 -07:00
|
|
|
assert r_no_ebi.height() == r_empty_ebi.height()
|
2019-06-08 19:57:53 -07:00
|
|
|
|
|
|
|
err.setData(x=x, y=x, bottom=x, top=x)
|
|
|
|
app.processEvents()
|
2021-05-01 18:05:33 -07:00
|
|
|
app.processEvents()
|
2019-06-08 19:57:53 -07:00
|
|
|
r_ebi = plot.viewRect()
|
|
|
|
|
2020-06-23 22:22:51 -07:00
|
|
|
assert r_ebi.height() > r_empty_ebi.height()
|
2019-06-08 19:57:53 -07:00
|
|
|
|
|
|
|
# unset data, ErrorBarItem disappears and view rect goes back to original
|
|
|
|
err.setData(x=None, y=None)
|
|
|
|
app.processEvents()
|
2021-05-01 18:05:33 -07:00
|
|
|
app.processEvents()
|
2019-06-08 19:57:53 -07:00
|
|
|
r_clear_ebi = plot.viewRect()
|
|
|
|
|
2020-06-23 22:22:51 -07:00
|
|
|
assert r_clear_ebi.height() == r_empty_ebi.height()
|
2019-09-27 13:37:40 -07:00
|
|
|
|
|
|
|
plot.close()
|