[aligner] Use lazy import for minhashing and kdtree
authorSimon Chabot <simon.chabot@logilab.fr>
Thu, 08 Nov 2012 13:24:41 +0100
changeset 94 12123af1815e
parent 93 203140d3f9ed
child 95 8a13d62cd8ff
[aligner] Use lazy import for minhashing and kdtree
aligner.py
--- a/aligner.py	Thu Nov 08 13:24:13 2012 +0100
+++ b/aligner.py	Thu Nov 08 13:24:41 2012 +0100
@@ -19,10 +19,8 @@
 
 import csv
 
-from scipy.spatial import KDTree
 
 import alignment.matrix as m
-from alignment.minhashing import Minlsh
 
 def _autocasted(data, encoding=None):
     data = data.strip()
@@ -49,6 +47,7 @@
 
 ##### KDTree #######
     if mode == 'kdtree':
+        from scipy.spatial import KDTree
         # XXX : If there are more than 2 dimensions ??
         aligntree  = KDTree([elt[indexes[0]] or (0, 0) for elt in alignset])
         targettree = KDTree([elt[indexes[1]] or (0, 0) for elt in targetset])
@@ -56,6 +55,7 @@
 
 #### Minhashing #####
     elif mode == 'minhashing':
+        from alignment.minhashing import Minlsh
         minhasher = Minlsh()
         minhasher.train([elt[indexes[0]] or '' for elt in alignset] +
                         [elt[indexes[1]] or '' for elt in targetset],