From 5c025c6a03cca2ebe3390671a81aaca28492e71c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 17 Feb 2017 15:59:31 -0600 Subject: [PATCH] [symfont] Make sure variance is never negative (float precision issue) --- Snippets/symfont.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Snippets/symfont.py b/Snippets/symfont.py index 63bb45575..a182a0c29 100755 --- a/Snippets/symfont.py +++ b/Snippets/symfont.py @@ -164,10 +164,10 @@ class GlyphStatistics(object): # Var(X) = E[X^2] - E[X]^2 @property def VarianceX(self): - return self.Moment2XX / self.Area - self.MeanX**2 + return max(0, self.Moment2XX / self.Area - self.MeanX**2) @property def VarianceY(self): - return self.Moment2YY / self.Area - self.MeanY**2 + return max(0, self.Moment2YY / self.Area - self.MeanY**2) @property def StdDevX(self):