diff --git a/energyplus_regressions/__init__.py b/energyplus_regressions/__init__.py index 27b5621..3485064 100644 --- a/energyplus_regressions/__init__.py +++ b/energyplus_regressions/__init__.py @@ -1,2 +1,2 @@ NAME = 'energyplus_regressions' -VERSION = '2.1.5' +VERSION = '2.1.6' diff --git a/energyplus_regressions/diffs/table_diff.py b/energyplus_regressions/diffs/table_diff.py index c509270..6930d1b 100755 --- a/energyplus_regressions/diffs/table_diff.py +++ b/energyplus_regressions/diffs/table_diff.py @@ -100,6 +100,8 @@ def thresh_abs_rel_diff(abs_thresh: float, rel_thresh: float, x: str, y: str) -> try: fx = float(x) fy = float(y) + if fx == fy: + return 0, 0, 'equal' abs_diff = abs(fx - fy) rel_diff = abs((fx - fy) / fx) if abs(fx) > abs(fy) else abs((fy - fx) / fy) diff = 'equal' diff --git a/energyplus_regressions/tests/diffs/tbl_resources/eplustbl_no_diff_different_spaces_base.htm b/energyplus_regressions/tests/diffs/tbl_resources/eplustbl_no_diff_different_spaces_base.htm new file mode 100644 index 0000000..dfac1a1 --- /dev/null +++ b/energyplus_regressions/tests/diffs/tbl_resources/eplustbl_no_diff_different_spaces_base.htm @@ -0,0 +1,100 @@ + + + + Bldg DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB ** + 2018-11-20 + 17:26:37 + - EnergyPlus + + + +

Table of Contents

+ +

Program Version:EnergyPlus, Version 9.0.1-a7c9cc14ce, YMD=2018.11.20 17:26

+

Tabular Output Report in Format: HTML

+

Building: Bldg

+

Environment: DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB **

+

Simulation Timestamp: 2018-11-20 + 17:26:37

+
+

Table of Contents

+ +

Report: Annual Building Utility Performance Summary

+

For: Entire Facility

+

Timestamp: 2018-11-20 + 17:26:37

+Values gathered over 0.00 hours

+WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.

+

+Site and Source Energy

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Total Energy [GJ]Energy Per Total Building Area [MJ/m2]Energy Per Conditioned Building Area [MJ/m2]
Total Site Energy 0.00 0.00 0.00
Net Site Energy 0.00 0.00 0.00
Total Source Energy 0.00 0.00 0.00
Net Source Energy 0.00 0.00 0.00
+

+Site to Source Energy Conversion Factors

+ + + + + + + + + + + + + +
Site=>Source Conversion Factor
Electricity 3.167
Natural Gas 1.084
+

+Building Area

+ + + + + + + + + + + + + + + + + +
Area [m2]
Total Building Area 232.26
Net Conditioned Building Area 232.26
Unconditioned Building Area 0.00
+

+ + diff --git a/energyplus_regressions/tests/diffs/tbl_resources/eplustbl_no_diff_different_spaces_mod.htm b/energyplus_regressions/tests/diffs/tbl_resources/eplustbl_no_diff_different_spaces_mod.htm new file mode 100644 index 0000000..d2fdcf7 --- /dev/null +++ b/energyplus_regressions/tests/diffs/tbl_resources/eplustbl_no_diff_different_spaces_mod.htm @@ -0,0 +1,100 @@ + + + + Bldg DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB ** + 2018-11-20 + 17:26:37 + - EnergyPlus + + + +

Table of Contents

+ +

Program Version:EnergyPlus, Version 9.0.1-a7c9cc14ce, YMD=2018.11.20 17:26

+

Tabular Output Report in Format: HTML

+

Building: Bldg

+

Environment: DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB **

+

Simulation Timestamp: 2018-11-20 + 17:26:37

+
+

Table of Contents

+ +

Report: Annual Building Utility Performance Summary

+

For: Entire Facility

+

Timestamp: 2018-11-20 + 17:26:37

+Values gathered over 0.00 hours

+WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.

+

+Site and Source Energy

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Total Energy [GJ]Energy Per Total Building Area [MJ/m2]Energy Per Conditioned Building Area [MJ/m2]
Total Site Energy 0.00 0.00 0.00
Net Site Energy 0.00 0.00 0.00
Total Source Energy 0.00 0.00 0.00
Net Source Energy 0.00 0.00 0.00
+

+Site to Source Energy Conversion Factors

+ + + + + + + + + + + + + +
Site=>Source Conversion Factor
Electricity 3.167
Natural Gas 1.084
+

+Building Area

+ + + + + + + + + + + + + + + + + +
Area [m2]
Total Building Area 232.26
Net Conditioned Building Area 232.26
Unconditioned Building Area 0.00
+

+ + diff --git a/energyplus_regressions/tests/diffs/test_table_diff.py b/energyplus_regressions/tests/diffs/test_table_diff.py index cd6999d..20910e4 100644 --- a/energyplus_regressions/tests/diffs/test_table_diff.py +++ b/energyplus_regressions/tests/diffs/test_table_diff.py @@ -34,6 +34,26 @@ def test_identical_files(self): self.assertEqual(0, response[7]) # in file 2 but not in file 1 self.assertEqual(0, response[8]) # in file 1 but not in file 2 + def test_files_with_different_spaces(self): + response = table_diff( + self.thresh_dict, + os.path.join(self.diff_files_dir, 'eplustbl_no_diff_different_spaces_base.htm'), + os.path.join(self.diff_files_dir, 'eplustbl_no_diff_different_spaces_mod.htm'), + os.path.join(self.temp_output_dir, 'abs_diff.htm'), + os.path.join(self.temp_output_dir, 'rel_diff.htm'), + os.path.join(self.temp_output_dir, 'math_diff.log'), + os.path.join(self.temp_output_dir, 'summary.htm'), + ) + self.assertEqual('', response[0]) # diff status + self.assertEqual(3, response[1]) # count_of_tables + self.assertEqual(0, response[2]) # big diffs + self.assertEqual(0, response[3]) # small diffs + self.assertEqual(17, response[4]) # equals + self.assertEqual(0, response[5]) # string diffs + self.assertEqual(0, response[6]) # size errors + self.assertEqual(0, response[7]) # in file 2 but not in file 1 + self.assertEqual(0, response[8]) # in file 1 but not in file 2 + def test_skips_some_tables(self): response = table_diff( self.thresh_dict,