From d870a34359682251dc22079161b003b5ad060c77 Mon Sep 17 00:00:00 2001 From: Sam Schott Date: Mon, 24 Jun 2019 14:49:32 +0100 Subject: [PATCH] add a test for clipping --- .../graphicsItems/tests/test_PlotDataItem.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pyqtgraph/graphicsItems/tests/test_PlotDataItem.py b/pyqtgraph/graphicsItems/tests/test_PlotDataItem.py index b506a654..adc525d9 100644 --- a/pyqtgraph/graphicsItems/tests/test_PlotDataItem.py +++ b/pyqtgraph/graphicsItems/tests/test_PlotDataItem.py @@ -64,3 +64,25 @@ def test_clear_in_step_mode(): c = pg.PlotDataItem([1,4,2,3], [5,7,6], stepMode=True) w.addItem(c) c.clear() + +def test_clipping(): + y = np.random.normal(size=150) + x = np.exp2(np.linspace(5, 10, 150)) # non-uniform spacing + + w = pg.PlotWidget(autoRange=True, downsample=5) + c = pg.PlotDataItem(x, y) + w.addItem(c) + w.show() + + c.setClipToView(True) + + w.setXRange(200, 600) + + for x_min in range(100, 2**10 - 100, 100): + w.setXRange(x_min, x_min + 100) + + xDisp, _ = c.getData() + vr = c.viewRect() + + assert xDisp[0] <= vr.left() + assert xDisp[-1] >= vr.right()