Ignore:
Timestamp:
02/28/11 10:06:18 (3 years ago)
Author:
markotoplak
Branch:
default
Convert:
31f3329800da487959e426276e7281c0d76eaffd
Message:

classification/tree.py fixed backward compatibility for printing and node counting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/classification/tree.py

    r7710 r7712  
    29302930        Return a string representation of a tree. 
    29312931 
    2932         :arg tree: The tree to dump to string. 
    2933         :type tree: class:`TreeClassifier` 
    29342932        :arg leafStr: The format string for printing the tree leaves. If  
    29352933          left empty, "%V (%^.2m%)" will be used for classification trees 
     
    29892987        Return the number of nodes of tree. 
    29902988        """ 
    2991         return _countNodes(self.tree if isinstance(self, _TreeClassifier) or \ 
    2992             isinstance(self, TreeClassifier) else self) 
     2989        return _countNodes(self.tree) 
    29932990 
    29942991    def count_leaves(self): 
     
    29962993        Return the number of leaves in the tree. 
    29972994        """ 
    2998         return _countLeaves(self.tree if isinstance(self, _TreeClassifier) or \ 
    2999             isinstance(self, TreeClassifier) else self) 
    3000  
    3001 dumpTree = TreeClassifier.dump 
    3002 """ An alias for :obj:`TreeClassifier.dump`. """ 
    3003  
    3004 def printTree(*a, **aa): 
    3005     """ 
    3006     Print out the tree (call :func:`dumpTree` with the same 
    3007     arguments and print out the result). 
    3008     """ 
    3009     print dumpTree(*a, **aa) 
    3010  
    3011 printTxt = printTree 
    3012 """ An alias for :func:`printTree`. Left for compatibility. """ 
    3013  
    3014 printDot = TreeClassifier.dot 
    3015 """ An alias for :obj:`TreeClassifier.dot` """ 
    3016  
    3017 dotTree = printDot 
    3018 """ An alias for :func:`printDot`. Left for compatibility. """ 
    3019  
    3020 countNodes = TreeClassifier.count_nodes 
    3021 countLeaves = TreeClassifier.count_leaves 
     2995        return _countLeaves(self.tree) 
    30222996 
    30232997def _countNodes(node): 
Note: See TracChangeset for help on using the changeset viewer.