Skip to content

Commit

Permalink
Drop use of numdiff for numerical comparison.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdswinbank committed Sep 8, 2015
1 parent 784be8f commit 5eedb13
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
4 changes: 0 additions & 4 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ If you use the "--small" run option then the corresponding output file is
named detected-sources_small.txt and the corresponding output directory is
called "output_small".

By default, we use some bespoke Python code to perform the comparison. Specify
the ``--use-numdiff`` option to ``bin/compare`` to use `Numdiff
<http://www.nongnu.org/numdiff/>`_ instead.

Included Data
-------------

Expand Down
27 changes: 2 additions & 25 deletions bin/compare
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,6 @@ def compareWithNumPy(filename, reference, tolerance):
valid = False
return valid

def compareWithNumDiff(filename, reference, tolerance, numdiffPath):
"""
Compare a generated data file to a reference by executing numdiff.
@param filename Path to input data file.
@param reference Path to reference file.
@param tolerance Tolerance.
@param numdiffPath Path to the numdiff executable.
"""
if subprocess.call([numdiffPath, filename, reference, "-a", str(tolerance), "-r", str(tolerance)]):
return False
else:
return True

def determineFlavor():
"""
Return a string representing the 'flavor' of the local system.
Expand Down Expand Up @@ -183,20 +168,12 @@ if __name__ == "__main__":
parser.add_argument('--tolerance', default=0, type=float, help="Tolerance for errors. "
"The test will fail if both the relative and absolute errors exceed the tolerance.")
parser.add_argument('--reference', type=extantFile, help="Reference data for comparison.")
parser.add_argument('--use-numdiff', action="store_true",
help="Perform comparison using external numdiff executable.")
parser.add_argument('--numdiff-path', type=extantFile, help="Path to numdiff executable.")
args = parser.parse_args()

if not args.reference:
args.reference=referenceFilename(args.filename)
if not args.use_numdiff:
result = compareWithNumPy(args.filename, args.reference, args.tolerance)
else:
if not args.numdiff_path:
args.numdiff_path = "numdiff" # Assume it's on the user's path.
result = compareWithNumDiff(args.filename, args.reference, args.tolerance, args.numdiff_path)

if result:
if compareWithNumPy(args.filename, args.reference, args.tolerance):
print("Ok.")
else:
sys.exit(1)

0 comments on commit 5eedb13

Please sign in to comment.