[symfont] Make sure variance is never negative (float precision issue)

This commit is contained in:
Behdad Esfahbod 2017-02-17 15:59:31 -06:00
parent 67fdff238b
commit 5c025c6a03

View File

@ -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):