Changeset 9919:8a2a770ef3af in orange for Orange/data/io.py


Ignore:
Timestamp:
02/07/12 13:16:54 (2 years ago)
Author:
markotoplak
Branch:
default
Message:

data.variable -> feature

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/data/io.py

    r9799 r9919  
    6666The signature for the custom load functions should be 
    6767 
    68 ``load_myformat(filename, create_new_on=Variable.MakeStatus.NoRecognizedValues, **kwargs)`` 
    69      
    70 When constructing variables :obj:`Orange.data.variable.make` should  
     68``load_myformat(filename, create_new_on=Orange.feature.Descriptor.MakeStatus.NoRecognizedValues, **kwargs)`` 
     69     
     70When constructing variables :obj:`Orange.feature.Descriptor.make` should  
    7171be used with the ``create_new_on`` parameter.  
    72 :obj:`~Orange.data.variable.make` will return an attribute and the  
     72:obj:`~Orange.feature.Descriptor.make` will return an attribute and the  
    7373status of the variable, telling whether a new attribute was created  
    74 or the old one reused and why (see :mod:`Orange.data.variable`).  
     74or the old one reused and why (see :mod:`Orange.feature`).  
    7575Additional keyword arguments can be provided in the call to  
    7676:obj:`~Orange.data.Table` constructor. These will be passed in the  
     
    9090 
    9191import Orange 
    92 import Orange.data.variable 
     92import Orange.feature 
    9393import Orange.misc 
    9494from Orange.core import \ 
     
    9898 
    9999from Orange.data import variable 
    100 from Orange.data.variable import Variable 
    101 MakeStatus = Variable.MakeStatus 
     100from Orange.feature import Descriptor 
     101MakeStatus = Orange.feature.Descriptor.MakeStatus 
     102make = Orange.feature.Descriptor.make 
    102103 
    103104def loadARFF(filename, create_on_new=MakeStatus.Incompatible, **kwargs): 
     
    115116        return loadARFF_Weka(filename, create_on_new) 
    116117 
    117 def loadARFF_Weka(filename, create_on_new=Orange.data.variable.Variable.MakeStatus.Incompatible, **kwargs): 
     118def loadARFF_Weka(filename, create_on_new=MakeStatus.Incompatible, **kwargs): 
    118119    """Return class:`Orange.data.Table` containing data from file in Weka ARFF format""" 
    119120    if not os.path.exists(filename) and os.path.exists(filename + ".arff"): 
     
    190191                        if len(sy) > 0: 
    191192                            vals.append(sy) 
    192                     a, s = Variable.make(atn, Orange.data.Type.Discrete, vals, [], create_on_new) 
     193                    a, s = make(atn, Orange.data.Type.Discrete, vals, [], create_on_new) 
    193194                else: 
    194195                    # real... 
    195                     a, s = Variable.make(atn, Orange.data.Type.Continuous, [], [], create_on_new) 
     196                    a, s = make(atn, Orange.data.Type.Continuous, [], [], create_on_new) 
    196197 
    197198                attributes.append(a) 
     
    270271        f.write('%s\n' % x[-1]) 
    271272 
    272 def loadMULAN(filename, create_on_new=Orange.data.variable.Variable.MakeStatus.Incompatible, **kwargs): 
     273def loadMULAN(filename, create_on_new=MakeStatus.Incompatible, **kwargs): 
    273274    """Return class:`Orange.data.Table` containing data from file in Mulan ARFF and XML format""" 
    274275    if filename[-4:] == ".xml": 
     
    398399    attributeLoadStatus = {} 
    399400    def make_float(name): 
    400         attr, s = Orange.data.variable.make(name, Orange.data.Type.Continuous, [], [], create_on_new) 
     401        attr, s = Orange.feature.Descriptor.make(name, Orange.data.Type.Continuous, [], [], create_on_new) 
    401402        attributeLoadStatus[attr] = s 
    402403        return attr 
    403404 
    404405    def make_disc(name, unordered): 
    405         attr, s = Orange.data.variable.make(name, Orange.data.Type.Discrete, [], unordered, create_on_new) 
     406        attr, s = Orange.feature.Descriptor.make(name, Orange.data.Type.Discrete, [], unordered, create_on_new) 
    406407        attributeLoadStatus[attr] = s 
    407408        return attr 
     
    478479        return variable.Python 
    479480    elif cell == "": 
    480         return variable.Variable 
     481        return variable.Descriptor 
    481482    elif len(cell.split(",")) > 1: 
    482483        return variable.Discrete, cell.split(",") 
Note: See TracChangeset for help on using the changeset viewer.