[QGIS Commit] r10409 - trunk/qgis/python/plugins/fTools/tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Mar 23 11:12:55 EDT 2009


Author: cfarmer
Date: 2009-03-23 11:12:55 -0400 (Mon, 23 Mar 2009)
New Revision: 10409

Modified:
   trunk/qgis/python/plugins/fTools/tools/doVisual.py
Log:
Fix crash when calculating basic stats on a column of zeros

Modified: trunk/qgis/python/plugins/fTools/tools/doVisual.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doVisual.py	2009-03-23 13:18:27 UTC (rev 10408)
+++ trunk/qgis/python/plugins/fTools/tools/doVisual.py	2009-03-23 15:12:55 UTC (rev 10409)
@@ -185,11 +185,16 @@
 			nElement += 1
 			self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
 		nVal= float( len( values ) )
-		meanVal = float( sumVal ) / nVal
-		for val in values:
-			stdVal += ( ( val - meanVal ) * ( val - meanVal ) )
-		stdVal = math.sqrt( stdVal / nVal )
-		cvVal = stdVal / meanVal
+		print "to here"
+		if not nVal > 0.00:
+			print "then here"
+			meanVal = float( sumVal ) / nVal
+			if not meanVal == 0.00:
+				for val in values:
+					stdVal += ( ( val - meanVal ) * ( val - meanVal ) )
+				print "finally here"
+				stdVal = math.sqrt( stdVal / nVal )
+				cvVal = stdVal / meanVal
 		lstStats = []
 		lstStats.append( "Mean    : " + unicode( meanVal ) )
 		lstStats.append( "StdDev : " + unicode( stdVal ) )



More information about the QGIS-commit mailing list