Skip to content
Permalink
Browse files

Fix crash when calculating basic stats on a column of zeros

git-svn-id: http://svn.osgeo.org/qgis/trunk@10409 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer
cfarmer committed Mar 23, 2009
1 parent 60611ef commit 65d9220ae0548d4d6eab7c6eb151b27ebdddd7de
Showing with 10 additions and 5 deletions.
  1. +10 −5 python/plugins/fTools/tools/doVisual.py
@@ -185,11 +185,16 @@ def basic_statistics( self, vlayer, myField ):
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 ) )

0 comments on commit 65d9220

Please sign in to comment.
You can’t perform that action at this time.