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

Updated channel specification flags documentation in 'extend-widgets'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/doc/extend-widgets/channels.htm

    r9671 r10997  
    5353widget are defined by:</p> 
    5454 
    55 <xmp class="code">self.inputs = [("Data", ExampleTable, self.dataset), ("Learner", orange.Learner, self.learner, 0)] 
     55<xmp class="code">self.inputs = [("Data", ExampleTable, self.dataset), 
     56               ("Learner", orange.Learner, self.learner, Multiple)] 
    5657</xmp> 
    5758 
    5859<p>Notice that everything is pretty much the same as it was with 
    59 widgets from previous lessons, the only difference being "0" as the 
    60 last value in the list that defines the <code>Learner</code> 
    61 channel. This "0" says that this is a multi-input channel. If it would 
    62 be "1" (default), it would mean that the widget can receive the input 
    63 only from one widget.</p> 
     60widgets from previous lessons, the only difference being 
     61<code>Multiple + Default</code> as the last value in the list that defines 
     62the <code>Learner</code> channel. This <code>Multiple + Default</code> says 
     63that this is a multi-input channel and is the default input for its type. 
     64If it would be unspecified then by default value of 
     65<code>Single + NonDefault</code> would be used. That would mean that the 
     66widget can receive the input only from one widget and is not the default input 
     67channel for its type (more on default channels later).</p> 
    6468 
    6569<p>How does the widget know from which widget did the token come from? 
     
    206210<img src="datasampler-totable.png"> 
    207211 
    208 <p>we would get a following window quering users for information on 
     212<p>we would get a following window querying users for information on 
    209213which channels to connect:</p> 
    210214 
     
    224228 
    225229<p>When enlisting the input channel of the same type, the non-default 
    226 channels have a special fourth value in the channel specification 
    227 list. So for our new <a href="OWLearningCurveB.py">learning curve</a> 
    228 widget, the channel specification is:</p> 
    229  
    230 <xmp class="code">self.inputs = [("Train Data", ExampleTable, self.trainset), ("Test Data", ExampleTable, self.testset, 1, 1), ("Learner", orange.Learner, self.learner, 0)] 
    231 </xmp> 
    232  
    233 <p>That is, the <code>Test Data</code> channel is a single-token 
    234 channel (third parameter) which is not a default one (where "1" 
    235 indicates that this is a so-called minor channel). To test how this 
    236 works, connect a file widget to a learning curve widget and - nothing 
    237 will really happen:</p> 
     230channels have a special flag in the channel specification list. So for 
     231our new <a href="OWLearningCurveB.py">learning curve</a> widget, the 
     232channel specification is:</p> 
     233 
     234<xmp class="code">self.inputs = [("Train Data", ExampleTable, self.trainset, Default), 
     235               ("Test Data", ExampleTable, self.testset), 
     236               ("Learner", orange.Learner, self.learner, Multiple)] 
     237</xmp> 
     238 
     239<p>That is, the <code>Train Data</code> channel is a single-token 
     240channel which is a default one (third parameter). Note that the flags can 
     241be added (or OR-d) together so <code>Default + Multi</code> is a valid flag. 
     242To test how this works, connect a file widget to a learning curve widget and 
     243- nothing will really happen:</p> 
    238244 
    239245<img src="file-to-learningcurveb.png"> 
Note: See TracChangeset for help on using the changeset viewer.