From 507617657778a10a3700c69bde1f49aaca7c0cb6 Mon Sep 17 00:00:00 2001 From: Daniel Bauer <daniel.j.bauer@fau.de> Date: Wed, 22 Jan 2025 14:16:16 +0100 Subject: [PATCH] always compare non-rounded values in floating to floating conversion --- tests/kernelcreation/test_type_cast.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/kernelcreation/test_type_cast.py b/tests/kernelcreation/test_type_cast.py index a88adbf78..8ad6d8670 100644 --- a/tests/kernelcreation/test_type_cast.py +++ b/tests/kernelcreation/test_type_cast.py @@ -61,8 +61,13 @@ def test_type_cast(gen_config, xp, from_type, to_type): kfunc = kernel.compile() kfunc(inp=inp, outp=outp) - # rounding mode depends on platform - try: + if np.issubdtype(from_type, np.floating) and not np.issubdtype( + to_type, np.floating + ): + # rounding mode depends on platform + try: + xp.testing.assert_array_equal(outp, truncated) + except AssertionError: + xp.testing.assert_array_equal(outp, rounded) + else: xp.testing.assert_array_equal(outp, truncated) - except AssertionError: - xp.testing.assert_array_equal(outp, rounded) -- GitLab