[GRASS-SVN] r71144 - grass-addons/grass7/temporal/t.rast.what.aggr

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 26 04:46:22 PDT 2017


Author: lucadelu
Date: 2017-05-26 04:46:21 -0700 (Fri, 26 May 2017)
New Revision: 71144

Modified:
   grass-addons/grass7/temporal/t.rast.what.aggr/t.rast.what.aggr.py
Log:
t.rast.what.aggr: moved scipy library where is needed so not all methods require it

Modified: grass-addons/grass7/temporal/t.rast.what.aggr/t.rast.what.aggr.py
===================================================================
--- grass-addons/grass7/temporal/t.rast.what.aggr/t.rast.what.aggr.py	2017-05-26 10:07:05 UTC (rev 71143)
+++ grass-addons/grass7/temporal/t.rast.what.aggr/t.rast.what.aggr.py	2017-05-26 11:46:21 UTC (rev 71144)
@@ -115,7 +115,6 @@
 from datetime import timedelta
 from subprocess import PIPE as PI
 import numpy as np
-from scipy import stats
 import grass.script as gscript
 from grass.exceptions import CalledModuleError
 
@@ -127,8 +126,12 @@
     elif met == 'median':
         return np.median(vals)
     elif met == 'mode':
-        m = stats.mode(vals)
-        return m.mode[0]
+        try:
+            from scipy import stats
+            m = stats.mode(vals)
+            return m.mode[0]
+        except ImportError:
+            gscript.fatal(_("For method 'mode' you need to install scipy"))
     elif met == 'minimum':
         return vals.min()
     elif met == 'maximum':



More information about the grass-commit mailing list