fix bug when plotting boolean arrays (#1748)
* test and fix for plotting boolean arrays * smaller is faster * oh, that bool went away * tests should keep up with optimizations
This commit is contained in:
parent
a534132c62
commit
4ee1fe4388
|
@ -639,6 +639,11 @@ class PlotDataItem(GraphicsObject):
|
||||||
x = self.xData
|
x = self.xData
|
||||||
y = self.yData
|
y = self.yData
|
||||||
|
|
||||||
|
if y.dtype == bool:
|
||||||
|
y = y.astype(np.uint8)
|
||||||
|
if x.dtype == bool:
|
||||||
|
x = x.astype(np.uint8)
|
||||||
|
|
||||||
if self.opts['fftMode']:
|
if self.opts['fftMode']:
|
||||||
x,y = self._fourierTransform(x, y)
|
x,y = self._fourierTransform(x, y)
|
||||||
# Ignore the first bin for fft data if we have a logx scale
|
# Ignore the first bin for fft data if we have a logx scale
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
from pyqtgraph.Qt import QtGui
|
from pyqtgraph.Qt import QtGui
|
||||||
|
@ -5,6 +6,16 @@ from pyqtgraph.Qt import QtGui
|
||||||
pg.mkQApp()
|
pg.mkQApp()
|
||||||
|
|
||||||
|
|
||||||
|
def test_bool():
|
||||||
|
truths = np.random.randint(0, 2, size=(100,)).astype(bool)
|
||||||
|
pdi = pg.PlotDataItem(truths)
|
||||||
|
bounds = pdi.dataBounds(1)
|
||||||
|
assert isinstance(bounds[0], np.uint8)
|
||||||
|
assert isinstance(bounds[1], np.uint8)
|
||||||
|
xdata, ydata = pdi.getData()
|
||||||
|
assert ydata.dtype == np.uint8
|
||||||
|
|
||||||
|
|
||||||
def test_fft():
|
def test_fft():
|
||||||
f = 20.
|
f = 20.
|
||||||
x = np.linspace(0, 1, 1000)
|
x = np.linspace(0, 1, 1000)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user