[Git][NTPsec/ntpsec][master] ntpviz: return 0 as variance of zero or one data items.
Gary E. Miller
gitlab at mg.gitlab.com
Wed Oct 5 20:31:05 UTC 2016
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
d734d4a8 by Gary E. Miller at 2016-10-05T13:29:57-07:00
ntpviz: return 0 as variance of zero or one data items.
No need to crash on empty input.
- - - - -
1 changed file:
- ntpstats/ntpviz
Changes:
=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -57,7 +57,8 @@ def pstdev(data, mu=None):
"""Calculates the population standard deviation."""
n = len(data)
if n < 2:
- raise ValueError('variance requires at least two data points')
+ # variance requires at least two data points
+ return 0
ss = _ss(data, mu)
pvar = ss/n # the population variance
return pvar**0.5
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d734d4a8d04995a88f5cca28bf30a2fc7370cede
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161005/c05d9b36/attachment.html>
More information about the vc
mailing list