From ad9df26fbae240d4d88fc87b5087c41de3a59aaf Mon Sep 17 00:00:00 2001 From: geohotstan <135171913+geohotstan@users.noreply.github.com> Date: Sun, 24 Nov 2024 20:31:34 +0800 Subject: [PATCH] add test for inconsistent behavior in float to int casting (#7870) * found teeny bug * no healthcheck * change function name --- test/test_dtype_alu.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_dtype_alu.py b/test/test_dtype_alu.py index 82395036f5..7d33278d33 100644 --- a/test/test_dtype_alu.py +++ b/test/test_dtype_alu.py @@ -173,5 +173,12 @@ class TestDTypeALU(unittest.TestCase): @given(ht.int32, strat.sampled_from(dtypes_float+dtypes_int+dtypes_bool)) def test_int32_cast(self, a, dtype): universal_test_cast(a, dtypes.int32, dtype) + @unittest.expectedFailure + def test_unsafe_cast_float_to_int_failure(self): + val = float(dtypes.max(dtypes.int32) - 1) + t1 = Tensor([val], dtype=dtypes.float32).cast(dtypes.int32) + t2 = Tensor(val, dtype=dtypes.float32).cast(dtypes.int32) + np.testing.assert_equal(t1.item(), t2.item()) + if __name__ == '__main__': unittest.main()