Changeset 7891:e2c3735e373a in orange


Ignore:
Timestamp:
05/05/11 11:29:23 (3 years ago)
Author:
markotoplak
Branch:
default
Convert:
8dd75363de0ab3c19ef6b1efa3ffffa9bc626cc0
Message:

Orange.data.variable converted to underscore_separeted. Fixes #787.

Location:
orange
Files:
1 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/data/variable.py

    r7830 r7891  
    2828        behaviour. 
    2929     
    30     .. attribute:: varType 
     30    .. attribute:: var_type 
    3131        
    3232        Variable type; it can be Orange.data.Type.Discrete, 
     
    3434        Orange.data.Type.Other.   
    3535 
    36     .. attribute:: getValueFrom 
     36    .. attribute:: get_value_from 
    3737 
    3838        A function (an instance of :obj:`Orange.core.Clasifier`) which computes 
     
    5353        manner. 
    5454     
    55     .. attribute:: randomGenerator 
     55    .. attribute:: random_generator 
    5656     
    5757        A local random number generator used by method 
    5858        :obj:`Variable.random_value`. 
    5959     
    60     .. attribute:: defaultMetaId 
     60    .. attribute:: default_meta_id 
    6161     
    6262        A proposed (but not guaranteed) meta id to be used for that variable. 
     
    8686           :rtype: :class:`Orange.data.Value` 
    8787        
    88     .. method:: computeValue(inst) 
     88    .. method:: compute_value(inst) 
    8989 
    9090           Compute the value of the variable given the instance by calling 
    91            `getValueFrom` through a mechanism that prevents deadlocks by 
     91           `get_value_from` through a mechanism that prevents deadlocks by 
    9292           circular calls. 
    9393 
     
    114114            shrinking the list can have disastrous effects and is therefore not 
    115115            really recommendable. Also, do not add values to the list by 
    116             calling its append or extend method: call the :obj:`addValue` 
     116            calling its append or extend method: call the :obj:`add_value` 
    117117            method instead. 
    118118 
     
    120120            be empty), so never set it to None. 
    121121     
    122     .. attribute:: baseValue 
     122    .. attribute:: base_value 
    123123 
    124124            Stores the base value for the variable as an index into `values`. 
     
    129129            there is no base value. 
    130130     
    131     .. method:: addValue 
     131    .. method:: add_value 
    132132     
    133133            Add a value to values. Always call this function instead of 
     
    141141    Descriptor for continuous variables. 
    142142     
    143     .. attribute:: numberOfDecimals 
     143    .. attribute:: number_of_decimals 
    144144     
    145145        The number of decimals used when the value is printed out, converted to 
    146146        a string or saved to a file. 
    147147     
    148     .. attribute:: scientificFormat 
     148    .. attribute:: scientific_format 
    149149     
    150150        If ``True``, the value is printed in scientific format whenever it 
    151         would have more than 5 digits. In this case, `numberOfDecimals` is 
     151        would have more than 5 digits. In this case, `number_of_decimals` is 
    152152        ignored. 
    153153 
    154     .. attribute:: adjustDecimals 
     154    .. attribute:: adjust_decimals 
    155155     
    156156        Tells Orange to monitor the number of decimals when the value is 
     
    166166        be printed with the same number of decimals as the largest number of  
    167167        decimals encountered in the file. If scientific notation occurs in the  
    168         file, `scientificFormat` will be set to ``True`` and scientific format  
     168        file, `scientific_format` will be set to ``True`` and scientific format  
    169169        will be used for values too large or too small.  
    170170     
     
    172172        decimals places. This can be changed either by setting the value 
    173173        from a string (e.g. ``inst[0]="3.14"``, but not ``inst[0]=3.14``) or by 
    174         manually setting the `numberOfDecimals`. 
    175  
    176     .. attribute:: startValue, endValue, stepValue 
     174        manually setting the `number_of_decimals`. 
     175 
     176    .. attribute:: start_value, end_value, step_value 
    177177     
    178178        The range used for :obj:`randomvalue`. 
     
    223223new variable will be computed from the old one on the fly.  
    224224 
    225 .. literalinclude:: code/variable-getValueFrom.py 
     225.. literalinclude:: code/variable-get_value_from.py 
    226226    :lines: 7-17 
    227227     
     
    231231needed, interpreted as ``False``). Finally, we tell e2 to use  
    232232``checkE`` to compute its value when needed, by assigning ``checkE`` to  
    233 ``e2.getValueFrom``.  
     233``e2.get_value_from``.  
    234234 
    235235``checkE`` is a function that is passed an instance and another argument we  
     
    244244the new variable. 
    245245 
    246 .. literalinclude:: code/variable-getValueFrom.py 
     246.. literalinclude:: code/variable-get_value_from.py 
    247247    :lines: 19-22 
    248248 
     
    251251to a new :obj:`Orange.data.Table`:: 
    252252 
    253     newDomain = Orange.data.Domain([data.domain["a"], data.domain["b"], e2, data.domain.classVar]) 
    254     newData = Orange.data.Table(newDomain, data)  
     253    new_domain = Orange.data.Domain([data.domain["a"], data.domain["b"], e2, data.domain.class_var]) 
     254    new_data = Orange.data.Table(new_domain, data)  
    255255 
    256256Automatic computation is useful when the data is split onto training and  
     
    263263transformed variables.  
    264264 
    265 .. literalinclude:: code/variable-getValueFrom.py 
     265.. literalinclude:: code/variable-get_value_from.py 
    266266    :lines: 24- 
    267267 
     
    347347There are two functions for reusing the attributes instead of creating new ones. 
    348348 
    349 .. function:: Orange.data.variable.make(name, type, ordered_values, unordered_values[, createNewOn]) 
     349.. function:: Orange.data.variable.make(name, type, ordered_values, unordered_values[, create_new_on]) 
    350350 
    351351    Find and return an existing variable or create a new one if none existing 
    352352    variables matches the given name, type and values. 
    353353     
    354     The optional `createOnNew` specifies the status at which a new variable is 
     354    The optional `create_new_on` specifies the status at which a new variable is 
    355355    created. The status must be at most ``Incompatible`` since incompatible (or 
    356356    non-existing) variables cannot be reused. If it is set lower, for instance  
     
    360360     
    361361    The function returns a tuple containing a variable descriptor and the 
    362     status of the best matching variable. So, if ``createOnNew`` is set to 
     362    status of the best matching variable. So, if ``create_new_on`` is set to 
    363363    ``MissingValues``, and there exists a variable whose status is, say, 
    364364    ``UnrecognizedValues``, a variable would be created, while the second  
     
    368368    indicator whether the returned variable is reused or not. This can be, 
    369369    however, read from the status code: if it is smaller than the specified 
    370     ``createNewOn``, the variable is reused, otherwise we got a new descriptor. 
    371  
    372     The exception to the rule is when ``createNewOn`` is OK. In this case, the  
     370    ``create_new_on``, the variable is reused, otherwise we got a new descriptor. 
     371 
     372    The exception to the rule is when ``create_new_on`` is OK. In this case, the  
    373373    function does not search through the existing attributes and cannot know the  
    374374    status, so the returned status in this case is always ``OK``. 
     
    380380    :param unordered_values: a list of values, for which the order does not 
    381381        matter 
    382     :param createNewOn: gives condition for constructing a new variable instead 
     382    :param create_new_on: gives condition for constructing a new variable instead 
    383383        of using the new one 
    384384     
    385385    :return_type: a tuple (:class:`Orange.data.variable.Variable`, int) 
    386386     
    387 .. function:: Orange.data.variable.retrieve(name, type, ordered_values, onordered_values[, createNewOn]) 
     387.. function:: Orange.data.variable.retrieve(name, type, ordered_values, onordered_values[, create_new_on]) 
    388388 
    389389    Find and return an existing variable, or :obj:`None` if no match is found. 
     
    395395    :param unordered_values: a list of values, for which the order does not 
    396396        matter 
    397     :param createNewOn: gives condition for constructing a new variable instead 
     397    :param create_new_on: gives condition for constructing a new variable instead 
    398398        of using the new one 
    399399 
Note: See TracChangeset for help on using the changeset viewer.