diff --git a/taxcalc/tests/test_cpscsv.py b/taxcalc/tests/test_cpscsv.py index d1aeb9b1f..3423336d6 100644 --- a/taxcalc/tests/test_cpscsv.py +++ b/taxcalc/tests/test_cpscsv.py @@ -51,12 +51,8 @@ def test_agg(tests_path, cps_fullsample): txt = expected_file.read() expected_results = txt.rstrip('\n\t ') + '\n' # cleanup end of file txt # ensure actual and expected results have no nonsmall differences - if sys.version_info.major == 2: - small = 0.0 # tighter test for Python 2.7 - else: - small = 0.1 # looser test for Python 3.6 diffs = nonsmall_diffs(actual_results.splitlines(True), - expected_results.splitlines(True), small) + expected_results.splitlines(True)) if diffs: new_filename = '{}{}'.format(aggres_path[:-10], 'actual.txt') with open(new_filename, 'w') as new_file: diff --git a/taxcalc/tests/test_puf_var_stats.py b/taxcalc/tests/test_puf_var_stats.py index cc95a3a3d..4b51f3d38 100644 --- a/taxcalc/tests/test_puf_var_stats.py +++ b/taxcalc/tests/test_puf_var_stats.py @@ -106,7 +106,7 @@ def calculate_mean_stats(calc, table, year): table[str(year)] = means -def differences(new_filename, old_filename, stat_kind, small): +def differences(new_filename, old_filename, stat_kind, small=0.0): """ Return message string if there are differences at least as large as small; otherwise (i.e., if there are only small differences) return empty string. @@ -176,17 +176,7 @@ def test_puf_var_stats(tests_path, puf_fullsample): table_corr.to_csv(corr_path, float_format='%8.2f', columns=table_corr.index) # compare new and old CSV files for nonsmall differences - if sys.version_info.major == 2: - # tighter tests for Python 2.7 - mean_msg = differences(mean_path, mean_path[:-4], - 'MEAN', small=0.0) - corr_msg = differences(corr_path, corr_path[:-4], - 'CORR', small=0.0) - else: - # looser tests for Python 3.6 - mean_msg = differences(mean_path, mean_path[:-4], - 'MEAN', small=1.0) - corr_msg = differences(corr_path, corr_path[:-4], - 'CORR', small=0.01) + mean_msg = differences(mean_path, mean_path[:-4], 'MEAN') + corr_msg = differences(corr_path, corr_path[:-4], 'CORR') if mean_msg or corr_msg: raise ValueError(mean_msg + corr_msg) diff --git a/taxcalc/tests/test_pufcsv.py b/taxcalc/tests/test_pufcsv.py index 3f2c58744..0e10d840d 100644 --- a/taxcalc/tests/test_pufcsv.py +++ b/taxcalc/tests/test_pufcsv.py @@ -58,11 +58,7 @@ def test_agg(tests_path, puf_fullsample): expected_results = txt.rstrip('\n\t ') + '\n' # cleanup end of file txt expect = expected_results.splitlines(True) # ensure actual and expect lines have differences no more than small value - if sys.version_info.major == 2: - small = 0.0 # tighter test for Python 2.7 - else: - small = 0.1 # looser test for Python 3.6 - diffs = nonsmall_diffs(actual, expect, small) + diffs = nonsmall_diffs(actual, expect) if diffs: new_filename = '{}{}'.format(aggres_path[:-10], 'actual.txt') with open(new_filename, 'w') as new_file: diff --git a/taxcalc/utils.py b/taxcalc/utils.py index 0b1440e94..0f0dd80af 100644 --- a/taxcalc/utils.py +++ b/taxcalc/utils.py @@ -1600,11 +1600,8 @@ def dec_graph_plot(data, def nonsmall_diffs(linelist1, linelist2, small=0.0): """ Return True if line lists differ significantly; otherwise return False. - Significant difference means one or more numbers differ (between - linelist1 and linelist2) by more than the small amount. - NOTE: this function is meant to be used only in the unit tests to handle - small differences in floating point values generated by Python 2.7 and 3.6, - where a nonzero small amount is used only under Python 3.6. + Significant numerical difference means one or more numbers differ (between + linelist1 and linelist2) by more than the specified small amount. """ # embedded function used only in nonsmall_diffs function def isfloat(value):