diff --git a/tests/kernelcreation/test_type_cast.py b/tests/kernelcreation/test_type_cast.py index cfead924cb5e641b94efad07d8f637e412ee6541..a88adbf78e0b16f56fbd05f70316004f7c4356dc 100644 --- a/tests/kernelcreation/test_type_cast.py +++ b/tests/kernelcreation/test_type_cast.py @@ -43,10 +43,14 @@ target_and_dtype = pytest.mark.parametrize( @target_and_dtype def test_type_cast(gen_config, xp, from_type, to_type): - inp = xp.array([-1, 0, 1, 3, -5, -312], dtype=from_type) + if np.issubdtype(from_type, np.floating): + inp = xp.array([-1.25, -0, 1.5, 3, -5, -312, 42, 6.625, -9], dtype=from_type) + else: + inp = xp.array([-1, 0, 1, 3, -5, -312, 42, 6, -9], dtype=from_type) outp = xp.zeros_like(inp).astype(to_type) - reference = inp.astype(to_type) + truncated = inp.astype(to_type) + rounded = xp.round(inp).astype(to_type) inp_field = Field.create_from_numpy_array("inp", inp) outp_field = Field.create_from_numpy_array("outp", outp) @@ -57,4 +61,8 @@ def test_type_cast(gen_config, xp, from_type, to_type): kfunc = kernel.compile() kfunc(inp=inp, outp=outp) - xp.testing.assert_array_equal(outp, reference) + # rounding mode depends on platform + try: + xp.testing.assert_array_equal(outp, truncated) + except AssertionError: + xp.testing.assert_array_equal(outp, rounded)