source: orange/orange/doc/extend-widgets/OWDataSamplerA.py @ 9398:a6b3d9c13ee0

Revision 9398:a6b3d9c13ee0, 1.6 KB checked in by mitar, 2 years ago (diff)

Renaming documentation for widgets developers.

Line 
1"""
2<name>Data Sampler (A)</name>
3<description>Randomly selects a subset of instances from the data set</description>
4<icon>icons/DataSamplerA.png</icon>
5<priority>10</priority>
6"""
7from OWWidget import *
8import OWGUI
9
10class OWDataSamplerA(OWWidget):
11   
12    def __init__(self, parent=None, signalManager=None):
13        OWWidget.__init__(self, parent, signalManager, 'SampleDataA')
14       
15        self.inputs = [("Data", ExampleTable, self.data)]
16        self.outputs = [("Sampled Data", ExampleTable)]
17
18        # GUI
19        box = OWGUI.widgetBox(self.controlArea, "Info")
20        self.infoa = OWGUI.widgetLabel(box, 'No data on input yet, waiting to get something.')
21        self.infob = OWGUI.widgetLabel(box, '')
22        self.resize(100,50)
23
24    def data(self, dataset):
25        if dataset:
26            self.infoa.setText('%d instances in input data set' % len(dataset))
27            indices = orange.MakeRandomIndices2(p0=0.1)
28            ind = indices(dataset)
29            sample = dataset.select(ind, 0)
30            self.infob.setText('%d sampled instances' % len(sample))
31            self.send("Sampled Data", sample)
32        else:
33            self.infoa.setText('No data on input yet, waiting to get something.')
34            self.infob.setText('')
35            self.send("Sampled Data", None)
36           
37
38##############################################################################
39# Test the widget, run from prompt
40
41if __name__=="__main__":
42    appl = QApplication(sys.argv)
43    ow = OWDataSamplerA()
44    ow.show()
45    dataset = orange.ExampleTable('../datasets/iris.tab')
46    ow.data(dataset)
47    appl.exec_()
Note: See TracBrowser for help on using the repository browser.