From a64a7cdbf8c4ea06fb3d70bb633f45c83c5cd21d Mon Sep 17 00:00:00 2001 From: Mavo Date: Mon, 15 Feb 2016 11:50:21 +0100 Subject: [PATCH] Python script compatible with version 3.4 Former-commit-id: 2e78da799d9d2c0a2f6cb6df216becebf8b12ca7 --- benchmark_dft.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/benchmark_dft.py b/benchmark_dft.py index d2c43bf80..8e9a5462b 100644 --- a/benchmark_dft.py +++ b/benchmark_dft.py @@ -3,7 +3,6 @@ import os.path import subprocess import re import time -import math import argparse STORM_PATH= "/Users/mvolk/develop/dft-storm/build/src/storm-dft" @@ -92,6 +91,11 @@ def run_tool(args, quiet=False): result = output return result +def isclose(a, b, rel_tol=1e-09, abs_tol=0.0): + if a == b: + return True + return abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol) + if __name__ == "__main__": parser = argparse.ArgumentParser(description='Benchmarking DFTs via Storm') parser.add_argument('--debuglevel', type=int, default=0, help='the debug level (0=silent, 1=print benchmarks, 2=print output from storm') @@ -115,7 +119,7 @@ if __name__ == "__main__": if not parametric: # Float result = float(result) - if not math.isclose(result, float(expected_result), rel_tol=1e-05): + if not isclose(result, float(expected_result), rel_tol=1e-05): print("Wrong result on example '{}' with property '{}': result: {}, Expected: {}".format(benchmark, prop, result, expected_result)) else: correct += 1