more complete test yields more complete behavior (#1765)

This commit is contained in:
Martin Chase 2021-05-05 18:07:34 -07:00 committed by GitHub
parent fa1be1e5bf
commit 2fb7cdafbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 7 deletions

View File

@ -238,6 +238,7 @@ class PlotItem(GraphicsWidget):
self.ctrl.averageGroup.toggled.connect(self.avgToggled)
self.ctrl.maxTracesCheck.toggled.connect(self.updateDecimation)
self.ctrl.forgetTracesCheck.toggled.connect(self.updateDecimation)
self.ctrl.maxTracesSpin.valueChanged.connect(self.updateDecimation)
if labels is None:
@ -1008,12 +1009,14 @@ class PlotItem(GraphicsWidget):
else:
numCurves = self.ctrl.maxTracesSpin.value()
for i, curve in enumerate(self.curves):
if i < numCurves:
curve.show()
elif self.ctrl.forgetTracesCheck.isChecked():
if self.ctrl.forgetTracesCheck.isChecked():
for curve in self.curves[:-numCurves]:
curve.clear()
self.removeItem(curve)
for i, curve in enumerate(reversed(self.curves)):
if i < numCurves:
curve.show()
else:
curve.hide()

View File

@ -30,14 +30,28 @@ def test_PlotItem_maxTraces():
curve1 = pg.PlotDataItem(np.random.normal(size=10))
item.addItem(curve1)
assert curve1.isVisible(), f"{curve1} should be visible"
assert curve1.isVisible(), "curve1 should be visible"
item.ctrl.maxTracesCheck.setChecked(True)
item.ctrl.maxTracesSpin.setValue(0)
assert not curve1.isVisible(), f"{curve1} should not be visible"
assert not curve1.isVisible(), "curve1 should not be visible"
item.ctrl.maxTracesCheck.setChecked(False)
assert curve1.isVisible(), f"{curve1} should be visible"
assert curve1.isVisible(), "curve1 should be visible"
curve2 = pg.PlotDataItem(np.random.normal(size=10))
item.addItem(curve2)
assert curve2.isVisible(), "curve2 should be visible"
item.ctrl.maxTracesCheck.setChecked(True)
item.ctrl.maxTracesSpin.setValue(1)
assert curve2.isVisible(), "curve2 should be visible"
assert not curve1.isVisible(), "curve1 should not be visible"
assert curve1 in item.curves, "curve1 should be in the item's curves"
item.ctrl.forgetTracesCheck.setChecked(True)
assert curve2 in item.curves, "curve2 should be in the item's curves"
assert curve1 not in item.curves, "curve1 should not be in the item's curves"
def test_plotitem_menu_initialize():