From 407b6124e1b37c3ab4987d836c1d300f35a6f1b6 Mon Sep 17 00:00:00 2001 From: shBLOCK <3332908658@qq.com> Date: Fri, 6 Oct 2023 09:09:09 +0800 Subject: [PATCH] Lower tolerances of is_close() as we're using 64bit floats now --- codegen/templates/common_utils.pyx | 4 ++-- tests/test_transform_3d.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codegen/templates/common_utils.pyx b/codegen/templates/common_utils.pyx index 93eff1a..5fe9441 100644 --- a/codegen/templates/common_utils.pyx +++ b/codegen/templates/common_utils.pyx @@ -7,8 +7,8 @@ ctypedef long long py_int ctypedef long double py_float -DEF DEFAULT_RELATIVE_TOLERANCE = 1e-5 -DEF DEFAULT_ABSOLUTE_TOLERANCE = 1e-14 +DEF DEFAULT_RELATIVE_TOLERANCE = 1e-09 +DEF DEFAULT_ABSOLUTE_TOLERANCE = 1e-15 cdef inline bint is_close(py_float a, py_float b, py_float rel_tol = DEFAULT_RELATIVE_TOLERANCE, py_float abs_tol = DEFAULT_ABSOLUTE_TOLERANCE) noexcept: diff --git a/tests/test_transform_3d.py b/tests/test_transform_3d.py index aac17c4..5daefb6 100644 --- a/tests/test_transform_3d.py +++ b/tests/test_transform_3d.py @@ -47,7 +47,7 @@ def test_translation_constructor(): def test_rotating_constructor(): t = Transform3D.rotating(Vec3(1.85, 9.23, 3.42).normalized, 1.98) - assert t.is_close(Transform3D(-0.350185, 0.551229, -0.757309, -0.075323, 0.789313, 0.609353, 0.933647, 0.270429, -0.234886, 0, 0, 0)) + assert t.is_close(Transform3D(-0.350185, 0.551229, -0.757309, -0.075323, 0.789313, 0.609353, 0.933647, 0.270429, -0.234886, 0, 0, 0), rel_tol=1e-5) def test_scaling_constructor(): t = Transform3D.scaling(Vec3(1, 2, 3))