From 0c0eaa7d38f668a8be5a0379562aa4fa36dbb97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AE=E0=AE=A9=E0=AF=8B=E0=AE=9C=E0=AF=8D=E0=AE=95?= =?UTF-8?q?=E0=AF=81=E0=AE=AE=E0=AE=BE=E0=AE=B0=E0=AF=8D=20=E0=AE=AA?= =?UTF-8?q?=E0=AE=B4=E0=AE=A9=E0=AE=BF=E0=AE=9A=E0=AF=8D=E0=AE=9A=E0=AE=BE?= =?UTF-8?q?=E0=AE=AE=E0=AE=BF?= Date: Tue, 11 Feb 2025 18:41:01 +0530 Subject: [PATCH 1/2] fix flaky test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: மனோஜ்குமார் பழனிச்சாமி --- tests/test_seed_behavior.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/tests/test_seed_behavior.py b/tests/test_seed_behavior.py index 7e4e71563e7d3..f5f9b3aa3a058 100644 --- a/tests/test_seed_behavior.py +++ b/tests/test_seed_behavior.py @@ -8,13 +8,13 @@ def test_seed_behavior(): - # Test with seed=None - Platform.seed_everything(None) + # Test with a specific seed + Platform.seed_everything(42) random_value_1 = random.randint(0, 100) np_random_value_1 = np.random.randint(0, 100) torch_random_value_1 = torch.randint(0, 100, (1, )).item() - Platform.seed_everything(None) + Platform.seed_everything(42) random_value_2 = random.randint(0, 100) np_random_value_2 = np.random.randint(0, 100) torch_random_value_2 = torch.randint(0, 100, (1, )).item() @@ -22,18 +22,3 @@ def test_seed_behavior(): assert random_value_1 != random_value_2 assert np_random_value_1 != np_random_value_2 assert torch_random_value_1 != torch_random_value_2 - - # Test with a specific seed - Platform.seed_everything(42) - random_value_3 = random.randint(0, 100) - np_random_value_3 = np.random.randint(0, 100) - torch_random_value_3 = torch.randint(0, 100, (1, )).item() - - Platform.seed_everything(42) - random_value_4 = random.randint(0, 100) - np_random_value_4 = np.random.randint(0, 100) - torch_random_value_4 = torch.randint(0, 100, (1, )).item() - - assert random_value_3 == random_value_4 - assert np_random_value_3 == np_random_value_4 - assert torch_random_value_3 == torch_random_value_4 From 9d16545746e79836980c1a36aead52b3908b0ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AE=E0=AE=A9=E0=AF=8B=E0=AE=9C=E0=AF=8D=E0=AE=95?= =?UTF-8?q?=E0=AF=81=E0=AE=AE=E0=AE=BE=E0=AE=B0=E0=AF=8D=20=E0=AE=AA?= =?UTF-8?q?=E0=AE=B4=E0=AE=A9=E0=AE=BF=E0=AE=9A=E0=AF=8D=E0=AE=9A=E0=AE=BE?= =?UTF-8?q?=E0=AE=AE=E0=AE=BF?= Date: Tue, 11 Feb 2025 19:31:53 +0530 Subject: [PATCH 2/2] fix condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: மனோஜ்குமார் பழனிச்சாமி --- tests/test_seed_behavior.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_seed_behavior.py b/tests/test_seed_behavior.py index f5f9b3aa3a058..c45ed6926d772 100644 --- a/tests/test_seed_behavior.py +++ b/tests/test_seed_behavior.py @@ -19,6 +19,6 @@ def test_seed_behavior(): np_random_value_2 = np.random.randint(0, 100) torch_random_value_2 = torch.randint(0, 100, (1, )).item() - assert random_value_1 != random_value_2 - assert np_random_value_1 != np_random_value_2 - assert torch_random_value_1 != torch_random_value_2 + assert random_value_1 == random_value_2 + assert np_random_value_1 == np_random_value_2 + assert torch_random_value_1 == torch_random_value_2