source: orange/Orange/testing/regression/tests_20/reference_cb-filter.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 520 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

Line 
1# Description: Shows how to derive a class from orange.Filter
2# Category:    filters, preprocessing, callbacks to Python
3# Classes:     Filter
4# Uses:        lenses
5# Referenced:  callbacks.htm
6
7import orange, orngTree, orngMisc
8tab = orange.ExampleTable(r"lenses.tab")
9
10filt = orange.Filter(lambda ex:ex["age"]=="young")
11for e in tab.select(filt):
12    print e
13
14class FilterYoung(orange.Filter):
15    def __call__(self, ex):
16        return ex["age"]=="young"
17
18print "\n"
19for e in tab.select(FilterYoung()):
20    print e
21
22
Note: See TracBrowser for help on using the repository browser.