def region_selected(self, regions): """Called from JavaScript""" if not regions: return self.send('Data', None) regions = regions.split(',') from Orange.data.filter import FilterStringList # TODO, FIXME: make this work for discrete attrs also filter = FilterStringList(self.metas[self.selected_attr], regions) self.send('Data', self.data._filter_values(filter))
def test_reprs(self): flid = IsDefined(negate=True) flhc = HasClass() flr = Random() fld = FilterDiscrete(self.attr_disc, None) flsv = SameValue(self.attr_disc, self.value_disc, negate=True) flc = FilterContinuous(self.vs[0], FilterContinuous.Less, 5) flc2 = FilterContinuous(self.vs[1], FilterContinuous.Greater, 3) flv = Values([flc, flc2], conjunction=False, negate=True) flvf = ValueFilter(self.attr_disc) fls = FilterString("name", FilterString.Equal, "Aardvark", case_sensitive=False) flsl = FilterStringList("name", ["Aardvark"], case_sensitive=False) flrx = FilterRegex("name", "^c...$") filters = [flid, flhc, flr, fld, flsv, flc, flv, flvf, fls, flsl, flrx] for f in filters: repr_str = repr(f) new_f = eval(repr_str) self.assertEqual(repr(new_f), repr_str)