[Git][NTPsec/ntpsec][master] ntpclients/ntpviz.py: Fix Python 2. It has no math.isfinite().

Gary E. Miller (@garyedmundsmiller) gitlab at mg.gitlab.com
Fri Dec 13 22:24:44 UTC 2024



Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
f3a5d620 by Gary E. Miller at 2024-12-13T14:24:05-08:00
ntpclients/ntpviz.py: Fix Python 2.  It has no math.isfinite().

- - - - -


1 changed file:

- ntpclients/ntpviz.py


Changes:

=====================================
ntpclients/ntpviz.py
=====================================
@@ -203,9 +203,10 @@ class RunningStats(object):
         self.variance = sum(pow((v-self.mu), 2) for v in values) / self.num
         self.sigma = math.sqrt(self.variance)
 
-        # Note: math.isnan(float("+Inf")) is false, so avoid isnan()
-        # Use isfinite() instead.
-        if ((not math.isfinite(self.sigma) or
+        # Note: math.isnan(float("+Inf")) is false, so isnan() and isinf()
+        # Python 2 hasa no math.isfinite()
+        if ((math.isinf(self.sigma) or
+             math.isnan(self.sigma) or
              1e-12 >= abs(self.sigma))):
             # Not finite, or too small.  Punt
             self.skewness = float('nan')



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/f3a5d6206b84e1b6623c2d71596656ff47a0e2ab

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/f3a5d6206b84e1b6623c2d71596656ff47a0e2ab
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20241213/ab33b355/attachment.htm>


More information about the vc mailing list