Skip to content

Commit

Permalink
Fix crash when calculating basic stats on a column of zeros
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10409 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer committed Mar 23, 2009
1 parent a49e520 commit 71b85ce
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions python/plugins/fTools/tools/doVisual.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
Expand Down

0 comments on commit 71b85ce

Please sign in to comment.