Ignore:
Timestamp:
06/13/13 18:12:28 (10 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Updated Widget development tutorial.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/extend-widgets/rst/OWDataSamplerC.py

    r11085 r11593  
    22<name>Data Sampler (C)</name> 
    33<description>Randomly selects a subset of instances from the data set</description> 
    4 <icon>icons/DataSamplerC.png</icon> 
     4<icon>icons/DataSamplerC.svg</icon> 
    55<priority>30</priority> 
    66""" 
     7import Orange 
     8 
    79from OWWidget import * 
    810import OWGUI 
     
    1315        OWWidget.__init__(self, parent, signalManager, 'SampleDataC') 
    1416         
    15         self.inputs = [("Data", ExampleTable, self.data)] 
    16         self.outputs = [("Sampled Data", ExampleTable), ("Other Data", ExampleTable)] 
     17        self.inputs = [("Data", Orange.data.Table, self.data)] 
     18        self.outputs = [("Sampled Data", Orange.data.Table), 
     19                        ("Other Data", Orange.data.Table)] 
    1720 
    1821        self.proportion = 50 
     
    4952 
    5053    def selection(self): 
    51         indices = orange.MakeRandomIndices2(p0=self.proportion / 100.) 
     54        indices = Orange.data.sample.SubsetIndices2(p0=self.proportion / 100.) 
    5255        ind = indices(self.dataset) 
    5356        self.sample = self.dataset.select(ind, 0) 
     
    6366            self.commit() 
    6467 
    65 ############################################################################## 
    66 # Test the widget, run from prompt 
    6768 
    6869if __name__=="__main__": 
     
    7071    ow = OWDataSamplerC() 
    7172    ow.show() 
    72     dataset = orange.ExampleTable('iris.tab') 
     73    dataset = Orange.data.Table('iris.tab') 
    7374    ow.data(dataset) 
    7475    appl.exec_() 
Note: See TracChangeset for help on using the changeset viewer.