[Spambayes-checkins] spambayes TestDriver.py,1.13,1.14
Tim Peters
tim_one@users.sourceforge.net
Wed, 25 Sep 2002 18:10:32 -0700
Update of /cvsroot/spambayes/spambayes
In directory usw-pr-cvs1:/tmp/cvs-serv10786
Modified Files:
TestDriver.py
Log Message:
The numerically naive way of computing the sdev for the histogram
display finally went negative on me. This isn't worth fixing right --
just call it 0 when this happens here.
Index: TestDriver.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/TestDriver.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** TestDriver.py 25 Sep 2002 18:39:17 -0000 1.13
--- TestDriver.py 26 Sep 2002 01:10:29 -0000 1.14
***************
*** 67,70 ****
--- 67,75 ----
mean = self.sum / self.n
var = self.sumsq / self.n - mean**2
+ # The vagaries of f.p. rounding can make var come out negative.
+ # There are ways to fix that, but they're too painful for this
+ # part of the code to endure.
+ if var < 0.0:
+ var = 0.0
print "%d items; mean %.2f; sdev %.2f" % (self.n, mean, sqrt(var))