Add test_setData() for PlotDataItem class

This commit is contained in:
Billy Su 2018-04-05 11:13:09 +08:00
parent b421cc2790
commit 7b9ba8634c

View File

@ -23,3 +23,29 @@ def test_fft():
x, y = pd.getData() x, y = pd.getData()
assert abs(x[np.argmax(y)] - np.log10(f)) < 0.01 assert abs(x[np.argmax(y)] - np.log10(f)) < 0.01
def test_setData():
pdi = pg.PlotDataItem()
#test empty data
pdi.setData([])
#test y data
y = list(np.random.normal(size=100))
pdi.setData(y)
assert len(pdi.xData) == 100
assert len(pdi.yData) == 100
#test x, y data
y += list(np.random.normal(size=50))
x = np.linspace(5, 10, 150)
pdi.setData(x, y)
assert len(pdi.xData) == 150
assert len(pdi.yData) == 150
#test dict of x, y list
y += list(np.random.normal(size=50))
x = list(np.linspace(5, 10, 200))
pdi.setData({'x': x, 'y': y})
assert len(pdi.xData) == 200
assert len(pdi.yData) == 200