Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating constants to the CODATA2018 values. #140

Merged
merged 12 commits into from
Jan 8, 2021
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/bin
/build
18 changes: 6 additions & 12 deletions tests/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import re
import subprocess
from math import isclose


floatPattern = re.compile("""(
Expand Down Expand Up @@ -45,8 +46,9 @@ def lineEquivalence(ref, trial, n, relativeError=1E-9, absoluteError=1E-10):
else:
# Look at all the floats on the lines
for rF, tF in zip(refFloats, trialFloats):
equal = fuzzyDiff(makeFloat(rF), makeFloat(tF),
relativeError, absoluteError)
equal = isclose( makeFloat(rF), makeFloat(tF),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I much prefer using a built-in function than home-grown.

rel_tol = relativeError,
abs_tol = absoluteError )
if not equal:
print("{} and {} are not equal".format(
rF[0], tF[0]))
Expand Down Expand Up @@ -82,6 +84,7 @@ def identicalLines(refLines, trialLines, diffFile,
for n, (ref, trial) in enumerate(zip(refLines, trialLines)):
equivalent = lineEquivalence(ref, trial, n,
relativeError, absoluteError)

if not equivalent:
fullEquivalence = False
writeDiff(diffFile, ref, trial, n)
Expand Down Expand Up @@ -112,15 +115,6 @@ def writeDiff(diff_file, refLine, trialLine, lineNumber):
diff_file.write("!{}".format(trialLine))


def fuzzyDiff(a, b, relativeError=1E-9, absoluteError=1E-10):
"""
fuzzDiff will compare to numbers (a and b) to see if they are identical
within the given tolerance. Returns bool.
"""
delta = max(abs(a), abs(b))*relativeError + absoluteError
return (abs(a - b) <= abs(delta))


retained_tapes = set(glob.glob('tape*'))
reference_tapes = glob.glob('referenceTape*')

Expand Down Expand Up @@ -152,7 +146,7 @@ def fuzzyDiff(a, b, relativeError=1E-9, absoluteError=1E-10):
diff_file.write("--- {} ---\n".format(trial_tape))

identical = identicalLines(
reference_lines, trial_lines, diff_file, 1E-7, 1E-7)
reference_lines, trial_lines, diff_file, 1E-9, 1e-10)
should_exit = not identical

if should_exit:
Expand Down