Merge pull request #645 from campagnola/scatterplotwidget-update

fix: scatterplotwidget behaves nicely when data contains infs
This commit is contained in:
Luke Campagnola 2018-03-09 10:17:05 -08:00 committed by GitHub
commit ee0877170d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 8 deletions

View File

@ -42,6 +42,11 @@ class ColorMapWidget(ptree.ParameterTree):
def restoreState(self, state):
self.params.restoreState(state)
def addColorMap(self, name):
"""Add a new color mapping and return the created parameter.
"""
return self.params.addNew(name)
class ColorMapParameter(ptree.types.GroupParameter):
sigColorMapChanged = QtCore.Signal(object)

View File

@ -30,7 +30,12 @@ class DataFilterWidget(ptree.ParameterTree):
def parameters(self):
return self.params
def addFilter(self, name):
"""Add a new filter and return the created parameter item.
"""
return self.params.addNew(name)
class DataFilterParameter(ptree.types.GroupParameter):
@ -47,10 +52,10 @@ class DataFilterParameter(ptree.types.GroupParameter):
def addNew(self, name):
mode = self.fields[name].get('mode', 'range')
if mode == 'range':
self.addChild(RangeFilterItem(name, self.fields[name]))
child = self.addChild(RangeFilterItem(name, self.fields[name]))
elif mode == 'enum':
self.addChild(EnumFilterItem(name, self.fields[name]))
child = self.addChild(EnumFilterItem(name, self.fields[name]))
return child
def fieldNames(self):
return self.fields.keys()

View File

@ -83,7 +83,19 @@ class ScatterPlotWidget(QtGui.QSplitter):
item = self.fieldList.addItem(item)
self.filter.setFields(fields)
self.colorMap.setFields(fields)
def setSelectedFields(self, *fields):
self.fieldList.itemSelectionChanged.disconnect(self.fieldSelectionChanged)
try:
self.fieldList.clearSelection()
for f in fields:
i = self.fields.keys().index(f)
item = self.fieldList.item(i)
item.setSelected(True)
finally:
self.fieldList.itemSelectionChanged.connect(self.fieldSelectionChanged)
self.fieldSelectionChanged()
def setData(self, data):
"""
Set the data to be processed and displayed.
@ -114,7 +126,6 @@ class ScatterPlotWidget(QtGui.QSplitter):
else:
self.filterText.setText('\n'.join(desc))
self.filterText.setVisible(True)
def updatePlot(self):
self.plot.clear()
@ -177,9 +188,9 @@ class ScatterPlotWidget(QtGui.QSplitter):
## mask out any nan values
mask = np.ones(len(xy[0]), dtype=bool)
if xy[0].dtype.kind == 'f':
mask &= ~np.isnan(xy[0])
mask &= np.isfinite(xy[0])
if xy[1] is not None and xy[1].dtype.kind == 'f':
mask &= ~np.isnan(xy[1])
mask &= np.isfinite(xy[1])
xy[0] = xy[0][mask]
style['symbolBrush'] = colors[mask]