1515# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1616#
1717
18+ import logging
1819
1920from cluster .cluster import Cluster
2021from cluster .method .base import BaseClusterMethod
2122from cluster .util import median , mean , genmatrix
2223
2324
25+ logger = logging .getLogger (__name__ )
26+
27+
2428class HierarchicalClustering (BaseClusterMethod ):
2529 """
2630 Implementation of the hierarchical clustering method as explained in
@@ -37,15 +41,17 @@ class HierarchicalClustering(BaseClusterMethod):
3741 Note that all of the returned clusters are more that 90 apart
3842 """
3943
40- def __init__ (self , data , distance_function , linkage = 'single' ):
44+ def __init__ (self , data , distance_function , linkage = None ):
4145 """
4246 Constructor
4347
4448 See BaseClusterMethod.__init__ for more details.
4549 """
50+ if not linkage :
51+ linkage = 'single'
52+ logger .info ("Initializing HierarchicalClustering object with linkage method %s" ,
53+ linkage )
4654 BaseClusterMethod .__init__ (self , data , distance_function )
47-
48- # set the linkage type to single
4955 self .set_linkage_method (linkage )
5056 self .__cluster_created = False
5157
@@ -199,6 +205,7 @@ def cluster(self, matrix=None, level=None, sequence=None):
199205 level - The current level of clustering
200206 sequence - The sequence number of the clustering
201207 """
208+ logger .info ("Performing cluster()" )
202209
203210 if matrix is None :
204211 # create level 0, first iteration (sequence)
@@ -247,6 +254,7 @@ def cluster(self, matrix=None, level=None, sequence=None):
247254
248255 # all the data is in one single cluster. We return that and stop
249256 self .__cluster_created = True
257+ logger .info ("Call to cluster() is complete" )
250258 return
251259
252260 def getlevel (self , threshold ):
0 commit comments