Doc updates for datafilterwidget
This commit is contained in:
parent
e8a999d8b1
commit
0fd0f08384
@ -10,6 +10,9 @@ class DataFilterWidget(ptree.ParameterTree):
|
|||||||
"""
|
"""
|
||||||
This class allows the user to filter multi-column data sets by specifying
|
This class allows the user to filter multi-column data sets by specifying
|
||||||
multiple criteria
|
multiple criteria
|
||||||
|
|
||||||
|
Wraps methods from DataFilterParameter: setFields, generateMask,
|
||||||
|
filterData, and describe.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sigFilterChanged = QtCore.Signal(object)
|
sigFilterChanged = QtCore.Signal(object)
|
||||||
@ -22,6 +25,7 @@ class DataFilterWidget(ptree.ParameterTree):
|
|||||||
self.params.sigTreeStateChanged.connect(self.filterChanged)
|
self.params.sigTreeStateChanged.connect(self.filterChanged)
|
||||||
|
|
||||||
self.setFields = self.params.setFields
|
self.setFields = self.params.setFields
|
||||||
|
self.generateMask = self.params.generateMask
|
||||||
self.filterData = self.params.filterData
|
self.filterData = self.params.filterData
|
||||||
self.describe = self.params.describe
|
self.describe = self.params.describe
|
||||||
|
|
||||||
@ -38,7 +42,8 @@ class DataFilterWidget(ptree.ParameterTree):
|
|||||||
|
|
||||||
|
|
||||||
class DataFilterParameter(ptree.types.GroupParameter):
|
class DataFilterParameter(ptree.types.GroupParameter):
|
||||||
|
"""A parameter group that specifies a set of filters to apply to tabular data.
|
||||||
|
"""
|
||||||
sigFilterChanged = QtCore.Signal(object)
|
sigFilterChanged = QtCore.Signal(object)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -61,6 +66,17 @@ class DataFilterParameter(ptree.types.GroupParameter):
|
|||||||
return self.fields.keys()
|
return self.fields.keys()
|
||||||
|
|
||||||
def setFields(self, fields):
|
def setFields(self, fields):
|
||||||
|
"""Set the list of fields that are available to be filtered.
|
||||||
|
|
||||||
|
*fields* must be a dict or list of tuples that maps field names
|
||||||
|
to a specification describing the field. Each specification is
|
||||||
|
itself a dict with either ``'mode':'range'`` or ``'mode':'enum'``::
|
||||||
|
|
||||||
|
filter.setFields([
|
||||||
|
('field1', {'mode': 'range'}),
|
||||||
|
('field2', {'mode': 'enum', 'values': ['val1', 'val2', 'val3']}),
|
||||||
|
])
|
||||||
|
"""
|
||||||
self.fields = OrderedDict(fields)
|
self.fields = OrderedDict(fields)
|
||||||
names = self.fieldNames()
|
names = self.fieldNames()
|
||||||
self.setAddList(names)
|
self.setAddList(names)
|
||||||
@ -71,6 +87,9 @@ class DataFilterParameter(ptree.types.GroupParameter):
|
|||||||
return data[self.generateMask(data)]
|
return data[self.generateMask(data)]
|
||||||
|
|
||||||
def generateMask(self, data):
|
def generateMask(self, data):
|
||||||
|
"""Return a boolean mask indicating whether each item in *data* passes
|
||||||
|
the filter critera.
|
||||||
|
"""
|
||||||
mask = np.ones(len(data), dtype=bool)
|
mask = np.ones(len(data), dtype=bool)
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
return mask
|
return mask
|
||||||
@ -94,6 +113,7 @@ class DataFilterParameter(ptree.types.GroupParameter):
|
|||||||
desc.append(fp.describe())
|
desc.append(fp.describe())
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
|
|
||||||
class RangeFilterItem(ptree.types.SimpleParameter):
|
class RangeFilterItem(ptree.types.SimpleParameter):
|
||||||
def __init__(self, name, opts):
|
def __init__(self, name, opts):
|
||||||
self.fieldName = name
|
self.fieldName = name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user