Spostata importazione della libreria pylab che ci mette un sacco di tempo

Leonardo [2010-04-07 07:40]
Spostata importazione della libreria pylab che ci mette un sacco di tempo
solo nel posto in cui serve.
Filename
Filtering/dwt.py
diff --git a/Filtering/dwt.py b/Filtering/dwt.py
index e3a3419..fda5204 100755
--- a/Filtering/dwt.py
+++ b/Filtering/dwt.py
@@ -69,11 +69,6 @@ LoadingLibrariesStarted()

 # Importing libraries
 try:
-    from pylab import show, plot, title, xlabel, ylabel, rcParams
-except ImportError:
-    print "Errore nell'importazione della libreria pylab. Installare python-matplotlib"
-    sys.exit(1)
-try:
     from numpy import array, sqrt, memmap, roll, inf
     from numpy.linalg import norm
 except ImportError:
@@ -81,13 +76,6 @@ except ImportError:
     sys.exit(1)
 import time
 import Filtering
-
-params = {
-    "text.usetex": True,
-    'font.family': 'serif',
-}
-
-rcParams.update(params)



@@ -184,6 +172,24 @@ class DWT():
         """
         Shows the result of filtering
         """
+
+        # Carichiamo la libreria pylab che non abbiamo caricato prima
+        # perché ci mette un sacco di tempo e non ci server nel caso
+        # della ricostruzione.
+        try:
+            from pylab import show, plot, title, xlabel, ylabel, rcParams
+
+            params = {
+                "text.usetex": True,
+                'font.family': 'serif',
+                }
+
+            rcParams.update(params)
+
+        except ImportError:
+            print "Errore nell'importazione della libreria pylab. Installare python-matplotlib"
+            sys.exit(1)
+

         # We set the frequency to have seconds (and not samples)
         # in the x-axis of the plot.
ViewGit