From c978b1804f4ac89e75ed01e035d848bb41e9bd86 Mon Sep 17 00:00:00 2001 From: Karthik Date: Mon, 9 Nov 2026 22:44:44 -0500 Subject: [PATCH] Migrate RNG comparisons to assert_allclose --- tests/test_rng.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/test_rng.py b/tests/test_rng.py index 5a58fc17d..878b6b666 100644 --- a/tests/test_rng.py +++ b/tests/test_rng.py @@ -23,11 +23,10 @@ def test_random(): assert rng.RNG.rand() == 0.5488135039273248 assert rng.RNG.randint(1_000_000) == 435829 assert rng.RNG.uniform(0, 1_000_000) == 844265.7485810174 - npt.assert_almost_equal( - rng.RNG.permutation([10, 20, 30, 40, 50]), [10, 30, 20, 50, 40] - ) - npt.assert_almost_equal( - rng.RNG.choice([10, 20, 30, 40, 50], 10, replace=True), - [30, 50, 10, 10, 50, 30, 20, 10, 20, 20], - ) + ref_permutation = [10, 30, 20, 50, 40] + cmp_permutation = rng.RNG.permutation([10, 20, 30, 40, 50]) + npt.assert_allclose(cmp_permutation, ref_permutation, atol=1.5e-07) + ref_choices = [30, 50, 10, 10, 50, 30, 20, 10, 20, 20] + cmp_choices = rng.RNG.choice([10, 20, 30, 40, 50], 10, replace=True) + npt.assert_allclose(cmp_choices, ref_choices, atol=1.5e-07) assert rng.RNG.normal() == 0.44386323274542566