From 0cb9daaee567369e6b1aac6f9c4b3bbdf147b02c Mon Sep 17 00:00:00 2001 From: Yash Katariya Date: Fri, 17 Jan 2020 17:06:03 -0800 Subject: [PATCH] Reduce precision in doctest. PiperOrigin-RevId: 290369404 Change-Id: I21f875991a08415f0e1d6fdeb6c3f4f1a00da3f8 --- tensorflow/tools/docs/tf_doctest_lib.py | 3 +-- tensorflow/tools/docs/tf_doctest_test.py | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tensorflow/tools/docs/tf_doctest_lib.py b/tensorflow/tools/docs/tf_doctest_lib.py index b33d14a0a40..2ba368e6fa2 100644 --- a/tensorflow/tools/docs/tf_doctest_lib.py +++ b/tensorflow/tools/docs/tf_doctest_lib.py @@ -115,8 +115,7 @@ class TfDoctestOutputChecker(doctest.OutputChecker, object): _ADDRESS_RE = re.compile(r'\bat 0x[0-9a-f]*?>') - def _allclose(self, want, got, rtol=1e-6, atol=1e-6): - # Same default as: tensorflow/python/framework/test_util.py "assertAllClose" + def _allclose(self, want, got, rtol=1e-3, atol=1e-3): return np.allclose(want, got, rtol=rtol, atol=atol) def check_output(self, want, got, optionflags): diff --git a/tensorflow/tools/docs/tf_doctest_test.py b/tensorflow/tools/docs/tf_doctest_test.py index 9d4fbc61e9f..441b9ac78f0 100644 --- a/tensorflow/tools/docs/tf_doctest_test.py +++ b/tensorflow/tools/docs/tf_doctest_test.py @@ -128,10 +128,8 @@ class TfDoctestOutputCheckerTest(parameterized.TestCase): @parameterized.parameters( # CHeck examples out of tolerence. - ['1.001e-6', [0]], - ['0.0', [1.001e-6]], - ['1.000001001e9', [1e9]], - ['1e9', [1.000001001e9]], + ['1.001e-2', [0]], + ['0.0', [1.001e-3]], ) def test_fail_tolerences(self, text, expected_floats): extract_floats = tf_doctest_lib._FloatExtractor()