[yoda-svn] yoda: Add abs function to eq calculation in yodadiff.

YODA Mercurial yoda at projects.hepforge.org
Tue Mar 8 23:00:01 GMT 2016


details:   https://yoda.hepforge.org/hg/yoda/rev/df54dbcfadfa
branches:  release-1-5
changeset: 1222:df54dbcfadfa
user:      Andy Buckley <andy at insectnation.org>
date:      Tue Mar 08 22:46:05 2016 +0000
description:
Add abs function to eq calculation in yodadiff.

diffs (23 lines):

--- a/ChangeLog	Tue Mar 08 22:42:41 2016 +0000
+++ b/ChangeLog	Tue Mar 08 22:46:05 2016 +0000
@@ -1,3 +1,7 @@
+2016-03-08  Andy Buckley  <andy.buckley at cern.ch>
+
+	* Add abs function to eq calculation in yodadiff.
+
 2016-02-29  Andy Buckley  <andy.buckley at cern.ch>
 
 	* Remove blocking of builds against ROOT6 -- it works fine.
--- a/bin/yodadiff	Tue Mar 08 22:42:41 2016 +0000
+++ b/bin/yodadiff	Tue Mar 08 22:46:05 2016 +0000
@@ -41,8 +41,8 @@
     if hasattr(a, "__iter__"):
         return all(eq(*pair) for pair in zip(a, b))
     ## Finally apply a tolerant numerical comparison on numeric types
-    # TODO: Be careful with values on either side of zero. Add abs tolerance "epsilon" term?
-    return (float(a) - float(b))/(float(a) + float(b)) < opts.TOL
+    # TODO: Be careful with values on either side of zero -- abs(float(a)) etc. on denom?
+    return abs(float(a) - float(b))/(float(a) + float(b)) < opts.TOL
 
 def ptstr(pt):
     vstr1 = "{x:.2g} + {ex[0]:.2g} - {ex[1]:.2g}"


More information about the yoda-svn mailing list